On Thu, Oct 15, 2026 at 5:44 AM Huang Shijie [off-list ref] wrote:
This will be used to replace the explicit sb->s_inodes iteration,
with the caller supplying a callback function and a private data
pointer that is passed to the callback along with each inode that is
iterated.
A single iteration function, super_iter_inodes(), is provided, with
the iteration mode selected by the INO_ITER_F_UNSAFE flag. The
INO_ITER_F_REFERENCED flag can additionally restrict the iteration to
inodes that still have a reference.
Without INO_ITER_F_UNSAFE, the callback is called with a valid,
unlocked and referenced inode, so any inode operation, including
blocking operations, is allowed. The iterator is responsible for
inode lifecycle management, so the callback only needs to implement
the operation it wants to perform on all inodes.
With INO_ITER_F_UNSAFE set, the inodes are iterated without taking a
reference and the callback is run in an atomic context that must not
block. This mode is for internal VFS use only and runs under a RCU
read lock so that the VFS inode is not freed from under the callback.
It is needed for operations that require tight control over the state
of the inodes they operate on.
This mechanism allows the existing sb->s_inodes iteration models to
be maintained, providing a generic implementation for iterating all
cached inodes on the superblock.
Signed-off-by: Huang Shijie <redacted>
Perhaps SELinux could also use this to replace its own inode walking
logic at the tail of security/selinux/hooks.c:sb_finish_set_opts()?