btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / overlay / 076
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2021 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test 076
6 #
7 # Support for chattr on overlayfs directories was added in kernel v5.10
8 # by commit 61536bed2149 ("ovl: support [S|G]ETFLAGS and FS[S|G]ETXATTR
9 # ioctls for directories").  That commit introduced a deadlock.
10 #
11 # This is a regression test for the fix commit b854cc659dcb ("ovl: avoid
12 # deadlock on directory ioctl")
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         $CHATTR_PROG -i $lowerdir/foo > /dev/null 2>&1
27         $CHATTR_PROG -i $upperdir/foo > /dev/null 2>&1
28         rm -f $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34
35 # remove previous $seqres.full before test
36 rm -f $seqres.full
37
38 # real QA test starts here
39 _supported_fs overlay
40 _require_scratch
41 _require_chattr i
42
43 # remove all files from previous runs
44 _scratch_mkfs
45
46 # prepare lower test file
47 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
48 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
49 workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
50 mkdir -p $lowerdir
51 mkdir $lowerdir/foo
52
53 # mounting overlay
54 _scratch_mount
55
56 # Try to add the immutable attributes, it will invoke ioctl() on the directory
57 # The ioctl will fail on kernel < 5.10, succeed on kernel >= 5.10.15 and hang
58 # on kernel v5.10..v5.10.14.  Anything but hang is considered a test success.
59 $CHATTR_PROG +i $SCRATCH_MNT/foo > /dev/null 2>&1
60
61 $UMOUNT_PROG $SCRATCH_MNT
62
63 # success, all done
64 echo "Silence is golden"
65 status=0
66 exit