mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] vfs: add inode iteration methods
@ 2026-11-13 11:56 Huang Shijie
  2026-11-13 11:57 ` [PATCH v2 1/3] " Huang Shijie
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Huang Shijie @ 2026-11-13 11:56 UTC (permalink / raw)
  To: axboe, viro, brauner, jack
  Cc: zhongyuan, fangbaoshun, yingzhiwei, agruenba, mic, gnoack, paul,
	jmorris, serge, aleksa, legion, david, sandeen, ebiggers,
	linux-block, linux-kernel, linux-fsdevel, gfs2,
	linux-security-module, sunjunchao, shijie8, Huang Shijie

This series adds two superblock inode iteration helpers:
super_iter_inodes()/super_iter_inodes_unsafe(), 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/

About the two helpers:  
  int super_iter_inodes(struct super_block *sb,
                        struct inode_iter_context *ctx);

  int super_iter_inodes_unsafe(struct super_block *sb,
                               struct inode_iter_context *ctx);

  - super_iter_inodes() runs @ctx->iter_fn() with a referenced inode
    and with sb->s_inode_list_lock dropped, so the callback is free to
    block and to do whatever it wants with the inode except drop the
    reference the iterator holds.  
    It is exported because GFS2 can be built as a module.

  - super_iter_inodes_unsafe() keeps sb->s_inode_list_lock and
    rcu_read_lock() held for the whole walk and takes no inode
    references at all.  Its callback therefore only has an existence
    guarantee: it must not block and must do its own inode state
    checks and its own reference handling.  
    It is internal to the VFS, being declared in fs/internal.h.

  - %INO_ITER_F_REFERENCED additionally restricts the safe iterator to
    inodes that still have a reference.  This preserves the "only
    handle referenced inodes" rule of landlock's sb-delete walk.

  - @ctx->prev is the resume point of the unsafe iterator: a caller
    which has to drop the list lock in the middle of a walk stores the
    inode to continue from, and the next call starts after that inode
    instead of at the head.

   Patch 1 adds the two iterators.

   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
           super_iter_inodes_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

v1-->v2:
   -split the super_iter_inodes_unsafe from super_iter_inodes.
   -add ->eligible() before calling the __iget().
   -others
   
   v1: https://lore.kernel.org/all/20261015093854.2082600-1-huangsj@hygon.cn/

Huang Shijie (3):
  vfs: add inode iteration methods
  vfs: convert inode iterators to super_iter_inodes_unsafe()
  vfs: convert sb->s_inodes iteration to super_iter_inodes()

 block/bdev.c                   | 111 ++++++++++++------------
 fs/drop_caches.c               |  49 +++++------
 fs/gfs2/ops_fstype.c           |  33 +++----
 fs/inode.c                     |  83 ++++++++++--------
 fs/internal.h                  |  34 ++++++++
 fs/quota/dquot.c               | 149 +++++++++++++++++---------------
 fs/super.c                     |  88 +++++++++++++++++--
 include/linux/fs/super_types.h |  25 ++++++
 security/landlock/fs.c         | 153 +++++++++++++--------------------
 9 files changed, 413 insertions(+), 312 deletions(-)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-13 12:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 11:56 [PATCH v2 0/3] vfs: add inode iteration methods Huang Shijie
2026-11-13 11:57 ` [PATCH v2 1/3] " Huang Shijie
2026-11-13 12:23   ` Christoph Hellwig
2026-11-13 11:57 ` [PATCH v2 2/3] vfs: convert inode iterators to super_iter_inodes_unsafe() Huang Shijie
2026-11-13 11:57 ` [PATCH v2 3/3] vfs: convert sb->s_inodes iteration to super_iter_inodes() Huang Shijie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®