Commit 646ec4615cd05972581c9c5342ed7a1e77df17bb
Committed by
Al Viro
1 parent
f7899bd547
Exists in
master
and in
4 other branches
fs: remove inode_add_to_list/__inode_add_to_list
Split up inode_add_to_list/__inode_add_to_list. Locking for the two lists will be split soon so these helpers really don't buy us much anymore. The __ prefixes for the sb list helpers will go away soon, but until inode_lock is gone we'll need them to distinguish between the locked and unlocked variants. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 3 changed files with 38 additions and 41 deletions Side-by-side Diff
fs/inode.c
... | ... | @@ -336,6 +336,28 @@ |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | +static inline void __inode_sb_list_add(struct inode *inode) | |
340 | +{ | |
341 | + list_add(&inode->i_sb_list, &inode->i_sb->s_inodes); | |
342 | +} | |
343 | + | |
344 | +/** | |
345 | + * inode_sb_list_add - add inode to the superblock list of inodes | |
346 | + * @inode: inode to add | |
347 | + */ | |
348 | +void inode_sb_list_add(struct inode *inode) | |
349 | +{ | |
350 | + spin_lock(&inode_lock); | |
351 | + __inode_sb_list_add(inode); | |
352 | + spin_unlock(&inode_lock); | |
353 | +} | |
354 | +EXPORT_SYMBOL_GPL(inode_sb_list_add); | |
355 | + | |
356 | +static inline void __inode_sb_list_del(struct inode *inode) | |
357 | +{ | |
358 | + list_del_init(&inode->i_sb_list); | |
359 | +} | |
360 | + | |
339 | 361 | static unsigned long hash(struct super_block *sb, unsigned long hashval) |
340 | 362 | { |
341 | 363 | unsigned long tmp; |
342 | 364 | |
... | ... | @@ -356,9 +378,10 @@ |
356 | 378 | */ |
357 | 379 | void __insert_inode_hash(struct inode *inode, unsigned long hashval) |
358 | 380 | { |
359 | - struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); | |
381 | + struct hlist_head *b = inode_hashtable + hash(inode->i_sb, hashval); | |
382 | + | |
360 | 383 | spin_lock(&inode_lock); |
361 | - hlist_add_head(&inode->i_hash, head); | |
384 | + hlist_add_head(&inode->i_hash, b); | |
362 | 385 | spin_unlock(&inode_lock); |
363 | 386 | } |
364 | 387 | EXPORT_SYMBOL(__insert_inode_hash); |
... | ... | @@ -436,7 +459,7 @@ |
436 | 459 | |
437 | 460 | spin_lock(&inode_lock); |
438 | 461 | __remove_inode_hash(inode); |
439 | - list_del_init(&inode->i_sb_list); | |
462 | + __inode_sb_list_del(inode); | |
440 | 463 | spin_unlock(&inode_lock); |
441 | 464 | |
442 | 465 | wake_up_inode(inode); |
443 | 466 | |
... | ... | @@ -685,38 +708,7 @@ |
685 | 708 | return NULL; |
686 | 709 | } |
687 | 710 | |
688 | -static inline void | |
689 | -__inode_add_to_lists(struct super_block *sb, struct hlist_head *head, | |
690 | - struct inode *inode) | |
691 | -{ | |
692 | - list_add(&inode->i_sb_list, &sb->s_inodes); | |
693 | - if (head) | |
694 | - hlist_add_head(&inode->i_hash, head); | |
695 | -} | |
696 | - | |
697 | 711 | /** |
698 | - * inode_add_to_lists - add a new inode to relevant lists | |
699 | - * @sb: superblock inode belongs to | |
700 | - * @inode: inode to mark in use | |
701 | - * | |
702 | - * When an inode is allocated it needs to be accounted for, added to the in use | |
703 | - * list, the owning superblock and the inode hash. This needs to be done under | |
704 | - * the inode_lock, so export a function to do this rather than the inode lock | |
705 | - * itself. We calculate the hash list to add to here so it is all internal | |
706 | - * which requires the caller to have already set up the inode number in the | |
707 | - * inode to add. | |
708 | - */ | |
709 | -void inode_add_to_lists(struct super_block *sb, struct inode *inode) | |
710 | -{ | |
711 | - struct hlist_head *head = inode_hashtable + hash(sb, inode->i_ino); | |
712 | - | |
713 | - spin_lock(&inode_lock); | |
714 | - __inode_add_to_lists(sb, head, inode); | |
715 | - spin_unlock(&inode_lock); | |
716 | -} | |
717 | -EXPORT_SYMBOL_GPL(inode_add_to_lists); | |
718 | - | |
719 | -/** | |
720 | 712 | * new_inode - obtain an inode |
721 | 713 | * @sb: superblock |
722 | 714 | * |
... | ... | @@ -743,7 +735,7 @@ |
743 | 735 | inode = alloc_inode(sb); |
744 | 736 | if (inode) { |
745 | 737 | spin_lock(&inode_lock); |
746 | - __inode_add_to_lists(sb, NULL, inode); | |
738 | + __inode_sb_list_add(inode); | |
747 | 739 | inode->i_ino = ++last_ino; |
748 | 740 | inode->i_state = 0; |
749 | 741 | spin_unlock(&inode_lock); |
... | ... | @@ -812,7 +804,8 @@ |
812 | 804 | if (set(inode, data)) |
813 | 805 | goto set_failed; |
814 | 806 | |
815 | - __inode_add_to_lists(sb, head, inode); | |
807 | + hlist_add_head(&inode->i_hash, head); | |
808 | + __inode_sb_list_add(inode); | |
816 | 809 | inode->i_state = I_NEW; |
817 | 810 | spin_unlock(&inode_lock); |
818 | 811 | |
... | ... | @@ -858,7 +851,8 @@ |
858 | 851 | old = find_inode_fast(sb, head, ino); |
859 | 852 | if (!old) { |
860 | 853 | inode->i_ino = ino; |
861 | - __inode_add_to_lists(sb, head, inode); | |
854 | + hlist_add_head(&inode->i_hash, head); | |
855 | + __inode_sb_list_add(inode); | |
862 | 856 | inode->i_state = I_NEW; |
863 | 857 | spin_unlock(&inode_lock); |
864 | 858 | |
... | ... | @@ -1318,7 +1312,7 @@ |
1318 | 1312 | */ |
1319 | 1313 | inode_lru_list_del(inode); |
1320 | 1314 | |
1321 | - list_del_init(&inode->i_sb_list); | |
1315 | + __inode_sb_list_del(inode); | |
1322 | 1316 | spin_unlock(&inode_lock); |
1323 | 1317 | evict(inode); |
1324 | 1318 | remove_inode_hash(inode); |
fs/xfs/linux-2.6/xfs_iops.c
... | ... | @@ -760,7 +760,9 @@ |
760 | 760 | |
761 | 761 | inode->i_ino = ip->i_ino; |
762 | 762 | inode->i_state = I_NEW; |
763 | - inode_add_to_lists(ip->i_mount->m_super, inode); | |
763 | + | |
764 | + inode_sb_list_add(inode); | |
765 | + insert_inode_hash(inode); | |
764 | 766 | |
765 | 767 | inode->i_mode = ip->i_d.di_mode; |
766 | 768 | inode->i_nlink = ip->i_d.di_nlink; |
include/linux/fs.h
... | ... | @@ -2171,7 +2171,6 @@ |
2171 | 2171 | |
2172 | 2172 | extern int inode_init_always(struct super_block *, struct inode *); |
2173 | 2173 | extern void inode_init_once(struct inode *); |
2174 | -extern void inode_add_to_lists(struct super_block *, struct inode *); | |
2175 | 2174 | extern void iput(struct inode *); |
2176 | 2175 | extern struct inode * igrab(struct inode *); |
2177 | 2176 | extern ino_t iunique(struct super_block *, ino_t); |
2178 | 2177 | |
... | ... | @@ -2202,9 +2201,11 @@ |
2202 | 2201 | |
2203 | 2202 | extern void __insert_inode_hash(struct inode *, unsigned long hashval); |
2204 | 2203 | extern void remove_inode_hash(struct inode *); |
2205 | -static inline void insert_inode_hash(struct inode *inode) { | |
2204 | +static inline void insert_inode_hash(struct inode *inode) | |
2205 | +{ | |
2206 | 2206 | __insert_inode_hash(inode, inode->i_ino); |
2207 | 2207 | } |
2208 | +extern void inode_sb_list_add(struct inode *inode); | |
2208 | 2209 | |
2209 | 2210 | #ifdef CONFIG_BLOCK |
2210 | 2211 | extern void submit_bio(int, struct bio *); |