From: Huang Shijie <huangsj@hygon.cn>
To: <viro@zeniv.linux.org.uk>, <brauner@kernel.org>, <jack@suse.cz>,
<hch@infradead.org>, <agruenba@redhat.com>, <mic@digikod.net>,
<axboe@kernel.dk>
Cc: <gnoack@google.com>, <paul@paul-moore.com>, <jmorris@namei.org>,
<serge@hallyn.com>, <legion@kernel.org>, <aleksa@amutable.com>,
<libaokun@linux.alibaba.com>, <ebiggers@kernel.org>,
<djwong@kernel.org>, <sandeen@redhat.com>, <zhongyuan@hygon.cn>,
<fangbaoshun@hygon.cn>, <yingzhiwei@hygon.cn>,
<wujianyong@hygon.cn>, <shijie8@gmail.com>,
<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-block@vger.kernel.org>, <gfs2@lists.linux.dev>,
<linux-security-module@vger.kernel.org>,
Huang Shijie <huangsj@hygon.cn>
Subject: [PATCH v3 03/11] fs/quota: convert remove_dquot_ref() to super_iter_inodes_locked()
Date: Fri, 20 Nov 2026 11:12:57 +0800 [thread overview]
Message-ID: <20261120031305.3561045-4-huangsj@hygon.cn> (raw)
In-Reply-To: <20261120031305.3561045-1-huangsj@hygon.cn>
Convert remove_dquot_ref() to super_iter_inodes_locked().
No functional change.
Signed-off-by: Huang Shijie <huangsj@hygon.cn>
---
fs/quota/dquot.c | 68 ++++++++++++++++++++++++++++--------------------
1 file changed, 40 insertions(+), 28 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index a3d503591871..9aaf2cfa9e1b 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -83,6 +83,8 @@
#include <linux/uaccess.h>
+#include "../internal.h"
+
/*
* There are five quota SMP locks:
* * dq_list_lock protects all lists with quotas and quota formats.
@@ -165,6 +167,11 @@ static struct kmem_cache *dquot_cachep;
/* workqueue for work quota_release_work*/
static struct workqueue_struct *quota_unbound_wq;
+struct dquot_ref_data {
+ int type;
+ int reserved;
+};
+
void register_quota_format(struct quota_format_type *fmt)
{
spin_lock(&dq_list_lock);
@@ -1117,41 +1124,46 @@ static int add_dquot_ref(struct super_block *sb, int type)
return err;
}
-static void remove_dquot_ref(struct super_block *sb, int type)
+static int remove_dquot_ref_fn(struct inode *inode, void *priv)
{
- struct inode *inode;
-#ifdef CONFIG_QUOTA_DEBUG
- int reserved = 0;
-#endif
+ struct dquot_ref_data *ref = priv;
- spin_lock(&sb->s_inode_list_lock);
- list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
- /*
- * We have to scan also I_NEW inodes because they can already
- * have quota pointer initialized. Luckily, we need to touch
- * only quota pointers and these have separate locking
- * (dq_data_lock).
- */
- spin_lock(&dq_data_lock);
- if (!IS_NOQUOTA(inode)) {
- struct dquot __rcu **dquots = i_dquot(inode);
- struct dquot *dquot = srcu_dereference_check(
- dquots[type], &dquot_srcu,
- lockdep_is_held(&dq_data_lock));
+ spin_lock(&dq_data_lock);
+ if (!IS_NOQUOTA(inode)) {
+ struct dquot __rcu **dquots = i_dquot(inode);
+ struct dquot *dquot = srcu_dereference_check(
+ dquots[ref->type], &dquot_srcu,
+ lockdep_is_held(&dq_data_lock));
#ifdef CONFIG_QUOTA_DEBUG
- if (unlikely(inode_get_rsv_space(inode) > 0))
- reserved = 1;
+ if (unlikely(inode_get_rsv_space(inode) > 0))
+ ref->reserved++;
#endif
- rcu_assign_pointer(dquots[type], NULL);
- if (dquot)
- dqput(dquot);
- }
- spin_unlock(&dq_data_lock);
+ rcu_assign_pointer(dquots[ref->type], NULL);
+ if (dquot)
+ dqput(dquot);
}
- spin_unlock(&sb->s_inode_list_lock);
+ spin_unlock(&dq_data_lock);
+ return INO_ITER_RET_NEXT;
+}
+
+static void remove_dquot_ref(struct super_block *sb, int type)
+{
+ struct dquot_ref_data ref = {
+ .type = type,
+ };
+
+ /*
+ * We have to scan I_NEW inodes because they can already
+ * have quota pointer initialized. Luckily, we need to touch
+ * only quota pointers and these have separate locking
+ * (dq_data_lock) so the existence guarantee that
+ * super_iter_inodes_locked() provides inodes passed to
+ * remove_dquot_ref_fn() is sufficient for this operation.
+ */
+ super_iter_inodes_locked(sb, remove_dquot_ref_fn, &ref);
#ifdef CONFIG_QUOTA_DEBUG
- if (reserved) {
+ if (ref.reserved) {
printk(KERN_WARNING "VFS (%s): Writes happened after quota"
" was disabled thus quota information is probably "
"inconsistent. Please run quotacheck(8).\n", sb->s_id);
--
2.53.0
next prev parent reply other threads:[~2026-11-20 3:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 3:12 [PATCH v3 0/11] vfs: add inode iteration methods Huang Shijie
2026-11-20 3:12 ` [PATCH v3 01/11] vfs: add super_iter_inodes() Huang Shijie
2026-11-20 14:56 ` Andreas Gruenbacher
2026-11-20 3:12 ` [PATCH v3 02/11] vfs: add super_iter_inodes_locked() Huang Shijie
2026-11-20 3:12 ` Huang Shijie [this message]
2026-11-20 3:12 ` [PATCH v3 04/11] block: convert nr_blockdev_pages() to super_iter_inodes_locked() Huang Shijie
2026-11-20 3:12 ` [PATCH v3 05/11] fs: convert generic_shutdown_super() poison loop Huang Shijie
2026-11-20 3:13 ` [PATCH v3 06/11] fs/inode: convert evict_inodes() to super_iter_inodes() Huang Shijie
2026-11-20 3:13 ` [PATCH v3 07/11] block: convert sync_bdevs() " Huang Shijie
2026-11-20 3:13 ` [PATCH v3 08/11] fs/drop_caches: convert drop_pagecache_sb() " Huang Shijie
2026-11-20 3:13 ` [PATCH v3 09/11] fs/quota: convert add_dquot_ref() " Huang Shijie
2026-11-20 3:13 ` [PATCH v3 10/11] landlock: convert hook_sb_delete() " Huang Shijie
2026-11-20 3:13 ` [PATCH v3 11/11] gfs2: convert gfs2_evict_inodes() " Huang Shijie
2026-11-20 14:59 ` [PATCH v3 0/11] vfs: add inode iteration methods Andreas Gruenbacher
2026-11-23 2:31 ` 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=20261120031305.3561045-4-huangsj@hygon.cn \
--to=huangsj@hygon.cn \
--cc=agruenba@redhat.com \
--cc=aleksa@amutable.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=ebiggers@kernel.org \
--cc=fangbaoshun@hygon.cn \
--cc=gfs2@lists.linux.dev \
--cc=gnoack@google.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=jmorris@namei.org \
--cc=legion@kernel.org \
--cc=libaokun@linux.alibaba.com \
--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=viro@zeniv.linux.org.uk \
--cc=wujianyong@hygon.cn \
--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