linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dio: fix typos in comments
@ 2011-01-11 12:15 Namhyung Kim
  2011-01-11 12:15 ` [PATCH 2/2] dio: simple cleanup for direct_io_worker() Namhyung Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2011-01-11 12:15 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel, Jiri Kosina

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Jiri Kosina <trivial@kernel.org>
---
 fs/direct-io.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 85882f6ba5f7..8201c2558d85 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -641,11 +641,11 @@ static int dio_send_cur_page(struct dio *dio)
 		/*
 		 * See whether this new request is contiguous with the old.
 		 *
-		 * Btrfs cannot handl having logically non-contiguous requests
-		 * submitted.  For exmple if you have
+		 * Btrfs cannot handle having logically non-contiguous requests
+		 * submitted.  For example if you have
 		 *
 		 * Logical:  [0-4095][HOLE][8192-12287]
-		 * Phyiscal: [0-4095]      [4096-8181]
+		 * Physical: [0-4095]      [4096-8191]
 		 *
 		 * We cannot submit those pages together as one BIO.  So if our
 		 * current logical offset in the file does not equal what would
-- 
1.7.3.4.600.g982838b0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] dio: simple cleanup for direct_io_worker()
  2011-01-11 12:15 [PATCH 1/2] dio: fix typos in comments Namhyung Kim
@ 2011-01-11 12:15 ` Namhyung Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2011-01-11 12:15 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel

Use DIV_ROUND_UP() and offset_in_page() to make code simpler.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 fs/direct-io.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 8201c2558d85..7ba681412bd4 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1020,16 +1020,19 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
 	for (seg = 0; seg < nr_segs; seg++) {
 		user_addr = (unsigned long)iov[seg].iov_base;
 		dio->pages_in_io +=
-			((user_addr+iov[seg].iov_len +PAGE_SIZE-1)/PAGE_SIZE
+			(DIV_ROUND_UP(user_addr + iov[seg].iov_len, PAGE_SIZE)
 				- user_addr/PAGE_SIZE);
 	}
 
 	for (seg = 0; seg < nr_segs; seg++) {
+		unsigned page_offset;
+
 		user_addr = (unsigned long)iov[seg].iov_base;
 		dio->size += bytes = iov[seg].iov_len;
+		page_offset = offset_in_page(user_addr);
 
 		/* Index into the first page of the first block */
-		dio->first_block_in_page = (user_addr & ~PAGE_MASK) >> blkbits;
+		dio->first_block_in_page = page_offset >> blkbits;
 		dio->final_block_in_request = dio->block_in_file +
 						(bytes >> blkbits);
 		/* Page fetching state */
@@ -1038,11 +1041,11 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
 		dio->curr_page = 0;
 
 		dio->total_pages = 0;
-		if (user_addr & (PAGE_SIZE-1)) {
+		if (page_offset) {
 			dio->total_pages++;
-			bytes -= PAGE_SIZE - (user_addr & (PAGE_SIZE - 1));
+			bytes -= PAGE_SIZE - page_offset;
 		}
-		dio->total_pages += (bytes + PAGE_SIZE - 1) / PAGE_SIZE;
+		dio->total_pages += DIV_ROUND_UP(bytes, PAGE_SIZE);
 		dio->curr_user_address = user_addr;
 	
 		ret = do_direct_IO(dio);
-- 
1.7.3.4.600.g982838b0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-11 12:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-11 12:15 [PATCH 1/2] dio: fix typos in comments Namhyung Kim
2011-01-11 12:15 ` [PATCH 2/2] dio: simple cleanup for direct_io_worker() Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).