__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;
__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;
* 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);
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
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);
*/
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))) {
inode = find_inode(sb, head, test, data);
spin_unlock(&inode_hash_lock);
- return IS_ERR(inode) ? NULL : inode;
+ return inode;
}
EXPORT_SYMBOL(ilookup5_nowait);
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);
}
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);
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;
}
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);
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);