aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2012-01-10 18:11:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 19:30:53 -0500
commitf32485be8397ad811312bc055d2e2a5906bc7576 (patch)
tree3f3ca7a7d8395253189def7742fbd43698dce996
parentb18c1c6e0c90cbcd38ba879bd63a44c94e4f7301 (diff)
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 <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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/reiserfs/bitmap.c3
-rw-r--r--fs/reiserfs/super.c43
2 files changed, 24 insertions, 22 deletions
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index a945cd265228..70de42f09f1d 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -1364,10 +1364,7 @@ int reiserfs_init_bitmap_cache(struct super_block *sb)
1364 struct reiserfs_bitmap_info *bitmap; 1364 struct reiserfs_bitmap_info *bitmap;
1365 unsigned int bmap_nr = reiserfs_bmap_count(sb); 1365 unsigned int bmap_nr = reiserfs_bmap_count(sb);
1366 1366
1367 /* Avoid lock recursion in fault case */
1368 reiserfs_write_unlock(sb);
1369 bitmap = vmalloc(sizeof(*bitmap) * bmap_nr); 1367 bitmap = vmalloc(sizeof(*bitmap) * bmap_nr);
1370 reiserfs_write_lock(sb);
1371 if (bitmap == NULL) 1368 if (bitmap == NULL)
1372 return -ENOMEM; 1369 return -ENOMEM;
1373 1370
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 1d42e707d5fa..620dd5d9e1b1 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1746,22 +1746,11 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1746 mutex_init(&REISERFS_SB(s)->lock); 1746 mutex_init(&REISERFS_SB(s)->lock);
1747 REISERFS_SB(s)->lock_depth = -1; 1747 REISERFS_SB(s)->lock_depth = -1;
1748 1748
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
1760 jdev_name = NULL; 1749 jdev_name = NULL;
1761 if (reiserfs_parse_options 1750 if (reiserfs_parse_options
1762 (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name, 1751 (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name,
1763 &commit_max_age, qf_names, &qfmt) == 0) { 1752 &commit_max_age, qf_names, &qfmt) == 0) {
1764 goto error; 1753 goto error_unlocked;
1765 } 1754 }
1766 if (jdev_name && jdev_name[0]) { 1755 if (jdev_name && jdev_name[0]) {
1767 REISERFS_SB(s)->s_jdev = kstrdup(jdev_name, GFP_KERNEL); 1756 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)
1777 1766
1778 if (blocks) { 1767 if (blocks) {
1779 SWARN(silent, s, "jmacd-7", "resize option for remount only"); 1768 SWARN(silent, s, "jmacd-7", "resize option for remount only");
1780 goto error; 1769 goto error_unlocked;
1781 } 1770 }
1782 1771
1783 /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */ 1772 /* 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)
1787 else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) { 1776 else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
1788 SWARN(silent, s, "sh-2021", "can not find reiserfs on %s", 1777 SWARN(silent, s, "sh-2021", "can not find reiserfs on %s",
1789 reiserfs_bdevname(s)); 1778 reiserfs_bdevname(s));
1790 goto error; 1779 goto error_unlocked;
1791 } 1780 }
1792 1781
1793 rs = SB_DISK_SUPER_BLOCK(s); 1782 rs = SB_DISK_SUPER_BLOCK(s);
@@ -1803,7 +1792,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1803 "or increase size of your LVM partition"); 1792 "or increase size of your LVM partition");
1804 SWARN(silent, s, "", "Or may be you forgot to " 1793 SWARN(silent, s, "", "Or may be you forgot to "
1805 "reboot after fdisk when it told you to"); 1794 "reboot after fdisk when it told you to");
1806 goto error; 1795 goto error_unlocked;
1807 } 1796 }
1808 1797
1809 sbi->s_mount_state = SB_REISERFS_STATE(s); 1798 sbi->s_mount_state = SB_REISERFS_STATE(s);
@@ -1811,8 +1800,9 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1811 1800
1812 if ((errval = reiserfs_init_bitmap_cache(s))) { 1801 if ((errval = reiserfs_init_bitmap_cache(s))) {
1813 SWARN(silent, s, "jmacd-8", "unable to read bitmap"); 1802 SWARN(silent, s, "jmacd-8", "unable to read bitmap");
1814 goto error; 1803 goto error_unlocked;
1815 } 1804 }
1805
1816 errval = -EINVAL; 1806 errval = -EINVAL;
1817#ifdef CONFIG_REISERFS_CHECK 1807#ifdef CONFIG_REISERFS_CHECK
1818 SWARN(silent, s, "", "CONFIG_REISERFS_CHECK is set ON"); 1808 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)
1835 if (reiserfs_barrier_flush(s)) { 1825 if (reiserfs_barrier_flush(s)) {
1836 printk("reiserfs: using flush barriers\n"); 1826 printk("reiserfs: using flush barriers\n");
1837 } 1827 }
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
1838 // set_device_ro(s->s_dev, 1) ; 1839 // set_device_ro(s->s_dev, 1) ;
1839 if (journal_init(s, jdev_name, old_format, commit_max_age)) { 1840 if (journal_init(s, jdev_name, old_format, commit_max_age)) {
1840 SWARN(silent, s, "sh-2022", 1841 SWARN(silent, s, "sh-2022",
@@ -1995,12 +1996,16 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1995 return (0); 1996 return (0);
1996 1997
1997error: 1998error:
1998 if (jinit_done) { /* kill the commit thread, free journal ram */ 1999 reiserfs_write_unlock(s);
2000
2001error_unlocked:
2002 /* kill the commit thread, free journal ram */
2003 if (jinit_done) {
2004 reiserfs_write_lock(s);
1999 journal_release_error(NULL, s); 2005 journal_release_error(NULL, s);
2006 reiserfs_write_unlock(s);
2000 } 2007 }
2001 2008
2002 reiserfs_write_unlock(s);
2003
2004 reiserfs_free_bitmap_cache(s); 2009 reiserfs_free_bitmap_cache(s);
2005 if (SB_BUFFER_WITH_SB(s)) 2010 if (SB_BUFFER_WITH_SB(s))
2006 brelse(SB_BUFFER_WITH_SB(s)); 2011 brelse(SB_BUFFER_WITH_SB(s));