From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@meta.com>
Cc: Christoph Hellwig <hch@lst.de>,
Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH 22/24] NFS: add a separate delegation return list
Date: Mon, 26 Jan 2026 07:06:39 +0100 [thread overview]
Message-ID: <20260126060638.GA1304@lst.de> (raw)
In-Reply-To: <20260125133300.2723227-1-clm@meta.com>
On Sun, Jan 25, 2026 at 05:30:07AM -0800, Chris Mason wrote:
> > + spin_lock(&server->delegations_lock);
> > + list_for_each_entry_rcu(d, &server->delegations_return, entry) {
> > + if (test_bit(NFS_DELEGATION_RETURN_DELAYED, &d->flags))
> > + clear_bit(NFS_DELEGATION_RETURN_DELAYED, &d->flags);
> > ret = true;
> > }
> > -out:
> > +
> > return ret;
> > }
>
> Is there a missing spin_unlock() here? The spin_lock() is taken but
> the function returns without releasing it. This appears to cause a
> deadlock when delegations_lock is next acquired.
Yes. I'm kinda surprised the sparse lock context tracking didn't
catch it, but maybe it gives up after multiple 'bad constant expression'
from the module parameters.
> > + if (test_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags) ||
> > + test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) ||
> > + test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) {
> > + spin_unlock(&delegation->lock);
> > + goto out_put_inode;
> > + }
>
> When a delegation has RETURN_DELAYED set, the code removes it from
> delegations_return (via list_del_init above) and then skips to
> out_put_inode without re-adding it to the list. Since
> nfs_server_clear_delayed_delegations() only iterates delegations_return,
> will this delegation ever have its RETURN_DELAYED flag cleared so it
> can be processed again?
>
> The scenario is: nfs_end_delegation_return() returns -EAGAIN, which
> sets RETURN_DELAYED via nfs_abort_delegation_return(), then
> nfs_mark_return_delegation() re-adds the delegation to
> delegations_return. On the next iteration of the loop, this check
> triggers and the delegation is dropped from the list without being
> re-queued.
This looks like a mess before and after. I think the best
idea is a separate list for the delayed returns, but I really
need to find a way to actually generate the delayed returns first.
I'll look into that, thanks!
next prev parent reply other threads:[~2026-01-26 6:06 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 7:26 add a LRU for delegations Christoph Hellwig
2026-01-07 7:26 ` [PATCH 01/24] NFS: remove __nfs_client_for_each_server Christoph Hellwig
2026-01-07 7:26 ` [PATCH 02/24] NFS: remove nfs_client_mark_return_unused_delegation_types Christoph Hellwig
2026-01-07 7:26 ` [PATCH 03/24] NFS: remove nfs_client_mark_return_all_delegations Christoph Hellwig
2026-01-07 7:26 ` [PATCH 04/24] NFS: remove the NULL inode check in nfs4_inode_return_delegation_on_close Christoph Hellwig
2026-01-07 7:26 ` [PATCH 05/24] NFS: remove nfs_inode_detach_delegation Christoph Hellwig
2026-01-07 7:26 ` [PATCH 06/24] NFS: remove nfs_start_delegation_return Christoph Hellwig
2026-01-07 7:26 ` [PATCH 07/24] NFS: assert rcu_read_lock is held in nfs_start_delegation_return_locked Christoph Hellwig
2026-01-07 7:26 ` [PATCH 08/24] NFS: drop the _locked postfix from nfs_start_delegation_return Christoph Hellwig
2026-01-07 7:27 ` [PATCH 09/24] NFS: remove NFS_DELEGATION_INODE_FREEING Christoph Hellwig
2026-01-07 7:27 ` [PATCH 10/24] NFS: open code nfs_delegation_need_return Christoph Hellwig
2026-01-07 7:27 ` [PATCH 11/24] NFS: remove nfs_free_delegation Christoph Hellwig
2026-01-07 7:27 ` [PATCH 12/24] NFS: rewrite nfs_delegations_present in terms of nr_active_delegations Christoph Hellwig
2026-01-07 7:27 ` [PATCH 13/24] NFS: move delegation lookup into can_open_delegated Christoph Hellwig
2026-01-07 7:27 ` [PATCH 14/24] NFS: return bool from nfs_detach_delegation{,_locked} Christoph Hellwig
2026-01-07 7:27 ` [PATCH 15/24] NFS: move the deleg_cur check out of nfs_detach_delegation_locked Christoph Hellwig
2026-01-07 7:27 ` [PATCH 16/24] NFS: simplify the detached delegation check in update_open_stateid Christoph Hellwig
2026-01-07 7:27 ` [PATCH 17/24] NFS: take a delegation reference in nfs4_get_valid_delegation Christoph Hellwig
2026-01-07 7:27 ` [PATCH 18/24] NFS: don't consume a delegation reference in nfs_end_delegation_return Christoph Hellwig
2026-01-07 7:27 ` [PATCH 19/24] NFS: use refcount_inc_not_zero nfs_start_delegation_return Christoph Hellwig
2026-01-07 7:27 ` [PATCH 20/24] NFS: use a local RCU critical section in nfs_start_delegation_return Christoph Hellwig
2026-01-07 7:27 ` [PATCH 21/24] NFS: reformat nfs_mark_delegation_revoked Christoph Hellwig
2026-01-07 7:27 ` [PATCH 22/24] NFS: add a separate delegation return list Christoph Hellwig
2026-01-25 13:30 ` Chris Mason
2026-01-26 6:06 ` Christoph Hellwig [this message]
2026-01-07 7:27 ` [PATCH 23/24] NFS: return delegations from the end of a LRU when over the watermark Christoph Hellwig
2026-01-07 7:27 ` [PATCH 24/24] NFS: make nfs_mark_return_unreferenced_delegations less aggressive Christoph Hellwig
2026-01-07 15:18 ` add a LRU for delegations Chuck Lever
2026-01-07 16:22 ` Christoph Hellwig
2026-01-07 19:22 ` Sagi Grimberg
2026-01-08 13:46 ` Christoph Hellwig
2026-01-09 0:13 ` Sagi Grimberg
2026-01-08 14:34 ` Chuck Lever
2026-01-08 15:35 ` Christoph Hellwig
2026-01-09 0:30 ` Sagi Grimberg
2026-01-09 1:07 ` Trond Myklebust
2026-01-11 7:46 ` Sagi Grimberg
2026-01-15 16:24 ` Christoph Hellwig
2026-01-21 20:42 ` Anna Schumaker
-- strict thread matches above, loose matches on Subject: below --
2025-12-18 5:56 Christoph Hellwig
2025-12-18 5:56 ` [PATCH 22/24] NFS: add a separate delegation return list Christoph Hellwig
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=20260126060638.GA1304@lst.de \
--to=hch@lst.de \
--cc=anna@kernel.org \
--cc=clm@meta.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trondmy@kernel.org \
/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