[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1119817: bookworm-pu: package btrfs-progs/6.2-1+deb12u2



Package: release.debian.org
Severity: normal
Tags: bookworm
X-Debbugs-Cc: btrfs-progs@packages.debian.org
Control: affects -1 + src:btrfs-progs
Control: block 1116278 with -1
User: release.debian.org@packages.debian.org
Usertags: pu

[ Reason ]
(Bug: #1116278)
There are currently two interfaces to query a btrfs filesystem's
health.

  1. "btrfs device stats" (for humans and machines)
  2. Log parsing (by machines for better instrumentation)

Humans will often prefer the output in prettyfied tabular form;
however, btrfs-progs 6.2-1 (and possibly earlier) hides file and/or
metadata corruption when outputting device stats in this format.

[ Impact ]
File and/or metadata corruption requires sysadmin action; That action
is `btrfs scrub`, which repairs the bad data (when there is a 2nd copy
ie: raid1 profile).  If a 2nd copy is not available then the necessity
of having to restore corrupted files from backup (in profile=single)
will no longer be hidden.  Failure to run a scrub means that secondary
corruption can wipe out the filesystem.

[ Tests ]
Upstream tests, a large body of users, real-world testing since Sat
Mar 25 19:41:39 2023 (the date of the first upstream release that
included this fix).  And I manually tested that it doesn't introduce a
regression as well as that it actually fixes the bug.

[ Risks ]
This patch is cherry picked from upstream, and the first release to
include it was 6.2.2 (bugfix release to 6.2); it applies 100% cleanly
to 6.2.  The code is simple and only affects display of filesystem
state.  The changed code is in an area that does not touch data.
Upstream is now at 6.17 and it not presented any problems.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
I'm not sure what I can add that isn't redundant to the header of
0002-btrfs-progs-dev-stats-fix-printing-wrong-values-in-t.patch, the
Debian changelog, and this bug report.


Regards,
Nicholas
diff -Nru btrfs-progs-6.2/debian/changelog btrfs-progs-6.2/debian/changelog
--- btrfs-progs-6.2/debian/changelog	2024-10-16 13:59:06.000000000 -0400
+++ btrfs-progs-6.2/debian/changelog	2025-10-31 15:16:11.000000000 -0400
@@ -1,3 +1,19 @@
+btrfs-progs (6.2-1+deb12u2) bookworm; urgency=medium
+
+  * Acknowledge NMU.
+  * Cherry pick upstream commit:cba1ef1 "btrfs-progs: dev stats: fix printing
+    wrong values in tabular output" because this bug hides file and/or
+    metadata corruption that requires sysadmin action; That action is `btrfs
+    scrub`, which repairs the bad data (when there is a 2nd copy ie: raid1
+    profile).  If a 2nd copy is not available then the necessity of having to
+    restore corrupted files from backup (in profile=single) will no longer be
+    hidden.  Thanks to Craig Hesling for reporting the bug and identifying the
+    commit of the fix (Closes: #1116278).
+  * Update the Maintainer field, because Adam Borowski is no longer
+    maintaining this package in Debian.
+
+ -- Nicholas D Steeves <sten@debian.org>  Fri, 31 Oct 2025 15:16:11 -0400
+
 btrfs-progs (6.2-1+deb12u1) bookworm; urgency=medium
 
   * Non-maintainer upload.
diff -Nru btrfs-progs-6.2/debian/control btrfs-progs-6.2/debian/control
--- btrfs-progs-6.2/debian/control	2023-02-28 18:16:51.000000000 -0500
+++ btrfs-progs-6.2/debian/control	2025-10-31 15:16:11.000000000 -0400
@@ -1,7 +1,7 @@
 Source: btrfs-progs
 Section: admin
 Priority: optional
-Maintainer: Adam Borowski <kilobyte@angband.pl>
+Maintainer: Nicholas D Steeves <sten@debian.org>
 Build-Depends: debhelper-compat (= 13),
                libext2fs-dev,
                pkg-config,
diff -Nru btrfs-progs-6.2/debian/patches/0002-btrfs-progs-dev-stats-fix-printing-wrong-values-in-t.patch btrfs-progs-6.2/debian/patches/0002-btrfs-progs-dev-stats-fix-printing-wrong-values-in-t.patch
--- btrfs-progs-6.2/debian/patches/0002-btrfs-progs-dev-stats-fix-printing-wrong-values-in-t.patch	1969-12-31 19:00:00.000000000 -0500
+++ btrfs-progs-6.2/debian/patches/0002-btrfs-progs-dev-stats-fix-printing-wrong-values-in-t.patch	2025-10-31 15:16:11.000000000 -0400
@@ -0,0 +1,83 @@
+From: David Sterba <dsterba@suse.com>
+Date: Tue, 7 Mar 2023 21:09:03 +0100
+Subject: btrfs-progs: dev stats: fix printing wrong values in tabular output
+
+The tabular output prints the same value for all columns:
+
+  # btrfs device stats /srv/btrfs-data
+  [/dev/sdc1].write_io_errs    0
+  [/dev/sdc1].read_io_errs     0
+  [/dev/sdc1].flush_io_errs    0
+  [/dev/sdc1].corruption_errs  0
+  [/dev/sdc1].generation_errs  0
+  [/dev/sdb1].write_io_errs    7489899
+  [/dev/sdb1].read_io_errs     3751023
+  [/dev/sdb1].flush_io_errs    117
+  [/dev/sdb1].corruption_errs  68
+  [/dev/sdb1].generation_errs  25
+
+  # btrfs device stats -T /srv/btrfs-data
+  Id Path      Write errors Read errors Flush errors Corruption errors Generation errors
+  -- --------- ------------ ----------- ------------ ----------------- -----------------
+   1 /dev/sdc1            0           0            0                 0                 0
+   2 /dev/sdb1           25          25           25                25                25
+
+The table_printf has a fixed list of columns and should not iterate over
+them. Only check if some of the value is set and return error.
+
+Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217045
+Issue: #585
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ cmds/device.c | 30 +++++++-----------------------
+ 1 file changed, 7 insertions(+), 23 deletions(-)
+
+diff --git a/cmds/device.c b/cmds/device.c
+index 2404842..ec70bb3 100644
+--- a/cmds/device.c
++++ b/cmds/device.c
+@@ -648,16 +648,6 @@ static int print_device_stat_tabular(struct string_table *table, int row,
+ 	char *canonical_path = path_canonicalize(path);
+ 	int j;
+ 	int err = 0;
+-	static const struct {
+-		const char name[32];
+-		enum btrfs_dev_stat_values stat_idx;
+-	} dev_stats[] = {
+-		{ "write_io_errs", BTRFS_DEV_STAT_WRITE_ERRS },
+-		{ "read_io_errs", BTRFS_DEV_STAT_READ_ERRS },
+-		{ "flush_io_errs", BTRFS_DEV_STAT_FLUSH_ERRS },
+-		{ "corruption_errs", BTRFS_DEV_STAT_CORRUPTION_ERRS },
+-		{ "generation_errs", BTRFS_DEV_STAT_GENERATION_ERRS },
+-	};
+ 
+ 	/* Skip header + --- line */
+ 	row += 2;
+@@ -677,20 +667,14 @@ static int print_device_stat_tabular(struct string_table *table, int row,
+ 	table_printf(table, 1, row, ">%s", canonical_path);
+ 	free(canonical_path);
+ 
+-	for (j = 0; j < ARRAY_SIZE(dev_stats); j++) {
+-		enum btrfs_dev_stat_values stat_idx = dev_stats[j].stat_idx;
++	table_printf(table, 2, row, ">%llu", args->values[BTRFS_DEV_STAT_WRITE_ERRS]);
++	table_printf(table, 3, row, ">%llu", args->values[BTRFS_DEV_STAT_READ_ERRS]);
++	table_printf(table, 4, row, ">%llu", args->values[BTRFS_DEV_STAT_FLUSH_ERRS]);
++	table_printf(table, 5, row, ">%llu", args->values[BTRFS_DEV_STAT_CORRUPTION_ERRS]);
++	table_printf(table, 6, row, ">%llu", args->values[BTRFS_DEV_STAT_GENERATION_ERRS]);
+ 
+-		/* We got fewer items than we know */
+-		if (args->nr_items < stat_idx + 1)
+-			continue;
+-
+-		table_printf(table, 2, row, ">%llu", args->values[stat_idx]);
+-		table_printf(table, 3, row, ">%llu", args->values[stat_idx]);
+-		table_printf(table, 4, row, ">%llu", args->values[stat_idx]);
+-		table_printf(table, 5, row, ">%llu", args->values[stat_idx]);
+-		table_printf(table, 6, row, ">%llu", args->values[stat_idx]);
+-
+-		if (check && (args->values[stat_idx] > 0))
++	for (j = 0; j < BTRFS_DEV_STAT_VALUES_MAX; j++) {
++		if (check && (args->values[j] > 0))
+ 			err |= 64;
+ 	}
+ 
diff -Nru btrfs-progs-6.2/debian/patches/series btrfs-progs-6.2/debian/patches/series
--- btrfs-progs-6.2/debian/patches/series	2024-10-16 13:59:06.000000000 -0400
+++ btrfs-progs-6.2/debian/patches/series	2025-10-31 15:16:11.000000000 -0400
@@ -1 +1,2 @@
 convert-fix-bad-csum-for-migrated-range.diff
+0002-btrfs-progs-dev-stats-fix-printing-wrong-values-in-t.patch

Reply to: