summaryrefslogtreecommitdiffstats
path: root/tests/bugs/bug-1101143.t
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2014-05-23 12:51:28 +0530
committerAnand Avati <avati@redhat.com>2014-06-12 01:10:45 -0700
commitd240958fb36e652a2b910fe79414fb8b934e6158 (patch)
tree99f5357a7aa527db304ce0487fade3905de0d4c1 /tests/bugs/bug-1101143.t
parentafeaab53f6ca450a3147a6230906a83ee1bebe5a (diff)
storage/posix: Janitor should guard against dir renames.
Problem: Directory rename while a brick is down can cause gfid handle of that directory to be deleted until next lookup happens on that directory. *) Self-heal does not have intelligence to detect renames at the moment. So it has to delete the directory 'd' using special flags, because it has to perform 'rm -rf' of that directory as it is not empty. Posix xlator implements this by renaming the directory deleted to 'landfill' directory in '.glusterfs' where janitor thread will perform actual rm -rf by traversing the directory. Janitor thread wakes up every 10 minutes to check if there are any directories to be deleted and deletes them. As part of deleting it also deletes the gfid-handles. Steps to hit the problem: 1) On a replicate volume create a directory 'd', file in 'd' called 'f' so the directory 'd' is not empty. 2) bring one of the bricks down (lets call it brick-a, the other one is brick-b 3) Rename d to d1 4) When brick-a comes online again, self-heal deletes directory 'd' and creates directory 'd1' on brick-a for performing self-heal. So on brick-a, gfid-handle of 'd' pointing to 'da is deleted and recreated to point to 'd1'. 5) This directory 'b' with all its directory hierarchy (for now just the file 'f') will be under 'landfill' directory. 6) When janitor thread wakes up and deletes directory 'd' and gfid-handle of 'd' without realizing that it is now pointing to 'd1'. Thus 'd1' loses its gfid-handle Fix: Delete gfid-handle for a directory only when the gfid-handle is stale. Change-Id: I21265b3bd3852f0967d916aaa21108ae5c9e7373 BUG: 1101143 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/7879 Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Xavier Hernandez <xhernandez@datalab.es> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'tests/bugs/bug-1101143.t')
-rw-r--r--tests/bugs/bug-1101143.t83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/bugs/bug-1101143.t b/tests/bugs/bug-1101143.t
new file mode 100644
index 00000000000..a6eda0c1acd
--- /dev/null
+++ b/tests/bugs/bug-1101143.t
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+
+#This file checks if softlinks are removed or not when rename is done while
+#a brick is down in a replica pair.
+cleanup;
+
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
+TEST $CLI volume set $V0 brick-log-level DEBUG
+TEST $CLI volume start $V0
+TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0
+cd $M0
+TEST mkdir -p d1/d2/d3
+TEST mkdir -p dir1/dir1
+d1_gfid_path=$(gf_get_gfid_backend_file_path $B0/${V0}0 d1)
+d1_gfid=$(gf_get_gfid_xattr $B0/${V0}0/d1)
+dir1_gfid_path=$(gf_get_gfid_backend_file_path $B0/${V0}0 dir1)
+dir1_dir1_gfid_path=$(gf_get_gfid_backend_file_path $B0/${V0}0 dir1/dir1)
+d1_d2_d3_old_gfid_path=$(gf_get_gfid_backend_file_path $B0/${V0}0 d1/d2/d3)
+d1_d2_d3_gfid=$(gf_get_gfid_xattr $B0/${V0}0/d1/d2/d3)
+TEST kill_brick $V0 $H0 $B0/${V0}0
+
+#Rename should not delete gfid-link by janitor
+TEST mv d1 d2
+
+#Rmdir should delete gfid-link by janitor
+TEST rm -rf dir1
+
+#Stale-link will be created if we do this after self-heal where old-gfid dir will be pointing to dir with different gfid on brick-0
+TEST rmdir d2/d2/d3
+TEST mkdir d2/d2/d3
+
+TEST $CLI volume set $V0 self-heal-daemon off
+TEST $CLI volume start $V0 force
+#Wait for the brick to come up
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0
+
+#Now enable self-heal-daemon so that heal will populate landfill
+TEST $CLI volume set $V0 self-heal-daemon on
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
+TEST $CLI volume heal $V0 full
+EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0
+EXPECT_NOT "0" landfill_entry_count $B0/${V0}0
+
+#Janitor thread walks once every 10 minutes, or at the time of brick start
+#So lets stop the volume and make some checks.
+TEST $CLI volume stop $V0
+
+#Test that it is pointing to gfid which is not the old one
+TEST stat $d1_d2_d3_old_gfid_path #Check there is stale link file
+new_gfid=$(getfattr -d -m. -e hex $d1_d2_d3_old_gfid_path | grep gfid| cut -f2 -d'=')
+#Check the gfids are valid
+EXPECT 34 expr length $new_gfid
+EXPECT 34 expr length $d1_d2_d3_gfid
+EXPECT_NOT $new_gfid echo $d1_d2_d3_gfid
+
+#restart it to make sure janitor wakes up.
+TEST $CLI volume start $V0 force
+EXPECT_WITHIN $JANITOR_TIMEOUT "0" landfill_entry_count $B0/${V0}0
+
+#After janitor cleans up, check that the directories have their softlinks
+d2_gfid_path=$(gf_get_gfid_backend_file_path $B0/${V0}0 d2)
+d2_gfid=$(gf_get_gfid_xattr $B0/${V0}0/d2)
+EXPECT "$d1_gfid_path" echo $d2_gfid_path
+EXPECT "$d1_gfid" echo $d2_gfid
+TEST stat $d1_gfid_path
+
+#TODO afr-v2 is not healing sub-directories because heal is not marking
+#new-entry changelog?. Will need to fix that. After the fix, the following line
+#needs to be un-commented.
+#TEST stat $(gf_get_gfid_backend_file_path $B0/${V0}0 d2/d2)
+
+#Check that janitor removed stale links
+TEST ! stat $dir1_gfid_path
+TEST ! stat $dir1_dir1_gfid_path
+TEST ! stat $d1_d2_d3_old_gfid_path #Check stale link file is deleted
+cleanup