Skip to content

Commit f32485b

Browse files
fweisbectorvalds
authored andcommitted
reiserfs: delay reiserfs lock until journal initialization
In the mount path, transactions that are made before journal initialization don't involve the filesystem. We can delay the reiserfs lock until we play with the journal. Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Al Viro <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Jeff Mahoney <[email protected]> Cc: Jan Kara <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent b18c1c6 commit f32485b

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

fs/reiserfs/bitmap.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,10 +1364,7 @@ int reiserfs_init_bitmap_cache(struct super_block *sb)
13641364
struct reiserfs_bitmap_info *bitmap;
13651365
unsigned int bmap_nr = reiserfs_bmap_count(sb);
13661366

1367-
/* Avoid lock recursion in fault case */
1368-
reiserfs_write_unlock(sb);
13691367
bitmap = vmalloc(sizeof(*bitmap) * bmap_nr);
1370-
reiserfs_write_lock(sb);
13711368
if (bitmap == NULL)
13721369
return -ENOMEM;
13731370

fs/reiserfs/super.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,22 +1746,11 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
17461746
mutex_init(&REISERFS_SB(s)->lock);
17471747
REISERFS_SB(s)->lock_depth = -1;
17481748

1749-
/*
1750-
* This function is called with the bkl, which also was the old
1751-
* locking used here.
1752-
* do_journal_begin() will soon check if we hold the lock (ie: was the
1753-
* bkl). This is likely because do_journal_begin() has several another
1754-
* callers because at this time, it doesn't seem to be necessary to
1755-
* protect against anything.
1756-
* Anyway, let's be conservative and lock for now.
1757-
*/
1758-
reiserfs_write_lock(s);
1759-
17601749
jdev_name = NULL;
17611750
if (reiserfs_parse_options
17621751
(s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name,
17631752
&commit_max_age, qf_names, &qfmt) == 0) {
1764-
goto error;
1753+
goto error_unlocked;
17651754
}
17661755
if (jdev_name && jdev_name[0]) {
17671756
REISERFS_SB(s)->s_jdev = kstrdup(jdev_name, GFP_KERNEL);
@@ -1777,7 +1766,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
17771766

17781767
if (blocks) {
17791768
SWARN(silent, s, "jmacd-7", "resize option for remount only");
1780-
goto error;
1769+
goto error_unlocked;
17811770
}
17821771

17831772
/* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
@@ -1787,7 +1776,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
17871776
else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
17881777
SWARN(silent, s, "sh-2021", "can not find reiserfs on %s",
17891778
reiserfs_bdevname(s));
1790-
goto error;
1779+
goto error_unlocked;
17911780
}
17921781

17931782
rs = SB_DISK_SUPER_BLOCK(s);
@@ -1803,16 +1792,17 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
18031792
"or increase size of your LVM partition");
18041793
SWARN(silent, s, "", "Or may be you forgot to "
18051794
"reboot after fdisk when it told you to");
1806-
goto error;
1795+
goto error_unlocked;
18071796
}
18081797

18091798
sbi->s_mount_state = SB_REISERFS_STATE(s);
18101799
sbi->s_mount_state = REISERFS_VALID_FS;
18111800

18121801
if ((errval = reiserfs_init_bitmap_cache(s))) {
18131802
SWARN(silent, s, "jmacd-8", "unable to read bitmap");
1814-
goto error;
1803+
goto error_unlocked;
18151804
}
1805+
18161806
errval = -EINVAL;
18171807
#ifdef CONFIG_REISERFS_CHECK
18181808
SWARN(silent, s, "", "CONFIG_REISERFS_CHECK is set ON");
@@ -1835,6 +1825,17 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
18351825
if (reiserfs_barrier_flush(s)) {
18361826
printk("reiserfs: using flush barriers\n");
18371827
}
1828+
1829+
/*
1830+
* This path assumed to be called with the BKL in the old times.
1831+
* Now we have inherited the big reiserfs lock from it and many
1832+
* reiserfs helpers called in the mount path and elsewhere require
1833+
* this lock to be held even if it's not always necessary. Let's be
1834+
* conservative and hold it early. The window can be reduced after
1835+
* careful review of the code.
1836+
*/
1837+
reiserfs_write_lock(s);
1838+
18381839
// set_device_ro(s->s_dev, 1) ;
18391840
if (journal_init(s, jdev_name, old_format, commit_max_age)) {
18401841
SWARN(silent, s, "sh-2022",
@@ -1995,12 +1996,16 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
19951996
return (0);
19961997

19971998
error:
1998-
if (jinit_done) { /* kill the commit thread, free journal ram */
1999+
reiserfs_write_unlock(s);
2000+
2001+
error_unlocked:
2002+
/* kill the commit thread, free journal ram */
2003+
if (jinit_done) {
2004+
reiserfs_write_lock(s);
19992005
journal_release_error(NULL, s);
2006+
reiserfs_write_unlock(s);
20002007
}
20012008

2002-
reiserfs_write_unlock(s);
2003-
20042009
reiserfs_free_bitmap_cache(s);
20052010
if (SB_BUFFER_WITH_SB(s))
20062011
brelse(SB_BUFFER_WITH_SB(s));

0 commit comments

Comments
 (0)