aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2012-02-03 17:12:42 -0500
committerJiri Kosina <jkosina@suse.cz>2012-02-03 17:13:05 -0500
commit972c5ae961d6e5103e2b33d935cfa4145fd47140 (patch)
tree350b2a76b979ba8766c09838617df67ff330eca0 /fs/reiserfs
parent5196d20305d5e30d871111d3a876cf067dd94255 (diff)
parent7c7ed8ec337bf5f62cc5287a6eb6b2f1b7504c2f (diff)
Merge branch 'master' into for-next
Sync with Linus' tree to be able to apply patch to a newer code (namely drivers/gpu/drm/gma500/psb_intel_lvds.c)
Diffstat (limited to 'fs/reiserfs')
-rw-r--r--fs/reiserfs/bitmap.c3
-rw-r--r--fs/reiserfs/journal.c64
-rw-r--r--fs/reiserfs/super.c81
3 files changed, 69 insertions, 79 deletions
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index a945cd26522..70de42f09f1 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/journal.c b/fs/reiserfs/journal.c
index eb711060a6f..c3cf54fd4de 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -2678,16 +2678,10 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2678 char b[BDEVNAME_SIZE]; 2678 char b[BDEVNAME_SIZE];
2679 int ret; 2679 int ret;
2680 2680
2681 /*
2682 * Unlock here to avoid various RECLAIM-FS-ON <-> IN-RECLAIM-FS
2683 * dependency inversion warnings.
2684 */
2685 reiserfs_write_unlock(sb);
2686 journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal)); 2681 journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal));
2687 if (!journal) { 2682 if (!journal) {
2688 reiserfs_warning(sb, "journal-1256", 2683 reiserfs_warning(sb, "journal-1256",
2689 "unable to get memory for journal structure"); 2684 "unable to get memory for journal structure");
2690 reiserfs_write_lock(sb);
2691 return 1; 2685 return 1;
2692 } 2686 }
2693 INIT_LIST_HEAD(&journal->j_bitmap_nodes); 2687 INIT_LIST_HEAD(&journal->j_bitmap_nodes);
@@ -2695,10 +2689,8 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2695 INIT_LIST_HEAD(&journal->j_working_list); 2689 INIT_LIST_HEAD(&journal->j_working_list);
2696 INIT_LIST_HEAD(&journal->j_journal_list); 2690 INIT_LIST_HEAD(&journal->j_journal_list);
2697 journal->j_persistent_trans = 0; 2691 journal->j_persistent_trans = 0;
2698 ret = reiserfs_allocate_list_bitmaps(sb, journal->j_list_bitmap, 2692 if (reiserfs_allocate_list_bitmaps(sb, journal->j_list_bitmap,
2699 reiserfs_bmap_count(sb)); 2693 reiserfs_bmap_count(sb)))
2700 reiserfs_write_lock(sb);
2701 if (ret)
2702 goto free_and_return; 2694 goto free_and_return;
2703 2695
2704 allocate_bitmap_nodes(sb); 2696 allocate_bitmap_nodes(sb);
@@ -2727,27 +2719,11 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2727 goto free_and_return; 2719 goto free_and_return;
2728 } 2720 }
2729 2721
2730 /*
2731 * We need to unlock here to avoid creating the following
2732 * dependency:
2733 * reiserfs_lock -> sysfs_mutex
2734 * Because the reiserfs mmap path creates the following dependency:
2735 * mm->mmap -> reiserfs_lock, hence we have
2736 * mm->mmap -> reiserfs_lock ->sysfs_mutex
2737 * This would ends up in a circular dependency with sysfs readdir path
2738 * which does sysfs_mutex -> mm->mmap_sem
2739 * This is fine because the reiserfs lock is useless in mount path,
2740 * at least until we call journal_begin. We keep it for paranoid
2741 * reasons.
2742 */
2743 reiserfs_write_unlock(sb);
2744 if (journal_init_dev(sb, journal, j_dev_name) != 0) { 2722 if (journal_init_dev(sb, journal, j_dev_name) != 0) {
2745 reiserfs_write_lock(sb);
2746 reiserfs_warning(sb, "sh-462", 2723 reiserfs_warning(sb, "sh-462",
2747 "unable to initialize jornal device"); 2724 "unable to initialize jornal device");
2748 goto free_and_return; 2725 goto free_and_return;
2749 } 2726 }
2750 reiserfs_write_lock(sb);
2751 2727
2752 rs = SB_DISK_SUPER_BLOCK(sb); 2728 rs = SB_DISK_SUPER_BLOCK(sb);
2753 2729
@@ -2829,9 +2805,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2829 journal->j_mount_id = 10; 2805 journal->j_mount_id = 10;
2830 journal->j_state = 0; 2806 journal->j_state = 0;
2831 atomic_set(&(journal->j_jlock), 0); 2807 atomic_set(&(journal->j_jlock), 0);
2832 reiserfs_write_unlock(sb);
2833 journal->j_cnode_free_list = allocate_cnodes(num_cnodes); 2808 journal->j_cnode_free_list = allocate_cnodes(num_cnodes);
2834 reiserfs_write_lock(sb);
2835 journal->j_cnode_free_orig = journal->j_cnode_free_list; 2809 journal->j_cnode_free_orig = journal->j_cnode_free_list;
2836 journal->j_cnode_free = journal->j_cnode_free_list ? num_cnodes : 0; 2810 journal->j_cnode_free = journal->j_cnode_free_list ? num_cnodes : 0;
2837 journal->j_cnode_used = 0; 2811 journal->j_cnode_used = 0;
@@ -2848,24 +2822,37 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2848 2822
2849 init_journal_hash(sb); 2823 init_journal_hash(sb);
2850 jl = journal->j_current_jl; 2824 jl = journal->j_current_jl;
2825
2826 /*
2827 * get_list_bitmap() may call flush_commit_list() which
2828 * requires the lock. Calling flush_commit_list() shouldn't happen
2829 * this early but I like to be paranoid.
2830 */
2831 reiserfs_write_lock(sb);
2851 jl->j_list_bitmap = get_list_bitmap(sb, jl); 2832 jl->j_list_bitmap = get_list_bitmap(sb, jl);
2833 reiserfs_write_unlock(sb);
2852 if (!jl->j_list_bitmap) { 2834 if (!jl->j_list_bitmap) {
2853 reiserfs_warning(sb, "journal-2005", 2835 reiserfs_warning(sb, "journal-2005",
2854 "get_list_bitmap failed for journal list 0"); 2836 "get_list_bitmap failed for journal list 0");
2855 goto free_and_return; 2837 goto free_and_return;
2856 } 2838 }
2857 if (journal_read(sb) < 0) { 2839
2840 /*
2841 * Journal_read needs to be inspected in order to push down
2842 * the lock further inside (or even remove it).
2843 */
2844 reiserfs_write_lock(sb);
2845 ret = journal_read(sb);
2846 reiserfs_write_unlock(sb);
2847 if (ret < 0) {
2858 reiserfs_warning(sb, "reiserfs-2006", 2848 reiserfs_warning(sb, "reiserfs-2006",
2859 "Replay Failure, unable to mount"); 2849 "Replay Failure, unable to mount");
2860 goto free_and_return; 2850 goto free_and_return;
2861 } 2851 }
2862 2852
2863 reiserfs_mounted_fs_count++; 2853 reiserfs_mounted_fs_count++;
2864 if (reiserfs_mounted_fs_count <= 1) { 2854 if (reiserfs_mounted_fs_count <= 1)
2865 reiserfs_write_unlock(sb);
2866 commit_wq = alloc_workqueue("reiserfs", WQ_MEM_RECLAIM, 0); 2855 commit_wq = alloc_workqueue("reiserfs", WQ_MEM_RECLAIM, 0);
2867 reiserfs_write_lock(sb);
2868 }
2869 2856
2870 INIT_DELAYED_WORK(&journal->j_work, flush_async_commits); 2857 INIT_DELAYED_WORK(&journal->j_work, flush_async_commits);
2871 journal->j_work_sb = sb; 2858 journal->j_work_sb = sb;
@@ -2896,14 +2883,13 @@ int journal_transaction_should_end(struct reiserfs_transaction_handle *th,
2896 journal->j_cnode_free < (journal->j_trans_max * 3)) { 2883 journal->j_cnode_free < (journal->j_trans_max * 3)) {
2897 return 1; 2884 return 1;
2898 } 2885 }
2899 /* protected by the BKL here */ 2886
2900 journal->j_len_alloc += new_alloc; 2887 journal->j_len_alloc += new_alloc;
2901 th->t_blocks_allocated += new_alloc ; 2888 th->t_blocks_allocated += new_alloc ;
2902 return 0; 2889 return 0;
2903} 2890}
2904 2891
2905/* this must be called inside a transaction, and requires the 2892/* this must be called inside a transaction
2906** kernel_lock to be held
2907*/ 2893*/
2908void reiserfs_block_writes(struct reiserfs_transaction_handle *th) 2894void reiserfs_block_writes(struct reiserfs_transaction_handle *th)
2909{ 2895{
@@ -2914,8 +2900,7 @@ void reiserfs_block_writes(struct reiserfs_transaction_handle *th)
2914 return; 2900 return;
2915} 2901}
2916 2902
2917/* this must be called without a transaction started, and does not 2903/* this must be called without a transaction started
2918** require BKL
2919*/ 2904*/
2920void reiserfs_allow_writes(struct super_block *s) 2905void reiserfs_allow_writes(struct super_block *s)
2921{ 2906{
@@ -2924,8 +2909,7 @@ void reiserfs_allow_writes(struct super_block *s)
2924 wake_up(&journal->j_join_wait); 2909 wake_up(&journal->j_join_wait);
2925} 2910}
2926 2911
2927/* this must be called without a transaction started, and does not 2912/* this must be called without a transaction started
2928** require BKL
2929*/ 2913*/
2930void reiserfs_wait_on_write_block(struct super_block *s) 2914void reiserfs_wait_on_write_block(struct super_block *s)
2931{ 2915{
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 19c454e61b7..e12d8b97cd4 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -455,16 +455,20 @@ int remove_save_link(struct inode *inode, int truncate)
455static void reiserfs_kill_sb(struct super_block *s) 455static void reiserfs_kill_sb(struct super_block *s)
456{ 456{
457 if (REISERFS_SB(s)) { 457 if (REISERFS_SB(s)) {
458 if (REISERFS_SB(s)->xattr_root) { 458 /*
459 d_invalidate(REISERFS_SB(s)->xattr_root); 459 * Force any pending inode evictions to occur now. Any
460 dput(REISERFS_SB(s)->xattr_root); 460 * inodes to be removed that have extended attributes
461 REISERFS_SB(s)->xattr_root = NULL; 461 * associated with them need to clean them up before
462 } 462 * we can release the extended attribute root dentries.
463 if (REISERFS_SB(s)->priv_root) { 463 * shrink_dcache_for_umount will BUG if we don't release
464 d_invalidate(REISERFS_SB(s)->priv_root); 464 * those before it's called so ->put_super is too late.
465 dput(REISERFS_SB(s)->priv_root); 465 */
466 REISERFS_SB(s)->priv_root = NULL; 466 shrink_dcache_sb(s);
467 } 467
468 dput(REISERFS_SB(s)->xattr_root);
469 REISERFS_SB(s)->xattr_root = NULL;
470 dput(REISERFS_SB(s)->priv_root);
471 REISERFS_SB(s)->priv_root = NULL;
468 } 472 }
469 473
470 kill_block_super(s); 474 kill_block_super(s);
@@ -1249,7 +1253,8 @@ static void handle_quota_files(struct super_block *s, char **qf_names,
1249 kfree(REISERFS_SB(s)->s_qf_names[i]); 1253 kfree(REISERFS_SB(s)->s_qf_names[i]);
1250 REISERFS_SB(s)->s_qf_names[i] = qf_names[i]; 1254 REISERFS_SB(s)->s_qf_names[i] = qf_names[i];
1251 } 1255 }
1252 REISERFS_SB(s)->s_jquota_fmt = *qfmt; 1256 if (*qfmt)
1257 REISERFS_SB(s)->s_jquota_fmt = *qfmt;
1253} 1258}
1254#endif 1259#endif
1255 1260
@@ -1514,9 +1519,7 @@ static int read_super_block(struct super_block *s, int offset)
1514static int reread_meta_blocks(struct super_block *s) 1519static int reread_meta_blocks(struct super_block *s)
1515{ 1520{
1516 ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))); 1521 ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s)));
1517 reiserfs_write_unlock(s);
1518 wait_on_buffer(SB_BUFFER_WITH_SB(s)); 1522 wait_on_buffer(SB_BUFFER_WITH_SB(s));
1519 reiserfs_write_lock(s);
1520 if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) { 1523 if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
1521 reiserfs_warning(s, "reiserfs-2504", "error reading the super"); 1524 reiserfs_warning(s, "reiserfs-2504", "error reading the super");
1522 return 1; 1525 return 1;
@@ -1741,22 +1744,11 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1741 mutex_init(&REISERFS_SB(s)->lock); 1744 mutex_init(&REISERFS_SB(s)->lock);
1742 REISERFS_SB(s)->lock_depth = -1; 1745 REISERFS_SB(s)->lock_depth = -1;
1743 1746
1744 /*
1745 * This function is called with the bkl, which also was the old
1746 * locking used here.
1747 * do_journal_begin() will soon check if we hold the lock (ie: was the
1748 * bkl). This is likely because do_journal_begin() has several another
1749 * callers because at this time, it doesn't seem to be necessary to
1750 * protect against anything.
1751 * Anyway, let's be conservative and lock for now.
1752 */
1753 reiserfs_write_lock(s);
1754
1755 jdev_name = NULL; 1747 jdev_name = NULL;
1756 if (reiserfs_parse_options 1748 if (reiserfs_parse_options
1757 (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name, 1749 (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name,
1758 &commit_max_age, qf_names, &qfmt) == 0) { 1750 &commit_max_age, qf_names, &qfmt) == 0) {
1759 goto error; 1751 goto error_unlocked;
1760 } 1752 }
1761 if (jdev_name && jdev_name[0]) { 1753 if (jdev_name && jdev_name[0]) {
1762 REISERFS_SB(s)->s_jdev = kstrdup(jdev_name, GFP_KERNEL); 1754 REISERFS_SB(s)->s_jdev = kstrdup(jdev_name, GFP_KERNEL);
@@ -1772,7 +1764,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1772 1764
1773 if (blocks) { 1765 if (blocks) {
1774 SWARN(silent, s, "jmacd-7", "resize option for remount only"); 1766 SWARN(silent, s, "jmacd-7", "resize option for remount only");
1775 goto error; 1767 goto error_unlocked;
1776 } 1768 }
1777 1769
1778 /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */ 1770 /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
@@ -1782,7 +1774,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1782 else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) { 1774 else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
1783 SWARN(silent, s, "sh-2021", "can not find reiserfs on %s", 1775 SWARN(silent, s, "sh-2021", "can not find reiserfs on %s",
1784 reiserfs_bdevname(s)); 1776 reiserfs_bdevname(s));
1785 goto error; 1777 goto error_unlocked;
1786 } 1778 }
1787 1779
1788 rs = SB_DISK_SUPER_BLOCK(s); 1780 rs = SB_DISK_SUPER_BLOCK(s);
@@ -1798,7 +1790,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1798 "or increase size of your LVM partition"); 1790 "or increase size of your LVM partition");
1799 SWARN(silent, s, "", "Or may be you forgot to " 1791 SWARN(silent, s, "", "Or may be you forgot to "
1800 "reboot after fdisk when it told you to"); 1792 "reboot after fdisk when it told you to");
1801 goto error; 1793 goto error_unlocked;
1802 } 1794 }
1803 1795
1804 sbi->s_mount_state = SB_REISERFS_STATE(s); 1796 sbi->s_mount_state = SB_REISERFS_STATE(s);
@@ -1806,8 +1798,9 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1806 1798
1807 if ((errval = reiserfs_init_bitmap_cache(s))) { 1799 if ((errval = reiserfs_init_bitmap_cache(s))) {
1808 SWARN(silent, s, "jmacd-8", "unable to read bitmap"); 1800 SWARN(silent, s, "jmacd-8", "unable to read bitmap");
1809 goto error; 1801 goto error_unlocked;
1810 } 1802 }
1803
1811 errval = -EINVAL; 1804 errval = -EINVAL;
1812#ifdef CONFIG_REISERFS_CHECK 1805#ifdef CONFIG_REISERFS_CHECK
1813 SWARN(silent, s, "", "CONFIG_REISERFS_CHECK is set ON"); 1806 SWARN(silent, s, "", "CONFIG_REISERFS_CHECK is set ON");
@@ -1830,24 +1823,26 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1830 if (reiserfs_barrier_flush(s)) { 1823 if (reiserfs_barrier_flush(s)) {
1831 printk("reiserfs: using flush barriers\n"); 1824 printk("reiserfs: using flush barriers\n");
1832 } 1825 }
1826
1833 // set_device_ro(s->s_dev, 1) ; 1827 // set_device_ro(s->s_dev, 1) ;
1834 if (journal_init(s, jdev_name, old_format, commit_max_age)) { 1828 if (journal_init(s, jdev_name, old_format, commit_max_age)) {
1835 SWARN(silent, s, "sh-2022", 1829 SWARN(silent, s, "sh-2022",
1836 "unable to initialize journal space"); 1830 "unable to initialize journal space");
1837 goto error; 1831 goto error_unlocked;
1838 } else { 1832 } else {
1839 jinit_done = 1; /* once this is set, journal_release must be called 1833 jinit_done = 1; /* once this is set, journal_release must be called
1840 ** if we error out of the mount 1834 ** if we error out of the mount
1841 */ 1835 */
1842 } 1836 }
1837
1843 if (reread_meta_blocks(s)) { 1838 if (reread_meta_blocks(s)) {
1844 SWARN(silent, s, "jmacd-9", 1839 SWARN(silent, s, "jmacd-9",
1845 "unable to reread meta blocks after journal init"); 1840 "unable to reread meta blocks after journal init");
1846 goto error; 1841 goto error_unlocked;
1847 } 1842 }
1848 1843
1849 if (replay_only(s)) 1844 if (replay_only(s))
1850 goto error; 1845 goto error_unlocked;
1851 1846
1852 if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) { 1847 if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
1853 SWARN(silent, s, "clm-7000", 1848 SWARN(silent, s, "clm-7000",
@@ -1861,9 +1856,19 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1861 reiserfs_init_locked_inode, (void *)(&args)); 1856 reiserfs_init_locked_inode, (void *)(&args));
1862 if (!root_inode) { 1857 if (!root_inode) {
1863 SWARN(silent, s, "jmacd-10", "get root inode failed"); 1858 SWARN(silent, s, "jmacd-10", "get root inode failed");
1864 goto error; 1859 goto error_unlocked;
1865 } 1860 }
1866 1861
1862 /*
1863 * This path assumed to be called with the BKL in the old times.
1864 * Now we have inherited the big reiserfs lock from it and many
1865 * reiserfs helpers called in the mount path and elsewhere require
1866 * this lock to be held even if it's not always necessary. Let's be
1867 * conservative and hold it early. The window can be reduced after
1868 * careful review of the code.
1869 */
1870 reiserfs_write_lock(s);
1871
1867 if (root_inode->i_state & I_NEW) { 1872 if (root_inode->i_state & I_NEW) {
1868 reiserfs_read_locked_inode(root_inode, &args); 1873 reiserfs_read_locked_inode(root_inode, &args);
1869 unlock_new_inode(root_inode); 1874 unlock_new_inode(root_inode);
@@ -1990,12 +1995,16 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1990 return (0); 1995 return (0);
1991 1996
1992error: 1997error:
1993 if (jinit_done) { /* kill the commit thread, free journal ram */ 1998 reiserfs_write_unlock(s);
1999
2000error_unlocked:
2001 /* kill the commit thread, free journal ram */
2002 if (jinit_done) {
2003 reiserfs_write_lock(s);
1994 journal_release_error(NULL, s); 2004 journal_release_error(NULL, s);
2005 reiserfs_write_unlock(s);
1995 } 2006 }
1996 2007
1997 reiserfs_write_unlock(s);
1998
1999 reiserfs_free_bitmap_cache(s); 2008 reiserfs_free_bitmap_cache(s);
2000 if (SB_BUFFER_WITH_SB(s)) 2009 if (SB_BUFFER_WITH_SB(s))
2001 brelse(SB_BUFFER_WITH_SB(s)); 2010 brelse(SB_BUFFER_WITH_SB(s));