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
14 # Import common functions.
18 # real QA test starts here
20 #_notrun "Need to fix up filtering before checkin"
22 # Modify as appropriate.
28 export MKFS_OPTIONS="-i size=512,attr=2"
29 _scratch_mkfs_xfs > /dev/null 2>&1
32 file=$SCRATCH_MNT/file
34 inum=`ls -i $file | awk '{print $1}'`
46 echo ""; echo "** add $start..$end EAs **"
48 while [ $i -le $end ]; do
49 ${ATTR_PROG} -s name.$i -V value $file >/dev/null
58 echo ""; echo "** rm $start..$end EAs **"
60 while [ $i -le $end ]; do
61 ${ATTR_PROG} -r name.$i $file >/dev/null
69 echo ""; echo "** $num extents **"
70 $here/src/makeextents -v -p -w -n $num $file
76 _scratch_xfs_db -r -c "inode $inum" -c "print" |\
78 /nextents/ { print; next }
79 /naextents/ { print; next }
82 /forkoff/ { printf("core.forkoff = %d (%d bytes)\n", $3, $3*8); next }
83 /format/ { print; next }
84 /size/ { print; next }
92 _scratch_xfs_db -r -c "inode $inum" -c "print u"
99 _scratch_xfs_db -r -c "inode $inum" -c "print a"
156 while [ $j -le 30 ]; do
164 while [ $j -ge 1 ]; do
172 while [ $j -le 30 ]; do
180 # Using a nested loop,
181 # for various number of data extents,
182 # try adding EAs and then removing EAs
183 # Check that when we play with the EAs that we don't mess with the extents
187 # now do the EAs with the extents
193 for i in `seq 1 $extents_inc $extents_max`; do
195 echo "--- extents: $i ---"
197 _print_inode_u > $tmp.u1
198 for j in `seq 1 $EAs_inc $EAs_max`; do
202 # should have same extents
204 _print_inode_u > $tmp.u2
206 _print_inode_u > $tmp.u3
209 echo "*** Extent differences before and after EAs added ***"
210 diff -s $tmp.u1 $tmp.u2 | _filter
212 if ! diff $tmp.u1 $tmp.u2 >/dev/null; then
213 echo "Data extents magically changed"
218 echo "*** Extent differences before and after EAs removed ***"
219 diff -s $tmp.u2 $tmp.u3 | _filter
221 if ! diff $tmp.u2 $tmp.u3 >/dev/null; then
222 echo "Data extents magically changed"
229 # The counterpart of _test_extents_eas
230 # with the nested loops reversed.
231 # For various number of EAs, try adding extents
232 # Check that when we play with the data extents that we don't mess with the EAs
236 # now do the EAs with the extents
242 for j in `seq 1 $EAs_inc $EAs_max`; do
246 echo "--- EAs: $j ---"
249 _print_inode_a > $tmp.a1
250 for i in `seq 1 $extents_inc $extents_max`; do
254 # should have same EAs
256 _print_inode_a > $tmp.a2
258 _print_inode_a > $tmp.a3
261 echo "*** EA differences before and after extents added ***"
262 diff -s $tmp.a1 $tmp.a2 | _filter
264 if ! diff $tmp.a1 $tmp.a2 >/dev/null; then
265 echo "EAs magically changed"
270 echo "*** EA differences before and after extents removed ***"
271 diff -s $tmp.a2 $tmp.a3 | _filter
273 if ! diff $tmp.a2 $tmp.a3 >/dev/null; then
274 echo "EAs magically changed"
281 # test to see how we go
284 # test to ensure it fits a max sf EA
286 # literal part of inode starts at offset 100 (decimal)
287 # for 512 bytes inode that gives 412 bytes of literal area
289 # min btree root (numrecs=3) => 3 * 16 + (4 or 8)
290 # for 8 byte alignment => 56 bytes
291 # => 512 - 156 = 356 bytes
305 # vlen = 356 - (6+4) = 346
308 _test_initial_sf_ea()
314 dd if=/dev/zero bs=1 count=$vlen | ${ATTR_PROG} -s name $file
326 # do a test with a variety of sized EAs