From a8af4380c27a91e244d3202951c91ad409c08013 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Wed, 3 Jun 2015 15:18:08 +0530 Subject: snapshot: Fix finding brick mount path logic Backport of http://review.gluster.org/#/c/11060/ Previously while finding brick mount paths of snap volume's bricks, we were taking brick order into consideration. This logic fails when a brick is removed or a tier is added. Hence modifying the logic to look for the first occurence of the word "brick" in the brick path. From there we iterate till we find a '/'. The string till the first '/' after we encounter the word brick is the brick mount path. Change-Id: Ic85983c4e975e701cdfd4e13f8e276ac391a3e49 BUG: 1228592 Signed-off-by: Avra Sengupta (cherry picked from commit bf3a6dcdf3c8a8a64e7c864b56c4d9be60fca8e6) Reviewed-on: http://review.gluster.org/11100 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Rajesh Joseph Reviewed-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-store.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index cb312ae9a63..ee279d30d17 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -2972,11 +2972,10 @@ out: /* Figure out the brick mount path, from the brick path */ int32_t -glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, - char **brick_mount_path) +glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path) { - char brick_num[PATH_MAX] = ""; char *ptr = NULL; + char *save_ptr = NULL; int32_t ret = -1; xlator_t *this = NULL; @@ -2991,12 +2990,10 @@ glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, goto out; } - snprintf (brick_num, sizeof(brick_num), "brick%d", brick_count); - /* Finding the pointer to the end of * /var/run/gluster/snaps/ */ - ptr = strstr (*brick_mount_path, brick_num); + ptr = strstr (*brick_mount_path, "brick"); if (!ptr) { /* Snapshot bricks must have brick num as part * of the brickpath @@ -3011,8 +3008,13 @@ glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, * /var/run/gluster/snaps// * and assigning '\0' to it. */ - ptr += strlen(brick_num); - *ptr = '\0'; + while ((*ptr != '\0') && (*ptr != '/')) + ptr++; + + if (*ptr == '/') { + ptr++; + *ptr = '\0'; + } ret = 0; out: @@ -3096,15 +3098,12 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, char *brick_mount_path = NULL; glusterd_brickinfo_t *brickinfo = NULL; int32_t ret = -1; - int32_t brick_count = -1; struct stat st_buf = {0, }; GF_ASSERT (this); GF_ASSERT (volinfo); - brick_count = 0; cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { - brick_count++; /* If the brick is not of this node, or its * snapshot is pending, or the brick is not * a snapshotted brick, we continue @@ -3116,7 +3115,6 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this, /* Fetch the brick mount path from the brickinfo->path */ ret = glusterd_find_brick_mount_path (brickinfo->path, - brick_count, &brick_mount_path); if (ret) { gf_log (this->name, GF_LOG_ERROR, -- cgit