Commit 756acc2d61712a8cafe2aa6ad626c60a185d3645

Authored by Al Viro
1 parent 1d3382cbf0

list.h: new helper - hlist_add_fake()

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>

Showing 3 changed files with 8 additions and 2 deletions Side-by-side Diff

... ... @@ -211,7 +211,7 @@
211 211 * appear hashed, but do not put on any lists. hlist_del()
212 212 * will work fine and require no locking.
213 213 */
214   - inode->i_hash.pprev = &inode->i_hash.next;
  214 + hlist_add_fake(&inode->i_hash);
215 215  
216 216 mark_inode_dirty(inode);
217 217 out:
... ... @@ -497,7 +497,7 @@
497 497 * appear hashed, but do not put on any lists. hlist_del()
498 498 * will work fine and require no locking.
499 499 */
500   - ip->i_hash.pprev = &ip->i_hash.next;
  500 + hlist_add_fake(&ip->i_hash);
501 501  
502 502 return (ip);
503 503 }
include/linux/list.h
... ... @@ -636,6 +636,12 @@
636 636 next->next->pprev = &next->next;
637 637 }
638 638  
  639 +/* after that we'll appear to be on some hlist and hlist_del will work */
  640 +static inline void hlist_add_fake(struct hlist_node *n)
  641 +{
  642 + n->pprev = &n->next;
  643 +}
  644 +
639 645 /*
640 646 * Move a list from one list head to another. Fixup the pprev
641 647 * reference of the first entry if it exists.