From patchwork Mon Jan 13 15:32:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13937655 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 A4EE21C5D61 for ; Mon, 13 Jan 2025 15:32:47 +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=1736782367; cv=none; b=cbT53EuDW5kNHwKpTFJS14KzU0KYGKIqs0qirrnnj561ZZJ4k9T4FAnzYFV/hgujGZt57/HlcwI6KCQJpZTJn7zrF9DPtD7Q7ouVVcSON5j2ib59LZLfxfKXJXZZj+GN0dcjmFkxI/7DSwaVdfOmKceKBoQzfNUTG0E40BMNkEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782367; c=relaxed/simple; bh=IkYQKu0ekNg3AM3qZGM6i634s0oQIoV7/1s0LxyIzHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SDX83fQvz32ovJ+3cP8MoZKnI5LCmHf2d2fynT1Gjleh+60w7AEikB67HaUl14GXTmI9XBZuNQnyZlHgwyW1HNTK07bhaYoBnRulx0IVZY5cMq2uTUQjwLKpgvjHBhCH4uHKVRnaYolWZNZTn0JWuqa3svCfrx1x7W/6/2K6LX0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K3it+4uQ; 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="K3it+4uQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F9A2C4CEE4; Mon, 13 Jan 2025 15:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736782367; bh=IkYQKu0ekNg3AM3qZGM6i634s0oQIoV7/1s0LxyIzHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K3it+4uQmzQ+MtDOPKV2GbLyyuVHLoQfBoro7DnmAyWbAQjiwPOuY+oll+JjovWXN Il8/ba5QTc1QgL8MbdqaenuIrNe/Icuvr7LN2u4ESwsbtM0rOsnMx1+8PJzgAaMngV IPPYC5LOYeXEOJNQNWByFVUqOnDD2I3B6b1cbMAxrWu4ZxUStkJS6pTDGvgL3GspOb +Tnn0B1Q6HTKkPZ/K4qQlAYBGV0NJlXHmVHiR/a7paFcHZKj0ykxunVBi3mzry5Jbv YR/cqBCxPOCvgscViikgBsB35+V5M43LGUlleVekcnfFGpuAZ9keFYnye7EJQlJexr uDxM1eMwNOHcQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH v3 1/7] NFS: CB_OFFLOAD can return NFS4ERR_DELAY Date: Mon, 13 Jan 2025 10:32:36 -0500 Message-ID: <20250113153235.48706-10-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250113153235.48706-9-cel@kernel.org> References: <20250113153235.48706-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=923; i=chuck.lever@oracle.com; h=from:subject; bh=UQXPAlUj4VLIOdz9PHZi/z9NMFIjPoUUk4StFgiNZVE=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnhTIZFUTB2bFPhGkk3GO296msNyyyrvuP0MKdA ZwcaGfbSfSJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ4UyGQAKCRAzarMzb2Z/ l+ZbD/9QJ/rvDSTjDsqw3BwCmcJBdx9ZLYXHzbRRKrVXHlpL9Th/wE+Bi8eKPSvQ7nPyTPMLSsq sA00DIPciYRSvrQ1zPKGjmSE+6gROE0rgU/ZUC7B2b1by06R66p/3Q68lSZioIdtapBwRnpASjt ag4cxkuHgw0cMt+NXVel+LofOOzd/MtKy16gnnKtEN4l1tPxoakKQX5sbTdv34PjZH7VM6zxy0j iS2mVrrf1BtSa5hP/8C7lI0Mj/3asqxa/hc+go80M36Oh7ewNK7qmuUKdVXx71HCZEARi6ZuiDc V8j6tZrKZJ6IV7+ccWBJ48RpTMymmzzoQonD5+FXrkIYCka4yVe4P7yy5HnsyUmtur1lgMxdXrG J4huwyt7UsIwS//3a6lb5jlgZbE2E/WeR3MoD9gRa3lAny1DE65XAxxnW7OOWfNaQmoAZHiA8gM a2I/yuAF9tY9ek2/AzYyl/Sb5mAFAl3taIVkhN8l+6jKtaedRd6XRox9JADUaFxu/f11ADAKYm1 bDjUgwDuko53VGK1FfqUzJeBwk5s6ChSI8i+i2xJbuxd6XEQHGxm3Pq3Ng+nhn6BY7JjYuURlNq ueZ0pBQXOrfotAygEuOdSqxkQs+Y0uCjV+tjcNfRQVtZhXC1CjdWprZvc/XCuFG3pVq063wr4w/ UxMdfBFJq4e6tEA== 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. Reviewed-by: Jeff Layton 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 Mon Jan 13 15:32:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13937656 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 862751C5D6B for ; Mon, 13 Jan 2025 15:32:48 +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=1736782368; cv=none; b=nsf54bMlABF0h44MW95OinfM0tqng7QTlivWNxbw3IjqjJGturd+SeH1GMAovzefKlj8sR9GcQsZvoUK79qoC3X5aVNY24RMDl8CEd6v3gxqDPMM5dfC7g2JrwyMaeoQ2fSSumpp7JNls9v37aQDT9EDBJpxlPibXsjorSJqA6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782368; c=relaxed/simple; bh=rd2ZxqoDE8xaiQZHHzsxsiiqvZp3P/CginDdmiIT54k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eF4mjDaJsHPydXnFhc41onHd0gyicVwKRKErzZGkShTXuJstsf3GcsLYWwv48cDO438FcLJ4Msex1vTrjKrjcMZhI6GvIGAgtLb83ku7GFl0cSl/Y4qwg97bEmeEakCPnknwzCzFEuxJwJ1unmhLhI/DWfcyumt5fzXAKUmCJIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qSmg812u; 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="qSmg812u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B253C4CEE5; Mon, 13 Jan 2025 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736782368; bh=rd2ZxqoDE8xaiQZHHzsxsiiqvZp3P/CginDdmiIT54k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qSmg812u+dMlnomVpEhfNJYgnEU5VsbcTbEuDzDraJv29l8Q1M6yv8FIF/S2szVU6 0U44gKbiRZ4OFxM/q672N6U1Hb8ROaTFUqTvIRb4T5KP6NlBDCWTUtYvL1wkvMol8E g19LVCdwa0DWiAdHkm3kkOUdV7zLivXzOh17T/DRLZeNH5euguMaw3EBRgc7mGiGQC UMv1ZRdXgGIiC5swy1h9AhWAG7WsaqfC13q8ZFi8wIRpJCEoujNuqi292kh5NFSP63 FUrHvBD9osOKZ5EwbcgSNTiJSk6m/QgHyN42gwc+9FrQMuPkzebpd8Qr1punTwT6qq eW7MH5ubZ0rVQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH v3 2/7] NFS: Fix typo in OFFLOAD_CANCEL comment Date: Mon, 13 Jan 2025 10:32:37 -0500 Message-ID: <20250113153235.48706-11-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250113153235.48706-9-cel@kernel.org> References: <20250113153235.48706-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=593; i=chuck.lever@oracle.com; h=from:subject; bh=mouARqxISM1482lXkswzcHqamIqKqvoBpq1nGC0q9JM=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnhTIagnQg9dBjNvtAL9LGkYTPANb0B6QbD1pgr 5bO9a78mR2JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ4UyGgAKCRAzarMzb2Z/ lwzSD/0QiClIOkddS+WQZvgPI4Ztijm/XSVucyy98aA18LFVFRCh4W9aHoa33Egn7Afevsq2cBj fb9CcYOb6BSvcmtBPnnou8TEy3dF/VH8pKPXYEqVAB28lJH2z5lozqqWnQWtZYLNdJqQTHT6Xmv NAkefOkVTGq3SenpRCjrL6xveB7yMTL5AH3BoCqwOx9h+Vp3kg/lk5RCtmJVD0USIgyOhz9A2gm ckYoeEBR0XGYOgIRA2B73KO9Q1TQpoNeVyVf2/qqCPOqjQKhCDsc4CFNUyQ1oSeNYc38IVgfIUV pdHsZTa6DR/LqoQRIVFSQQuuyRSVSiMy1QWFPkF7ca2i2G6s9XAMNPDExWsLSqea78ohy4AWUQb S7+mijK8TOiXPpoBnH4eaH7cv+Ac3j5Iy2xS7XCH8eDlRdfr7+kQwdQxCTkOFl8HkQaLaIhovQ+ shZTfnx0X0TFP21yZPQ/XZPsTSieGGfVuJqCHE8KJREPY7l9tMCfn7ecjKTn+rmge/2K7dhGYqU LPU71vKMUOpSh3VFtxZ3vf8KdO3c7VzZjsXcY8TYnX8oPbigLy08xcgONfGBsUaWVHFId3JbTKX 9m8XfHxURKIHLhEQNAR5VTNKQ4HX+63tEiD7/dWL8DG/T9Mpb1ZhNqS03fajNUiT9W62GOps+zh /iE/vv8qbsMtVLQ== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Reviewed-by: Jeff Layton 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 Mon Jan 13 15:32:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13937657 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 5BF841C5D6B for ; Mon, 13 Jan 2025 15:32:49 +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=1736782369; cv=none; b=FeiCwL4xDi3Yen3C4iP0ffFmBCfIuTpqhVsQvDPqaaKwIutSx6jmdIaVlk0rjHMr+qsviLcysiG/yNKCs17rIJCV6W9PxnJyK7CsqZrByqUZ9t6XhcKj449HX1ZGPjq0ZYyFJ6iJ+w0gHi/LstAN+Zus7duGB2BQ8yRfMVCZkM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782369; c=relaxed/simple; bh=gvBQn0hYPgX1rOI21+gUboOSFVb4hUiJCGma5brf0ZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Omhm0QdyjqSqBlIcbuOlCeI5MUNRhuJbf4GxKWrbWeXszOCPVCkucn4XhgxQA/liVVFgx/gHZD4k/etLZq9rI3bxt2Dzp9sFVPiPDbNHY+UcwztPLveKmDDrvigPsK6pv3GFR4am08WQBPaLV5WC2tKX+1NIxbBVfD24g/Yissg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rtCvqAz+; 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="rtCvqAz+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44AF2C4CEE4; Mon, 13 Jan 2025 15:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736782368; bh=gvBQn0hYPgX1rOI21+gUboOSFVb4hUiJCGma5brf0ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rtCvqAz+Tn06ma6/Io259GBzAyPPW3dId3z1dCnNvQ/G/BmcAM8yu1lSkXAhmikoU wNK1HTFUn3BovtyoDLWBVC1m3f5j51mB4m6ofOoBoKWdoTkmtDLmB4jS/UUlxwhYvo +UJz8/d5KownC/8PGS84WR2aJX4RUv4uMz4ptumyuawvgvWVPPy+YwXiGlAEUetqfI 8delCqrXsW47qpHc9AKUw566Q91zW5HMXgWGumAjSGxmmmq9LQ9Y228aIT+3qcKdca ilmF7aApKmcJequgcsc67iiwkNLf2kjFqct7l1Rr+3ISZJWPZusTX+XuPj1+ICvsy7 RQ9WqwpgupktQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH v3 3/7] NFS: Rename struct nfs4_offloadcancel_data Date: Mon, 13 Jan 2025 10:32:38 -0500 Message-ID: <20250113153235.48706-12-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250113153235.48706-9-cel@kernel.org> References: <20250113153235.48706-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=2825; i=chuck.lever@oracle.com; h=from:subject; bh=99XHjaBPukWpn7lNCoJZQykjg0wceaCYqsgnzbi99BI=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnhTIaRNM8qw9liDvQmHuXAbUJlfTVIWHr9bB92 aQ5siTnGNGJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ4UyGgAKCRAzarMzb2Z/ l9xMEACuiL24b96MaMSZ460tUmlA7TiXtMMhQX6nbMYGwDnSybqZMGt7cqhmSHL973dwCZ34A+n teQGYiRc3rc7JJNbcxwWhrUvT3mNZQIhE04Srr3alv1Wyt4+29CBNzGd67whN8i7vS3rIatrXtU 44H25GfAfjrdVq38kKE9/fh9cUm8N7UQpaGwzRcFX8+w1Dc0JT9e8jXxfZ5KWR0+Ieo0Urnjw3E BGVraaQ1usxkM0Wgy+rlpyW8Qy8orEm3p2pw8oRvIUFTdBaX5rtZawRhSwMh38WHNZE+VpZstEh stkxf8X6GlTX1b4tR2bQIIxWY5n4s7vm8RkV+JG1fjMCvMNzU5hH7e9oF/iXS/Q3GHgeBlS8E7Q n/oiIQrLj7VtcfyGWtRJ+cG0TEA5BjJjJBqP/WRLWtcrtPv/gJKAQDxlCMFsHAyYCC2t7+ez8/S 3O8G6MUixvqKG4xag/R8sYSZoYobpm6gJroeBUwbztW017F6iCoa/07t/uwLBXZKd4YUjDwJ6+S lr3KwJDKEwBAkeCMl2nYRKcKFEADTBHUFgPs4xmltD0Se8dRYMvbbWm6n9Q+Uq+EmzCAatm54Rf HSWArlJ2B9Om3cApKm1YsKpSJFezDUCMSm4ZSfTJzCoH9ICbRd34i8LifG3Ff6A08b3SwlhwHD7 V9C4lT2igbe7sqQ== 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. Reviewed-by: Jeff Layton 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 531c9c20ef1d..9d716907cf30 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 Mon Jan 13 15:32:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13937658 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 48C8A1C5D4F for ; Mon, 13 Jan 2025 15:32:49 +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=1736782370; cv=none; b=jT8pHauTn75NbafOmznDvn85B+rRaHAM0XR6JIJss6T6Q+1JCCO0leeNA1RSqOJ1rApEfV36MuQFkNfs+1+jyzSgfAWVkYvLomIXGmXECfW3PsscQVHOHbADdChHheiHYp9u3xtjhNI6Ec5efmffi37KV5cnmmldC/ZVwr1Fsic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782370; c=relaxed/simple; bh=9ESQg7KqaiZejbVROqJA6sQpvxMHcZf4EsfmZIbUn2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=epF65ME6TV6JT2E/0ab3WDFRpk5uis6KkOkDQIVBdrf5Zb4x6iBeSDwzW3iAmmNdrJff2sThyDqaxfFyMxacKJeXR42bZvsuzwAzzYWd0rrH6YP+SgLDDM9f4tLyLMoxa3zqc/wUw0HNF9T5AkjSttFlsqtWygxRXAcKC8eOv3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QOBKU0db; 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="QOBKU0db" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E259C4CEE3; Mon, 13 Jan 2025 15:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736782369; bh=9ESQg7KqaiZejbVROqJA6sQpvxMHcZf4EsfmZIbUn2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QOBKU0db1/bgFgfRwZO5JvSGflSZfY4mGc29D8jrxUMBdEUkeIgswCri/EBwRjHBt FanTdIhiutvuBzCCP2BlOz2ZAY7RY+knjQ/NAEk+pVaU43CTrWYv3pgk8eh4WJhMLw KY8swJnmYnWwQqgCsVCdB4sT6mQid8D1YRTcuSkkZh6WesYAQtDSMMyTenkaEwzpxW RB99q1dYEbXeaVHKta5DNmI+PDXjDgY5iBjh68PwqBVczQ7YX/crKo87UqdqdQU+NG O39vd0M2hY9L0jmj/dG5CEEU89YA2BSZsLYugUXYrl0PaYUr/0u9TtfXorXhmqUgdH bo+tEPYzJkBhQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH v3 4/7] NFS: Implement NFSv4.2's OFFLOAD_STATUS XDR Date: Mon, 13 Jan 2025 10:32:39 -0500 Message-ID: <20250113153235.48706-13-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250113153235.48706-9-cel@kernel.org> References: <20250113153235.48706-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=5839; i=chuck.lever@oracle.com; h=from:subject; bh=5skOVYdGzJnHGNfdQalH1CauZDqdcwSDW3RSNzfQPa8=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnhTIae4wPFS+MvO8BYXPDMISWibpRAZbRAkaxa ZiK7lPiakSJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ4UyGgAKCRAzarMzb2Z/ l/bdD/9U7JcpZcZ7fxvHa3+KCN5NYutHhwhmU1bUAEYUQUkC9MsK5+IWLtIfYofe8QJ23xcoQxV neng22D1vnDFsG0D04vg+opemmG2g8xAHtLt1b9NBWuLOOTsMoXW8/ibPbVwI6WKQjDCqbM9B7b eUNgmNCqNu3jBLoQYDbsvSC13Nw+NtPdTMQV6/5bCrq0MvuXTW7qS+//WcPH6INz93lnMn+ow+N KUm+S/CD6IHGLsKX2ABlhgw4opGFxuOj9kYhwY4nZyxb7zC1kbaGoKFoQ4b5YqypXW7+Xn7HubG QlnlEHxvytw8Nmy4ENi+WFtMZbjOqde84sH+nI0JS9Wl13JLTEYvbveqGxVyi8y6YJCnOjyXnKP phHpx1fNIVyk/O8lF5J/iZW2YwMMTZFtLoxhe0Z+NpDM0d3nl8O6l431q/lRPNNGZ4DgV2MBD7W gkIrl793agRFRB6J3CfADGCPWFXNod/Wc0VQhQDZx7A2J8BhwxylemCfwn0GGdiqh3ypYYsYsns j8PDUGF9Tjlg/cwgLrks9PHY7AP3C+16NWorU0ynH2M8XAz1xZu5ZUStdF8wo/q0cybWTrb5wWK yOFD1zygeKwVfSwOIoRH/qhGjKqn3RZi9Xll0xv7Oyaed03LbN3u+W4VjYxLuVK+4FI5/bnBAGk yZdV59PkrSTkrjw== 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. Reviewed-by: Jeff Layton 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..a928b7f90e59 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 559273a0f16d..9ac6c7a26b44 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; }; struct nfs42_copy_notify_args { From patchwork Mon Jan 13 15:32:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13937659 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 286AA1FBBD4 for ; Mon, 13 Jan 2025 15:32:50 +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=1736782371; cv=none; b=XbGWoL2k0XP0PuHJ6wvyWAqTXPfGb+Atmn8iwsZmAjy03GROYPu09jd5ba7iv8dAI2MaxiINDXUEGAVBTJKHBoT6cu7gs8fYb0JFt0tv8/OiX7ykT/jn0JXS5y4oL28MmFB2u2XOnELdq5w9ASc7BoSG2YyT1epn7RYPOGidsGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782371; c=relaxed/simple; bh=NpDrhUg13464ShKgMBnN+WPef70qhHI11+pKs7Vicaw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JhZ6FcXRJzOBMBvzuNJp/44MAOUZDNy5EvvpgwsdmXjOlFnhxMoOLAcyxesnOykZ0Z0KcIOnC9KxWS7oQBofnpGltmI89Ygsy30m88tiTf8pzJ3NYCDt556oib97egc9vfh6hpRca40dKoiyqIbXF6G1XoMv0I6UTcz8bUxX+S8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AedY1A27; 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="AedY1A27" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13E18C4CEE4; Mon, 13 Jan 2025 15:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736782370; bh=NpDrhUg13464ShKgMBnN+WPef70qhHI11+pKs7Vicaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AedY1A27l1HyOHdpogX8PGYq6bhbMQM0ptR4Bapvs26pyKrDWb3fJOl6duj16fKUH MOgpFj4RqmZngOrxGSKhK2lY7G/IzVfr7nh8OyAE6MQ5a9SdRMLgrGWSR/0UREd8Hl /qWza2sHRb01qXVCAxhTUj+J+D+gSefgbL683Tc0oYUqqGUsXayXynTKnk9Zy86eWs rpSpMZowDKmHK8i7zB7+tCEpAIpeW3E3nmEZURyhMIf54Y3BCXCI3F3aJSkhwWZJKG 1VFs6/Blj/O0at6p550XMGuY9kNEmNOLrLUt+8QAqt5WZH+Jud7daQBFq+ScUuuo98 uDgRvsm4o3NpA== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH v3 5/7] NFS: Implement NFSv4.2's OFFLOAD_STATUS operation Date: Mon, 13 Jan 2025 10:32:40 -0500 Message-ID: <20250113153235.48706-14-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250113153235.48706-9-cel@kernel.org> References: <20250113153235.48706-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=5197; i=chuck.lever@oracle.com; h=from:subject; bh=U6fUcIARHwP9x5OsVme1NO6lN3U1mXLsRB7y4MhNakQ=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnhTIaaggv//8U3uVi0am6kr3wH4n8Q6SgUFLsd nx3QYg9c/KJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ4UyGgAKCRAzarMzb2Z/ l3JMD/9Gshp4D03JiX6AgWsHkFA3V3XEbwPaWvJfnHWZ8T18PhfmIXwjudEJsfoHzp3p6Bsn/dt VxEDDx9uLPZTXcchsgQVmi+P1V2fOrxTqoDV48qRXx+4ZaiLxen8KcevvoYxL85oerOQppFIwTo IjjqhQeYB0Sb+8Hq2PY6pd8JlSgxfoyTijyvPZuHaF0TnWTYU+3pcida7DpEDqsKORDbKuZVy+O cYxbMObbeBc1sge9lJxFvkQXymZRKqBbJzbQtB+vA18QsSOety5KsMHGHcdSWFN7JPj6yooWsBD zgnKt53Qr+kUfObBkoUGIfVyeqY3Q4eSnhBCR+ZrGnPMlhXaIUaI3Lp/ZZ3J5hSdAC6JoTiWVwN DstIbmmpg+2+vJw1h3FL2lbxWab1p/mJMpEqWPEkeVS/1wc0aT/1rQ0oG3mNWk+ToRQoEKqT0iK Ta0P5FMt3Hih8zbPud7cu1ViBzGwDHWBg1r1jo7Bjdty3X2ulPC5SmOj0iAOEV5cEHrK//DKlKb pg7r55ucdTi4N7CxMa/hOiyJjWLLxiB0BmCFZJvauMqMqI5D6fHJUkR6vsRlIKKZUmvh0PD+rfM 9iLoeNrMDMtzxiSoFFFq8Sb8YnrW/QUw0bseloC8+asjO4G51Ft0I5WbO5wM0L/e5Elf1n8cRzT 3XNs8jTaEK1kaxA== 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. Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever --- fs/nfs/nfs42proc.c | 103 ++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 3 +- include/linux/nfs_fs_sb.h | 1 + 3 files changed, 106 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 9d716907cf30..23508669d051 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,107 @@ static int nfs42_do_offload_cancel_async(struct file *dst, return status; } +static int +_nfs42_proc_offload_status(struct nfs_server *server, struct file *file, + struct nfs42_offload_data *data) +{ + struct nfs_open_context *ctx = nfs_file_open_context(file); + struct rpc_message msg = { + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OFFLOAD_STATUS], + .rpc_argp = &data->args, + .rpc_resp = &data->res, + .rpc_cred = ctx->cred, + }; + int status; + + status = nfs4_call_sync(server->client, server, &msg, + &data->args.osa_seq_args, + &data->res.osr_seq_res, 1); + switch (status) { + case 0: + break; + + 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. + */ + status = -EBADF; + break; + case -NFS4ERR_NOTSUPP: + case -ENOTSUPP: + case -EOPNOTSUPP: + server->caps &= ~NFS_CAP_OFFLOAD_STATUS; + status = -EOPNOTSUPP; + break; + } + + return status; +} + +/** + * nfs42_proc_offload_status - Poll completion status of an async copy operation + * @dst: handle of file being copied into + * @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 + * %-ERESTARTSYS: Wait interrupted by signal + * + * Other negative errnos indicate the client could not complete the + * request. + */ +static int __maybe_unused +nfs42_proc_offload_status(struct file *dst, nfs4_stateid *stateid, u64 *copied) +{ + struct inode *inode = file_inode(dst); + struct nfs_server *server = NFS_SERVER(inode); + struct nfs4_exception exception = { + .inode = inode, + }; + struct nfs42_offload_data *data; + int status; + + if (!(server->caps & NFS_CAP_OFFLOAD_STATUS)) + return -EOPNOTSUPP; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + data->seq_server = server; + data->args.osa_src_fh = NFS_FH(inode); + memcpy(&data->args.osa_stateid, stateid, + sizeof(data->args.osa_stateid)); + exception.stateid = &data->args.osa_stateid; + do { + status = _nfs42_proc_offload_status(server, dst, data); + if (status == -EOPNOTSUPP) + goto out; + status = nfs4_handle_exception(server, status, &exception); + } while (exception.retry); + if (status) + goto out; + + *copied = data->res.osr_count; + if (!data->res.complete_count) + status = -EINPROGRESS; + else if (data->res.osr_complete != NFS_OK) + status = -EREMOTEIO; + +out: + kfree(data); + 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 405f17e6e0b4..973b8d8fa98b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -10769,7 +10769,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 b804346a9741..946ca1c28773 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -290,6 +290,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 Mon Jan 13 15:32:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13937660 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 1F0A31C5D49 for ; Mon, 13 Jan 2025 15:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782372; cv=none; b=RSSZDzzsQqwKSHtubHJhkczFTCwvjBn1XJ2X1o/4bL1iZKGNfkMLdZjYo+W8H/hEoGDKi3ie4Xuj+VKDykV6a18F1lOtiXAlPW42iPiI0BEZTLw4WfuIZW9y3zGxr/iuXxAsUa10AfuJWS3EiZKeTqA2pOZAtpsNaAVIGgGxQgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782372; c=relaxed/simple; bh=RsMld3utU85XCus2M6JodmzxzG40AESQ9SK1ML4uiQ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hDh6GgDOQHuIxBlYNuGAUORxwmepOXB7C31OwiP6FWBK53btxQUbTkdYrmnCmZZSQN6EB6xdDOeqtiFLeol2hcnBdjGDBI6lBpbWcm1XNpHq6RzGpEsj6BJge6KML2SU0EKQAAAc/t4FUNn062xeBU8zwT/U+hMngJMRJoajFkk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sl3crLT9; 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="sl3crLT9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00E94C4CEE3; Mon, 13 Jan 2025 15:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736782371; bh=RsMld3utU85XCus2M6JodmzxzG40AESQ9SK1ML4uiQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sl3crLT9VMZU+Ym1YUGTM1PT+jx5AfeOCn9cwNA4jqN8Jdp8g2Ha+hXMazPRxCI+h 7XWgtMLKUjz33xKAW/Q/SxSyGdV+BjLtyd+opv/cYb2+I07yHbsXruktjzpV7kcTPF p4gncnase5zapvzWkEGons1nZKb/sDHMtCpzadTGSlfhiBy1UNLsDyrJHz6RC2EjJK qh3up4vD5jIK4BlflVeF+dVooFjaL6R++wP92Ufcmjct5l0/x+P0D7JOMIriMWiZP2 sU/IMgBYdeZpOerH8l1a8UZb3B1nQN+2ZHMd0FTZ/oQSpuxfH1Dl9zuEUCCp/gNYRJ dxCTOQ2ebkk+g== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever , Olga Kornievskaia Subject: [PATCH v3 6/7] NFS: Use NFSv4.2's OFFLOAD_STATUS operation Date: Mon, 13 Jan 2025 10:32:41 -0500 Message-ID: <20250113153235.48706-15-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250113153235.48706-9-cel@kernel.org> References: <20250113153235.48706-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=5461; i=chuck.lever@oracle.com; h=from:subject; bh=i70vHbAFBDUE6UR4bx72VMirKZT3GeRjmXgzWJHNoo4=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnhTIbarAK7NmQPAoTwA0cP8mI4rndot9DkrrCm RL8/JggdQ2JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ4UyGwAKCRAzarMzb2Z/ lzrZD/4psYs8qOvz1TTZWVQi1yCEJ6iz/ecyA7O07lyoACQVqvLQP7oll45GGbldZCPYxe2OscP OBTc2l7SGEEMVxq27thnVrykd7je4RPzaOjA5+iPGlIETBqomFkYPZIWI2ygCcPCxZyPbL/pSO5 yyZnHSCbXEvptfYOq6LbqBcHtDUuYwDVdsOvFgtyrwwvZvEU2GEt3eo9YtBQQLNo5JYeELY5XIi YDTPrzQNGq/QO5cKzt3T6SIyWtvzjNqByx5jrV+XQ2QHUqdN8xYuowZHMbdR3RGEfb8KbpG38rQ 8pMzrVlBDwrzEG7zRh+RYWNOIfe1eayS0p8OYDIY0OjDBqCj01ujr+z5gXq2qL/PvirthrIvtOM rzTYoz/5z4BXBStA0XKGfR4UgKlYT5nklJxd7rVuk1xCv325wwXhesZzlsysCydDSK3ct8hzLza AHlinwuWwjjB9PuYZmAztfuVXNXjCDdAOKMYKXiqdXvrMQmnyKTNIUhc/+o00NAlG61BUi9gM84 XPrLcNBg9bZH5NmkuRZ4KnHT8JsJABFASZE25xdJYXtMH1OtJnzxhaLpM2MpIKFnMoXzxVxlkeX sLJW6kAXrN/J8YhtOrKYChBhr9yJ6+bnBp1nCZVWlD28oM+XATTMFtOfkISQofXQFKwtrP+k+zn sIgfW6LFu26SFXg== 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 Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever --- fs/nfs/nfs42proc.c | 70 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 23508669d051..4baa66cd966a 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -175,6 +175,20 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len) return err; } +static void nfs4_copy_dequeue_callback(struct nfs_server *dst_server, + struct nfs_server *src_server, + struct nfs4_copy_state *copy) +{ + spin_lock(&dst_server->nfs_client->cl_lock); + list_del_init(©->copies); + spin_unlock(&dst_server->nfs_client->cl_lock); + if (dst_server != src_server) { + spin_lock(&src_server->nfs_client->cl_lock); + list_del_init(©->src_copies); + spin_unlock(&src_server->nfs_client->cl_lock); + } +} + static int handle_async_copy(struct nfs42_copy_res *res, struct nfs_server *dst_server, struct nfs_server *src_server, @@ -184,9 +198,12 @@ 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); + struct nfs_client *clp = dst_server->nfs_client; + unsigned long timeout = 3 * HZ; + int status = NFS4_OK; + u64 copied; copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_KERNEL); if (!copy) @@ -224,15 +241,12 @@ static int handle_async_copy(struct nfs42_copy_res *res, spin_unlock(&src_server->nfs_client->cl_lock); } - status = wait_for_completion_interruptible(©->completion); - spin_lock(&dst_server->nfs_client->cl_lock); - list_del_init(©->copies); - spin_unlock(&dst_server->nfs_client->cl_lock); - if (dst_server != src_server) { - spin_lock(&src_server->nfs_client->cl_lock); - list_del_init(©->src_copies); - spin_unlock(&src_server->nfs_client->cl_lock); - } +wait: + status = wait_for_completion_interruptible_timeout(©->completion, + timeout); + if (!status) + goto timeout; + nfs4_copy_dequeue_callback(dst_server, src_server, copy); if (status == -ERESTARTSYS) { goto out_cancel; } else if (copy->flags || copy->error == NFS4ERR_PARTNER_NO_AUTH) { @@ -242,6 +256,7 @@ static int handle_async_copy(struct nfs42_copy_res *res, } 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 +268,39 @@ 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: + timeout <<= 1; + if (timeout > (clp->cl_lease_time >> 1)) + timeout = clp->cl_lease_time >> 1; + status = nfs42_proc_offload_status(dst, ©->stateid, &copied); + if (status == -EINPROGRESS) + goto wait; + nfs4_copy_dequeue_callback(dst_server, src_server, copy); + switch (status) { + case 0: + /* 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 -EREMOTEIO: + /* COPY operation failed on the server. */ + status = -EOPNOTSUPP; + res->write_res.count = copied; + goto out_free; + case -EBADF: + /* Server did not recognize the copy stateid. It has + * probably restarted and lost the plot. */ + res->write_res.count = 0; + status = -EOPNOTSUPP; + 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; + } + goto out_free; } static int process_copy_commit(struct file *dst, loff_t pos_dst, @@ -643,7 +691,7 @@ _nfs42_proc_offload_status(struct nfs_server *server, struct file *file, * Other negative errnos indicate the client could not complete the * request. */ -static int __maybe_unused +static int nfs42_proc_offload_status(struct file *dst, nfs4_stateid *stateid, u64 *copied) { struct inode *inode = file_inode(dst); From patchwork Mon Jan 13 15:32:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13937661 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 17E241FBBE7 for ; Mon, 13 Jan 2025 15:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782373; cv=none; b=fBMHD/5LfCAhEoSN19/wdpX4RVFn4FNiUaAFOVcMr2cfQP8CSyM2apuer9iYN/MYhGx6VwHV4uof27nI67fuJ0Seh7cMtqlMYQomtm4cwZtM2OENU/oPBtAwJKdf3782SzgGfmBTfboKIihSxgDrbo/GgaYb75rdkTS1ht7mfIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736782373; c=relaxed/simple; bh=Z09/2VuvQ3zxAG1O6Wkbe4RdL66Mg44UjtK5uMkgSvM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WwIszeEsjRZMARv+ryo1kl/gRCrourir/5TjQLQCr6oEEDImKjy5V8MZTiQgkKpbnjOf0rzlG96u62wTZazF73xuNyPHYB4pfMahhP0lhirZdKWaseifJPvn6jUhX4NhDFWmJA9WFjAZhVj5CWrr0jZXH9L449qk1O9YMGITdTA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SABFvM3r; 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="SABFvM3r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00782C4CEE4; Mon, 13 Jan 2025 15:32:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736782372; bh=Z09/2VuvQ3zxAG1O6Wkbe4RdL66Mg44UjtK5uMkgSvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SABFvM3reoUizAegEU0Z4bkac1SqzyonHhIVpBjdw6QYfaPftJdqk3OQWz+KeFh95 6I08aMHSLzMD64lGwWbNqZZEybXSd5nUZWeefWTnL4MZ/1XvWABefkHQLgUv4nXUuC 6eTId4BAjaizjk1mr5fKvY6ztfIheUffosGzXQYVoYUO5D2qgWyD5tr8mIW3pPwacq +lDtRDGiyufXKMEZ9GGvctK5Q0OtPwErT1stPieQRi/nhPIfpUjDpyaVVAKRkXQk+Z alC6vMqn519CzOUWTc8QvfyE2mk1L3KX6lGxG4ZFCNoWqDJyaOec522m2H0kJO5HAN BjUps8iMqGQMQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH v3 7/7] NFS: Refactor trace_nfs4_offload_cancel Date: Mon, 13 Jan 2025 10:32:42 -0500 Message-ID: <20250113153235.48706-16-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250113153235.48706-9-cel@kernel.org> References: <20250113153235.48706-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=1841; i=chuck.lever@oracle.com; h=from:subject; bh=lS7gLKxLV6e35cAwmz+7g8/4d/Vm+xpaV7ZAzDdK8gM=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnhTIbh+yLG8krlIp/tYnQNbc5i47MlJlTzkCK0 MFrpBCdENuJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ4UyGwAKCRAzarMzb2Z/ l7DmEACbXHKbJUvNn1FW38yJiZ/z34HRvk4sXArThUrZO4Tp0jSD3RMQy9Jkq8Etp/MOMwpB2/e 42yVtruJc+lSIPenP9A7BSkhuIxzyLX3dXLXpodeqC0/ImNu5GxQgdsbpcYw8I8KS44OUDPoT+4 IV0WIjFw2OUlnVLVhX2OckAMLAx9HPuCavgA649Yd2OB6oiMRACNPRRgyfLSlpeVud16zOjIual EPjOJUjxMcjwOcJ54zT/z8SEsq8/u/OkIx/k/J8PDFvbfBlFjIp4rF8mCGwxETGlWcslgQ3nIwr YmWqvboOU7ozp2EmS+HAj0XQ0l7yJXOf/+MLKLRAsvjwf212CXz61OE1bEr+jM+A7csdhXh6yCt E7p0QMd6UYPC49n1oZWHPQdeDa3LhhCun/qNikMWEb6RD+bUGoDnrtyKbREJG0pjLAj+E/MdBtH xCWF8/JhQV0Jrs4JZTdTk63ES6Dc8hpKuMn5uWVW5NBszbi905m7a5X6NLqcvFaZYf6SmHNJ5D7 1FwOQHDXLJtmjt/tQEOnr9PfTUCdZ5dhRsze5TiF83PRHUlskt0cfj9jfHYMvJfVazAt8xnEA4X MNN67mHgmLrmcUg8Dqrm5LGoojSX8zmBr5tKQ7Zf2ZFJHFQwZScYFnMNXmLAnBwyU3jJtO3RCfb gsdSSZqzXE8ruaQ== 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. Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever --- fs/nfs/nfs42proc.c | 1 + fs/nfs/nfs4trace.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 4baa66cd966a..9dbb93dc3839 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -648,6 +648,7 @@ _nfs42_proc_offload_status(struct nfs_server *server, struct file *file, status = nfs4_call_sync(server->client, server, &msg, &data->args.osa_seq_args, &data->res.osr_seq_res, 1); + trace_nfs4_offload_status(&data->args, status); switch (status) { case 0: break; 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(