提交 a6cbcd4a 编写于 作者: A Al Viro

get rid of pointless iov_length() in ->direct_IO()

all callers have iov_length(iter->iov, iter->nr_segs) == iov_iter_count(iter)
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 16b1f05d
...@@ -370,7 +370,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, ...@@ -370,7 +370,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
struct ccc_object *obj = cl_inode2ccc(inode); struct ccc_object *obj = cl_inode2ccc(inode);
long count = iov_length(iter->iov, iter->nr_segs); long count = iov_iter_count(iter);
long tot_bytes = 0, result = 0; long tot_bytes = 0, result = 0;
struct ll_inode_info *lli = ll_i2info(inode); struct ll_inode_info *lli = ll_i2info(inode);
unsigned long seg = 0; unsigned long seg = 0;
......
...@@ -7456,7 +7456,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb, ...@@ -7456,7 +7456,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
* we need to flush the dirty pages again to make absolutely sure * we need to flush the dirty pages again to make absolutely sure
* that any outstanding dirty pages are on disk. * that any outstanding dirty pages are on disk.
*/ */
count = iov_length(iter->iov, iter->nr_segs); count = iov_iter_count(iter);
if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT, if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
&BTRFS_I(inode)->runtime_flags)) &BTRFS_I(inode)->runtime_flags))
filemap_fdatawrite_range(inode->i_mapping, offset, count); filemap_fdatawrite_range(inode->i_mapping, offset, count);
......
...@@ -856,13 +856,13 @@ ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, ...@@ -856,13 +856,13 @@ ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret; ssize_t ret;
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
iter->nr_segs, ext2_get_block); iter->nr_segs, ext2_get_block);
if (ret < 0 && (rw & WRITE)) if (ret < 0 && (rw & WRITE))
ext2_write_failed(mapping, offset + ext2_write_failed(mapping, offset + count);
iov_length(iter->iov, iter->nr_segs));
return ret; return ret;
} }
......
...@@ -1828,7 +1828,7 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb, ...@@ -1828,7 +1828,7 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
handle_t *handle; handle_t *handle;
ssize_t ret; ssize_t ret;
int orphan = 0; int orphan = 0;
size_t count = iov_length(iter->iov, iter->nr_segs); size_t count = iov_iter_count(iter);
int retries = 0; int retries = 0;
trace_ext3_direct_IO_enter(inode, offset, count, rw); trace_ext3_direct_IO_enter(inode, offset, count, rw);
......
...@@ -647,7 +647,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb, ...@@ -647,7 +647,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
handle_t *handle; handle_t *handle;
ssize_t ret; ssize_t ret;
int orphan = 0; int orphan = 0;
size_t count = iov_length(iter->iov, iter->nr_segs); size_t count = iov_iter_count(iter);
int retries = 0; int retries = 0;
if (rw == WRITE) { if (rw == WRITE) {
......
...@@ -3090,7 +3090,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, ...@@ -3090,7 +3090,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
ssize_t ret; ssize_t ret;
size_t count = iov_length(iter->iov, iter->nr_segs); size_t count = iov_iter_count(iter);
int overwrite = 0; int overwrite = 0;
get_block_t *get_block_func = NULL; get_block_t *get_block_func = NULL;
int dio_flags = 0; int dio_flags = 0;
...@@ -3225,6 +3225,7 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, ...@@ -3225,6 +3225,7 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret; ssize_t ret;
/* /*
...@@ -3237,13 +3238,12 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, ...@@ -3237,13 +3238,12 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
if (ext4_has_inline_data(inode)) if (ext4_has_inline_data(inode))
return 0; return 0;
trace_ext4_direct_IO_enter(inode, offset, iov_length(iter->iov, iter->nr_segs), rw); trace_ext4_direct_IO_enter(inode, offset, count, rw);
if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
ret = ext4_ext_direct_IO(rw, iocb, iter, offset); ret = ext4_ext_direct_IO(rw, iocb, iter, offset);
else else
ret = ext4_ind_direct_IO(rw, iocb, iter, offset); ret = ext4_ind_direct_IO(rw, iocb, iter, offset);
trace_ext4_direct_IO_exit(inode, offset, trace_ext4_direct_IO_exit(inode, offset, count, rw, ret);
iov_length(iter->iov, iter->nr_segs), rw, ret);
return ret; return ret;
} }
......
...@@ -191,6 +191,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb, ...@@ -191,6 +191,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret; ssize_t ret;
if (rw == WRITE) { if (rw == WRITE) {
...@@ -203,7 +204,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb, ...@@ -203,7 +204,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
* *
* Return 0, and fallback to normal buffered write. * Return 0, and fallback to normal buffered write.
*/ */
loff_t size = offset + iov_length(iter->iov, iter->nr_segs); loff_t size = offset + count;
if (MSDOS_I(inode)->mmu_private < size) if (MSDOS_I(inode)->mmu_private < size)
return 0; return 0;
} }
...@@ -215,8 +216,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb, ...@@ -215,8 +216,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
iter->nr_segs, fat_get_block); iter->nr_segs, fat_get_block);
if (ret < 0 && (rw & WRITE)) if (ret < 0 && (rw & WRITE))
fat_write_failed(mapping, offset + fat_write_failed(mapping, offset + count);
iov_length(iter->iov, iter->nr_segs));
return ret; return ret;
} }
......
...@@ -2900,7 +2900,7 @@ fuse_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, ...@@ -2900,7 +2900,7 @@ fuse_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
loff_t pos = 0; loff_t pos = 0;
struct inode *inode; struct inode *inode;
loff_t i_size; loff_t i_size;
size_t count = iov_length(iter->iov, iter->nr_segs); size_t count = iov_iter_count(iter);
struct fuse_io_priv *io; struct fuse_io_priv *io;
pos = offset; pos = offset;
......
...@@ -1081,7 +1081,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb, ...@@ -1081,7 +1081,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
*/ */
if (mapping->nrpages) { if (mapping->nrpages) {
loff_t lstart = offset & (PAGE_CACHE_SIZE - 1); loff_t lstart = offset & (PAGE_CACHE_SIZE - 1);
loff_t len = iov_length(iter->iov, iter->nr_segs); loff_t len = iov_iter_count(iter);
loff_t end = PAGE_ALIGN(offset + len) - 1; loff_t end = PAGE_ALIGN(offset + len) - 1;
rv = 0; rv = 0;
......
...@@ -130,6 +130,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb, ...@@ -130,6 +130,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = file_inode(file)->i_mapping->host; struct inode *inode = file_inode(file)->i_mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret; ssize_t ret;
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
...@@ -141,7 +142,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb, ...@@ -141,7 +142,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
*/ */
if (unlikely((rw & WRITE) && ret < 0)) { if (unlikely((rw & WRITE) && ret < 0)) {
loff_t isize = i_size_read(inode); loff_t isize = i_size_read(inode);
loff_t end = offset + iov_length(iter->iov, iter->nr_segs); loff_t end = offset + count;
if (end > isize) if (end > isize)
hfs_write_failed(mapping, end); hfs_write_failed(mapping, end);
......
...@@ -128,6 +128,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb, ...@@ -128,6 +128,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = file_inode(file)->i_mapping->host; struct inode *inode = file_inode(file)->i_mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret; ssize_t ret;
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, iter->nr_segs, ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, iter->nr_segs,
...@@ -139,7 +140,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb, ...@@ -139,7 +140,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
*/ */
if (unlikely((rw & WRITE) && ret < 0)) { if (unlikely((rw & WRITE) && ret < 0)) {
loff_t isize = i_size_read(inode); loff_t isize = i_size_read(inode);
loff_t end = offset + iov_length(iter->iov, iter->nr_segs); loff_t end = offset + count;
if (end > isize) if (end > isize)
hfsplus_write_failed(mapping, end); hfsplus_write_failed(mapping, end);
......
...@@ -336,6 +336,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb, ...@@ -336,6 +336,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret; ssize_t ret;
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
...@@ -347,7 +348,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb, ...@@ -347,7 +348,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
*/ */
if (unlikely((rw & WRITE) && ret < 0)) { if (unlikely((rw & WRITE) && ret < 0)) {
loff_t isize = i_size_read(inode); loff_t isize = i_size_read(inode);
loff_t end = offset + iov_length(iter->iov, iter->nr_segs); loff_t end = offset + count;
if (end > isize) if (end > isize)
jfs_write_failed(mapping, end); jfs_write_failed(mapping, end);
......
...@@ -486,9 +486,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter, ...@@ -486,9 +486,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter,
struct nfs_direct_req *dreq; struct nfs_direct_req *dreq;
struct nfs_lock_context *l_ctx; struct nfs_lock_context *l_ctx;
ssize_t result = -EINVAL; ssize_t result = -EINVAL;
size_t count; size_t count = iov_iter_count(iter);
count = iov_length(iter->iov, iter->nr_segs);
nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count); nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count);
dfprintk(FILE, "NFS: direct read(%pD2, %zd@%Ld)\n", dfprintk(FILE, "NFS: direct read(%pD2, %zd@%Ld)\n",
...@@ -877,7 +875,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, ...@@ -877,7 +875,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
get_dreq(dreq); get_dreq(dreq);
atomic_inc(&inode->i_dio_count); atomic_inc(&inode->i_dio_count);
NFS_I(dreq->inode)->write_io += iov_length(iter->iov, iter->nr_segs); NFS_I(dreq->inode)->write_io += iov_iter_count(iter);
for (seg = 0; seg < iter->nr_segs; seg++) { for (seg = 0; seg < iter->nr_segs; seg++) {
const struct iovec *vec = &iter->iov[seg]; const struct iovec *vec = &iter->iov[seg];
result = nfs_direct_write_schedule_segment(&desc, vec, pos, uio); result = nfs_direct_write_schedule_segment(&desc, vec, pos, uio);
...@@ -936,9 +934,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter, ...@@ -936,9 +934,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter,
struct nfs_direct_req *dreq; struct nfs_direct_req *dreq;
struct nfs_lock_context *l_ctx; struct nfs_lock_context *l_ctx;
loff_t end; loff_t end;
size_t count; size_t count = iov_iter_count(iter);
count = iov_length(iter->iov, iter->nr_segs);
end = (pos + count - 1) >> PAGE_CACHE_SHIFT; end = (pos + count - 1) >> PAGE_CACHE_SHIFT;
nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count); nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count);
......
...@@ -304,6 +304,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, ...@@ -304,6 +304,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
size_t count = iov_iter_count(iter);
ssize_t size; ssize_t size;
if (rw == WRITE) if (rw == WRITE)
...@@ -319,7 +320,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, ...@@ -319,7 +320,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
*/ */
if (unlikely((rw & WRITE) && size < 0)) { if (unlikely((rw & WRITE) && size < 0)) {
loff_t isize = i_size_read(inode); loff_t isize = i_size_read(inode);
loff_t end = offset + iov_length(iter->iov, iter->nr_segs); loff_t end = offset + count;
if (end > isize) if (end > isize)
nilfs_write_failed(mapping, end); nilfs_write_failed(mapping, end);
......
...@@ -3087,6 +3087,7 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb, ...@@ -3087,6 +3087,7 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
{ {
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret; ssize_t ret;
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
...@@ -3098,7 +3099,7 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb, ...@@ -3098,7 +3099,7 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
*/ */
if (unlikely((rw & WRITE) && ret < 0)) { if (unlikely((rw & WRITE) && ret < 0)) {
loff_t isize = i_size_read(inode); loff_t isize = i_size_read(inode);
loff_t end = offset + iov_length(iter->iov, iter->nr_segs); loff_t end = offset + count;
if ((end > isize) && inode_newsize_ok(inode, isize) == 0) { if ((end > isize) && inode_newsize_ok(inode, isize) == 0) {
truncate_setsize(inode, isize); truncate_setsize(inode, isize);
......
...@@ -223,12 +223,13 @@ static ssize_t udf_direct_IO(int rw, struct kiocb *iocb, ...@@ -223,12 +223,13 @@ static ssize_t udf_direct_IO(int rw, struct kiocb *iocb,
struct file *file = iocb->ki_filp; struct file *file = iocb->ki_filp;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
size_t count = iov_iter_count(iter);
ssize_t ret; ssize_t ret;
ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, iter->nr_segs, ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, iter->nr_segs,
udf_get_block); udf_get_block);
if (unlikely(ret < 0 && (rw & WRITE))) if (unlikely(ret < 0 && (rw & WRITE)))
udf_write_failed(mapping, offset + iov_length(iter->iov, iter->nr_segs)); udf_write_failed(mapping, offset + count);
return ret; return ret;
} }
......
...@@ -1458,7 +1458,7 @@ xfs_vm_direct_IO( ...@@ -1458,7 +1458,7 @@ xfs_vm_direct_IO(
ssize_t ret; ssize_t ret;
if (rw & WRITE) { if (rw & WRITE) {
size_t size = iov_length(iter->iov, iter->nr_segs); size_t size = iov_iter_count(iter);
/* /*
* We cannot preallocate a size update transaction here as we * We cannot preallocate a size update transaction here as we
......
...@@ -1698,7 +1698,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -1698,7 +1698,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
goto out; /* skip atime */ goto out; /* skip atime */
size = i_size_read(inode); size = i_size_read(inode);
retval = filemap_write_and_wait_range(mapping, pos, retval = filemap_write_and_wait_range(mapping, pos,
pos + iov_length(iov, nr_segs) - 1); pos + count - 1);
if (!retval) if (!retval)
retval = mapping->a_ops->direct_IO(READ, iocb, &i, pos); retval = mapping->a_ops->direct_IO(READ, iocb, &i, pos);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册