mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
inode: convert inode_sb_list_lock to per-sb
The process of reducing contention on per-superblock inode lists starts with moving the locking to match the per-superblock inode list. This takes the global lock out of the picture and reduces the contention problems to within a single filesystem. This doesn't get rid of contention as the locks still have global CPU scope, but it does isolate operations on different superblocks form each other. Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Josef Bacik <jbacik@fb.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Christoph Hellwig <hch@lst.de> Tested-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
parent
cbedaac634
commit
74278da9f7
10 changed files with 57 additions and 54 deletions
28
fs/inode.c
28
fs/inode.c
|
@ -28,8 +28,8 @@
|
|||
* inode->i_state, inode->i_hash, __iget()
|
||||
* Inode LRU list locks protect:
|
||||
* inode->i_sb->s_inode_lru, inode->i_lru
|
||||
* inode_sb_list_lock protects:
|
||||
* sb->s_inodes, inode->i_sb_list
|
||||
* inode->i_sb->s_inode_list_lock protects:
|
||||
* inode->i_sb->s_inodes, inode->i_sb_list
|
||||
* bdi->wb.list_lock protects:
|
||||
* bdi->wb.b_{dirty,io,more_io,dirty_time}, inode->i_wb_list
|
||||
* inode_hash_lock protects:
|
||||
|
@ -37,7 +37,7 @@
|
|||
*
|
||||
* Lock ordering:
|
||||
*
|
||||
* inode_sb_list_lock
|
||||
* inode->i_sb->s_inode_list_lock
|
||||
* inode->i_lock
|
||||
* Inode LRU list locks
|
||||
*
|
||||
|
@ -45,7 +45,7 @@
|
|||
* inode->i_lock
|
||||
*
|
||||
* inode_hash_lock
|
||||
* inode_sb_list_lock
|
||||
* inode->i_sb->s_inode_list_lock
|
||||
* inode->i_lock
|
||||
*
|
||||
* iunique_lock
|
||||
|
@ -57,8 +57,6 @@ static unsigned int i_hash_shift __read_mostly;
|
|||
static struct hlist_head *inode_hashtable __read_mostly;
|
||||
static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock);
|
||||
|
||||
__cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_sb_list_lock);
|
||||
|
||||
/*
|
||||
* Empty aops. Can be used for the cases where the user does not
|
||||
* define any of the address_space operations.
|
||||
|
@ -426,18 +424,18 @@ static void inode_lru_list_del(struct inode *inode)
|
|||
*/
|
||||
void inode_sb_list_add(struct inode *inode)
|
||||
{
|
||||
spin_lock(&inode_sb_list_lock);
|
||||
spin_lock(&inode->i_sb->s_inode_list_lock);
|
||||
list_add(&inode->i_sb_list, &inode->i_sb->s_inodes);
|
||||
spin_unlock(&inode_sb_list_lock);
|
||||
spin_unlock(&inode->i_sb->s_inode_list_lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(inode_sb_list_add);
|
||||
|
||||
static inline void inode_sb_list_del(struct inode *inode)
|
||||
{
|
||||
if (!list_empty(&inode->i_sb_list)) {
|
||||
spin_lock(&inode_sb_list_lock);
|
||||
spin_lock(&inode->i_sb->s_inode_list_lock);
|
||||
list_del_init(&inode->i_sb_list);
|
||||
spin_unlock(&inode_sb_list_lock);
|
||||
spin_unlock(&inode->i_sb->s_inode_list_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,7 +592,7 @@ void evict_inodes(struct super_block *sb)
|
|||
struct inode *inode, *next;
|
||||
LIST_HEAD(dispose);
|
||||
|
||||
spin_lock(&inode_sb_list_lock);
|
||||
spin_lock(&sb->s_inode_list_lock);
|
||||
list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
|
||||
if (atomic_read(&inode->i_count))
|
||||
continue;
|
||||
|
@ -610,7 +608,7 @@ void evict_inodes(struct super_block *sb)
|
|||
spin_unlock(&inode->i_lock);
|
||||
list_add(&inode->i_lru, &dispose);
|
||||
}
|
||||
spin_unlock(&inode_sb_list_lock);
|
||||
spin_unlock(&sb->s_inode_list_lock);
|
||||
|
||||
dispose_list(&dispose);
|
||||
}
|
||||
|
@ -631,7 +629,7 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty)
|
|||
struct inode *inode, *next;
|
||||
LIST_HEAD(dispose);
|
||||
|
||||
spin_lock(&inode_sb_list_lock);
|
||||
spin_lock(&sb->s_inode_list_lock);
|
||||
list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
|
||||
spin_lock(&inode->i_lock);
|
||||
if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
|
||||
|
@ -654,7 +652,7 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty)
|
|||
spin_unlock(&inode->i_lock);
|
||||
list_add(&inode->i_lru, &dispose);
|
||||
}
|
||||
spin_unlock(&inode_sb_list_lock);
|
||||
spin_unlock(&sb->s_inode_list_lock);
|
||||
|
||||
dispose_list(&dispose);
|
||||
|
||||
|
@ -890,7 +888,7 @@ struct inode *new_inode(struct super_block *sb)
|
|||
{
|
||||
struct inode *inode;
|
||||
|
||||
spin_lock_prefetch(&inode_sb_list_lock);
|
||||
spin_lock_prefetch(&sb->s_inode_list_lock);
|
||||
|
||||
inode = new_inode_pseudo(sb);
|
||||
if (inode)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue