[PATCH] 2.6.9-rc2-mm1 dio fine alignment and pages in io

From: Badari Pulavarty
Date: Thu Sep 23 2004 - 19:55:29 EST


Hi Andrew,

Here is the fix for dio_new_bio() BUG() with fsx tests.
The problem is, I changed dio_pages_in_io calculation to
be exactly the number of pages we needed to map the user-buffer
to do the IO. But with fine-grain alignment (non fs-blocksize),
we may need 2 more pages (ZERO_PAGE) to zero out first and last
block if needed.

Here is the patch to fix the problem.

Here is the bug info.

http://bugme.osdl.org/show_bug.cgi?id=3447


Thanks,
Badari


--- linux.org/fs/direct-io.c 2004-09-23 18:02:16.386912312 -0700
+++ linux/fs/direct-io.c 2004-09-23 18:06:51.110148032 -0700
@@ -958,7 +958,15 @@ direct_io_worker(int rw, struct kiocb *i
dio->bio_list = NULL;
dio->waiter = NULL;

- dio->pages_in_io = 0;
+ /*
+ * In case of non-aligned buffers, we may need 2 more
+ * pages since we need to zero out first and last block.
+ */
+ if (unlikely(dio->blkfactor))
+ dio->pages_in_io = 2;
+ else
+ dio->pages_in_io = 0;
+
for (seg = 0; seg < nr_segs; seg++) {
user_addr = (unsigned long)iov[seg].iov_base;
dio->pages_in_io +=