From: Badari Pulavarty <pbadari@us.ibm.com>

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 bug info.

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

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/fs/direct-io.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)

diff -puN fs/direct-io.c~dio-fine-alignment-and-pages-in-io fs/direct-io.c
--- 25/fs/direct-io.c~dio-fine-alignment-and-pages-in-io	2004-09-23 18:12:22.020145480 -0700
+++ 25-akpm/fs/direct-io.c	2004-09-23 18:12:22.024144872 -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 +=
_