3434 * inode->i_state, inode->i_hash, __iget()
3535 * inode_lru_lock protects:
3636 * inode_lru, inode->i_lru
37+ * inode_sb_list_lock protects:
38+ * sb->s_inodes, inode->i_sb_list
3739 *
3840 * Lock ordering:
3941 * inode_lock
4042 * inode->i_lock
43+ *
44+ * inode_sb_list_lock
45+ * inode->i_lock
4146 * inode_lru_lock
4247 */
4348
@@ -99,6 +104,8 @@ static struct hlist_head *inode_hashtable __read_mostly;
99104 */
100105DEFINE_SPINLOCK (inode_lock );
101106
107+ __cacheline_aligned_in_smp DEFINE_SPINLOCK (inode_sb_list_lock );
108+
102109/*
103110 * iprune_sem provides exclusion between the icache shrinking and the
104111 * umount path.
@@ -378,26 +385,23 @@ static void inode_lru_list_del(struct inode *inode)
378385 spin_unlock (& inode_lru_lock );
379386}
380387
381- static inline void __inode_sb_list_add (struct inode * inode )
382- {
383- list_add (& inode -> i_sb_list , & inode -> i_sb -> s_inodes );
384- }
385-
386388/**
387389 * inode_sb_list_add - add inode to the superblock list of inodes
388390 * @inode: inode to add
389391 */
390392void inode_sb_list_add (struct inode * inode )
391393{
392- spin_lock (& inode_lock );
393- __inode_sb_list_add ( inode );
394- spin_unlock (& inode_lock );
394+ spin_lock (& inode_sb_list_lock );
395+ list_add ( & inode -> i_sb_list , & inode -> i_sb -> s_inodes );
396+ spin_unlock (& inode_sb_list_lock );
395397}
396398EXPORT_SYMBOL_GPL (inode_sb_list_add );
397399
398- static inline void __inode_sb_list_del (struct inode * inode )
400+ static inline void inode_sb_list_del (struct inode * inode )
399401{
402+ spin_lock (& inode_sb_list_lock );
400403 list_del_init (& inode -> i_sb_list );
404+ spin_unlock (& inode_sb_list_lock );
401405}
402406
403407static unsigned long hash (struct super_block * sb , unsigned long hashval )
@@ -481,9 +485,10 @@ static void evict(struct inode *inode)
481485
482486 spin_lock (& inode_lock );
483487 list_del_init (& inode -> i_wb_list );
484- __inode_sb_list_del (inode );
485488 spin_unlock (& inode_lock );
486489
490+ inode_sb_list_del (inode );
491+
487492 if (op -> evict_inode ) {
488493 op -> evict_inode (inode );
489494 } else {
@@ -539,7 +544,7 @@ void evict_inodes(struct super_block *sb)
539544 struct inode * inode , * next ;
540545 LIST_HEAD (dispose );
541546
542- spin_lock (& inode_lock );
547+ spin_lock (& inode_sb_list_lock );
543548 list_for_each_entry_safe (inode , next , & sb -> s_inodes , i_sb_list ) {
544549 if (atomic_read (& inode -> i_count ))
545550 continue ;
@@ -555,7 +560,7 @@ void evict_inodes(struct super_block *sb)
555560 spin_unlock (& inode -> i_lock );
556561 list_add (& inode -> i_lru , & dispose );
557562 }
558- spin_unlock (& inode_lock );
563+ spin_unlock (& inode_sb_list_lock );
559564
560565 dispose_list (& dispose );
561566
@@ -584,7 +589,7 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty)
584589 struct inode * inode , * next ;
585590 LIST_HEAD (dispose );
586591
587- spin_lock (& inode_lock );
592+ spin_lock (& inode_sb_list_lock );
588593 list_for_each_entry_safe (inode , next , & sb -> s_inodes , i_sb_list ) {
589594 spin_lock (& inode -> i_lock );
590595 if (inode -> i_state & (I_NEW | I_FREEING | I_WILL_FREE )) {
@@ -607,7 +612,7 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty)
607612 spin_unlock (& inode -> i_lock );
608613 list_add (& inode -> i_lru , & dispose );
609614 }
610- spin_unlock (& inode_lock );
615+ spin_unlock (& inode_sb_list_lock );
611616
612617 dispose_list (& dispose );
613618
@@ -867,16 +872,14 @@ struct inode *new_inode(struct super_block *sb)
867872{
868873 struct inode * inode ;
869874
870- spin_lock_prefetch (& inode_lock );
875+ spin_lock_prefetch (& inode_sb_list_lock );
871876
872877 inode = alloc_inode (sb );
873878 if (inode ) {
874- spin_lock (& inode_lock );
875879 spin_lock (& inode -> i_lock );
876880 inode -> i_state = 0 ;
877881 spin_unlock (& inode -> i_lock );
878- __inode_sb_list_add (inode );
879- spin_unlock (& inode_lock );
882+ inode_sb_list_add (inode );
880883 }
881884 return inode ;
882885}
@@ -945,7 +948,7 @@ static struct inode *get_new_inode(struct super_block *sb,
945948 inode -> i_state = I_NEW ;
946949 hlist_add_head (& inode -> i_hash , head );
947950 spin_unlock (& inode -> i_lock );
948- __inode_sb_list_add (inode );
951+ inode_sb_list_add (inode );
949952 spin_unlock (& inode_lock );
950953
951954 /* Return the locked inode with I_NEW set, the
@@ -994,7 +997,7 @@ static struct inode *get_new_inode_fast(struct super_block *sb,
994997 inode -> i_state = I_NEW ;
995998 hlist_add_head (& inode -> i_hash , head );
996999 spin_unlock (& inode -> i_lock );
997- __inode_sb_list_add (inode );
1000+ inode_sb_list_add (inode );
9981001 spin_unlock (& inode_lock );
9991002
10001003 /* Return the locked inode with I_NEW set, the
0 commit comments