diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-09-28 21:31:10 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-10-01 19:40:47 -0400 |
commit | 9ec9b917b3f6cf676226f074fdcdeceebe1a0b29 (patch) | |
tree | 7c71ca81faa20a1e44624f7489fae1264db8e269 /include/linux/fs.h | |
parent | 32cb8103ecfacdd5ed8e1eb390221c3f8339de6f (diff) |
vfs: use fast_list for superblock's inode listfast_list
Use the new fast_list for super_block.s_inodes.
This gives similar performance to Dave's dlock list approach [1]; lock
contention is now moved to the lru_list locks.
Iteration is now fully lockless - instead we iterate using
rcu_read_lock(), which means we must take care for racing with removal.
Generally this is already handled - code that iterates over s_inodes
takes i_lock and checks i_state, skipping inodes that are
I_WILL_FREE|I_FREEING. However, code may also check for nonzero
i_sb_list_idx if it wishes to iterate over precisely the inodes that are
on the s_inodes list.
[1]: https://lore.kernel.org/linux-fsdevel/20231206060629.2827226-4-david@fromorbit.com/
Cc: Christian Brauner <brauner@kernel.org>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Waiman Long <longman@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index e3c603d01337..755ff1f15baa 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -45,6 +45,7 @@ #include <linux/slab.h> #include <linux/maple_tree.h> #include <linux/rw_hint.h> +#include <linux/fast_list.h> #include <asm/byteorder.h> #include <uapi/linux/fs.h> @@ -700,7 +701,6 @@ struct inode { u16 i_wb_frn_history; #endif struct list_head i_lru; /* inode LRU list */ - struct list_head i_sb_list; struct list_head i_wb_list; /* backing dev writeback list */ union { struct hlist_head i_dentry; @@ -714,6 +714,7 @@ struct inode { #if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING) atomic_t i_readcount; /* struct files open RO */ #endif + unsigned i_sb_list_idx; union { const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ void (*free_inode)(struct inode *); @@ -1384,9 +1385,7 @@ struct super_block { */ int s_stack_depth; - /* s_inode_list_lock protects s_inodes */ - spinlock_t s_inode_list_lock ____cacheline_aligned_in_smp; - struct list_head s_inodes; /* all inodes */ + struct fast_list s_inodes; /* all inodes */ spinlock_t s_inode_wblist_lock; struct list_head s_inodes_wb; /* writeback inodes */ |