2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
7 # Test copy-up of lowerdir with opaque xattr set.
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.
14 # This is fixed by "ovl: don't copy up opaqueness".
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
22 status=1 # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
31 # get standard environment, filters and checks
35 # remove previous $seqres.full before test
38 # real QA test starts here
41 # Use non-default scratch underlying overlay dirs, we need to check
42 # them explicity after test.
43 _require_scratch_nocheck
45 # Remove all files from previous tests
48 # Create multiple lowerdirs and upperdir, workdir, and testdir on lowerdir
49 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
50 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
51 upperdir=$OVL_BASE_SCRATCH_MNT/upper
52 workdir=$OVL_BASE_SCRATCH_MNT/workdir
53 # When overlay inode index feature is enabled, a workdir cannot be reused
54 # with a different upperdir. workdir2 in this test is used as the workdir
55 # when lowerdir2 is used as the upperdir.
56 workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
57 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $workdir2
58 mkdir -p $lowerdir1/testdir/d
60 # mount overlay with $lowerdir2 as upperdir, and remove & recreate testdir,
61 # make testdir on $lowerdir2 opaque
62 _overlay_scratch_mount_dirs $lowerdir1 $lowerdir2 $workdir2
63 rm -rf $SCRATCH_MNT/testdir
64 mkdir -p $SCRATCH_MNT/testdir/visibledir
65 # unmount overlayfs but not base fs
66 $UMOUNT_PROG $SCRATCH_MNT
69 _overlay_check_scratch_dirs $lowerdir1 $lowerdir2 $workdir2
71 # mount overlay again, with lowerdir1 and lowerdir2 as multiple lowerdirs,
72 # and create a new file in testdir, triggers copyup from lowerdir,
73 # copyup should not copy overlayfs private xattr
74 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
75 touch $SCRATCH_MNT/testdir/visiblefile
77 # umount and mount overlay again, buggy kernel treats the copied-up dir as
78 # opaque, visibledir is not seen in merged dir.
79 $UMOUNT_PROG $SCRATCH_MNT
80 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
81 ls $SCRATCH_MNT/testdir
84 _overlay_check_scratch_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir