From 24d682bf814e0962a8f2fd2a1855ef56cb21a47c Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 31 May 2021 14:47:06 -0700 Subject: [PATCH] Add orphan-inodes test Signed-off-by: Zach Brown --- tests/funcs/filter.sh | 1 + tests/golden/orphan-inodes | 4 ++ tests/sequence | 1 + tests/tests/orphan-inodes.sh | 77 ++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 tests/golden/orphan-inodes create mode 100644 tests/tests/orphan-inodes.sh diff --git a/tests/funcs/filter.sh b/tests/funcs/filter.sh index 8f146e34..9ca9f304 100644 --- a/tests/funcs/filter.sh +++ b/tests/funcs/filter.sh @@ -71,6 +71,7 @@ t_filter_dmesg() re="$re|scoutfs .* quorum .* error" re="$re|scoutfs .* error reading quorum block" re="$re|scoutfs .* error .* writing quorum block" + re="$re|scoutfs .* error .* while checking to delete inode" egrep -v "($re)" } diff --git a/tests/golden/orphan-inodes b/tests/golden/orphan-inodes new file mode 100644 index 00000000..cb79e12d --- /dev/null +++ b/tests/golden/orphan-inodes @@ -0,0 +1,4 @@ +== test our inode existance function +== unlinked and opened inodes still exist +== orphan from failed evict deletion is picked up +== orphaned inos in all mounts all deleted diff --git a/tests/sequence b/tests/sequence index 0d709c1d..b39ac824 100644 --- a/tests/sequence +++ b/tests/sequence @@ -29,6 +29,7 @@ cross-mount-data-free.sh persistent-item-vers.sh setup-error-teardown.sh fence-and-reclaim.sh +orphan-inodes.sh mount-unmount-race.sh createmany-parallel-mounts.sh archive-light-cycle.sh diff --git a/tests/tests/orphan-inodes.sh b/tests/tests/orphan-inodes.sh new file mode 100644 index 00000000..bc55d35b --- /dev/null +++ b/tests/tests/orphan-inodes.sh @@ -0,0 +1,77 @@ +# +# make sure we clean up orphaned inodes +# + +t_require_commands sleep touch sync stat handle_cat kill rm +t_require_mounts 2 + +# +# usually bash prints an annoying output message when jobs +# are killed. We can avoid that by redirecting stderr for +# the bash process when it reaps the jobs that are killed. +# +silent_kill() { + exec {ERR}>&2 2>/dev/null + kill "$@" + wait "$@" + exec 2>&$ERR {ERR}>&- +} + +# +# We don't have a great way to test that inode items still exist. We +# don't prevent opening handles with nlink 0 today, so we'll use that. +# This would have to change to some other method. +# +inode_exists() +{ + local ino="$1" + + handle_cat "$T_M0" "$ino" > "$T_TMP.handle_cat.log" 2>&1 +} + +echo "== test our inode existance function" +path="$T_D0/file" +touch "$path" +ino=$(stat -c "%i" "$path") +inode_exists $ino || echo "$ino didn't exist" + +echo "== unlinked and opened inodes still exist" +sleep 1000000 < "$path" & +pid="$!" +rm -f "$path" +inode_exists $ino || echo "$ino didn't exist" + +echo "== orphan from failed evict deletion is picked up" +# pending kill signal stops evict from getting locks and deleting +silent_kill $pid +sleep 55 +inode_exists $ino && echo "$ino still exists" + +echo "== orphaned inos in all mounts all deleted" +pids="" +inos="" +for nr in $(t_fs_nrs); do + eval path="\$T_D${nr}/file-$nr" + touch "$path" + inos="$inos $(stat -c %i $path)" + sleep 1000000 < "$path" & + pids="$pids $!" + rm -f "$path" +done +sync +silent_kill $pids +for nr in $(t_fs_nrs); do + t_force_umount $nr +done +t_mount_all +# wait for all fence requests to complete +while test -d $(echo /sys/fs/scoutfs/*/fence/* | cut -d " " -f 1); do + sleep .5 +done +# wait for orphan scans to run +sleep 55 +for ino in $inos; do + inode_exists $ino && echo "$ino still exists" +done + +t_pass