linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] loop: replace kill_bdev with invalidate_bdev
@ 2020-05-30  3:48 Zheng Bin
  2020-05-30  9:07 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Bin @ 2020-05-30  3:48 UTC (permalink / raw)
  To: axboe, bvanassche, jaegeuk, linux-block; +Cc: houtao1, yi.zhang, zhengbin13

When a filesystem is mounting 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>
---
 drivers/block/loop.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index da693e6a834e..418bb4621255 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1289,7 +1289,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
 	if (lo->lo_offset != info->lo_offset ||
 	    lo->lo_sizelimit != info->lo_sizelimit) {
 		sync_blockdev(lo->lo_device);
-		kill_bdev(lo->lo_device);
+		invalidate_bdev(lo->lo_device);
 	}

 	/* I/O need to be drained during transfer transition */
@@ -1320,7 +1320,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)

 	if (lo->lo_offset != info->lo_offset ||
 	    lo->lo_sizelimit != info->lo_sizelimit) {
-		/* kill_bdev should have truncated all the pages */
+		/* invalidate_bdev should have truncated all the pages */
 		if (lo->lo_device->bd_inode->i_mapping->nrpages) {
 			err = -EAGAIN;
 			pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",
@@ -1565,11 +1565,11 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
 		return 0;

 	sync_blockdev(lo->lo_device);
-	kill_bdev(lo->lo_device);
+	invalidate_bdev(lo->lo_device);

 	blk_mq_freeze_queue(lo->lo_queue);

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] loop: replace kill_bdev with invalidate_bdev
  2020-05-30  3:48 [PATCH] loop: replace kill_bdev with invalidate_bdev Zheng Bin
@ 2020-05-30  9:07 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2020-05-30  9:07 UTC (permalink / raw)
  To: Zheng Bin; +Cc: axboe, bvanassche, jaegeuk, linux-block, houtao1, yi.zhang

On Sat, May 30, 2020 at 11:48:09AM +0800, Zheng Bin wrote:
> When a filesystem is mounting on a loop device and on a loop ioctl

s/mounting/mounted/ ?

> 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>

Otherwise this looks reasonable:

Reviewed-by: Christoph Hellwig <hch@lst.de>

Can you also add a patch to now mark kill_bdev static in block_dev.c,
as this removed the last external users?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-30  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-30  3:48 [PATCH] loop: replace kill_bdev with invalidate_bdev Zheng Bin
2020-05-30  9:07 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).