From mboxrd@z Thu Jan 1 00:00:00 1970 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 102F1154BF0; Mon, 18 Nov 2024 21:19:07 +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=1731964748; cv=none; b=ptXGpzJ6W+Fb4UGNvXvHG09B2tec5iEJIVIoVl+HjQOBEhnemHRcX7F+pMktBGl0aLZE1A+/sTMqhYpYosRTWyJlU9yzgEKRKSg57KtdKozPNs0Mkt4vH6svRKnVeGQxF3RML0+rgs2/RB2txzror42C9LRORARPrKGaYJ/GriM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731964748; c=relaxed/simple; bh=x+ZlJ9WAnrggxSnSnHZz4wUcD0sX0yp4+zH+mfS8b8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DNLm2ztRBsfqa1q50hGR/lGKO0ZS4KKzjhxX/bl36ycYN5QXClsoVG/g393KEtX2i/suFwqQv1OdKgoO16QK2iBbn4GIUALt/vcsi6SKllPbHT0qPeIlBKHUNEkAfKfnMBUOhrStB5S3dZmGIAi7TLD5iGxCixECnbo/rAdXFNk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wb+CcC8H; 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="Wb+CcC8H" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22599C4CECF; Mon, 18 Nov 2024 21:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731964747; bh=x+ZlJ9WAnrggxSnSnHZz4wUcD0sX0yp4+zH+mfS8b8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wb+CcC8Hmm76YFlpWqcRbvfVIBCrEwlhN7LOQUTJEQyJ5nb+McyQapDOekb1949/b XE4URKQRk8Gh6J2wgSQ1OiIjHAhKx8uqZekUuJmXcT1wPIhKhplunCTcQQ7OqC5G32 YTZxJhU0TWGYlgdCvznXc0Ee5hTrHyMQlhVBzT/AXHlT0iC6owuhOWCZix/eKX9o4S D4gASKT5NCatXyMzw2NRc/2zoeuYacXQXHJvrD2kF6ya/G0X4QyIdyKnF03u2B1gaA nrFnWqus0RpVSSAK/J0MHq72MUw8kRIWoqZ7GRIVhva0d5kjQt2sOPgPKiD81/1yD8 yQwq5kwoMqhhA== From: cel@kernel.org To: Cc: , Jeff Layton , Chuck Lever Subject: [PATCH 6.1 2/5] NFSD: Async COPY result needs to return a write verifier Date: Mon, 18 Nov 2024 16:18:57 -0500 Message-ID: <20241118211900.3808-3-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241118211900.3808-1-cel@kernel.org> References: <20241118211900.3808-1-cel@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chuck Lever [ Upstream commit 9ed666eba4e0a2bb8ffaa3739d830b64d4f2aaad ] Currently, when NFSD handles an asynchronous COPY, it returns a zero write verifier, relying on the subsequent CB_OFFLOAD callback to pass the write verifier and a stable_how4 value to the client. However, if the CB_OFFLOAD never arrives at the client (for example, if a network partition occurs just as the server sends the CB_OFFLOAD operation), the client will never receive this verifier. Thus, if the client sends a follow-up COMMIT, there is no way for the client to assess the COMMIT result. The usual recovery for a missing CB_OFFLOAD is for the client to send an OFFLOAD_STATUS operation, but that operation does not carry a write verifier in its result. Neither does it carry a stable_how4 value, so the client /must/ send a COMMIT in this case -- which will always fail because currently there's still no write verifier in the COPY result. Thus the server needs to return a normal write verifier in its COPY result even if the COPY operation is to be performed asynchronously. If the server recognizes the callback stateid in subsequent OFFLOAD_STATUS operations, then obviously it has not restarted, and the write verifier the client received in the COPY result is still valid and can be used to assess a COMMIT of the copied data, if one is needed. Reviewed-by: Jeff Layton [ cel: adjusted to apply to origin/linux-6.1.y ] Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 50f17cee8bcf..b8fb37cc59c4 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -717,15 +717,6 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, &access->ac_supported); } -static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net) -{ - __be32 *verf = (__be32 *)verifier->data; - - BUILD_BUG_ON(2*sizeof(*verf) != sizeof(verifier->data)); - - nfsd_copy_write_verifier(verf, net_generic(net, nfsd_net_id)); -} - static __be32 nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) @@ -1593,7 +1584,6 @@ static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync) test_bit(NFSD4_COPY_F_COMMITTED, ©->cp_flags) ? NFS_FILE_SYNC : NFS_UNSTABLE; nfsd4_copy_set_sync(copy, sync); - gen_boot_verifier(©->cp_res.wr_verifier, copy->cp_clp->net); } static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy, @@ -1764,9 +1754,14 @@ static __be32 nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) { - struct nfsd4_copy *copy = &u->copy; - __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); struct nfsd4_copy *async_copy = NULL; + struct nfsd4_copy *copy = &u->copy; + struct nfsd42_write_res *result; + __be32 status; + + result = ©->cp_res; + nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn); copy->cp_clp = cstate->clp; if (nfsd4_ssc_is_inter(copy)) { @@ -1786,8 +1781,6 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, memcpy(©->fh, &cstate->current_fh.fh_handle, sizeof(struct knfsd_fh)); if (nfsd4_copy_is_async(copy)) { - struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); - status = nfserrno(-ENOMEM); async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL); if (!async_copy) @@ -1799,8 +1792,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out_err; if (!nfs4_init_copy_state(nn, copy)) goto out_err; - memcpy(©->cp_res.cb_stateid, ©->cp_stateid.cs_stid, - sizeof(copy->cp_res.cb_stateid)); + memcpy(&result->cb_stateid, ©->cp_stateid.cs_stid, + sizeof(result->cb_stateid)); dup_copy_fields(copy, async_copy); async_copy->copy_task = kthread_create(nfsd4_do_async_copy, async_copy, "%s", "copy thread"); -- 2.47.0 From mboxrd@z Thu Jan 1 00:00:00 1970 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 DCDA914D2A3 for ; Tue, 19 Nov 2024 04:36:19 +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=1731990979; cv=none; b=pp//lbRZfeztOZlsDk8xwwLnD2r8o+FLErsGs/m4FtsSajVwj+y/Iw4+M8F2+ZndMviYrEAa54vMadsHmswq+F0aQaVP+DUn3vuuBiVbVTwwWxg/TTDNsD5m6u72VwPpMz0vl7yF9TGoehtJr5xySQqdVaEYRMwYjVlXUn7oeBQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990979; c=relaxed/simple; bh=5OeTZEjogVamaJqNf3Vn3WIJS2sF/6VICcYgwtJuaNI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rpcwu4bXuYj2KVzr0b7IO0UJnLECx4LIXHqXrjX3DX2hNRzVqcGTGy4jGDScflRyERTtNhELBCKmz7oWmWkYjGLGfjNwjDJNAM+AXyuBe4paLa8RfTAakIbfNjm0VUryC97PVWq80A5NEZFLRZedhTWZDqx+1KrU0Zplep5gZQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XSCXp5xK; 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="XSCXp5xK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C890C4CED1; Tue, 19 Nov 2024 04:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731990979; bh=5OeTZEjogVamaJqNf3Vn3WIJS2sF/6VICcYgwtJuaNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XSCXp5xKCo5Xpubzux+khdaL2r1cqRAPn83ycD8ADvlM8/F+wNGfI70oKsiAtSs0H 6QQRR+HBjEcRLAORQiaCB7HM8PTVX69A2iog2lPkrRwmikEdUI04iYNfTvJgAq8O9P gOg/7yNLpLnGYNzuPme8gZURYAmkD6xM5DoIL3Nq+gLP1nuj3/RBY2+2NfSbuHEPqa xYghE0xXnrYJw4U1WA74o1JkxXvXyJAsWA0WnIl6qswSMbpbN7hSqzyxIFAfZOTHhV 5O19tABeXdNHKQPLjXg4984X2ssjb6CKAQpa7lOVHLZfZmcyRrfz0dWO0z/hcGKp3m I04gmf3gKm4SA== From: Sasha Levin To: stable@vger.kernel.org Cc: cel@kernel.org, Sasha Levin Subject: Re: [PATCH 6.1 2/5] NFSD: Async COPY result needs to return a write verifier Date: Mon, 18 Nov 2024 23:36:17 -0500 Message-ID: <20241118211900.3808-3-cel@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241118211900.3808-3-cel@kernel.org> References: Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: <20241119043617.1LNtCfLgmRTsZ8WdoNSzGc4yzL2vUHqyhm-JnrZUnu4@z> [ Sasha's backport helper bot ] Hi, The upstream commit SHA1 provided is correct: 9ed666eba4e0a2bb8ffaa3739d830b64d4f2aaad WARNING: Author mismatch between patch and upstream commit: Backport author: cel@kernel.org Commit author: Chuck Lever Commit in newer trees: |-----------------|----------------------------------------------| | 6.11.y | Present (different SHA1: ea5fb07d126d) | | 6.6.y | Not found | | 6.1.y | Not found | |-----------------|----------------------------------------------| Note: The patch differs from the upstream commit: --- --- - 2024-11-18 23:09:20.596467234 -0500 +++ /tmp/tmp.hSLD74MWP5 2024-11-18 23:09:20.590908718 -0500 @@ -1,3 +1,5 @@ +[ Upstream commit 9ed666eba4e0a2bb8ffaa3739d830b64d4f2aaad ] + Currently, when NFSD handles an asynchronous COPY, it returns a zero write verifier, relying on the subsequent CB_OFFLOAD callback to pass the write verifier and a stable_how4 value to the client. @@ -25,16 +27,17 @@ is needed. Reviewed-by: Jeff Layton +[ cel: adjusted to apply to origin/linux-6.1.y ] Signed-off-by: Chuck Lever --- - fs/nfsd/nfs4proc.c | 23 ++++++++--------------- - 1 file changed, 8 insertions(+), 15 deletions(-) + fs/nfsd/nfs4proc.c | 25 +++++++++---------------- + 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c -index 963a02e179a0a..231c6035602f6 100644 +index 50f17cee8bcf..b8fb37cc59c4 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c -@@ -752,15 +752,6 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, +@@ -717,15 +717,6 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, &access->ac_supported); } @@ -50,7 +53,7 @@ static __be32 nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) -@@ -1632,7 +1623,6 @@ static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync) +@@ -1593,7 +1584,6 @@ static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync) test_bit(NFSD4_COPY_F_COMMITTED, ©->cp_flags) ? NFS_FILE_SYNC : NFS_UNSTABLE; nfsd4_copy_set_sync(copy, sync); @@ -58,30 +61,24 @@ } static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy, -@@ -1805,9 +1795,11 @@ static __be32 +@@ -1764,9 +1754,14 @@ static __be32 nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) { +- struct nfsd4_copy *copy = &u->copy; +- __be32 status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); -+ struct nfsd4_copy *async_copy = NULL; - struct nfsd4_copy *copy = &u->copy; + struct nfsd4_copy *async_copy = NULL; ++ struct nfsd4_copy *copy = &u->copy; + struct nfsd42_write_res *result; - __be32 status; -- struct nfsd4_copy *async_copy = NULL; - - /* - * Currently, async COPY is not reliable. Force all COPY -@@ -1816,6 +1808,9 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, - */ - nfsd4_copy_set_sync(copy, true); - ++ __be32 status; ++ + result = ©->cp_res; + nfsd_copy_write_verifier((__be32 *)&result->wr_verifier.data, nn); -+ + copy->cp_clp = cstate->clp; if (nfsd4_ssc_is_inter(copy)) { - trace_nfsd_copy_inter(copy); -@@ -1840,8 +1835,6 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, +@@ -1786,8 +1781,6 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, memcpy(©->fh, &cstate->current_fh.fh_handle, sizeof(struct knfsd_fh)); if (nfsd4_copy_is_async(copy)) { @@ -90,7 +87,7 @@ status = nfserrno(-ENOMEM); async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL); if (!async_copy) -@@ -1853,8 +1846,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, +@@ -1799,8 +1792,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out_err; if (!nfs4_init_copy_state(nn, copy)) goto out_err; @@ -101,3 +98,6 @@ dup_copy_fields(copy, async_copy); async_copy->copy_task = kthread_create(nfsd4_do_async_copy, async_copy, "%s", "copy thread"); +-- +2.47.0 + --- Results of testing on various branches: | Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.1.y | Success | Success |