From patchwork Fri Feb 14 15:57:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13975188 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C559245002 for ; Fri, 14 Feb 2025 15:57:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739548671; cv=none; b=Pd6IF1E0yt1lL/2T5VwZEJZdEtF4YgL0OovDXiQd7Bi99+aem0scliA6HsZQ7rnGK5xO7O+nDsNssZVjrySyejCH/mj1Iqz6RHSLFmCo87irPg5UGvYjEn4SHONkjOfmGmyQGm5X9Nfvktrguir7lK/ggTQBwhZkASJ4tLZRI5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739548671; c=relaxed/simple; bh=CLBVbWkNRA23qaMrTddi5L/iaUzexYkHibsCI2XTuLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kIdsG5Lfm8FO+OfAiqrEaOKGUCpfdiIDnTold8dwm0mNqb+qfdS47Mc+h3UgH2bXYPKqHK5Kwj6jEJE/QmYESsyYpBWh09P6WKHN4RG69MWnuI2GZH+OmTBWRfvy2CBOI74F1/xrBMrd/FQapY2eqV/HBXOsjIVGx49xOaHjmfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fD7bMyjK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fD7bMyjK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7455FC4CEDD; Fri, 14 Feb 2025 15:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739548671; bh=CLBVbWkNRA23qaMrTddi5L/iaUzexYkHibsCI2XTuLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fD7bMyjKav2jCB3Nm3uiGq/4r7g7ErJp3ZoY/6hNpQqAUDkHq6WmDdXMm6L+Mafng aEfMaNtO75HY1viBU/UGFmzyrLa2emzgSe+tcWLhGKRnK8DvN5Z1PsGg337+27Ckei zz/V9splzBMFX/ArTjKWkJea25robuwahzS+cnFOpgH9JqA7PWIXzR3TFHvaWmOdmO 5qNoUi7qzkrLqvZvC0q40HridGVGTe57dWBGRTOUJdHuow39ve0u65tPdFgxvfG6W7 GH0MqhFa4mJ5RF1qNmNQGLKCVWWY8+EDdBrPtqKZP/GQ6ZQsh2LZDC5bFQ8k77ptwa IBtfqE2Joi0Eg== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 1/3] NFSD: Record call's slot index Date: Fri, 14 Feb 2025 10:57:44 -0500 Message-ID: <20250214155746.18016-2-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250214155746.18016-1-cel@kernel.org> References: <20250214155746.18016-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever 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 --- 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; From patchwork Fri Feb 14 15:57:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13975189 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 958D026738D for ; Fri, 14 Feb 2025 15:57:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739548672; cv=none; b=X4cqeSO/1SB1sisJETVWxNmlp+97B8tidzPSEGkUjCOPG5XpH32P0OPy+XvlWZrmxvAq1++qAKehdzZq0+bKPizNvF6nT9U4LJbxipnGutz4XA/kzyzezzwYkjie8VyhS31kyEWatXb1eoOxk+ewv1aHVWOTTSXH7yItTC5JjPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739548672; c=relaxed/simple; bh=Xu7KCb1VWPuRPNPIq+Q6ZEqjYKWcK/YdB2+TRse8TaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A5EXDreS4C/D6NRna2wfsw6GR0VIFhkrJ2BO7PAMN2vEJ9Dgjjy93i8BlREfWBCpVAPEnRVxeVu5WTX9hf5znso5/Sj7fCo2Kwz3JP+s5KGyAM1+VHEogbrVEbeSo6eWbljJtGPO/k+WZz8/3GTlDNM4PcOpahl8LQkFEgJkBu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VzAt66Pq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VzAt66Pq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 599D1C4CEEE; Fri, 14 Feb 2025 15:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739548672; bh=Xu7KCb1VWPuRPNPIq+Q6ZEqjYKWcK/YdB2+TRse8TaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VzAt66Pq0D1D4VzlPgJmy+EJPbzqve5lPOlX6+oRwG8Ewv0+I+eXoD8+0mBPgn1nD CieoYyvNHhxmIIWHizQpmHa1RvBGHA6+zSeEgQ1Vzco89DpFacIeZEQolkV09JW+Y/ nqkOvVrQF3GEW8MZ2MCXzyZDVKpMMYqjsoEl+mxqQe4g6mUaTDxdo5yzTyKj+vBtZ0 xsnDhjlWQr1435KgCV3M7KOx4w1UGEPlUt9LILN4CMo/qiGNTyb48+RPMRoXbwB/FK 2J/3x7wpiJ5KovCwU3lP5ewR0JSf9dOA1YYH2YK+FllI5SzOI9/Swmx4Ol4wCoqjkG Q6E5+N7tVPfCA== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 2/3] NFSD: Implement CB_SEQUENCE referring call lists Date: Fri, 14 Feb 2025 10:57:45 -0500 Message-ID: <20250214155746.18016-3-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250214155746.18016-1-cel@kernel.org> References: <20250214155746.18016-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever NFSD has yet to implement a mechanism for resolving races between a server's reply and a related callback operation. For example, a CB_OFFLOAD callback can race with the matching COPY response. The client will not recognize the copy state ID in the CB_OFFLOAD callback until the COPY response arrives. Trond points out: > It is also needed for the same kind of race with delegation > recalls, layout recalls, CB_NOTIFY_DEVICEID and would also be > helpful (although not as strongly required) for CB_NOTIFY_LOCK. RFC 8881 Section 20.9.3 describes referring call lists this way: > The csa_referring_call_lists array is the list of COMPOUND > requests, identified by session ID, slot ID, and sequence ID. > These are requests that the client previously sent to the server. > These previous requests created state that some operation(s) in > the same CB_COMPOUND as the csa_referring_call_lists are > identifying. A session ID is included because leased state is tied > to a client ID, and a client ID can have multiple sessions. See > Section 2.10.6.3. Introduce the XDR infrastructure for populating the csa_referring_call_lists argument of CB_SEQUENCE. Subsequent patches will put the referring call list to use. Note that cb_sequence_enc_sz estimates that only zero or one rcl is included in each CB_SEQUENCE, but the new infrastructure can manage any number of referring calls. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4callback.c | 132 +++++++++++++++++++++++++++++++++++++++-- fs/nfsd/state.h | 22 +++++++ fs/nfsd/xdr4cb.h | 5 +- 3 files changed, 153 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 50e468bdb8d4..0bdae29cf0bb 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -419,6 +419,29 @@ static u32 highest_slotid(struct nfsd4_session *ses) return idx; } +static void +encode_referring_call4(struct xdr_stream *xdr, + const struct nfsd4_referring_call *rc) +{ + encode_uint32(xdr, rc->rc_sequenceid); + encode_uint32(xdr, rc->rc_slotid); +} + +static void +encode_referring_call_list4(struct xdr_stream *xdr, + const struct nfsd4_referring_call_list *rcl) +{ + struct nfsd4_referring_call *rc; + __be32 *p; + + p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN); + xdr_encode_opaque_fixed(p, rcl->rcl_sessionid.data, + NFS4_MAX_SESSIONID_LEN); + encode_uint32(xdr, rcl->__nr_referring_calls); + list_for_each_entry(rc, &rcl->rcl_referring_calls, __list) + encode_referring_call4(xdr, rc); +} + /* * CB_SEQUENCE4args * @@ -436,6 +459,7 @@ static void encode_cb_sequence4args(struct xdr_stream *xdr, struct nfs4_cb_compound_hdr *hdr) { struct nfsd4_session *session = cb->cb_clp->cl_cb_session; + struct nfsd4_referring_call_list *rcl; __be32 *p; if (hdr->minorversion == 0) @@ -444,12 +468,16 @@ static void encode_cb_sequence4args(struct xdr_stream *xdr, encode_nfs_cb_opnum4(xdr, OP_CB_SEQUENCE); encode_sessionid4(xdr, session); - p = xdr_reserve_space(xdr, 4 + 4 + 4 + 4 + 4); + p = xdr_reserve_space(xdr, XDR_UNIT * 4); *p++ = cpu_to_be32(session->se_cb_seq_nr[cb->cb_held_slot]); /* csa_sequenceid */ *p++ = cpu_to_be32(cb->cb_held_slot); /* csa_slotid */ *p++ = cpu_to_be32(highest_slotid(session)); /* csa_highest_slotid */ *p++ = xdr_zero; /* csa_cachethis */ - xdr_encode_empty_array(p); /* csa_referring_call_lists */ + + /* csa_referring_call_lists */ + encode_uint32(xdr, cb->cb_nr_referring_call_list); + list_for_each_entry(rcl, &cb->cb_referring_call_list, __list) + encode_referring_call_list4(xdr, rcl); hdr->nops++; } @@ -1306,10 +1334,102 @@ static void nfsd41_destroy_cb(struct nfsd4_callback *cb) nfsd41_cb_inflight_end(clp); } -/* - * TODO: cb_sequence should support referring call lists, cachethis, - * and mark callback channel down on communication errors. +/** + * nfsd41_cb_referring_call - add a referring call to a callback operation + * @cb: context of callback to add the rc to + * @sessionid: referring call's session ID + * @slotid: referring call's session slot index + * @seqno: referring call's slot sequence number + * + * Caller serializes access to @cb. + * + * NB: If memory allocation fails, the referring call is not added. */ +void nfsd41_cb_referring_call(struct nfsd4_callback *cb, + struct nfs4_sessionid *sessionid, + u32 slotid, u32 seqno) +{ + struct nfsd4_referring_call_list *rcl; + struct nfsd4_referring_call *rc; + bool found; + + might_sleep(); + + found = false; + list_for_each_entry(rcl, &cb->cb_referring_call_list, __list) { + if (!memcmp(rcl->rcl_sessionid.data, sessionid->data, + NFS4_MAX_SESSIONID_LEN)) { + found = true; + break; + } + } + if (!found) { + rcl = kmalloc(sizeof(*rcl), GFP_KERNEL); + if (!rcl) + return; + memcpy(rcl->rcl_sessionid.data, sessionid->data, + NFS4_MAX_SESSIONID_LEN); + rcl->__nr_referring_calls = 0; + INIT_LIST_HEAD(&rcl->rcl_referring_calls); + list_add(&rcl->__list, &cb->cb_referring_call_list); + cb->cb_nr_referring_call_list++; + } + + found = false; + list_for_each_entry(rc, &rcl->rcl_referring_calls, __list) { + if (rc->rc_sequenceid == seqno && rc->rc_slotid == slotid) { + found = true; + break; + } + } + if (!found) { + rc = kmalloc(sizeof(*rc), GFP_KERNEL); + if (!rc) + goto out; + rc->rc_sequenceid = seqno; + rc->rc_slotid = slotid; + rcl->__nr_referring_calls++; + list_add(&rc->__list, &rcl->rcl_referring_calls); + } + +out: + if (!rcl->__nr_referring_calls) { + cb->cb_nr_referring_call_list--; + kfree(rcl); + } +} + +/** + * nfsd41_cb_destroy_referring_call_list - release referring call info + * @cb: context of a callback that has completed + * + * Callers who allocate referring calls using nfsd41_cb_referring_call() must + * release those resources by calling nfsd41_cb_destroy_referring_call_list. + * + * Caller serializes access to @cb. + */ +void nfsd41_cb_destroy_referring_call_list(struct nfsd4_callback *cb) +{ + struct nfsd4_referring_call_list *rcl; + struct nfsd4_referring_call *rc; + + while (!list_empty(&cb->cb_referring_call_list)) { + rcl = list_first_entry(&cb->cb_referring_call_list, + struct nfsd4_referring_call_list, + __list); + + while (!list_empty(&rcl->rcl_referring_calls)) { + rc = list_first_entry(&rcl->rcl_referring_calls, + struct nfsd4_referring_call, + __list); + list_del(&rc->__list); + kfree(rc); + } + list_del(&rcl->__list); + kfree(rcl); + } +} + static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata) { struct nfsd4_callback *cb = calldata; @@ -1622,6 +1742,8 @@ void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp, cb->cb_status = 0; cb->cb_need_restart = false; cb->cb_held_slot = -1; + cb->cb_nr_referring_call_list = 0; + INIT_LIST_HEAD(&cb->cb_referring_call_list); } /** diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 74d2d7b42676..b4af840fc4f9 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -64,6 +64,21 @@ typedef struct { refcount_t cs_count; } copy_stateid_t; +struct nfsd4_referring_call { + struct list_head __list; + + u32 rc_sequenceid; + u32 rc_slotid; +}; + +struct nfsd4_referring_call_list { + struct list_head __list; + + struct nfs4_sessionid rcl_sessionid; + int __nr_referring_calls; + struct list_head rcl_referring_calls; +}; + struct nfsd4_callback { struct nfs4_client *cb_clp; struct rpc_message cb_msg; @@ -73,6 +88,9 @@ struct nfsd4_callback { int cb_status; int cb_held_slot; bool cb_need_restart; + + int cb_nr_referring_call_list; + struct list_head cb_referring_call_list; }; struct nfsd4_callback_ops { @@ -777,6 +795,10 @@ extern __be32 nfs4_check_open_reclaim(struct nfs4_client *); extern void nfsd4_probe_callback(struct nfs4_client *clp); extern void nfsd4_probe_callback_sync(struct nfs4_client *clp); extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *); +extern void nfsd41_cb_referring_call(struct nfsd4_callback *cb, + struct nfs4_sessionid *sessionid, + u32 slotid, u32 seqno); +extern void nfsd41_cb_destroy_referring_call_list(struct nfsd4_callback *cb); extern void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp, const struct nfsd4_callback_ops *ops, enum nfsd4_cb_op op); extern bool nfsd4_run_cb(struct nfsd4_callback *cb); diff --git a/fs/nfsd/xdr4cb.h b/fs/nfsd/xdr4cb.h index f1a315cd31b7..f4e29c0c701c 100644 --- a/fs/nfsd/xdr4cb.h +++ b/fs/nfsd/xdr4cb.h @@ -6,8 +6,11 @@ #define cb_compound_enc_hdr_sz 4 #define cb_compound_dec_hdr_sz (3 + (NFS4_MAXTAGLEN >> 2)) #define sessionid_sz (NFS4_MAX_SESSIONID_LEN >> 2) +#define enc_referring_call4_sz (1 + 1) +#define enc_referring_call_list4_sz (sessionid_sz + 1 + \ + enc_referring_call4_sz) #define cb_sequence_enc_sz (sessionid_sz + 4 + \ - 1 /* no referring calls list yet */) + enc_referring_call_list4_sz) #define cb_sequence_dec_sz (op_dec_sz + sessionid_sz + 4) #define op_enc_sz 1 From patchwork Fri Feb 14 15:57:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13975190 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DB99267713 for ; Fri, 14 Feb 2025 15:57:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739548673; cv=none; b=Jvooi3imgKl7v6/WTy8SxeXtdwkZuBjhIMXK8/YnObuiobOJFWKzEYDv4S0r8epFDWjT13TNxjc3FPY2fUc62XLbRl/yubW7Q4WXfc0eYCJ/7uafOapaQxtKmkOuboap0TCEecxjjJcbJdkN6/wYwm8mri1TWmWLnJ6+1IkNWRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739548673; c=relaxed/simple; bh=w9P2crVu2h7w1/R0YW9Pa5PD5aCncf6NJpqcuJWLb70=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gkmMafCckrvGBZkKYtv0H699XgVxCA1PdY688XlKC+ZeY6VOGdtgyJvX9fkt/bYIOxZ3y7Qbqu2xF56ozcnNdYAqz/7ohFnfusQG/ijCrN2g74WM51VO7ixxIBc1CpK9cAhtEBrZVRxY7ZjP7RX5zfe3MpiLbbUKLHkGAmvXb9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nmCj+IYy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nmCj+IYy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E773C4CEDD; Fri, 14 Feb 2025 15:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739548673; bh=w9P2crVu2h7w1/R0YW9Pa5PD5aCncf6NJpqcuJWLb70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmCj+IYy/zgZLwRO4Hlmp4716vr1cd16ayq8Bp45EvKrDwn333ljF1iD/MLG7XTBS +X7RzbVcOaWgrLXaj32CO1QC2KcET3BGTC+XbrH07ot1DmLFviVYYZLMIuot7EQOUv WBm/85P9Q6cxyjlHkmEorYQgD3WVMlMbFYP6CqjUkODihTLxFE2whOw6+mVasSJsb0 DdjmpWDRIIA1ZaONfmgm7Nvg2BXLZOwD3g9tXcSpxxVqMXDT17cAkl8CjQMtgeox/n N1vZwDuqqkFLmOqPHr2TWlsACPh5Ama2IOVu9ZDA/aO+6W/PkByvkA8Qw7Le4qotfW 9fH72GfanzSxg== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever , Trond Myklebust Subject: [RFC PATCH 3/3] NFSD: Use a referring call list for CB_OFFLOAD Date: Fri, 14 Feb 2025 10:57:46 -0500 Message-ID: <20250214155746.18016-4-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250214155746.18016-1-cel@kernel.org> References: <20250214155746.18016-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever Help the client resolve the race between the reply to an asynchronous COPY reply and the associated CB_OFFLOAD callback by planting the session, slot, and sequence number of the COPY in the CB_SEQUENCE contained in the CB_OFFLOAD COMPOUND. Suggested-by: Trond Myklebust Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 9 +++++++++ fs/nfsd/xdr4.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index d09a96cbec1e..48b3f5948640 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1713,6 +1713,7 @@ static int nfsd4_cb_offload_done(struct nfsd4_callback *cb, return 0; } } + nfsd41_cb_destroy_referring_call_list(cb); return 1; } @@ -1845,6 +1846,9 @@ static void nfsd4_send_cb_offload(struct nfsd4_copy *copy) nfsd4_init_cb(&cbo->co_cb, copy->cp_clp, &nfsd4_cb_offload_ops, NFSPROC4_CLNT_CB_OFFLOAD); + nfsd41_cb_referring_call(&cbo->co_cb, &cbo->co_referring_sessionid, + cbo->co_referring_slotid, + cbo->co_referring_seqno); trace_nfsd_cb_offload(copy->cp_clp, &cbo->co_res.cb_stateid, &cbo->co_fh, copy->cp_count, copy->nfserr); nfsd4_run_cb(&cbo->co_cb); @@ -1961,6 +1965,11 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, memcpy(&result->cb_stateid, ©->cp_stateid.cs_stid, sizeof(result->cb_stateid)); dup_copy_fields(copy, async_copy); + memcpy(async_copy->cp_cb_offload.co_referring_sessionid.data, + cstate->session->se_sessionid.data, + NFS4_MAX_SESSIONID_LEN); + async_copy->cp_cb_offload.co_referring_slotid = cstate->slot_idx; + async_copy->cp_cb_offload.co_referring_seqno = cstate->slot->sl_seqid; async_copy->copy_task = kthread_create(nfsd4_do_async_copy, async_copy, "%s", "copy thread"); if (IS_ERR(async_copy->copy_task)) diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 561894ff4b01..e2e6e6d2393d 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -677,6 +677,10 @@ struct nfsd4_cb_offload { __be32 co_nfserr; unsigned int co_retries; struct knfsd_fh co_fh; + + struct nfs4_sessionid co_referring_sessionid; + u32 co_referring_slotid; + u32 co_referring_seqno; }; struct nfsd4_copy {