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.
41 export MKFS_OPTIONS="-i size=512,attr=2"
42 _scratch_mkfs_xfs > /dev/null 2>&1
45 file=$SCRATCH_MNT/file
47 inum=`ls -i $file | awk '{print $1}'`
59 echo ""; echo "** add $start..$end EAs **"
61 while [ $i -le $end ]; do
62 ${ATTR_PROG} -s name.$i -V value $file >/dev/null
71 echo ""; echo "** rm $start..$end EAs **"
73 while [ $i -le $end ]; do
74 ${ATTR_PROG} -r name.$i $file >/dev/null
82 echo ""; echo "** $num extents **"
83 $here/src/makeextents -v -p -w -n $num $file
89 _scratch_xfs_db -r -c "inode $inum" -c "print" |\
91 /nextents/ { print; next }
92 /naextents/ { print; next }
95 /forkoff/ { printf("core.forkoff = %d (%d bytes)\n", $3, $3*8); next }
96 /format/ { print; next }
97 /size/ { print; next }
105 _scratch_xfs_db -r -c "inode $inum" -c "print u"
112 _scratch_xfs_db -r -c "inode $inum" -c "print a"
169 while [ $j -le 30 ]; do
177 while [ $j -ge 1 ]; do
185 while [ $j -le 30 ]; do
193 # Using a nested loop,
194 # for various number of data extents,
195 # try adding EAs and then removing EAs
196 # Check that when we play with the EAs that we don't mess with the extents
200 # now do the EAs with the extents
206 for i in `seq 1 $extents_inc $extents_max`; do
208 echo "--- extents: $i ---"
210 _print_inode_u > $tmp.u1
211 for j in `seq 1 $EAs_inc $EAs_max`; do
215 # should have same extents
217 _print_inode_u > $tmp.u2
219 _print_inode_u > $tmp.u3
222 echo "*** Extent differences before and after EAs added ***"
223 diff -s $tmp.u1 $tmp.u2 | _filter
225 if ! diff $tmp.u1 $tmp.u2 >/dev/null; then
226 echo "Data extents magically changed"
231 echo "*** Extent differences before and after EAs removed ***"
232 diff -s $tmp.u2 $tmp.u3 | _filter
234 if ! diff $tmp.u2 $tmp.u3 >/dev/null; then
235 echo "Data extents magically changed"
242 # The counterpart of _test_extents_eas
243 # with the nested loops reversed.
244 # For various number of EAs, try adding extents
245 # Check that when we play with the data extents that we don't mess with the EAs
249 # now do the EAs with the extents
255 for j in `seq 1 $EAs_inc $EAs_max`; do
259 echo "--- EAs: $j ---"
262 _print_inode_a > $tmp.a1
263 for i in `seq 1 $extents_inc $extents_max`; do
267 # should have same EAs
269 _print_inode_a > $tmp.a2
271 _print_inode_a > $tmp.a3
274 echo "*** EA differences before and after extents added ***"
275 diff -s $tmp.a1 $tmp.a2 | _filter
277 if ! diff $tmp.a1 $tmp.a2 >/dev/null; then
278 echo "EAs magically changed"
283 echo "*** EA differences before and after extents removed ***"
284 diff -s $tmp.a2 $tmp.a3 | _filter
286 if ! diff $tmp.a2 $tmp.a3 >/dev/null; then
287 echo "EAs magically changed"
294 # test to see how we go
297 # test to ensure it fits a max sf EA
299 # literal part of inode starts at offset 100 (decimal)
300 # for 512 bytes inode that gives 412 bytes of literal area
302 # min btree root (numrecs=3) => 3 * 16 + (4 or 8)
303 # for 8 byte alignment => 56 bytes
304 # => 512 - 156 = 356 bytes
318 # vlen = 356 - (6+4) = 346
321 _test_initial_sf_ea()
327 dd if=/dev/zero bs=1 count=$vlen | ${ATTR_PROG} -s name $file
339 # do a test with a variety of sized EAs