mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
xfstests generic/260: get correct trimmed bytes
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>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
This commit is contained in:
@@ -288,5 +288,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
|
||||
|
||||
+2
-6
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user