summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-utils.c
diff options
context:
space:
mode:
authorRajesh Joseph <rjoseph@redhat.com>2014-07-01 20:25:04 +0530
committerVijay Bellur <vbellur@redhat.com>2014-07-03 06:53:12 -0700
commitdedef037d64fef59d74b9861562aa7f93857a53e (patch)
treee3ed0c288cfac75f0ece3f10a64bfa63bbb9a431 /xlators/mgmt/glusterd/src/glusterd-utils.c
parent3df72ddcdb371c441b5535ad802fc59a794e3ac9 (diff)
glusterd/snapshot: Change file-system uuid to file-system label
Problem: In XFS changing file-system UUID with xfs_admin is causing too much delay with large file-system. The time taken by xfs_admin tool to change UUID is directly proportional to the size of the file system. Cause: In XFS file-system UUID is stored in file-system superblock. Therefore for chaning UUID all the superblock needs to be changed. Fix: Instead of using file-system UUID use file-system label. Change-Id: Ifb4c668fb29cfc1c89d9b221abc8d09dc09589ec BUG: 1115107 Signed-off-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-on: http://review.gluster.org/8215 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Avra Sengupta <asengupt@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 6b973a3638d..02b2ba923e5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -612,6 +612,7 @@ glusterd_brickinfo_dup (glusterd_brickinfo_t *brickinfo,
strcpy (dup_brickinfo->hostname, brickinfo->hostname);
strcpy (dup_brickinfo->path, brickinfo->path);
strcpy (dup_brickinfo->device_path, brickinfo->device_path);
+ strcpy (dup_brickinfo->fstype, brickinfo->fstype);
ret = gf_canonicalize_path (dup_brickinfo->path);
if (ret) {
gf_log (THIS->name, GF_LOG_ERROR, "Failed to canonicalize "
@@ -710,6 +711,13 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
strncpy (new_brickinfo->device_path, value,
sizeof(new_brickinfo->device_path));
+ snprintf (key, sizeof (key), "snap%d.brick%d.fs_type",
+ volcount, brick_count);
+ ret = dict_get_str (dict, key, &value);
+ if (!ret)
+ strncpy (new_brickinfo->fstype, value,
+ sizeof(new_brickinfo->fstype));
+
/* If the brick is not of this peer, or snapshot is missed *
* for the brick do not replace the xattr for it */
if ((!uuid_compare (brickinfo->uuid, MY_UUID)) &&
@@ -2363,6 +2371,15 @@ gd_add_brick_snap_details_to_dict (dict_t *dict, char *prefix,
goto out;
}
+ snprintf (key, sizeof (key), "%s.fs_type", prefix);
+ ret = dict_set_str (dict, key, brickinfo->fstype);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set fstype for %s:%s",
+ brickinfo->hostname, brickinfo->path);
+ goto out;
+ }
+
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.mount_dir", prefix);
ret = dict_set_str (dict, key, brickinfo->mount_dir);
@@ -3695,6 +3712,7 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix,
glusterd_conf_t *conf = NULL;
char key[512] = {0,};
char *snap_device = NULL;
+ char *fs_type = NULL;
char *mount_dir = NULL;
this = THIS;
@@ -3727,6 +3745,14 @@ gd_import_new_brick_snap_details (dict_t *dict, char *prefix,
}
strcpy (brickinfo->device_path, snap_device);
+ snprintf (key, sizeof (key), "%s.fs_type", prefix);
+ ret = dict_get_str (dict, key, &fs_type);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "%s missing in payload", key);
+ goto out;
+ }
+ strcpy (brickinfo->fstype, fs_type);
+
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.mount_dir", prefix);
ret = dict_get_str (dict, key, &mount_dir);
@@ -12206,7 +12232,8 @@ glusterd_compare_volume_name(struct list_head *list1, struct list_head *list2)
}
int32_t
-glusterd_mount_lvm_snapshot (char *device_path, char *brick_mount_path)
+glusterd_mount_lvm_snapshot (char *device_path, char *brick_mount_path,
+ const char *fstype)
{
char msg[NAME_MAX] = "";
int32_t ret = -1;
@@ -12222,7 +12249,20 @@ glusterd_mount_lvm_snapshot (char *device_path, char *brick_mount_path)
runinit (&runner);
snprintf (msg, sizeof (msg), "mount %s %s",
device_path, brick_mount_path);
- runner_add_args (&runner, "mount", device_path, brick_mount_path, NULL);
+
+ /* XFS file-system does not allow to mount file-system with duplicate
+ * UUID. File-system UUID of snapshot and its origin volume is same.
+ * Therefore to mount such a snapshot in XFS we need to pass nouuid
+ * option
+ */
+ if (!strcmp (fstype, "xfs")) {
+ runner_add_args (&runner, "mount", "-o", "nouuid",
+ device_path, brick_mount_path, NULL);
+ } else {
+ runner_add_args (&runner, "mount", device_path,
+ brick_mount_path, NULL);
+ }
+
runner_log (&runner, this->name, GF_LOG_DEBUG, msg);
ret = runner_run (&runner);
if (ret) {