Commit 1d3382cb authored by Al Viro's avatar Al Viro

new helper: inode_unhashed()

note: for race-free uses you inode_lock held
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent a8dade34
...@@ -3849,7 +3849,7 @@ static void inode_tree_add(struct inode *inode) ...@@ -3849,7 +3849,7 @@ static void inode_tree_add(struct inode *inode)
p = &root->inode_tree.rb_node; p = &root->inode_tree.rb_node;
parent = NULL; parent = NULL;
if (hlist_unhashed(&inode->i_hash)) if (inode_unhashed(inode))
return; return;
spin_lock(&root->inode_lock); spin_lock(&root->inode_lock);
......
...@@ -962,7 +962,7 @@ void __mark_inode_dirty(struct inode *inode, int flags) ...@@ -962,7 +962,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
* dirty list. Add blockdev inodes as well. * dirty list. Add blockdev inodes as well.
*/ */
if (!S_ISBLK(inode->i_mode)) { if (!S_ISBLK(inode->i_mode)) {
if (hlist_unhashed(&inode->i_hash)) if (inode_unhashed(inode))
goto out; goto out;
} }
if (inode->i_state & I_FREEING) if (inode->i_state & I_FREEING)
......
...@@ -1094,7 +1094,7 @@ int insert_inode_locked(struct inode *inode) ...@@ -1094,7 +1094,7 @@ int insert_inode_locked(struct inode *inode)
__iget(old); __iget(old);
spin_unlock(&inode_lock); spin_unlock(&inode_lock);
wait_on_inode(old); wait_on_inode(old);
if (unlikely(!hlist_unhashed(&old->i_hash))) { if (unlikely(!inode_unhashed(old))) {
iput(old); iput(old);
return -EBUSY; return -EBUSY;
} }
...@@ -1133,7 +1133,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, ...@@ -1133,7 +1133,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
__iget(old); __iget(old);
spin_unlock(&inode_lock); spin_unlock(&inode_lock);
wait_on_inode(old); wait_on_inode(old);
if (unlikely(!hlist_unhashed(&old->i_hash))) { if (unlikely(!inode_unhashed(old))) {
iput(old); iput(old);
return -EBUSY; return -EBUSY;
} }
...@@ -1186,7 +1186,7 @@ EXPORT_SYMBOL(generic_delete_inode); ...@@ -1186,7 +1186,7 @@ EXPORT_SYMBOL(generic_delete_inode);
*/ */
int generic_drop_inode(struct inode *inode) int generic_drop_inode(struct inode *inode)
{ {
return !inode->i_nlink || hlist_unhashed(&inode->i_hash); return !inode->i_nlink || inode_unhashed(inode);
} }
EXPORT_SYMBOL_GPL(generic_drop_inode); EXPORT_SYMBOL_GPL(generic_drop_inode);
......
...@@ -422,7 +422,7 @@ int reiserfs_commit_write(struct file *f, struct page *page, ...@@ -422,7 +422,7 @@ int reiserfs_commit_write(struct file *f, struct page *page,
static void update_ctime(struct inode *inode) static void update_ctime(struct inode *inode)
{ {
struct timespec now = current_fs_time(inode->i_sb); struct timespec now = current_fs_time(inode->i_sb);
if (hlist_unhashed(&inode->i_hash) || !inode->i_nlink || if (inode_unhashed(inode) || !inode->i_nlink ||
timespec_equal(&inode->i_ctime, &now)) timespec_equal(&inode->i_ctime, &now))
return; return;
......
...@@ -786,6 +786,11 @@ struct inode { ...@@ -786,6 +786,11 @@ struct inode {
void *i_private; /* fs or device private pointer */ void *i_private; /* fs or device private pointer */
}; };
static inline int inode_unhashed(struct inode *inode)
{
return hlist_unhashed(&inode->i_hash);
}
/* /*
* inode->i_mutex nesting subclasses for the lock validator: * inode->i_mutex nesting subclasses for the lock validator:
* *
......
...@@ -2146,7 +2146,7 @@ static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len, ...@@ -2146,7 +2146,7 @@ static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
if (*len < 3) if (*len < 3)
return 255; return 255;
if (hlist_unhashed(&inode->i_hash)) { if (inode_unhashed(inode)) {
/* Unfortunately insert_inode_hash is not idempotent, /* Unfortunately insert_inode_hash is not idempotent,
* so as we hash inodes here rather than at creation * so as we hash inodes here rather than at creation
* time, we need a lock to ensure we only try * time, we need a lock to ensure we only try
...@@ -2154,7 +2154,7 @@ static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len, ...@@ -2154,7 +2154,7 @@ static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
*/ */
static DEFINE_SPINLOCK(lock); static DEFINE_SPINLOCK(lock);
spin_lock(&lock); spin_lock(&lock);
if (hlist_unhashed(&inode->i_hash)) if (inode_unhashed(inode))
__insert_inode_hash(inode, __insert_inode_hash(inode,
inode->i_ino + inode->i_generation); inode->i_ino + inode->i_generation);
spin_unlock(&lock); spin_unlock(&lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment