7c2869
From 6380d281a86905f149a3fbdb1f9675647d086ee8 Mon Sep 17 00:00:00 2001
7c2869
From: Krutika Dhananjay <kdhananj@redhat.com>
7c2869
Date: Wed, 19 Jul 2017 16:14:59 +0530
7c2869
Subject: [PATCH 662/675] storage/posix: Use the ret value of posix_gfid_heal()
7c2869
7c2869
... to make the change in commit acf8cfdf truly useful.
7c2869
7c2869
Without this, a race between entry creation fops and lookup
7c2869
at posix layer can cause lookups to fail with ENODATA, as
7c2869
opposed to ENOENT.
7c2869
7c2869
> Upstream: https://review.gluster.org/17821
7c2869
> BUG: 1472758
7c2869
> Change-Id: I44a226872283a25f1f4812f03f68921c5eb335bb
7c2869
7c2869
Change-Id: I44a226872283a25f1f4812f03f68921c5eb335bb
7c2869
BUG: 1583464
7c2869
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
7c2869
Reviewed-on: https://code.engineering.redhat.com/gerrit/140383
7c2869
Tested-by: RHGS Build Bot <nigelb@redhat.com>
7c2869
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
7c2869
---
7c2869
 xlators/storage/posix/src/posix-helpers.c | 16 +++++++---------
7c2869
 xlators/storage/posix/src/posix.c         |  7 ++++++-
7c2869
 2 files changed, 13 insertions(+), 10 deletions(-)
7c2869
7c2869
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
7c2869
index ad3639a..073465b 100644
7c2869
--- a/xlators/storage/posix/src/posix-helpers.c
7c2869
+++ b/xlators/storage/posix/src/posix-helpers.c
7c2869
@@ -1540,23 +1540,21 @@ posix_gfid_heal (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req
7c2869
         struct stat  stat = {0, };
7c2869
 
7c2869
         if (!xattr_req)
7c2869
-                goto out;
7c2869
+                return 0;
7c2869
 
7c2869
-        if (sys_lstat (path, &stat) != 0)
7c2869
-                goto out;
7c2869
+        if (sys_lstat (path, &stat) != 0) {
7c2869
+                return -errno;
7c2869
+        }
7c2869
 
7c2869
         ret = sys_lgetxattr (path, GFID_XATTR_KEY, uuid_curr, 16);
7c2869
         if (ret != 16) {
7c2869
                 if (is_fresh_file (&stat)) {
7c2869
-                        ret = -1;
7c2869
-                        errno = ENOENT;
7c2869
-                        goto out;
7c2869
+                        return -ENOENT;
7c2869
                 }
7c2869
         }
7c2869
 
7c2869
-        ret = posix_gfid_set (this, path, loc, xattr_req);
7c2869
-out:
7c2869
-        return ret;
7c2869
+        posix_gfid_set (this, path, loc, xattr_req);
7c2869
+        return 0;
7c2869
 }
7c2869
 
7c2869
 
7c2869
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
7c2869
index 331461c..d499e09 100644
7c2869
--- a/xlators/storage/posix/src/posix.c
7c2869
+++ b/xlators/storage/posix/src/posix.c
7c2869
@@ -190,7 +190,12 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
7c2869
                 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &buf;;
7c2869
 
7c2869
                 if (gf_uuid_is_null (loc->inode->gfid)) {
7c2869
-                        posix_gfid_heal (this, real_path, loc, xdata);
7c2869
+                        op_ret = posix_gfid_heal (this, real_path, loc, xdata);
7c2869
+                        if (op_ret < 0) {
7c2869
+                                op_errno = -op_ret;
7c2869
+                                op_ret = -1;
7c2869
+                                goto out;
7c2869
+                        }
7c2869
                         MAKE_ENTRY_HANDLE (real_path, par_path, this,
7c2869
                                            loc, &buf;;
7c2869
                 }
7c2869
-- 
7c2869
1.8.3.1
7c2869