Skip to content

Commit aacfc19

Browse files
Christoph HellwigAl Viro
authored andcommitted
fs: simplify the blockdev_direct_IO prototype
Simple filesystems always pass inode->i_sb_bdev as the block device argument, and never need a end_io handler. Let's simply things for them and for my grepping activity by dropping these arguments. The only thing not falling into that scheme is ext4, which passes and end_io handler without needing special flags (yet), but given how messy the direct I/O code there is use of __blockdev_direct_IO in one instead of two out of three cases isn't going to make a large difference anyway. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent df2d6f2 commit aacfc19

10 files changed

Lines changed: 26 additions & 29 deletions

File tree

‎fs/ext2/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,8 @@ ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
843843
struct inode *inode = mapping->host;
844844
ssize_t ret;
845845

846-
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev,
847-
iov, offset, nr_segs, ext2_get_block, NULL);
846+
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
847+
ext2_get_block);
848848
if (ret < 0 && (rw & WRITE))
849849
ext2_write_failed(mapping, offset + iov_length(iov, nr_segs));
850850
return ret;

‎fs/ext3/inode.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,9 +1816,8 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
18161816
}
18171817

18181818
retry:
1819-
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
1820-
offset, nr_segs,
1821-
ext3_get_block, NULL);
1819+
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
1820+
ext3_get_block);
18221821
/*
18231822
* In case of error extending write may have instantiated a few
18241823
* blocks outside i_size. Trim these off again.

‎fs/ext4/inode.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,10 +3501,8 @@ static ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
35013501
offset, nr_segs,
35023502
ext4_get_block, NULL, NULL, 0);
35033503
else {
3504-
ret = blockdev_direct_IO(rw, iocb, inode,
3505-
inode->i_sb->s_bdev, iov,
3506-
offset, nr_segs,
3507-
ext4_get_block, NULL);
3504+
ret = blockdev_direct_IO(rw, iocb, inode, iov,
3505+
offset, nr_segs, ext4_get_block);
35083506

35093507
if (unlikely((rw & WRITE) && ret < 0)) {
35103508
loff_t isize = i_size_read(inode);
@@ -3748,11 +3746,13 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
37483746
EXT4_I(inode)->cur_aio_dio = iocb->private;
37493747
}
37503748

3751-
ret = blockdev_direct_IO(rw, iocb, inode,
3749+
ret = __blockdev_direct_IO(rw, iocb, inode,
37523750
inode->i_sb->s_bdev, iov,
37533751
offset, nr_segs,
37543752
ext4_get_block_write,
3755-
ext4_end_io_dio);
3753+
ext4_end_io_dio,
3754+
NULL,
3755+
DIO_LOCKING | DIO_SKIP_HOLES);
37563756
if (iocb->private)
37573757
EXT4_I(inode)->cur_aio_dio = NULL;
37583758
/*

‎fs/fat/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
211211
* FAT need to use the DIO_LOCKING for avoiding the race
212212
* condition of fat_get_block() and ->truncate().
213213
*/
214-
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev,
215-
iov, offset, nr_segs, fat_get_block, NULL);
214+
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
215+
fat_get_block);
216216
if (ret < 0 && (rw & WRITE))
217217
fat_write_failed(mapping, offset + iov_length(iov, nr_segs));
218218

‎fs/hfs/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
123123
struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
124124
ssize_t ret;
125125

126-
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
127-
offset, nr_segs, hfs_get_block, NULL);
126+
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
127+
hfs_get_block);
128128

129129
/*
130130
* In case of error extending write may have instantiated a few

‎fs/hfsplus/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
119119
struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
120120
ssize_t ret;
121121

122-
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
123-
offset, nr_segs, hfsplus_get_block, NULL);
122+
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
123+
hfsplus_get_block);
124124

125125
/*
126126
* In case of error extending write may have instantiated a few

‎fs/jfs/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
329329
struct inode *inode = file->f_mapping->host;
330330
ssize_t ret;
331331

332-
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
333-
offset, nr_segs, jfs_get_block, NULL);
332+
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
333+
jfs_get_block);
334334

335335
/*
336336
* In case of error extending write may have instantiated a few

‎fs/nilfs2/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
259259
return 0;
260260

261261
/* Needs synchronization with the cleaner */
262-
size = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
263-
offset, nr_segs, nilfs_get_block, NULL);
262+
size = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
263+
nilfs_get_block);
264264

265265
/*
266266
* In case of error extending write may have instantiated a few

‎fs/reiserfs/inode.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,9 +3068,8 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
30683068
struct inode *inode = file->f_mapping->host;
30693069
ssize_t ret;
30703070

3071-
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
3072-
offset, nr_segs,
3073-
reiserfs_get_blocks_direct_io, NULL);
3071+
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
3072+
reiserfs_get_blocks_direct_io);
30743073

30753074
/*
30763075
* In case of error extending write may have instantiated a few

‎include/linux/fs.h‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,12 +2418,11 @@ ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
24182418
dio_submit_t submit_io, int flags);
24192419

24202420
static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
2421-
struct inode *inode, struct block_device *bdev, const struct iovec *iov,
2422-
loff_t offset, unsigned long nr_segs, get_block_t get_block,
2423-
dio_iodone_t end_io)
2421+
struct inode *inode, const struct iovec *iov, loff_t offset,
2422+
unsigned long nr_segs, get_block_t get_block)
24242423
{
2425-
return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
2426-
nr_segs, get_block, end_io, NULL,
2424+
return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
2425+
offset, nr_segs, get_block, NULL, NULL,
24272426
DIO_LOCKING | DIO_SKIP_HOLES);
24282427
}
24292428
#endif

0 commit comments

Comments
 (0)