Re: [RFC 02/12] common/rc: Add a helper to run fsx on a given file

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Thu, Jun 12, 2025 at 11:47:33AM +0530, Ojaswin Mujoo wrote:
> On Wed, Jun 11, 2025 at 07:31:38AM -0700, Darrick J. Wong wrote:
> > On Wed, Jun 11, 2025 at 03:04:45PM +0530, Ojaswin Mujoo wrote:
> > > Currently run_fsx is hardcoded to run on a file in $TEST_DIR.
> > > Add a helper _run_fsx_on_file so that we can run fsx on any
> > > given file including in $SCRATCH_MNT. Also, refactor _run_fsx
> > > to use this helper.
> > > 
> > > No functional change is intended in this patch.
> > > 
> > > Signed-off-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx>
> > > ---
> > >  common/rc | 21 ++++++++++++++++++---
> > >  1 file changed, 18 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/common/rc b/common/rc
> > > index cfbe2a5f..a5d811a1 100644
> > > --- a/common/rc
> > > +++ b/common/rc
> > > @@ -5115,13 +5115,22 @@ _require_hugepage_fsx()
> > >  		_notrun "fsx binary does not support MADV_COLLAPSE"
> > >  }
> > >  
> > > -_run_fsx()
> > > +_run_fsx_on_file()
> > >  {
> > > +	local testfile=$1
> > > +	shift
> > > +
> > > +	if ! [ -f $testfile ]
> > > +	then
> > > +		echo "_run_fsx_on_file: $testfile doesn't exist. Creating" >> $seqres.full
> > > +		touch $testfile
> > > +	fi
> > > +
> > >  	echo "fsx $*"
> > >  	local args=`echo $@ | sed -e "s/ BSIZE / $bsize /g" -e "s/ PSIZE / $psize /g"`
> > > -	set -- $FSX_PROG $args $FSX_AVOID $TEST_DIR/junk
> > > +	set -- $FSX_PROG $args $FSX_AVOID $testfile
> > 
> > 	local testfile="${1:-$TEST_DIR/junk}"
> > 	...
> > 	set -- $FSX_PROG $args $FSX_AVOID $testfile
> > 
> > Then you don't need the extra helper.
> Hi Darrick,
> 
> I originally added the extra helper so that we won't need to change the
> existing run_fsx calls. For example, with the change you suggested,
> generic/263 would need to be changed from:
> 
> run_fsx -N 10000  -o 8192   -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z
> 
> to 
> 
> run_fsx $TEST_DIR/junk -N 10000  -o 8192   -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z
> 
> because otherwise, the $1 would actually be "-N" and run_fsx would get
> confused. 
> 
> However, if you would prefer to drop the helper and rather modify
> run_fsx and the call sites to pass a filename, that should be doable as
> well. Please let me know your preference on this.

Ah, right.  I forgot that the function filters its arguments but then
passes them on to fsx.  Ignore this comment, then. :)

Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>

--D

> 
> Regards,
> ojaswin
> 
> > 
> > --D
> > 
> > >  	echo "$@" >>$seqres.full
> > > -	rm -f $TEST_DIR/junk
> > > +	rm -f $testfile
> > >  	"$@" 2>&1 | tee -a $seqres.full >$tmp.fsx
> > >  	local res=${PIPESTATUS[0]}
> > >  	if [ $res -ne 0 ]; then
> > > @@ -5133,6 +5142,12 @@ _run_fsx()
> > >  	return 0
> > >  }
> > >  
> > > +_run_fsx()
> > > +{
> > > +	_run_fsx_on_file $TEST_DIR/junk $@
> > > +	return $?
> > > +}
> > > +
> > >  # Run fsx with -h(ugepage buffers).  If we can't set up a hugepage then skip
> > >  # the test, but if any other error occurs then exit the test.
> > >  _run_hugepage_fsx() {
> > > -- 
> > > 2.49.0
> > > 
> > > 
> 




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux