list.h: new helper - hlist_add_fake()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 23 Oct 2010 19:23:40 +0000 (15:23 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 26 Oct 2010 01:24:15 +0000 (21:24 -0400)
Make node look as if it was on hlist, with hlist_del()
working correctly.  Usable without any locking...

Convert a couple of places where we want to do that to
inode->i_hash.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/hfsplus/inode.c
fs/jfs/jfs_imap.c
include/linux/list.h

index 7844928..8afd7e8 100644 (file)
@@ -211,7 +211,7 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
         * appear hashed, but do not put on any lists.  hlist_del()
         * will work fine and require no locking.
         */
-       inode->i_hash.pprev = &inode->i_hash.next;
+       hlist_add_fake(&inode->i_hash);
 
        mark_inode_dirty(inode);
 out:
index f8332dc..3a09423 100644 (file)
@@ -497,7 +497,7 @@ struct inode *diReadSpecial(struct super_block *sb, ino_t inum, int secondary)
         * appear hashed, but do not put on any lists.  hlist_del()
         * will work fine and require no locking.
         */
-       ip->i_hash.pprev = &ip->i_hash.next;
+       hlist_add_fake(&ip->i_hash);
 
        return (ip);
 }
index 88a0006..9a5f8a7 100644 (file)
@@ -636,6 +636,12 @@ static inline void hlist_add_after(struct hlist_node *n,
                next->next->pprev  = &next->next;
 }
 
+/* after that we'll appear to be on some hlist and hlist_del will work */
+static inline void hlist_add_fake(struct hlist_node *n)
+{
+       n->pprev = &n->next;
+}
+
 /*
  * Move a list from one list head to another. Fixup the pprev
  * reference of the first entry if it exists.