Skip to contentSkip to conversation

direct-io: Minor cleanups in do_blockdev_direct_IO

PATCH In review Nikolay Borisov 2 participants 4 messages Aug 2, 2017 – Feb 21, 2018 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 direct-io: Minor cleanups in do_blockdev_direct_IO

We already get the block counts and the calculate the end block at the beginning of the function. Let's use the local variables for consistency and readability. No functional changes

---
 fs/direct-io.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/direct-io.c +2 -3
index 08cf27811e5a..987bc17a5f5e 100644
@@ -1139,7 +1139,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);
@@ -1248,8 +1248,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
Signature · 1 line
2.7.4
#2 lore raw
In reply to Nikolay Borisov
Quoted 6 lines · Nikolay Borisov

We already get the block counts and the calculate the end block at the beginning of the function. Let's use the local variables for consistency and readability. No functional changes

---

ping

Quoted 27 lines
 fs/direct-io.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/direct-io.c +2 -3
index 08cf27811e5a..987bc17a5f5e 100644
@@ -1139,7 +1139,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);
@@ -1248,8 +1248,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
#3 lore raw
In reply to Nikolay Borisov
Quoted 24 lines · Nikolay Borisov

We already get the block counts and the calculate the end block at the beginning of the function. Let's use the local variables for consistency and readability. No functional changes

---
 fs/direct-io.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/direct-io.c +1 -1
index 08cf27811e5a..987bc17a5f5e 100644
@@ -1139,7 +1139,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);

fs/direct-io.c do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, · line 1254

Quoted 9 lines
fs/direct-io.c +1 -2
@@ -1248,8 +1248,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

Ping on that forgotten one :)