Remove rw from {,__,do_}blockdev_direct_IO()
authorOmar Sandoval <osandov@osandov.com>
Mon, 16 Mar 2015 11:33:50 +0000 (04:33 -0700)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Apr 2015 02:29:44 +0000 (22:29 -0400)
Most filesystems call through to these at some point, so we'll start
here.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
20 files changed:
fs/affs/file.c
fs/block_dev.c
fs/btrfs/inode.c
fs/direct-io.c
fs/ext2/inode.c
fs/ext3/inode.c
fs/ext4/indirect.c
fs/ext4/inode.c
fs/f2fs/data.c
fs/fat/inode.c
fs/gfs2/aops.c
fs/hfs/inode.c
fs/hfsplus/inode.c
fs/jfs/inode.c
fs/nilfs2/inode.c
fs/ocfs2/aops.c
fs/reiserfs/inode.c
fs/udf/inode.c
fs/xfs/xfs_aops.c
include/linux/fs.h

index 7c1a3d4c19c23cd0fd2e9452d813b1014f0233fd..1edc0d4b40dbaef94600003a3abd73575bcc3c0f 100644 (file)
@@ -405,7 +405,7 @@ affs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
                        return 0;
        }
 
-       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, affs_get_block);
+       ret = blockdev_direct_IO(iocb, inode, iter, offset, affs_get_block);
        if (ret < 0 && (rw & WRITE))
                affs_write_failed(mapping, offset + count);
        return ret;
index b5e87896f517d17aea743eec62cdfeada14db203..bc23afd35fdba7f7ca3752dbaf4a53a7dbefd412 100644 (file)
@@ -152,9 +152,8 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
 
-       return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iter,
-                                   offset, blkdev_get_block,
-                                   NULL, NULL, 0);
+       return __blockdev_direct_IO(iocb, inode, I_BDEV(inode), iter, offset,
+                                   blkdev_get_block, NULL, NULL, 0);
 }
 
 int __sync_blockdev(struct block_device *bdev, int wait)
index 686331f22b15ce0fcc8233c2529a50c2eb6190c7..e9a3ff8a85fd4c79cff17f07407bd8be16c419ef 100644 (file)
@@ -8174,10 +8174,10 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
                wakeup = false;
        }
 
-       ret = __blockdev_direct_IO(rw, iocb, inode,
-                       BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev,
-                       iter, offset, btrfs_get_blocks_direct, NULL,
-                       btrfs_submit_direct, flags);
+       ret = __blockdev_direct_IO(iocb, inode,
+                                  BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev,
+                                  iter, offset, btrfs_get_blocks_direct, NULL,
+                                  btrfs_submit_direct, flags);
        if (rw & WRITE) {
                current->journal_info = NULL;
                if (ret < 0 && ret != -EIOCBQUEUED)
index 6fb00e3f1059791d21b4ffc80671f3d051ecbc8e..c3b560b24a463c50569a2a37c5d04f8d5af92c4d 100644 (file)
@@ -1093,10 +1093,10 @@ static inline int drop_refcount(struct dio *dio)
  * for the whole file.
  */
 static inline ssize_t
-do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
-       struct block_device *bdev, struct iov_iter *iter, loff_t offset, 
-       get_block_t get_block, dio_iodone_t end_io,
-       dio_submit_t submit_io, int flags)
+do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
+                     struct block_device *bdev, struct iov_iter *iter,
+                     loff_t offset, get_block_t get_block, dio_iodone_t end_io,
+                     dio_submit_t submit_io, int flags)
 {
        unsigned i_blkbits = ACCESS_ONCE(inode->i_blkbits);
        unsigned blkbits = i_blkbits;
@@ -1110,9 +1110,6 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
        struct blk_plug plug;
        unsigned long align = offset | iov_iter_alignment(iter);
 
-       if (rw & WRITE)
-               rw = WRITE_ODIRECT;
-
        /*
         * Avoid references to bdev if not absolutely needed to give
         * the early prefetch in the caller enough time.
@@ -1127,7 +1124,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
        }
 
        /* watch out for a 0 len io from a tricksy fs */
-       if (rw == READ && !iov_iter_count(iter))
+       if (iov_iter_rw(iter) == READ && !iov_iter_count(iter))
                return 0;
 
        dio = kmem_cache_alloc(dio_cache, GFP_KERNEL);
@@ -1143,7 +1140,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
 
        dio->flags = flags;
        if (dio->flags & DIO_LOCKING) {
-               if (rw == READ) {
+               if (iov_iter_rw(iter) == READ) {
                        struct address_space *mapping =
                                        iocb->ki_filp->f_mapping;
 
@@ -1169,19 +1166,19 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
        if (is_sync_kiocb(iocb))
                dio->is_async = false;
        else if (!(dio->flags & DIO_ASYNC_EXTEND) &&
-            (rw & WRITE) && end > i_size_read(inode))
+                iov_iter_rw(iter) == WRITE && end > i_size_read(inode))
                dio->is_async = false;
        else
                dio->is_async = true;
 
        dio->inode = inode;
-       dio->rw = rw;
+       dio->rw = iov_iter_rw(iter) == WRITE ? WRITE_ODIRECT : READ;
 
        /*
         * For AIO O_(D)SYNC writes we need to defer completions to a workqueue
         * so that we can call ->fsync.
         */
-       if (dio->is_async && (rw & WRITE) &&
+       if (dio->is_async && iov_iter_rw(iter) == WRITE &&
            ((iocb->ki_filp->f_flags & O_DSYNC) ||
             IS_SYNC(iocb->ki_filp->f_mapping->host))) {
                retval = dio_set_defer_completion(dio);
@@ -1274,7 +1271,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
         * we can let i_mutex go now that its achieved its purpose
         * of protecting us from looking up uninitialized blocks.
         */
-       if (rw == READ && (dio->flags & DIO_LOCKING))
+       if (iov_iter_rw(iter) == READ && (dio->flags & DIO_LOCKING))
                mutex_unlock(&dio->inode->i_mutex);
 
        /*
@@ -1286,7 +1283,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
         */
        BUG_ON(retval == -EIOCBQUEUED);
        if (dio->is_async && retval == 0 && dio->result &&
-           (rw == READ || dio->result == count))
+           (iov_iter_rw(iter) == READ || dio->result == count))
                retval = -EIOCBQUEUED;
        else
                dio_await_completion(dio);
@@ -1300,11 +1297,11 @@ out:
        return retval;
 }
 
-ssize_t
-__blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
-       struct block_device *bdev, struct iov_iter *iter, loff_t offset,
-       get_block_t get_block, dio_iodone_t end_io,
-       dio_submit_t submit_io, int flags)
+ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
+                            struct block_device *bdev, struct iov_iter *iter,
+                            loff_t offset, get_block_t get_block,
+                            dio_iodone_t end_io, dio_submit_t submit_io,
+                            int flags)
 {
        /*
         * The block device state is needed in the end to finally
@@ -1318,8 +1315,8 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
        prefetch(bdev->bd_queue);
        prefetch((char *)bdev->bd_queue + SMP_CACHE_BYTES);
 
-       return do_blockdev_direct_IO(rw, iocb, inode, bdev, iter, offset,
-                                    get_block, end_io, submit_io, flags);
+       return do_blockdev_direct_IO(iocb, inode, bdev, iter, offset, get_block,
+                                    end_io, submit_io, flags);
 }
 
 EXPORT_SYMBOL(__blockdev_direct_IO);
index df9d6afbc5d5eb745e00a9a2575b28890e94d7b7..3cbeb1b63acf8ea15e4aa8e9080bea71b1cd1691 100644 (file)
@@ -864,7 +864,7 @@ ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
                ret = dax_do_io(rw, iocb, inode, iter, offset, ext2_get_block,
                                NULL, DIO_LOCKING);
        else
-               ret = blockdev_direct_IO(rw, iocb, inode, iter, offset,
+               ret = blockdev_direct_IO(iocb, inode, iter, offset,
                                         ext2_get_block);
        if (ret < 0 && (rw & WRITE))
                ext2_write_failed(mapping, offset + count);
index db07ffbe7c85cdabbe89d49b3b2294dd8a1d84cf..6fb376c8d9386d82c4c227fe79d8cc9c5a3c203a 100644 (file)
@@ -1856,7 +1856,7 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
        }
 
 retry:
-       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, ext3_get_block);
+       ret = blockdev_direct_IO(iocb, inode, iter, offset, ext3_get_block);
        /*
         * In case of error extending write may have instantiated a few
         * blocks outside i_size. Trim these off again.
index 740c7871c11770a683395989df5548d3d3357c22..ae4ffc27abc66d5a78a6e5698be748899ff18259 100644 (file)
@@ -693,9 +693,10 @@ retry:
                        ret = dax_do_io(rw, iocb, inode, iter, offset,
                                        ext4_get_block, NULL, 0);
                else
-                       ret = __blockdev_direct_IO(rw, iocb, inode,
-                                       inode->i_sb->s_bdev, iter, offset,
-                                       ext4_get_block, NULL, NULL, 0);
+                       ret = __blockdev_direct_IO(iocb, inode,
+                                                  inode->i_sb->s_bdev, iter,
+                                                  offset, ext4_get_block, NULL,
+                                                  NULL, 0);
                inode_dio_done(inode);
        } else {
 locked:
@@ -703,8 +704,8 @@ locked:
                        ret = dax_do_io(rw, iocb, inode, iter, offset,
                                        ext4_get_block, NULL, DIO_LOCKING);
                else
-                       ret = blockdev_direct_IO(rw, iocb, inode, iter,
-                                       offset, ext4_get_block);
+                       ret = blockdev_direct_IO(iocb, inode, iter, offset,
+                                                ext4_get_block);
 
                if (unlikely((rw & WRITE) && ret < 0)) {
                        loff_t isize = i_size_read(inode);
index a3f451370bef4b49a23343daf63af2459de0741c..ec049c04b197f42ca1597fa362a81c0cbc67e46d 100644 (file)
@@ -3037,7 +3037,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
                ret = dax_do_io(rw, iocb, inode, iter, offset, get_block_func,
                                ext4_end_io_dio, dio_flags);
        else
-               ret = __blockdev_direct_IO(rw, iocb, inode,
+               ret = __blockdev_direct_IO(iocb, inode,
                                           inode->i_sb->s_bdev, iter, offset,
                                           get_block_func,
                                           ext4_end_io_dio, NULL, dio_flags);
index 497f8515d2056283d040b912dd638e65a4576fe7..e16adebcb9b674bac5c70f1d5b19ba59a6d8b600 100644 (file)
@@ -1159,7 +1159,7 @@ static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb,
        if (rw & WRITE)
                __allocate_data_blocks(inode, offset, count);
 
-       err = blockdev_direct_IO(rw, iocb, inode, iter, offset, get_data_block);
+       err = blockdev_direct_IO(iocb, inode, iter, offset, get_data_block);
        if (err < 0 && (rw & WRITE))
                f2fs_write_failed(mapping, offset + count);
 
index 8521207de22935464f074b70448cae781ed403e1..a1a39f571e781a782d817d8cb72431645a00a287 100644 (file)
@@ -274,7 +274,7 @@ 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, iter, offset, fat_get_block);
+       ret = blockdev_direct_IO(iocb, inode, iter, offset, fat_get_block);
        if (ret < 0 && (rw & WRITE))
                fat_write_failed(mapping, offset + count);
 
index fe6634d25d1ddb591a60a40f32f054cae89ed5f2..59983a18cab42f424a05ed68be21d6a92726f27e 100644 (file)
@@ -1095,9 +1095,8 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
                        truncate_inode_pages_range(mapping, lstart, end);
        }
 
-       rv = __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev,
-                                 iter, offset,
-                                 gfs2_get_block_direct, NULL, NULL, 0);
+       rv = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
+                                 offset, gfs2_get_block_direct, NULL, NULL, 0);
 out:
        gfs2_glock_dq(&gh);
        gfs2_holder_uninit(&gh);
index 9337065bcc6761280e5abb7b8078811172e3a76b..e92d175d1fd7ce4aa133d5816e3b208daa4c300d 100644 (file)
@@ -133,7 +133,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
        size_t count = iov_iter_count(iter);
        ssize_t ret;
 
-       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, hfs_get_block);
+       ret = blockdev_direct_IO(iocb, inode, iter, offset, hfs_get_block);
 
        /*
         * In case of error extending write may have instantiated a few
index 5f86cadb0542c074b7015483303d3bdfefe3347f..2a98dc07c22c5110cb87896018d5b11c48efc385 100644 (file)
@@ -131,8 +131,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
        size_t count = iov_iter_count(iter);
        ssize_t ret;
 
-       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, 
-                                hfsplus_get_block);
+       ret = blockdev_direct_IO(iocb, inode, iter, offset, hfsplus_get_block);
 
        /*
         * In case of error extending write may have instantiated a few
index 3197aed106148d8b0839b80405ecad125c14e7aa..c20f7883543fb425af430f29d91d7a9d5850e726 100644 (file)
@@ -339,7 +339,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
        size_t count = iov_iter_count(iter);
        ssize_t ret;
 
-       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, jfs_get_block);
+       ret = blockdev_direct_IO(iocb, inode, iter, offset, jfs_get_block);
 
        /*
         * In case of error extending write may have instantiated a few
index ab4987bc637f8b084298086cf48f00e31bfe1298..3727b8caa46e012b1421774b32ea561cc3488d6a 100644 (file)
@@ -318,8 +318,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
                return 0;
 
        /* Needs synchronization with the cleaner */
-       size = blockdev_direct_IO(rw, iocb, inode, iter, offset,
-                                 nilfs_get_block);
+       size = blockdev_direct_IO(iocb, inode, iter, offset, nilfs_get_block);
 
        /*
         * In case of error extending write may have instantiated a few
index e1bf18c5d25e1cc907abf53e4ac984870dc0584e..68cb199fb2b6a258f8be6b48d4d23eeb3f5d5c19 100644 (file)
@@ -738,10 +738,9 @@ static ssize_t ocfs2_direct_IO_write(struct kiocb *iocb,
                di_bh = NULL;
        }
 
-       written = __blockdev_direct_IO(WRITE, iocb, inode, inode->i_sb->s_bdev,
-                       iter, offset,
-                       ocfs2_direct_IO_get_blocks,
-                       ocfs2_dio_end_io, NULL, 0);
+       written = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
+                                      offset, ocfs2_direct_IO_get_blocks,
+                                      ocfs2_dio_end_io, NULL, 0);
        if (unlikely(written < 0)) {
                loff_t i_size = i_size_read(inode);
 
@@ -844,11 +843,10 @@ static ssize_t ocfs2_direct_IO(int rw,
                return 0;
 
        if (rw == READ)
-               return __blockdev_direct_IO(rw, iocb, inode,
-                                   inode->i_sb->s_bdev,
-                                   iter, offset,
-                                   ocfs2_direct_IO_get_blocks,
-                                   ocfs2_dio_end_io, NULL, 0);
+               return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev,
+                                           iter, offset,
+                                           ocfs2_direct_IO_get_blocks,
+                                           ocfs2_dio_end_io, NULL, 0);
        else
                return ocfs2_direct_IO_write(iocb, iter, offset);
 }
index 9312b7842e036f64ac02135102b445f0769e7702..a51e9177b05671d9d716077cb74a26f814e50729 100644 (file)
@@ -3286,7 +3286,7 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
        size_t count = iov_iter_count(iter);
        ssize_t ret;
 
-       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset,
+       ret = blockdev_direct_IO(iocb, inode, iter, offset,
                                 reiserfs_get_blocks_direct_io);
 
        /*
index 9c1fbd23913db541c3facc1342614793b1403bfd..3adf49c01c196ca3da7f1b7de7b0c6d477e7abad 100644 (file)
@@ -225,7 +225,7 @@ static ssize_t udf_direct_IO(int rw, struct kiocb *iocb,
        size_t count = iov_iter_count(iter);
        ssize_t ret;
 
-       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, udf_get_block);
+       ret = blockdev_direct_IO(iocb, inode, iter, offset, udf_get_block);
        if (unlikely(ret < 0 && (rw & WRITE)))
                udf_write_failed(mapping, offset + count);
        return ret;
index 4f8cdc59bc38154b45f1adfd69c0a371df4394e3..5ca504c66e854fc8c5f96eb1149b76b02526cf9d 100644 (file)
@@ -1504,14 +1504,13 @@ xfs_vm_direct_IO(
        struct block_device     *bdev = xfs_find_bdev_for_inode(inode);
 
        if (rw & WRITE) {
-               return __blockdev_direct_IO(rw, iocb, inode, bdev, iter,
-                                           offset, xfs_get_blocks_direct,
+               return __blockdev_direct_IO(iocb, inode, bdev, iter, offset,
+                                           xfs_get_blocks_direct,
                                            xfs_end_io_direct_write, NULL,
                                            DIO_ASYNC_EXTEND);
        }
-       return __blockdev_direct_IO(rw, iocb, inode, bdev, iter,
-                                   offset, xfs_get_blocks_direct,
-                                   NULL, NULL, 0);
+       return __blockdev_direct_IO(iocb, inode, bdev, iter, offset,
+                                   xfs_get_blocks_direct, NULL, NULL, 0);
 }
 
 /*
index f1e3f65255a81092cfa084342f1440779793fc12..c67b6de8be331e534d20485df982c9115abe0411 100644 (file)
@@ -2634,16 +2634,18 @@ enum {
 
 void dio_end_io(struct bio *bio, int error);
 
-ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
-       struct block_device *bdev, struct iov_iter *iter, loff_t offset,
-       get_block_t get_block, dio_iodone_t end_io,
-       dio_submit_t submit_io, int flags);
-
-static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
-               struct inode *inode, struct iov_iter *iter, loff_t offset,
-               get_block_t get_block)
-{
-       return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iter,
+ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
+                            struct block_device *bdev, struct iov_iter *iter,
+                            loff_t offset, get_block_t get_block,
+                            dio_iodone_t end_io, dio_submit_t submit_io,
+                            int flags);
+
+static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
+                                        struct inode *inode,
+                                        struct iov_iter *iter, loff_t offset,
+                                        get_block_t get_block)
+{
+       return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
                                    offset, get_block, NULL, NULL,
                                    DIO_LOCKING | DIO_SKIP_HOLES);
 }