* [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev
@ 2020-06-18 4:21 Zheng Bin
2020-06-18 4:21 ` [PATCH v3 1/2] " Zheng Bin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Zheng Bin @ 2020-06-18 4:21 UTC (permalink / raw)
To: hch, axboe, bvanassche, jaegeuk, viro, linux-fsdevel, linux-block
Cc: houtao1, yi.zhang, zhengbin13
v1->v2: modify comment, and make function 'kill_bdev' static
v2->v3: adapt code for commit 0c3796c24459
("loop: Factor out configuring loop from status")
Zheng Bin (2):
loop: replace kill_bdev with invalidate_bdev
block: make function 'kill_bdev' static
drivers/block/loop.c | 8 ++++----
fs/block_dev.c | 5 ++---
include/linux/fs.h | 2 --
3 files changed, 6 insertions(+), 9 deletions(-)
--
2.25.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/2] loop: replace kill_bdev with invalidate_bdev
2020-06-18 4:21 [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev Zheng Bin
@ 2020-06-18 4:21 ` Zheng Bin
2020-06-18 4:21 ` [PATCH v3 2/2] block: make function 'kill_bdev' static Zheng Bin
2020-06-18 15:24 ` [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Zheng Bin @ 2020-06-18 4:21 UTC (permalink / raw)
To: hch, axboe, bvanassche, jaegeuk, viro, linux-fsdevel, linux-block
Cc: houtao1, yi.zhang, zhengbin13
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>
---
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 c33bbbfd1bd9..475e1a738560 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1368,14 +1368,14 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
lo->lo_sizelimit != info->lo_sizelimit) {
size_changed = true;
sync_blockdev(lo->lo_device);
- kill_bdev(lo->lo_device);
+ invalidate_bdev(lo->lo_device);
}
/* I/O need to be drained during transfer transition */
blk_mq_freeze_queue(lo->lo_queue);
if (size_changed && lo->lo_device->bd_inode->i_mapping->nrpages) {
- /* If any pages were dirtied after kill_bdev(), try again */
+ /* If any pages were dirtied after invalidate_bdev(), try again */
err = -EAGAIN;
pr_warn("%s: loop%d (%s) has still dirty pages (nrpages=%lu)\n",
__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)
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.25.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/2] block: make function 'kill_bdev' static
2020-06-18 4:21 [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev Zheng Bin
2020-06-18 4:21 ` [PATCH v3 1/2] " Zheng Bin
@ 2020-06-18 4:21 ` Zheng Bin
2020-06-18 15:24 ` [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Zheng Bin @ 2020-06-18 4:21 UTC (permalink / raw)
To: hch, axboe, bvanassche, jaegeuk, viro, linux-fsdevel, linux-block
Cc: houtao1, yi.zhang, zhengbin13
kill_bdev does not have any external user, so make it static.
Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
fs/block_dev.c | 5 ++---
include/linux/fs.h | 2 --
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 47860e589388..0137ed31d58d 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -75,7 +75,7 @@ static void bdev_write_inode(struct block_device *bdev)
}
/* Kill _all_ buffers and pagecache , dirty or not.. */
-void kill_bdev(struct block_device *bdev)
+static void kill_bdev(struct block_device *bdev)
{
struct address_space *mapping = bdev->bd_inode->i_mapping;
@@ -84,8 +84,7 @@ void kill_bdev(struct block_device *bdev)
invalidate_bh_lrus();
truncate_inode_pages(mapping, 0);
-}
-EXPORT_SYMBOL(kill_bdev);
+}
/* Invalidate clean unused buffers and pagecache. */
void invalidate_bdev(struct block_device *bdev)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2e675c075694..f5bb1efc0c45 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2609,7 +2609,6 @@ extern void bdput(struct block_device *);
extern void invalidate_bdev(struct block_device *);
extern void iterate_bdevs(void (*)(struct block_device *, void *), void *);
extern int sync_blockdev(struct block_device *bdev);
-extern void kill_bdev(struct block_device *);
extern struct super_block *freeze_bdev(struct block_device *);
extern void emergency_thaw_all(void);
extern void emergency_thaw_bdev(struct super_block *sb);
@@ -2625,7 +2624,6 @@ static inline bool sb_is_blkdev_sb(struct super_block *sb)
#else
static inline void bd_forget(struct inode *inode) {}
static inline int sync_blockdev(struct block_device *bdev) { return 0; }
-static inline void kill_bdev(struct block_device *bdev) {}
static inline void invalidate_bdev(struct block_device *bdev) {}
static inline struct super_block *freeze_bdev(struct block_device *sb)
--
2.25.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev
2020-06-18 4:21 [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev Zheng Bin
2020-06-18 4:21 ` [PATCH v3 1/2] " Zheng Bin
2020-06-18 4:21 ` [PATCH v3 2/2] block: make function 'kill_bdev' static Zheng Bin
@ 2020-06-18 15:24 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2020-06-18 15:24 UTC (permalink / raw)
To: Zheng Bin, hch, bvanassche, jaegeuk, viro, linux-fsdevel, linux-block
Cc: houtao1, yi.zhang
On 6/17/20 10:21 PM, Zheng Bin wrote:
> v1->v2: modify comment, and make function 'kill_bdev' static
> v2->v3: adapt code for commit 0c3796c24459
> ("loop: Factor out configuring loop from status")
>
> Zheng Bin (2):
> loop: replace kill_bdev with invalidate_bdev
> block: make function 'kill_bdev' static
>
> drivers/block/loop.c | 8 ++++----
> fs/block_dev.c | 5 ++---
> include/linux/fs.h | 2 --
> 3 files changed, 6 insertions(+), 9 deletions(-)
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-18 15:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 4:21 [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev Zheng Bin
2020-06-18 4:21 ` [PATCH v3 1/2] " Zheng Bin
2020-06-18 4:21 ` [PATCH v3 2/2] block: make function 'kill_bdev' static Zheng Bin
2020-06-18 15:24 ` [PATCH v3 0/2] loop: replace kill_bdev with invalidate_bdev Jens Axboe
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).