]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
vfs: Remove invalidate_inodes()
authorJan Kara <jack@suse.cz>
Fri, 7 Mar 2025 14:43:19 +0000 (15:43 +0100)
committerChristian Brauner <brauner@kernel.org>
Sat, 8 Mar 2025 11:19:22 +0000 (12:19 +0100)
The function can be replaced by evict_inodes. The only difference is
that evict_inodes() skips the inodes with positive refcount without
touching ->i_lock, but they are equivalent as evict_inodes() repeats the
refcount check after having grabbed ->i_lock.

Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20250307144318.28120-2-jack@suse.cz
Signed-off-by: Christian Brauner <brauner@kernel.org>
Documentation/filesystems/porting.rst
fs/inode.c
fs/internal.h
fs/smb/client/file.c
fs/super.c
security/landlock/fs.c

index 1639e78e314696527d62794d00d73c13f7850f97..12a71ba221b83af20e04a5f3153a9b680ce6ede4 100644 (file)
@@ -1157,3 +1157,8 @@ in normal case it points into the pathname being looked up.
 NOTE: if you need something like full path from the root of filesystem,
 you are still on your own - this assists with simple cases, but it's not
 magic.
+
+---
+
+** mandatory **
+invalidate_inodes() is gone use evict_inodes() instead.
index 0cd2304150971f63fffff6ab87e846a72d3eabb2..10121fc7b87e44d61768d53290fd32a92873f798 100644 (file)
@@ -910,46 +910,6 @@ again:
 }
 EXPORT_SYMBOL_GPL(evict_inodes);
 
-/**
- * invalidate_inodes   - attempt to free all inodes on a superblock
- * @sb:                superblock to operate on
- *
- * Attempts to free all inodes (including dirty inodes) for a given superblock.
- */
-void invalidate_inodes(struct super_block *sb)
-{
-       struct inode *inode, *next;
-       LIST_HEAD(dispose);
-
-again:
-       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)) {
-                       spin_unlock(&inode->i_lock);
-                       continue;
-               }
-               if (atomic_read(&inode->i_count)) {
-                       spin_unlock(&inode->i_lock);
-                       continue;
-               }
-
-               inode->i_state |= I_FREEING;
-               inode_lru_list_del(inode);
-               spin_unlock(&inode->i_lock);
-               list_add(&inode->i_lru, &dispose);
-               if (need_resched()) {
-                       spin_unlock(&sb->s_inode_list_lock);
-                       cond_resched();
-                       dispose_list(&dispose);
-                       goto again;
-               }
-       }
-       spin_unlock(&sb->s_inode_list_lock);
-
-       dispose_list(&dispose);
-}
-
 /*
  * Isolate the inode from the LRU in preparation for freeing it.
  *
index 1cb85a62c07fe87390430a5878ee017a7f7fa8e0..82127c69e641aff8b37a36cb13da6746ece4a806 100644 (file)
@@ -207,7 +207,6 @@ bool in_group_or_capable(struct mnt_idmap *idmap,
  * fs-writeback.c
  */
 extern long get_nr_dirty_inodes(void);
-void invalidate_inodes(struct super_block *sb);
 
 /*
  * dcache.c
index 79de2f2f9c41a3d46595b3897ea46840c242819b..63cb6dc88e605494333124dc81f9cbebc6764826 100644 (file)
@@ -387,7 +387,7 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon)
        spin_unlock(&tcon->tc_lock);
 
        /*
-        * BB Add call to invalidate_inodes(sb) for all superblocks mounted
+        * BB Add call to evict_inodes(sb) for all superblocks mounted
         * to this tcon.
         */
 }
index 5a7db4a556e37323ab89b5e9f5ec7d323c3d029d..5b38d2d922525a321153fcf993b20914c5f2a1b4 100644 (file)
@@ -1417,7 +1417,7 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise)
        if (!surprise)
                sync_filesystem(sb);
        shrink_dcache_sb(sb);
-       invalidate_inodes(sb);
+       evict_inodes(sb);
        if (sb->s_op->shutdown)
                sb->s_op->shutdown(sb);
 
index 71b9dc331aae87825826256e0f7c6f171dbeee47..582769ae830eadc9d2b86be5e8fa86758381dac6 100644 (file)
@@ -1216,7 +1216,7 @@ static void hook_inode_free_security_rcu(void *inode_security)
 /*
  * Release the inodes used in a security policy.
  *
- * Cf. fsnotify_unmount_inodes() and invalidate_inodes()
+ * Cf. fsnotify_unmount_inodes() and evict_inodes()
  */
 static void hook_sb_delete(struct super_block *const sb)
 {