2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
8 # Let's look, xfs_db, at the inode and its literal area for the
9 # extents and the attributes
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
31 # real QA test starts here
33 #_notrun "Need to fix up filtering before checkin"
35 # Modify as appropriate.
42 export MKFS_OPTIONS="-i size=512,attr=2"
43 _scratch_mkfs_xfs > /dev/null 2>&1
46 file=$SCRATCH_MNT/file
48 inum=`ls -i $file | awk '{print $1}'`
60 echo ""; echo "** add $start..$end EAs **"
62 while [ $i -le $end ]; do
63 ${ATTR_PROG} -s name.$i -V value $file >/dev/null
72 echo ""; echo "** rm $start..$end EAs **"
74 while [ $i -le $end ]; do
75 ${ATTR_PROG} -r name.$i $file >/dev/null
83 echo ""; echo "** $num extents **"
84 src/makeextents -v -p -w -n $num $file
90 _scratch_xfs_db -r -c "inode $inum" -c "print" |\
92 /nextents/ { print; next }
93 /naextents/ { print; next }
96 /forkoff/ { printf("core.forkoff = %d (%d bytes)\n", $3, $3*8); next }
97 /format/ { print; next }
98 /size/ { print; next }
106 _scratch_xfs_db -r -c "inode $inum" -c "print u"
113 _scratch_xfs_db -r -c "inode $inum" -c "print a"
170 while [ $j -le 30 ]; do
178 while [ $j -ge 1 ]; do
186 while [ $j -le 30 ]; do
194 # Using a nested loop,
195 # for various number of data extents,
196 # try adding EAs and then removing EAs
197 # Check that when we play with the EAs that we don't mess with the extents
201 # now do the EAs with the extents
207 for i in `seq 1 $extents_inc $extents_max`; do
209 echo "--- extents: $i ---"
211 _print_inode_u > $tmp.u1
212 for j in `seq 1 $EAs_inc $EAs_max`; do
216 # should have same extents
218 _print_inode_u > $tmp.u2
220 _print_inode_u > $tmp.u3
223 echo "*** Extent differences before and after EAs added ***"
224 diff -s $tmp.u1 $tmp.u2 | _filter
226 if ! diff $tmp.u1 $tmp.u2 >/dev/null; then
227 echo "Data extents magically changed"
232 echo "*** Extent differences before and after EAs removed ***"
233 diff -s $tmp.u2 $tmp.u3 | _filter
235 if ! diff $tmp.u2 $tmp.u3 >/dev/null; then
236 echo "Data extents magically changed"
243 # The counterpart of _test_extents_eas
244 # with the nested loops reversed.
245 # For various number of EAs, try adding extents
246 # Check that when we play with the data extents that we don't mess with the EAs
250 # now do the EAs with the extents
256 for j in `seq 1 $EAs_inc $EAs_max`; do
260 echo "--- EAs: $j ---"
263 _print_inode_a > $tmp.a1
264 for i in `seq 1 $extents_inc $extents_max`; do
268 # should have same EAs
270 _print_inode_a > $tmp.a2
272 _print_inode_a > $tmp.a3
275 echo "*** EA differences before and after extents added ***"
276 diff -s $tmp.a1 $tmp.a2 | _filter
278 if ! diff $tmp.a1 $tmp.a2 >/dev/null; then
279 echo "EAs magically changed"
284 echo "*** EA differences before and after extents removed ***"
285 diff -s $tmp.a2 $tmp.a3 | _filter
287 if ! diff $tmp.a2 $tmp.a3 >/dev/null; then
288 echo "EAs magically changed"
295 # test to see how we go
298 # test to ensure it fits a max sf EA
300 # literal part of inode starts at offset 100 (decimal)
301 # for 512 bytes inode that gives 412 bytes of literal area
303 # min btree root (numrecs=3) => 3 * 16 + (4 or 8)
304 # for 8 byte alignment => 56 bytes
305 # => 512 - 156 = 356 bytes
319 # vlen = 356 - (6+4) = 346
322 _test_initial_sf_ea()
328 dd if=/dev/zero bs=1 count=$vlen | ${ATTR_PROG} -s name $file
340 # do a test with a variety of sized EAs