mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Huang Shijie <huangsj@hygon.cn>
To: <axboe@kernel.dk>, <viro@zeniv.linux.org.uk>,
	<brauner@kernel.org>, <jack@suse.cz>
Cc: <zhongyuan@hygon.cn>, <fangbaoshun@hygon.cn>,
	<yingzhiwei@hygon.cn>, <agruenba@redhat.com>, <mic@digikod.net>,
	<gnoack@google.com>, <paul@paul-moore.com>, <jmorris@namei.org>,
	<serge@hallyn.com>, <aleksa@amutable.com>, <legion@kernel.org>,
	<david@kernel.org>, <sandeen@redhat.com>, <ebiggers@kernel.org>,
	<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-fsdevel@vger.kernel.org>, <gfs2@lists.linux.dev>,
	<linux-security-module@vger.kernel.org>,
	<sunjunchao@bytedance.com>, <shijie8@gmail.com>,
	Huang Shijie <huangsj@hygon.cn>
Subject: [PATCH v2 0/3] vfs: add inode iteration methods
Date: Fri, 13 Nov 2026 19:56:59 +0800	[thread overview]
Message-ID: <20261113115702.586594-1-huangsj@hygon.cn> (raw)

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



             reply	other threads:[~2026-11-13 11:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 11:56 Huang Shijie [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261113115702.586594-1-huangsj@hygon.cn \
    --to=huangsj@hygon.cn \
    --cc=agruenba@redhat.com \
    --cc=aleksa@amutable.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=david@kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=fangbaoshun@hygon.cn \
    --cc=gfs2@lists.linux.dev \
    --cc=gnoack@google.com \
    --cc=jack@suse.cz \
    --cc=jmorris@namei.org \
    --cc=legion@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    --cc=sandeen@redhat.com \
    --cc=serge@hallyn.com \
    --cc=shijie8@gmail.com \
    --cc=sunjunchao@bytedance.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yingzhiwei@hygon.cn \
    --cc=zhongyuan@hygon.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®