From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: disk-io: output error message for tree block bytenr mismatch case
Date: Sun, 29 Nov 2020 18:16:32 +0800 [thread overview]
Message-ID: <20201129101632.110692-1-wqu@suse.com> (raw)
[BUG]
There is a report from the community that, btrfs aborted transaction due
to page_offset() of a tree block doesn't match with its eb header.
The code looks like this:
if (WARN_ON(found_start != start))
return -EUCLEAN;
[CAUSE]
With extra debug patch and great help from the reporter, it turns out
that, there is a memory bitflip:
[ 471.998855] BTRFS warning (device sda1): page_start and eb_start
mismatch, eb_start=17593525075968 page_start=1339031552
Note that:
eb_start = 0x10004fd00000 (Extracted from in-memory tree block header)
page_start = 0x00004fd00000 (Page offset)
This is an obvious memory bitflip.
[ENHANCEMENT]
The check on extent buffer header can be considered as part of tree
checker, but more fundamental.
So it's reasonable to follow the tree-checker scheme to outputting human
readable error message, and output the "write time tree block corruption
detected" message.
Also with the human readable error message, there is no need to always
trigger a kernel warning, just trigger the warning for debug build.
Link: https://www.spinics.net/lists/linux-btrfs/msg107895.html
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/disk-io.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 37b2e0aad162..b6040f8ffb08 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -465,8 +465,16 @@ static int csum_dirty_buffer(struct btrfs_fs_info *fs_info, struct bio_vec *bvec
* Please do not consolidate these warnings into a single if.
* It is useful to know what went wrong.
*/
- if (WARN_ON(found_start != start))
+ if (unlikely(found_start != start)) {
+ btrfs_err(fs_info,
+ "tree block bytenr mismatch, page_offset=%llu header_bytenr=%llu",
+ start, found_start);
+ btrfs_err(fs_info,
+ "block=%llu write time tree block corruption detected",
+ eb->start);
+ WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG));
return -EUCLEAN;
+ }
if (WARN_ON(!PageUptodate(page)))
return -EUCLEAN;
--
2.29.2
reply other threads:[~2020-11-29 10:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20201129101632.110692-1-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