Fix deadlock in journal_create
PATCH 1/1 Fix deadlock in journal_create
Hi,
I ran across a deadlock yesterday when trying to do a journal_create
at mount time. The problem is that journal_create does a sync_dev which eventually tries to do a get_super which does:
down_read(&s->s_umount);
The problem arises if I call journal_create from my read_super method in which case get_sb_bdev has already done:
down_write(&s->s_umount);
from alloc_super. Replacing the sync_dev call with an fsync_no_super seems to have fixed the deadlock.
It you want to test this out using ext3 (I have verified it with my own filesystem), simply follow these steps:
1) create an ext2 filesystem on a device
2) mount that new partition and make a "journal file" on it (using dd). get the inode number of that file.
3) unmount it and remount it as an ext3 filesystem using the option:
journal=inode_number where inode number is the inode number of the journal file you just created.
This will get ext3's read_super method to call ext3_create_journal which will hang during a journal_create.
A one line patch is attached. Please let me know what you think.
--Mark
--
Mark Fasheh
Software Developer, Oracle Corp
[email protected]
fs/jbd/journal.c renamed from fs/jbd/journal.c.orig +1 -1
@@ -912,7 +912,7 @@ int journal_create(journal_t *journal)__brelse (bh); } -sync_dev (journal->j_dev); +fsync_no_super (journal->j_dev);jbd_debug (1 ,"JBD: journal cleared.\n" );/* OK, fill in the initial static fields in the new superblock */
Hi,
Quoted 4 lines · Mark Fasheh
This will get ext3's
read_supermethod to callext3_create_journalwhich will hang during ajournal_create.A one line patch is attached. Please let me know what you think.
Looks OK to me.
--Stephen