* [PATCH] jbd: Fix lock ordering bug in journal_unmap_buffer()
@ 2012-11-23 17:20 Jan Kara
0 siblings, 0 replies; only message in thread
From: Jan Kara @ 2012-11-23 17:20 UTC (permalink / raw)
To: linux-ext4; +Cc: Jan Kara
Commit 09e05d48 introduced a wait for transaction commit into
journal_unmap_buffer() in the case we are truncating a buffer undergoing commit
in the page stradding i_size on a filesystem with blocksize < pagesize. Sadly
we forgot to drop buffer lock before waiting for transaction commit and thus
deadlock is possible when kjournald wants to lock the buffer.
Fix the problem by dropping the buffer lock before waiting for transaction
commit. Since we are still holding page lock (and that is OK), buffer cannot
disappear under us.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/jbd/transaction.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
I want to push this fix to Linus soon. JBD2 needs the fix as well but there
it affects only data=journal mode and the fix is more complex due to different
lock ordering.
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 78b7f84..7f5120b 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -1961,7 +1961,9 @@ retry:
spin_unlock(&journal->j_list_lock);
jbd_unlock_bh_state(bh);
spin_unlock(&journal->j_state_lock);
+ unlock_buffer(bh);
log_wait_commit(journal, tid);
+ lock_buffer(bh);
goto retry;
}
/*
--
1.7.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-11-23 17:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-23 17:20 [PATCH] jbd: Fix lock ordering bug in journal_unmap_buffer() Jan Kara
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).