Blob Blame History Raw
From 6380d281a86905f149a3fbdb1f9675647d086ee8 Mon Sep 17 00:00:00 2001
From: Krutika Dhananjay <kdhananj@redhat.com>
Date: Wed, 19 Jul 2017 16:14:59 +0530
Subject: [PATCH 662/675] storage/posix: Use the ret value of posix_gfid_heal()

... to make the change in commit acf8cfdf truly useful.

Without this, a race between entry creation fops and lookup
at posix layer can cause lookups to fail with ENODATA, as
opposed to ENOENT.

> Upstream: https://review.gluster.org/17821
> BUG: 1472758
> Change-Id: I44a226872283a25f1f4812f03f68921c5eb335bb

Change-Id: I44a226872283a25f1f4812f03f68921c5eb335bb
BUG: 1583464
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/140383
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 xlators/storage/posix/src/posix-helpers.c | 16 +++++++---------
 xlators/storage/posix/src/posix.c         |  7 ++++++-
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index ad3639a..073465b 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1540,23 +1540,21 @@ posix_gfid_heal (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req
         struct stat  stat = {0, };
 
         if (!xattr_req)
-                goto out;
+                return 0;
 
-        if (sys_lstat (path, &stat) != 0)
-                goto out;
+        if (sys_lstat (path, &stat) != 0) {
+                return -errno;
+        }
 
         ret = sys_lgetxattr (path, GFID_XATTR_KEY, uuid_curr, 16);
         if (ret != 16) {
                 if (is_fresh_file (&stat)) {
-                        ret = -1;
-                        errno = ENOENT;
-                        goto out;
+                        return -ENOENT;
                 }
         }
 
-        ret = posix_gfid_set (this, path, loc, xattr_req);
-out:
-        return ret;
+        posix_gfid_set (this, path, loc, xattr_req);
+        return 0;
 }
 
 
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 331461c..d499e09 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -190,7 +190,12 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
                 MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &buf);
 
                 if (gf_uuid_is_null (loc->inode->gfid)) {
-                        posix_gfid_heal (this, real_path, loc, xdata);
+                        op_ret = posix_gfid_heal (this, real_path, loc, xdata);
+                        if (op_ret < 0) {
+                                op_errno = -op_ret;
+                                op_ret = -1;
+                                goto out;
+                        }
                         MAKE_ENTRY_HANDLE (real_path, par_path, this,
                                            loc, &buf);
                 }
-- 
1.8.3.1