btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / overlay / 014
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
4 #
5 # FS QA Test 014
6 #
7 # Test copy-up of lowerdir with opaque xattr set.
8 #
9 # When copying up a directory with opaque xattr set, the xattr was copied up as
10 # well, after a remount the opaque flag is honored so the copied-up directory
11 # is treated as opaque, which causes files created in the lowerdir to be hidden
12 # when using multiple lower directories.
13 #
14 # This is fixed by "ovl: don't copy up opaqueness".
15 #
16 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=1        # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27         cd /
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 # Use non-default scratch underlying overlay dirs, we need to check
41 # them explicity after test.
42 _require_scratch_nocheck
43
44 # Remove all files from previous tests
45 _scratch_mkfs
46
47 # Create multiple lowerdirs and upperdir, workdir, and testdir on lowerdir
48 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
49 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
50 upperdir=$OVL_BASE_SCRATCH_MNT/upper
51 workdir=$OVL_BASE_SCRATCH_MNT/workdir
52 # When overlay inode index feature is enabled, a workdir cannot be reused
53 # with a different upperdir. workdir2 in this test is used as the workdir
54 # when lowerdir2 is used as the upperdir.
55 workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
56 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $workdir2
57 mkdir -p $lowerdir1/testdir/d
58
59 # mount overlay with $lowerdir2 as upperdir, and remove & recreate testdir,
60 # make testdir on $lowerdir2 opaque
61 _overlay_scratch_mount_dirs $lowerdir1 $lowerdir2 $workdir2
62 rm -rf $SCRATCH_MNT/testdir
63 mkdir -p $SCRATCH_MNT/testdir/visibledir
64 # unmount overlayfs but not base fs
65 $UMOUNT_PROG $SCRATCH_MNT
66
67 # check overlayfs
68 _overlay_check_scratch_dirs $lowerdir1 $lowerdir2 $workdir2
69
70 # mount overlay again, with lowerdir1 and lowerdir2 as multiple lowerdirs,
71 # and create a new file in testdir, triggers copyup from lowerdir,
72 # copyup should not copy overlayfs private xattr
73 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
74 touch $SCRATCH_MNT/testdir/visiblefile
75
76 # umount and mount overlay again, buggy kernel treats the copied-up dir as
77 # opaque, visibledir is not seen in merged dir.
78 $UMOUNT_PROG $SCRATCH_MNT
79 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
80 ls $SCRATCH_MNT/testdir
81
82 # check overlayfs
83 _overlay_check_scratch_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
84
85 # success, all done
86 status=0
87 exit