From: Dave Chinner <dchinner@xxxxxxxxxx> The slowest test tto run on my test VMs is xfs/227: ... xfs/227 826 ... It is doing nested iteration on created filesets that are explicitly defined, so separate the inner loop filesets and run the outer loops in parallel. Also reduce the number of times we have to execute setfattr and xfs_io to once per created file instead of once per xattr/extent count per file. The result is test runtime reduction of ~60%. .... xfs/227 336 .... Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx> --- tests/xfs/227 | 57 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/tests/xfs/227 b/tests/xfs/227 index 2ad910cbd..7f8ee2dba 100755 --- a/tests/xfs/227 +++ b/tests/xfs/227 @@ -41,7 +41,7 @@ fragment_freespace() # allocate inode space mkdir -p $_dir for i in `seq 0 1 1000`; do - touch $_file.$i + echo -n > $_file.$i done for i in `seq 0 63 1000`; do mv $_file.$i $_dir @@ -68,19 +68,23 @@ fragment_freespace() create_attrs() { - for foo in `seq 0 1 $1`; do - $SETFATTR_PROG -n user.$foo -v 0xbabe $2 - done + ( echo "# file: $2" + for i in `seq 0 1 $1`; do + echo "user.$foo=\"0xbabe\"" + done ) > $tmp.$1.attrs + $SETFATTR_PROG --restore=$tmp.$1.attrs $2 } create_data() { - size=`expr \( $1 + 1 \) \* 4096` - $XFS_IO_PROG -f -c "truncate $size" $2 > /dev/null 2>&1 - for foo in `seq $1 -1 0`; do - let offset=$foo*4096 - $XFS_IO_PROG -f -c "resvsp $offset 4096" $2 > /dev/null 2>&1 + local blocks=$1 + local cmd_str + + for off in `seq $blocks -1 0`; do + cmd_str="-c \"resvsp $((off * 4096)) 4096\" $cmd_str" done + $XFS_IO_PROG -f -c "truncate $((($blocks + 1) * 4096))" \ + $cmd_str $2 >> seqres.full 2>&1 } # create the designated file with a certain number of attributes and a certain @@ -119,6 +123,27 @@ create_target_attr_last() create_attrs $nattrs $target } +do_fsr() +{ + local n=$1 + local i=$2 + local j + + for j in `seq 5 1 20`; do + create_target_attr_first $i $j $targ.$i.$j >> $seqres.full 2>&1 + done + xfs_bmap -vp $targ.$i.* >> $seqres.full 2>&1 + FSRXFSTEST=true xfs_fsr -d -v -C $n $targ.$i.* >> $seqres.full 2>&1 + xfs_bmap -vp $targ.$i.* >> $seqres.full 2>&1 + for j in `seq 5 1 20`; do + create_target_attr_last $i $j $targ.$i.$j >> $seqres.full 2>&1 + done + xfs_bmap -vp $targ.$i.* >> $seqres.full 2>&1 + FSRXFSTEST=true xfs_fsr -d -v -C $n $targ.$i.* >> $seqres.full 2>&1 + xfs_bmap -vp $targ.$i.* >> $seqres.full 2>&1 +} + + # use a small filesystem so we can control freespace easily _scratch_mkfs_sized $((50 * 1024 * 1024)) >> $seqres.full 2>&1 _scratch_mount @@ -154,19 +179,9 @@ targ=$SCRATCH_MNT/fsr_test_file.$$ for n in `seq 4 1 12`; do echo "*** n == $n ***" >> $seqres.full for i in `seq 5 1 15`; do - for j in `seq 5 1 20`; do - create_target_attr_first $i $j $targ.$i.$j >> $seqres.full 2>&1 - done - xfs_bmap -vp $targ.$i.* >> $seqres.full 2>&1 - FSRXFSTEST=true xfs_fsr -d -v -C $n $targ.$i.* >> $seqres.full 2>&1 - xfs_bmap -vp $targ.$i.* >> $seqres.full 2>&1 - for j in `seq 5 1 20`; do - create_target_attr_last $i $j $targ.$i.$j >> $seqres.full 2>&1 - done - xfs_bmap -vp $targ.$i.* >> $seqres.full 2>&1 - FSRXFSTEST=true xfs_fsr -d -v -C $n $targ.$i.* >> $seqres.full 2>&1 - xfs_bmap -vp $targ.$i.* >> $seqres.full 2>&1 + do_fsr $n $i & done + wait done _scratch_unmount -- 2.45.2