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 _begin_fstest auto quick copyup
19 # Import common functions.
22 # real QA test starts here
24 _fixed_by_kernel_commit 0956254a2d5b "ovl: don't copy up opaqueness"
26 # Use non-default scratch underlying overlay dirs, we need to check
27 # them explicity after test.
28 _require_scratch_nocheck
30 # Remove all files from previous tests
33 # Create multiple lowerdirs and upperdir, workdir, and testdir on lowerdir
34 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
35 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
36 upperdir=$OVL_BASE_SCRATCH_MNT/upper
37 workdir=$OVL_BASE_SCRATCH_MNT/workdir
38 # When overlay inode index feature is enabled, a workdir cannot be reused
39 # with a different upperdir. workdir2 in this test is used as the workdir
40 # when lowerdir2 is used as the upperdir.
41 workdir2=$OVL_BASE_SCRATCH_MNT/workdir2
42 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir $workdir2
43 mkdir -p $lowerdir1/testdir/d
45 # mount overlay with $lowerdir2 as upperdir, and remove & recreate testdir,
46 # make testdir on $lowerdir2 opaque
47 _overlay_scratch_mount_dirs $lowerdir1 $lowerdir2 $workdir2
48 rm -rf $SCRATCH_MNT/testdir
49 mkdir -p $SCRATCH_MNT/testdir/visibledir
50 # unmount overlayfs but not base fs
51 $UMOUNT_PROG $SCRATCH_MNT
54 _overlay_check_scratch_dirs $lowerdir1 $lowerdir2 $workdir2
56 # mount overlay again, with lowerdir1 and lowerdir2 as multiple lowerdirs,
57 # and create a new file in testdir, triggers copyup from lowerdir,
58 # copyup should not copy overlayfs private xattr
59 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
60 touch $SCRATCH_MNT/testdir/visiblefile
62 # umount and mount overlay again, buggy kernel treats the copied-up dir as
63 # opaque, visibledir is not seen in merged dir.
64 $UMOUNT_PROG $SCRATCH_MNT
65 _overlay_scratch_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
66 ls $SCRATCH_MNT/testdir
69 _overlay_check_scratch_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir