summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2018-01-16 10:16:41 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2018-01-16 20:18:35 +0000
commitd06de8e3428c2312eff74b42dafc8aab93636e2e (patch)
treedec128a5f681e49596b279d496aa950fa74cbf5a /xlators
parentdb992106c8be8a54bc0de612e7a0fe10c942c3e4 (diff)
posix: delete stale gfid handles in nameless lookup
..in order for self-heal of symlinks to work properly (see BZ for details). Backport of https://review.gluster.org/#/c/19070/ Signed-off-by: Ravishankar N <ravishankar@redhat.com> Change-Id: I9a011d00b07a690446f7fd3589e96f840e8b7501 BUG: 1534842
Diffstat (limited to 'xlators')
-rw-r--r--xlators/storage/posix/src/posix.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 93058811ff2..3b80102a9fc 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -213,7 +213,10 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
dict_t * xattr = NULL;
char * real_path = NULL;
char * par_path = NULL;
+ char *gfid_path = NULL;
+ uuid_t gfid = {0};
struct iatt postparent = {0,};
+ struct stat statbuf = {0};
int32_t gfidless = 0;
char *pgfid_xattr_key = NULL;
int32_t nlink_samepgfid = 0;
@@ -267,7 +270,19 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
"lstat on %s failed",
real_path ? real_path : "null");
}
-
+ if (loc_is_nameless(loc)) {
+ if (!op_errno)
+ op_errno = ESTALE;
+ loc_gfid (loc, gfid);
+ MAKE_HANDLE_ABSPATH (gfid_path, this, gfid);
+ op_ret = sys_lstat(gfid_path, &statbuf);
+ if (op_ret == 0 && statbuf.st_nlink == 1) {
+ gf_msg (this->name, GF_LOG_WARNING, ESTALE,
+ P_MSG_HANDLE_DELETE, "Found stale gfid "
+ "handle %s, removing it.", gfid_path);
+ posix_handle_unset (this, gfid, NULL);
+ }
+ }
entry_ret = -1;
goto parent;
}