Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=101.204.27.37 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794571062; b=DVZye/P2AWxbmqBegA+71SdcbAUyZkcvY2ALbHPTkjuiyhrBtMFJkNCa0EUlLAOFkbzL BSukGdSwKfifUF9im8s2xpvzkWgXKgJDhsCDJhCE7yCcyxyOy8LGyeRyL6s5ai0UC81W4 GeG0PzmvE22sTZ6A8I/8MS7/hLxd4bUmH9wwBXTL7kQ7hW7/2+MlJWzE8YFfE0H3Tw2w2 PWzOEI0sZmoM6m3F1CnMcAPq70SavcwPtzPefrUODKVf7Kf3PPP1973eMGYc2zFPaHDN8 EMxYVFmGH//6XFgkGLKQlG2rzDE7DOBOBHDQiXrn4wwenCf28KXPyJrPK7nuRUSxWxg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794571062; h=DMARC-Filter:Received:Received:Received:Received:From:To:CC:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: Content-Type:X-Originating-IP:X-ClientProxiedBy; bh=YHpzHEdUDZ5SvCxvkjenerDSoX95H+RemwkThqVSCZg=; b=R0idfO4WDIwzF5q1OjJhk7nivpLGU4BJo58+XamvWZ48atmeP4d2m8UBhFvK+Lg6WBlG trlUpF4KEcRi05lt8TknWftjBhu/GEPTiVo7Vutc2SEZEPb2wzgBYP2RJDGYfJnGSU9Xo 2winaAwmvS4UdJoUEKLTkXdwaFuyzpU4TmsONrqv7yr7OqjGsexE0+z8QakHVfn82qvqr PUO1r9PjZHXsvLpPEVQcB4r1UcMChP4e27HdqKcTq8qtciGju/zuSU+d9v624cyKVhel7 EpGrd3aFlHQJw3MoR6/jFugicz/pIUj2v2L/dVARumlKSdxrSnvE+YUYkXBIP+EKLfA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=hygon.cn; spf=pass smtp.mailfrom=hygon.cn; arc=none smtp.remote-ip=101.204.27.37 Received: from spam01.hygon.cn (unknown [101.204.27.37]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25E88606A31C for ; Fri, 13 Nov 2026 11:57:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 25E88606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hygon.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hygon.cn Received: from maildlp2.hygon.cn (unknown [127.0.0.1]) by spam01.hygon.cn (Postfix) with ESMTP id 4jQwjg2LbCzVcB5; Fri, 13 Nov 2026 19:57:27 +0800 (CST) Received: from maildlp2.hygon.cn (unknown [172.23.18.61]) by spam01.hygon.cn (Postfix) with ESMTP id 4jQwjf25jzzVcB5; Fri, 13 Nov 2026 19:57:26 +0800 (CST) Received: from cncheex04.Hygon.cn (unknown [172.23.18.114]) by maildlp2.hygon.cn (Postfix) with ESMTPS id AFA0C30004D3; Fri, 13 Nov 2026 19:56:35 +0800 (CST) Received: from hsj-2U-Workstation.hygon.cn (172.19.24.226) by cncheex04.Hygon.cn (172.23.18.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Fri, 13 Nov 2026 19:57:24 +0800 From: Huang Shijie To: , , , CC: , , , , , , , , , , , , , , , , , , , , , Huang Shijie Subject: [PATCH v2 0/3] vfs: add inode iteration methods Date: Fri, 13 Nov 2026 19:56:59 +0800 Message-ID: <20261113115702.586594-1-huangsj@hygon.cn> X-Mailer: git-send-email 2.53.0 X-Mailing-List: gfs2@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: cncheex05.Hygon.cn (172.23.18.115) To cncheex04.Hygon.cn (172.23.18.114) 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