[PATCH 0/3] vfs: add inode iteration method super_iter_inodes
flat view
COOLING4d
From: Huang Shijie <hidden>
Date: 2026-10-15 09:40:35
Also in:
gfs2, linux-block, linux-fsdevel, lkml
This series adds a single superblock inode iteration helper, super_iter_inodes(), and converts the open-coded sb->s_inodes walks in the VFS to it. The design is based on Dave Chinner's patch set: "vfs: improving inode cache iteration scalability" https://lore.kernel.org/all/20241002014017.3801899-1-david@fromorbit.com/ (local) The helper takes a callback, a private data pointer and flags: int super_iter_inodes(struct super_block *sb, ino_iter_fn iter_fn, void *private_data, int flags); - Without a flag, @iter_fn runs with a valid, referenced inode and may block; the iterator owns the inode lifecycle and filters out I_NEW/I_FREEING/I_WILL_FREE inodes. - %INO_ITER_F_REFERENCED additionally restricts the iteration to inodes that still have a reference. This preserves the "only handle referenced inodes" rule of landlock's sb-delete walk. - %INO_ITER_F_UNSAFE runs @iter_fn in atomic context (rcu_read_lock() plus sb->s_inode_list_lock) without taking a reference. The callback must do its own state checks, must not block and must do its own rescheduling by returning %INO_ITER_RET_ABORT. Patch 1 adds the iterator. Patch 2 converts the callers that cannot use referenced inodes (dquot removal, inode eviction, nr_blockdev_pages and the generic_shutdown_super() poisoning loop) to %INO_ITER_F_UNSAFE. Patch 3 converts the remaining callers (sync_bdevs, drop_pagecache_sb, gfs2_kill_sb, add_dquot_ref and landlock's hook_sb_delete). BTW: This patch set depends a small patch: "fs/drop_caches: skip filesystems without fs writeback" https://lkml.org/lkml/2026/9/23/675 Huang Shijie (3): vfs: add inode iteration method super_iter_inodes vfs: convert inode iterators to the unsafe super_iter_inodes() vfs: convert sb->s_inodes iteration to super_iter_inodes() block/bdev.c | 84 ++++++++----------- fs/drop_caches.c | 36 ++------- fs/gfs2/ops_fstype.c | 68 +++++----------- fs/inode.c | 68 ++++++++-------- fs/quota/dquot.c | 132 ++++++++++++++---------------- fs/super.c | 131 +++++++++++++++++++++++++++--- include/linux/fs/super_types.h | 14 ++++ security/landlock/fs.c | 142 +++++++++++---------------------- 8 files changed, 340 insertions(+), 335 deletions(-) -- 2.34.1