2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
8 # pv#979606: xfs bug in going from attr2 back to attr1
10 # Test bug in going from attr2 back to attr1 where xfs
11 # (due to xfs_attr_shortform_bytesfit)
12 # would reset the di_forkoff to the m_offset instead of
13 # leaving the di_forkoff alone as was intended.
15 # We create enough dirents to push us past m_attroffset,
16 # and create an EA so we have a fork offset
17 # and then turn on attr1 and add one more EA which
18 # will write over the shortform dirents.
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
26 status=1 # failure is the default!
27 trap "_cleanup; exit \$status" 0 1 2 3 15
40 for i in `seq $start_num $end_num`; do
49 for i in `seq $start_num $end_num`; do
50 $SETFATTR_PROG -n user.$i -v 0xbabe $fork_dir
58 for i in `seq $start_num $end_num`; do
59 $SETFATTR_PROG -x user.$i $fork_dir
63 # If filetype is available (-n ftype=1) will get v3 dirs;
64 # just filter/replace to make this look the same as if we
65 # had v2 dirs, as we are not interested in this info.
68 tee -a $seqres.full | \
69 sed -e "s/core.forkoff/forkoff/g" | \
70 egrep '^u.sfdir2|^u.sfdir3|^a.sfattr|forkoff' | \
71 egrep -v 'inumber|parent' | \
72 sed -e s/sfdir3/sfdir2/g | \
78 tee -a $seqres.full | tr ',' '\n' | grep ATTR
84 echo "================================="
85 _scratch_xfs_db -c "version" 2>&1 | _filter_version
86 _scratch_xfs_db -c "inode $inum" -c p 2>&1 | _filter_inode
87 echo "================================="
94 if [ $1 = "-r" ]; then
95 echo "*** remove EAs start $2 end $3 ***"
98 echo "*** create EAs start $2 end $3 ***"
102 cd /; $UMOUNT_PROG $SCRATCH_MNT
108 num=`expr $2 - $1 + 1`
110 echo "*** create $num dirents ***"
113 _create_dirents $1 $2
114 cd /; $UMOUNT_PROG $SCRATCH_MNT
121 echo "Try setting attr1 by db"
123 _scratch_xfs_db -x -c "version attr1" | _filter_version
126 # get standard environment, filters and checks
131 # real QA test starts here
133 # Modify as appropriate.
142 _scratch_mkfs -i attr=2,size=512 -l lazy-count=1 | _filter_mkfs \
143 >>$seqres.full 2>$tmp.mkfs
144 # import crc status and attr version
147 # _scratch_mkfs may ignore $MKFS_OPTIONS if mkfs fails due to conflicts between
148 # $MKFS_OPTIONS and the provided mkfs options, which could result in creating
149 # an XFS we don't want. Check crc status and attr version to be sure.
150 if [ $_fs_has_crcs -eq 1 ]; then
151 _notrun "attr v1 not supported on $SCRATCH_DEV"
153 if [ $attr -ne 2 ]; then
154 _notrun "need attr v2 on $SCRATCH_DEV"
157 # set inum to root dir ino
158 # we'll add in dirents and EAs into the root directory
159 inum=`_scratch_xfs_get_sb_field rootino`
160 fork_dir=$SCRATCH_MNT
163 # add enough dirents to be inline but more
164 # than will fit for m_attroffset for 512b inodes
165 # for attr2 this is not a problem
168 # add 1 ea so we get our forkoff happening
171 # now change back to attr1 where forkoff is constant now
175 # for a bug in xfs_add_shortform_bytesfit
176 # where it resets the forkoff to m_attroffset>>3 instead of
177 # leaving as di_forkoff
178 # If it resets to m_attroffset which is in the middle of
179 # the dirents then they will get corrupted