Skip to content

Commit f4bd34b

Browse files
zhengbin13axboe
authored andcommitted
loop: replace kill_bdev with invalidate_bdev
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: 5db470e ("loop: drop caches if offset or block_size are changed") Signed-off-by: Zheng Bin <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent bc163c2 commit f4bd34b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/block/loop.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,14 +1368,14 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
13681368
lo->lo_sizelimit != info->lo_sizelimit) {
13691369
size_changed = true;
13701370
sync_blockdev(lo->lo_device);
1371-
kill_bdev(lo->lo_device);
1371+
invalidate_bdev(lo->lo_device);
13721372
}
13731373

13741374
/* I/O need to be drained during transfer transition */
13751375
blk_mq_freeze_queue(lo->lo_queue);
13761376

13771377
if (size_changed && lo->lo_device->bd_inode->i_mapping->nrpages) {
1378-
/* If any pages were dirtied after kill_bdev(), try again */
1378+
/* If any pages were dirtied after invalidate_bdev(), try again */
13791379
err = -EAGAIN;
13801380
pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",
13811381
__func__, lo->lo_number, lo->lo_file_name,
@@ -1615,11 +1615,11 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
16151615
return 0;
16161616

16171617
sync_blockdev(lo->lo_device);
1618-
kill_bdev(lo->lo_device);
1618+
invalidate_bdev(lo->lo_device);
16191619

16201620
blk_mq_freeze_queue(lo->lo_queue);
16211621

1622-
/* kill_bdev should have truncated all the pages */
1622+
/* invalidate_bdev should have truncated all the pages */
16231623
if (lo->lo_device->bd_inode->i_mapping->nrpages) {
16241624
err = -EAGAIN;
16251625
pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",

0 commit comments

Comments
 (0)