diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-02 14:17:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-02 14:17:05 -0500 |
commit | 45d28b097280a78893ce25a5d0db41e6a2717853 (patch) | |
tree | 0c2049700c5fca3fc9d73d2f347fab21e84765f8 /fs | |
parent | 4207a152bc242effd0b8231143aa5b9f7a1593a9 (diff) | |
parent | 835d5247d98f46e35d007dcfa6215e526ca33360 (diff) |
Merge branch 'reiserfs/kill-bkl' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing
* 'reiserfs/kill-bkl' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing:
reiserfs: Safely acquire i_mutex from xattr_rmdir
reiserfs: Safely acquire i_mutex from reiserfs_for_each_xattr
reiserfs: Fix journal mutex <-> inode mutex lock inversion
reiserfs: Fix unwanted recursive reiserfs lock in reiserfs_unlink()
reiserfs: Relax lock before open xattr dir in reiserfs_xattr_set_handle()
reiserfs: Relax reiserfs lock while freeing the journal
reiserfs: Fix reiserfs lock <-> i_mutex dependency inversion on xattr
reiserfs: Warn on lock relax if taken recursively
reiserfs: Fix reiserfs lock <-> i_xattr_sem dependency inversion
reiserfs: Fix remaining in-reclaim-fs <-> reclaim-fs-on locking inversion
reiserfs: Fix reiserfs lock <-> inode mutex dependency inversion
reiserfs: Fix reiserfs lock and journal lock inversion dependency
reiserfs: Fix possible recursive lock
Diffstat (limited to 'fs')
-rw-r--r-- | fs/reiserfs/bitmap.c | 3 | ||||
-rw-r--r-- | fs/reiserfs/inode.c | 5 | ||||
-rw-r--r-- | fs/reiserfs/journal.c | 18 | ||||
-rw-r--r-- | fs/reiserfs/lock.c | 9 | ||||
-rw-r--r-- | fs/reiserfs/namei.c | 7 | ||||
-rw-r--r-- | fs/reiserfs/xattr.c | 26 |
6 files changed, 53 insertions, 15 deletions
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c index 685495707181..65c872761177 100644 --- a/fs/reiserfs/bitmap.c +++ b/fs/reiserfs/bitmap.c | |||
@@ -1277,7 +1277,10 @@ int reiserfs_init_bitmap_cache(struct super_block *sb) | |||
1277 | struct reiserfs_bitmap_info *bitmap; | 1277 | struct reiserfs_bitmap_info *bitmap; |
1278 | unsigned int bmap_nr = reiserfs_bmap_count(sb); | 1278 | unsigned int bmap_nr = reiserfs_bmap_count(sb); |
1279 | 1279 | ||
1280 | /* Avoid lock recursion in fault case */ | ||
1281 | reiserfs_write_unlock(sb); | ||
1280 | bitmap = vmalloc(sizeof(*bitmap) * bmap_nr); | 1282 | bitmap = vmalloc(sizeof(*bitmap) * bmap_nr); |
1283 | reiserfs_write_lock(sb); | ||
1281 | if (bitmap == NULL) | 1284 | if (bitmap == NULL) |
1282 | return -ENOMEM; | 1285 | return -ENOMEM; |
1283 | 1286 | ||
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 290ae38fca8a..1150ebb2536f 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -31,11 +31,12 @@ void reiserfs_delete_inode(struct inode *inode) | |||
31 | JOURNAL_PER_BALANCE_CNT * 2 + | 31 | JOURNAL_PER_BALANCE_CNT * 2 + |
32 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb); | 32 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb); |
33 | struct reiserfs_transaction_handle th; | 33 | struct reiserfs_transaction_handle th; |
34 | int depth; | ||
34 | int err; | 35 | int err; |
35 | 36 | ||
36 | truncate_inode_pages(&inode->i_data, 0); | 37 | truncate_inode_pages(&inode->i_data, 0); |
37 | 38 | ||
38 | reiserfs_write_lock(inode->i_sb); | 39 | depth = reiserfs_write_lock_once(inode->i_sb); |
39 | 40 | ||
40 | /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ | 41 | /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ |
41 | if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */ | 42 | if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */ |
@@ -74,7 +75,7 @@ void reiserfs_delete_inode(struct inode *inode) | |||
74 | out: | 75 | out: |
75 | clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */ | 76 | clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */ |
76 | inode->i_blocks = 0; | 77 | inode->i_blocks = 0; |
77 | reiserfs_write_unlock(inode->i_sb); | 78 | reiserfs_write_unlock_once(inode->i_sb, depth); |
78 | } | 79 | } |
79 | 80 | ||
80 | static void _make_cpu_key(struct cpu_key *key, int version, __u32 dirid, | 81 | static void _make_cpu_key(struct cpu_key *key, int version, __u32 dirid, |
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 2f8a7e7b8dab..83ac4d3b3cb0 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -2009,10 +2009,11 @@ static int do_journal_release(struct reiserfs_transaction_handle *th, | |||
2009 | destroy_workqueue(commit_wq); | 2009 | destroy_workqueue(commit_wq); |
2010 | commit_wq = NULL; | 2010 | commit_wq = NULL; |
2011 | } | 2011 | } |
2012 | reiserfs_write_lock(sb); | ||
2013 | 2012 | ||
2014 | free_journal_ram(sb); | 2013 | free_journal_ram(sb); |
2015 | 2014 | ||
2015 | reiserfs_write_lock(sb); | ||
2016 | |||
2016 | return 0; | 2017 | return 0; |
2017 | } | 2018 | } |
2018 | 2019 | ||
@@ -2758,11 +2759,18 @@ int journal_init(struct super_block *sb, const char *j_dev_name, | |||
2758 | struct reiserfs_journal *journal; | 2759 | struct reiserfs_journal *journal; |
2759 | struct reiserfs_journal_list *jl; | 2760 | struct reiserfs_journal_list *jl; |
2760 | char b[BDEVNAME_SIZE]; | 2761 | char b[BDEVNAME_SIZE]; |
2762 | int ret; | ||
2761 | 2763 | ||
2764 | /* | ||
2765 | * Unlock here to avoid various RECLAIM-FS-ON <-> IN-RECLAIM-FS | ||
2766 | * dependency inversion warnings. | ||
2767 | */ | ||
2768 | reiserfs_write_unlock(sb); | ||
2762 | journal = SB_JOURNAL(sb) = vmalloc(sizeof(struct reiserfs_journal)); | 2769 | journal = SB_JOURNAL(sb) = vmalloc(sizeof(struct reiserfs_journal)); |
2763 | if (!journal) { | 2770 | if (!journal) { |
2764 | reiserfs_warning(sb, "journal-1256", | 2771 | reiserfs_warning(sb, "journal-1256", |
2765 | "unable to get memory for journal structure"); | 2772 | "unable to get memory for journal structure"); |
2773 | reiserfs_write_lock(sb); | ||
2766 | return 1; | 2774 | return 1; |
2767 | } | 2775 | } |
2768 | memset(journal, 0, sizeof(struct reiserfs_journal)); | 2776 | memset(journal, 0, sizeof(struct reiserfs_journal)); |
@@ -2771,10 +2779,12 @@ int journal_init(struct super_block *sb, const char *j_dev_name, | |||
2771 | INIT_LIST_HEAD(&journal->j_working_list); | 2779 | INIT_LIST_HEAD(&journal->j_working_list); |
2772 | INIT_LIST_HEAD(&journal->j_journal_list); | 2780 | INIT_LIST_HEAD(&journal->j_journal_list); |
2773 | journal->j_persistent_trans = 0; | 2781 | journal->j_persistent_trans = 0; |
2774 | if (reiserfs_allocate_list_bitmaps(sb, | 2782 | ret = reiserfs_allocate_list_bitmaps(sb, journal->j_list_bitmap, |
2775 | journal->j_list_bitmap, | 2783 | reiserfs_bmap_count(sb)); |
2776 | reiserfs_bmap_count(sb))) | 2784 | reiserfs_write_lock(sb); |
2785 | if (ret) | ||
2777 | goto free_and_return; | 2786 | goto free_and_return; |
2787 | |||
2778 | allocate_bitmap_nodes(sb); | 2788 | allocate_bitmap_nodes(sb); |
2779 | 2789 | ||
2780 | /* reserved for journal area support */ | 2790 | /* reserved for journal area support */ |
diff --git a/fs/reiserfs/lock.c b/fs/reiserfs/lock.c index ee2cfc0fd8a7..b87aa2c1afc1 100644 --- a/fs/reiserfs/lock.c +++ b/fs/reiserfs/lock.c | |||
@@ -86,3 +86,12 @@ void reiserfs_check_lock_depth(struct super_block *sb, char *caller) | |||
86 | reiserfs_panic(sb, "%s called without kernel lock held %d", | 86 | reiserfs_panic(sb, "%s called without kernel lock held %d", |
87 | caller); | 87 | caller); |
88 | } | 88 | } |
89 | |||
90 | #ifdef CONFIG_REISERFS_CHECK | ||
91 | void reiserfs_lock_check_recursive(struct super_block *sb) | ||
92 | { | ||
93 | struct reiserfs_sb_info *sb_i = REISERFS_SB(sb); | ||
94 | |||
95 | WARN_ONCE((sb_i->lock_depth > 0), "Unwanted recursive reiserfs lock!\n"); | ||
96 | } | ||
97 | #endif | ||
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index e296ff72a6cc..9d4dcf0b07cb 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c | |||
@@ -921,6 +921,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry) | |||
921 | struct reiserfs_transaction_handle th; | 921 | struct reiserfs_transaction_handle th; |
922 | int jbegin_count; | 922 | int jbegin_count; |
923 | unsigned long savelink; | 923 | unsigned long savelink; |
924 | int depth; | ||
924 | 925 | ||
925 | inode = dentry->d_inode; | 926 | inode = dentry->d_inode; |
926 | 927 | ||
@@ -932,7 +933,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry) | |||
932 | JOURNAL_PER_BALANCE_CNT * 2 + 2 + | 933 | JOURNAL_PER_BALANCE_CNT * 2 + 2 + |
933 | 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb); | 934 | 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb); |
934 | 935 | ||
935 | reiserfs_write_lock(dir->i_sb); | 936 | depth = reiserfs_write_lock_once(dir->i_sb); |
936 | retval = journal_begin(&th, dir->i_sb, jbegin_count); | 937 | retval = journal_begin(&th, dir->i_sb, jbegin_count); |
937 | if (retval) | 938 | if (retval) |
938 | goto out_unlink; | 939 | goto out_unlink; |
@@ -993,7 +994,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry) | |||
993 | 994 | ||
994 | retval = journal_end(&th, dir->i_sb, jbegin_count); | 995 | retval = journal_end(&th, dir->i_sb, jbegin_count); |
995 | reiserfs_check_path(&path); | 996 | reiserfs_check_path(&path); |
996 | reiserfs_write_unlock(dir->i_sb); | 997 | reiserfs_write_unlock_once(dir->i_sb, depth); |
997 | return retval; | 998 | return retval; |
998 | 999 | ||
999 | end_unlink: | 1000 | end_unlink: |
@@ -1003,7 +1004,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1003 | if (err) | 1004 | if (err) |
1004 | retval = err; | 1005 | retval = err; |
1005 | out_unlink: | 1006 | out_unlink: |
1006 | reiserfs_write_unlock(dir->i_sb); | 1007 | reiserfs_write_unlock_once(dir->i_sb, depth); |
1007 | return retval; | 1008 | return retval; |
1008 | } | 1009 | } |
1009 | 1010 | ||
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 8c7033a8b67e..c3b004ee627b 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -83,7 +83,8 @@ static int xattr_unlink(struct inode *dir, struct dentry *dentry) | |||
83 | BUG_ON(!mutex_is_locked(&dir->i_mutex)); | 83 | BUG_ON(!mutex_is_locked(&dir->i_mutex)); |
84 | vfs_dq_init(dir); | 84 | vfs_dq_init(dir); |
85 | 85 | ||
86 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); | 86 | reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex, |
87 | I_MUTEX_CHILD, dir->i_sb); | ||
87 | error = dir->i_op->unlink(dir, dentry); | 88 | error = dir->i_op->unlink(dir, dentry); |
88 | mutex_unlock(&dentry->d_inode->i_mutex); | 89 | mutex_unlock(&dentry->d_inode->i_mutex); |
89 | 90 | ||
@@ -98,7 +99,8 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry) | |||
98 | BUG_ON(!mutex_is_locked(&dir->i_mutex)); | 99 | BUG_ON(!mutex_is_locked(&dir->i_mutex)); |
99 | vfs_dq_init(dir); | 100 | vfs_dq_init(dir); |
100 | 101 | ||
101 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); | 102 | reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex, |
103 | I_MUTEX_CHILD, dir->i_sb); | ||
102 | dentry_unhash(dentry); | 104 | dentry_unhash(dentry); |
103 | error = dir->i_op->rmdir(dir, dentry); | 105 | error = dir->i_op->rmdir(dir, dentry); |
104 | if (!error) | 106 | if (!error) |
@@ -235,16 +237,22 @@ static int reiserfs_for_each_xattr(struct inode *inode, | |||
235 | if (IS_PRIVATE(inode) || get_inode_sd_version(inode) == STAT_DATA_V1) | 237 | if (IS_PRIVATE(inode) || get_inode_sd_version(inode) == STAT_DATA_V1) |
236 | return 0; | 238 | return 0; |
237 | 239 | ||
240 | reiserfs_write_unlock(inode->i_sb); | ||
238 | dir = open_xa_dir(inode, XATTR_REPLACE); | 241 | dir = open_xa_dir(inode, XATTR_REPLACE); |
239 | if (IS_ERR(dir)) { | 242 | if (IS_ERR(dir)) { |
240 | err = PTR_ERR(dir); | 243 | err = PTR_ERR(dir); |
244 | reiserfs_write_lock(inode->i_sb); | ||
241 | goto out; | 245 | goto out; |
242 | } else if (!dir->d_inode) { | 246 | } else if (!dir->d_inode) { |
243 | err = 0; | 247 | err = 0; |
248 | reiserfs_write_lock(inode->i_sb); | ||
244 | goto out_dir; | 249 | goto out_dir; |
245 | } | 250 | } |
246 | 251 | ||
247 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR); | 252 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR); |
253 | |||
254 | reiserfs_write_lock(inode->i_sb); | ||
255 | |||
248 | buf.xadir = dir; | 256 | buf.xadir = dir; |
249 | err = reiserfs_readdir_dentry(dir, &buf, fill_with_dentries, &pos); | 257 | err = reiserfs_readdir_dentry(dir, &buf, fill_with_dentries, &pos); |
250 | while ((err == 0 || err == -ENOSPC) && buf.count) { | 258 | while ((err == 0 || err == -ENOSPC) && buf.count) { |
@@ -283,8 +291,9 @@ static int reiserfs_for_each_xattr(struct inode *inode, | |||
283 | err = journal_begin(&th, inode->i_sb, blocks); | 291 | err = journal_begin(&th, inode->i_sb, blocks); |
284 | if (!err) { | 292 | if (!err) { |
285 | int jerror; | 293 | int jerror; |
286 | mutex_lock_nested(&dir->d_parent->d_inode->i_mutex, | 294 | reiserfs_mutex_lock_nested_safe( |
287 | I_MUTEX_XATTR); | 295 | &dir->d_parent->d_inode->i_mutex, |
296 | I_MUTEX_XATTR, inode->i_sb); | ||
288 | err = action(dir, data); | 297 | err = action(dir, data); |
289 | jerror = journal_end(&th, inode->i_sb, blocks); | 298 | jerror = journal_end(&th, inode->i_sb, blocks); |
290 | mutex_unlock(&dir->d_parent->d_inode->i_mutex); | 299 | mutex_unlock(&dir->d_parent->d_inode->i_mutex); |
@@ -480,11 +489,16 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th, | |||
480 | if (!buffer) | 489 | if (!buffer) |
481 | return lookup_and_delete_xattr(inode, name); | 490 | return lookup_and_delete_xattr(inode, name); |
482 | 491 | ||
492 | reiserfs_write_unlock(inode->i_sb); | ||
483 | dentry = xattr_lookup(inode, name, flags); | 493 | dentry = xattr_lookup(inode, name, flags); |
484 | if (IS_ERR(dentry)) | 494 | if (IS_ERR(dentry)) { |
495 | reiserfs_write_lock(inode->i_sb); | ||
485 | return PTR_ERR(dentry); | 496 | return PTR_ERR(dentry); |
497 | } | ||
486 | 498 | ||
487 | down_write(&REISERFS_I(inode)->i_xattr_sem); | 499 | down_read(&REISERFS_I(inode)->i_xattr_sem); |
500 | |||
501 | reiserfs_write_lock(inode->i_sb); | ||
488 | 502 | ||
489 | xahash = xattr_hash(buffer, buffer_size); | 503 | xahash = xattr_hash(buffer, buffer_size); |
490 | while (buffer_pos < buffer_size || buffer_pos == 0) { | 504 | while (buffer_pos < buffer_size || buffer_pos == 0) { |