overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / generic / 066
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 066
6 #
7 # This test is motivated by an fsync issue discovered in btrfs.
8 # The issue was that the fsync log replay code did not remove xattrs that were
9 # deleted before the inode was fsynced. So verify that if we delete a xattr from
10 # a file and then fsync the file, after log replay the file does not have that
11 # xattr anymore. Also test the case where a file is fsynced, one of its xattrs
12 # is removed, a hard link to that file is created and the fsync log is committed
13 # by issuing an fsync on another file. This indirect case should also result in
14 # not having the xattr anymore after the fsync log is replayed.
15 #
16 # The btrfs issue was fixed by the following linux kernel patch:
17 #
18 #  Btrfs: remove deleted xattrs on fsync log replay
19 #
20 seq=`basename $0`
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
23
24 here=`pwd`
25 tmp=/tmp/$$
26 status=1        # failure is the default!
27
28 _cleanup()
29 {
30         _cleanup_flakey
31         rm -f $tmp.*
32 }
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/filter
38 . ./common/dmflakey
39 . ./common/attr
40
41 # real QA test starts here
42 _supported_fs generic
43 _supported_os Linux
44 _require_scratch
45 _require_dm_target flakey
46 _require_attrs
47
48 rm -f $seqres.full
49
50 _scratch_mkfs >> $seqres.full 2>&1
51 _require_metadata_journaling $SCRATCH_DEV
52 _init_flakey
53 _mount_flakey
54
55 # Create out test file and add 3 xattrs to it.
56 touch $SCRATCH_MNT/foobar
57 $SETFATTR_PROG -n user.attr1 -v val1 $SCRATCH_MNT/foobar
58 $SETFATTR_PROG -n user.attr2 -v val2 $SCRATCH_MNT/foobar
59 $SETFATTR_PROG -n user.attr3 -v val3 $SCRATCH_MNT/foobar
60
61 # Make sure everything is durably persisted.
62 sync
63
64 # Now delete the second xattr and fsync the inode.
65 $SETFATTR_PROG -x user.attr2 $SCRATCH_MNT/foobar
66 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar
67
68 _flakey_drop_and_remount
69
70 # After the fsync log is replayed, the file should have only 2 xattrs, the ones
71 # named user.attr1 and user.attr3. The btrfs fsync log replay bug left the file
72 # with the 3 xattrs that we had before deleting the second one and fsyncing the
73 # file.
74 echo "xattr names and values after first fsync log replay:"
75 _getfattr --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
76
77 # Now write some data to our file, fsync it, remove the first xattr, add a new
78 # hard link to our file and commit the fsync log by fsyncing some other new
79 # file. This is to verify that after log replay our first xattr does not exist
80 # anymore.
81 echo "hello world!" >> $SCRATCH_MNT/foobar
82 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar
83 $SETFATTR_PROG -x user.attr1 $SCRATCH_MNT/foobar
84 ln $SCRATCH_MNT/foobar $SCRATCH_MNT/foobar_link
85 touch $SCRATCH_MNT/qwerty
86 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/qwerty
87
88 _flakey_drop_and_remount
89
90 # Now only the xattr with name user.attr3 should be set in our file.
91 echo "xattr names and values after second fsync log replay:"
92 _getfattr --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
93
94 status=0
95 exit