|
|
d1681e |
From 960ecba01a057ff8a2fc356624720904419e7f49 Mon Sep 17 00:00:00 2001
|
|
|
d1681e |
From: Ravishankar N <ravishankar@redhat.com>
|
|
|
d1681e |
Date: Tue, 16 Jan 2018 10:16:41 +0530
|
|
|
d1681e |
Subject: [PATCH 129/139] posix: delete stale gfid handles in nameless lookup
|
|
|
d1681e |
|
|
|
d1681e |
..in order for self-heal of symlinks to work properly (see BZ for
|
|
|
d1681e |
details).
|
|
|
d1681e |
|
|
|
d1681e |
Backport of https://review.gluster.org/#/c/19070/
|
|
|
d1681e |
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
|
|
|
d1681e |
|
|
|
d1681e |
Change-Id: I9a011d00b07a690446f7fd3589e96f840e8b7501
|
|
|
d1681e |
BUG: 1527309
|
|
|
d1681e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/127739
|
|
|
d1681e |
Tested-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
|
|
|
d1681e |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
d1681e |
Reviewed-by: Ashish Pandey <aspandey@redhat.com>
|
|
|
d1681e |
Reviewed-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
|
|
|
d1681e |
---
|
|
|
d1681e |
tests/bugs/heal-symlinks.t | 65 +++++++++++++++++++++++++++++++++++++++
|
|
|
d1681e |
xlators/storage/posix/src/posix.c | 17 +++++++++-
|
|
|
d1681e |
2 files changed, 81 insertions(+), 1 deletion(-)
|
|
|
d1681e |
create mode 100644 tests/bugs/heal-symlinks.t
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/tests/bugs/heal-symlinks.t b/tests/bugs/heal-symlinks.t
|
|
|
d1681e |
new file mode 100644
|
|
|
d1681e |
index 0000000..ecd2b52
|
|
|
d1681e |
--- /dev/null
|
|
|
d1681e |
+++ b/tests/bugs/heal-symlinks.t
|
|
|
d1681e |
@@ -0,0 +1,65 @@
|
|
|
d1681e |
+#!/bin/bash
|
|
|
d1681e |
+. $(dirname $0)/../include.rc
|
|
|
d1681e |
+. $(dirname $0)/../volume.rc
|
|
|
d1681e |
+. $(dirname $0)/../afr.rc
|
|
|
d1681e |
+cleanup;
|
|
|
d1681e |
+
|
|
|
d1681e |
+###############################################################################
|
|
|
d1681e |
+TEST glusterd
|
|
|
d1681e |
+TEST pidof glusterd
|
|
|
d1681e |
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
|
|
|
d1681e |
+TEST $CLI volume set $V0 performance.stat-prefetch off
|
|
|
d1681e |
+TEST $CLI volume start $V0
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0;
|
|
|
d1681e |
+
|
|
|
d1681e |
+cd $M0
|
|
|
d1681e |
+TEST "echo hello_world > FILE"
|
|
|
d1681e |
+TEST ln -s FILE SOFTLINK
|
|
|
d1681e |
+
|
|
|
d1681e |
+# Remove symlink only (not the .glusterfs entry) and trigger named heal.
|
|
|
d1681e |
+TEST rm -f $B0/${V0}2/SOFTLINK
|
|
|
d1681e |
+TEST stat SOFTLINK
|
|
|
d1681e |
+
|
|
|
d1681e |
+# To heal and clear new-entry mark on source bricks.
|
|
|
d1681e |
+TEST $CLI volume heal $V0
|
|
|
d1681e |
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
|
|
|
d1681e |
+
|
|
|
d1681e |
+EXPECT 2 stat -c %h $B0/${V0}2/SOFTLINK
|
|
|
d1681e |
+EXPECT "hello_world" cat $B0/${V0}2/SOFTLINK
|
|
|
d1681e |
+
|
|
|
d1681e |
+cd -
|
|
|
d1681e |
+cleanup
|
|
|
d1681e |
+###############################################################################
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST glusterd
|
|
|
d1681e |
+TEST pidof glusterd
|
|
|
d1681e |
+TEST $CLI volume create $V0 disperse 3 redundancy 1 $H0:$B0/${V0}{0,1,2}
|
|
|
d1681e |
+TEST $CLI volume set $V0 performance.stat-prefetch off
|
|
|
d1681e |
+TEST $CLI volume start $V0
|
|
|
d1681e |
+
|
|
|
d1681e |
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0;
|
|
|
d1681e |
+
|
|
|
d1681e |
+cd $M0
|
|
|
d1681e |
+TEST "echo hello_world > FILE"
|
|
|
d1681e |
+TEST ln -s FILE SOFTLINK
|
|
|
d1681e |
+
|
|
|
d1681e |
+# Remove symlink only (not the .glusterfs entry) and trigger named heal.
|
|
|
d1681e |
+TEST rm -f $B0/${V0}2/SOFTLINK
|
|
|
d1681e |
+TEST stat SOFTLINK
|
|
|
d1681e |
+
|
|
|
d1681e |
+# To heal and clear new-entry mark on source bricks.
|
|
|
d1681e |
+TEST $CLI volume heal $V0
|
|
|
d1681e |
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
|
|
|
d1681e |
+
|
|
|
d1681e |
+EXPECT 2 stat -c %h $B0/${V0}2/SOFTLINK
|
|
|
d1681e |
+TEST kill_brick $V0 $H0 $B0/${V0}0
|
|
|
d1681e |
+cd -
|
|
|
d1681e |
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
|
|
|
d1681e |
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0;
|
|
|
d1681e |
+cd $M0
|
|
|
d1681e |
+EXPECT "hello_world" cat SOFTLINK
|
|
|
d1681e |
+
|
|
|
d1681e |
+cd -
|
|
|
d1681e |
+cleanup
|
|
|
d1681e |
+###############################################################################
|
|
|
d1681e |
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
|
|
|
d1681e |
index d0433ec..8aeca3b 100644
|
|
|
d1681e |
--- a/xlators/storage/posix/src/posix.c
|
|
|
d1681e |
+++ b/xlators/storage/posix/src/posix.c
|
|
|
d1681e |
@@ -213,7 +213,10 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
|
|
|
d1681e |
dict_t * xattr = NULL;
|
|
|
d1681e |
char * real_path = NULL;
|
|
|
d1681e |
char * par_path = NULL;
|
|
|
d1681e |
+ char *gfid_path = NULL;
|
|
|
d1681e |
+ uuid_t gfid = {0};
|
|
|
d1681e |
struct iatt postparent = {0,};
|
|
|
d1681e |
+ struct stat statbuf = {0};
|
|
|
d1681e |
int32_t gfidless = 0;
|
|
|
d1681e |
char *pgfid_xattr_key = NULL;
|
|
|
d1681e |
int32_t nlink_samepgfid = 0;
|
|
|
d1681e |
@@ -267,7 +270,19 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
|
|
|
d1681e |
"lstat on %s failed",
|
|
|
d1681e |
real_path ? real_path : "null");
|
|
|
d1681e |
}
|
|
|
d1681e |
-
|
|
|
d1681e |
+ if (loc_is_nameless(loc)) {
|
|
|
d1681e |
+ if (!op_errno)
|
|
|
d1681e |
+ op_errno = ESTALE;
|
|
|
d1681e |
+ loc_gfid (loc, gfid);
|
|
|
d1681e |
+ MAKE_HANDLE_ABSPATH (gfid_path, this, gfid);
|
|
|
d1681e |
+ op_ret = sys_lstat(gfid_path, &statbuf);
|
|
|
d1681e |
+ if (op_ret == 0 && statbuf.st_nlink == 1) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_WARNING, ESTALE,
|
|
|
d1681e |
+ P_MSG_HANDLE_DELETE, "Found stale gfid "
|
|
|
d1681e |
+ "handle %s, removing it.", gfid_path);
|
|
|
d1681e |
+ posix_handle_unset (this, gfid, NULL);
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+ }
|
|
|
d1681e |
entry_ret = -1;
|
|
|
d1681e |
goto parent;
|
|
|
d1681e |
}
|
|
|
d1681e |
--
|
|
|
d1681e |
1.8.3.1
|
|
|
d1681e |
|