4 # Test nlink accounting of overlay hardlinks with offline modifications.
6 # nlink of overlay inode should account for the union of lower and upper
7 # hardlinks. Orphan index inodes with union nlink 0 should be cleaned on
10 #-----------------------------------------------------------------------
11 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
12 # Author: Amir Goldstein <amir73il@gmail.com>
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # get standard environment, filters and checks
47 # remove previous $seqres.full before test
50 # real QA test starts here
54 _require_scratch_feature index
60 # mount and check nlink after overlay offline modification
61 _scratch_mount -o index=on
64 echo "== $when offline =="
65 for f in $HARDLINKS; do
66 _ls_l $SCRATCH_MNT/$f | awk '{ print $2, $9 }' | _filter_scratch
69 $UMOUNT_PROG $SCRATCH_MNT
72 # Create lower hardlinks
77 ln $lowerdir/0 $lowerdir/1
78 ln $lowerdir/0 $lowerdir/2
81 test_hardlinks_offline()
84 report_nlink "all upper"
86 # Unlink copied up hardlink
89 report_nlink "unlink upper"
91 # Link to copied up hardlink
92 ln $upperdir/2 $upperdir/3
94 report_nlink "link upper"
96 # Rename over copied up hardlink
98 mv $upperdir/new $upperdir/1
100 report_nlink "rename over upper"
102 # Unlink new upper hardlink
105 report_nlink "unlink new upper"
107 # Unlink last upper and drop union nlink to zero
111 report_nlink "unlink last lower"
113 # Verify that orphan index is cleaned when dropping nlink to zero
114 # With nfs_export=on index will contain a whiteout index entry, so allow
115 # chardev entries in index dir.
116 find $workdir/index -mindepth 1 -type c -o -print
119 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
120 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
121 workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
123 # Remove all files from previous tests
126 # Create lower hardlinks
129 # Enable overlay index feature to prevent breaking hardlinks on copy up
130 _scratch_mount -o index=on
132 # Copy up and index hardlinks
137 # Perform the rest of the changes offline
138 $UMOUNT_PROG $SCRATCH_MNT
140 test_hardlinks_offline