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 _begin_fstest attr auto quick
28 for i in `seq $start_num $end_num`; do
37 for i in `seq $start_num $end_num`; do
38 $SETFATTR_PROG -n user.$i -v 0xbabe $fork_dir
46 for i in `seq $start_num $end_num`; do
47 $SETFATTR_PROG -x user.$i $fork_dir
51 # If filetype is available (-n ftype=1) will get v3 dirs;
52 # just filter/replace to make this look the same as if we
53 # had v2 dirs, as we are not interested in this info.
56 tee -a $seqres.full | \
57 sed -e "s/core.forkoff/forkoff/g" | \
58 egrep '^u.sfdir2|^u.sfdir3|^a.sfattr|forkoff' | \
59 egrep -v 'inumber|parent' | \
60 sed -e s/sfdir3/sfdir2/g | \
66 tee -a $seqres.full | tr ',' '\n' | grep ATTR
72 echo "================================="
73 _scratch_xfs_db -c "version" 2>&1 | _filter_version
74 _scratch_xfs_db -c "inode $inum" -c p 2>&1 | _filter_inode
75 echo "================================="
82 if [ $1 = "-r" ]; then
83 echo "*** remove EAs start $2 end $3 ***"
86 echo "*** create EAs start $2 end $3 ***"
90 cd /; $UMOUNT_PROG $SCRATCH_MNT
96 num=`expr $2 - $1 + 1`
98 echo "*** create $num dirents ***"
101 _create_dirents $1 $2
102 cd /; $UMOUNT_PROG $SCRATCH_MNT
109 echo "Try setting attr1 by db"
111 _scratch_xfs_db -x -c "version attr1" | _filter_version
114 # Import common functions.
118 # real QA test starts here
120 # Modify as appropriate.
127 _scratch_mkfs -i attr=2,size=512 -l lazy-count=1 | _filter_mkfs \
128 >>$seqres.full 2>$tmp.mkfs
129 # import crc status and attr version
132 # _scratch_mkfs may ignore $MKFS_OPTIONS if mkfs fails due to conflicts between
133 # $MKFS_OPTIONS and the provided mkfs options, which could result in creating
134 # an XFS we don't want. Check crc status and attr version to be sure.
135 if [ $_fs_has_crcs -eq 1 ]; then
136 _notrun "attr v1 not supported on $SCRATCH_DEV"
138 if [ $attr -ne 2 ]; then
139 _notrun "need attr v2 on $SCRATCH_DEV"
142 # set inum to root dir ino
143 # we'll add in dirents and EAs into the root directory
144 inum=`_scratch_xfs_get_sb_field rootino`
145 fork_dir=$SCRATCH_MNT
148 # add enough dirents to be inline but more
149 # than will fit for m_attroffset for 512b inodes
150 # for attr2 this is not a problem
153 # add 1 ea so we get our forkoff happening
156 # now change back to attr1 where forkoff is constant now
160 # for a bug in xfs_add_shortform_bytesfit
161 # where it resets the forkoff to m_attroffset>>3 instead of
162 # leaving as di_forkoff
163 # If it resets to m_attroffset which is in the middle of
164 # the dirents then they will get corrupted