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