fs/direct-io.c: minor cleanups in do_blockdev_direct_IO
authorNikolay Borisov <[email protected]>
Thu, 5 Apr 2018 23:24:36 +0000 (16:24 -0700)
committerLinus Torvalds <[email protected]>
Fri, 6 Apr 2018 04:36:26 +0000 (21:36 -0700)
We already get the block counts and calculate the end block at the
beginning of the function.  Let's use the local variables for
consistency and readability.  No functional changes

[[email protected]: constify the locals to prevent future slipups]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Nikolay Borisov <[email protected]>
Reviewed-by: Jeff Moyer <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Jens Axboe <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/direct-io.c

index 1357ef563893a1a8f0d2967eeb4b6e7b0ee6444a..1effd7bc5d02c86c69ce3c280d996902783184ee 100644 (file)
@@ -1178,9 +1178,9 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
        unsigned blkbits = i_blkbits;
        unsigned blocksize_mask = (1 << blkbits) - 1;
        ssize_t retval = -EINVAL;
-       size_t count = iov_iter_count(iter);
+       const size_t count = iov_iter_count(iter);
        loff_t offset = iocb->ki_pos;
-       loff_t end = offset + count;
+       const loff_t end = offset + count;
        struct dio *dio;
        struct dio_submit sdio = { 0, };
        struct buffer_head map_bh = { 0, };
@@ -1201,7 +1201,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
        }
 
        /* watch out for a 0 len io from a tricksy fs */
-       if (iov_iter_rw(iter) == READ && !iov_iter_count(iter))
+       if (iov_iter_rw(iter) == READ && !count)
                return 0;
 
        dio = kmem_cache_alloc(dio_cache, GFP_KERNEL);
@@ -1318,8 +1318,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
 
        dio->should_dirty = (iter->type == ITER_IOVEC);
        sdio.iter = iter;
-       sdio.final_block_in_request =
-               (offset + iov_iter_count(iter)) >> blkbits;
+       sdio.final_block_in_request = end >> blkbits;
 
        /*
         * In case of non-aligned buffers, we may need 2 more