|
|
887953 |
From a902a17263648180bba8a0167a221e549ba5186a Mon Sep 17 00:00:00 2001
|
|
|
887953 |
From: N Balachandran <nbalacha@redhat.com>
|
|
|
887953 |
Date: Wed, 6 Feb 2019 10:26:42 +0530
|
|
|
887953 |
Subject: [PATCH 519/529] cluster/dht: Delete invalid linkto files in rmdir
|
|
|
887953 |
|
|
|
887953 |
rm -rf <dir> fails on dirs which contain linkto files
|
|
|
887953 |
that point to themselves because dht incorrectly thought
|
|
|
887953 |
that they were cached files after looking them up.
|
|
|
887953 |
The fix now treats them as invalid linkto files
|
|
|
887953 |
and deletes them.
|
|
|
887953 |
|
|
|
887953 |
upstream master: https://review.gluster.org/#/c/glusterfs/+/22066/
|
|
|
887953 |
|
|
|
887953 |
> Change-Id: I376c72a5309714ee339c74485e02cfb4e29be643
|
|
|
887953 |
> fixes: bz#1667804
|
|
|
887953 |
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
887953 |
|
|
|
887953 |
Change-Id: Ib759907131f791e5853b2e0cb38a68d94a3efd81
|
|
|
887953 |
BUG: 1668989
|
|
|
887953 |
Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
887953 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/162342
|
|
|
887953 |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
887953 |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
887953 |
---
|
|
|
887953 |
tests/bugs/distribute/bug-1667804.t | 63 ++++++++++++++++++++++++++++++++++++
|
|
|
887953 |
xlators/cluster/dht/src/dht-common.c | 6 ++--
|
|
|
887953 |
2 files changed, 67 insertions(+), 2 deletions(-)
|
|
|
887953 |
create mode 100644 tests/bugs/distribute/bug-1667804.t
|
|
|
887953 |
|
|
|
887953 |
diff --git a/tests/bugs/distribute/bug-1667804.t b/tests/bugs/distribute/bug-1667804.t
|
|
|
887953 |
new file mode 100644
|
|
|
887953 |
index 0000000..3f7c431
|
|
|
887953 |
--- /dev/null
|
|
|
887953 |
+++ b/tests/bugs/distribute/bug-1667804.t
|
|
|
887953 |
@@ -0,0 +1,63 @@
|
|
|
887953 |
+#!/bin/bash
|
|
|
887953 |
+
|
|
|
887953 |
+. $(dirname $0)/../../include.rc
|
|
|
887953 |
+. $(dirname $0)/../../volume.rc
|
|
|
887953 |
+. $(dirname $0)/../../dht.rc
|
|
|
887953 |
+
|
|
|
887953 |
+function confirm_all_linkto_files ()
|
|
|
887953 |
+{
|
|
|
887953 |
+ inpath=$1
|
|
|
887953 |
+ for infile in $inpath/*
|
|
|
887953 |
+ do
|
|
|
887953 |
+ echo $infile
|
|
|
887953 |
+ ret1=$(is_dht_linkfile $infile)
|
|
|
887953 |
+ if [ "$ret1" -eq 0 ]; then
|
|
|
887953 |
+ echo "$infile is not a linkto file"
|
|
|
887953 |
+ echo 0
|
|
|
887953 |
+ return
|
|
|
887953 |
+ fi
|
|
|
887953 |
+ done
|
|
|
887953 |
+ echo 1
|
|
|
887953 |
+}
|
|
|
887953 |
+
|
|
|
887953 |
+cleanup;
|
|
|
887953 |
+
|
|
|
887953 |
+#Basic checks
|
|
|
887953 |
+TEST glusterd
|
|
|
887953 |
+TEST pidof glusterd
|
|
|
887953 |
+TEST $CLI volume info
|
|
|
887953 |
+
|
|
|
887953 |
+#Create a distributed volume
|
|
|
887953 |
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2};
|
|
|
887953 |
+TEST $CLI volume start $V0
|
|
|
887953 |
+
|
|
|
887953 |
+# Mount FUSE
|
|
|
887953 |
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
|
|
|
887953 |
+
|
|
|
887953 |
+#Create files and rename them in order to create linkto files
|
|
|
887953 |
+TEST mkdir -p $M0/dir0/dir1
|
|
|
887953 |
+TEST touch $M0/dir0/dir1/file-{1..50}
|
|
|
887953 |
+
|
|
|
887953 |
+for i in {1..50}; do
|
|
|
887953 |
+ mv $M0/dir0/dir1/file-$i $M0/dir0/dir1/nfile-$i;
|
|
|
887953 |
+done
|
|
|
887953 |
+
|
|
|
887953 |
+#Remove the second brick to force the creation of linkto files
|
|
|
887953 |
+#on the removed brick
|
|
|
887953 |
+
|
|
|
887953 |
+TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 start
|
|
|
887953 |
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0 $H0:$B0/${V0}2"
|
|
|
887953 |
+TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 stop
|
|
|
887953 |
+
|
|
|
887953 |
+EXPECT "1" confirm_all_linkto_files $B0/${V0}2/dir0/dir1
|
|
|
887953 |
+
|
|
|
887953 |
+#Modify the xattrs of the linkto files on the removed brick to point to itself.
|
|
|
887953 |
+
|
|
|
887953 |
+target=$(cat $M0/.meta/graphs/active/$V0-dht/subvolumes/1/name)
|
|
|
887953 |
+
|
|
|
887953 |
+setfattr -n trusted.glusterfs.dht.linkto -v "$target\0" $B0/${V0}2/dir0/dir1/nfile*
|
|
|
887953 |
+
|
|
|
887953 |
+
|
|
|
887953 |
+TEST rm -rf $M0/dir0
|
|
|
887953 |
+
|
|
|
887953 |
+cleanup;
|
|
|
887953 |
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
|
|
|
887953 |
index 767c6a8..1311a8d 100644
|
|
|
887953 |
--- a/xlators/cluster/dht/src/dht-common.c
|
|
|
887953 |
+++ b/xlators/cluster/dht/src/dht-common.c
|
|
|
887953 |
@@ -10062,8 +10062,10 @@ dht_rmdir_is_subvol_empty (call_frame_t *frame, xlator_t *this,
|
|
|
887953 |
|
|
|
887953 |
subvol = dht_linkfile_subvol (this, NULL, &trav->d_stat,
|
|
|
887953 |
trav->dict);
|
|
|
887953 |
- if (!subvol) {
|
|
|
887953 |
-
|
|
|
887953 |
+ if (!subvol || (subvol == src)) {
|
|
|
887953 |
+ /* we need to delete the linkto file if it does not
|
|
|
887953 |
+ * have a valid subvol or it points to itself.
|
|
|
887953 |
+ */
|
|
|
887953 |
gf_msg (this->name, GF_LOG_INFO, 0,
|
|
|
887953 |
DHT_MSG_INVALID_LINKFILE,
|
|
|
887953 |
"Linkfile does not have link subvolume. "
|
|
|
887953 |
--
|
|
|
887953 |
1.8.3.1
|
|
|
887953 |
|