diff mbox series

[RFC,1/3] NFSD: Record call's slot index

Message ID 20250214155746.18016-2-cel@kernel.org (mailing list archive)
State Handled Elsewhere
Headers show
Series Implement referring call lists for CB_OFFLOAD | expand

Commit Message

Chuck Lever Feb. 14, 2025, 3:57 p.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

The slot index number of the current COMPOUND has, until now, not
been needed outside of nfsd4_sequence(). But to record the tuple
that represents the referring call, the slot number will be
needed when processing subsequent operations in the COMPOUND.

I've brute-forced this by adding a field to nfsd4_compound_state,
but there's probably a way to add the index to nfsd4_slot. I'm just
not sure yet whether slot table resizing might change the index that
a struct nfsd4_slot represents.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/nfs4proc.c  | 1 +
 fs/nfsd/nfs4state.c | 1 +
 fs/nfsd/xdr4.h      | 1 +
 3 files changed, 3 insertions(+)

Comments

Jeff Layton Feb. 14, 2025, 6:26 p.m. UTC | #1
On Fri, 2025-02-14 at 10:57 -0500, cel@kernel.org wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> The slot index number of the current COMPOUND has, until now, not
> been needed outside of nfsd4_sequence(). But to record the tuple
> that represents the referring call, the slot number will be
> needed when processing subsequent operations in the COMPOUND.
> 
> I've brute-forced this by adding a field to nfsd4_compound_state,
> but there's probably a way to add the index to nfsd4_slot. I'm just
> not sure yet whether slot table resizing might change the index that
> a struct nfsd4_slot represents.
> 

The slot number is just the index into the xarray, and AFAICS they
never change indexes. I think it's safe to just store the index in the
nfsd4_slot itself whenever an xa_store is done in se_slots.

> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  fs/nfsd/nfs4proc.c  | 1 +
>  fs/nfsd/nfs4state.c | 1 +
>  fs/nfsd/xdr4.h      | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index 23052fa0e8bf..d09a96cbec1e 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -2792,6 +2792,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
>  
>  	resp->xdr = &rqstp->rq_res_stream;
>  	resp->statusp = resp->xdr->p;
> +	cstate->slot_idx = -1;
>  
>  	/* reserve space for: NFS status code */
>  	xdr_reserve_space(resp->xdr, XDR_UNIT);
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index b7a0cfd05401..c38601c9bf13 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -4415,6 +4415,7 @@ nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
>  	else
>  		slot->sl_flags &= ~NFSD4_SLOT_CACHETHIS;
>  
> +	cstate->slot_idx = seq->slotid;
>  	cstate->slot = slot;
>  	cstate->session = session;
>  	cstate->clp = clp;
> diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
> index c26ba86dbdfd..561894ff4b01 100644
> --- a/fs/nfsd/xdr4.h
> +++ b/fs/nfsd/xdr4.h
> @@ -186,6 +186,7 @@ struct nfsd4_compound_state {
>  	/* For sessions DRC */
>  	struct nfsd4_session	*session;
>  	struct nfsd4_slot	*slot;
> +	int			slot_idx;
>  	int			data_offset;
>  	bool                    spo_must_allowed;
>  	size_t			iovlen;
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 23052fa0e8bf..d09a96cbec1e 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -2792,6 +2792,7 @@  nfsd4_proc_compound(struct svc_rqst *rqstp)
 
 	resp->xdr = &rqstp->rq_res_stream;
 	resp->statusp = resp->xdr->p;
+	cstate->slot_idx = -1;
 
 	/* reserve space for: NFS status code */
 	xdr_reserve_space(resp->xdr, XDR_UNIT);
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index b7a0cfd05401..c38601c9bf13 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4415,6 +4415,7 @@  nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	else
 		slot->sl_flags &= ~NFSD4_SLOT_CACHETHIS;
 
+	cstate->slot_idx = seq->slotid;
 	cstate->slot = slot;
 	cstate->session = session;
 	cstate->clp = clp;
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
index c26ba86dbdfd..561894ff4b01 100644
--- a/fs/nfsd/xdr4.h
+++ b/fs/nfsd/xdr4.h
@@ -186,6 +186,7 @@  struct nfsd4_compound_state {
 	/* For sessions DRC */
 	struct nfsd4_session	*session;
 	struct nfsd4_slot	*slot;
+	int			slot_idx;
 	int			data_offset;
 	bool                    spo_must_allowed;
 	size_t			iovlen;