bdev_write_inode() is really odd loop calling write_inode_now(). The bdev doesn't have any pages by now and if there are any dirty bits in the inode state, they are stale. Just call write_inode_now() once to clear them. Signed-off-by: Jan Kara --- block/bdev.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index f20f91b3176e..9fa72df4f47a 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -60,24 +60,6 @@ struct block_device *file_bdev(struct file *bdev_file) } EXPORT_SYMBOL(file_bdev); -static void bdev_write_inode(struct block_device *bdev) -{ - struct inode *inode = BD_INODE(bdev); - int ret; - - spin_lock(&inode->i_lock); - while (inode_state_read(inode) & I_DIRTY) { - spin_unlock(&inode->i_lock); - ret = write_inode_now(inode, true); - if (ret) - pr_warn_ratelimited( - "VFS: Dirty inode writeback failed for block device %pg (err=%d).\n", - bdev, ret); - spin_lock(&inode->i_lock); - } - spin_unlock(&inode->i_lock); -} - /* Kill _all_ buffers and pagecache , dirty or not.. */ static void kill_bdev(struct block_device *bdev) { @@ -755,7 +737,12 @@ static void blkdev_flush_mapping(struct block_device *bdev) WARN_ON_ONCE(bdev->bd_holders); sync_blockdev(bdev); kill_bdev(bdev); - bdev_write_inode(bdev); + /* + * All data is written out and evicted but inode can have some stale + * I_DIRTY bits set. Call write_inode_now() to get rid of them so that + * the inode can be evicted. + */ + write_inode_now(BD_INODE(bdev), 1); } static void blkdev_put_whole(struct block_device *bdev) -- 2.53.0