Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: remove __sync_blockdev

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>

authored by

Christoph Hellwig and committed by
Jens Axboe
70164eb6 9a208ba5

+15 -13
+6 -5
block/bdev.c
··· 185 185 186 186 EXPORT_SYMBOL(sb_min_blocksize); 187 187 188 - int __sync_blockdev(struct block_device *bdev, int wait) 188 + int sync_blockdev_nowait(struct block_device *bdev) 189 189 { 190 190 if (!bdev) 191 191 return 0; 192 - if (!wait) 193 - return filemap_flush(bdev->bd_inode->i_mapping); 194 - return filemap_write_and_wait(bdev->bd_inode->i_mapping); 192 + return filemap_flush(bdev->bd_inode->i_mapping); 195 193 } 194 + EXPORT_SYMBOL_GPL(sync_blockdev_nowait); 196 195 197 196 /* 198 197 * Write out and wait upon all the dirty data associated with a block ··· 199 200 */ 200 201 int sync_blockdev(struct block_device *bdev) 201 202 { 202 - return __sync_blockdev(bdev, 1); 203 + if (!bdev) 204 + return 0; 205 + return filemap_write_and_wait(bdev->bd_inode->i_mapping); 203 206 } 204 207 EXPORT_SYMBOL(sync_blockdev); 205 208
-5
fs/internal.h
··· 23 23 #ifdef CONFIG_BLOCK 24 24 extern void __init bdev_cache_init(void); 25 25 26 - extern int __sync_blockdev(struct block_device *bdev, int wait); 27 26 void iterate_bdevs(void (*)(struct block_device *, void *), void *); 28 27 void emergency_thaw_bdev(struct super_block *sb); 29 28 #else ··· 30 31 { 31 32 } 32 33 33 - static inline int __sync_blockdev(struct block_device *bdev, int wait) 34 - { 35 - return 0; 36 - } 37 34 static inline void iterate_bdevs(void (*f)(struct block_device *, void *), 38 35 void *arg) 39 36 {
+4 -3
fs/sync.c
··· 3 3 * High-level sync()-related operations 4 4 */ 5 5 6 + #include <linux/blkdev.h> 6 7 #include <linux/kernel.h> 7 8 #include <linux/file.h> 8 9 #include <linux/fs.h> ··· 46 45 /* 47 46 * Do the filesystem syncing work. For simple filesystems 48 47 * writeback_inodes_sb(sb) just dirties buffers with inodes so we have 49 - * to submit I/O for these buffers via __sync_blockdev(). This also 48 + * to submit I/O for these buffers via sync_blockdev(). This also 50 49 * speeds up the wait == 1 case since in that case write_inode() 51 50 * methods call sync_dirty_buffer() and thus effectively write one block 52 51 * at a time. ··· 54 53 writeback_inodes_sb(sb, WB_REASON_SYNC); 55 54 if (sb->s_op->sync_fs) 56 55 sb->s_op->sync_fs(sb, 0); 57 - ret = __sync_blockdev(sb->s_bdev, 0); 56 + ret = sync_blockdev_nowait(sb->s_bdev); 58 57 if (ret < 0) 59 58 return ret; 60 59 61 60 sync_inodes_sb(sb); 62 61 if (sb->s_op->sync_fs) 63 62 sb->s_op->sync_fs(sb, 1); 64 - return __sync_blockdev(sb->s_bdev, 1); 63 + return sync_blockdev(sb->s_bdev); 65 64 } 66 65 EXPORT_SYMBOL(sync_filesystem); 67 66
+5
include/linux/blkdev.h
··· 1266 1266 #ifdef CONFIG_BLOCK 1267 1267 void invalidate_bdev(struct block_device *bdev); 1268 1268 int sync_blockdev(struct block_device *bdev); 1269 + int sync_blockdev_nowait(struct block_device *bdev); 1269 1270 #else 1270 1271 static inline void invalidate_bdev(struct block_device *bdev) 1271 1272 { 1272 1273 } 1273 1274 static inline int sync_blockdev(struct block_device *bdev) 1275 + { 1276 + return 0; 1277 + } 1278 + static inline int sync_blockdev_nowait(struct block_device *bdev) 1274 1279 { 1275 1280 return 0; 1276 1281 }