summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorAtin Mukherjee <amukherj@redhat.com>2016-03-31 14:58:02 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-04-05 03:46:44 -0700
commitd3c77459593255ed2c88094c8477b8a0c9ff9073 (patch)
treec686f78d9dd32551d2385896b805104368fd475c /xlators/mgmt
parentd65419677cf784599d4352d94f626823f895a18b (diff)
glusterd: build realpath post recreate of brick mount for snapshot
Commit a60c39d introduced a new field called real_path in brickinfo to hold the realpath() conversion. However at restore path for all snapshots and snapshot restored volumes the brickpath gets recreated post restoration of bricks which means the realpath () call will fail here for all the snapshots and cloned volumes. Fix is to store the realpath for snapshots and clones post recreating the brick mounts. For normal volume it would be done during retrieving the brick details from the store. Change-Id: Ia34853acddb28bcb7f0f70ca85fabcf73276ef13 BUG: 1322772 Signed-off-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-on: http://review.gluster.org/13869 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Avra Sengupta <asengupt@redhat.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c58
1 files changed, 42 insertions, 16 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 97f5147dd39..c776e4b5249 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -2385,24 +2385,34 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)
GLUSTERD_ASSIGN_BRICKID_TO_BRICKINFO (brickinfo, volinfo,
brickid++);
}
- /* By now if the brick is a local brick then it will be able to
- * resolve which is the only thing we want now for checking
- * whether the brickinfo->uuid matches with MY_UUID for realpath
- * check. Hence do not handle error
+ /* Populate brickinfo->real_path for normal volumes, for
+ * snapshot or snapshot restored volume this would be done post
+ * creating the brick mounts
*/
- (void)glusterd_resolve_brick (brickinfo);
- if (!gf_uuid_compare(brickinfo->uuid, MY_UUID)) {
- if (!realpath (brickinfo->path, abspath)) {
- gf_msg (this->name, GF_LOG_CRITICAL, errno,
- GD_MSG_BRICKINFO_CREATE_FAIL, "realpath"
- " () failed for brick %s. The "
- "underlying file system may be in bad"
- " state", brickinfo->path);
- ret = -1;
- goto out;
+ if (!volinfo->is_snap_volume &&
+ gf_uuid_is_null (volinfo->restored_from_snap)) {
+ /* By now if the brick is a local brick then it will be
+ * able to resolve which is the only thing we want now
+ * for checking whether the brickinfo->uuid matches
+ * with MY_UUID for realpath check. Hence do not handle
+ * error
+ */
+ (void)glusterd_resolve_brick (brickinfo);
+ if (!gf_uuid_compare(brickinfo->uuid, MY_UUID)) {
+ if (!realpath (brickinfo->path, abspath)) {
+ gf_msg (this->name, GF_LOG_CRITICAL,
+ errno,
+ GD_MSG_BRICKINFO_CREATE_FAIL,
+ "realpath() failed for brick %s"
+ ". The underlying file system "
+ "may be in bad state",
+ brickinfo->path);
+ ret = -1;
+ goto out;
+ }
+ strncpy (brickinfo->real_path, abspath,
+ strlen(abspath));
}
- strncpy (brickinfo->real_path, abspath,
- strlen(abspath));
}
cds_list_add_tail (&brickinfo->brick_list, &volinfo->bricks);
brick_count++;
@@ -3216,6 +3226,7 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this,
glusterd_brickinfo_t *brickinfo = NULL;
int32_t ret = -1;
struct stat st_buf = {0, };
+ char abspath[PATH_MAX] = {0};
GF_ASSERT (this);
GF_ASSERT (volinfo);
@@ -3272,6 +3283,21 @@ glusterd_recreate_vol_brick_mounts (xlator_t *this,
GD_MSG_BRK_MNTPATH_MOUNT_FAIL,
"Failed to mount brick_mount_path");
}
+ if (!gf_uuid_compare(brickinfo->uuid, MY_UUID)) {
+ if (!realpath (brickinfo->path, abspath)) {
+ gf_msg (this->name, GF_LOG_CRITICAL,
+ errno,
+ GD_MSG_BRICKINFO_CREATE_FAIL,
+ "realpath() failed for brick %s"
+ ". The underlying file system "
+ "may be in bad state",
+ brickinfo->path);
+ ret = -1;
+ goto out;
+ }
+ strncpy (brickinfo->real_path, abspath,
+ strlen(abspath));
+ }
if (brick_mount_path) {
GF_FREE (brick_mount_path);