aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2009-05-13 14:13:40 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-06-06 06:17:26 -0400
commit72a43d63cb51057393edfbcfc4596066205ad15d (patch)
tree25b59cdaa08aabadc20100bd2a0c12b5feeaf520 /fs
parent460bcf57b128ce1c0dd553d905fedc097f9955c6 (diff)
ext3/4 with synchronous writes gets wedged by Postfix
OK, that's probably the easiest way to do that, as much as I don't like it... Since iget() et.al. will not accept I_FREEING (will wait to go away and restart), and since we'd better have serialization between new/free on fs data structures anyway, we can afford simply skipping I_FREEING et.al. in insert_inode_locked(). We do that from new_inode, so it won't race with free_inode in any interesting ways and it won't race with iget (of any origin; nfsd or in case of fs corruption a lookup) since both still will wait for I_LOCK. Reviewed-by: "Theodore Ts'o" <tytso@mit.edu> Acked-by: Jan Kara <jack@suse.cz> Tested-by: David Watson <dbwatson@ukfsn.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/inode.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/fs/inode.c b/fs/inode.c
index 0571983755dc..a4876e561953 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1053,13 +1053,22 @@ int insert_inode_locked(struct inode *inode)
1053 struct super_block *sb = inode->i_sb; 1053 struct super_block *sb = inode->i_sb;
1054 ino_t ino = inode->i_ino; 1054 ino_t ino = inode->i_ino;
1055 struct hlist_head *head = inode_hashtable + hash(sb, ino); 1055 struct hlist_head *head = inode_hashtable + hash(sb, ino);
1056 struct inode *old;
1057 1056
1058 inode->i_state |= I_LOCK|I_NEW; 1057 inode->i_state |= I_LOCK|I_NEW;
1059 while (1) { 1058 while (1) {
1059 struct hlist_node *node;
1060 struct inode *old = NULL;
1060 spin_lock(&inode_lock); 1061 spin_lock(&inode_lock);
1061 old = find_inode_fast(sb, head, ino); 1062 hlist_for_each_entry(old, node, head, i_hash) {
1062 if (likely(!old)) { 1063 if (old->i_ino != ino)
1064 continue;
1065 if (old->i_sb != sb)
1066 continue;
1067 if (old->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE))
1068 continue;
1069 break;
1070 }
1071 if (likely(!node)) {
1063 hlist_add_head(&inode->i_hash, head); 1072 hlist_add_head(&inode->i_hash, head);
1064 spin_unlock(&inode_lock); 1073 spin_unlock(&inode_lock);
1065 return 0; 1074 return 0;
@@ -1081,14 +1090,24 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
1081{ 1090{
1082 struct super_block *sb = inode->i_sb; 1091 struct super_block *sb = inode->i_sb;
1083 struct hlist_head *head = inode_hashtable + hash(sb, hashval); 1092 struct hlist_head *head = inode_hashtable + hash(sb, hashval);
1084 struct inode *old;
1085 1093
1086 inode->i_state |= I_LOCK|I_NEW; 1094 inode->i_state |= I_LOCK|I_NEW;
1087 1095
1088 while (1) { 1096 while (1) {
1097 struct hlist_node *node;
1098 struct inode *old = NULL;
1099
1089 spin_lock(&inode_lock); 1100 spin_lock(&inode_lock);
1090 old = find_inode(sb, head, test, data); 1101 hlist_for_each_entry(old, node, head, i_hash) {
1091 if (likely(!old)) { 1102 if (old->i_sb != sb)
1103 continue;
1104 if (!test(old, data))
1105 continue;
1106 if (old->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE))
1107 continue;
1108 break;
1109 }
1110 if (likely(!node)) {
1092 hlist_add_head(&inode->i_hash, head); 1111 hlist_add_head(&inode->i_hash, head);
1093 spin_unlock(&inode_lock); 1112 spin_unlock(&inode_lock);
1094 return 0; 1113 return 0;