generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 084
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 084
6 #
7 # Test hardlink to unlinked file.
8 #
9 # Regression test for commit:
10 # aae8a97 fs: Don't allow to create hardlink for deleted file
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_fs generic
33 _supported_os Linux
34 _require_scratch
35
36 link_unlink_storm()
37 {
38         local src=$1
39         local target=$2
40         local i=0
41
42         while true; do
43                 ln -f $src $target.$i >/dev/null 2>&1
44                 rm -f $target.$i >/dev/null 2>&1
45                 let i=i+1
46         done
47 }
48
49 rm -f $seqres.full
50 nr_cpu=`$here/src/feature -o`
51 echo "Silence is golden"
52
53 _scratch_mkfs >>$seqres.full 2>&1
54 _scratch_mount
55
56 # create, open & unlinked files so unlinked inode list is not empty
57 $here/src/multi_open_unlink -f $SCRATCH_MNT/$seq.unlinked -n $nr_cpu &
58 open_pid=$!
59
60 # start link/unlink storm
61 src=$SCRATCH_MNT/$seq.target
62 touch $src
63 for i in `seq 1 $nr_cpu`; do
64         target=$SCRATCH_MNT/$seq.target.link.$i
65         link_unlink_storm $src $target &
66         link_pids="$link_pids $!"
67 done
68
69 # remove & re-create target to race with link/unlink
70 while true; do
71         rm -f $src
72         touch $src
73 done &
74 sleep 5
75 kill $! >/dev/null 2>&1
76
77 kill $open_pid $link_pids >/dev/null 2>&1
78 wait $open_pid $link_pids
79
80 # all done, no oops/hang expected, _check_filesystems checks SCRATCH_DEV after test
81 status=0
82 exit