2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016-2017 CTERA Networks. All Rights Reserved.
7 # Test hardlink breakage after unlink and mount cycle
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
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
31 # real QA test starts here
34 _require_scratch_feature index
38 _scratch_mkfs >>$seqres.full 2>&1
40 # Create 2 hardlinked files in lower
41 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
43 echo "zero" >> $lowerdir/foo
44 ln $lowerdir/foo $lowerdir/bar
47 # Enable overlay index feature to prevent breaking hardlinks on copy up
48 _scratch_mount -o index=on
58 echo "== Before copy up =="
61 # Modify content of one of the hardlinks
64 echo "== After write one =="
67 # Unlink the copied up hardlink
70 echo "== After unlink one =="
73 # Verify that the hardlinks survive a mount cycle
74 _scratch_cycle_mount index=on
76 echo "== After mount cycle =="
79 # Drop caches to get the copied up hardlink out of cache
80 echo 3 > /proc/sys/vm/drop_caches
82 # Modify content of the other hardlink
85 echo "== After write two =="