From patchwork Tue Oct 8 13:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826511 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 B76D213959D for ; Tue, 8 Oct 2024 13:47:38 +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=1728395258; cv=none; b=WFoP279BjNjqC0M1vlR/A1bN17lcGWdGdk9WdIXsWzCW0c0KWALkmfFuwheKTfZlfhFgsAR8fLmjzUak8OSTEceX6RBwLvsvmawlUJOuNjB3W5WWsMcrtq6Rhl5+tZtmCiveGeUWXxFkJM78bYMeZTX1qOebd0mwSS46TvXMcbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395258; c=relaxed/simple; bh=PS+siCOz9OVFuPMJFQAG4sD84t/J1JI/yJ7OfIcJIN8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UqkQvH5nBu0K/OJ4+bsh0sBFHJqWdl50jTfvmwwDPk8F0grCQpj3IbM+//CUa+VKPDNdVtYBNvOzKV4Gm6U2pk6kCJTHLFk7/zbSagQ30aL1/A5yUOKRermo42AQW3jgEwZNgvrPTz0JAX57viPQnjqu4IcsAMFS8WQoV+oAVUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ruDbwBng; 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="ruDbwBng" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2DDDC4CECE; Tue, 8 Oct 2024 13:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395258; bh=PS+siCOz9OVFuPMJFQAG4sD84t/J1JI/yJ7OfIcJIN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ruDbwBngukT7wB8omVyUUy0ow/R+Qwoaou74aEr1kjG54m5IKv2nkNCNFsIDEuK7G dPEiCI9Xwfuh05ENNJPXkMR2mv98xSrWVHPQxzVVcZPa0LJ3FtCMGDEAuO4rouXbFz FHVfKCaKKIwxjo++vGOnkLqBSEpQfEUhuSUVp0L22sTWVSnyjcVi32YXyrLTh3MSCf WhmpKWCeBfxoX7qnIAVBbRXL0w4LiqdWBQSuxER8yJAGe/AjwAjD/2kmnHkTg0brbS QI2DrgB/7nOHAqFEtSFatjV74kWSJgCdhR1FquHQH9TcSf5Lx7wthQkSxzR0pJqAu0 WIFRuabK1S6fg== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 1/9] NFS: CB_OFFLOAD can return NFS4ERR_DELAY Date: Tue, 8 Oct 2024 09:47:20 -0400 Message-ID: <20241008134719.116825-12-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=876; i=chuck.lever@oracle.com; h=from:subject; bh=hx9wCizVSEyAIJq+6ZAKF9s0uu1JfMv95X8lImJ0J3g=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfy+tktoJadsbimKKjyY2exwa8tRPGayhfZ8 d/rXBlI41eJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38gAKCRAzarMzb2Z/ l71gD/0bPaAnIj822ciXe4n84gWVUcdty91w9uUr7OY9QaNaClM4L1v81KtG2nkL8q0MZC9U38T TBUfLs3ow8NeCABTpO1CPuo+2aLSwRDHzYCe/WGgWTfuzYxi9S5WDoH9Uwn+upoW20vNg+1Ze4g /WhvtpvRMDtm0MWOURnbTbkHNsdIDFthqDrYE5TSVmI4l1BGjQv4DPGFhARqXiIeS+rBSqdBz/J ++W7XGzc4pxrl1VSTJBifstJ6kYo3yM5xkQ1ZR3QyEjSZjsZdoKpFPJAjUr4qzvxToHozly13e7 GkQXZwngNn6/KjZCSiPiCDOjoNWrz5bVg77Lqq8eEF4qdvUK4VMVfaaDzds3Tsn0/ZgNoErjB4n o8TGQ0rmyS0yD/lGDC5NnjgEAsb6MvXBJ4Pc4FSfu0CVZN//TJOfjRvfR29ad5XTipHg89dvdXA qXdfW47P9qZmgVI8VxyqRHIX/TK0N8ROZ6ZPbRGDIUWVXUunN0MYTqJPiCGlzTyGtCWz2cvV9bv dRGmMnLO/kE987zIKRk7kN8C1bN4viPH1mpCrmdBrHWxXGPqdyTx815XTpsJBSazOR0OHQ6WmCY DJBuW0HLNups9YFFmfXEJS/PJRKfn6nBIiV4/AzRo0941ummuvJNSUi7TSSTCaxD+fHk+EKIHfQ MXIATvPSaXCI1Uw== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever RFC 7862 permits the callback service to respond to a CB_OFFLOAD operation with NFS4ERR_DELAY. Use that instead of NFS4ERR_SERVERFAULT for temporary memory allocation failure, as that is more consistent with how other operations report memory allocation failure. Signed-off-by: Chuck Lever --- fs/nfs/callback_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 7832fb0369a1..8397c43358bd 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -718,7 +718,7 @@ __be32 nfs4_callback_offload(void *data, void *dummy, copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_KERNEL); if (!copy) - return htonl(NFS4ERR_SERVERFAULT); + return cpu_to_be32(NFS4ERR_DELAY); spin_lock(&cps->clp->cl_lock); rcu_read_lock(); From patchwork Tue Oct 8 13:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826512 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 D060013959D for ; Tue, 8 Oct 2024 13:47:39 +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=1728395259; cv=none; b=aCK6Ph1F/S2D8gwtcOGNKTeh0P4Lq3VeICSxLiOGywiuOer0bOtZsKDudv/ogCCE0gSVM5wfchw7EFsnrZtlGvNV4Tgccrmg9k022xwzrXFx3F+/zETtDAz5h5isymG8LcCdzoXZQHuEPTtw9H+5VKsnST6Km8ecVYIDk6+sttk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395259; c=relaxed/simple; bh=0NgbepDpKWWEDAeg8qZaZLrThOVr10jhViRRGfnEelQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fw/LFDoRp3lSYdvFwPsI3cH7JVwM4SkvWBcKekzat3OkenW2w7VpHBIC0ex0kmTiofnmkRQTNQRm2zE1UFkHyIwmjaA/sxYvhk1yHPqaxrzF6Eh3kUT+AI1iKw72RZRN8gLtd/00RLHYaH8Wrwx4Dvvr4dDXUc4ILd8W8XkBRj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GsPjSDZm; 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="GsPjSDZm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A694C4CECC; Tue, 8 Oct 2024 13:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395259; bh=0NgbepDpKWWEDAeg8qZaZLrThOVr10jhViRRGfnEelQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GsPjSDZmIvdJEztraGV7p9jrxPl2p/2414PpVC3JAWg7O76OHq+E6n0koc4AH4xIC KprlYhHhm2VGuIMnlNqBjM3KZey41B8+iMBBEV92yPV6NaSPxCUAFfCAjJ7L3ItGDy Z/Nnz7Xp0VbGd2SuXuMxfvErKoCVQYEDz1juRTmWD2q5Hhm2WxjMTRp97nuKxlEKVG mfhPgwu6+w8M9BPmFHaMQ8pL2FTDXrCsCzx8UsBDpoXKu7PC2gn+kLIeubn/WTaNyS H6lwTAh/asnEiBgVAVWX3fXaHCObMxvQ+PVql2bklZnKOrbeudNhlZ1aqO9pxZeUe0 OOD7sKld0yW4Q== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 2/9] NFSD: Free async copy information in nfsd4_cb_offload_release() Date: Tue, 8 Oct 2024 09:47:21 -0400 Message-ID: <20241008134719.116825-13-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=3644; i=chuck.lever@oracle.com; h=from:subject; bh=8QSyr89hxnWWPpw8HGdXacTZ9ztmzRPb0IspVXS3k14=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfyT8CVCsA8gwMZRtK95M0Vy/8TRiPfuOeVT n13YXzJ65KJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38gAKCRAzarMzb2Z/ l726D/oC49bItz/v56m3ZO7QxDBQN1sEGuph1Fb65HqBZMqvxIrLGGEEv7SZejX23OrdZk8uOUg 8x5HHIaFunLURdmGXfvWvuMp9i2tX2XbZfVaBDagl+0S9kR1LnncP7G+/PTgjfR0SXePcz3DvZ7 ywMfjVOVyRgPj42RuPXlDPjQ+6Cx+9g4wkKiwzE7tgDlakNP4ApYD/E+0YPVaodEtVJY5WbWjF1 09dUBXDbAOYOl2K7Sd73easWAdLiiMGcHL9PKY+GNUs+FGr7BLIKifIhsbI2LsNn+RNr2accCE+ WT0WaS9rKKp/rhCdiGF1BP7tA57q7i6EwaGYt+S3B844cxfFpcxY6MVf415WUN1Ib/o0UGULbAL WDAR/DBSJthmCJsffjx8M5pj32SvoFGROMR7f9QpY2notMz/SOANeeRlVDEv8wwC/ncHYcYLzJP wkBcPdo9EX1kwQJaoe0faDZk/jY67bSpyP99Cx5ZRKc1F0P0dId0bHdPrN0FZOH/z88bPy6vdwQ +UQKnf43s3ftwn9mUp5K+fIHNPhHLI0kzEkn/ducDnRfH4JPEXHYiz25HqZpjn+P0fku0ouDg+D +TNmMH7EugSWwwFqonXbpkPXBhhtKrwCu0YLbqLo9Csf6IGXx7ALxXpVj3B9Vlbvj2vZPBRcn5F 5/VJwIWdd1ic3Wg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever RFC 7862 Section 4.8 states: > 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. Currently, NFSD purges the metadata for an async COPY operation as soon as the CB_OFFLOAD callback has been sent. It does not wait for even the client's CB_OFFLOAD response, as the paragraph above suggests that it should. This makes the OFFLOAD_STATUS operation ineffective in the window between the completion of the COPY and the server's receipt of the CB_OFFLOAD response. This is important if, for example, the client responds with NFS4ERR_DELAY, or the transport is lost before the server receives the response. A client might use OFFLOAD_STATUS to query the server about the missing CB_OFFLOAD, but NFSD will respond to OFFLOAD_STATUS as if it had never heard of the presented copy stateid. This patch starts to address this issue by extending the lifetime of struct nfsd4_copy at least until the server has seen the CB_OFFLOAD response, or its CB_OFFLOAD operation has timed out. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 18 +++++++++++------- fs/nfsd/xdr4.h | 3 +++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index b5a6bf4f459f..a3c564a9596c 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -57,6 +57,8 @@ module_param(inter_copy_offload_enable, bool, 0644); MODULE_PARM_DESC(inter_copy_offload_enable, "Enable inter server to server copy offload. Default: false"); +static void cleanup_async_copy(struct nfsd4_copy *copy); + #ifdef CONFIG_NFSD_V4_2_INTER_SSC static int nfsd4_ssc_umount_timeout = 900000; /* default to 15 mins */ module_param(nfsd4_ssc_umount_timeout, int, 0644); @@ -1598,8 +1600,10 @@ static void nfsd4_cb_offload_release(struct nfsd4_callback *cb) { struct nfsd4_cb_offload *cbo = container_of(cb, struct nfsd4_cb_offload, co_cb); + struct nfsd4_copy *copy = + container_of(cbo, struct nfsd4_copy, cp_cb_offload); - kfree(cbo); + cleanup_async_copy(copy); } static int nfsd4_cb_offload_done(struct nfsd4_callback *cb, @@ -1730,13 +1734,10 @@ static void cleanup_async_copy(struct nfsd4_copy *copy) nfs4_put_copy(copy); } +/* Kick off a CB_OFFLOAD callback, but don't wait for the response */ static void nfsd4_send_cb_offload(struct nfsd4_copy *copy) { - struct nfsd4_cb_offload *cbo; - - cbo = kzalloc(sizeof(*cbo), GFP_KERNEL); - if (!cbo) - return; + struct nfsd4_cb_offload *cbo = ©->cp_cb_offload; memcpy(&cbo->co_res, ©->cp_res, sizeof(copy->cp_res)); memcpy(&cbo->co_fh, ©->fh, sizeof(copy->fh)); @@ -1786,10 +1787,13 @@ static int nfsd4_do_async_copy(void *data) } do_callback: + /* The kthread exits forthwith. Ensure that a subsequent + * OFFLOAD_CANCEL won't try to kill it again. */ + set_bit(NFSD4_COPY_F_STOPPED, ©->cp_flags); + 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/xdr4.h b/fs/nfsd/xdr4.h index 2a21a7662e03..dec29afa43f3 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -699,6 +699,9 @@ struct nfsd4_copy { struct nfsd42_write_res cp_res; struct knfsd_fh fh; + /* offload callback */ + struct nfsd4_cb_offload cp_cb_offload; + struct nfs4_client *cp_clp; struct nfsd_file *nf_src; From patchwork Tue Oct 8 13:47:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826513 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 9C40113959D for ; Tue, 8 Oct 2024 13:47:40 +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=1728395260; cv=none; b=MfYEHfe8MAYlHg7PbstONPLephB/WKAAOdh6kgEHi+lcsSy4Jt/4utH+xTp/zqw97eTJYTOgZ0AOzcjrUa8kqqlVlyz+tFFwnmMzr9y1KPQNKZNRIo8/tTQVu1s3DjvXDi/VYawLziuRIiiH3YUeu1OImo2z9TrBZS3JqUV6e3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395260; c=relaxed/simple; bh=UO3Ijkcb2D6amcPFfIdr+M+0dhnixPQGtn7OVb983mI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FFGCcIv9Q2HPFb5rBuu5MM/1B4+5JnI+HyP/PouH99SV7IJoSiLWfkp8lBnZngyBxr/VyAQshopxQ+Rk7RL2B/LTdJIc4Xxsgg0236Mp0i7vS+itqwdWy3fqdEPMgve7b1qACeZYUQ0zMSv95RQNPm6q1sfa8pg/+VSuYHljhbs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j9mlzSJ6; 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="j9mlzSJ6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85FE8C4CECE; Tue, 8 Oct 2024 13:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395260; bh=UO3Ijkcb2D6amcPFfIdr+M+0dhnixPQGtn7OVb983mI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j9mlzSJ63dZa5ae1FBol5DZZwm2Z8hdOdSUERklsO/a4OMCPbP0mmTkAwcHkDLBPQ 8/elDlwcUgRVg0rzFtlQzGzmLLNeCl34ylKQYxSbiUCUwKG447q4ZVdmujoO60Iytb srgPZhrnw1z3i+/rIzp0Yep8j9jPinyLw+igBa4PzlBx8m4ViqIyG2Jr/1QHUpPfpf EvMzjkCJJLNb5ZuH7gjcFp+q/0RtYkhT1ICkCG1P5xRDfsZJNiYkX0Q3Tw9PoeoVpf v1FX3f7a0avJrRtfOAy1xuIB6vyM6rJ6+YAj5m9/0b8QSKo5AiLG0VKQbbEmkBT770 4bkMcSB+T1Fxg== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 3/9] NFSD: Handle an NFS4ERR_DELAY response to CB_OFFLOAD Date: Tue, 8 Oct 2024 09:47:22 -0400 Message-ID: <20241008134719.116825-14-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=1622; i=chuck.lever@oracle.com; h=from:subject; bh=Ka++gHgUIUzafsIgfC4Xq2XQF8GGbX8s118CqdOApNM=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfy3X6McosSqKuvQxLpnn3gQXCxoc1asENae hhxuKzwFiqJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38gAKCRAzarMzb2Z/ l//dEACSrjdU0UUORvOGshj8/MmKlGnowF2vDPs9V85bC6etDNVirtmn/ig9Ib1ItFjLu8DX+Hc IHWQ5P3IFt29olzUZQ99yvcyJM2DfKUO2gNYys/DeEjGbQBi9pyrTYifAuK6gNxgJPz7ptixL5e kRBjrA2ylTjOeM83G90jQvuFtFKV2iWSZyYt/F8DjUTVUSm6Wg6MdBHTp7UiyHIxfYxxKj/YNnK zh6dWXWZpRTtGBLsvF886aAFMHX/APMa6HUr08hq+stt3PDE2SBk9vxZpkN2vBr8cwwJVsAGPpv VaAaMDw/yXrVDTkXdooq0NJ85U6PBQXAmPf+WyZydnsHpvTlMkIKZYv1jafZd2AlLPIoVu7kY4R lggEDb23q6FDqJ+wrD14iJJUHv5FKdh01/E4oLBIPktoCa6U6lsJFtgQRCNUg4LBitZd22ByRiO h2OLXhJKTwekXcQC6sFRKOcZfX37pgCo6kpEU3os46h0OjBTCHxZ72CKkr+L/bYnHuUp1D2lTBu XHvfJKpzr9YhbTJeCWYXeP7OUYRPvlAlrqJyk6qww+Fb4Zs4j61yH8bPFXNTtxE0OJ8FNZT6koC crE7Co/J6PBNu8YzTWfgrdJ9HGKYWoydDh8M3I4i5Bk6M0d0eNjW3kUNYYsGjSz3b1PzJvYWc0Y BXUP00Ex2mosSEw== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever RFC 7862 permits callback services to respond to CB_OFFLOAD with NFS4ERR_DELAY. Currently NFSD drops the CB_OFFLOAD in that case. To improve the reliability of COPY offload, NFSD should rather send another CB_OFFLOAD completion notification. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 8 ++++++++ fs/nfsd/xdr4.h | 1 + 2 files changed, 9 insertions(+) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index a3c564a9596c..02e73ebbfe5c 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1613,6 +1613,13 @@ static int nfsd4_cb_offload_done(struct nfsd4_callback *cb, container_of(cb, struct nfsd4_cb_offload, co_cb); trace_nfsd_cb_offload_done(&cbo->co_res.cb_stateid, task); + switch (task->tk_status) { + case -NFS4ERR_DELAY: + if (cbo->co_retries--) { + rpc_delay(task, 1 * HZ); + return 0; + } + } return 1; } @@ -1742,6 +1749,7 @@ static void nfsd4_send_cb_offload(struct nfsd4_copy *copy) memcpy(&cbo->co_res, ©->cp_res, sizeof(copy->cp_res)); memcpy(&cbo->co_fh, ©->fh, sizeof(copy->fh)); cbo->co_nfserr = copy->nfserr; + cbo->co_retries = 5; nfsd4_init_cb(&cbo->co_cb, copy->cp_clp, &nfsd4_cb_offload_ops, NFSPROC4_CLNT_CB_OFFLOAD); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index dec29afa43f3..cd2bf63651e3 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -675,6 +675,7 @@ struct nfsd4_cb_offload { struct nfsd4_callback co_cb; struct nfsd42_write_res co_res; __be32 co_nfserr; + unsigned int co_retries; struct knfsd_fh co_fh; }; From patchwork Tue Oct 8 13:47:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826514 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 5F58013959D for ; Tue, 8 Oct 2024 13:47:41 +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=1728395261; cv=none; b=Koq5nHK1yTyrQI843+qoxRFkkB92T0sGpAdKb8xoDofS34NT7/MiYGI7aw+opL16wIDPJdWNIwebYEwFFJjN6QP62IH20ZlIkz93o39yJx0nr0jsCWLR17GGa8BwmBLYTn9qkiOpWz5vsrkLLWUp88OfO/tJ+1KipLFGBFk/JHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395261; c=relaxed/simple; bh=qG088IO4r4BEzBy7NMBh4tMUVi3+24fxaKWYm++4hng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RrYWxTy+gMVY796sk/eSIgmSCNmEXDxlFEkMoJ9IDszKdIKV1IVpfv7NhnmrjUyqjk/ZdTlyTRaroi7he8IwGmuaZdPB7hDyEG2Gqdp2rCw4/4FyveZB5dUIdOeOOMPKCXUDYJhGvTZOGGbyOT/kjp63NvUuJOCqUlmDUD+L1EM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XTSKjgBn; 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="XTSKjgBn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6995BC4CED3; Tue, 8 Oct 2024 13:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395261; bh=qG088IO4r4BEzBy7NMBh4tMUVi3+24fxaKWYm++4hng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XTSKjgBndCvpNggci1aJ/HFaFHeUlo9YvCIcxQSaIvfMzU9d+FWua69d6shr7IjG6 m8yz4Ge4VSmALS7vbs9u2XeKDJg83pd7tSr+s3tivAZaD/Xq0hnJHRkwVXO4hMO5kw FxtVSR8qGqhGX4caqubDIiubpvZwAT50V28M+nj/Z/o3pGH5oN2WubOkrX18masrVL jjUGP+Y1N9KG6JqTHjA0XxBlFGAaibX+gT9W+H+tWp/GyVly24E+2rIWqZBGh8sUyT XFTb5FibXcXxaQOW4vQSms+/JIkxvQXDlD7PlbKJLeshBpZRgF2fs92vDUmkD9B3Di pBTzLc4uGlUGQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 4/9] NFS: Fix typo in OFFLOAD_CANCEL comment Date: Tue, 8 Oct 2024 09:47:23 -0400 Message-ID: <20241008134719.116825-15-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=546; i=chuck.lever@oracle.com; h=from:subject; bh=eJ3obtcWZiv2MzPuYhGsLc1j6s9O3yd2d/rO9u5uxcI=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfyc59zOK9MZ1+rN5U9n39Z0V1TE00T1lwwp 0SQt3N0KgKJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38gAKCRAzarMzb2Z/ l9xCD/9v9c6OOQpuraxaSU9jVecnFg3McQwEkxU3Te9YfNS2stX8ABbNHbdTTkOP4xUj5sdDlCM QhQpeCup8E8aGQ3YKmXvQImFJI6pnhVIudS1AvnhREzkKRU3XzfPRV6qc5u6rtT54IKcC/nIQuZ FjK0HAqsT0G84MxkwlYW/w3bXxLhu3zYnGh8rPNvsy4znNJTr9kh4eAbVqdosmYNnxD5INj3jDO gZwcp/wKAIybwevt0pCvKbuiynuV1Ls2PSx/Rwnve4BlKRtvF5S6IOmhxq+K2+7XfIkMYg+4vla 52GXId+OFZ2e36lWjeZoQ0y9iKX2Fj81ywDtYUxJlcNb1PlMac82GYIQR7oom3TwWUksXovGdw0 NQn29EJknodFCKx7OU4USdpJOcTc+6XisXMMwtIZZekL852Ie3ovouNNz9Yxqu2x99dUKhnFNuQ 61M3Oaf2RXsj4jS+89iZbhxRgXayE9ehs+Zy6VVRZkqukD9gXvM/cpOwSP4rdFINPrbj58IvlK3 ORPqRYuFwkuQumM+xtqEBf/0xiPzRSRvmBDwQWtpdqEvbP8D+waBruWlf5XUCCm0pfTIs8G9N9K BzTHBem2BafK04xESZPBbJiBkc3S1iDqpWtm9zUYpwqNtQlvGPZXsmy6mWU6okkjtTmEh8ODgN4 0Tf8cnpcjpd9Ewg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Signed-off-by: Chuck Lever --- fs/nfs/nfs42xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 9e3ae53e2205..ef5730c5e704 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -549,7 +549,7 @@ static void nfs4_xdr_enc_copy(struct rpc_rqst *req, } /* - * Encode OFFLOAD_CANEL request + * Encode OFFLOAD_CANCEL request */ static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req, struct xdr_stream *xdr, From patchwork Tue Oct 8 13:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826515 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 7127113959D for ; Tue, 8 Oct 2024 13:47:42 +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=1728395262; cv=none; b=Xa8uNLEwjLJa0HDOnjepcAjCJjLGLKbGsz1SmFXb4zT8NXQyKq3TcSikKcran8GY8qjeT0Ks4Gc9t5pO6nmrcF7ozEHVdsrXH0hdgjAzV9bh87FAfgmPnQuPs0hci9KhjsuuTwdlb5KMD2//GWd4KcMpR/0nfFa5swybjHwTFn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395262; c=relaxed/simple; bh=10qgMmKU0mBH7X62+YE4LHUhsde4DYDMcNlY44hAu4M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OpDDpA4ZTYR4qC02tQUqYMD5aXHLqxrNyI0daSbtgvqoptwcPnhssE7TVc72+eix8IPzT6XLzskGFOB/bHjE4kq7Erj8rSpbHceaLQ2MpRYHCL+IoRWDuKHDzm46/8O2MdaCbo/J6lJyhQndWuG0JQS1OLqHfAS4T1i049sc3/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WlsHKktH; 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="WlsHKktH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B630C4CEC7; Tue, 8 Oct 2024 13:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395262; bh=10qgMmKU0mBH7X62+YE4LHUhsde4DYDMcNlY44hAu4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WlsHKktH3XMzZjReL6EdN4hPCrFI9ZTqLRNjJlo55TIrqjklBc/SA93+NvTRa6Foj sfrdaWFQpUy7Kdn/iakJI42QY76bL16fwMbTX5LPlNjIGl03QG25XjC3FMpdBMUAIN ZgovITvaadub8SDgGazVns89YbUG4LP9gCeGSTgsHNVpdcGAf63NiSdVPT8Xan28uw /Y4YCtrU0xayu3WRZa8oD1XkDgQAfnDgB3hbiSQnt4aK+FywaTCcXcvdtC+Se5Gm7k chbrPP2PuD/4o8/hIfRL/qTKOywlmtKbJaZ33lF2p0t9+m8B87fZnOd8m1wJsl0K5C e7LLxbtgMmQlw== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 5/9] NFS: Implement NFSv4.2's OFFLOAD_STATUS XDR Date: Tue, 8 Oct 2024 09:47:24 -0400 Message-ID: <20241008134719.116825-16-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=5794; i=chuck.lever@oracle.com; h=from:subject; bh=QZq5ul7uYvH8Xb1l4B2DuMAL2V3+j8T+DZ1aGtQPhiI=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfzlCMChIT39BI29eibG9DjeH/UbkhMva4v7 HHzCuXTB7eJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38wAKCRAzarMzb2Z/ lzIIEACCRQ5ur5Pq8vCTl+MPl7cslenDpxCncgS5DiEviRCJgHEZML+M1fb9UnNGK+Zkq5ssJWO 0DhpE4i4UbdlVRcTGISwv+9clBSWYpDg9x/Ygp33ImUKGIABK83QngYvyJzESJrVLV+kqlXevqC iFqabpilZikxyjN8gHloMqtjcTl1a565BFEncEEtpcV2aQrsUhfTDxknpUqudon4IBN1yR0wIOn YvzsIE6FGEDb31J8IvMjtKjrsi9g78Hjloj2chFjYBTQ9F7Oy8RGbI8Psy2fLROURK5POMH06Iu U8m/r6i0spmotkmzBvwR2u+d2ScXVcLIT7Gl8GVeZbM6sbNdQSGEW+vh2EnwWW9p3Auwo805tW8 Q6Hup6XTJE3vMnj3NdUJB3cWm5CmCHNWuV0yFGhMh+uIN0cL05/gl0u1G4QlMwaxWUn949vyqMB FRhB3ElOP+FHIuScVhi4UEpT/U8dELKzaUz787S/4fyY6woKz6HbkThxzXpayrYzxU5a1jD0IX0 KP+tZXK4/Qk0H7vGmyf+u9pw3rMkMq1zaOdg3LGWCAtUuhcga5sfIQbJZPaEd6tXYmN4AooyuHq ehNIO1sAA0UfIjeqxYpwSiHjQkpjiIU65BGr8CUnNU69u+N8SjZvpnY1e6GNHLapgNIphOLj4KP EAuQ+SyKaheFVfA== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Add XDR encoding and decoding functions for the NFSv4.2 OFFLOAD_STATUS operation. Signed-off-by: Chuck Lever --- fs/nfs/nfs42xdr.c | 86 +++++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4xdr.c | 1 + include/linux/nfs4.h | 1 + include/linux/nfs_xdr.h | 5 ++- 4 files changed, 91 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index ef5730c5e704..ad3d1293f917 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -35,6 +35,11 @@ #define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \ XDR_QUADLEN(NFS4_STATEID_SIZE)) #define decode_offload_cancel_maxsz (op_decode_hdr_maxsz) +#define encode_offload_status_maxsz (op_encode_hdr_maxsz + \ + XDR_QUADLEN(NFS4_STATEID_SIZE)) +#define decode_offload_status_maxsz (op_decode_hdr_maxsz + \ + 2 /* osr_count */ + \ + 2 /* osr_complete */) #define encode_copy_notify_maxsz (op_encode_hdr_maxsz + \ XDR_QUADLEN(NFS4_STATEID_SIZE) + \ 1 + /* nl4_type */ \ @@ -143,6 +148,14 @@ decode_sequence_maxsz + \ decode_putfh_maxsz + \ decode_offload_cancel_maxsz) +#define NFS4_enc_offload_status_sz (compound_encode_hdr_maxsz + \ + encode_sequence_maxsz + \ + encode_putfh_maxsz + \ + encode_offload_status_maxsz) +#define NFS4_dec_offload_status_sz (compound_decode_hdr_maxsz + \ + decode_sequence_maxsz + \ + decode_putfh_maxsz + \ + decode_offload_status_maxsz) #define NFS4_enc_copy_notify_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ encode_copy_notify_maxsz) @@ -343,6 +356,14 @@ static void encode_offload_cancel(struct xdr_stream *xdr, encode_nfs4_stateid(xdr, &args->osa_stateid); } +static void encode_offload_status(struct xdr_stream *xdr, + const struct nfs42_offload_status_args *args, + struct compound_hdr *hdr) +{ + encode_op_hdr(xdr, OP_OFFLOAD_STATUS, decode_offload_status_maxsz, hdr); + encode_nfs4_stateid(xdr, &args->osa_stateid); +} + static void encode_copy_notify(struct xdr_stream *xdr, const struct nfs42_copy_notify_args *args, struct compound_hdr *hdr) @@ -567,6 +588,25 @@ static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req, encode_nops(&hdr); } +/* + * Encode OFFLOAD_STATUS request + */ +static void nfs4_xdr_enc_offload_status(struct rpc_rqst *req, + struct xdr_stream *xdr, + const void *data) +{ + const struct nfs42_offload_status_args *args = data; + struct compound_hdr hdr = { + .minorversion = nfs4_xdr_minorversion(&args->osa_seq_args), + }; + + encode_compound_hdr(xdr, req, &hdr); + encode_sequence(xdr, &args->osa_seq_args, &hdr); + encode_putfh(xdr, args->osa_src_fh, &hdr); + encode_offload_status(xdr, args, &hdr); + encode_nops(&hdr); +} + /* * Encode COPY_NOTIFY request */ @@ -919,6 +959,26 @@ static int decode_offload_cancel(struct xdr_stream *xdr, return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL); } +static int decode_offload_status(struct xdr_stream *xdr, + struct nfs42_offload_status_res *res) +{ + ssize_t result; + int status; + + status = decode_op_hdr(xdr, OP_OFFLOAD_STATUS); + if (status) + return status; + /* osr_count */ + if (xdr_stream_decode_u64(xdr, &res->osr_count) < 0) + return -EIO; + /* osr_complete<1> */ + result = xdr_stream_decode_uint32_array(xdr, res->osr_complete, 1); + if (result < 0) + return -EIO; + res->complete_count = result; + return 0; +} + static int decode_copy_notify(struct xdr_stream *xdr, struct nfs42_copy_notify_res *res) { @@ -1368,6 +1428,32 @@ static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp, return status; } +/* + * Decode OFFLOAD_STATUS response + */ +static int nfs4_xdr_dec_offload_status(struct rpc_rqst *rqstp, + struct xdr_stream *xdr, + void *data) +{ + struct nfs42_offload_status_res *res = data; + struct compound_hdr hdr; + int status; + + status = decode_compound_hdr(xdr, &hdr); + if (status) + goto out; + status = decode_sequence(xdr, &res->osr_seq_res, rqstp); + if (status) + goto out; + status = decode_putfh(xdr); + if (status) + goto out; + status = decode_offload_status(xdr, res); + +out: + return status; +} + /* * Decode COPY_NOTIFY response */ diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index e8ac3f615f93..08be0a0cce24 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -7702,6 +7702,7 @@ const struct rpc_procinfo nfs4_procedures[] = { PROC42(CLONE, enc_clone, dec_clone), PROC42(COPY, enc_copy, dec_copy), PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel), + PROC42(OFFLOAD_STATUS, enc_offload_status, dec_offload_status), PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify), PROC(LOOKUPP, enc_lookupp, dec_lookupp), PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror), diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 8d7430d9f218..5de96243a252 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -695,6 +695,7 @@ enum { NFSPROC4_CLNT_LISTXATTRS, NFSPROC4_CLNT_REMOVEXATTR, NFSPROC4_CLNT_READ_PLUS, + NFSPROC4_CLNT_OFFLOAD_STATUS, }; /* nfs41 types */ diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 12d8e47bc5a3..ad337c0ebdba 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1520,8 +1520,9 @@ struct nfs42_offload_status_args { struct nfs42_offload_status_res { struct nfs4_sequence_res osr_seq_res; - uint64_t osr_count; - int osr_status; + u64 osr_count; + int complete_count; + u32 osr_complete[1]; }; struct nfs42_copy_notify_args { From patchwork Tue Oct 8 13:47:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826516 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 4032513959D for ; Tue, 8 Oct 2024 13:47:42 +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=1728395263; cv=none; b=UrcI7ilkfs9XzDmC4u4fKCoYuTHNukb88Fnkw+ekgadzr/DdeePwkMJHnSR7TBwwFQiolNnNlu/oi7dNa5YJDlHaND8iFrR3+ovABZJPfIitOXs/Og9nIxcTfS3XiCVoqUIzcCJPb3RfBLeEoYmf3Mqsj6w6Uw3U23beuEp8W18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395263; c=relaxed/simple; bh=8pAVJWyIRIPCQ3OKk6Z2FzJsUsntFH5eloLL0T4UBe8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WnK1nPCtuV4JnmGyPs1T9mxdJlke4YniT1kkRH9WYeh+HU8gcrKvq1jU7TdYIUJCTXMDTGOxnZhLzMAn5jjobgPpNIkfYFc3rBv4FmMz2xwyZg3IdXnlyXr9hzgUC/GzeNnyi4Y0EZdj72cUsIZbA43tmoBwLLMV073ZjV1PNXM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=plNslbgj; 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="plNslbgj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32F50C4CECD; Tue, 8 Oct 2024 13:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395262; bh=8pAVJWyIRIPCQ3OKk6Z2FzJsUsntFH5eloLL0T4UBe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=plNslbgj3LGM7GB7Yn2fJCmFKCXG4I+vukMU1Se6tVCrcX3K9lZdMqnJnG3s6228D K/7HLF1dm9+HAiaVIevVxha2woTe9KFoGUd1a6zxmw6UkmuyngDMWAFNYm8loVGjiP KK9nQoMfnOqXGjWICE/P/+u6HHB+kmxb6KhPOyLkAScSVieGgQHxizcdFXXbrebc// I1g5V8Y7NCEk5YkEotZgNZyLQn+EkainI/odwCtoQZNJnq4KMgASlOATA+11QyfM34 gTouet6CFPIMMwk7GoPR3s1GLrRNCURFlUFdP/IfrdUyCzgIo8xWjpiRs2w70yyjWF nWtiZcfEv8BVg== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 6/9] NFS: Rename struct nfs4_offloadcancel_data Date: Tue, 8 Oct 2024 09:47:25 -0400 Message-ID: <20241008134719.116825-17-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=2778; i=chuck.lever@oracle.com; h=from:subject; bh=oqDViKSQ5ht7diNV6TS0pIDPsl5WipUPGufsRBDdu5g=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfzu9wnbw2OrUKWUKVOAYMrt+ZSVmjfIQ6uS kD+0zQSBuCJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38wAKCRAzarMzb2Z/ l5bkEAChncjLghwM9JHH2D89ztDL0IlCgf0QJa2akWz6+R63QaYAM0SqXC8JhSsDQZSk50UYUu8 N0fJRI0fNg5UWC81O7rK0WmUuMglGKrwbhq3IsFYtjWpCujLZnpYOp+l9SRv6LVh59vAI16mPU/ Z58xMIQPnWE0DLWwRHHw8VRD6NP+SuRypLcp6zIhI0Re/5myLqxW96sVDcX0lf5YzzZ/XiNlF0z x+yd0Mhz0xcYN2wzfP8UzuW0svmPOJ0s4vPApYtubaEe4yhDP7G2kRUkfstGKIugohjVzlnss3e gWC9Felougct55dkN9HvjLPf4jOcfnql7XhPr/FxBfD6lO0RStQLqhh3avGiRKXfaVgXv9qMvTL rmfXaysKVJwZojzD6kPKf5z/+Va8JMBR/AZ5roc0VWXtlPn3POGdxXM3jFEtDR2kbrDzcr5eGBB wNm4gMpeTcURq6NBcHeK2gfDqLnL5WrngYyrB0VS0PdkumO5A9kUt3KGOWgLqqF2yeF1nuN7T+w eXvpdVWUMal6e0Zy7PfKxtnThxZGbm9RkudMDoKEpm1v0xBSqJ3nvZbps6aZq7AeTGjKmnqU2MB qUCEYqw4G2ih5I8P8BWkZzdcMuXw7T6ijIaRNXCfwq3FCxZOxUHd2j5Qr9cJ6KDYtzrZFaX523F dzYUbPxj6miJYHw== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Refactor: This struct can be used unchanged for the new OFFLOAD_STATUS implementation, so give it a more generic name. Signed-off-by: Chuck Lever --- fs/nfs/nfs42proc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 28704f924612..869605a0a9d5 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -498,15 +498,15 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, return err; } -struct nfs42_offloadcancel_data { +struct nfs42_offload_data { struct nfs_server *seq_server; struct nfs42_offload_status_args args; struct nfs42_offload_status_res res; }; -static void nfs42_offload_cancel_prepare(struct rpc_task *task, void *calldata) +static void nfs42_offload_prepare(struct rpc_task *task, void *calldata) { - struct nfs42_offloadcancel_data *data = calldata; + struct nfs42_offload_data *data = calldata; nfs4_setup_sequence(data->seq_server->nfs_client, &data->args.osa_seq_args, @@ -515,7 +515,7 @@ static void nfs42_offload_cancel_prepare(struct rpc_task *task, void *calldata) static void nfs42_offload_cancel_done(struct rpc_task *task, void *calldata) { - struct nfs42_offloadcancel_data *data = calldata; + struct nfs42_offload_data *data = calldata; trace_nfs4_offload_cancel(&data->args, task->tk_status); nfs41_sequence_done(task, &data->res.osr_seq_res); @@ -525,22 +525,22 @@ static void nfs42_offload_cancel_done(struct rpc_task *task, void *calldata) rpc_restart_call_prepare(task); } -static void nfs42_free_offloadcancel_data(void *data) +static void nfs42_offload_release(void *data) { kfree(data); } static const struct rpc_call_ops nfs42_offload_cancel_ops = { - .rpc_call_prepare = nfs42_offload_cancel_prepare, + .rpc_call_prepare = nfs42_offload_prepare, .rpc_call_done = nfs42_offload_cancel_done, - .rpc_release = nfs42_free_offloadcancel_data, + .rpc_release = nfs42_offload_release, }; static int nfs42_do_offload_cancel_async(struct file *dst, nfs4_stateid *stateid) { struct nfs_server *dst_server = NFS_SERVER(file_inode(dst)); - struct nfs42_offloadcancel_data *data = NULL; + struct nfs42_offload_data *data = NULL; struct nfs_open_context *ctx = nfs_file_open_context(dst); struct rpc_task *task; struct rpc_message msg = { @@ -559,7 +559,7 @@ static int nfs42_do_offload_cancel_async(struct file *dst, if (!(dst_server->caps & NFS_CAP_OFFLOAD_CANCEL)) return -EOPNOTSUPP; - data = kzalloc(sizeof(struct nfs42_offloadcancel_data), GFP_KERNEL); + data = kzalloc(sizeof(struct nfs42_offload_data), GFP_KERNEL); if (data == NULL) return -ENOMEM; From patchwork Tue Oct 8 13:47:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826517 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 D6C5C13959D for ; Tue, 8 Oct 2024 13:47:43 +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=1728395263; cv=none; b=Yq4yKYL/XAlZ/wiObN8kZ7HKnHhb7pNY23L794ylquhlPZQpXoji12oyNXaeI6Ip/a5twfrb0OPrTNV1d5KQzNhsHU+h8bk67QgpMZ5NOrp4/dLjC55wat+Jh/e84bPAqY2Rg5dDo6U70muKt5/K9lyGDKesRzzYohqMjbUTaXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395263; c=relaxed/simple; bh=9CI8yTRHsiTkk+aPc/E1JM77Dh59f8kecEQpR3DPgYE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nyYgYLxYHhT6zMgqtETc6aYUq9KYhZE5wxJrlhRfMUFeIH+W36vqMitOC5c4cfJVmfozvQIbA2l28vwHHn3L4vY4c1tyg7QvBlgPiM9PUmXPqF5tJxmCN1+2h5GsQCMhiU7+hzySNTfJPVFCi3WxnMPAn++Hd+fQ+D3muiF3KeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J/waiCXf; 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="J/waiCXf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16D2AC4CED1; Tue, 8 Oct 2024 13:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395263; bh=9CI8yTRHsiTkk+aPc/E1JM77Dh59f8kecEQpR3DPgYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J/waiCXfSnbhbP7W53KghpNEcP1q83g1fYENpeyQPqU7PGQGzgySDZat2y2dJtfvN zDSz4FeMyzAmnx+YrZ3vd7TkDHjgcP36/07PnswFjxHpGPV1+CjwgzuUT9GMi4ro7H 2w8VCQcDGRDwjpxd5XxUkc0aiV3g5pkUj6YcXnBESYZjeeB/43/owbSd4GU+DV0/MN l/Ao4s+n87Wk/GjAA8BifrWmSfG++5t7qPyqLzgU75exBc0DadA7Gt9xdU2TI8A5fY WUktFe2iVXw+OsnWG+X7lwFIW76GnetrhoCWkh/Kp8QxJPEj/49Sdmr4NnPFc8kp+h KbBWnMc+JzdSw== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 7/9] NFS: Implement NFSv4.2's OFFLOAD_STATUS operation Date: Tue, 8 Oct 2024 09:47:26 -0400 Message-ID: <20241008134719.116825-18-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=5850; i=chuck.lever@oracle.com; h=from:subject; bh=n80RJYvY1xtKahZ9ZDtUSeGPcfI9YfevHhzr4FdxMB8=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfzd3OrFO8ZSVey/oyupzlPaHzcXMjPlHy+f lIdJy4pSGSJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38wAKCRAzarMzb2Z/ l49KEAC5zejXDt/MFXTyoevly09AiTk45biFgU/fixLJAcXeH5KTowc1iZrea/PhOOfCtfwYsDo CRQilQ9c/caoxHarP039BJvu0XMEDjQTm7yZTY2pUGgxq9pzNxEXUA2Y00LDVBHl8Oaxq/i7bGa 5tYCwTP3Gr8CRZ5po4JUw22u8azUxdsQ2xGyWlJnOOzuJmek182CGGwafsuRyMC3Y/Sz/aFqKx6 OHVa50ZApuGepWV37XxA2zR8nZ3CE0gWRaysZP3Bzn6eg2o+NslZ0Z8I7lmzRnMMQESFr+Mdvwm bAq1GfCjWvOtl+JxpwEGP3/bJqdKcMCi0OgtYAs5Bx79/5i7veYMJIFEjQ5e0yhBIp8sxaoBOkY ck3xBdgGQSMPW9z7x2lm6ZQitfkrCQFo5LOPbAy34w+VoOeH2n+7YdalWFTJLz3TqgKWeFoNbBT P6ILeWdjFn5pY7a4rIpPmqmd2nscYhj4rLEZHiNI6zH5eMsWfP8ThNuwGSC9Ffnx/bf2myrHSUB oHfzZdwSsZASRp93PaCE2AhF8wyYeO9cLNJHJogKYw02L1xpGJlXzF4uKvSTKoFbAmvT3Ntw1LO 78OO4id6YuLYi0C2kXE1OM6/YiOEiT76z9hRnyGhO56XgrUGBXdvS87PcW/vz8SyZ0kaBzagPA4 FHlIX3UwDtCVA9g== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Enable the Linux NFS client to observe the progress of an offloaded asynchronous COPY operation. This new operation will be put to use in a subsequent patch. Signed-off-by: Chuck Lever --- fs/nfs/nfs42proc.c | 122 ++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 3 +- include/linux/nfs_fs_sb.h | 1 + 3 files changed, 125 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 869605a0a9d5..175330843558 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -21,6 +21,8 @@ #define NFSDBG_FACILITY NFSDBG_PROC static int nfs42_do_offload_cancel_async(struct file *dst, nfs4_stateid *std); +static int nfs42_proc_offload_status(struct file *file, nfs4_stateid *stateid, + u64 *copied); static void nfs42_set_netaddr(struct file *filep, struct nfs42_netaddr *naddr) { @@ -582,6 +584,126 @@ static int nfs42_do_offload_cancel_async(struct file *dst, return status; } +static void nfs42_offload_status_done(struct rpc_task *task, void *calldata) +{ + struct nfs42_offload_data *data = calldata; + + if (!nfs4_sequence_done(task, &data->res.osr_seq_res)) + return; + + switch (task->tk_status) { + case 0: + return; + case -NFS4ERR_DELAY: + if (nfs4_async_handle_error(task, data->seq_server, + NULL, NULL) == -EAGAIN) + rpc_restart_call_prepare(task); + else + task->tk_status = -EIO; + break; + case -NFS4ERR_GRACE: + case -NFS4ERR_ADMIN_REVOKED: + case -NFS4ERR_BAD_STATEID: + case -NFS4ERR_OLD_STATEID: + /* + * Server does not recognize the COPY stateid. CB_OFFLOAD + * could have purged it, or server might have rebooted. + * Since COPY stateids don't have an associated inode, + * avoid triggering state recovery. + */ + task->tk_status = -EBADF; + break; + case -NFS4ERR_NOTSUPP: + case -ENOTSUPP: + case -EOPNOTSUPP: + data->seq_server->caps &= ~NFS_CAP_OFFLOAD_STATUS; + task->tk_status = -EOPNOTSUPP; + break; + default: + task->tk_status = -EIO; + } +} + +static const struct rpc_call_ops nfs42_offload_status_ops = { + .rpc_call_prepare = nfs42_offload_prepare, + .rpc_call_done = nfs42_offload_status_done, + .rpc_release = nfs42_offload_release +}; + +/** + * nfs42_proc_offload_status - Poll completion status of an async copy operation + * @file: handle of file being copied + * @stateid: copy stateid (from async COPY result) + * @copied: OUT: number of bytes copied so far + * + * Return values: + * %0: Server returned an NFS4_OK completion status + * %-EINPROGRESS: Server returned no completion status + * %-EREMOTEIO: Server returned an error completion status + * %-EBADF: Server did not recognize the copy stateid + * %-EOPNOTSUPP: Server does not support OFFLOAD_STATUS + * + * Other negative errnos indicate the client could not complete the + * request. + */ +static int nfs42_proc_offload_status(struct file *file, nfs4_stateid *stateid, + u64 *copied) +{ + struct nfs_open_context *ctx = nfs_file_open_context(file); + struct nfs_server *server = NFS_SERVER(file_inode(file)); + struct nfs42_offload_data *data = NULL; + struct rpc_message msg = { + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OFFLOAD_STATUS], + .rpc_cred = ctx->cred, + }; + struct rpc_task_setup task_setup_data = { + .rpc_client = server->client, + .rpc_message = &msg, + .callback_ops = &nfs42_offload_status_ops, + .workqueue = nfsiod_workqueue, + .flags = RPC_TASK_ASYNC | RPC_TASK_SOFTCONN, + }; + struct rpc_task *task; + int status; + + if (!(server->caps & NFS_CAP_OFFLOAD_STATUS)) + return -EOPNOTSUPP; + + data = kzalloc(sizeof(struct nfs42_offload_data), GFP_KERNEL); + if (data == NULL) + return -ENOMEM; + + data->seq_server = server; + data->args.osa_src_fh = NFS_FH(file_inode(file)); + memcpy(&data->args.osa_stateid, stateid, + sizeof(data->args.osa_stateid)); + msg.rpc_argp = &data->args; + msg.rpc_resp = &data->res; + task_setup_data.callback_data = data; + nfs4_init_sequence(&data->args.osa_seq_args, &data->res.osr_seq_res, + 1, 0); + task = rpc_run_task(&task_setup_data); + if (IS_ERR(task)) { + nfs42_offload_release(data); + return PTR_ERR(task); + } + status = rpc_wait_for_completion_task(task); + if (status) + goto out; + + *copied = data->res.osr_count; + if (task->tk_status) + status = task->tk_status; + else if (!data->res.complete_count) + status = -EINPROGRESS; + else if (data->res.osr_complete[0] != NFS_OK) + status = -EREMOTEIO; + +out: + rpc_put_task(task); + return status; +} + static int _nfs42_proc_copy_notify(struct file *src, struct file *dst, struct nfs42_copy_notify_args *args, struct nfs42_copy_notify_res *res) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index cd2fbde2e6d7..324e38b70b9f 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -10763,7 +10763,8 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { | NFS_CAP_CLONE | NFS_CAP_LAYOUTERROR | NFS_CAP_READ_PLUS - | NFS_CAP_MOVEABLE, + | NFS_CAP_MOVEABLE + | NFS_CAP_OFFLOAD_STATUS, .init_client = nfs41_init_client, .shutdown_client = nfs41_shutdown_client, .match_stateid = nfs41_match_stateid, diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 853df3fcd4c2..05b8deadd3b1 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -289,6 +289,7 @@ struct nfs_server { #define NFS_CAP_CASE_INSENSITIVE (1U << 6) #define NFS_CAP_CASE_PRESERVING (1U << 7) #define NFS_CAP_REBOOT_LAYOUTRETURN (1U << 8) +#define NFS_CAP_OFFLOAD_STATUS (1U << 9) #define NFS_CAP_OPEN_XOR (1U << 12) #define NFS_CAP_DELEGTIME (1U << 13) #define NFS_CAP_POSIX_LOCK (1U << 14) From patchwork Tue Oct 8 13:47:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826518 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 D012713959D for ; Tue, 8 Oct 2024 13:47:44 +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=1728395264; cv=none; b=d2Pdy+8pk2a4UOHl2e0zBdVQU4AMBXnYz5TXl2z6oIdmGGhlSj/GQ7gG+MIsRyY4dr3vdBZBNWhNsYXk/VSIYTNbZa5gDbZiNv7nGQfkVHKvDF+OunL5uWHmIWHRAB4HnPdC6AEblwKS7QCoFqcBhlxqeUl0vu7RZI/SzRqIYQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395264; c=relaxed/simple; bh=q0RETyiCP/d0baSmOVxrwtvB8fHv4FHoJ2JK18jFLBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m1qrrwzz5eDbVlln90GM69pT8GYUnw5jQYqKNt/HoUFfgi2ZGyItefClzUGr5qZ3xQlYa7lIPz1R7xKDuAsNSPu8cK1pC7xczxhDH2l6afxBa9LtLPSPDP5pkliG7z/KLLKMmIAXLt4am3NawroUtb7nN9/WLgYNVWtAfzy23wA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=czXddXHx; 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="czXddXHx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0628C4CECC; Tue, 8 Oct 2024 13:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395264; bh=q0RETyiCP/d0baSmOVxrwtvB8fHv4FHoJ2JK18jFLBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=czXddXHxlLu461+p+kKRuB41YuFLHF/cLNpmhpTvnQtcKIFfGT4rtZR4uV2u9TQAd n8Fdz+R8rYnVlO8ua0QjA5HWCNQCFpGKVVfyM40+6SrAdr0qhrt8CKHzHd+FRYj8LD n+vDTryV47+RTudxg4i0T91aozxjPwZgO3TxCOcGBDoa34RS3OIT9voGiB60F+dM+r UHuh8Kfy4+f/zetmNiBg8c6PJ66fy923tmqVXROXaCLsKE2WCL8FreazllyPVa/Rxp 11RRzaZq7bxL/lrihS8TF20SFbsMzmSjYQP03CdeoFGn+BzNu/ca6TNlIjXIVupB4f khHCJfQpGq57g== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever , Olga Kornievskaia Subject: [RFC PATCH 8/9] NFS: Use NFSv4.2's OFFLOAD_STATUS operation Date: Tue, 8 Oct 2024 09:47:27 -0400 Message-ID: <20241008134719.116825-19-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=4536; i=chuck.lever@oracle.com; h=from:subject; bh=v+/LHBuN8ciCwAoUTfr98DwrUyGBgKIMqQuGP0oqoMY=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfzaLEw1zH1dt7+vSFzECU/hM8iJjAehRnMH d6V3gntT9iJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38wAKCRAzarMzb2Z/ l0IpEACDWBMgDC1zKZemc/F2OJ2typRA5EY0Yo5rgDcvnpDo6Wnuw6izC1TDJFwXV/RMCBBlnnN fYneHpgggchmzdAtkqm7Z78aNUIpqaQlPw8Si6Zv783rh/xMJPsKMtcFi3TeBLhCvtMU7GSjtn8 /kox/IlEcklixTiJCa/pA4U9B++G5eHFHd8Xo4GlCV0J0F3Ial9b9/IgHxWZ3DxaKRK/8cpQhBF yx+Xp97IMND4RSZasUt+b185unA6tZsMzATe3CwX3lZoFnYVUnYznEGLqHv1tq00z929QQPeGh8 DzZWn+t0pTRF6QSX8G0ZVtk4Ze9iF8xe3zL8c2kPz0yAtqBgKGhjciaEVcPRcQx4+kZhSWWlq3f ck8kzVpmxNxVFTpQkt+x2J1isD3CtQrV20QJeK9im4FCIgXPHZ0HkPEbk/5N/9w1XxEjnAHHAYf cew385w8tk2qCbPjT43zfDiCrOXwWbbEFCNuZtQ0Yyq2iw9izrPwvdQWX361mbGe4+8/C3mG7OT ydCBeg/jLL3/fGEh93C5KDj4VO2sxozHvREzVbZu9SdSFEBNb7oq84oDSg2mlEpxpHJyA7DvC4s 3O2R2/bmgRPmB62TvwfnVwAUDSeL14hoGUAB7kM8HcgA4HijJdWm9XnixMq7n5wT/SFCVQrXIPZ 2JEgIdZvSQnX5gg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever We've found that there are cases where a transport disconnection results in the loss of callback RPCs. NFS servers typically do not retransmit callback operations after a disconnect. This can be a problem for the Linux NFS client's current implementation of asynchronous COPY, which waits indefinitely for a CB_OFFLOAD callback. If a transport disconnect occurs while an async COPY is running, there's a good chance the client will never get the completing CB_OFFLOAD. Fix this by implementing the OFFLOAD_STATUS operation so that the Linux NFS client can probe the NFS server if it doesn't see a CB_OFFLOAD in a reasonable amount of time. This patch implements a simplistic check. As future work, the client might also be able to detect whether there is no forward progress on the request asynchronous COPY operation, and CANCEL it. Suggested-by: Olga Kornievskaia Link: https://bugzilla.kernel.org/show_bug.cgi?id=218735 Signed-off-by: Chuck Lever --- fs/nfs/nfs42proc.c | 56 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 175330843558..fc4f64750dc5 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -175,6 +175,11 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len) return err; } +/* Wait this long before checking progress on a COPY operation */ +enum { + NFS42_COPY_TIMEOUT = 3 * HZ, +}; + static int handle_async_copy(struct nfs42_copy_res *res, struct nfs_server *dst_server, struct nfs_server *src_server, @@ -184,9 +189,10 @@ static int handle_async_copy(struct nfs42_copy_res *res, bool *restart) { struct nfs4_copy_state *copy, *tmp_copy = NULL, *iter; - int status = NFS4_OK; struct nfs_open_context *dst_ctx = nfs_file_open_context(dst); struct nfs_open_context *src_ctx = nfs_file_open_context(src); + int status = NFS4_OK; + u64 copied; copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_KERNEL); if (!copy) @@ -224,7 +230,9 @@ static int handle_async_copy(struct nfs42_copy_res *res, spin_unlock(&src_server->nfs_client->cl_lock); } - status = wait_for_completion_interruptible(©->completion); +wait: + status = wait_for_completion_interruptible_timeout(©->completion, + NFS42_COPY_TIMEOUT); spin_lock(&dst_server->nfs_client->cl_lock); list_del_init(©->copies); spin_unlock(&dst_server->nfs_client->cl_lock); @@ -233,15 +241,21 @@ static int handle_async_copy(struct nfs42_copy_res *res, list_del_init(©->src_copies); spin_unlock(&src_server->nfs_client->cl_lock); } - if (status == -ERESTARTSYS) { - goto out_cancel; - } else if (copy->flags || copy->error == NFS4ERR_PARTNER_NO_AUTH) { - status = -EAGAIN; - *restart = true; + switch (status) { + case 0: + goto timeout; + case -ERESTARTSYS: goto out_cancel; + default: + if (copy->flags || copy->error == NFS4ERR_PARTNER_NO_AUTH) { + status = -EAGAIN; + *restart = true; + goto out_cancel; + } } out: res->write_res.count = copy->count; + /* Copy out the updated write verifier provided by CB_OFFLOAD. */ memcpy(&res->write_res.verifier, ©->verf, sizeof(copy->verf)); status = -copy->error; @@ -253,6 +267,34 @@ static int handle_async_copy(struct nfs42_copy_res *res, if (!nfs42_files_from_same_server(src, dst)) nfs42_do_offload_cancel_async(src, src_stateid); goto out_free; +timeout: + status = nfs42_proc_offload_status(src, ©->stateid, &copied); + switch (status) { + case 0: + case -EREMOTEIO: + /* The server recognized the copy stateid, so it hasn't + * rebooted. Don't overwrite the verifier returned in the + * COPY result. */ + res->write_res.count = copied; + goto out_free; + case -EINPROGRESS: + goto wait; + case -EBADF: + /* Server did not recognize the copy stateid. It has + * probably restarted and lost the plot. State recovery + * might redrive the COPY from the beginning, in this + * case? */ + res->write_res.count = 0; + status = -EREMOTEIO; + break; + case -EOPNOTSUPP: + /* RFC 7862 REQUIREs server to support OFFLOAD_STATUS when + * it has signed up for an async COPY, so server is not + * spec-compliant. */ + res->write_res.count = 0; + status = -EREMOTEIO; + } + goto out; } static int process_copy_commit(struct file *dst, loff_t pos_dst, From patchwork Tue Oct 8 13:47:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13826519 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 E24F913959D for ; Tue, 8 Oct 2024 13:47:45 +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=1728395267; cv=none; b=Pssj+xD5JbkT5Ds7vj5D2ArTBDgYJ/z8DVahU9PNxriVOyAftdy89AsWj0WvQBLamfAkMrsa20awizkGJ3BgzfD1D4O1qAYJZrNaE2mbfwvxrIPGPltaKaEKb3a9GeQLPuNsz4xu0EZseCbSJUte8uF96hCrEdD1r4pI5pgrEVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728395267; c=relaxed/simple; bh=mTuGx4SVXiwdAajUEXjZTtwIyz4nkfEwR1uOqVPMuCc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aalz7SBBUJy/b2ITzdCN3KUEvot4sWVgKNjs4DUHurbmw6CoRcmijEkJ2khRuSIDiddKLYnvt27tqYwYthC5Qqykmg3GBRmBlH6Heqs0VzE0qFnYTvnA8YEnnMFbIDCrHZPUv41mGAKzrL6s1mi8WHjN3m6eiyxAe5CuO2elFEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jgb/kUVz; 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="jgb/kUVz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9E99C4CEC7; Tue, 8 Oct 2024 13:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728395265; bh=mTuGx4SVXiwdAajUEXjZTtwIyz4nkfEwR1uOqVPMuCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgb/kUVzwMJEBLjOkqbQL/DBXvwrpJJdNjiFS9+oAK+4Z+twyWCYNtheONK5sjWCU cAPCwfqlcttGZcRHfpNhJ3uvuRI5+Cosx4Lw4YJMkm0/5joDU3bUUhvWGPRosnyq99 J6KddWt+l0hzi5oQV0IW47DKAhCjqgAEihXxKmP4dNb7idI9LKjvcAIgvpeDWJNYRH 31aKZACCEXWM7OkZOvCaX2MRE7iD4arua6t9Hc1IJeaBwSvlT6n5KxxXx5/D6M2Ld2 tXfZQAGUttm0ezy8rl5x+AaOgeK+ZKD4fI5k0l3lE83zGjRvRT3d7J1xltAxqoMJTN C/92vQv8t2sbQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 9/9] NFS: Refactor trace_nfs4_offload_cancel Date: Tue, 8 Oct 2024 09:47:28 -0400 Message-ID: <20241008134719.116825-20-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008134719.116825-11-cel@kernel.org> References: <20241008134719.116825-11-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=1772; i=chuck.lever@oracle.com; h=from:subject; bh=IaGhxkPgZ+sQTuTFNMR0JSleOsMlw4QR5wI39oikoOs=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnBTfzpQmb6HEtYmELUH9elKb7GPIoET1mkTsdw yN2KJkGdV2JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZwU38wAKCRAzarMzb2Z/ l1nGD/4k9s+d7eWx8m1eBDB8lycftq2Kvm0yaiLjCpSmOq0eT0lw7v0LBx4QAWZzfC4QzZhK3SL +1JUUxE0mJ56w/yodviejjp3TFcV21XTTYH/pGzFHjneqhh15qDFS7odowVBCAvxkLP1toe9i99 kIZMCYbVOeMPr9VQ5xSUcUtHFkyGRrCoRHKVsOuwBLMg4CuoB5iC89ukR+XrQC1XmJQik3q2+/e D7B77CbaYEzhWhHbiZOWNVGTyCcjuP+hlmMEPNi+V55OV7sNTToumphNkMnr8mmIFKDoAuAGiiw nNHJoKekQq/QG911bMPRP/aWIAnu1lA0RfO6x3r3D6i6/YRU6WSya8AXjtnyeFG0CVif7dwTtZr VoE2BocKeFkqOQ8jdyabNYuumijXfbnjnPWHnUUCGlTVIWHadPLC2pD5tf7MJU4GaD8k1dWR/V5 jK9gF6WtlWud5lANqX0wUmRYc9R9oTJfxfF8wHu9Fb3ZZN7j8eH2fMYi5XuRV9JI9avjYhdiz1f oGfrbq789mDy75NbPL/i7yssuzCv2SemalVhOefVuSW12m2MJ0mLdvw/BPEk3tt+lKXlCQ0iZuD GPUIUPyedg66c208NwVsaV9XHMEHbzcjYESESMt0MhReuHAuxbvBRlE4zC1+Y8xNElRqBZxh497 jHkfGY2Tf4uiCBg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Add a trace_nfs4_offload_status trace point that looks just like trace_nfs4_offload_cancel. Promote that event to an event class to avoid duplicating code. An alternative approach would be to expand trace_nfs4_offload_status to report more of the actual OFFLOAD_STATUS result. Signed-off-by: Chuck Lever --- fs/nfs/nfs42proc.c | 2 ++ fs/nfs/nfs4trace.h | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index fc4f64750dc5..969293bf8228 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -630,6 +630,8 @@ static void nfs42_offload_status_done(struct rpc_task *task, void *calldata) { struct nfs42_offload_data *data = calldata; + trace_nfs4_offload_status(&data->args, task->tk_status); + if (!nfs4_sequence_done(task, &data->res.osr_seq_res)) return; diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index 22c973316f0b..bc67fe6801b1 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h @@ -2608,7 +2608,7 @@ TRACE_EVENT(nfs4_copy_notify, ) ); -TRACE_EVENT(nfs4_offload_cancel, +DECLARE_EVENT_CLASS(nfs4_offload_class, TP_PROTO( const struct nfs42_offload_status_args *args, int error @@ -2640,6 +2640,15 @@ TRACE_EVENT(nfs4_offload_cancel, __entry->stateid_seq, __entry->stateid_hash ) ); +#define DEFINE_NFS4_OFFLOAD_EVENT(name) \ + DEFINE_EVENT(nfs4_offload_class, name, \ + TP_PROTO( \ + const struct nfs42_offload_status_args *args, \ + int error \ + ), \ + TP_ARGS(args, error)) +DEFINE_NFS4_OFFLOAD_EVENT(nfs4_offload_cancel); +DEFINE_NFS4_OFFLOAD_EVENT(nfs4_offload_status); DECLARE_EVENT_CLASS(nfs4_xattr_event, TP_PROTO(