@@ -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;
[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(-)