fstests: add _require_hardlinks for all necessary tests
[xfstests-dev.git] / tests / generic / 498
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 498
6 #
7 # Test that if we create a new hard link for a file which was previously
8 # fsync'ed, fsync a parent directory of the new hard link and power fail,
9 # the parent directory exists after mounting the filesystem again.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         _cleanup_flakey
21         cd /
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 mkdir $SCRATCH_MNT/A
45 mkdir $SCRATCH_MNT/B
46 mkdir $SCRATCH_MNT/A/C
47 touch $SCRATCH_MNT/B/foo
48 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/B/foo
49 # It is important the new hard link is located in a hierarchy of new directories
50 # (not yet persisted).
51 ln $SCRATCH_MNT/B/foo $SCRATCH_MNT/A/C/foo
52 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/A
53
54 # Simulate a power failure and mount the filesystem to check that what we
55 # explicitly fsync'ed exists.
56 _flakey_drop_and_remount
57
58 [ -d $SCRATCH_MNT/A ] || echo "directory A missing"
59 [ -f $SCRATCH_MNT/B/foo ] || echo "file B/foo is missing"
60
61 _unmount_flakey
62
63 echo "Silence is golden"
64 status=0
65 exit