* [PATCH] xfstests generic/260: get correct trimmed bytes
@ 2013-10-03 11:57 Eryu Guan
2013-10-04 1:07 ` Dave Chinner
0 siblings, 1 reply; 5+ messages in thread
From: Eryu Guan @ 2013-10-03 11:57 UTC (permalink / raw)
To: xfs; +Cc: Eryu Guan
Newer fstrim(1) reports trimmed bytes differently, e.g.
new fstrim: /mnt/ext4: 9.7 GiB (10411118592 bytes) trimmed
old fstrim: /mnt/ext4: 10411118592 bytes were trimmed
generic/260 reports syntax error
+./tests/generic/260: line 111: [: 9.7: integer expression expected
+./tests/generic/260: line 121: [: 9.7: integer expression expected
+./tests/generic/260: line 183: [: 9.7: integer expression expected
Fix it so 260 passes with both old and new fstrim.
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
tests/generic/260 | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/tests/generic/260 b/tests/generic/260
index dc8b822..bc9eb3b 100755
--- a/tests/generic/260
+++ b/tests/generic/260
@@ -104,9 +104,8 @@ _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_PROG -v -o10M $SCRATCH_MNT)
-nopref=${out##*: }
-bytes=${nopref%% *}
+out=$($FSTRIM_PROG -v -o10M $SCRATCH_MNT | egrep -o "[0-9]+ bytes")
+bytes=${out%% *}
if [ $bytes -gt $(_math "$fssize*1024") ]; then
status=1
@@ -177,9 +176,8 @@ _scratch_mount
# It is because btrfs does not have not-yet-used parts of the device
# mapped and since we got here right after the mkfs, there is not
# enough free extents in the root tree.
-out=$($FSTRIM_PROG -v -l$len $SCRATCH_MNT)
-nopref=${out##*: }
-bytes=${nopref%% *}
+out=$($FSTRIM_PROG -v -l$len $SCRATCH_MNT | egrep -o "[0-9]+ bytes")
+bytes=${out%% *}
if [ $bytes -le $(_math "$fssize*512") ] && [ $FSTYP != "btrfs" ]; then
status=1
echo "It seems that fs logic handling len argument overflows"
--
1.8.3.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] xfstests generic/260: get correct trimmed bytes
2013-10-03 11:57 [PATCH] xfstests generic/260: get correct trimmed bytes Eryu Guan
@ 2013-10-04 1:07 ` Dave Chinner
2013-10-04 6:32 ` [PATCH v2] " Eryu Guan
0 siblings, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2013-10-04 1:07 UTC (permalink / raw)
To: Eryu Guan; +Cc: xfs
On Thu, Oct 03, 2013 at 07:57:17PM +0800, Eryu Guan wrote:
> Newer fstrim(1) reports trimmed bytes differently, e.g.
>
> new fstrim: /mnt/ext4: 9.7 GiB (10411118592 bytes) trimmed
> old fstrim: /mnt/ext4: 10411118592 bytes were trimmed
>
> generic/260 reports syntax error
>
> +./tests/generic/260: line 111: [: 9.7: integer expression expected
> +./tests/generic/260: line 121: [: 9.7: integer expression expected
> +./tests/generic/260: line 183: [: 9.7: integer expression expected
>
> Fix it so 260 passes with both old and new fstrim.
>
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---
> tests/generic/260 | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/tests/generic/260 b/tests/generic/260
> index dc8b822..bc9eb3b 100755
> --- a/tests/generic/260
> +++ b/tests/generic/260
> @@ -104,9 +104,8 @@ _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_PROG -v -o10M $SCRATCH_MNT)
> -nopref=${out##*: }
> -bytes=${nopref%% *}
> +out=$($FSTRIM_PROG -v -o10M $SCRATCH_MNT | egrep -o "[0-9]+ bytes")
> +bytes=${out%% *}
Can you add this as a "_filter_fstrim" function to common/filter
with a comment explaining what version of fstrim the output changed
in?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2] xfstests generic/260: get correct trimmed bytes
2013-10-04 1:07 ` Dave Chinner
@ 2013-10-04 6:32 ` Eryu Guan
2013-10-08 0:45 ` Dave Chinner
2013-10-16 20:20 ` Rich Johnston
0 siblings, 2 replies; 5+ messages in thread
From: Eryu Guan @ 2013-10-04 6:32 UTC (permalink / raw)
To: xfs; +Cc: Eryu Guan
Starting from util-linux v2.23 fstrim(1) reports trimmed bytes
differently, e.g.
new fstrim: /mnt/ext4: 9.7 GiB (10411118592 bytes) trimmed
old fstrim: /mnt/ext4: 10411118592 bytes were trimmed
generic/260 reports syntax error
+./tests/generic/260: line 111: [: 9.7: integer expression expected
+./tests/generic/260: line 121: [: 9.7: integer expression expected
+./tests/generic/260: line 183: [: 9.7: integer expression expected
Add a new filter called _filter_fstrim in common/filter and get the
correct trimmed bytes in generic/260, so the test passes with both old
and new fstrim.
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
v2: add _filter_fstrim to filter the output as Dave suggested
common/filter | 8 ++++++++
tests/generic/260 | 8 ++------
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/common/filter b/common/filter
index ee738ca..9144863 100644
--- a/common/filter
+++ b/common/filter
@@ -280,5 +280,13 @@ _filter_size_to_bytes()
echo $((${size:0:${#size}-1}*$mul))
}
+# Print trimmed bytes of fstrim
+# Starting from util-linux v2.23 fstrim usees human readable sizes in
+# verbose output
+_filter_fstrim()
+{
+ egrep -o "[0-9]+ bytes" | $AWK_PROG '{print $1}'
+}
+
# make sure this script returns success
/bin/true
diff --git a/tests/generic/260 b/tests/generic/260
index dc8b822..a003a7f 100755
--- a/tests/generic/260
+++ b/tests/generic/260
@@ -104,9 +104,7 @@ _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_PROG -v -o10M $SCRATCH_MNT)
-nopref=${out##*: }
-bytes=${nopref%% *}
+bytes=$($FSTRIM_PROG -v -o10M $SCRATCH_MNT | _filter_fstrim)
if [ $bytes -gt $(_math "$fssize*1024") ]; then
status=1
@@ -177,9 +175,7 @@ _scratch_mount
# It is because btrfs does not have not-yet-used parts of the device
# mapped and since we got here right after the mkfs, there is not
# enough free extents in the root tree.
-out=$($FSTRIM_PROG -v -l$len $SCRATCH_MNT)
-nopref=${out##*: }
-bytes=${nopref%% *}
+bytes=$($FSTRIM_PROG -v -l$len $SCRATCH_MNT | _filter_fstrim)
if [ $bytes -le $(_math "$fssize*512") ] && [ $FSTYP != "btrfs" ]; then
status=1
echo "It seems that fs logic handling len argument overflows"
--
1.8.3.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] xfstests generic/260: get correct trimmed bytes
2013-10-04 6:32 ` [PATCH v2] " Eryu Guan
@ 2013-10-08 0:45 ` Dave Chinner
2013-10-16 20:20 ` Rich Johnston
1 sibling, 0 replies; 5+ messages in thread
From: Dave Chinner @ 2013-10-08 0:45 UTC (permalink / raw)
To: Eryu Guan; +Cc: xfs
On Fri, Oct 04, 2013 at 02:32:56PM +0800, Eryu Guan wrote:
> Starting from util-linux v2.23 fstrim(1) reports trimmed bytes
> differently, e.g.
>
> new fstrim: /mnt/ext4: 9.7 GiB (10411118592 bytes) trimmed
> old fstrim: /mnt/ext4: 10411118592 bytes were trimmed
>
> generic/260 reports syntax error
>
> +./tests/generic/260: line 111: [: 9.7: integer expression expected
> +./tests/generic/260: line 121: [: 9.7: integer expression expected
> +./tests/generic/260: line 183: [: 9.7: integer expression expected
>
> Add a new filter called _filter_fstrim in common/filter and get the
> correct trimmed bytes in generic/260, so the test passes with both old
> and new fstrim.
>
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---
> v2: add _filter_fstrim to filter the output as Dave suggested
Looks good!
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] xfstests generic/260: get correct trimmed bytes
2013-10-04 6:32 ` [PATCH v2] " Eryu Guan
2013-10-08 0:45 ` Dave Chinner
@ 2013-10-16 20:20 ` Rich Johnston
1 sibling, 0 replies; 5+ messages in thread
From: Rich Johnston @ 2013-10-16 20:20 UTC (permalink / raw)
To: Eryu Guan, xfs
This has been committed.
Thanks
--Rich
commit 9366fb285e6a2fac935e03c54f6be50f90ab1e64
Author: Eryu Guan <eguan@redhat.com>
Date: Fri Oct 4 06:32:56 2013 +0000
xfstests generic/260: get correct trimmed bytes
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-16 20:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-03 11:57 [PATCH] xfstests generic/260: get correct trimmed bytes Eryu Guan
2013-10-04 1:07 ` Dave Chinner
2013-10-04 6:32 ` [PATCH v2] " Eryu Guan
2013-10-08 0:45 ` Dave Chinner
2013-10-16 20:20 ` Rich Johnston
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox