diff options
| author | Christoph Hellwig <hch@lst.de> | 2010-10-23 07:15:32 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-10-25 21:26:10 -0400 |
| commit | 646ec4615cd05972581c9c5342ed7a1e77df17bb (patch) | |
| tree | 23c252d906f5356205b4d42c4ff9b4e6f70ebca2 /fs/inode.c | |
| parent | f7899bd5472e8e99741369b4a32eca44e5282a85 (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>
Diffstat (limited to 'fs/inode.c')
| -rw-r--r-- | fs/inode.c | 70 |
1 files changed, 32 insertions, 38 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 | ||
| 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 | static unsigned long hash(struct super_block *sb, unsigned long hashval) | 361 | static 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 | */ |
| 357 | void __insert_inode_hash(struct inode *inode, unsigned long hashval) | 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 | 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 | } |
| 364 | EXPORT_SYMBOL(__insert_inode_hash); | 387 | EXPORT_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 | ||
| 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 | /** | ||
| 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 | /** | 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); |
