From: Chandan Rajendra Date: Sun, 25 Dec 2016 13:31:03 +0000 (+0530) Subject: clean_bdev_aliases: Prevent cleaning blocks that are not in block range X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=6c006a9d94bfb5cbcc5150e8fd7f45d3f92f3ee8;p=linux-beck.git clean_bdev_aliases: Prevent cleaning blocks that are not in block range The first block to be cleaned may start at a non-zero page offset. In such a scenario clean_bdev_aliases() will end up cleaning blocks that do not fall in the range of blocks to be cleaned. This commit fixes the issue by skipping blocks that do not fall in valid block range. Signed-off-by: Chandan Rajendra Reviewed-by: Jan Kara Reviewed-by: Eryu Guan Signed-off-by: Jens Axboe --- diff --git a/fs/buffer.c b/fs/buffer.c index d21771fcf7d3..0e87401cf335 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1660,7 +1660,7 @@ void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len) head = page_buffers(page); bh = head; do { - if (!buffer_mapped(bh)) + if (!buffer_mapped(bh) || (bh->b_blocknr < block)) goto next; if (bh->b_blocknr >= block + len) break;