aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-10-23 07:15:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-10-25 21:26:10 -0400
commit646ec4615cd05972581c9c5342ed7a1e77df17bb (patch)
tree23c252d906f5356205b4d42c4ff9b4e6f70ebca2
parentf7899bd5472e8e99741369b4a32eca44e5282a85 (diff)
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>
-rw-r--r--fs/inode.c70
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c4
-rw-r--r--include/linux/fs.h5
3 files changed, 38 insertions, 41 deletions
diff --git a/fs/inode.c b/fs/inode.c
index 78c41c626cdc..430d70f2abe7 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -336,6 +336,28 @@ static void inode_lru_list_del(struct inode *inode)
336 } 336 }
337} 337}
338 338
339static 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 */
348void 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}
354EXPORT_SYMBOL_GPL(inode_sb_list_add);
355
356static inline void __inode_sb_list_del(struct inode *inode)
357{
358 list_del_init(&inode->i_sb_list);
359}
360
339static unsigned long hash(struct super_block *sb, unsigned long hashval) 361static unsigned long hash(struct super_block *sb, unsigned long hashval)
340{ 362{
341 unsigned long tmp; 363 unsigned long tmp;
@@ -356,9 +378,10 @@ static unsigned long hash(struct super_block *sb, unsigned long hashval)
356 */ 378 */
357void __insert_inode_hash(struct inode *inode, unsigned long hashval) 379void __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 spin_lock(&inode_lock); 383 spin_lock(&inode_lock);
361 hlist_add_head(&inode->i_hash, head); 384 hlist_add_head(&inode->i_hash, b);
362 spin_unlock(&inode_lock); 385 spin_unlock(&inode_lock);
363} 386}
364EXPORT_SYMBOL(__insert_inode_hash); 387EXPORT_SYMBOL(__insert_inode_hash);
@@ -436,7 +459,7 @@ static void dispose_list(struct list_head *head)
436 459
437 spin_lock(&inode_lock); 460 spin_lock(&inode_lock);
438 __remove_inode_hash(inode); 461 __remove_inode_hash(inode);
439 list_del_init(&inode->i_sb_list); 462 __inode_sb_list_del(inode);
440 spin_unlock(&inode_lock); 463 spin_unlock(&inode_lock);
441 464
442 wake_up_inode(inode); 465 wake_up_inode(inode);
@@ -685,37 +708,6 @@ repeat:
685 return NULL; 708 return NULL;
686} 709}
687 710
688static 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/**
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 */
709void 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}
717EXPORT_SYMBOL_GPL(inode_add_to_lists);
718
719/** 711/**
720 * new_inode - obtain an inode 712 * new_inode - obtain an inode
721 * @sb: superblock 713 * @sb: superblock
@@ -743,7 +735,7 @@ struct inode *new_inode(struct super_block *sb)
743 inode = alloc_inode(sb); 735 inode = alloc_inode(sb);
744 if (inode) { 736 if (inode) {
745 spin_lock(&inode_lock); 737 spin_lock(&inode_lock);
746 __inode_add_to_lists(sb, NULL, inode); 738 __inode_sb_list_add(inode);
747 inode->i_ino = ++last_ino; 739 inode->i_ino = ++last_ino;
748 inode->i_state = 0; 740 inode->i_state = 0;
749 spin_unlock(&inode_lock); 741 spin_unlock(&inode_lock);
@@ -812,7 +804,8 @@ static struct inode *get_new_inode(struct super_block *sb,
812 if (set(inode, data)) 804 if (set(inode, data))
813 goto set_failed; 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 inode->i_state = I_NEW; 809 inode->i_state = I_NEW;
817 spin_unlock(&inode_lock); 810 spin_unlock(&inode_lock);
818 811
@@ -858,7 +851,8 @@ static struct inode *get_new_inode_fast(struct super_block *sb,
858 old = find_inode_fast(sb, head, ino); 851 old = find_inode_fast(sb, head, ino);
859 if (!old) { 852 if (!old) {
860 inode->i_ino = ino; 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 inode->i_state = I_NEW; 856 inode->i_state = I_NEW;
863 spin_unlock(&inode_lock); 857 spin_unlock(&inode_lock);
864 858
@@ -1318,7 +1312,7 @@ static void iput_final(struct inode *inode)
1318 */ 1312 */
1319 inode_lru_list_del(inode); 1313 inode_lru_list_del(inode);
1320 1314
1321 list_del_init(&inode->i_sb_list); 1315 __inode_sb_list_del(inode);
1322 spin_unlock(&inode_lock); 1316 spin_unlock(&inode_lock);
1323 evict(inode); 1317 evict(inode);
1324 remove_inode_hash(inode); 1318 remove_inode_hash(inode);
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index ec858e09d546..71d83c93621c 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -760,7 +760,9 @@ xfs_setup_inode(
760 760
761 inode->i_ino = ip->i_ino; 761 inode->i_ino = ip->i_ino;
762 inode->i_state = I_NEW; 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 inode->i_mode = ip->i_d.di_mode; 767 inode->i_mode = ip->i_d.di_mode;
766 inode->i_nlink = ip->i_d.di_nlink; 768 inode->i_nlink = ip->i_d.di_nlink;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 876275fc0638..d43e8b6685a2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2171,7 +2171,6 @@ extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin);
2171 2171
2172extern int inode_init_always(struct super_block *, struct inode *); 2172extern int inode_init_always(struct super_block *, struct inode *);
2173extern void inode_init_once(struct inode *); 2173extern void inode_init_once(struct inode *);
2174extern void inode_add_to_lists(struct super_block *, struct inode *);
2175extern void iput(struct inode *); 2174extern void iput(struct inode *);
2176extern struct inode * igrab(struct inode *); 2175extern struct inode * igrab(struct inode *);
2177extern ino_t iunique(struct super_block *, ino_t); 2176extern ino_t iunique(struct super_block *, ino_t);
@@ -2202,9 +2201,11 @@ extern int file_remove_suid(struct file *);
2202 2201
2203extern void __insert_inode_hash(struct inode *, unsigned long hashval); 2202extern void __insert_inode_hash(struct inode *, unsigned long hashval);
2204extern void remove_inode_hash(struct inode *); 2203extern void remove_inode_hash(struct inode *);
2205static inline void insert_inode_hash(struct inode *inode) { 2204static inline void insert_inode_hash(struct inode *inode)
2205{
2206 __insert_inode_hash(inode, inode->i_ino); 2206 __insert_inode_hash(inode, inode->i_ino);
2207} 2207}
2208extern void inode_sb_list_add(struct inode *inode);
2208 2209
2209#ifdef CONFIG_BLOCK 2210#ifdef CONFIG_BLOCK
2210extern void submit_bio(int, struct bio *); 2211extern void submit_bio(int, struct bio *);