get rid of pointless iov_length() in ->direct_IO()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 5 Mar 2014 03:38:00 +0000 (22:38 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 6 May 2014 21:32:45 +0000 (17:32 -0400)
all callers have iov_length(iter->iov, iter->nr_segs) == iov_iter_count(iter)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
18 files changed:
drivers/staging/lustre/lustre/llite/rw26.c
fs/btrfs/inode.c
fs/ext2/inode.c
fs/ext3/inode.c
fs/ext4/indirect.c
fs/ext4/inode.c
fs/fat/inode.c
fs/fuse/file.c
fs/gfs2/aops.c
fs/hfs/inode.c
fs/hfsplus/inode.c
fs/jfs/inode.c
fs/nfs/direct.c
fs/nilfs2/inode.c
fs/reiserfs/inode.c
fs/udf/inode.c
fs/xfs/xfs_aops.c
mm/filemap.c

index 66e05c6f4d27ae015358b2f3bd0c29c1c9e2e42d..38a5b580e7f0a49a8ab78a914b2bd54ba100ca7a 100644 (file)
@@ -370,7 +370,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
        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;
        struct ll_inode_info *lli = ll_i2info(inode);
        unsigned long seg = 0;
index 30a6cc51f32c907d7f5989397e2479db56563f59..c46a025d0c4b0482d028ee48c63f2bb21df95152 100644 (file)
@@ -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
         * 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,
                     &BTRFS_I(inode)->runtime_flags))
                filemap_fdatawrite_range(inode->i_mapping, offset, count);
index 47fbe760a7f8be90e8aec0963ac57f395e8d0b30..116e809aa7cbbf2b4cfa53420958cd50f1a0718e 100644 (file)
@@ -856,13 +856,13 @@ ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
        struct file *file = iocb->ki_filp;
        struct address_space *mapping = file->f_mapping;
        struct inode *inode = mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t ret;
 
        ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset,
                                 iter->nr_segs, ext2_get_block);
        if (ret < 0 && (rw & WRITE))
-               ext2_write_failed(mapping, offset +
-                                 iov_length(iter->iov, iter->nr_segs));
+               ext2_write_failed(mapping, offset + count);
        return ret;
 }
 
index 7a5c501dc31b44787f9c7b25bc5d1aea98aae8bd..8582ae2c80b06912c11f24f424766fb41da1a54c 100644 (file)
@@ -1828,7 +1828,7 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
        handle_t *handle;
        ssize_t ret;
        int orphan = 0;
-       size_t count = iov_length(iter->iov, iter->nr_segs);
+       size_t count = iov_iter_count(iter);
        int retries = 0;
 
        trace_ext3_direct_IO_enter(inode, offset, count, rw);
index eb5ae16902d0b9c77bd062253c341b11c7b9ccb8..123898a6af05ecaa60de6cee658595d6db75beae 100644 (file)
@@ -647,7 +647,7 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
        handle_t *handle;
        ssize_t ret;
        int orphan = 0;
-       size_t count = iov_length(iter->iov, iter->nr_segs);
+       size_t count = iov_iter_count(iter);
        int retries = 0;
 
        if (rw == WRITE) {
index 29996c1b673ebd90d7e6e75f91d0e9964ef1c105..2b993579a96819b117fd9d9a37cf51b2aae585d9 100644 (file)
@@ -3090,7 +3090,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
        ssize_t ret;
-       size_t count = iov_length(iter->iov, iter->nr_segs);
+       size_t count = iov_iter_count(iter);
        int overwrite = 0;
        get_block_t *get_block_func = NULL;
        int dio_flags = 0;
@@ -3225,6 +3225,7 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t ret;
 
        /*
@@ -3237,13 +3238,12 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
        if (ext4_has_inline_data(inode))
                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))
                ret = ext4_ext_direct_IO(rw, iocb, iter, offset);
        else
                ret = ext4_ind_direct_IO(rw, iocb, iter, offset);
-       trace_ext4_direct_IO_exit(inode, offset,
-                               iov_length(iter->iov, iter->nr_segs), rw, ret);
+       trace_ext4_direct_IO_exit(inode, offset, count, rw, ret);
        return ret;
 }
 
index d5237a19905564a27bf19aec957039be9230229d..154a6f9d3189c4bd7c5008cf742d3a34ebb762a0 100644 (file)
@@ -191,6 +191,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
        struct file *file = iocb->ki_filp;
        struct address_space *mapping = file->f_mapping;
        struct inode *inode = mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t ret;
 
        if (rw == WRITE) {
@@ -203,7 +204,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
                 *
                 * 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)
                        return 0;
        }
@@ -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,
                                 iter->nr_segs, fat_get_block);
        if (ret < 0 && (rw & WRITE))
-               fat_write_failed(mapping, offset +
-                                iov_length(iter->iov, iter->nr_segs));
+               fat_write_failed(mapping, offset + count);
 
        return ret;
 }
index 17d96f36df159c80f75afa58cae7778c020edac1..36f15f9c1de24859f9d3a972d0b8793bdd4c5f9b 100644 (file)
@@ -2900,7 +2900,7 @@ fuse_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
        loff_t pos = 0;
        struct inode *inode;
        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;
 
        pos = offset;
index e84ddaa421042974b508bb8f9b3420092d7da067..228a12d2afa9aedf3bc4a60e653d54e881f93bf2 100644 (file)
@@ -1081,7 +1081,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
         */
        if (mapping->nrpages) {
                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;
 
                rv = 0;
index 09cff13528c5261e1d0a89a8b97b4c93443fa0a7..dc69e8f315818bd6e05a40200240637399391c27 100644 (file)
@@ -130,6 +130,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
        struct file *file = iocb->ki_filp;
        struct address_space *mapping = file->f_mapping;
        struct inode *inode = file_inode(file)->i_mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t ret;
 
        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,
         */
        if (unlikely((rw & WRITE) && ret < 0)) {
                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)
                        hfs_write_failed(mapping, end);
index 7f894a5b5eafa5a419c5c8a7b0824a559644102f..e6b1251af47aece2f704bf3ece196709f91083eb 100644 (file)
@@ -128,6 +128,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
        struct file *file = iocb->ki_filp;
        struct address_space *mapping = file->f_mapping;
        struct inode *inode = file_inode(file)->i_mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t ret;
 
        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,
         */
        if (unlikely((rw & WRITE) && ret < 0)) {
                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)
                        hfsplus_write_failed(mapping, end);
index 7052744d51074b9a1ef4e8b2adfc8dc2c2bfdc42..6cde5928693bb48dde5520361a716dee8bdc6cba 100644 (file)
@@ -336,6 +336,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
        struct file *file = iocb->ki_filp;
        struct address_space *mapping = file->f_mapping;
        struct inode *inode = file->f_mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t ret;
 
        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,
         */
        if (unlikely((rw & WRITE) && ret < 0)) {
                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)
                        jfs_write_failed(mapping, end);
index 21723149668b39b706fa72172bffc1d5263600a8..1d34f454989ea6a6310084d97f3835ea7e7066f2 100644 (file)
@@ -486,9 +486,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter,
        struct nfs_direct_req *dreq;
        struct nfs_lock_context *l_ctx;
        ssize_t result = -EINVAL;
-       size_t count;
-
-       count = iov_length(iter->iov, iter->nr_segs);
+       size_t count = iov_iter_count(iter);
        nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count);
 
        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,
        get_dreq(dreq);
        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++) {
                const struct iovec *vec = &iter->iov[seg];
                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,
        struct nfs_direct_req *dreq;
        struct nfs_lock_context *l_ctx;
        loff_t end;
-       size_t count;
-
-       count = iov_length(iter->iov, iter->nr_segs);
+       size_t count = iov_iter_count(iter);
        end = (pos + count - 1) >> PAGE_CACHE_SHIFT;
 
        nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count);
index 1c0e8fedc09593b2468ed6fdc9bc3be942a4dea1..7aaf913e8709a0145c44754234b3635b7b5b8a5c 100644 (file)
@@ -304,6 +304,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
        struct file *file = iocb->ki_filp;
        struct address_space *mapping = file->f_mapping;
        struct inode *inode = file->f_mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t size;
 
        if (rw == WRITE)
@@ -319,7 +320,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
         */
        if (unlikely((rw & WRITE) && size < 0)) {
                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)
                        nilfs_write_failed(mapping, end);
index 17bf4c41a5092e0934fef60d14f768d24eaef7aa..723affe921f1bdfc6104000c62535fbc10b29403 100644 (file)
@@ -3087,6 +3087,7 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t ret;
 
        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,
         */
        if (unlikely((rw & WRITE) && ret < 0)) {
                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) {
                        truncate_setsize(inode, isize);
index 5b184c7f7dcbf0cfcd2c3a24d313afc31db45df8..28984baf61949d15adf355035da0df2d21e526d9 100644 (file)
@@ -223,12 +223,13 @@ static ssize_t udf_direct_IO(int rw, struct kiocb *iocb,
        struct file *file = iocb->ki_filp;
        struct address_space *mapping = file->f_mapping;
        struct inode *inode = mapping->host;
+       size_t count = iov_iter_count(iter);
        ssize_t ret;
 
        ret = blockdev_direct_IO(rw, iocb, inode, iter->iov, offset, iter->nr_segs,
                                  udf_get_block);
        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;
 }
 
index 330d7b1c4be34a204db18f53569bde13ef7039bc..6462b3186784bb7af25759e3aa2223deeb2ea612 100644 (file)
@@ -1458,7 +1458,7 @@ xfs_vm_direct_IO(
        ssize_t                 ret;
 
        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
index 139641274f1e182631b0b936482621be9fe48b30..70c048ea36e0b19e95aa1f729cadb36d1c334c88 100644 (file)
@@ -1698,7 +1698,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
                        goto out; /* skip atime */
                size = i_size_read(inode);
                retval = filemap_write_and_wait_range(mapping, pos,
-                                       pos + iov_length(iov, nr_segs) - 1);
+                                       pos + count - 1);
                if (!retval)
                        retval = mapping->a_ops->direct_IO(READ, iocb, &i, pos);