All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs-progs: check: Detect overlapping csum item
@ 2020-03-04  7:26 Qu Wenruo
  2020-03-04  7:27 ` [PATCH 1/2] btrfs-progs: check: Detect overlap csum items Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Qu Wenruo @ 2020-03-04  7:26 UTC (permalink / raw)
  To: linux-btrfs

There is one report about tree-checker rejecting overlapping csum item.

I haven't yet seen another report, thus the problem doesn't look
widespread, thus maybe some regression in older kernels.

At least let btrfs check to detect such problem.
If we had another report, I'll spending extra time for the repair
functionality (it's not that simple, as it involves a lot of csum item
operation, and unexpected overlapping range).

Qu Wenruo (2):
  btrfs-progs: check: Detect overlap csum items
  btrfs-progs: fsck-tests: Add test image for overlapping csum item

 check/main.c                                  |   9 +++++++++
 .../overlap_csum_item.img.xz                  | Bin 0 -> 2172 bytes
 .../fsck-tests/045-overlap-csum-item/test.sh  |  19 ++++++++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100644 tests/fsck-tests/045-overlap-csum-item/overlap_csum_item.img.xz
 create mode 100755 tests/fsck-tests/045-overlap-csum-item/test.sh

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] btrfs-progs: check: Detect overlap csum items
  2020-03-04  7:26 [PATCH 0/2] btrfs-progs: check: Detect overlapping csum item Qu Wenruo
@ 2020-03-04  7:27 ` Qu Wenruo
  2020-03-04  7:27 ` [PATCH 2/2] btrfs-progs: fsck-tests: Add test image for overlapping csum item Qu Wenruo
  2020-05-25 13:49 ` [PATCH 0/2] btrfs-progs: check: Detect " David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2020-03-04  7:27 UTC (permalink / raw)
  To: linux-btrfs

There is a report about csum item overlap, which makes newer btrfs
kernel to reject it due to tree-checker.

Now let btrfs-progs have the same ability to detect such problem.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/check/main.c b/check/main.c
index d02dd1636852..c526c72d158e 100644
--- a/check/main.c
+++ b/check/main.c
@@ -5893,6 +5893,7 @@ static int check_csums(struct btrfs_root *root)
 	struct btrfs_path path;
 	struct extent_buffer *leaf;
 	struct btrfs_key key;
+	u64 last_data_end = 0;
 	u64 offset = 0, num_bytes = 0;
 	u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy);
 	int errors = 0;
@@ -5952,6 +5953,13 @@ static int check_csums(struct btrfs_root *root)
 			continue;
 		}
 
+		if (key.offset < last_data_end) {
+			error(
+	"csum overlap, current bytenr=%llu prev_end=%llu, eb=%llu slot=%u",
+				key.offset, last_data_end, leaf->start,
+				path.slots[0]);
+			errors++;
+		}
 		data_len = (btrfs_item_size_nr(leaf, path.slots[0]) /
 			      csum_size) * root->fs_info->sectorsize;
 		if (!verify_csum)
@@ -5982,6 +5990,7 @@ skip_csum_check:
 			num_bytes = 0;
 		}
 		num_bytes += data_len;
+		last_data_end = key.offset + data_len;
 		path.slots[0]++;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] btrfs-progs: fsck-tests: Add test image for overlapping csum item
  2020-03-04  7:26 [PATCH 0/2] btrfs-progs: check: Detect overlapping csum item Qu Wenruo
  2020-03-04  7:27 ` [PATCH 1/2] btrfs-progs: check: Detect overlap csum items Qu Wenruo
@ 2020-03-04  7:27 ` Qu Wenruo
  2020-05-25 13:49 ` [PATCH 0/2] btrfs-progs: check: Detect " David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2020-03-04  7:27 UTC (permalink / raw)
  To: linux-btrfs

The image has a csum item overlap with next csum item, make sure btrfs
check can detect it.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../overlap_csum_item.img.xz                  | Bin 0 -> 2172 bytes
 .../fsck-tests/045-overlap-csum-item/test.sh  |  19 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 tests/fsck-tests/045-overlap-csum-item/overlap_csum_item.img.xz
 create mode 100755 tests/fsck-tests/045-overlap-csum-item/test.sh

diff --git a/tests/fsck-tests/045-overlap-csum-item/overlap_csum_item.img.xz b/tests/fsck-tests/045-overlap-csum-item/overlap_csum_item.img.xz
new file mode 100644
index 0000000000000000000000000000000000000000..9bcf152c7c590d4dca915f5d1ecb15fb4a58af84
GIT binary patch
literal 2172
zcmV-?2!r?iH+ooF000E$*0e?f03iV!0000G&sfah5B~@|T>wRyj;C3^v%$$4d1t#p
zhA1?_T+OH))zRFdMm2c&pnO1wG%HdgqI}w%X?J7m77UG=uUbZE^{Xv=U?o*n&ukHJ
z0b3B>5Ui4qA{eq9)|q*K|9wB5H4fyt4jl()>6hOTdc`kC)*Xeb9d9xC+HniKLB{Xd
z*4D|3NF#40L&yo>s0zoXV-yPOo{HLNDT>F5D5~|0s|`Ib`+O*TVUe}OeW#L<f?r7n
z9%@#>inXNoXGAEX8w{s<=@appY}Gf4uNY2DvFr94hx8d>LE*E%W17TzSz~G$a!@+s
zf-k14+prl-s9Qf(WIo_$os3JbCdfQCV$+CV%yg!#4BDYxc!B%OLDTi6ZhxgiiauGR
zV``d$m7{3UR19>&BI*LNJ(!-|QGiy-9u$k}E1`?^ihp*D&cl<wYffJxFW&o8^Q+RE
zNXM2=O(&FS^q(zq>AMU9<gHo#IUN3M!}RBksrCGZoUD4amrgJUOfVwlQ7C!MCASbW
zzHFhAWBM|uE8~SVt8t!BjbYX84&%e{P^_3H4p{6$f0PQx-<{Jl0+X+cA-x$E9AQ>9
zezal;)TJ%+=@3bnbf?N*nD6gUEg3@G4!&*k9;2^^8YmM1Fsaw`7s&nMRzRtKo_={{
zx-AGCk1g1^%ITHu3`O_-;?2e3@#6=Nyuh1Mda0s)q2PkMQ>?wD^GMWAqEE<|d%M6{
zL<5f;x<Qr<=9{vc*dPJx2QlU3J?4GJgwo3iWfSs{uZ+m<1px7E0K!P@-W)3F#t>mm
z`ltDJr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sh
new file mode 100755
index 000000000000..06649ed9331c
--- /dev/null
+++ b/tests/fsck-tests/045-overlap-csum-item/test.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Verify that check can detect overlapped csum items
+#
+# There is one report of overlap csum items, causing tree-checker to reject
+# the csum tree.
+#
+# Make sure btrfs check can at least detect such error
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_image() {
+	run_mustfail "overlapping csum item not detected" \
+		"$TOP/btrfs" check "$1"
+}
+
+check_all_images
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] btrfs-progs: check: Detect overlapping csum item
  2020-03-04  7:26 [PATCH 0/2] btrfs-progs: check: Detect overlapping csum item Qu Wenruo
  2020-03-04  7:27 ` [PATCH 1/2] btrfs-progs: check: Detect overlap csum items Qu Wenruo
  2020-03-04  7:27 ` [PATCH 2/2] btrfs-progs: fsck-tests: Add test image for overlapping csum item Qu Wenruo
@ 2020-05-25 13:49 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2020-05-25 13:49 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Wed, Mar 04, 2020 at 03:26:59PM +0800, Qu Wenruo wrote:
> There is one report about tree-checker rejecting overlapping csum item.

Do you have link of the report?

I think the bug has been fixed by "btrfs: fix corrupt log due to
concurrent fsync of inodes with shared extents".

> I haven't yet seen another report, thus the problem doesn't look
> widespread, thus maybe some regression in older kernels.
> 
> At least let btrfs check to detect such problem.
> If we had another report, I'll spending extra time for the repair
> functionality (it's not that simple, as it involves a lot of csum item
> operation, and unexpected overlapping range).
> 
> Qu Wenruo (2):
>   btrfs-progs: check: Detect overlap csum items
>   btrfs-progs: fsck-tests: Add test image for overlapping csum item

Added to devel.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-25 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04  7:26 [PATCH 0/2] btrfs-progs: check: Detect overlapping csum item Qu Wenruo
2020-03-04  7:27 ` [PATCH 1/2] btrfs-progs: check: Detect overlap csum items Qu Wenruo
2020-03-04  7:27 ` [PATCH 2/2] btrfs-progs: fsck-tests: Add test image for overlapping csum item Qu Wenruo
2020-05-25 13:49 ` [PATCH 0/2] btrfs-progs: check: Detect " David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.