linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] set_page_buffer_dirty should skip unmapped buffers
@ 2006-09-01 15:50 Badari Pulavarty
  2006-09-01 16:12 ` Anton Altaparmakov
  0 siblings, 1 reply; 32+ messages in thread
From: Badari Pulavarty @ 2006-09-01 15:50 UTC (permalink / raw)
  To: sct, akpm; +Cc: linux-fsdevel, lkml, ext4

Hi Andrew,

I have been running into following bug while running fsx
tests on 1k (ext3) filesystem all the time. 

----------- [cut here ] --------- [please bite here ] ---------
Kernel BUG at fs/buffer.c:2791
invalid opcode: 0000 [1] SMP

Its complaining about BUG_ON(!buffer_mapped(bh)).

It was hard to track it down, needed lots of debug - but here 
is the problem & fix.  Since the fix is in __set_page_buffer_dirty()
code - I am wondering how it would effect others :(

With this fix fsx tests ran for more than 16 hours (and still
running).

Please let me know, what you think.

Thanks,
Badari 

Patch to fix: Kernel BUG at fs/buffer.c:2791
on 1k (2k) filesystems while running fsx.

journal_commit_transaction collects lots of dirty buffer from
and does a single ll_rw_block() to write them out. ll_rw_block()
locks the buffer and checks to see if they are dirty and submits
them for IO.

In the mean while, journal_unmap_buffers() as part of
truncate can unmap the buffer and throw it away. Since its
a 1k (2k) filesystem - each page (4k) will have more than
one buffer_head attached to the page and and we can't free 
up buffer_heads attached to the page (if we are not
invalidating the whole page).

Now, any call to set_page_dirty() (like msync_interval)
could end up setting all the buffer heads attached to
this page again dirty, including the ones those got
cleaned up :(

If ll_rw_block() runs now and sees the dirty bit it does
submit_bh() on those buffer_heads and triggers the assert.

Fix is to check if the buffer is mapped before setting its
dirty bit in __set_page_dirty_buffers().

Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
---
 fs/buffer.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Index: linux-2.6.18-rc5/fs/buffer.c
===================================================================
--- linux-2.6.18-rc5.orig/fs/buffer.c	2006-09-01 08:20:51.000000000 -0700
+++ linux-2.6.18-rc5/fs/buffer.c	2006-09-01 08:41:01.000000000 -0700
@@ -846,7 +846,13 @@ int __set_page_dirty_buffers(struct page
 		struct buffer_head *bh = head;
 
 		do {
-			set_buffer_dirty(bh);
+			/*
+			 * Its possible that, not all buffers attached to
+			 * this page are mapped (cleaned up by truncate).
+			 * If so, skip them.
+			 */
+			if (buffer_mapped(bh))
+				set_buffer_dirty(bh);
 			bh = bh->b_this_page;
 		} while (bh != head);
 	}



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

end of thread, other threads:[~2006-09-28 15:03 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-01 15:50 [RFC][PATCH] set_page_buffer_dirty should skip unmapped buffers Badari Pulavarty
2006-09-01 16:12 ` Anton Altaparmakov
2006-09-01 16:32   ` Badari Pulavarty
2006-09-01 17:18     ` Andrew Morton
2006-09-01 17:43       ` Badari Pulavarty
2006-09-01 21:01       ` Badari Pulavarty
2006-09-05 16:11       ` Badari Pulavarty
2006-09-06 12:47         ` Jan Kara
2006-09-06 15:12           ` Badari Pulavarty
2006-09-06 15:34             ` Jan Kara
2006-09-06 16:19               ` Badari Pulavarty
2006-09-06 16:27                 ` Jan Kara
2006-09-06 16:43                   ` Badari Pulavarty
2006-09-06 17:03                     ` Jan Kara
2006-09-06 17:16                   ` Badari Pulavarty
2006-09-06 17:27                     ` Jan Kara
2006-09-07  2:14                       ` Andrew Morton
2006-09-07  3:04                         ` Badari Pulavarty
2006-09-07  3:34                           ` Andrew Morton
2006-09-07 15:11                       ` Badari Pulavarty
2006-09-07 20:48                         ` Jan Kara
2006-09-07 22:30                         ` Jan Kara
2006-09-08  4:33                           ` Badari Pulavarty
2006-09-08  8:25                             ` Jan Kara
2006-09-08 14:35                               ` Badari Pulavarty
2006-09-11  9:46                                 ` Jan Kara
2006-09-11 20:45                                   ` Badari Pulavarty
2006-09-11 20:52                                     ` Jan Kara
2006-09-13 20:25                           ` Dave Kleikamp
2006-09-14  3:38                             ` Andrew Morton
2006-09-27 22:01                               ` Eric Sandeen
2006-09-28 15:03                                 ` [PATCH] JBD: Make journal_do_submit_data static Dave Kleikamp

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