xfstests: Change fstrim behaviour to be consistent with upstream version
PATCH 1/1 xfstests: Change fstrim behaviour to be consistent with upstream version
Rename fstrim option from "-s" to "-o" and change output message when verbose option is set.
--- 251 | 2 +- 260 | 22 ++++++++++++---------- src/fstrim.c | 11 ++++++----- 3 files changed, 19 insertions(+), 16 deletions(-)
251 +1 -1
@@ -107,7 +107,7 @@ fstrim_loop() wait $fpid fi while [ $start -lt $fsize ] ; do - $here/src/fstrim -m ${minlen}k -s ${start}k -l ${step}k $SCRATCH_MNT & + $here/src/fstrim -m ${minlen}k -o ${start}k -l ${step}k $SCRATCH_MNT & fpid=$! wait $fpid start=$(( $start + $step ))
260 +12 -10
@@ -59,19 +59,19 @@ max_64bit=$(_math "2^64 - 1") # the file system echo "[+] Start beyond the end of fs (should fail)" -"$FSTRIM" -s $beyond_eofs $SCRATCH_MNT +"$FSTRIM" -o $beyond_eofs $SCRATCH_MNT [ $? -eq 0 ] && status=1 echo "[+] Start beyond the end of fs with len set (should fail)" -"$FSTRIM" -s $beyond_eofs -l1M $SCRATCH_MNT +"$FSTRIM" -o $beyond_eofs -l1M $SCRATCH_MNT [ $? -eq 0 ] && status=1 echo "[+] Start = 2^64-1 (should fail)" -"$FSTRIM" -s $max_64bit $SCRATCH_MNT +"$FSTRIM" -o $max_64bit $SCRATCH_MNT [ $? -eq 0 ] && status=1 echo "[+] Start = 2^64-1 and len is set (should fail)" -"$FSTRIM" -s $max_64bit -l1M $SCRATCH_MNT +"$FSTRIM" -o $max_64bit -l1M $SCRATCH_MNT [ $? -eq 0 ] && status=1 _scratch_unmount
@@ -85,13 +85,13 @@ echo "[+] Default length (should succeed)" "$FSTRIM" $SCRATCH_MNT [ $? -ne 0 ] && status=1 echo "[+] Default length with start set (should succeed)" -"$FSTRIM" -s10M $SCRATCH_MNT +"$FSTRIM" -o10M $SCRATCH_MNT [ $? -ne 0 ] && status=1 echo "[+] Length beyond the end of fs (should succeed)" "$FSTRIM" -l $beyond_eofs $SCRATCH_MNT [ $? -ne 0 ] && status=1 echo "[+] Length beyond the end of fs with start set (should succeed)" -"$FSTRIM" -s10M -l $beyond_eofs $SCRATCH_MNT +"$FSTRIM" -o10M -l $beyond_eofs $SCRATCH_MNT [ $? -ne 0 ] && status=1 _scratch_unmount
@@ -101,8 +101,9 @@ _scratch_mount # This is a bit fuzzy, but since the file system is fresh # there should be at least (fssize/2) free space to trim. # This is supposed to catch wrong FITRIM argument handling -out=$("$FSTRIM" -v -s10M $SCRATCH_MNT) -bytes=${out%% *} +out=$("$FSTRIM" -v -o10M $SCRATCH_MNT) +nopref=${out##*: } +bytes=${nopref%% *} if [ $bytes -gt $(_math "$fssize*1024") ]; then status=1
@@ -155,7 +156,7 @@ _scratch_unmount _scratch_mkfs >/dev/null 2>&1 _scratch_mount # It should fail since $start is beyond the end of file system -"$FSTRIM" -s$start -l10M $SCRATCH_MNT &> /dev/null +"$FSTRIM" -o$start -l10M $SCRATCH_MNT &> /dev/null if [ $? -eq 0 ]; then status=1 echo "It seems that fs logic handling start"\
@@ -174,7 +175,8 @@ _scratch_mount # mapped and since we got here right after the mkfs, there is not # enough free extents in the root tree. out=$("$FSTRIM" -v -l$len $SCRATCH_MNT) -bytes=${out%% *} +nopref=${out##*: } +bytes=${nopref%% *} if [ $bytes -le $(_math "$fssize*512") ] && [ $FSTYP != "btrfs" ]; then status=1 echo "It seems that fs logic handling len argument overflows"
src/fstrim.c +6 -5
@@ -58,9 +58,9 @@ struct options {static void usage (void ) { fprintf(stderr, - "Usage: %s [-s start] [-l length] [-m minimum-extent]" + "Usage: %s [-o offset] [-l length] [-m minimum-extent]" " [-v] {mountpoint}\n\t" - "-s Starting Byte to discard from\n\t" + "-o Offset in Bytes to discard from\n\t" "-l Number of Bytes to discard from the start\n\t" "-m Minimum extent length to discard\n\t" "-v Verbose - number of discarded bytes\n",
@@ -152,9 +152,9 @@ static int parse_opts(int argc, char **argv, struct options *opts) {int c; -while ((c =getopt (argc, argv,"s:l:m:v" )) !=EOF ) { +while ((c =getopt (argc, argv,"o:l:m:v" )) !=EOF ) {switch (c) { -case 's' :/* starting point */ +case 'o' :/* starting point */ opts->range->start =get_number (&optarg);break ;case 'l' :/* length */
@@ -242,7 +242,8 @@ int main(int argc, char **argv) }if ((opts->verbose) && (opts->range)) -fprintf (stdout,"%llu Bytes were trimmed\n" , (unsigned long long )opts->range->len); +fprintf (stdout,"%s: %llu bytes were trimmed\n" , opts->mpoint, + (unsigned long long )opts->range->len); ret =EXIT_SUCCESS ;
Signature · 6 lines
1.7.7.6 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 2 lines · Tomas Racek
Rename fstrim option from "-s" to "-o" and change output message when verbose option is set.
Why modify a local utility program like this? There's little point in trying to match some other utilities' command line parameters just for the sake of it...
If we have duplicate code (i.e. a copy of the upstream utility) or the local tool can be completely replaced by the upstream tool, then we should use upstream and remove the local copy completely. Distros have been shipping fstrim for long enough now that most people running testing on upstream kernels will have it installed...
Adding a _require_fstrim() function that checks for the upstream version of fstrim to be installed for each test that requires it would go along with this.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 9 lines · Dave Chinner
If we have duplicate code (i.e. a copy of the upstream utility) or the local tool can be completely replaced by the upstream tool, then we should use upstream and remove the local copy completely. Distros have been shipping fstrim for long enough now that most people running testing on upstream kernels will have it installed...
Adding a
_require_fstrim()function that checks for the upstream version of fstrim to be installed for each test that requires it would go along with this.
I would also vote for just using the upstream util-linux fstrim. Not quite sure what the history was here, but it might have been that the xfstests one actually was the earlier version. Lukas, any opinions?
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines
If we have duplicate code (i.e. a copy of the upstream utility) or the local tool can be completely replaced by the upstream tool, then we should use upstream and remove the local copy completely. Distros have been shipping fstrim for long enough now that most people running testing on upstream kernels will have it installed...
OK, I'll create the patch which drops local version.
Quoted 3 lines
Adding a
_require_fstrim()function that checks for the upstream version of fstrim to be installed for each test that requires it would go along with this.
Did you mean something like
_require_fstrim()
{
which fstrim &>/dev/null || _notrun "This test requires fstrim utility."
}in common.rc or locally in each test?
Thanks for comments!
Tomas
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 14 lines · Christoph Hellwig
Date: Mon, 30 Jul 2012 22:33:36 -0400
From: Christoph Hellwig <[email protected]>
To: Dave Chinner <[email protected]>
Cc: Tomas Racek <[email protected]>, [email protected], [email protected]
Subject: Re: [PATCH] xfstests: Change fstrim behaviour to be consistent with
upstream versionQuoted 6 lines · Dave Chinner
If we have duplicate code (i.e. a copy of the upstream utility) or the local tool can be completely replaced by the upstream tool, then we should use upstream and remove the local copy completely. Distros have been shipping fstrim for long enough now that most people running testing on upstream kernels will have it installed...
Quoted 8 lines
Quoted 3 lines
Adding a
_require_fstrim()function that checks for the upstream version of fstrim to be installed for each test that requires it would go along with this.I would also vote for just using the upstream util-linux fstrim. Not quite sure what the history was here, but it might have been that the xfstests one actually was the earlier version. Lukas, any opinions?
The local xfstests version was indeed the earlier version and it was not even in the util-linux back then. So now, when we already have fstrim in util-linux and most distributions already ship it, I do not see any reason for maintaining the local copy anymore.
I agree that we should be using upstream fstrim and remove the local version completely.
Thanks!
-Lukas
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 20 lines · Tomas Racek
Date: Tue, 31 Jul 2012 06:24:26 -0400 (EDT)
From: Tomas Racek <[email protected]>
To: Dave Chinner <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH] xfstests: Change fstrim behaviour to be consistent with
upstream versionQuoted 6 lines
If we have duplicate code (i.e. a copy of the upstream utility) or the local tool can be completely replaced by the upstream tool, then we should use upstream and remove the local copy completely. Distros have been shipping fstrim for long enough now that most people running testing on upstream kernels will have it installed...
OK, I'll create the patch which drops local version.
Quoted 3 lines
Adding a
_require_fstrim()function that checks for the upstream version of fstrim to be installed for each test that requires it would go along with this.
Quoted 8 lines
Did you mean something like
_require_fstrim(){ which fstrim &>/dev/null || _notrun "This test requires fstrim utility." }in common.rc or locally in each test?
I think that having this test in common.rc along with others is definitely better option.
And while you're in it, you can also add another _require_ for the actual FITRIM support. Although calling it _require_fitrim seems rather confusing, so maybe _require_batched_discard with the device as an argument ?
Thanks!
-Lukas
Quoted 5 lines
Thanks for comments!
Tomas
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs