Commit 37c69b98 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Linus Torvalds

reiserfs: don't lock journal_init()

journal_init() doesn't need the lock since no operation on the filesystem
is involved there.  journal_read() and get_list_bitmap() have yet to be
reviewed carefully though before removing the lock there.  Just keep the
it around these two calls for safety.
Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jeff Mahoney <jeffm@suse.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f32485be
...@@ -2678,16 +2678,10 @@ int journal_init(struct super_block *sb, const char *j_dev_name, ...@@ -2678,16 +2678,10 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
int ret; int ret;
/*
* Unlock here to avoid various RECLAIM-FS-ON <-> IN-RECLAIM-FS
* dependency inversion warnings.
*/
reiserfs_write_unlock(sb);
journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal)); journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal));
if (!journal) { if (!journal) {
reiserfs_warning(sb, "journal-1256", reiserfs_warning(sb, "journal-1256",
"unable to get memory for journal structure"); "unable to get memory for journal structure");
reiserfs_write_lock(sb);
return 1; return 1;
} }
INIT_LIST_HEAD(&journal->j_bitmap_nodes); INIT_LIST_HEAD(&journal->j_bitmap_nodes);
...@@ -2695,10 +2689,8 @@ int journal_init(struct super_block *sb, const char *j_dev_name, ...@@ -2695,10 +2689,8 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
INIT_LIST_HEAD(&journal->j_working_list); INIT_LIST_HEAD(&journal->j_working_list);
INIT_LIST_HEAD(&journal->j_journal_list); INIT_LIST_HEAD(&journal->j_journal_list);
journal->j_persistent_trans = 0; journal->j_persistent_trans = 0;
ret = reiserfs_allocate_list_bitmaps(sb, journal->j_list_bitmap, if (reiserfs_allocate_list_bitmaps(sb, journal->j_list_bitmap,
reiserfs_bmap_count(sb)); reiserfs_bmap_count(sb)))
reiserfs_write_lock(sb);
if (ret)
goto free_and_return; goto free_and_return;
allocate_bitmap_nodes(sb); allocate_bitmap_nodes(sb);
...@@ -2727,27 +2719,11 @@ int journal_init(struct super_block *sb, const char *j_dev_name, ...@@ -2727,27 +2719,11 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
goto free_and_return; goto free_and_return;
} }
/*
* We need to unlock here to avoid creating the following
* dependency:
* reiserfs_lock -> sysfs_mutex
* Because the reiserfs mmap path creates the following dependency:
* mm->mmap -> reiserfs_lock, hence we have
* mm->mmap -> reiserfs_lock ->sysfs_mutex
* This would ends up in a circular dependency with sysfs readdir path
* which does sysfs_mutex -> mm->mmap_sem
* This is fine because the reiserfs lock is useless in mount path,
* at least until we call journal_begin. We keep it for paranoid
* reasons.
*/
reiserfs_write_unlock(sb);
if (journal_init_dev(sb, journal, j_dev_name) != 0) { if (journal_init_dev(sb, journal, j_dev_name) != 0) {
reiserfs_write_lock(sb);
reiserfs_warning(sb, "sh-462", reiserfs_warning(sb, "sh-462",
"unable to initialize jornal device"); "unable to initialize jornal device");
goto free_and_return; goto free_and_return;
} }
reiserfs_write_lock(sb);
rs = SB_DISK_SUPER_BLOCK(sb); rs = SB_DISK_SUPER_BLOCK(sb);
...@@ -2829,9 +2805,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name, ...@@ -2829,9 +2805,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
journal->j_mount_id = 10; journal->j_mount_id = 10;
journal->j_state = 0; journal->j_state = 0;
atomic_set(&(journal->j_jlock), 0); atomic_set(&(journal->j_jlock), 0);
reiserfs_write_unlock(sb);
journal->j_cnode_free_list = allocate_cnodes(num_cnodes); journal->j_cnode_free_list = allocate_cnodes(num_cnodes);
reiserfs_write_lock(sb);
journal->j_cnode_free_orig = journal->j_cnode_free_list; journal->j_cnode_free_orig = journal->j_cnode_free_list;
journal->j_cnode_free = journal->j_cnode_free_list ? num_cnodes : 0; journal->j_cnode_free = journal->j_cnode_free_list ? num_cnodes : 0;
journal->j_cnode_used = 0; journal->j_cnode_used = 0;
...@@ -2848,24 +2822,37 @@ int journal_init(struct super_block *sb, const char *j_dev_name, ...@@ -2848,24 +2822,37 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
init_journal_hash(sb); init_journal_hash(sb);
jl = journal->j_current_jl; jl = journal->j_current_jl;
/*
* get_list_bitmap() may call flush_commit_list() which
* requires the lock. Calling flush_commit_list() shouldn't happen
* this early but I like to be paranoid.
*/
reiserfs_write_lock(sb);
jl->j_list_bitmap = get_list_bitmap(sb, jl); jl->j_list_bitmap = get_list_bitmap(sb, jl);
reiserfs_write_unlock(sb);
if (!jl->j_list_bitmap) { if (!jl->j_list_bitmap) {
reiserfs_warning(sb, "journal-2005", reiserfs_warning(sb, "journal-2005",
"get_list_bitmap failed for journal list 0"); "get_list_bitmap failed for journal list 0");
goto free_and_return; goto free_and_return;
} }
if (journal_read(sb) < 0) {
/*
* Journal_read needs to be inspected in order to push down
* the lock further inside (or even remove it).
*/
reiserfs_write_lock(sb);
ret = journal_read(sb);
reiserfs_write_unlock(sb);
if (ret < 0) {
reiserfs_warning(sb, "reiserfs-2006", reiserfs_warning(sb, "reiserfs-2006",
"Replay Failure, unable to mount"); "Replay Failure, unable to mount");
goto free_and_return; goto free_and_return;
} }
reiserfs_mounted_fs_count++; reiserfs_mounted_fs_count++;
if (reiserfs_mounted_fs_count <= 1) { if (reiserfs_mounted_fs_count <= 1)
reiserfs_write_unlock(sb);
commit_wq = alloc_workqueue("reiserfs", WQ_MEM_RECLAIM, 0); commit_wq = alloc_workqueue("reiserfs", WQ_MEM_RECLAIM, 0);
reiserfs_write_lock(sb);
}
INIT_DELAYED_WORK(&journal->j_work, flush_async_commits); INIT_DELAYED_WORK(&journal->j_work, flush_async_commits);
journal->j_work_sb = sb; journal->j_work_sb = sb;
......
...@@ -1826,6 +1826,17 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -1826,6 +1826,17 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
printk("reiserfs: using flush barriers\n"); printk("reiserfs: using flush barriers\n");
} }
// set_device_ro(s->s_dev, 1) ;
if (journal_init(s, jdev_name, old_format, commit_max_age)) {
SWARN(silent, s, "sh-2022",
"unable to initialize journal space");
goto error_unlocked;
} else {
jinit_done = 1; /* once this is set, journal_release must be called
** if we error out of the mount
*/
}
/* /*
* This path assumed to be called with the BKL in the old times. * This path assumed to be called with the BKL in the old times.
* Now we have inherited the big reiserfs lock from it and many * Now we have inherited the big reiserfs lock from it and many
...@@ -1836,16 +1847,6 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) ...@@ -1836,16 +1847,6 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
*/ */
reiserfs_write_lock(s); reiserfs_write_lock(s);
// set_device_ro(s->s_dev, 1) ;
if (journal_init(s, jdev_name, old_format, commit_max_age)) {
SWARN(silent, s, "sh-2022",
"unable to initialize journal space");
goto error;
} else {
jinit_done = 1; /* once this is set, journal_release must be called
** if we error out of the mount
*/
}
if (reread_meta_blocks(s)) { if (reread_meta_blocks(s)) {
SWARN(silent, s, "jmacd-9", SWARN(silent, s, "jmacd-9",
"unable to reread meta blocks after journal init"); "unable to reread meta blocks after journal init");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment