aboutsummaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/fs/inode.c b/fs/inode.c
index 4d8e3be55976..03dfeb2e3928 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -18,7 +18,6 @@
18#include <linux/hash.h> 18#include <linux/hash.h>
19#include <linux/swap.h> 19#include <linux/swap.h>
20#include <linux/security.h> 20#include <linux/security.h>
21#include <linux/ima.h>
22#include <linux/pagemap.h> 21#include <linux/pagemap.h>
23#include <linux/cdev.h> 22#include <linux/cdev.h>
24#include <linux/bootmem.h> 23#include <linux/bootmem.h>
@@ -114,7 +113,7 @@ static void wake_up_inode(struct inode *inode)
114 * Prevent speculative execution through spin_unlock(&inode_lock); 113 * Prevent speculative execution through spin_unlock(&inode_lock);
115 */ 114 */
116 smp_mb(); 115 smp_mb();
117 wake_up_bit(&inode->i_state, __I_LOCK); 116 wake_up_bit(&inode->i_state, __I_NEW);
118} 117}
119 118
120/** 119/**
@@ -157,11 +156,6 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
157 156
158 if (security_inode_alloc(inode)) 157 if (security_inode_alloc(inode))
159 goto out; 158 goto out;
160
161 /* allocate and initialize an i_integrity */
162 if (ima_inode_alloc(inode))
163 goto out_free_security;
164
165 spin_lock_init(&inode->i_lock); 159 spin_lock_init(&inode->i_lock);
166 lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key); 160 lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key);
167 161
@@ -201,9 +195,6 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
201#endif 195#endif
202 196
203 return 0; 197 return 0;
204
205out_free_security:
206 security_inode_free(inode);
207out: 198out:
208 return -ENOMEM; 199 return -ENOMEM;
209} 200}
@@ -235,7 +226,6 @@ static struct inode *alloc_inode(struct super_block *sb)
235void __destroy_inode(struct inode *inode) 226void __destroy_inode(struct inode *inode)
236{ 227{
237 BUG_ON(inode_has_buffers(inode)); 228 BUG_ON(inode_has_buffers(inode));
238 ima_inode_free(inode);
239 security_inode_free(inode); 229 security_inode_free(inode);
240 fsnotify_inode_delete(inode); 230 fsnotify_inode_delete(inode);
241#ifdef CONFIG_FS_POSIX_ACL 231#ifdef CONFIG_FS_POSIX_ACL
@@ -700,17 +690,17 @@ void unlock_new_inode(struct inode *inode)
700 } 690 }
701#endif 691#endif
702 /* 692 /*
703 * This is special! We do not need the spinlock when clearing I_LOCK, 693 * This is special! We do not need the spinlock when clearing I_NEW,
704 * because we're guaranteed that nobody else tries to do anything about 694 * because we're guaranteed that nobody else tries to do anything about
705 * the state of the inode when it is locked, as we just created it (so 695 * the state of the inode when it is locked, as we just created it (so
706 * there can be no old holders that haven't tested I_LOCK). 696 * there can be no old holders that haven't tested I_NEW).
707 * However we must emit the memory barrier so that other CPUs reliably 697 * However we must emit the memory barrier so that other CPUs reliably
708 * see the clearing of I_LOCK after the other inode initialisation has 698 * see the clearing of I_NEW after the other inode initialisation has
709 * completed. 699 * completed.
710 */ 700 */
711 smp_mb(); 701 smp_mb();
712 WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW)); 702 WARN_ON(!(inode->i_state & I_NEW));
713 inode->i_state &= ~(I_LOCK|I_NEW); 703 inode->i_state &= ~I_NEW;
714 wake_up_inode(inode); 704 wake_up_inode(inode);
715} 705}
716EXPORT_SYMBOL(unlock_new_inode); 706EXPORT_SYMBOL(unlock_new_inode);
@@ -741,7 +731,7 @@ static struct inode *get_new_inode(struct super_block *sb,
741 goto set_failed; 731 goto set_failed;
742 732
743 __inode_add_to_lists(sb, head, inode); 733 __inode_add_to_lists(sb, head, inode);
744 inode->i_state = I_LOCK|I_NEW; 734 inode->i_state = I_NEW;
745 spin_unlock(&inode_lock); 735 spin_unlock(&inode_lock);
746 736
747 /* Return the locked inode with I_NEW set, the 737 /* Return the locked inode with I_NEW set, the
@@ -788,7 +778,7 @@ static struct inode *get_new_inode_fast(struct super_block *sb,
788 if (!old) { 778 if (!old) {
789 inode->i_ino = ino; 779 inode->i_ino = ino;
790 __inode_add_to_lists(sb, head, inode); 780 __inode_add_to_lists(sb, head, inode);
791 inode->i_state = I_LOCK|I_NEW; 781 inode->i_state = I_NEW;
792 spin_unlock(&inode_lock); 782 spin_unlock(&inode_lock);
793 783
794 /* Return the locked inode with I_NEW set, the 784 /* Return the locked inode with I_NEW set, the
@@ -1093,7 +1083,7 @@ int insert_inode_locked(struct inode *inode)
1093 ino_t ino = inode->i_ino; 1083 ino_t ino = inode->i_ino;
1094 struct hlist_head *head = inode_hashtable + hash(sb, ino); 1084 struct hlist_head *head = inode_hashtable + hash(sb, ino);
1095 1085
1096 inode->i_state |= I_LOCK|I_NEW; 1086 inode->i_state |= I_NEW;
1097 while (1) { 1087 while (1) {
1098 struct hlist_node *node; 1088 struct hlist_node *node;
1099 struct inode *old = NULL; 1089 struct inode *old = NULL;
@@ -1130,7 +1120,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
1130 struct super_block *sb = inode->i_sb; 1120 struct super_block *sb = inode->i_sb;
1131 struct hlist_head *head = inode_hashtable + hash(sb, hashval); 1121 struct hlist_head *head = inode_hashtable + hash(sb, hashval);
1132 1122
1133 inode->i_state |= I_LOCK|I_NEW; 1123 inode->i_state |= I_NEW;
1134 1124
1135 while (1) { 1125 while (1) {
1136 struct hlist_node *node; 1126 struct hlist_node *node;
@@ -1520,7 +1510,7 @@ EXPORT_SYMBOL(inode_wait);
1520 * until the deletion _might_ have completed. Callers are responsible 1510 * until the deletion _might_ have completed. Callers are responsible
1521 * to recheck inode state. 1511 * to recheck inode state.
1522 * 1512 *
1523 * It doesn't matter if I_LOCK is not set initially, a call to 1513 * It doesn't matter if I_NEW is not set initially, a call to
1524 * wake_up_inode() after removing from the hash list will DTRT. 1514 * wake_up_inode() after removing from the hash list will DTRT.
1525 * 1515 *
1526 * This is called with inode_lock held. 1516 * This is called with inode_lock held.
@@ -1528,8 +1518,8 @@ EXPORT_SYMBOL(inode_wait);
1528static void __wait_on_freeing_inode(struct inode *inode) 1518static void __wait_on_freeing_inode(struct inode *inode)
1529{ 1519{
1530 wait_queue_head_t *wq; 1520 wait_queue_head_t *wq;
1531 DEFINE_WAIT_BIT(wait, &inode->i_state, __I_LOCK); 1521 DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW);
1532 wq = bit_waitqueue(&inode->i_state, __I_LOCK); 1522 wq = bit_waitqueue(&inode->i_state, __I_NEW);
1533 prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE); 1523 prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
1534 spin_unlock(&inode_lock); 1524 spin_unlock(&inode_lock);
1535 schedule(); 1525 schedule();