Skip to contentSkip to conversation

ext3 jbd needs to wait for locked buffers

PATCH In review Chris Mason 2 participants 2 messages Jun 18, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext3 jbd needs to wait for locked buffers

jbd needs to wait for any io to complete on the buffer before changing the end_io function. Using set_buffer_locked means that it can change the end_io function while the page is in the middle of writeback, and the writeback bit on the page will never get cleared.

Since we set the buffer dirty earlier on, if the page was previously dirty, pdflush or memory pressure might trigger a writepage call, which will race with jbd's set_buffer_locked.

fs/jbd/commit.c +1 -1
Index: linux.t/fs/jbd/commit.c
===================================================================
@@ -504,7 +504,7 @@ write_out_data:
 start_journal_io:
 			for (i = 0; i < bufs; i++) {
 				struct buffer_head *bh = wbuf[i];
-				set_buffer_locked(bh);
+				lock_buffer(bh);
 				clear_buffer_dirty(bh);
 				set_buffer_uptodate(bh);
 				bh->b_end_io = journal_end_buffer_io_sync;
#1 lore raw
Quoted 3 lines · Chris Mason

jbd needs to wait for any io to complete on the buffer before
changing the end_io function.

Thanks, I bet that was fun to hunt down.

Same problem in 2.4, although there it looks like it'll just cause a memory leak. I guess if an app is mmapping a blockdev we could end up with a permanently locked page though.