Commit a848c23fb1e59ddcde23b7715b08ad8bfef78ee0

Authored by Liu Bo
Committed by Greg Kroah-Hartman
1 parent bd7c57d3ca

Btrfs: fix crash on endio of reading corrupted block

commit 38c1c2e44bacb37efd68b90b3f70386a8ee370ee upstream.

The crash is

------------[ cut here ]------------
kernel BUG at fs/btrfs/extent_io.c:2124!
[...]
Workqueue: btrfs-endio normal_work_helper [btrfs]
RIP: 0010:[<ffffffffa02d6055>]  [<ffffffffa02d6055>] end_bio_extent_readpage+0xb45/0xcd0 [btrfs]

This is in fact a regression.

It is because we forgot to increase @offset properly in reading corrupted block,
so that the @offset remains, and this leads to checksum errors while reading
left blocks queued up in the same bio, and then ends up with hiting the above
BUG_ON.

Reported-by: Chris Murphy <lists@colorremedies.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 1 additions and 0 deletions Side-by-side Diff

fs/btrfs/extent_io.c
... ... @@ -2525,6 +2525,7 @@
2525 2525 test_bit(BIO_UPTODATE, &bio->bi_flags);
2526 2526 if (err)
2527 2527 uptodate = 0;
  2528 + offset += len;
2528 2529 continue;
2529 2530 }
2530 2531 }