summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2013-11-19 18:04:39 +0530
committerRaghavendra Bhat <raghavendra@redhat.com>2013-11-22 12:18:33 +0530
commitfae2c3e27037899198d8e7d83ea6aeb7f45f0ebd (patch)
treef3f7d8176a2e1244b35fbcc4a72f51b5a85666f9
parent2b8fccc75f6a4a2bc7f2e2027f92f4ecd4942f64 (diff)
mgmt/glusterd: do not use the root of the snaped device as the brick path
Suppose a volume's brick has the path /export/brick/vol/dir and lvm of that brick is mounted at /export. Now snap of that brick is taken, and is mounted on a path (say /run/gluster/snaps/<snapname>) While creating the brick for the snap volume, /run/gluster/snaps/<snapname> (i.e the mount point of the snap lvm) should not be used as the export directory. The directory path remaining after the mount point of the original lvm should be appended to the snap lvm mounted path and should be used as the export directory (ex: /run/gluster/snaps/<snapname>/brick/vol/dir in this case). Its because the volume-id of the original volume and other extended attributes wont be set on the root. It will be in the same path as the original lvm. Change-Id: I832dac8478eba1a318bdbcdf6cd8bf55b2a3261d Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 8309038..82335e8 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -2539,6 +2539,8 @@ glusterd_snap_brick_create (char *device, glusterd_volinfo_t *snap_volinfo,
char *mnt_pt = NULL;
struct mntent *entry = NULL;
FILE *mtab = NULL;
+ char *snap_brick_dir = NULL;
+ char snap_brick_path[PATH_MAX] = {0, };
this = THIS;
priv = this->private;
@@ -2569,13 +2571,30 @@ glusterd_snap_brick_create (char *device, glusterd_volinfo_t *snap_volinfo,
if (tmp[0] == '-')
tmp[0] = '/';
+ ret = glusterd_get_brick_root (original_brickinfo->path, &mnt_pt);
+ if (ret) {
+ gf_log (this->name, GF_LOG_WARNING, "could not get the root of"
+ "the brick path %s", original_brickinfo->path);
+ goto out;
+ }
+
+ if (strncmp (original_brickinfo->path, mnt_pt, strlen (mnt_pt))) {
+ gf_log (this->name, GF_LOG_WARNING, "brick: %s brick mount: %s",
+ original_brickinfo->path, mnt_pt);
+ goto out;
+ }
+
+ snap_brick_dir = &original_brickinfo->path[strlen (mnt_pt)];
+ if (snap_brick_dir)
+ snap_brick_dir++;
+
snprintf (snap_brick_mount_path, sizeof (snap_brick_mount_path),
"%s/%s%s-brick", GLUSTERD_DEFAULT_SNAPS_BRICK_DIR,
snap_volinfo->volname, tmp);
- ret = glusterd_get_brick_root (original_brickinfo->path, &mnt_pt);
- if (ret)
- goto out;
+ snprintf (snap_brick_path, sizeof (snap_brick_path), "%s/%s",
+ snap_brick_mount_path, snap_brick_dir);
+
entry = glusterd_get_mnt_entry_info (mnt_pt, mtab);
if (!entry) {
@@ -2611,7 +2630,7 @@ glusterd_snap_brick_create (char *device, glusterd_volinfo_t *snap_volinfo,
}
strcpy (snap_brickinfo->hostname, original_brickinfo->hostname);
- strcpy (snap_brickinfo->path, snap_brick_mount_path);
+ strcpy (snap_brickinfo->path, snap_brick_path);
LOCK (&snap_volinfo->lock);
{
list_add_tail (&snap_brickinfo->brick_list,
@@ -2629,6 +2648,7 @@ out:
endmntent (mtab);
gf_log ("", GF_LOG_TRACE, "Returning %d", ret);
+ GF_FREE (mnt_pt);
return ret;
}