From patchwork Wed Aug 28 17:40:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13781626 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 992EB1A4F15 for ; Wed, 28 Aug 2024 17:40:15 +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=1724866815; cv=none; b=Edds5ULNc0EUKOjsn3IrR1rdHnNL6vxhV2iI6S57PTAvmhaapA6O2uY9mDbdTmZ7AbcErk1vEygXEKB2tuCsjL/5/xtdBNaSw6OFfqLGc2HAgAQDTA3E7Npt/DdDG+plQwYlwZfU4levys1B1SiPM6Rvn2qMdJi6Dfqvrn5rgH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724866815; c=relaxed/simple; bh=6oFDHWl9ASZRRqKca6rJtTNEg2+eX4CfpH82kVFivvw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tVl/aXryLTIID1BEtat/7BH4hoLtNpL4D40WqSjrcH5AUOMVeGyEfpmJWVJ/85Rp1ikGQD9aGe4465VLmd5ZlCwTg/ZTrqE5BPXnpq5L8/ymLn+1TMdklQNZ6y3vwrp2GUjSIYoFZAqVrQCN7vqZat1IpAPpcMYZIcwgH6WQlyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fl6bnOAi; 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="fl6bnOAi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0E59C4CEC1; Wed, 28 Aug 2024 17:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724866815; bh=6oFDHWl9ASZRRqKca6rJtTNEg2+eX4CfpH82kVFivvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fl6bnOAi79TlLt6gVMYT0wRL3ojfl/q7qIEZ1nTBGIHH+yynNv48z0lVOCBzK8N0b 7DzUZVtNoveIf/DZemGc+slm6cccbD/zjV01qMZcXLWFJaOKFuxriMJ8MMwth4AScL vNMVn4nU8M6f8Hdros24C6lYAFV+r8nNhHMtZ2WSRHlyzu/zEZBuAaFXFse508vH21 h5aHPbNhm31k+pKMQ8sfE386QWjcaHPGohgWELx/njucrFj8t+7lBUgas2Hzp6B3Fp yylUpDyeQMDLK/ybYfb1tK4LK1I+4JB2br/p2OOnPAiCc3mg0nVfRtjORXkEf6RK3R 1YghYREjCiKPw== From: cel@kernel.org To: Cc: Olga Kornievskaia , Dai Ngo , Jeff Layton , Chuck Lever Subject: [RFC PATCH 1/7] NFSD: Async COPY result needs to return a write verifier Date: Wed, 28 Aug 2024 13:40:03 -0400 Message-ID: <20240828174001.322745-10-cel@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828174001.322745-9-cel@kernel.org> References: <20240828174001.322745-9-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4213; i=chuck.lever@oracle.com; h=from:subject; bh=K/lF++1pminDy6pTIOKTccQ4D/b/G5sJcZBdqmrNj4o=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmz2D6jI7oEBfZa87kARZg0yFbwQc8EGOD7/Cre s/5ULkv4H2JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZs9g+gAKCRAzarMzb2Z/ l8ZVD/4qCsjQVCc6EWKKWbMvM8JRBpahKKkV+5aBUDjhXSOBpWjKrEGun5+xC7QxMFMn6F26Xmf 0MpwOrivwYDh1W2YHLLo2w6lHO5zxAiLX9CofX3XGTviZdC2XtGoG/U8YWlOlNFEWplPQuy+7X1 FJrzTwu6PwMuxcD9B2AgZe+C/zbhFIllW/OviERn/Epg5H04kpo8fHgsYorAT8oFG9O8BpfyVD7 SVIf591iJXjsAfwzxa5G/gOIZKXmphgXIOE6cbMHV/H62P9CaLOpuyQqwAcPlXRs5Mt4wBzOsI8 nFxW2DYNb3Z3AAeXKWUPb1MZyId17WVChQXGEIe7IzEZD9x7z+zVNB8JHAt3aMtsOQI1peNr7c5 zpXjfKQSzfO0TmVfpUK3oxwtmsJa0vLS8qTOYYyfwwiiiHp6tF7LPHPvY29KrXgXR+MzxFC+NV3 xv//SSas23GEiLVXxI2jT/a5/di+/40XMMTdJnmS9M9wUNYzWT1AtEX6NChZFMYkh0fL4Gi6X6T oEWGLlAUwu2RbuGvsxO5MCdy2bKX5jI03nkeiwzYMTmAHA/x5WU4sSBFCzgMUN9b5Pu3hdckcvZ cL5qoZboLGe0HXdjl5faXPOH4CL8h3TsPfMpSlpE7RWy0RXkt9XNKtwwA35vEEQXsB2pRMROOBl ldxFjhArbXQoTJg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever 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. Signed-off-by: Chuck Lever Reviewed-by: Jeff Layton --- 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 2e39cf2e502a..60c526adc27c 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -751,15 +751,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) @@ -1630,7 +1621,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, @@ -1803,9 +1793,11 @@ 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; /* * Currently, async COPY is not reliable. Force all COPY @@ -1814,6 +1806,9 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, */ nfsd4_copy_set_sync(copy, true); + 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); @@ -1838,8 +1833,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) @@ -1851,8 +1844,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"); From patchwork Wed Aug 28 17:40:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13781627 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 76E5E1A4F15; Wed, 28 Aug 2024 17:40:16 +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=1724866816; cv=none; b=caVhhtAMLJUDLcSG51JNju79hUivK2dhz78v1RoTwgA2bEskqqj9A9wCa/mrfFQXy16Shss3Vv6PwX0MAFqaRinzGYpuk5NSZ3et02GaWNriXcW2k5Qrf/3v5bNcz52pORjVt3m1xWH5UKzLR1m9Stw5IGSKgadsQ4r8m8cVYeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724866816; c=relaxed/simple; bh=+orhpqbhYE73syn3xRae0ko0GUimh1gok3+JeXs6uDg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QECQga8Fqhxn+gG+qtyIsYGQW4dLiYPNS5QG+vcDcmXjAdOf49Z8o9/syptedGuMywZB8sDswPq6z7Kj37/eIehLryXA0drhL2pHiWOew1DKzKuC9eWgi0TXjb+BkzfdVR3M1sTlKT/x8JjX2GTlHq4l43rGJe/IfIAhNn6iegU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aSf5Lsk/; 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="aSf5Lsk/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B67F7C4CEC0; Wed, 28 Aug 2024 17:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724866816; bh=+orhpqbhYE73syn3xRae0ko0GUimh1gok3+JeXs6uDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aSf5Lsk/HF8PJlGzIT13stZDjoRppbHnyg67V3Vw1VahRPiZ3lzaMarZBZJGNbRvf vgGs9SbpgCPFa0nTvhAQWanawZewQo+/VnC5bL8FqoomKMHNaLSn14B2ZpCGlgLRTM thvKUOKUyTY7TtVdnlShiIQmInoqXk4qdGJkPKA2jWjEzycgWjBdo5RiMirYXdu3ol P7G5GxvJQKRj0CBINKFWyeR2AlxaxO6elOK5vU4Vtbp48K4sHAckuOvNcz38uYjYZA w2SqM/a0yr/qmT6mo3SQJ6q/3dJjh7erFK/OGHpOk4qrbfUdczlk9ZnimjR36en3RH W+G1yWek8dMTg== From: cel@kernel.org To: Cc: Olga Kornievskaia , Dai Ngo , Jeff Layton , Chuck Lever , stable@vger.kernel.org Subject: [RFC PATCH 2/7] NFSD: Limit the number of concurrent async COPY operations Date: Wed, 28 Aug 2024 13:40:04 -0400 Message-ID: <20240828174001.322745-11-cel@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828174001.322745-9-cel@kernel.org> References: <20240828174001.322745-9-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3621; i=chuck.lever@oracle.com; h=from:subject; bh=VEBWKnuVul4SKhnXBt8l9TWqaWgmVvsUzjYpWA+H0Ig=; b=kA0DAAgBM2qzM29mf5cByyZiAGbPYPqglbuRPJal4DFBuKhVlkGJYND5XDEQ0m42OIf14G4d+ 4kCMwQAAQgAHRYhBCiy5bASht8kPPI+/jNqszNvZn+XBQJmz2D6AAoJEDNqszNvZn+XEyEQAKlS vVcXhCSvVdM3Fp2oHwWJ0bOHDKsN1dSUFg6ZQ+OjmxKP9boLlTYofM8+YC8IVQTa/2IB4Ud03eE 9YxhLDldW5Jncdy2C4z6Z9xr4woSvcJkFaJDOoM6zdGpqCrLjcnce7pgReESP/+T5mKNftngnYR pD0U2gsbx3bRxjWDQmNaEtTeJlghYdvwsBOMiT7uGI+hBvzIgUgzEz1bZG93eL5gd5oQcoDvUQz v7+E8e+I3Ss2fvZKI1/fBUA1PndyQ9pxNEJxjzSLrVAY7onVFi7+xmg21oGfANj2DcF5u/Voscs uBdgnKjvX2ftxCNCAYh+GzhvRHbgSeDT1O/abY8iQ62tLQLoFiWxLaNwsUY6bR2LAx8pbBvd4TH KXy8lPJwxbGHVt99lvG+o3h5NR3kQi9zaPxPTZuy17ygaWk4fm+fJaLzPJBOJdqs+nDufjpy5SG iNo9qJP29SkcWVXbMe8CoJ7JYMiKwbgRBBEJm/ZAOIZxP/EuoIyH4DN6XxV9b+fJU7EqRMNKHd2 7BsM+b+bby0XT3QxQHwUe1PIDB8PlzHsEfVGujBNEAPXarVrdX5XMzBq1L8cYji6K/B2K2a2YDF pMOZk+JorjC69CCtRTIFghhgQ/EntzXvM1BeJMWJswSMYbv07mIR3dGKXrkwv3c4D1H0ywh6jr0 GgfN8 X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Nothing appears to limit the number of concurrent async COPY operations that clients can start. In addition, AFAICT each async COPY can copy an unlimited number of 4MB chunks, so can run for a long time. Thus IMO async COPY can become a DoS vector. Add a restriction mechanism that bounds the number of concurrent background COPY operations. Start simple and try to be fair -- this patch implements a per-namespace limit. An async COPY request that occurs while this limit is exceeded gets NFS4ERR_DELAY. The requesting client can choose to send the request again after a delay or fall back to a traditional read/write style copy. If there is need to make the mechanism more sophisticated, we can visit that in future patches. Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever Reviewed-by: Jeff Layton --- fs/nfsd/netns.h | 1 + fs/nfsd/nfs4proc.c | 12 ++++++++++-- fs/nfsd/nfs4state.c | 1 + fs/nfsd/xdr4.h | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 14ec15656320..5cae26917436 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -148,6 +148,7 @@ struct nfsd_net { u32 s2s_cp_cl_id; struct idr s2s_cp_stateids; spinlock_t s2s_cp_lock; + atomic_t pending_async_copies; /* * Version information diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 60c526adc27c..27f7eceb3b00 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1279,6 +1279,7 @@ static void nfs4_put_copy(struct nfsd4_copy *copy) { if (!refcount_dec_and_test(©->refcount)) return; + atomic_dec(©->cp_nn->pending_async_copies); kfree(copy->cp_src); kfree(copy); } @@ -1833,10 +1834,17 @@ 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)) { - status = nfserrno(-ENOMEM); + /* Arbitrary cap on number of pending async copy operations */ + int nrthreads = atomic_read(&rqstp->rq_pool->sp_nrthreads); + async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL); if (!async_copy) goto out_err; + async_copy->cp_nn = nn; + if (atomic_inc_return(&nn->pending_async_copies) > nrthreads) { + atomic_dec(&nn->pending_async_copies); + goto out_err; + } INIT_LIST_HEAD(&async_copy->copies); refcount_set(&async_copy->refcount, 1); async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL); @@ -1876,7 +1884,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, } if (async_copy) cleanup_async_copy(async_copy); - status = nfserrno(-ENOMEM); + status = nfserr_jukebox; goto out; } diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index a20c2c9d7d45..aaebc60cc77c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -8554,6 +8554,7 @@ static int nfs4_state_create_net(struct net *net) spin_lock_init(&nn->client_lock); spin_lock_init(&nn->s2s_cp_lock); idr_init(&nn->s2s_cp_stateids); + atomic_set(&nn->pending_async_copies, 0); spin_lock_init(&nn->blocked_locks_lock); INIT_LIST_HEAD(&nn->blocked_locks_lru); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index fbdd42cde1fa..2a21a7662e03 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -713,6 +713,7 @@ struct nfsd4_copy { struct nfsd4_ssc_umount_item *ss_nsui; struct nfs_fh c_fh; nfs4_stateid stateid; + struct nfsd_net *cp_nn; }; static inline void nfsd4_copy_set_sync(struct nfsd4_copy *copy, bool sync) From patchwork Wed Aug 28 17:40:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13781628 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 3B58F1A4F15 for ; Wed, 28 Aug 2024 17:40:17 +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=1724866817; cv=none; b=LibHlWDmvJqNF06nrm/W4Y8ps9AdaIhv4eTglH+zpIyG95Bf4npTtP1LVNwiXb54FMCi4h3hKCylQQKgrFejypNAo9tYGBAIigbPrvuPCquJedTnLX1KuLVW5JpGaWtysPWTHa/A+H6bLIKSQIGwOjincXfgab2zfp5FiUcgBko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724866817; c=relaxed/simple; bh=oKbO+JltJlOnXD4peAa6mLTPzL9OzrmLezFkCPts63g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EDNi8/bGhPYxlBccPb1t96hB8zHGs+UXh2lHi8jUV7lMt07Y8ERzZGmV9zyubi3J6o/2cocq/l+KPgyxKL0dwX1pbjHefwFnTygKgdHctWUujicrQ9i9o4IlpaF0O9qFCpkT6T4kWhusNGhx3CkIU7uf60kThR7TApWBlhS1+gg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kzX6bDGR; 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="kzX6bDGR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9280EC4CEC2; Wed, 28 Aug 2024 17:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724866817; bh=oKbO+JltJlOnXD4peAa6mLTPzL9OzrmLezFkCPts63g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kzX6bDGRq3zLEbY7LbnB8R8FA0NgpRL0T0mGdadA/A8LV3Eh+Eb4oVfG5ra6qQBRZ SfiCtSQvZYFUptGLp3T9hGTrj08BQIOhM1TILxG0hSEo15QkeJdmHuFOFsrXQSN5Ai k/eSf3wJl/ucKWB0pSA04qQfoJKiBNWSqGijsNjvuFNSDEK7zcNfUVKxf4gfFzYlsj 8+UATAuuOnOHXpPD28q42B0QnZFl1Qxq/m6UKOOGo3rCPXeKwDovGvJzOI5kbmiuEB 4ngMGnhjSI5hQ26Xq3lPNxTjVkR6hFi0Mo5oBDd+AbmGdmSVTsG8lqrDya+TnCzv3z 4IrFm1QRXtW9w== From: cel@kernel.org To: Cc: Olga Kornievskaia , Dai Ngo , Jeff Layton , Chuck Lever Subject: [RFC PATCH 3/7] NFSD: Display copy stateids with conventional print formatting Date: Wed, 28 Aug 2024 13:40:05 -0400 Message-ID: <20240828174001.322745-12-cel@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828174001.322745-9-cel@kernel.org> References: <20240828174001.322745-9-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1421; i=chuck.lever@oracle.com; h=from:subject; bh=/y9b7DgVsvjf36gzPBQSIiSN73wExXN0lZK9iTtABsc=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmz2D67dZmsuz44/APgh8zvzLvEBaiELbr4E2Kr nSHc2wWng+JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZs9g+gAKCRAzarMzb2Z/ l2MWD/0VtT6mx6mk01vQR+xvYLl2snL0L/ATQbSkKIiFhj4xdamY0qE7koyoMSi9TaeFhEENRgk AUaGouCXS+WCZfNHGfXhOFPMV2avop7sJ95vNkHed3WPRX/6dI5xND1c2fpWcFzG52V9ePWToz3 ClxtCZoAvjrFhNyNtaNZXIovAwkkTHkXegvgMW+yNWWmGFFykfPWL2xIg62qut/xfZiadeKEcJN fRU3PNSLWet72AexMW/mypWHxMhyU3S0PJeb5dJ0hwxGeF7BZ8tOJS1PROqkfjawlvVBz1eul52 rvj3yjnlShkP+GOPdNTpqCUDQNdeojbdXKLeP5wusoBs1fQ/6Eye8HTTSe7/4PD6V4dRfxhZglG VrrOeAWGI9UL5MDmL4mit3D1pk1t9vQf9v5P+PZd/urDsoU2nJCcG/+CyzSnOTWHsx+rJlvOAiv klDz0oWOx123qMyq3ihkeUgc2NPqxXsXxfvF1Al6U0wjWHXxGI/sudHFE+MjI+ZRpDzzuAYK0Pe igmYtUQDOgNVmMDoztZeU736ccQtVIetvdUtfR+BFKKI5Ji9gQvkdzXqkWM/chJxmRsG7ninFPb ccY3KNFFX6RQHiJrboomQ2YHSpNq5iKXQ7j/yg6siDWGWWw2RemQVoO3sHV3cpR/Wxq7DABHFTj meIDgyIhxR1pttg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Make it easier to grep for s2s COPY stateids in trace logs: Use the same display format in nfsd_copy_class as is used to display other stateids. Signed-off-by: Chuck Lever --- fs/nfsd/trace.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 77bbd23aa150..e61109d97b4e 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -2153,14 +2153,14 @@ DECLARE_EVENT_CLASS(nfsd_copy_class, sizeof(struct sockaddr_in6)); ), TP_printk("client=%pISpc intra=%d async=%d " - "src_stateid[si_generation:0x%x cl_boot:0x%x cl_id:0x%x so_id:0x%x] " - "dst_stateid[si_generation:0x%x cl_boot:0x%x cl_id:0x%x so_id:0x%x] " + "src_client %08x:%08x src_stateid %08x:%08x " + "dst_client %08x:%08x dst_stateid %08x:%08x " "cp_src_pos=%llu cp_dst_pos=%llu cp_count=%llu", __get_sockaddr(addr), __entry->intra, __entry->async, - __entry->src_si_generation, __entry->src_cl_boot, - __entry->src_cl_id, __entry->src_so_id, - __entry->dst_si_generation, __entry->dst_cl_boot, - __entry->dst_cl_id, __entry->dst_so_id, + __entry->src_cl_boot, __entry->src_cl_id, + __entry->src_so_id, __entry->src_si_generation, + __entry->dst_cl_boot, __entry->dst_cl_id, + __entry->dst_so_id, __entry->dst_si_generation, __entry->src_cp_pos, __entry->dst_cp_pos, __entry->cp_count ) ); From patchwork Wed Aug 28 17:40:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13781629 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 053DF1A4F15 for ; Wed, 28 Aug 2024 17:40:18 +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=1724866818; cv=none; b=riKOEqU6oz6bKqyQJi7r/fLrv/eJ0AC4RQaADo68/uhwuRTq7+U3YWYCPXmwxInStsFW0ipV2j4+IMzxadeMcbOuZQ5pnAt4gNNDIe+qOwff1QwijCP0HSaTDYsAGyeNmPoJMDZZoWA2eRXWH5fruruFy2IEj+v/YAtMTvsdiTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724866818; c=relaxed/simple; bh=nkIpk0AeCLnLLAjlyBLAyRkfPW8+BODdD91xKkaweB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YfnY0ZpDtl+UnDl8Baf3AZAvMFS91FXv7eH87wrSwSFqSonjeLD7XBGKk2q8IvBQcCsagFrNRHjo7CVCGtyyb5Ny5+4Tb7mAn4KKUQ8jeAcPUYQx1JUt3gCgF/GfwGNrzA7jAyPj3HeWFD6CXxUFA9He6+JH2oIWjnPDVVQI8uI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=evseel4y; 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="evseel4y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59E40C4CEC4; Wed, 28 Aug 2024 17:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724866817; bh=nkIpk0AeCLnLLAjlyBLAyRkfPW8+BODdD91xKkaweB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=evseel4yYQVvprMfftMRVP8Y+Ro8Seiph4yzU5TgNNOxwIE4oG/t5nQ1t7A7HgLhx vvJ5NmU0CLuK2IRUQcKhmEHKau+VpDJlQ7cpEgkEgriJrdnRki6LnJ/m1KPPuSh/KJ Jq61oyBm2BNa/6GNMbLFqGSmRTSKLw98evux2bdFCtaX9Nqq8A1xInh3AFqlT6eNFj a38uJYReuiMZFZb8Oo++4AAe5C2R31qgxgjl598ncN3ANKp94jbSZ2JBhxrZoMK7zx vKAm3hSfx9hysrfUkAFBVsvjVodUNVVe7VCrBUKayv83QXtTsqz3T6n8nGaoddGG93 KaLpQIfDcUOgw== From: cel@kernel.org To: Cc: Olga Kornievskaia , Dai Ngo , Jeff Layton , Chuck Lever Subject: [RFC PATCH 4/7] NFSD: Record the callback stateid in copy tracepoints Date: Wed, 28 Aug 2024 13:40:06 -0400 Message-ID: <20240828174001.322745-13-cel@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828174001.322745-9-cel@kernel.org> References: <20240828174001.322745-9-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2391; i=chuck.lever@oracle.com; h=from:subject; bh=qlXc64DJ02glSt67PnaT8N/CZaF6iS/i2ccVMBwKxhA=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmz2D6WhK9whip6E1bpMSIu3I8yCvQb6iVgSu7T JKyBeohIbyJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZs9g+gAKCRAzarMzb2Z/ l6ihEACfvzQYxGYTP62q71JpxO4+X9edlXj21aTFarrB+8JEuhQIM9wVdVj1ieWv75502cjWqRd JblrDowji0tqyupEmemWshijLbqUSDI9mJ+eBsYtqF0MJb+Ihu+2sQ0ZHCcc6/njtt3YHUehjY/ TZx5PheMASXI5lkmR+F6/tTJ9q7Fdnhphrmmj5zzoEqMuWufea2HSVeLH2QC9hmleudqTgddMiU QbuxHMv7ZA+PrvRyLODp7Fcrxi0s4u7o56pIA9qMWxDht6rJ0WT81eEWJjPFnarv3wO5zqApqGc gwj3muhzLoX5a5jUzgdFrx5mhcNpuQoULm6yBl+gSQGo/5eGRY3zvHp1/zFPeIgbjZsm1vhclPm ZfRLTRUEuHWkqgQssSx/HrbMFL6Zne8I77BUuL0RaISp2F1KWF78ND90Aa9rS2z0LFvJsAo3unl hqgwoU1d9JJ02QSmxMueOS9xDeJSMEijW8+y5Xwo3LUHEwE/PmpoxzepqyUp7PElSco+gjJLeBk CDLoY+j6Hq5xs2L6Ps1N8feDRKgfx3ZjGv3g0qXfaVP8AmQD6R6dR8I6ANULPScu1XD+XeiU9QS PXpOVC/3BKDSsabj9POBSue3W6TiemQu9MbvSvdPBt5jZ2mvJgOXI7hFvTCZ/4ai0sYlJgA8MwC O/AintBlVjx+3jw== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Match COPY operations up with CB_OFFLOAD operations. Signed-off-by: Chuck Lever --- fs/nfsd/trace.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index e61109d97b4e..61ca9632021d 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -2127,6 +2127,10 @@ DECLARE_EVENT_CLASS(nfsd_copy_class, __field(u32, dst_cl_id) __field(u32, dst_so_id) __field(u32, dst_si_generation) + __field(u32, cb_cl_boot) + __field(u32, cb_cl_id) + __field(u32, cb_so_id) + __field(u32, cb_si_generation) __field(u64, src_cp_pos) __field(u64, dst_cp_pos) __field(u64, cp_count) @@ -2135,6 +2139,7 @@ DECLARE_EVENT_CLASS(nfsd_copy_class, TP_fast_assign( const stateid_t *src_stp = ©->cp_src_stateid; const stateid_t *dst_stp = ©->cp_dst_stateid; + const stateid_t *cb_stp = ©->cp_res.cb_stateid; __entry->intra = test_bit(NFSD4_COPY_F_INTRA, ©->cp_flags); __entry->async = !test_bit(NFSD4_COPY_F_SYNCHRONOUS, ©->cp_flags); @@ -2146,6 +2151,10 @@ DECLARE_EVENT_CLASS(nfsd_copy_class, __entry->dst_cl_id = dst_stp->si_opaque.so_clid.cl_id; __entry->dst_so_id = dst_stp->si_opaque.so_id; __entry->dst_si_generation = dst_stp->si_generation; + __entry->cb_cl_boot = cb_stp->si_opaque.so_clid.cl_boot; + __entry->cb_cl_id = cb_stp->si_opaque.so_clid.cl_id; + __entry->cb_so_id = cb_stp->si_opaque.so_id; + __entry->cb_si_generation = cb_stp->si_generation; __entry->src_cp_pos = copy->cp_src_pos; __entry->dst_cp_pos = copy->cp_dst_pos; __entry->cp_count = copy->cp_count; @@ -2155,12 +2164,15 @@ DECLARE_EVENT_CLASS(nfsd_copy_class, TP_printk("client=%pISpc intra=%d async=%d " "src_client %08x:%08x src_stateid %08x:%08x " "dst_client %08x:%08x dst_stateid %08x:%08x " + "cb_client %08x:%08x cb_stateid %08x:%08x " "cp_src_pos=%llu cp_dst_pos=%llu cp_count=%llu", __get_sockaddr(addr), __entry->intra, __entry->async, __entry->src_cl_boot, __entry->src_cl_id, __entry->src_so_id, __entry->src_si_generation, __entry->dst_cl_boot, __entry->dst_cl_id, __entry->dst_so_id, __entry->dst_si_generation, + __entry->cb_cl_boot, __entry->cb_cl_id, + __entry->cb_so_id, __entry->cb_si_generation, __entry->src_cp_pos, __entry->dst_cp_pos, __entry->cp_count ) ); From patchwork Wed Aug 28 17:40:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13781630 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 BFA341A4F15 for ; Wed, 28 Aug 2024 17:40:18 +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=1724866818; cv=none; b=gNaqnlIWSYwPktD2PICH6ts96Kj6a5/CiICxe5UvBt/x9qOxXnAfW3tDjYKrfQhgtv8QrfoM48q1RcAmFvW2zm2TDjlWMosU9OmKm6c8hSVZlGMsMTXmPlgx9E33QxB+XHfAlJQphwfQBoJVx36TlODtaT3Wq1wbvTy9o8oCA5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724866818; c=relaxed/simple; bh=jKobVgu0acTMnt1FZU3hAsGxqMKb/6PmK0FjU7wxFqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mWslkbC9sLU/daVLgwuyCY8GAIRkJNti/kJ0Em0xdDvjuaBMaLS5TNLsiAevcy28hxeFOplfoCrylfrQJgUVtWfUqgO8BVTkzKNlpduTzfRf7i0WY0Kxyty7GLY5Z+33k+n7N53JmJXYFfLnXOI1IyzXFkngBGGCBDHXKlejTlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QS2TcyMP; 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="QS2TcyMP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 216A4C4CEC0; Wed, 28 Aug 2024 17:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724866818; bh=jKobVgu0acTMnt1FZU3hAsGxqMKb/6PmK0FjU7wxFqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QS2TcyMP/tCYZgNXbimqt3quommZypURPf3s0tn7u0Rc1mBbQlgKAtvbBEFsCG2v/ qCFs+ztI+IvoXys2YkySA6miuc1Y7h2VNDPU4K/bB3w9vf9d+8JAETBOUjC/3A3qsE JhBv0HUqtFODkQWkV+7M/y8srQTjQRnAh6Tov7CHKu84WAFIdBtwCNWrWz0W16fYL+ 007X0HbcyKb7vuyRiIeGg0UGZdgBMjzkAF4Cl50jpUu5WI+mRds+iyjaxYNxfZp/Eg bbBFzE8VVrQQr6i/bjn07OK+Ia4c3tqEyIddwg/G1i+Q7W2pt4yiYmogM3QH2rQudP HEkfnJ18sKTeg== From: cel@kernel.org To: Cc: Olga Kornievskaia , Dai Ngo , Jeff Layton , Chuck Lever Subject: [RFC PATCH 5/7] NFSD: Clean up extra whitespace in trace_nfsd_copy_done Date: Wed, 28 Aug 2024 13:40:07 -0400 Message-ID: <20240828174001.322745-14-cel@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828174001.322745-9-cel@kernel.org> References: <20240828174001.322745-9-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=623; i=chuck.lever@oracle.com; h=from:subject; bh=LqOGC9tY/vwoLZr9odBeBS3kZzrq7UqNKArbJPXDe5k=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmz2D6dOssd4dmn7pK4CcWNXQU/rA+XpmkCJ//0 JZZeNETXsSJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZs9g+gAKCRAzarMzb2Z/ l2Y2EAChhy1ivzTpvpXeSvrqWKoRnHsPaOeL+yKFz8GFa85MBdh8+zgy3tBkE75K6PYsIDxy51t 9GNun9ff34lgi7XctMFkI291K5qi1CZ/hA/NTyMRGnL+te6SqkuEl+zKdDH1QFQhgTtr59aYq3R cqIxnlGJ4LvOEheZqjkinecJEUYtAV82xHWFmihLkBsPKBE8xzE1NsJuQwvSUgSkJh38pGzgjDs 4Vu47qj43rPTR/2OH1Rpgm3fpJEsvJJAqu2FsQP++rrr0V97RdRRJCvkQl1sSIM+fxqK4cg2bBl Z4wlaG9FHFg/M41OMiBHHanG4XDPk8htBnjXTUJmc80Rz/kaB7ulR9gagAXQ7vgHm8B37BHd3ZI GkXCrPdozWzjwY6K9Nn/EI7yVFPZfiLp2yCl4Bj2mW7m/d4LwMHnh3vNrmkX0RlfLVbDAkfN51W EqKenMcxTUtd7OVJuBSB+3inp/0IfGBKI2pjzHB95c464LIox30id6F6Py2LeEWGXbsjKwvdCUx N7kdBtpe7eZehefdMXAZJp/8d4M0d8lg67eMr5x2IXmMC2aIC4djsPvv9knowxh9IswgfZk5wuK Nyyev5yh4iwI4H9mXOi/C8qbuIcz0uAgEEcFFuGnZik+4MaZtrjp0o4U9wiUeslktqmcQ1p9pkX HYA+aYm/04u7EWw== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Signed-off-by: Chuck Lever --- fs/nfsd/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 61ca9632021d..d3bbd58b44de 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -2205,7 +2205,7 @@ TRACE_EVENT(nfsd_copy_done, __assign_sockaddr(addr, ©->cp_clp->cl_addr, sizeof(struct sockaddr_in6)); ), - TP_printk("addr=%pISpc status=%d intra=%d async=%d ", + TP_printk("addr=%pISpc status=%d intra=%d async=%d", __get_sockaddr(addr), __entry->status, __entry->intra, __entry->async ) ); From patchwork Wed Aug 28 17:40:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13781631 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 D4A961A4F15 for ; Wed, 28 Aug 2024 17:40: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=1724866819; cv=none; b=qwRaxFZcpf9NRzDLuLOBnq03Rt2x/KiQBNvSE459pQUpqBmpXm8h8fVaVL5Kc5eIH/kW8DE1+VMsDs9aBPfeqZ53BT/y+4yK282ksMn64oHpq2wPK/vk3zDsStYZemSY1eGWLyRCEw+azPNsu+Tlrcz7mKJvZ6aWh5OQ8v3fuO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724866819; c=relaxed/simple; bh=aWby0vCjyBSrR859hrjshOQRlTr+PjLYxD+LzePGeBw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jv1Z64mgLkN+uKrT8sm/bNbIBgjGRXqCl6bYzwBMEBjFlsy/hfehVYNnw2626eODkkrnehw/vKYC3/H6noBoT51pUGCY54R5v8wQn2qd/sYK/TahFwEtP8lYxpxjgm7s1rqboDibKR41dI0eU6vWOCZsGyLcUi0FPUT4Xg1JdDU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bHawMpDd; 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="bHawMpDd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCC60C4CEC1; Wed, 28 Aug 2024 17:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724866819; bh=aWby0vCjyBSrR859hrjshOQRlTr+PjLYxD+LzePGeBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bHawMpDdLPSlLoec1bQX4+bBVdJ0JBgOH7vYrz0bAut3Cs8mmF0XKFON9A3Axb80T X9lOi3n/bvB73PFM4LqNqm8TLPgFrS5lFwn6+17rxVHnIPLZr9ka8awz0W0JgP3+D2 af5XgOCE+BzJ8yTngb3anRWysZSplTTWM4Bp5ff//Fpk4xasjQng5xFLpF/QkgKdn9 J6etZamhkvBnOkK7ls5BAwNDYsBVM2vtr8AK9ZSMxQ0o2qzPEC3P2xhbVh3eLBvIs8 3lqY1SO5PduMJVx2XKujvoHWrRGCg5tzlujTG9xi+JdhlGrYfYv4+XBHFcKLqqQk3t pb3XL4h9mC1gA== From: cel@kernel.org To: Cc: Olga Kornievskaia , Dai Ngo , Jeff Layton , Chuck Lever Subject: [RFC PATCH 6/7] NFSD: Document callback stateid laundering Date: Wed, 28 Aug 2024 13:40:08 -0400 Message-ID: <20240828174001.322745-15-cel@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828174001.322745-9-cel@kernel.org> References: <20240828174001.322745-9-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2953; i=chuck.lever@oracle.com; h=from:subject; bh=Uo1EwGHvb06X0rSppHPe7oD//N8B4eumMYNYPONhYyI=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmz2D6cPVBj9+oiKXxPRwXrOqbGvVwr7DEZz2y1 7KPsLj2i5eJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZs9g+gAKCRAzarMzb2Z/ lymJD/9kQxAj0F7ATY3kWi/CTk+7PfIfbBTQyOUvULNkx8ceM05afOlAgITzUaNHvbO/+pmanKb 4g/y1d224H0Tj+dQjB7JkMeomWQoKAalIafShSBUq/zzUJbgErfZGn4/pC7xD67p92bplm5edvB a3YYMIFT1pOH2XDhg22jxtGr38yD//WFPNU4ueE8bJBzoWVB1qkO8BZ7riPe4uOJrgmBmV+GlCv JxkTJfqX2MpzrtTbS5pL7gwX9eeBmuWbyVg8aXSpxxYdTHH+ABQTqUqXtL3ADUxMIp/c3mVl8H8 Co0dWYZXYd4aJJ5wGiTO44Yq/vkG8W3duxKipGu4A0gRLD1yeCdNrJmwYgfGlGaY7lwqoX3SUir mnwFVtsJyWNeXbqqCZhZIujwf7dFww5Q68IPJcgwa/reDLW5lUPhy0WeMMg9rfrD0UxgGy0AOoJ Ob/wCdkDzXlEaPuTKHVWQ1usZnaKKudYGRTHEf9wCAy2q+mRmRBmgVgM5+uxYHs8PCKswUbknuD 378JUGvTTZ5Zjdp2p4gMHwA3piWAP4GCh3Q2FEiq8GREpu6hsksTLvKchOBaz6sJ4HTowXXeFP5 A1dLaE08KvuPtC9HZsO23izEVyodMrRXkptgQonIEWE3Nrg7J7ZAMPWwVFaqYphjW/0y6CEAi3r /HGSrZiq9YTBQGA== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever NFSD removes COPY callback stateids after once lease period. This practice keeps the list of callback stateids limited to prevent a DoS possibility, but doesn't comply with the spirit of RFC 7862 Section 4.8, which says: > A copy offload stateid will be valid until either (A) the client or > server restarts or (B) the client returns the resource by issuing an > OFFLOAD_CANCEL operation or the client replies to a CB_OFFLOAD > operation. Note there are no BCP 14 compliance keywords in this text, so NFSD is free to ignore this stateid lifetime guideline without becoming non-compliant. Nevertheless, this behavior variance should be explicitly documented in the code. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4state.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index aaebc60cc77c..437b94beb115 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6324,6 +6324,29 @@ static void nfsd4_ssc_expire_umount(struct nfsd_net *nn) } #endif +/* + * RFC 7862 Section 4.8 says that, if the client hasn't replied to a + * CB_OFFLOAD, that COPY callback stateid will live until the client or + * server restarts. To prevent a DoS resulting from a pile of these + * stateids accruing over time, NFSD purges them after one lease period. + */ +static void nfs4_launder_cpntf_statelist(struct nfsd_net *nn, + struct laundry_time *lt) +{ + struct nfs4_cpntf_state *cps; + copy_stateid_t *cps_t; + int i; + + spin_lock(&nn->s2s_cp_lock); + idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) { + cps = container_of(cps_t, struct nfs4_cpntf_state, cp_stateid); + if (cps->cp_stateid.cs_type == NFS4_COPYNOTIFY_STID && + state_expired(lt, cps->cpntf_time)) + _free_cpntf_state_locked(nn, cps); + } + spin_unlock(&nn->s2s_cp_lock); +} + /* Check if any lock belonging to this lockowner has any blockers */ static bool nfs4_lockowner_has_blockers(struct nfs4_lockowner *lo) @@ -6495,9 +6518,6 @@ nfs4_laundromat(struct nfsd_net *nn) .cutoff = ktime_get_boottime_seconds() - nn->nfsd4_lease, .new_timeo = nn->nfsd4_lease }; - struct nfs4_cpntf_state *cps; - copy_stateid_t *cps_t; - int i; if (clients_still_reclaiming(nn)) { lt.new_timeo = 0; @@ -6505,14 +6525,8 @@ nfs4_laundromat(struct nfsd_net *nn) } nfsd4_end_grace(nn); - spin_lock(&nn->s2s_cp_lock); - idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) { - cps = container_of(cps_t, struct nfs4_cpntf_state, cp_stateid); - if (cps->cp_stateid.cs_type == NFS4_COPYNOTIFY_STID && - state_expired(<, cps->cpntf_time)) - _free_cpntf_state_locked(nn, cps); - } - spin_unlock(&nn->s2s_cp_lock); + nfs4_launder_cpntf_statelist(nn, <); + nfs4_get_client_reaplist(nn, &reaplist, <); nfs4_process_client_reaplist(&reaplist); From patchwork Wed Aug 28 17:40:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13781632 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 ABF5F1A4F15 for ; Wed, 28 Aug 2024 17:40:20 +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=1724866820; cv=none; b=VgVuWeY94L0az201oB9OrurHCPLonpC6Sjuq4A/UxnhL+q9KUcrUtJNF36OK/ouA0AgyOxoOB7rdjnRI9ZSP5T1nb+HuuwY1gQ0/ex8/BBRU7HxF7noPtfMRviQKvNWHh7vOEQOEvsivj++TipLouI515Um1Osq+hz2lVtMdIXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724866820; c=relaxed/simple; bh=wNXa+khYT4NMDIWPxHQPMZRgDBMCeuRyzv6cwPuywvg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C34JfBK5IAI5gfHLE2hePQS6KPlmxEXSp52aoBuM90p0p96LplvLu6Hhvj1VJ0aUQx8aDLEHzcJun3yaLfv62PV74OvfDZNZ9PhKDsFhXqnNElzOX/ERIZIkhho5pzpGDideLlDSA17R9cU52BGbuA8pYszil88o2q6xS393cxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M2dsGnh+; 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="M2dsGnh+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A335EC4CEC3; Wed, 28 Aug 2024 17:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724866820; bh=wNXa+khYT4NMDIWPxHQPMZRgDBMCeuRyzv6cwPuywvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M2dsGnh+uTwGUl7ZYrvKe98ZGoC3cLDcSpZyReeG9eBNWqUcCUOraItS0vF5UKc1A NgpspUJIEONBlJZshkDhclnqvqpJOf0m8HPeUePnpuEaANY8XFYwCzZGcMETbTgWiA 5i4+jqoXOZy/3kKH5gZIdA+7pXfM8Hh/QqeDO99n2fdspHNFTOUagcWZEcvHuySy7L uCEiMeUMNvXNwLdr5FdSjrp13m7D76ygQvopmCT5YMxN4k5C7skt+snUeyAOOfme1q cQh3nXmEgcmkkH/f6sRdU0yNEYa6IG2xJBgNtCDkwqQPtwMkZSZOIvGuJLyCIt7r3E pSbtbcBHNJFEg== From: cel@kernel.org To: Cc: Olga Kornievskaia , Dai Ngo , Jeff Layton , Chuck Lever Subject: [RFC PATCH 7/7] NFSD: Wrap async copy operations with trace points Date: Wed, 28 Aug 2024 13:40:09 -0400 Message-ID: <20240828174001.322745-16-cel@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828174001.322745-9-cel@kernel.org> References: <20240828174001.322745-9-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4332; i=chuck.lever@oracle.com; h=from:subject; bh=rDwV+7jkKyejYwbHzPD5mVH8mTxc+zl/wmF7eO1Vpjc=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmz2D7QxMfkxQxlxvanfptoMT9SX2/pPcIW8pOd 09MEp5hKg6JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZs9g+wAKCRAzarMzb2Z/ l3e4D/9AWuCjotQqVO4tLWX1ysuGSJxwIW07PhSZIa5i7+srv/Bb1icFm9P8cSrKIMotghiA4A0 E1wuQPM+oOw+W9mfDxoLFnniYRg+u/OowAWsILscdVFy11DnJ/K8G8gJChtve6Es9SwrqoIGuDz CgQGt+kigtR2mHuYUNayDUPDzcE+5qjmM+5GHrpd0SQovNT/ICPMRKyIxQjiwC6dx78NZpq+3JX ckiHo2E7OqfGtJJniW50CkCVwa29oqhs5S17MOey96jKSvYATTBdz1S6wi4NZcvDeD3uVEp5eJg PRz5EZqkX3VLupEK8NAjmHoj2T/GBl+FEgFmaMVeXW0rQ7ASm4XzH98MJs2da1AxHy4dka450p3 Kxr0c3P5npUqO5vqCyUA5x8wqMb0bsu1c+o3tbs5RjwT4G8eFzJh0eEf1oibd3WoBUld5bY06IP +DPMmvRxl+v3t6V//RT1omFrg/fntIoLN8k1rqgImn7miZ5wacGWrRyizh6L8AUatka01cPmok5 gLDXT2ad5LKxS8Tdm2V424voB2o7EeQQfPnAteBK+eJPCHe1JowC80p/d9IltMSCOEQF+KAMOf7 1e37aLI18LcXXYM1iOO5sBT3OK3n1xTS8KFqsKkqm+JlTjGTBpVanVqJFM4ozssp/EIQ1QcE3vv CUI4EwgebvulFhw== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Add an nfsd_copy_async_done to record the timestamp, the final status code, and the callback stateid of an async copy. Rename the nfsd_copy_do_async tracepoint to match that naming convention to make it easier to enable both of these with a single glob. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 3 +- fs/nfsd/trace.h | 71 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 27f7eceb3b00..8b2074c72206 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1758,7 +1758,7 @@ static int nfsd4_do_async_copy(void *data) { struct nfsd4_copy *copy = (struct nfsd4_copy *)data; - trace_nfsd_copy_do_async(copy); + trace_nfsd_copy_async(copy); if (nfsd4_ssc_is_inter(copy)) { struct file *filp; @@ -1785,6 +1785,7 @@ static int nfsd4_do_async_copy(void *data) do_callback: set_bit(NFSD4_COPY_F_COMPLETED, ©->cp_flags); + trace_nfsd_copy_async_done(copy); nfsd4_send_cb_offload(copy); cleanup_async_copy(copy); return 0; diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index d3bbd58b44de..5febacd479b4 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -2184,7 +2184,7 @@ DEFINE_EVENT(nfsd_copy_class, nfsd_copy_##name, \ DEFINE_COPY_EVENT(inter); DEFINE_COPY_EVENT(intra); -DEFINE_COPY_EVENT(do_async); +DEFINE_COPY_EVENT(async); TRACE_EVENT(nfsd_copy_done, TP_PROTO( @@ -2210,6 +2210,75 @@ TRACE_EVENT(nfsd_copy_done, ) ); +TRACE_EVENT(nfsd_copy_async_done, + TP_PROTO( + const struct nfsd4_copy *copy + ), + TP_ARGS(copy), + TP_STRUCT__entry( + __field(int, status) + __field(bool, intra) + __field(bool, async) + __field(u32, src_cl_boot) + __field(u32, src_cl_id) + __field(u32, src_so_id) + __field(u32, src_si_generation) + __field(u32, dst_cl_boot) + __field(u32, dst_cl_id) + __field(u32, dst_so_id) + __field(u32, dst_si_generation) + __field(u32, cb_cl_boot) + __field(u32, cb_cl_id) + __field(u32, cb_so_id) + __field(u32, cb_si_generation) + __field(u64, src_cp_pos) + __field(u64, dst_cp_pos) + __field(u64, cp_count) + __sockaddr(addr, sizeof(struct sockaddr_in6)) + ), + TP_fast_assign( + const stateid_t *src_stp = ©->cp_src_stateid; + const stateid_t *dst_stp = ©->cp_dst_stateid; + const stateid_t *cb_stp = ©->cp_res.cb_stateid; + + __entry->status = be32_to_cpu(copy->nfserr); + __entry->intra = test_bit(NFSD4_COPY_F_INTRA, ©->cp_flags); + __entry->async = !test_bit(NFSD4_COPY_F_SYNCHRONOUS, ©->cp_flags); + __entry->src_cl_boot = src_stp->si_opaque.so_clid.cl_boot; + __entry->src_cl_id = src_stp->si_opaque.so_clid.cl_id; + __entry->src_so_id = src_stp->si_opaque.so_id; + __entry->src_si_generation = src_stp->si_generation; + __entry->dst_cl_boot = dst_stp->si_opaque.so_clid.cl_boot; + __entry->dst_cl_id = dst_stp->si_opaque.so_clid.cl_id; + __entry->dst_so_id = dst_stp->si_opaque.so_id; + __entry->dst_si_generation = dst_stp->si_generation; + __entry->cb_cl_boot = cb_stp->si_opaque.so_clid.cl_boot; + __entry->cb_cl_id = cb_stp->si_opaque.so_clid.cl_id; + __entry->cb_so_id = cb_stp->si_opaque.so_id; + __entry->cb_si_generation = cb_stp->si_generation; + __entry->src_cp_pos = copy->cp_src_pos; + __entry->dst_cp_pos = copy->cp_dst_pos; + __entry->cp_count = copy->cp_count; + __assign_sockaddr(addr, ©->cp_clp->cl_addr, + sizeof(struct sockaddr_in6)); + ), + TP_printk("client=%pISpc status=%d intra=%d async=%d " + "src_client %08x:%08x src_stateid %08x:%08x " + "dst_client %08x:%08x dst_stateid %08x:%08x " + "cb_client %08x:%08x cb_stateid %08x:%08x " + "cp_src_pos=%llu cp_dst_pos=%llu cp_count=%llu", + __get_sockaddr(addr), + __entry->status, __entry->intra, __entry->async, + __entry->src_cl_boot, __entry->src_cl_id, + __entry->src_so_id, __entry->src_si_generation, + __entry->dst_cl_boot, __entry->dst_cl_id, + __entry->dst_so_id, __entry->dst_si_generation, + __entry->cb_cl_boot, __entry->cb_cl_id, + __entry->cb_so_id, __entry->cb_si_generation, + __entry->src_cp_pos, __entry->dst_cp_pos, __entry->cp_count + ) +); + #endif /* _NFSD_TRACE_H */ #undef TRACE_INCLUDE_PATH