aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2010-10-23 15:19:20 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-10-25 21:24:15 -0400
commit1d3382cbf02986e4833849f528d451367ea0b4cb (patch)
treeb754f9903c0f77ce40dcff18030b49d0ce213eab
parenta8dade34e3df581bc36ca2afe6e27055e178801c (diff)
new helper: inode_unhashed()
note: for race-free uses you inode_lock held Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/btrfs/inode.c2
-rw-r--r--fs/fs-writeback.c2
-rw-r--r--fs/inode.c6
-rw-r--r--fs/reiserfs/xattr.c2
-rw-r--r--include/linux/fs.h5
-rw-r--r--mm/shmem.c4
6 files changed, 13 insertions, 8 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c03864406af3..f6f2a0da2695 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3849,7 +3849,7 @@ again:
3849 p = &root->inode_tree.rb_node; 3849 p = &root->inode_tree.rb_node;
3850 parent = NULL; 3850 parent = NULL;
3851 3851
3852 if (hlist_unhashed(&inode->i_hash)) 3852 if (inode_unhashed(inode))
3853 return; 3853 return;
3854 3854
3855 spin_lock(&root->inode_lock); 3855 spin_lock(&root->inode_lock);
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 29e3f409bbd0..39f44f2e709a 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -962,7 +962,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
962 * dirty list. Add blockdev inodes as well. 962 * dirty list. Add blockdev inodes as well.
963 */ 963 */
964 if (!S_ISBLK(inode->i_mode)) { 964 if (!S_ISBLK(inode->i_mode)) {
965 if (hlist_unhashed(&inode->i_hash)) 965 if (inode_unhashed(inode))
966 goto out; 966 goto out;
967 } 967 }
968 if (inode->i_state & I_FREEING) 968 if (inode->i_state & I_FREEING)
diff --git a/fs/inode.c b/fs/inode.c
index db7c74c7dd80..4440cf1034ec 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1094,7 +1094,7 @@ int insert_inode_locked(struct inode *inode)
1094 __iget(old); 1094 __iget(old);
1095 spin_unlock(&inode_lock); 1095 spin_unlock(&inode_lock);
1096 wait_on_inode(old); 1096 wait_on_inode(old);
1097 if (unlikely(!hlist_unhashed(&old->i_hash))) { 1097 if (unlikely(!inode_unhashed(old))) {
1098 iput(old); 1098 iput(old);
1099 return -EBUSY; 1099 return -EBUSY;
1100 } 1100 }
@@ -1133,7 +1133,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
1133 __iget(old); 1133 __iget(old);
1134 spin_unlock(&inode_lock); 1134 spin_unlock(&inode_lock);
1135 wait_on_inode(old); 1135 wait_on_inode(old);
1136 if (unlikely(!hlist_unhashed(&old->i_hash))) { 1136 if (unlikely(!inode_unhashed(old))) {
1137 iput(old); 1137 iput(old);
1138 return -EBUSY; 1138 return -EBUSY;
1139 } 1139 }
@@ -1186,7 +1186,7 @@ EXPORT_SYMBOL(generic_delete_inode);
1186 */ 1186 */
1187int generic_drop_inode(struct inode *inode) 1187int generic_drop_inode(struct inode *inode)
1188{ 1188{
1189 return !inode->i_nlink || hlist_unhashed(&inode->i_hash); 1189 return !inode->i_nlink || inode_unhashed(inode);
1190} 1190}
1191EXPORT_SYMBOL_GPL(generic_drop_inode); 1191EXPORT_SYMBOL_GPL(generic_drop_inode);
1192 1192
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index f7415de13878..5d04a7828e7a 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -422,7 +422,7 @@ int reiserfs_commit_write(struct file *f, struct page *page,
422static void update_ctime(struct inode *inode) 422static void update_ctime(struct inode *inode)
423{ 423{
424 struct timespec now = current_fs_time(inode->i_sb); 424 struct timespec now = current_fs_time(inode->i_sb);
425 if (hlist_unhashed(&inode->i_hash) || !inode->i_nlink || 425 if (inode_unhashed(inode) || !inode->i_nlink ||
426 timespec_equal(&inode->i_ctime, &now)) 426 timespec_equal(&inode->i_ctime, &now))
427 return; 427 return;
428 428
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c3f6daf749cc..78043da85e1f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -786,6 +786,11 @@ struct inode {
786 void *i_private; /* fs or device private pointer */ 786 void *i_private; /* fs or device private pointer */
787}; 787};
788 788
789static inline int inode_unhashed(struct inode *inode)
790{
791 return hlist_unhashed(&inode->i_hash);
792}
793
789/* 794/*
790 * inode->i_mutex nesting subclasses for the lock validator: 795 * inode->i_mutex nesting subclasses for the lock validator:
791 * 796 *
diff --git a/mm/shmem.c b/mm/shmem.c
index 080b09a57a8f..27a58120dbd5 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2146,7 +2146,7 @@ static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
2146 if (*len < 3) 2146 if (*len < 3)
2147 return 255; 2147 return 255;
2148 2148
2149 if (hlist_unhashed(&inode->i_hash)) { 2149 if (inode_unhashed(inode)) {
2150 /* Unfortunately insert_inode_hash is not idempotent, 2150 /* Unfortunately insert_inode_hash is not idempotent,
2151 * so as we hash inodes here rather than at creation 2151 * so as we hash inodes here rather than at creation
2152 * time, we need a lock to ensure we only try 2152 * 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 */ 2154 */
2155 static DEFINE_SPINLOCK(lock); 2155 static DEFINE_SPINLOCK(lock);
2156 spin_lock(&lock); 2156 spin_lock(&lock);
2157 if (hlist_unhashed(&inode->i_hash)) 2157 if (inode_unhashed(inode))
2158 __insert_inode_hash(inode, 2158 __insert_inode_hash(inode,
2159 inode->i_ino + inode->i_generation); 2159 inode->i_ino + inode->i_generation);
2160 spin_unlock(&lock); 2160 spin_unlock(&lock);