]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
fstests: filter.btrfs: handle detailed missing device report better
authorQu Wenruo <wqu@suse.com>
Wed, 9 Nov 2022 06:22:36 +0000 (14:22 +0800)
committerZorro Lang <zlang@kernel.org>
Wed, 23 Nov 2022 03:55:03 +0000 (11:55 +0800)
[FAILURES]
The following btrfs test cases failed with newer btrfs-progs:

- btrfs/197
- btrfs/198
- btrfs/254

They all fail due to output mismatch like the following:

     Label: none  uuid: <UUID>
      Total devices <NUM> FS bytes used <SIZE>
      devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
    - *** Some devices missing
    + devid <DEVID> size 0 used 0 path  MISSING

[CAUSE]
Since btrfs-progs commit 957a79c9b016 ("btrfs-progs: fi show: print
missing device for a mounted file system"), we output the detailed info
of a missing device if "btrfs filesystem show" is executed using
"-m <mnt>" option.

Such detailed output no longer follows the old format, thus causing the
output mismatch.

[FIX]
Update _filter_btrfs_filesystem_show() to handle detailed missing
device by:

- Buffer the output first

- Output the first two lines
  Which is always label/uuid and the total device accounting.

- Replace the detailed missing device line with old output

- Sort (in reverse order) and uniq the device list

By this we can handle both old and new output correctly.
Although this means we lacks the ability to detect mutltiple missing
devices, thankfully the involved test cases are not checking this yet.

[ Zorro: add "rm -f $tmp.btrfs_filesystem_show" ]

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/filter.btrfs

index d4169cc69112588d74a0fd3a8362c6cc35c8060a..02c6b92dfa9465d976db211d6a99a10fed49859b 100644 (file)
@@ -35,7 +35,18 @@ _filter_btrfs_filesystem_show()
        _filter_size | _filter_btrfs_version | _filter_devid | \
        _filter_zero_size | \
        sed -e "s/\(Total devices\) $NUMDEVS/\1 $NUM_SUBST/g" | \
-       uniq
+       uniq > $tmp.btrfs_filesystem_show
+
+       # The first two lines are Label/UUID and total devices
+       head -n 2 $tmp.btrfs_filesystem_show
+
+       # The remaining is the device list, first filter out the detailed
+       # missing device to the generic one.
+       # Then sort and uniq the result
+       tail -n +3 $tmp.btrfs_filesystem_show | \
+       sed -e "s/devid <DEVID> size 0 used 0 path  MISSING/*** Some devices missing/" | \
+       sort -r | uniq
+       rm -f $tmp.btrfs_filesystem_show
 }
 
 # This eliminates all numbers, and shows only unique lines,