diff options
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r-- | fs/quota/dquot.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index a2a622e079f0..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,33 +900,38 @@ 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 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) | 905 | spin_lock(&inode->i_lock); |
906 | if ((inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) || | ||
907 | !atomic_read(&inode->i_writecount) || | ||
908 | !dqinit_needed(inode, type)) { | ||
909 | spin_unlock(&inode->i_lock); | ||
906 | continue; | 910 | continue; |
911 | } | ||
907 | #ifdef CONFIG_QUOTA_DEBUG | 912 | #ifdef CONFIG_QUOTA_DEBUG |
908 | if (unlikely(inode_get_rsv_space(inode) > 0)) | 913 | if (unlikely(inode_get_rsv_space(inode) > 0)) |
909 | reserved = 1; | 914 | reserved = 1; |
910 | #endif | 915 | #endif |
911 | if (!atomic_read(&inode->i_writecount)) | ||
912 | continue; | ||
913 | if (!dqinit_needed(inode, type)) | ||
914 | continue; | ||
915 | |||
916 | __iget(inode); | 916 | __iget(inode); |
917 | spin_unlock(&inode_lock); | 917 | spin_unlock(&inode->i_lock); |
918 | spin_unlock(&inode_sb_list_lock); | ||
918 | 919 | ||
919 | iput(old_inode); | 920 | iput(old_inode); |
920 | __dquot_initialize(inode, type); | 921 | __dquot_initialize(inode, type); |
921 | /* We hold a reference to 'inode' so it couldn't have been | 922 | |
922 | * removed from s_inodes list while we dropped the inode_lock. | 923 | /* |
923 | * 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 |
924 | * reference and we cannot iput it under inode_lock. So we | 925 | * removed from s_inodes list while we dropped the |
925 | * 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 | */ | ||
926 | old_inode = inode; | 931 | old_inode = inode; |
927 | spin_lock(&inode_lock); | 932 | spin_lock(&inode_sb_list_lock); |
928 | } | 933 | } |
929 | spin_unlock(&inode_lock); | 934 | spin_unlock(&inode_sb_list_lock); |
930 | iput(old_inode); | 935 | iput(old_inode); |
931 | 936 | ||
932 | #ifdef CONFIG_QUOTA_DEBUG | 937 | #ifdef CONFIG_QUOTA_DEBUG |
@@ -1007,7 +1012,7 @@ static void remove_dquot_ref(struct super_block *sb, int type, | |||
1007 | struct inode *inode; | 1012 | struct inode *inode; |
1008 | int reserved = 0; | 1013 | int reserved = 0; |
1009 | 1014 | ||
1010 | spin_lock(&inode_lock); | 1015 | spin_lock(&inode_sb_list_lock); |
1011 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 1016 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
1012 | /* | 1017 | /* |
1013 | * 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 |
@@ -1021,7 +1026,7 @@ static void remove_dquot_ref(struct super_block *sb, int type, | |||
1021 | remove_inode_dquot_ref(inode, type, tofree_head); | 1026 | remove_inode_dquot_ref(inode, type, tofree_head); |
1022 | } | 1027 | } |
1023 | } | 1028 | } |
1024 | spin_unlock(&inode_lock); | 1029 | spin_unlock(&inode_sb_list_lock); |
1025 | #ifdef CONFIG_QUOTA_DEBUG | 1030 | #ifdef CONFIG_QUOTA_DEBUG |
1026 | if (reserved) { | 1031 | if (reserved) { |
1027 | printk(KERN_WARNING "VFS (%s): Writes happened after quota" | 1032 | printk(KERN_WARNING "VFS (%s): Writes happened after quota" |