diff options
author | Vijaikumar M <vmallika@redhat.com> | 2014-07-31 14:37:19 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2014-08-03 07:28:52 -0700 |
commit | 8080a5555e7ba17b9e691171259899ca9e390c76 (patch) | |
tree | 9a4973fa268da88cb726017bb24d8ce013494fe4 /xlators/mgmt/glusterd/src/glusterd-store.c | |
parent | f3204a06eb8156743110b1613b4b4b63b70572b6 (diff) |
glusterd/snapshot: Inherit the mount options of a original brick
when creating snapshots
When creating a snapshot a LVM is created at the backend and is mounted
under /var/run/gluster/snaps/... However, this mount does not inherit
the mount options for the original brick acting as the parent for the
snap.
If the snap is restored, this could lead to performance degredations,
functional limitations, or in extreme scenarios even potential data
loss.
Change-Id: I67d70fd83430d83dacc5380c6c928e27fb9c9e1b
BUG: 1125180
Signed-off-by: Vijaikumar M <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/8394
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 3f241bbe53a..b2ff8c2e00e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -336,6 +336,17 @@ gd_store_brick_snap_details_write (int fd, glusterd_brickinfo_t *brickinfo) } } + if (strlen (brickinfo->mnt_opts) > 0) { + snprintf (value, sizeof (value), "%s", brickinfo->mnt_opts); + ret = gf_store_save_value (fd, + GLUSTERD_STORE_KEY_BRICK_MNTOPTS, value); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to save " + "brick mnt opts of brick %s", brickinfo->path); + goto out; + } + } + memset (value, 0, sizeof (value)); snprintf (value, sizeof(value), "%d", brickinfo->snap_status); ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_SNAP_STATUS, @@ -2318,6 +2329,10 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) strlen (GLUSTERD_STORE_KEY_BRICK_FSTYPE))) { strncpy (brickinfo->fstype, value, sizeof (brickinfo->fstype)); + } else if (!strncmp (key, GLUSTERD_STORE_KEY_BRICK_MNTOPTS, + strlen (GLUSTERD_STORE_KEY_BRICK_MNTOPTS))) { + strncpy (brickinfo->mnt_opts, value, + sizeof (brickinfo->mnt_opts)); } else if (!strncmp (key, GLUSTERD_STORE_KEY_BRICK_VGNAME, strlen (GLUSTERD_STORE_KEY_BRICK_VGNAME))) { @@ -3143,8 +3158,8 @@ out: * at the brick_mount_path */ int32_t -glusterd_mount_brick_paths (char *brick_mount_path, char *device_path, - const char *fstype) +glusterd_mount_brick_paths (char *brick_mount_path, + glusterd_brickinfo_t *brickinfo) { int32_t ret = -1; runner_t runner = {0, }; @@ -3157,7 +3172,7 @@ glusterd_mount_brick_paths (char *brick_mount_path, char *device_path, this = THIS; GF_ASSERT (this); GF_ASSERT (brick_mount_path); - GF_ASSERT (device_path); + GF_ASSERT (brickinfo); priv = this->private; GF_ASSERT (priv); @@ -3179,21 +3194,20 @@ glusterd_mount_brick_paths (char *brick_mount_path, char *device_path, */ /* Activate the snapshot */ runinit (&runner); - runner_add_args (&runner, "lvchange", "-ay", device_path, + runner_add_args (&runner, "lvchange", "-ay", brickinfo->device_path, NULL); ret = runner_run (&runner); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to activate %s. Error: %s", - device_path, strerror(errno)); + brickinfo->device_path, strerror(errno)); goto out; } else gf_log (this->name, GF_LOG_DEBUG, - "Activating %s successful", device_path); + "Activating %s successful", brickinfo->device_path); /* Mount the snapshot */ - ret = glusterd_mount_lvm_snapshot (device_path, brick_mount_path, - fstype); + ret = glusterd_mount_lvm_snapshot (brickinfo, brick_mount_path); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to mount lvm snapshot."); @@ -3266,8 +3280,7 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, /* Check if brick_mount_path is already mounted. * If not, mount the device_path at the brick_mount_path */ - ret = glusterd_mount_brick_paths (brick_mount_path, - brickinfo->device_path, brickinfo->fstype); + ret = glusterd_mount_brick_paths (brick_mount_path, brickinfo); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to mount brick_mount_path"); |