common: kill _supported_os
[xfstests-dev.git] / tests / overlay / 047
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016-2017 CTERA Networks. All Rights Reserved.
4 #
5 # FSQA Test No. 047
6 #
7 # Test hardlink breakage after unlink and mount cycle
8 #
9 # - file A and B are hardlinked in lower
10 # - modify A to trigger copy up and index lower
11 # - unlink A and mount cycle
12 # - check that B still contains the modified data
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
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 overlay
33 _require_scratch
34 _require_scratch_feature index
35
36 rm -f $seqres.full
37
38 _scratch_mkfs >>$seqres.full 2>&1
39
40 # Create 2 hardlinked files in lower
41 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
42 mkdir -p $lowerdir
43 echo "zero" >> $lowerdir/foo
44 ln $lowerdir/foo $lowerdir/bar
45
46
47 # Enable overlay index feature to prevent breaking hardlinks on copy up
48 _scratch_mount -o index=on
49
50
51 rm -f $tmp.*
52
53 foo=$SCRATCH_MNT/foo
54 bar=$SCRATCH_MNT/bar
55
56 FILES="$foo $bar"
57
58 echo "== Before copy up =="
59 cat $foo
60
61 # Modify content of one of the hardlinks
62 echo "one" >> $bar
63
64 echo "== After write one =="
65 cat $foo
66
67 # Unlink the copied up hardlink
68 rm $bar
69
70 echo "== After unlink one =="
71 cat $foo
72
73 # Verify that the hardlinks survive a mount cycle
74 _scratch_cycle_mount index=on
75
76 echo "== After mount cycle =="
77 cat $foo
78
79 # Drop caches to get the copied up hardlink out of cache
80 echo 3 > /proc/sys/vm/drop_caches
81
82 # Modify content of the other hardlink
83 echo "two" >> $foo
84
85 echo "== After write two =="
86 cat $foo
87
88 status=0
89 exit