summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2023-12-06 10:43:36 +1100
committerKent Overstreet <kent.overstreet@linux.dev>2024-02-15 22:08:37 -0500
commit2bff91319d294f43a67bd979a95501e34a134af4 (patch)
treeb529734f18465b37388dbc85c86a9ae975d0d6e7
parentd3738af0ae989f97743874acdb7d0e787a03e03b (diff)
vfs: Remove unnecessary list_for_each_entry_safe() variants
evict_inodes() and invalidate_inodes() use list_for_each_entry_safe() to iterate sb->s_inodes list. However, since we use i_lru list entry for our local temporary list of inodes to destroy, the inode is guaranteed to stay in sb->s_inodes list while we hold sb->s_inode_list_lock. So there is no real need for safe iteration variant and we can use list_for_each_entry() just fine. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Waiman Long <longman@redhat.com>
-rw-r--r--fs/inode.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/inode.c b/fs/inode.c
index 91048c4c9c9e..54587447eca4 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -711,12 +711,12 @@ static void dispose_list(struct list_head *head)
*/
void evict_inodes(struct super_block *sb)
{
- struct inode *inode, *next;
+ struct inode *inode;
LIST_HEAD(dispose);
again:
spin_lock(&sb->s_inode_list_lock);
- list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
+ list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
if (atomic_read(&inode->i_count))
continue;
@@ -757,12 +757,12 @@ EXPORT_SYMBOL_GPL(evict_inodes);
*/
void invalidate_inodes(struct super_block *sb)
{
- struct inode *inode, *next;
+ struct inode *inode;
LIST_HEAD(dispose);
again:
spin_lock(&sb->s_inode_list_lock);
- list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
+ list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
spin_lock(&inode->i_lock);
if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
spin_unlock(&inode->i_lock);