4 # Test nlink accounting of overlay hardlinks.
6 # nlink of overlay inode should account for the union of lower and upper
9 #-----------------------------------------------------------------------
10 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
11 # Author: Amir Goldstein <amir73il@gmail.com>
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
46 # remove previous $seqres.full before test
49 # real QA test starts here
53 _require_scratch_feature index
59 [ $DCACHETEMP != cold ] || echo 2 > /proc/sys/vm/drop_caches
61 # check nlink with warm dcache after overlay modification
63 echo "== $when - $DCACHETEMP dcache =="
64 for f in $HARDLINKS; do
65 _ls_l $SCRATCH_MNT/$f | awk '{ print $2, $9 }' | _filter_scratch
69 # Create lower hardlinks
72 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
75 ln $lowerdir/0 $lowerdir/1
76 ln $lowerdir/0 $lowerdir/2
77 ln $lowerdir/0 $lowerdir/3
83 report_nlink "all lower"
85 # Unlink lower hardlink
88 report_nlink "unlink lower"
90 # Link to lower hardlink
91 ln $SCRATCH_MNT/3 $SCRATCH_MNT/4
93 report_nlink "link lower"
95 # Link to upper hardlink
96 ln $SCRATCH_MNT/4 $SCRATCH_MNT/5
98 report_nlink "link upper"
100 # Rename over lower hardlink
101 touch $SCRATCH_MNT/new
102 mv $SCRATCH_MNT/new $SCRATCH_MNT/1
104 report_nlink "cover lower"
106 # Unlink upper hardlink
109 report_nlink "unlink upper"
111 # Rename over upper hardlink
112 touch $SCRATCH_MNT/new
113 mv $SCRATCH_MNT/new $SCRATCH_MNT/4
115 report_nlink "cover upper"
117 # Unlink last upper (union still has one lower)
120 report_nlink "unlink last upper"
122 # Unlink last lower and drop union nlink to zero (and hopefully not below)
125 # Verify that orphan index is cleaned when dropping nlink to zero
126 ls $OVL_BASE_SCRATCH_MNT/$OVL_WORK/index
129 # Remove all files from previous tests
132 # Create lower hardlinks
135 # Enable overlay index feature to prevent breaking hardlinks on copy up
136 _scratch_mount -o index=on
137 # Test hardlinks with warm dcache
141 # Reset to lower hardlinks
145 _scratch_mount -o index=on
147 # Test hardlinks with cold dcache