loop: replace kill_bdev with invalidate_bdev
authorZheng Bin <zhengbin13@huawei.com>
Thu, 18 Jun 2020 04:21:37 +0000 (12:21 +0800)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:36:52 +0000 (15:36 -0400)
commit588ad2b29ea3d4fe95da5ae161b370b539e16382
tree8dc626c86f239948df90d46bc84f49ca734486ef
parentd9a74e455070cf95a845cd153f44d915fa110da5
loop: replace kill_bdev with invalidate_bdev

commit f4bd34b139a3fa2808c4205f12714c65e1548c6c upstream.

When a filesystem is mounted on a loop device and on a loop ioctl
LOOP_SET_STATUS64, because of kill_bdev, buffer_head mappings are getting
destroyed.
kill_bdev
  truncate_inode_pages
    truncate_inode_pages_range
      do_invalidatepage
        block_invalidatepage
          discard_buffer  -->clear BH_Mapped flag

sb_bread
  __bread_gfp
  bh = __getblk_gfp
  -->discard_buffer clear BH_Mapped flag
  __bread_slow
    submit_bh
      submit_bh_wbc
        BUG_ON(!buffer_mapped(bh))  --> hit this BUG_ON

Fixes: 5db470e229e2 ("loop: drop caches if offset or block_size are changed")
Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/loop.c