* [PATCH] btrfs: add new filter for missing devices
@ 2021-09-03 10:50 Nikolay Borisov
2021-09-10 10:44 ` Nikolay Borisov
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Borisov @ 2021-09-03 10:50 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, Nikolay Borisov
There are pending changes to btrfs progs which make the output of
'btrfs fi show' more useful w.r.t to misisng devices. I.e instead of
printing a single '*** Some devices missing' at the end it now produces
one line per missing device:
Total devices 2 FS bytes used 128.00KiB
devid 1 size 5.00GiB used 1.26GiB path /dev/loop0
devid 2 size 0 used 0 path /dev/loop1 ***MISSING***
This obviously will break all existing tests so in anticipation for this
change landing the filter is being added.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
common/filter.btrfs | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/common/filter.btrfs b/common/filter.btrfs
index d4169cc69112..37b92478c939 100644
--- a/common/filter.btrfs
+++ b/common/filter.btrfs
@@ -13,6 +13,22 @@ _filter_devid()
sed -e "s/\(devid\)\s\+[0-9]\+/\1 <DEVID>/g"
}
+
+# Filter btrfs fi show output to match the old format, before the more verbose
+# missing device lines were add
+_filter_btrfs_missing_line()
+{
+ awk '
+ BEGIN {should_print=0}
+# skip empty lines as btrfs progs inserts such
+ /^$/ {next}
+ !/.*\*\*\*MISSING\*\*\*/ {print $0}
+ /.*\*\*\*MISSING\*\*\*/ {should_print=1}
+# The final \n adds an extra empty line to match with the original output
+ END {if (should_print) {print "\t*** Some devices missing"} print "\n"}
+ '
+}
+
# If passed a number as first arg, filter that number of devices
# If passed a UUID as second arg, filter that exact UUID
_filter_btrfs_filesystem_show()
@@ -31,9 +47,9 @@ _filter_btrfs_filesystem_show()
fi
# the uniq collapses all device lines into 1
- _filter_uuid $UUID | _filter_scratch | _filter_scratch_pool | \
- _filter_size | _filter_btrfs_version | _filter_devid | \
- _filter_zero_size | \
+ _filter_btrfs_missing_line | _filter_uuid $UUID | _filter_scratch | \
+ _filter_scratch_pool | _filter_size | _filter_btrfs_version | \
+ _filter_devid | _filter_zero_size | \
sed -e "s/\(Total devices\) $NUMDEVS/\1 $NUM_SUBST/g" | \
uniq
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: add new filter for missing devices
2021-09-03 10:50 [PATCH] btrfs: add new filter for missing devices Nikolay Borisov
@ 2021-09-10 10:44 ` Nikolay Borisov
0 siblings, 0 replies; 2+ messages in thread
From: Nikolay Borisov @ 2021-09-10 10:44 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs
On 3.09.21 г. 13:50, Nikolay Borisov wrote:
> There are pending changes to btrfs progs which make the output of
> 'btrfs fi show' more useful w.r.t to misisng devices. I.e instead of
> printing a single '*** Some devices missing' at the end it now produces
> one line per missing device:
>
> Total devices 2 FS bytes used 128.00KiB
> devid 1 size 5.00GiB used 1.26GiB path /dev/loop0
> devid 2 size 0 used 0 path /dev/loop1 ***MISSING***
>
> This obviously will break all existing tests so in anticipation for this
> change landing the filter is being added.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Please ignore this patch for now as we haven't decided on what the
format of the output should be so I'll likely be sending a V2 once this
is decided.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-10 10:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 10:50 [PATCH] btrfs: add new filter for missing devices Nikolay Borisov
2021-09-10 10:44 ` Nikolay Borisov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).