From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/2] btrfs-progs: check: Detect overlap csum items
Date: Wed, 4 Mar 2020 15:27:00 +0800 [thread overview]
Message-ID: <20200304072701.38403-2-wqu@suse.com> (raw)
In-Reply-To: <20200304072701.38403-1-wqu@suse.com>
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
next prev parent reply other threads:[~2020-03-04 7:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-04 7:26 [PATCH 0/2] btrfs-progs: check: Detect overlapping csum item Qu Wenruo
2020-03-04 7:27 ` Qu Wenruo [this message]
2020-03-04 7:27 ` [PATCH 2/2] btrfs-progs: fsck-tests: Add test image for " Qu Wenruo
2020-05-25 13:49 ` [PATCH 0/2] btrfs-progs: check: Detect " David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200304072701.38403-2-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox