2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Reproducer for a deadlock in xfs_rename reported by Wenli Xie.
9 # When overlayfs is running on top of xfs and the user unlinks a file in the
10 # overlay, overlayfs will create a whiteout inode and ask us to "rename" the
11 # whiteout file atop the one being unlinked. If the file being unlinked loses
12 # its one nlink, we then have to put the inode on the unlinked list.
14 # This requires us to grab the AGI buffer of the whiteout inode to take it
15 # off the unlinked list (which is where whiteouts are created) and to grab
16 # the AGI buffer of the file being deleted. If the whiteout was created in
17 # a higher numbered AG than the file being deleted, we'll lock the AGIs in
18 # the wrong order and deadlock.
20 # Note that this test doesn't do anything xfs-specific so it's a generic test.
21 # This is a regression test for commit 6da1b4b1ab36 ("xfs: fix an ABBA deadlock
25 _begin_fstest auto rw whiteout rename
27 # Override the default cleanup function.
35 # Import common functions.
38 # real QA test starts here
40 _require_attrs trusted
41 _supported_fs ^overlay
42 _require_extra_fs overlay
44 _scratch_mkfs >> $seqres.full
46 _supports_filetype $SCRATCH_MNT || _notrun "overlayfs test requires d_type"
48 mkdir $SCRATCH_MNT/lowerdir
49 mkdir $SCRATCH_MNT/lowerdir1
50 mkdir $SCRATCH_MNT/lowerdir/etc
51 mkdir $SCRATCH_MNT/workers
52 echo salts > $SCRATCH_MNT/lowerdir/etc/access.conf
53 touch $SCRATCH_MNT/running
56 test -e $SCRATCH_MNT/running || return
57 rm -f $SCRATCH_MNT/running
59 while [ "$(ls $SCRATCH_MNT/workers/ | wc -l)" -gt 0 ]; do
66 local mergedir="$SCRATCH_MNT/merged$tag"
67 local l="lowerdir=$SCRATCH_MNT/lowerdir:$SCRATCH_MNT/lowerdir1"
68 local u="upperdir=$SCRATCH_MNT/upperdir$tag"
69 local w="workdir=$SCRATCH_MNT/workdir$tag"
72 touch $SCRATCH_MNT/workers/$tag
73 while test -e $SCRATCH_MNT/running; do
74 rm -rf $SCRATCH_MNT/merged$tag
75 rm -rf $SCRATCH_MNT/upperdir$tag
76 rm -rf $SCRATCH_MNT/workdir$tag
77 mkdir $SCRATCH_MNT/merged$tag
78 mkdir $SCRATCH_MNT/workdir$tag
79 mkdir $SCRATCH_MNT/upperdir$tag
81 mount -t overlay overlay -o "$l,$u,$w,$i" $mergedir
82 mv $mergedir/etc/access.conf $mergedir/etc/access.conf.bak
83 touch $mergedir/etc/access.conf
84 mv $mergedir/etc/access.conf $mergedir/etc/access.conf.bak
85 touch $mergedir/etc/access.conf
88 rm -f $SCRATCH_MNT/workers/$tag
91 for i in $(seq 0 $((4 + LOAD_FACTOR)) ); do
95 sleep $((30 * TIME_FACTOR))
98 echo Silence is golden.