block: remove __sync_blockdev
authorChristoph Hellwig <hch@lst.de>
Tue, 19 Oct 2021 06:25:25 +0000 (08:25 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 22 Oct 2021 14:36:55 +0000 (08:36 -0600)
Instead offer a new sync_blockdev_nowait helper for the !wait case.
This new helper is exported as it will grow modular callers in a bit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211019062530.2174626-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bdev.c
fs/internal.h
fs/sync.c
include/linux/blkdev.h

index 7e6156203a71c5ba2d62d69250b4e9607205b01c..9a33c414f450265e9dc77436c08f58d4c22b8b77 100644 (file)
@@ -185,14 +185,13 @@ int sb_min_blocksize(struct super_block *sb, int size)
 
 EXPORT_SYMBOL(sb_min_blocksize);
 
-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);
 }
+EXPORT_SYMBOL_GPL(sync_blockdev_nowait);
 
 /*
  * Write out and wait upon all the dirty data associated with a block
@@ -200,7 +199,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);
 
index 3cd065c8a66b4ceb99d255f4c0fa82314fa218d9..b5caa16f4645dbd3f069d3bc95fc8c3b463f04d5 100644 (file)
@@ -23,7 +23,6 @@ struct pipe_inode_info;
 #ifdef CONFIG_BLOCK
 extern void __init bdev_cache_init(void);
 
-extern int __sync_blockdev(struct block_device *bdev, int wait);
 void iterate_bdevs(void (*)(struct block_device *, void *), void *);
 void emergency_thaw_bdev(struct super_block *sb);
 #else
@@ -31,10 +30,6 @@ static inline void bdev_cache_init(void)
 {
 }
 
-static inline int __sync_blockdev(struct block_device *bdev, int wait)
-{
-       return 0;
-}
 static inline void iterate_bdevs(void (*f)(struct block_device *, void *),
                void *arg)
 {
index 0d6cdc507cb9867a2c863522c9265b7629b33e0e..a621089eb07ee17f3107dc9c1716b459f8ff9443 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -3,6 +3,7 @@
  * High-level sync()-related operations
  */
 
+#include <linux/blkdev.h>
 #include <linux/kernel.h>
 #include <linux/file.h>
 #include <linux/fs.h>
@@ -45,7 +46,7 @@ int sync_filesystem(struct super_block *sb)
        /*
         * Do the filesystem syncing work.  For simple filesystems
         * writeback_inodes_sb(sb) just dirties buffers with inodes so we have
-        * to submit I/O for these buffers via __sync_blockdev().  This also
+        * to submit I/O for these buffers via sync_blockdev().  This also
         * speeds up the wait == 1 case since in that case write_inode()
         * methods call sync_dirty_buffer() and thus effectively write one block
         * at a time.
@@ -53,14 +54,14 @@ int sync_filesystem(struct super_block *sb)
        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);
 
index f72ccb2829db9f34b5aaee53eddffa7fc1b23809..4b5a6bbdacd05b24f67921ac7a91c5541b26325f 100644 (file)
@@ -1266,6 +1266,7 @@ int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart,
 #ifdef CONFIG_BLOCK
 void invalidate_bdev(struct block_device *bdev);
 int sync_blockdev(struct block_device *bdev);
+int sync_blockdev_nowait(struct block_device *bdev);
 #else
 static inline void invalidate_bdev(struct block_device *bdev)
 {
@@ -1274,6 +1275,10 @@ static inline int sync_blockdev(struct block_device *bdev)
 {
        return 0;
 }
+static inline int sync_blockdev_nowait(struct block_device *bdev)
+{
+       return 0;
+}
 #endif
 int fsync_bdev(struct block_device *bdev);