generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 104
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 104
6 #
7 # Test that if we add hard links (in the same directory) to two files and then
8 # fsync only one of the files, after the fsync log/journal is replayed all the
9 # links exist and the filesystem metadata (directory and file inodes) is in a
10 # consistent state.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         _cleanup_flakey
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/dmflakey
29
30 # real QA test starts here
31 _supported_fs generic
32 _supported_os Linux
33 _require_scratch
34 _require_hardlinks
35 _require_dm_target flakey
36
37 rm -f $seqres.full
38
39 _scratch_mkfs >>$seqres.full 2>&1
40 _require_metadata_journaling $SCRATCH_DEV
41 _init_flakey
42 _mount_flakey
43
44 # Create our test directory and files.
45 mkdir $SCRATCH_MNT/testdir
46 touch $SCRATCH_MNT/testdir/foo
47 touch $SCRATCH_MNT/testdir/bar
48
49 # Make sure everything done so far is durably persisted.
50 sync
51
52 # Create one hard link for file foo and another one for file bar. After that
53 # fsync only the file bar.
54 ln $SCRATCH_MNT/testdir/bar $SCRATCH_MNT/testdir/bar_link
55 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/foo_link
56 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/bar
57
58 _flakey_drop_and_remount
59
60 # Now verify both our files have a link count of 2.
61 echo "Link count for file foo: $(stat -c %h $SCRATCH_MNT/testdir/foo)"
62 echo "Link count for file bar: $(stat -c %h $SCRATCH_MNT/testdir/bar)"
63
64 # We should be able to remove all the links of our files in testdir, and after
65 # that the parent directory should become empty and therefore possible to
66 # remove it.
67 rm -f $SCRATCH_MNT/testdir/*
68 rmdir $SCRATCH_MNT/testdir
69
70 _unmount_flakey
71
72 # The fstests framework will call fsck against our filesystem which will verify
73 # that all metadata is in a consistent state.
74
75 status=0
76 exit