d1681e
From 395a535ec778f34e0b17150a6a37ac25790f760d Mon Sep 17 00:00:00 2001
d1681e
From: Sunny Kumar <sunkumar@redhat.com>
d1681e
Date: Wed, 22 Aug 2018 02:08:40 +0530
d1681e
Subject: [PATCH 357/359] snapshot : fix snapshot status failure due to symlink
d1681e
 problem
d1681e
d1681e
Problems : 1. Snapshot status for individual snapshots were failing after OS
d1681e
              upgrade from RHEL6 to RHEL7.
d1681e
           2. Post upgrade snapshot creation of cloned volume was failing.
d1681e
d1681e
Root Cause :  When OS upgrade is from RHEL6 to RHEL7 there is difference in
d1681e
              symlink (/var/run)  between these two versions.
d1681e
              Basically when (/var/run) is symlinked to /run, mount command
d1681e
              resolves path and mounts it. But at the same time call to
d1681e
              those functions fails who depends on absolute path.
d1681e
              (like strcmp in glusterd_get_mnt_entry_info)
d1681e
d1681e
Solution : Resolve the input path to absolute path before calling these
d1681e
           functions.
d1681e
d1681e
Test : Tested on same setup where issue was reported. After this
d1681e
       patch snapshot issues are completely resolved.
d1681e
d1681e
Upstream Patch : https://review.gluster.org/#/c/glusterfs/+/20885/
d1681e
Change-Id: I5ba57998cea614c6072709f52f42a57562018844
d1681e
BUG: 1619538
d1681e
d1681e
>fixes: bz#1619843
d1681e
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
d1681e
d1681e
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
d1681e
Change-Id: I6bc045f0baa6c858da43d6c8324ae690d76dc842
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/147812
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
d1681e
---
d1681e
 xlators/mgmt/glusterd/src/glusterd-utils.c | 10 +++++++++-
d1681e
 1 file changed, 9 insertions(+), 1 deletion(-)
d1681e
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
index 1752425..136a032 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
d1681e
@@ -7030,6 +7030,7 @@ glusterd_get_mnt_entry_info (char *mnt_pt, char *buff, int buflen,
d1681e
 {
d1681e
         struct mntent  *entry   = NULL;
d1681e
         FILE           *mtab    = NULL;
d1681e
+        char abspath[PATH_MAX] = "";
d1681e
 
d1681e
         GF_ASSERT (mnt_pt);
d1681e
         GF_ASSERT (buff);
d1681e
@@ -7039,13 +7040,20 @@ glusterd_get_mnt_entry_info (char *mnt_pt, char *buff, int buflen,
d1681e
         if (!mtab)
d1681e
                 goto out;
d1681e
 
d1681e
+        if (!realpath (mnt_pt, abspath)) {
d1681e
+                gf_msg (THIS->name, GF_LOG_ERROR, 0,
d1681e
+                        GD_MSG_MNTENTRY_GET_FAIL,
d1681e
+                        "realpath () failed for path %s", mnt_pt);
d1681e
+                goto out;
d1681e
+        }
d1681e
+
d1681e
         entry = getmntent_r (mtab, entry_ptr, buff, buflen);
d1681e
 
d1681e
         while (1) {
d1681e
                 if (!entry)
d1681e
                         goto out;
d1681e
 
d1681e
-                if (!strcmp (entry->mnt_dir, mnt_pt) &&
d1681e
+                if (!strcmp (entry->mnt_dir, abspath) &&
d1681e
                     strcmp (entry->mnt_type, "rootfs"))
d1681e
                         break;
d1681e
                 entry = getmntent_r (mtab, entry_ptr, buff, buflen);
d1681e
-- 
d1681e
1.8.3.1
d1681e