Skip to content

Commit 70164eb

Browse files
Christoph Hellwigaxboe
authored andcommitted
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>
1 parent 9a208ba commit 70164eb

4 files changed

Lines changed: 15 additions & 13 deletions

File tree

‎block/bdev.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,23 @@ int sb_min_blocksize(struct super_block *sb, int size)
185185

186186
EXPORT_SYMBOL(sb_min_blocksize);
187187

188-
int __sync_blockdev(struct block_device *bdev, int wait)
188+
int sync_blockdev_nowait(struct block_device *bdev)
189189
{
190190
if (!bdev)
191191
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);
195193
}
194+
EXPORT_SYMBOL_GPL(sync_blockdev_nowait);
196195

197196
/*
198197
* Write out and wait upon all the dirty data associated with a block
199198
* device via its mapping. Does not take the superblock lock.
200199
*/
201200
int sync_blockdev(struct block_device *bdev)
202201
{
203-
return __sync_blockdev(bdev, 1);
202+
if (!bdev)
203+
return 0;
204+
return filemap_write_and_wait(bdev->bd_inode->i_mapping);
204205
}
205206
EXPORT_SYMBOL(sync_blockdev);
206207

‎fs/internal.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,13 @@ struct pipe_inode_info;
2323
#ifdef CONFIG_BLOCK
2424
extern void __init bdev_cache_init(void);
2525

26-
extern int __sync_blockdev(struct block_device *bdev, int wait);
2726
void iterate_bdevs(void (*)(struct block_device *, void *), void *);
2827
void emergency_thaw_bdev(struct super_block *sb);
2928
#else
3029
static inline void bdev_cache_init(void)
3130
{
3231
}
3332

34-
static inline int __sync_blockdev(struct block_device *bdev, int wait)
35-
{
36-
return 0;
37-
}
3833
static inline void iterate_bdevs(void (*f)(struct block_device *, void *),
3934
void *arg)
4035
{

‎fs/sync.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* High-level sync()-related operations
44
*/
55

6+
#include <linux/blkdev.h>
67
#include <linux/kernel.h>
78
#include <linux/file.h>
89
#include <linux/fs.h>
@@ -45,22 +46,22 @@ int sync_filesystem(struct super_block *sb)
4546
/*
4647
* Do the filesystem syncing work. For simple filesystems
4748
* writeback_inodes_sb(sb) just dirties buffers with inodes so we have
48-
* to submit I/O for these buffers via __sync_blockdev(). This also
49+
* to submit I/O for these buffers via sync_blockdev(). This also
4950
* speeds up the wait == 1 case since in that case write_inode()
5051
* methods call sync_dirty_buffer() and thus effectively write one block
5152
* at a time.
5253
*/
5354
writeback_inodes_sb(sb, WB_REASON_SYNC);
5455
if (sb->s_op->sync_fs)
5556
sb->s_op->sync_fs(sb, 0);
56-
ret = __sync_blockdev(sb->s_bdev, 0);
57+
ret = sync_blockdev_nowait(sb->s_bdev);
5758
if (ret < 0)
5859
return ret;
5960

6061
sync_inodes_sb(sb);
6162
if (sb->s_op->sync_fs)
6263
sb->s_op->sync_fs(sb, 1);
63-
return __sync_blockdev(sb->s_bdev, 1);
64+
return sync_blockdev(sb->s_bdev);
6465
}
6566
EXPORT_SYMBOL(sync_filesystem);
6667

‎include/linux/blkdev.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,7 @@ int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart,
12661266
#ifdef CONFIG_BLOCK
12671267
void invalidate_bdev(struct block_device *bdev);
12681268
int sync_blockdev(struct block_device *bdev);
1269+
int sync_blockdev_nowait(struct block_device *bdev);
12691270
#else
12701271
static inline void invalidate_bdev(struct block_device *bdev)
12711272
{
@@ -1274,6 +1275,10 @@ static inline int sync_blockdev(struct block_device *bdev)
12741275
{
12751276
return 0;
12761277
}
1278+
static inline int sync_blockdev_nowait(struct block_device *bdev)
1279+
{
1280+
return 0;
1281+
}
12771282
#endif
12781283
int fsync_bdev(struct block_device *bdev);
12791284

0 commit comments

Comments
 (0)