common: print hints for reasons of test failures
[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 . ./common/preamble
17 _begin_fstest auto quick copyup
18
19 # Import common functions.
20 . ./common/filter
21
22 # real QA test starts here
23 _supported_fs overlay
24 _fixed_by_kernel_commit 0956254a2d5b "ovl: don't copy up opaqueness"
25
26 # Use non-default scratch underlying overlay dirs, we need to check
27 # them explicity after test.
28 _require_scratch_nocheck
29
30 # Remove all files from previous tests
31 _scratch_mkfs
32
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
44
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
52
53 # check overlayfs
54 _overlay_check_scratch_dirs $lowerdir1 $lowerdir2 $workdir2
55
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
61
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
67
68 # check overlayfs
69 _overlay_check_scratch_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir
70
71 # success, all done
72 status=0
73 exit