]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/inode.c
openvswitch: drop unneeded BUG_ON() in ovs_flow_cmd_build_info()
[mirror_ubuntu-bionic-kernel.git] / fs / inode.c
index 9975b38edb32c5d2b9833ee8dc5f7997dcf73666..b7841b4f2bd05b1b86c10cf2aed70b4b64e2797b 100644 (file)
@@ -800,10 +800,6 @@ repeat:
                        __wait_on_freeing_inode(inode);
                        goto repeat;
                }
-               if (unlikely(inode->i_state & I_CREATING)) {
-                       spin_unlock(&inode->i_lock);
-                       return ERR_PTR(-ESTALE);
-               }
                __iget(inode);
                spin_unlock(&inode->i_lock);
                return inode;
@@ -831,10 +827,6 @@ repeat:
                        __wait_on_freeing_inode(inode);
                        goto repeat;
                }
-               if (unlikely(inode->i_state & I_CREATING)) {
-                       spin_unlock(&inode->i_lock);
-                       return ERR_PTR(-ESTALE);
-               }
                __iget(inode);
                spin_unlock(&inode->i_lock);
                return inode;
@@ -961,18 +953,6 @@ EXPORT_SYMBOL(lockdep_annotate_inode_mutex_key);
  * inode and wake up anyone waiting for the inode to finish initialisation.
  */
 void unlock_new_inode(struct inode *inode)
-{
-       lockdep_annotate_inode_mutex_key(inode);
-       spin_lock(&inode->i_lock);
-       WARN_ON(!(inode->i_state & I_NEW));
-       inode->i_state &= ~I_NEW & ~I_CREATING;
-       smp_mb();
-       wake_up_bit(&inode->i_state, __I_NEW);
-       spin_unlock(&inode->i_lock);
-}
-EXPORT_SYMBOL(unlock_new_inode);
-
-void discard_new_inode(struct inode *inode)
 {
        lockdep_annotate_inode_mutex_key(inode);
        spin_lock(&inode->i_lock);
@@ -981,9 +961,8 @@ void discard_new_inode(struct inode *inode)
        smp_mb();
        wake_up_bit(&inode->i_state, __I_NEW);
        spin_unlock(&inode->i_lock);
-       iput(inode);
 }
-EXPORT_SYMBOL(discard_new_inode);
+EXPORT_SYMBOL(unlock_new_inode);
 
 /**
  * lock_two_nondirectories - take two i_mutexes on non-directory objects
@@ -1129,8 +1108,6 @@ again:
        inode = find_inode_fast(sb, head, ino);
        spin_unlock(&inode_hash_lock);
        if (inode) {
-               if (IS_ERR(inode))
-                       return NULL;
                wait_on_inode(inode);
                if (unlikely(inode_unhashed(inode))) {
                        iput(inode);
@@ -1168,8 +1145,6 @@ again:
                 */
                spin_unlock(&inode_hash_lock);
                destroy_inode(inode);
-               if (IS_ERR(old))
-                       return NULL;
                inode = old;
                wait_on_inode(inode);
                if (unlikely(inode_unhashed(inode))) {
@@ -1287,7 +1262,7 @@ struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval,
        inode = find_inode(sb, head, test, data);
        spin_unlock(&inode_hash_lock);
 
-       return IS_ERR(inode) ? NULL : inode;
+       return inode;
 }
 EXPORT_SYMBOL(ilookup5_nowait);
 
@@ -1315,8 +1290,6 @@ struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
 again:
        inode = ilookup5_nowait(sb, hashval, test, data);
        if (inode) {
-               if (IS_ERR(inode))
-                       return NULL;
                wait_on_inode(inode);
                if (unlikely(inode_unhashed(inode))) {
                        iput(inode);
@@ -1428,17 +1401,12 @@ int insert_inode_locked(struct inode *inode)
                }
                if (likely(!old)) {
                        spin_lock(&inode->i_lock);
-                       inode->i_state |= I_NEW | I_CREATING;
+                       inode->i_state |= I_NEW;
                        hlist_add_head(&inode->i_hash, head);
                        spin_unlock(&inode->i_lock);
                        spin_unlock(&inode_hash_lock);
                        return 0;
                }
-               if (unlikely(old->i_state & I_CREATING)) {
-                       spin_unlock(&old->i_lock);
-                       spin_unlock(&inode_hash_lock);
-                       return -EBUSY;
-               }
                __iget(old);
                spin_unlock(&old->i_lock);
                spin_unlock(&inode_hash_lock);
@@ -1458,8 +1426,6 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
        struct super_block *sb = inode->i_sb;
        struct hlist_head *head = inode_hashtable + hash(sb, hashval);
 
-       inode->i_state |= I_CREATING;
-
        while (1) {
                struct inode *old = NULL;
 
@@ -1478,17 +1444,12 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
                }
                if (likely(!old)) {
                        spin_lock(&inode->i_lock);
-                       inode->i_state |= I_NEW | I_CREATING;
+                       inode->i_state |= I_NEW;
                        hlist_add_head(&inode->i_hash, head);
                        spin_unlock(&inode->i_lock);
                        spin_unlock(&inode_hash_lock);
                        return 0;
                }
-               if (unlikely(old->i_state & I_CREATING)) {
-                       spin_unlock(&old->i_lock);
-                       spin_unlock(&inode_hash_lock);
-                       return -EBUSY;
-               }
                __iget(old);
                spin_unlock(&old->i_lock);
                spin_unlock(&inode_hash_lock);
@@ -1859,8 +1820,13 @@ int file_remove_privs(struct file *file)
        int kill;
        int error = 0;
 
-       /* Fast path for nothing security related */
-       if (IS_NOSEC(inode))
+       /*
+        * Fast path for nothing security related.
+        * As well for non-regular files, e.g. blkdev inodes.
+        * For example, blkdev_write_iter() might get here
+        * trying to remove privs which it is not allowed to.
+        */
+       if (IS_NOSEC(inode) || !S_ISREG(inode->i_mode))
                return 0;
 
        kill = dentry_needs_remove_privs(dentry);