overlay/029: fix test failure with nfs_export feature enabled
[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 _supported_os Linux
41 # Use non-default scratch underlying overlay dirs, we need to check
42 # them explicity after test.
43 _require_scratch_nocheck
44
45 # Remove all files from previous tests
46 _scratch_mkfs
47
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
59
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
67
68 # check overlayfs
69 _overlay_check_scratch_dirs $lowerdir1 $lowerdir2 $workdir2
70
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
76
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
82
83 # check overlayfs
84 _overlay_check_scratch_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
85
86 # success, all done
87 status=0
88 exit