Btrfs: fix crash on endio of reading corrupted block
authorLiu Bo <bo.li.liu@oracle.com>
Tue, 19 Aug 2014 15:33:13 +0000 (23:33 +0800)
committerChris Mason <clm@fb.com>
Thu, 21 Aug 2014 14:55:30 +0000 (07:55 -0700)
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>
fs/btrfs/extent_io.c

index 1c70cff4a9e1e7d5e48213c6d0e3be54f8b29cc9..f34b1e262d4ef74361095ef471509edfe56b4f1c 100644 (file)
@@ -2532,6 +2532,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
                                        test_bit(BIO_UPTODATE, &bio->bi_flags);
                                if (err)
                                        uptodate = 0;
+                               offset += len;
                                continue;
                        }
                }