From ab27d4288997acc1b6c6bdd55a3387644eea6ecd Mon Sep 17 00:00:00 2001 From: Sunny Kumar Date: Wed, 22 Aug 2018 02:08:40 +0530 Subject: snapshot : fix snapshot status failure due to symlink problem Problems : 1. Snapshot status for individual snapshots were failing after OS upgrade from RHEL6 to RHEL7. 2. Post upgrade snapshot creation of cloned volume was failing. Root Cause : When OS upgrade is from RHEL6 to RHEL7 there is difference in symlink (/var/run) between these two versions. Basically when (/var/run) is symlinked to /run, mount command resolves path and mounts it. But at the same time call to those functions fails who depends on absolute path. (like strcmp in glusterd_get_mnt_entry_info) Solution : Resolve the input path to absolute path before calling these functions. Test : Tested on same setup where issue was reported. After this patch snapshot issues are completely resolved. Change-Id: I5ba57998cea614c6072709f52f42a57562018844 fixes: bz#1619843 Signed-off-by: Sunny Kumar --- xlators/mgmt/glusterd/src/glusterd-utils.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 06d17ea5710..87c1fcaaad1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -7027,6 +7027,7 @@ glusterd_get_mnt_entry_info (char *mnt_pt, char *buff, int buflen, { struct mntent *entry = NULL; FILE *mtab = NULL; + char abspath[PATH_MAX] = ""; GF_ASSERT (mnt_pt); GF_ASSERT (buff); @@ -7036,13 +7037,20 @@ glusterd_get_mnt_entry_info (char *mnt_pt, char *buff, int buflen, if (!mtab) goto out; + if (!realpath (mnt_pt, abspath)) { + gf_msg (THIS->name, GF_LOG_ERROR, 0, + GD_MSG_MNTENTRY_GET_FAIL, + "realpath () failed for path %s", mnt_pt); + goto out; + } + entry = getmntent_r (mtab, entry_ptr, buff, buflen); while (1) { if (!entry) goto out; - if (!strcmp (entry->mnt_dir, mnt_pt) && + if (!strcmp (entry->mnt_dir, abspath) && strcmp (entry->mnt_type, "rootfs")) break; entry = getmntent_r (mtab, entry_ptr, buff, buflen); -- cgit