From: Luis Henriques <luis@igalia.com>
To: Chunsheng Luo <luochunsheng@ustc.edu>
Cc: bernd@bsbernd.com, david@fromorbit.com, kernel-dev@igalia.com,
laura.promberger@cern.ch, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, mharvey@jumptrading.com,
miklos@szeredi.hu
Subject: Re: [PATCH v4] fuse: new work queue to periodically invalidate expired dentries
Date: Tue, 19 Aug 2025 10:59:14 +0100 [thread overview]
Message-ID: <87ldnfmy31.fsf@wotan.olymp> (raw)
In-Reply-To: <20250819035208.540-1-luochunsheng@ustc.edu> (Chunsheng Luo's message of "Tue, 19 Aug 2025 11:52:08 +0800")
On Tue, Aug 19 2025, Chunsheng Luo wrote:
> On Mon, 7 Jul 2025 16:34:13 Luis Henriques wrote:
>
>>+static void fuse_dentry_tree_add_node(struct dentry *dentry)
>>+{
>>+ struct fuse_conn *fc = get_fuse_conn_super(dentry->d_sb);
>>+ struct fuse_dentry *fd = dentry->d_fsdata;
>>+ struct fuse_dentry *cur;
>>+ struct rb_node **p, *parent = NULL;
>>+ bool start_work = false;
>>+
>>+ if (!fc->inval_wq)
>>+ return;
>
> First check.
>
>>+
>>+ spin_lock(&fc->dentry_tree_lock);
>>+
>>+ if (!fc->inval_wq) {
>>+ spin_unlock(&fc->dentry_tree_lock);
>>+ return;
>>+ }
>
> Check again.
>
> I don't think the if (!fc->inval_wq) check needs to be re-evaluated
> while holding the lock. The reason is that the inval_wq variable
> doesn't appear to require lock protection. It only gets assigned
> during fuse_conn_init and fuse_conn_destroy. Furthermore,
> in fuse_conn_destroy we set inval_wq to zero without holding a lock,
> and then synchronously cancel any pending work items.
>
> Therefore, performing this check twice with if (!fc->inval_wq)
> seems unnecessary.
Thank you for your feedback, Chunsheng. Having two checks here was just a
small optimisation, the second one is the _real_ one. So yeah, I guess
it's fine to drop the first one.
Cheers,
--
Luís
> Also, in the subject, it would be more appropriate to change
> "work queue" to "workqueue".
>
> Thanks
> Chunsheng Luo
>
>>+
>>+ start_work = RB_EMPTY_ROOT(&fc->dentry_tree);
>>+ __fuse_dentry_tree_del_node(fc, fd);
>>+
>>+ p = &fc->dentry_tree.rb_node;
>>+ while (*p) {
>>+ parent = *p;
>>+ cur = rb_entry(*p, struct fuse_dentry, node);
>>+ if (fd->time > cur->time)
>>+ p = &(*p)->rb_left;
>>+ else
>>+ p = &(*p)->rb_right;
>>+ }
>>+ rb_link_node(&fd->node, parent, p);
>>+ rb_insert_color(&fd->node, &fc->dentry_tree);
>>+ spin_unlock(&fc->dentry_tree_lock);
>>+
>>+ if (start_work)
>>+ schedule_delayed_work(&fc->dentry_tree_work,
>>+ secs_to_jiffies(fc->inval_wq));
>>+}
prev parent reply other threads:[~2025-08-19 9:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-07 15:34 [PATCH v4] fuse: new work queue to periodically invalidate expired dentries Luis Henriques
2025-07-09 10:58 ` Luis Henriques
2025-08-18 13:21 ` Miklos Szeredi
2025-08-19 9:26 ` Luis Henriques
2025-08-19 3:52 ` Chunsheng Luo
2025-08-19 9:59 ` Luis Henriques [this message]
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=87ldnfmy31.fsf@wotan.olymp \
--to=luis@igalia.com \
--cc=bernd@bsbernd.com \
--cc=david@fromorbit.com \
--cc=kernel-dev@igalia.com \
--cc=laura.promberger@cern.ch \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luochunsheng@ustc.edu \
--cc=mharvey@jumptrading.com \
--cc=miklos@szeredi.hu \
/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;
as well as URLs for NNTP newsgroup(s).