linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 2.6.8-rc4-mm1 DIO pages-in-io accounting fix
@ 2004-08-16 17:50 Badari Pulavarty
  0 siblings, 0 replies; only message in thread
From: Badari Pulavarty @ 2004-08-16 17:50 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 781 bytes --]

Hi Andrew,

I found one more accounting inconsistency with dio_pages_in_io.
This is a day-one bug and I started hitting it on latest -mm
due to the recent changes to dio_pages_in_io calculations to be
exact.

If the file is badly fragmented (no contiguous blocks at all),
and the user buffer is not page aligned - we need to create
IO for each disk block with 2 pages. (bio with 2 vecs).
 
dio_bio_add_page() should not decrement dio_pages_in_io for every
add page. It should only decrement, it only if its done with that
page and moving on to next page. (since dio_pages_in_io represent 
how many actual pages we are operating on). 

Here is the patch to fix this accounting. Without this patch, we
will hit BUG() in dio_new_bio() with O_DIRECT on filesystems,.

Thanks,
Badari



[-- Attachment #2: dio_inio.patch --]
[-- Type: text/plain, Size: 636 bytes --]

--- linux.org/fs/direct-io.c	2004-08-16 10:57:33.112528208 -0700
+++ linux-2.6.8-rc4-mm1/fs/direct-io.c	2004-08-16 10:59:10.668697416 -0700
@@ -561,7 +561,11 @@ static int dio_bio_add_page(struct dio *
 	ret = bio_add_page(dio->bio, dio->cur_page,
 			dio->cur_page_len, dio->cur_page_offset);
 	if (ret == dio->cur_page_len) {
-		dio->pages_in_io--;
+		/*
+		 * Decrement count only, if we are done with this page
+		 */
+		if ((dio->cur_page_len + dio->cur_page_offset) == PAGE_SIZE)
+			dio->pages_in_io--;
 		page_cache_get(dio->cur_page);
 		dio->final_block_in_bio = dio->cur_page_block +
 			(dio->cur_page_len >> dio->blkbits);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-08-16 17:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-16 17:50 [PATCH] 2.6.8-rc4-mm1 DIO pages-in-io accounting fix Badari Pulavarty

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).