diff options
author | Dave Chinner <dchinner@redhat.com> | 2011-03-22 07:23:40 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-03-24 21:16:32 -0400 |
commit | 55fa6091d83160ca772fc37cebae45d42695a708 (patch) | |
tree | 4df49f372032e30449e1a2dd64daf443e20b781c /fs/quota/dquot.c | |
parent | f283c86afe6aa70b733d1ecebad5d9464943b774 (diff) |
fs: move i_sb_list out from under inode_lock
Protect the per-sb inode list with a new global lock
inode_sb_list_lock and use it to protect the list manipulations and
traversals. This lock replaces the inode_lock as the inodes on the
list can be validity checked while holding the inode->i_lock and
hence the inode_lock is no longer needed to protect the list.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r-- | fs/quota/dquot.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index a1470fda366c..fcc8ae75d874 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -76,7 +76,7 @@ | |||
76 | #include <linux/buffer_head.h> | 76 | #include <linux/buffer_head.h> |
77 | #include <linux/capability.h> | 77 | #include <linux/capability.h> |
78 | #include <linux/quotaops.h> | 78 | #include <linux/quotaops.h> |
79 | #include <linux/writeback.h> /* for inode_lock, oddly enough.. */ | 79 | #include "../internal.h" /* ugh */ |
80 | 80 | ||
81 | #include <asm/uaccess.h> | 81 | #include <asm/uaccess.h> |
82 | 82 | ||
@@ -900,7 +900,7 @@ static void add_dquot_ref(struct super_block *sb, int type) | |||
900 | int reserved = 0; | 900 | int reserved = 0; |
901 | #endif | 901 | #endif |
902 | 902 | ||
903 | spin_lock(&inode_lock); | 903 | spin_lock(&inode_sb_list_lock); |
904 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 904 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
905 | spin_lock(&inode->i_lock); | 905 | spin_lock(&inode->i_lock); |
906 | if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || | 906 | if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || |
@@ -915,19 +915,23 @@ static void add_dquot_ref(struct super_block *sb, int type) | |||
915 | #endif | 915 | #endif |
916 | __iget(inode); | 916 | __iget(inode); |
917 | spin_unlock(&inode->i_lock); | 917 | spin_unlock(&inode->i_lock); |
918 | spin_unlock(&inode_lock); | 918 | spin_unlock(&inode_sb_list_lock); |
919 | 919 | ||
920 | iput(old_inode); | 920 | iput(old_inode); |
921 | __dquot_initialize(inode, type); | 921 | __dquot_initialize(inode, type); |
922 | /* We hold a reference to 'inode' so it couldn't have been | 922 | |
923 | * removed from s_inodes list while we dropped the inode_lock. | 923 | /* |
924 | * We cannot iput the inode now as we can be holding the last | 924 | * We hold a reference to 'inode' so it couldn't have been |
925 | * reference and we cannot iput it under inode_lock. So we | 925 | * removed from s_inodes list while we dropped the |
926 | * keep the reference and iput it later. */ | 926 | * inode_sb_list_lock We cannot iput the inode now as we can be |
927 | * holding the last reference and we cannot iput it under | ||
928 | * inode_sb_list_lock. So we keep the reference and iput it | ||
929 | * later. | ||
930 | */ | ||
927 | old_inode = inode; | 931 | old_inode = inode; |
928 | spin_lock(&inode_lock); | 932 | spin_lock(&inode_sb_list_lock); |
929 | } | 933 | } |
930 | spin_unlock(&inode_lock); | 934 | spin_unlock(&inode_sb_list_lock); |
931 | iput(old_inode); | 935 | iput(old_inode); |
932 | 936 | ||
933 | #ifdef CONFIG_QUOTA_DEBUG | 937 | #ifdef CONFIG_QUOTA_DEBUG |
@@ -1008,7 +1012,7 @@ static void remove_dquot_ref(struct super_block *sb, int type, | |||
1008 | struct inode *inode; | 1012 | struct inode *inode; |
1009 | int reserved = 0; | 1013 | int reserved = 0; |
1010 | 1014 | ||
1011 | spin_lock(&inode_lock); | 1015 | spin_lock(&inode_sb_list_lock); |
1012 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 1016 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
1013 | /* | 1017 | /* |
1014 | * We have to scan also I_NEW inodes because they can already | 1018 | * We have to scan also I_NEW inodes because they can already |
@@ -1022,7 +1026,7 @@ static void remove_dquot_ref(struct super_block *sb, int type, | |||
1022 | remove_inode_dquot_ref(inode, type, tofree_head); | 1026 | remove_inode_dquot_ref(inode, type, tofree_head); |
1023 | } | 1027 | } |
1024 | } | 1028 | } |
1025 | spin_unlock(&inode_lock); | 1029 | spin_unlock(&inode_sb_list_lock); |
1026 | #ifdef CONFIG_QUOTA_DEBUG | 1030 | #ifdef CONFIG_QUOTA_DEBUG |
1027 | if (reserved) { | 1031 | if (reserved) { |
1028 | printk(KERN_WARNING "VFS (%s): Writes happened after quota" | 1032 | printk(KERN_WARNING "VFS (%s): Writes happened after quota" |