From 69eb58e851a9230eae4f1dd5b24c11b82076a77e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 31 May 2021 15:23:48 +0300 Subject: [PATCH] block: remove __sync_blockdev Instead provide a sync_blockdev_nowait helper for sync_filesystem. Signed-off-by: Christoph Hellwig --- fs/block_dev.c | 10 +++++----- fs/internal.h | 5 ++--- fs/sync.c | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 61d280020aa0..cf898bb21082 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -517,13 +517,11 @@ static __init int blkdev_init(void) } module_init(blkdev_init); -int __sync_blockdev(struct block_device *bdev, int wait) +int sync_blockdev_nowait(struct block_device *bdev) { if (!bdev) return 0; - if (!wait) - return filemap_flush(bdev->bd_inode->i_mapping); - return filemap_write_and_wait(bdev->bd_inode->i_mapping); + return filemap_flush(bdev->bd_inode->i_mapping); } /* @@ -532,7 +530,9 @@ int __sync_blockdev(struct block_device *bdev, int wait) */ int sync_blockdev(struct block_device *bdev) { - return __sync_blockdev(bdev, 1); + if (!bdev) + return 0; + return filemap_write_and_wait(bdev->bd_inode->i_mapping); } EXPORT_SYMBOL(sync_blockdev); diff --git a/fs/internal.h b/fs/internal.h index 0047d70eae6b..028a2ed0b2b3 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -23,15 +23,14 @@ struct pipe_inode_info; #ifdef CONFIG_BLOCK extern void __init bdev_cache_init(void); -extern int __sync_blockdev(struct block_device *bdev, int wait); +int sync_blockdev_nowait(struct block_device *bdev); void iterate_bdevs(void (*)(struct block_device *, void *), void *); void emergency_thaw_bdev(struct super_block *sb); #else static inline void bdev_cache_init(void) { } - -static inline int __sync_blockdev(struct block_device *bdev, int wait) +static inline int sync_blockdev_nowait(struct block_device *bdev) { return 0; } diff --git a/fs/sync.c b/fs/sync.c index a3b7108991c6..fb15314ec97c 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -45,21 +45,21 @@ int sync_filesystem(struct super_block *sb) /* * For simple filesystems writeback_inodes_sb(sb) just dirties buffers * with inodes so we have to submit IO for these buffers via - * __sync_blockdev(). This also speeds up the wait == 1 case since in - * that case write_inode() functions do sync_dirty_buffer() and thus + * sync_blockdev_nowait(). This also speeds up the wait == 1 case since + * in that case write_inode() functions do sync_dirty_buffer() and thus * effectively write one block at a time. */ writeback_inodes_sb(sb, WB_REASON_SYNC); if (sb->s_op->sync_fs) sb->s_op->sync_fs(sb, 0); - ret = __sync_blockdev(sb->s_bdev, 0); + ret = sync_blockdev_nowait(sb->s_bdev); if (ret < 0) return ret; sync_inodes_sb(sb); if (sb->s_op->sync_fs) sb->s_op->sync_fs(sb, 1); - return __sync_blockdev(sb->s_bdev, 1); + return sync_blockdev(sb->s_bdev); } EXPORT_SYMBOL(sync_filesystem); -- 2.50.1