Skip to content

Commit

Permalink
fs: simplify the blockdev_direct_IO prototype
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Jul 21, 2011
1 parent df2d6f2 commit aacfc19
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 29 deletions.
4 changes: 2 additions & 2 deletions fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,8 @@ ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
struct inode *inode = mapping->host;
ssize_t ret;

ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev,
iov, offset, nr_segs, ext2_get_block, NULL);
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
ext2_get_block);
if (ret < 0 && (rw & WRITE))
ext2_write_failed(mapping, offset + iov_length(iov, nr_segs));
return ret;
Expand Down
5 changes: 2 additions & 3 deletions fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,9 +1816,8 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
}

retry:
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs,
ext3_get_block, NULL);
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
ext3_get_block);
/*
* In case of error extending write may have instantiated a few
* blocks outside i_size. Trim these off again.
Expand Down
12 changes: 6 additions & 6 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3501,10 +3501,8 @@ static ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
offset, nr_segs,
ext4_get_block, NULL, NULL, 0);
else {
ret = blockdev_direct_IO(rw, iocb, inode,
inode->i_sb->s_bdev, iov,
offset, nr_segs,
ext4_get_block, NULL);
ret = blockdev_direct_IO(rw, iocb, inode, iov,
offset, nr_segs, ext4_get_block);

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

ret = blockdev_direct_IO(rw, iocb, inode,
ret = __blockdev_direct_IO(rw, iocb, inode,
inode->i_sb->s_bdev, iov,
offset, nr_segs,
ext4_get_block_write,
ext4_end_io_dio);
ext4_end_io_dio,
NULL,
DIO_LOCKING | DIO_SKIP_HOLES);
if (iocb->private)
EXT4_I(inode)->cur_aio_dio = NULL;
/*
Expand Down
4 changes: 2 additions & 2 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
* FAT need to use the DIO_LOCKING for avoiding the race
* condition of fat_get_block() and ->truncate().
*/
ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev,
iov, offset, nr_segs, fat_get_block, NULL);
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
fat_get_block);
if (ret < 0 && (rw & WRITE))
fat_write_failed(mapping, offset + iov_length(iov, nr_segs));

Expand Down
4 changes: 2 additions & 2 deletions fs/hfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
ssize_t ret;

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

/*
* In case of error extending write may have instantiated a few
Expand Down
4 changes: 2 additions & 2 deletions fs/hfsplus/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
ssize_t ret;

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

/*
* In case of error extending write may have instantiated a few
Expand Down
4 changes: 2 additions & 2 deletions fs/jfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
struct inode *inode = file->f_mapping->host;
ssize_t ret;

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

/*
* In case of error extending write may have instantiated a few
Expand Down
4 changes: 2 additions & 2 deletions fs/nilfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
return 0;

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

/*
* In case of error extending write may have instantiated a few
Expand Down
5 changes: 2 additions & 3 deletions fs/reiserfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3068,9 +3068,8 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
struct inode *inode = file->f_mapping->host;
ssize_t ret;

ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs,
reiserfs_get_blocks_direct_io, NULL);
ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
reiserfs_get_blocks_direct_io);

/*
* In case of error extending write may have instantiated a few
Expand Down
9 changes: 4 additions & 5 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2418,12 +2418,11 @@ ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
dio_submit_t submit_io, int flags);

static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
struct inode *inode, struct block_device *bdev, const struct iovec *iov,
loff_t offset, unsigned long nr_segs, get_block_t get_block,
dio_iodone_t end_io)
struct inode *inode, const struct iovec *iov, loff_t offset,
unsigned long nr_segs, get_block_t get_block)
{
return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
nr_segs, get_block, end_io, NULL,
return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
offset, nr_segs, get_block, NULL, NULL,
DIO_LOCKING | DIO_SKIP_HOLES);
}
#endif
Expand Down

0 comments on commit aacfc19

Please sign in to comment.