glusterfs/0519-cluster-dht-Delete-invalid-linkto-files-in-rmdir.patch
Milind Changire 2f3c8edfdf autobuild v3.12.2-41
Resolves: bz#1390151 bz#1410145 bz#1429190 bz#1510752 bz#1511779
Resolves: bz#1570958 bz#1574490 bz#1595246 bz#1618669 bz#1661393
Resolves: bz#1668989 bz#1669020
Signed-off-by: Milind Changire <mchangir@redhat.com>
2019-02-11 20:46:22 -05:00

119 lines
3.7 KiB
Diff

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