From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <cel@kernel.org>, NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Chuck Lever <chuck.lever@oracle.com>
Subject: Re: [PATCH v4 4/6] NFSD: Refactor find_one_sb_stid() into find_next_sb_stid()
Date: Wed, 18 Mar 2026 10:30:08 -0400 [thread overview]
Message-ID: <e1c465a1010b702ff41af23caef6177ff88aa4e8.camel@kernel.org> (raw)
In-Reply-To: <20260318-umount-kills-nfsv4-state-v4-4-56aad44ab982@oracle.com>
On Wed, 2026-03-18 at 10:15 -0400, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
>
> Export-scoped state revocation, added in a subsequent commit,
> needs to advance past non-matching stids within the same
> client without restarting from position zero on each call.
>
> Extract find_next_sb_stid(), which accepts a starting IDR
> position and can resume iteration across multiple calls.
> find_one_sb_stid() becomes a thin wrapper that starts from
> position zero.
>
> No change in behavior.
>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> fs/nfsd/nfs4state.c | 25 ++++++++++++++++++++-----
> 1 file changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index d476192e4b27..891669b32804 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -1738,25 +1738,40 @@ static void release_openowner(struct nfs4_openowner *oo)
> nfs4_put_stateowner(&oo->oo_owner);
> }
>
> -static struct nfs4_stid *find_one_sb_stid(struct nfs4_client *clp,
> - struct super_block *sb,
> - unsigned int sc_types)
> +/*
> + * On return of a non-NULL stid, @id holds that entry's IDR key;
> + * caller must increment @id before the next call to advance past it.
> + */
> +static struct nfs4_stid *find_next_sb_stid(struct nfs4_client *clp,
> + struct super_block *sb,
> + unsigned int sc_types,
> + unsigned long *id)
> {
> - unsigned long id, tmp;
> struct nfs4_stid *stid;
>
> spin_lock(&clp->cl_lock);
> - idr_for_each_entry_ul(&clp->cl_stateids, stid, tmp, id)
> + while ((stid = idr_get_next_ul(&clp->cl_stateids, id)) != NULL) {
> if ((stid->sc_type & sc_types) &&
> stid->sc_status == 0 &&
> stid->sc_file->fi_inode->i_sb == sb) {
> refcount_inc(&stid->sc_count);
> break;
> }
> + (*id)++;
> + }
> spin_unlock(&clp->cl_lock);
> return stid;
> }
>
> +static struct nfs4_stid *find_one_sb_stid(struct nfs4_client *clp,
> + struct super_block *sb,
> + unsigned int sc_types)
> +{
> + unsigned long id = 0;
> +
> + return find_next_sb_stid(clp, sb, sc_types, &id);
> +}
> +
> static void revoke_ol_stid(struct nfs4_client *clp,
> struct nfs4_ol_stateid *stp)
> {
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2026-03-18 14:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 14:15 [PATCH v4 0/6] Automatic NFSv4 state revocation on filesystem unmount Chuck Lever
2026-03-18 14:15 ` [PATCH v4 1/6] NFSD: Extract revoke_one_stid() utility function Chuck Lever
2026-03-18 14:21 ` Jeff Layton
2026-03-18 14:15 ` [PATCH v4 2/6] NFSD: Add NFSD_CMD_UNLOCK netlink command with ip scope Chuck Lever
2026-03-18 14:28 ` Jeff Layton
2026-03-18 14:32 ` Chuck Lever
2026-03-18 14:15 ` [PATCH v4 3/6] NFSD: Add filesystem scope to NFSD_CMD_UNLOCK Chuck Lever
2026-03-18 14:29 ` Jeff Layton
2026-03-18 14:15 ` [PATCH v4 4/6] NFSD: Refactor find_one_sb_stid() into find_next_sb_stid() Chuck Lever
2026-03-18 14:30 ` Jeff Layton [this message]
2026-03-18 14:15 ` [PATCH v4 5/6] NFSD: Add export-scoped state revocation Chuck Lever
2026-03-18 14:47 ` Jeff Layton
2026-03-18 14:51 ` Chuck Lever
2026-03-18 14:58 ` Jeff Layton
2026-03-18 17:57 ` Chuck Lever
2026-03-18 14:15 ` [PATCH v4 6/6] NFSD: Add nfsd_file_close_export() for file cache cleanup Chuck Lever
2026-03-18 14:24 ` [PATCH v4 0/6] Automatic NFSv4 state revocation on filesystem unmount Jeff Layton
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=e1c465a1010b702ff41af23caef6177ff88aa4e8.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=cel@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/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