linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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, Chuck Lever <chuck.lever@oracle.com>
Subject: Re: [PATCH v2 4/4] NFSD: Move nfsd4_cache_this()
Date: Tue, 07 Oct 2025 13:20:13 -0400	[thread overview]
Message-ID: <3d2b9d2451739f4671a1dc360ab4545e92692f42.camel@kernel.org> (raw)
In-Reply-To: <20251007160413.4953-5-cel@kernel.org>

On Tue, 2025-10-07 at 12:04 -0400, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> nfsd4_cache_this() has one call site, and is not related to XDR at
> all. It doesn't belong in fs/nfsd/xdr4.h.
> 
> As a clean-up, move this function (and its helper) to nfs4state.c,
> next to its caller.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  fs/nfsd/nfs4state.c | 23 +++++++++++++++++++++++
>  fs/nfsd/xdr4.h      | 23 -----------------------
>  2 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index c9053ef4d79f..2c4fa4a23463 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -3476,6 +3476,29 @@ gen_callback(struct nfs4_client *clp, struct nfsd4_setclientid *se, struct svc_r
>  	return;
>  }
>  
> +static bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
> +{
> +	struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
> +
> +	return args->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
> +}
> +
> +/*
> + * Solo SEQUENCE operations are not supposed respect the setting in the
> + * sa_cachethis field, since that field controls whether the operations
> + * /after/ the SEQUENCE are preserved in the slot reply cache. Because
> + * clients might use a solo SEQUENCE to query the current state of the
> + * session or slot, a cached reply would return stale data to the client.
> + *
> + * Therefore NFSD treats solo SEQUENCE as an uncached operation no matter
> + * how the sa_cachethis field is set.
> + */
> +static bool nfsd4_cache_this(struct nfsd4_compoundres *resp)
> +{
> +	return (resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS) &&
> +		!nfsd4_is_solo_sequence(resp);
> +}
> +
>  /*
>   * Cache a reply. nfsd4_check_resp_size() has bounded the cache size.
>   */
> diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
> index 9619e78f0ed2..6f0129ea754d 100644
> --- a/fs/nfsd/xdr4.h
> +++ b/fs/nfsd/xdr4.h
> @@ -923,29 +923,6 @@ struct nfsd4_compoundres {
>  	struct nfsd4_compound_state	cstate;
>  };
>  
> -static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
> -{
> -	struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
> -
> -	return args->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
> -}
> -
> -/*
> - * Solo SEQUENCE operations are not supposed respect the setting in the
> - * sa_cachethis field, since that field controls whether the operations
> - * /after/ the SEQUENCE are preserved in the slot reply cache. Because
> - * clients might use a solo SEQUENCE to query the current state of the
> - * session or slot, a cached reply would return stale data to the client.
> - *
> - * Therefore NFSD treats solo SEQUENCE as an uncached operation no matter
> - * how the sa_cachethis field is set.
> - */
> -static inline bool nfsd4_cache_this(struct nfsd4_compoundres *resp)
> -{
> -	return (resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS) &&
> -		!nfsd4_is_solo_sequence(resp);
> -}
> -
>  static inline bool nfsd4_last_compound_op(struct svc_rqst *rqstp)
>  {
>  	struct nfsd4_compoundres *resp = rqstp->rq_resp;

Reviewed-by: Jeff Layton <jlayton@kernel.org>

      reply	other threads:[~2025-10-07 17:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07 16:04 [PATCH v2 0/4] Fix unwanted memory overwrites Chuck Lever
2025-10-07 16:04 ` [PATCH v2 1/4] NFSD: Skip close replay processing if XDR encoding fails Chuck Lever
2025-10-07 16:04 ` [PATCH v2 2/4] NFSD: Fix the "is this a solo SEQUENCE" predicate Chuck Lever
2025-10-07 17:18   ` Jeff Layton
2025-10-07 16:04 ` [PATCH v2 3/4] NFSD: Do not cache solo SEQUENCE operations Chuck Lever
2025-10-07 17:19   ` Jeff Layton
2025-10-07 20:05   ` Chuck Lever
2025-10-07 22:12     ` NeilBrown
2025-10-08 13:04       ` Chuck Lever
2025-10-08 22:03         ` NeilBrown
2025-10-09 12:56           ` Chuck Lever
2025-10-09 23:29             ` NeilBrown
2025-10-10 13:03               ` Chuck Lever
2025-10-11  0:55                 ` NeilBrown
2025-10-11 15:30                   ` Chuck Lever
2025-10-07 22:21   ` Calum Mackay
2025-10-07 16:04 ` [PATCH v2 4/4] NFSD: Move nfsd4_cache_this() Chuck Lever
2025-10-07 17:20   ` Jeff Layton [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=3d2b9d2451739f4671a1dc360ab4545e92692f42.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=cel@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=dai.ngo@oracle.com \
    --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;
as well as URLs for NNTP newsgroup(s).