From patchwork Tue Dec 3 16:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13892683 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 9B14F18BC1D for ; Tue, 3 Dec 2024 16:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243359; cv=none; b=WRm/XFDwuxHmh+Qhe6vmqHnBm0y3OZFz6kE5CMDpX2ynKxvTOjHOoqswcoNhUjpP0ifMqwiw8t1IPYix0Wl0AyDCS0gYRveVxiH3OUIByH7Tbny2y257GNqlffslW9R675IBSsxy+dBJM4OSNZdscQ56oJ7d5qBABHcGtChYk8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243359; c=relaxed/simple; bh=mGjyLUC8Tdl3s3Io8OxFN8wjAOa9sgigj2kk4i+JBQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RpdGftW7DJIoGLLPG8uz83vaMdWM/spIsWVmgK/uRfnHgNrNX22pQum+eFj0i3VykCeuY0hr19kbFh75eIDTbIyZv4w4BqVfLGCL0+faAu54SWtZa69ySsK2DBEuakyGppZ7SOYjYESX8XXBUXVU300qTUCrdD2EL5/betHXzP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LZdtsBMr; 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="LZdtsBMr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1F99C4CED6; Tue, 3 Dec 2024 16:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733243359; bh=mGjyLUC8Tdl3s3Io8OxFN8wjAOa9sgigj2kk4i+JBQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LZdtsBMrMsoFtmp/pq4S4KnQhmsNt5ApbDWrOHEXFQAaXhp9VFIphBVxi5C7p6Ty/ 2yYq6zxTzIh2oGSFJP2z7fDKYOp+4ihu4+Cj6gQJruvqF5DUaRcoQBZiWsnOcg2wjk MkV99ViCLxH8l110F/dPDNG+CF3/6iXcOARxrhVi3o8sr+F+1ioMSfELd0n9EzTkSd tIMK/yfNZtZKoMAohvuvE28t77LZDUkuQm9jEIHEdMCrqRr2Q2iv4hSMwx+CdNCqfQ S1c3TAiMii50p+fH2jwuhl4RLGgZHmdyyGN6QOjctntMf/ygiuuLbzcAIx8JfqPUSf wGon/4YCf4wCg== From: cel@kernel.org To: Olga Kornievskaia , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v1 1/7] NFS: CB_OFFLOAD can return NFS4ERR_DELAY Date: Tue, 3 Dec 2024 11:29:10 -0500 Message-ID: <20241203162908.302354-10-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203162908.302354-9-cel@kernel.org> References: <20241203162908.302354-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=876; i=chuck.lever@oracle.com; h=from:subject; bh=qXuGrjg6SDFchdJvPLGOato/moBZTWja3ZWBZre7U8g=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnTzHalI7zb0ON3ksPyJGdZ3rXRv7V4llY6edT+ 5XQB6PruJuJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ08x2gAKCRAzarMzb2Z/ l1uIEACVBg6/mzssUiZPCh77Eqz44FLFXjU9l9yOyILSdNEzG89NWCNtvOUMGDhtPBuHqQIDqIN 1/o8o2MVlMGfQmeqzGz8FvLe84mX01Bb9Zo9HiK2Nkv5XNXVleZu6bHxEfU7fC7cUAd/yP2MKuC QXmvXrgInO8aSW6MpWjqxWDoVm0xiIRbOy+MCfukwZBE4CV+9pEZ6j6Hi8Rv0cAN7UpWbelPfno KQLzMqbILziA6VmIp7rXDO7zJE/OX472nr0JVU70oyztljdK5Ew178a6WZAmg/WlhnUbC2w/Hfj oubwQSqfp+ZfEhGfpeLey8B85i1vcx8nz9Lpx3vEO1TFc2YQrERB29+A1YL3/9kS6UeaCs/upQ0 2IggP3/NNIu+Vxa9wycDl+l6lqWQ6u6NKDg7G/dOLmJw6J9ni9vtkPLes9NXJnzgM4DJjvrWcRE tsvhwRfDNTx4PL3cpKveyq1MSbHTn2K7EqcI8gyrxtjO8Uxn2STCEYc24Q2O7BVe1npBvvcbYec ZI67myd1C509Y+h6YdIxNJwQayyxSmARXE5gjW8mgjq1Up+YJXuX1JtydA6wxuC0FVFWNaxZ5Sm kRUhTCJVmJ/tpvoLkniJjNjiaFU9Fjq5SFizzvKQzcf7N/L7WOYrp2djQr5XQmBPbIzoLGjuUhT zC/V4zCRalv/m2A== 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 Dec 3 16:29:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13892684 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 EF8051F8AD4 for ; Tue, 3 Dec 2024 16:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243360; cv=none; b=hVOXnRFbhe/kP5vwKx1oQYDCWhYE7OVYnj+fgROIS+fDFnFEOxY5mlVfIBmdq2P7AbeU+XpaeDj/+dYvaHB1RY9MYQLKZmeyUGh1NhPKBCGo6XIqg4HyXOFmrs4IVhckjOAdagnHI0bwS5Y8hcwGC+cSY541H2qgR+JruMlRQ1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243360; c=relaxed/simple; bh=xjZby/G+1S0HtB+8hgO8Un9xUZQtgkwttk+DiH1A6IE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yt1J2P/yet7eSe0DD4nYyKeG0EMfxeoThIEjushYC1syPTR66yRes73RjBCOIDiKZwF969T/JqnwMQ9pwI9dTOI0vmjc1cWZio1CJX6goR875AXQJOyA9mHMQ8z6DzBR5VciArjtefVNEZakyaUALzIbtSg8jV3XZj5MiXcJe60= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iVLlb/BS; 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="iVLlb/BS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EDB4C4CECF; Tue, 3 Dec 2024 16:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733243359; bh=xjZby/G+1S0HtB+8hgO8Un9xUZQtgkwttk+DiH1A6IE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iVLlb/BSVN7Zshyucg8OWNu9hwMwdv9wt8owVNrOoBOhkjDgXM16Xa4r4RGmtHh6U +Vpup+YSQum+XU7Q7T0aPKLf2DpFnPdrRV9KA5XBaMkqRyB4K3/F4xVE4zglPg10hW F2LZlCfvFPiHKcUtnDUgslEkvNkIGc+WO+y48qbXL32b0UG3sy0PqtuUnQUYfZy3N6 LbCF+qMEKA/FAyvk6f8HecfXIWwZ6UMm2L+HyV8ei6K4CGuxhZQjP7f44kfW5Vp1o0 Wvy+EQU1bR6VdEgcH6NnnODdR2m1u2AJz4LaALfMHlbmpptXJEKUM8bNbwA+EJQo3O J+hU6qgilINSw== From: cel@kernel.org To: Olga Kornievskaia , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v1 2/7] NFS: Fix typo in OFFLOAD_CANCEL comment Date: Tue, 3 Dec 2024 11:29:11 -0500 Message-ID: <20241203162908.302354-11-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203162908.302354-9-cel@kernel.org> References: <20241203162908.302354-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=546; i=chuck.lever@oracle.com; h=from:subject; bh=iMfLGnMC2GTPGqB77IBVlR2DJhMBFTN/oBgNP4k3UPU=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnTzHaiihnzZWIEfy5TkDaUouIstdQzlq5dvEdo RuUqDbv3wuJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ08x2gAKCRAzarMzb2Z/ l6KfD/995YEkuRlkg89Ulyt8fzRgt2EiXuzjJ1PEtygMs83qF3MVqI4IW7e6Ql697MzsM8vd4Ci +li1+0E/GuEr7KabADX+eGv/UMzE4ook3cHqrv28NYB+9TR6yDJqWTOJZf6nG4WiLLl+UcOuUlI aTXhyTFZhPEC7WoCsMpwPSEf3c/HvRiv7S5AzmQCxEqzzT9DEnzCpXjEHQ5eYyMQVSOgyqdLaTo oPFVyP/Foyq71em8LFKWU6ufv+/SVcH5R71XQIJPjGjqeuyQBSPerYlgFG+RBUGDjJMHFNbGlj+ 12/IjbUW9ZCg5+gOvrxHu4jXbMoqh2TwGdentfpTTi5Rx6u7ngXz3ekMrIqn0TChovHNm7GNukn yMlwUGRlkEfMr25UF7vzAoIaAFANFMwGImL7AaPbZCq/CY/DAwdq2loiHkmWdbJr6X1ugfx+AHX v0OfyEbNLF1Fuy0vpQlV6H7ZkeeLtf5e9czBo+I0E/eG3EDAyl1YJev5z//7huhHZ2vZRm5op+A gynVkpCN9WtXFjYsrqMJN8G/GyzJ03XHGN87DoNhoML+2j0u4qYIyw7c/Mv8ifAT4jgO4oSW84U bYdB5udju/fKpoxRhFs2O9lXl0lC0s082H3NzOJ4/v0qoGuZKm2a72b28EF9QfIwile9gko0UDe Vm+mKOpik6Bk6hQ== 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 Dec 3 16:29:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13892685 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 EB07D1F8AD4 for ; Tue, 3 Dec 2024 16:29:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243361; cv=none; b=JEx8nwrNJoH1839ZNjy+NaXD4tPFjMwR8+5MtS/VAwetEKmKbIK2j8DbLZebiaas0FEj0Toq5JPx5a/ZNSDfI7Mq+pSJct/SPSvI6qisB8c55mD7a2kGcXp2iWkDwSH2dkjwv6hsj5JDTz12+c4BBf5PgVc2RneBNLHwzigWUNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243361; c=relaxed/simple; bh=o4OPCvcvzGjpQ2jsC3ajssM6BwUC/ZQrtYpiBuMazYk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J/l5u0PPwS6d/PIhCh3bAWOpYtAAgvuvSChsRZ56KYTy856cEBOUjvYHMuH0sWdqxAwETgoWqwDwZM/Tl6aZ3sx+TOqvzQ65egoupdjryHA4pwg+GRrR71MhGPKY8TxXDA2A7MOIt51N6TDDOnBfBuCWTkysD4Ec69Pg6YKdymw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fdozGFLS; 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="fdozGFLS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CEF7C4CED6; Tue, 3 Dec 2024 16:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733243360; bh=o4OPCvcvzGjpQ2jsC3ajssM6BwUC/ZQrtYpiBuMazYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fdozGFLS6VkmHbYVPmwpKOyRzZ060T5mFSuMYf5D5/lVOTlw4ihoXP25g+SfKE4bt oe613Flc0a52d+vodvBt0UvAOYVn1EYU1XODLgfc/uNVKojyajVVLK+U7419L+Ojpd wEHV40Hl5u3A+3r+gAyQcfbeqX/I0AozyQBK4WMkLtDw2v9hwPlQO3kvlsVfVGeWbf 2xhuOKonleVnSRVZzixgJwXNRUKb445C6cYxY9cy5Zrlyk5ctPfcPToXu2yJV29e6a KgxnHB+jYpbLZdN9y3+zHXIM23KRWDx6Qe4nnK4udvm1IJaT9BUAfkZq7kI8Hg0Y5n 5B+Ntbpwf2TYw== From: cel@kernel.org To: Olga Kornievskaia , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v1 3/7] NFS: Rename struct nfs4_offloadcancel_data Date: Tue, 3 Dec 2024 11:29:12 -0500 Message-ID: <20241203162908.302354-12-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203162908.302354-9-cel@kernel.org> References: <20241203162908.302354-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=2778; i=chuck.lever@oracle.com; h=from:subject; bh=OjH+m397zWOGeAlWbq2+w1ipk8WludUbOjofUQ3hJn0=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnTzHaQUDdD5d36iI9/pYM8QCFMEyhnWZ4TGPJD HbLmfXMYZKJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ08x2gAKCRAzarMzb2Z/ l8hkD/9OEAJlQmawDJg4bhojNEuWEvasXvP9QD7a2RAlYpa4W/lrtyq+WWXMF+PvZ7XucoNDyyW qnmxWbBtToeK75mQHVMhh53ES/9R4SD3Gx/SBrWP1WOxvtpiWWF5mZngJBfNIpNvFwyFUNyigwC BBD6HwDbFiy2YY77f6TFBVIiNm6hbUrjnGnrAz5UAJlLV2QXTmIATcS3ZDUttL/ZDQR6x7aIVWC R1EBEFbLm09s+sHKlM4NwLk4xpnZKCKuOl28ONqeulBGKyKEZ53K2HdbJSznvndHr4IvcrOycmT hPDgf1umoXV16TptRtCtyNvKTxmHEuB3JllCpSb2d81zI9r4RSKV1h0gajoiX/DGg8PQiaf61H+ LeskHBP3aoJs867XsnkLKqJpNFp9tHocBtmv0eKnAjdZWTUDgprraCUrwcvEwLdMvs5PtSHrfrc byc8/9YNMYNi9A0IHOa4O7E6XkkmGevmVHP7fcDJRD1D2q9ST6zKhordu6TfyQIvP9UbzVVGAxn Oc3s0l03Wsz8LDJvYisWektUzPRZmkqrLdUnvfapoKlhsM0S4E08iMmM1MTxCcSLZg1CXhErF4y HBFVoEzEGbP2+0ehTx08aL9hl8M1rdmOhz0CR4e3ULal372yjxw3NJdm1lPmeP+yORcRHEiWoa7 27UIr1pPbcZMWdw== 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 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 Tue Dec 3 16:29:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13892686 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 407E71F8AE4 for ; Tue, 3 Dec 2024 16:29:21 +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=1733243361; cv=none; b=mKVbPFo+18RKjKG0XzkQRHB9l+b/J/9CR76jGhqYivHx3/fn7Ksqasu+sOk9REjhllCPtLf8bVNSjeIj68aFTHAK5xX39faeurnb5wt/INIn6P61SpG2iAQmU7fV36ARTf3zL+BJCtOUP2vXdJM/u4aQl7EC690RWNea9LfvYwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243361; c=relaxed/simple; bh=UHYvkJ/Qmw8fb6OtUDOkOorY6lSj4IVXt1zWIkSVVuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K4puTOS/txuPkBieRoW946YbP3KmMflfeAiIhtDXtNkbaRtsdQ5zJW9I9bAyC1i02WCvINug6RDKy445zw9zA679ym2QLrXkcEBxkDAA+pUSF5/xynR7z74ANWXNlv29tHvm8IZ6W66TzFNVybC+OdA8he+ZRDK1BjtAt3SnHao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QIY+IgOS; 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="QIY+IgOS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF00FC4CECF; Tue, 3 Dec 2024 16:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733243361; bh=UHYvkJ/Qmw8fb6OtUDOkOorY6lSj4IVXt1zWIkSVVuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QIY+IgOSeWiQU3BfdYREzVyDWhB83pgOoCMOe5ey4mcE6YpCt+f+QszfI9ueWyAfP 5gpzbaCnqnp5GTZybMAdZaqdIQINCRVvWZokciLGuOuSQJnk5n8oIb2wjmDp7siLfM ZOBkCDdI4V14FA7dupmqXe4kweElQ3dChkYeeFD+KnPFkKpNtYowmthOhXSPCXai+G QqJA1ZNxqfBSYYPtsHSrCMnVEgwKSZrM9ZV/hJZKydq7mw5x7e/FQ20MY3/i9k0SmK KOf/wRpaPssjdX12Cv+6L5DvTV0B/vXhJCBA9oAougMxNT73FDsy8XqSWxHTSqrv0N xLrN8AxqrMt+A== From: cel@kernel.org To: Olga Kornievskaia , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v1 4/7] NFS: Implement NFSv4.2's OFFLOAD_STATUS XDR Date: Tue, 3 Dec 2024 11:29:13 -0500 Message-ID: <20241203162908.302354-13-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203162908.302354-9-cel@kernel.org> References: <20241203162908.302354-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=5792; i=chuck.lever@oracle.com; h=from:subject; bh=VVja45jvjBnwA3YK9gym7fzUL0QdIxmHxMQFFKKkUpQ=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnTzHbhVDTbw1zxqw0jFYj1hGPnXzRPUAwUwLxx gMEHCYAGWKJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ08x2wAKCRAzarMzb2Z/ l7nXD/0XRJqdhH03BpFWEzm+GY3dCMp7yrTuQwu6kYK/sj5ctXIF8MPPDRNMZa/AUs3beLef2pu 4elBc+Mta2DoybPS+VJUADKbHoK3vDVtWYLRgTB5TDqzsoC45dQaTjv/cbWCHGh9pwUK6Xt8Hms NGWZfGD6df928lM6MWiteUSZf3+4ShmOObjuBvmgjzy+vJ7X7QC/qkGP3q4nGUlXnr6HSXrxJHH vHfU3hdbkoCSAcGuiJtaxkL9nT7vN76+HdiT50bOLGnMtBo2W8b74f4NzaoGUmuSdkBYtC0m1L0 fFiEA0XEUMidiopQzQMx/h79Fgm1E+3wqIltrmJ/t3i9oMdfeZGNDHqylcdVAlsee58BOztciOD lTryzKvLof+9dizmuYbpVv1LJ+E806Lp7Q0e/MJBrIrmziSj6vhlqM6RNqeR79W9MDmA+FAG3Md M2OkA6YFmkJ7QHb2NEChvEgNOBiC7Nop8+QV/vCFMG3SlP1aI4PPlHiIWBCM7aIiuMs2lkl3+zE 4hNwLMUjFzIBM/sOLK9ygEm8oTfHuj+nN1/4IoeII0fS2iWNSfsySv9j/lSB9cIbQQJ3hGWeknp kFCJ6wR7QKAN2IPkQ3LUUFQJk2CaEZ/M+NSZh7usee4ohlWCW1Xs806GA5v3ell1fb41d/sHV7I ItQmI4n5r2pbWAA== 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..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 Tue Dec 3 16:29:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13892687 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 E63211F8AE4 for ; Tue, 3 Dec 2024 16:29:21 +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=1733243362; cv=none; b=pTsWNnVd3cDycKdna59MTRWHLb3rZAeXUFzjL571m5HC8IZ0cqoDNAzOlzn3hzznj+YQOC395D2Yy38TSQfHEFClvyiBXW11NWpYUukHkFXrU89gV1Ng3pVThvbNtEkvYOtKv40XWnTr9fggNR9K9Jpjib37zHuCjAGs4+rbqYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243362; c=relaxed/simple; bh=Ad1wxUut4XVotie1gU3Nou6N3wMEFKd1vQkJIi2vu7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k10w//7GFbXRMZ3ZG3HtkLbPd7GkrRqhKogtYVAmW22b+zh4kq20QcfcSnkdyLqJcnG33H1uRcokIQMHthXgpFgEuVXJE8/GbIHOzDfqmpWdyxRGGF5rjtx2jkGhXlUijmprjCCieXBfnISAo48N0Eh8cwKXeNvwZ8GZI1crsaU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RbK18aJv; 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="RbK18aJv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CD35C4CED6; Tue, 3 Dec 2024 16:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733243361; bh=Ad1wxUut4XVotie1gU3Nou6N3wMEFKd1vQkJIi2vu7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbK18aJvRfG8wbuXSDo0gQlCCuaEDC8S0GMROrM9FaQceKEwUTrhPZejbi9Rjrp+C UL8zda2OztWyw3Ro/xZ+L0ZW5E5U8Y0P/LifTe/TS2+U7zsBI6ij8vlHiaywAEzUS/ jomHwck+QryYTcmIFRxUYqWExFNYnhUZADAKKaJtFzkApTWnnEiQLf3NHnhjz0mqYJ +DG9eIj/7yjMCAnpYEI3HRELGv46KixWpFKi0eHLGJcYtFW6wmQ3Wn8m/GueEpc3oS K0IcTCZcDUHKdETe8/QCzWb7gMce1SNtzqJPcYqcaVqIfx+cFwbrhKm5R8qP5yTosp ZXHUWVNh6x/iQ== From: cel@kernel.org To: Olga Kornievskaia , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v1 5/7] NFS: Implement NFSv4.2's OFFLOAD_STATUS operation Date: Tue, 3 Dec 2024 11:29:14 -0500 Message-ID: <20241203162908.302354-14-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203162908.302354-9-cel@kernel.org> References: <20241203162908.302354-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=5790; i=chuck.lever@oracle.com; h=from:subject; bh=LYTOve5p/LmEGFffPsOkYr53z7Z574x7V88ig6cV6Zs=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnTzHbflTLzvKZqyWYgS38lOi3qW/U0Je3rCgnt 4xvZxtyhISJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ08x2wAKCRAzarMzb2Z/ l3ZLD/9a+b2io958B4+MJINID9WM1jQ1nXW/TwaQgwPUvDEK/nfTDPW2NISRlHQ0tOqsCCani+Q yM4Sz+d4QinpMdg8P4ydUmVgSbzVP7MOxJwD+WQRKCRIVABHxbH0zHRJoVSzatJzwC6rRAXTwAH +4kqQb+1qDdILpp3ydK8hQUhGsdYyN5kZSSE3FN/9Mikx63mAf6ZP7LcqjEsIwFZCMEC8TNV3z8 Uvm/4ncJSGBOR0jjEzJTwWfhFKznvfff4zKcBCsipTyTkgnlr7MQZjdFL4DZU7iGBjEw9rU8PDp NEE1EwjRoThDwpPffhzgNG3wwjrYaz5jMeRtw+Kh5qgxYBZc0b5vQUEYyYgAdpbXxqTFNbuo0AP jJzbVqMVnXg1X1/OfNXqIwbWhadPu+9WxBETb2EAZq4lykgs9TK0XKAzK1KRtq+JYKXX3a7q/4W J60LJn4G8juAXAUX8cmdtrQx2CQIzn+Q+1cABav0epVhpLdUKEPt1kAg3KijKVclTrXClCHzApM z56JQdt9t5luxP8N23l/k5nCvw416YcGR2amFqPPuUtaoodYsmHyvCKx4tAtE4c5TWd6HWzmlT+ 4zCYlQFUdQMykR3vKeeCgkWBCxPmII7KFbfo6n27SP3QWSM1RkNOW1gejCBZ2ZnuuOVCU0gWRHB d89p7HG5HISkAbg== 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 | 117 ++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 3 +- include/linux/nfs_fs_sb.h | 1 + 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 9d716907cf30..fa180ce7c803 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,121 @@ 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; + + nfs41_sequence_done(task, &data->res.osr_seq_res); + switch (task->tk_status) { + case 0: + return; + 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: + if (nfs4_async_handle_error(task, data->seq_server, + NULL, NULL) == -EAGAIN) + rpc_restart_call_prepare(task); + else + 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 + * %-ERESTARTSYS: Wait interrupted by signal + * + * 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 != 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 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 Tue Dec 3 16:29:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13892688 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 A6D691F8AE4 for ; Tue, 3 Dec 2024 16:29:22 +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=1733243362; cv=none; b=SmTUhFw7iBIlnMTlDv9lQmuI4GL1gkTIVNTFIxrcAkD66lr4Di0QvAa6UlbMz95OTcSDQ5IjoQcCwUbaVV5jKotuLXCls2z/G1uDI7XgzRusHwYNKJRMhuIvs4WOHIWO24I6y7jk96iNsCuxPBO3RbY+SnEUxOtZrGIZM85YSFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243362; c=relaxed/simple; bh=Np5ui7EbiMofzqRS40bS85XPIWkOO9rvA8sE0hFDSlk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R48phJeb7iK+F0Xr4KQOidu0SDfJz3f4nXD9YOXQvUcfWvO8YAG4JlvNFH0rzzBYiRPUhcll7JPvG430qcGYI2/F4uPFe+VBP24nyFhy375cz1vrFXUvITiWK3WOc/fBG1WaiuUaTTVLxHUnZKuaWLQZ93LO2Z5DDhhTlYWmGhc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nQsgNrFo; 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="nQsgNrFo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A098C4CECF; Tue, 3 Dec 2024 16:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733243362; bh=Np5ui7EbiMofzqRS40bS85XPIWkOO9rvA8sE0hFDSlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQsgNrFob3/YrsUADiq+ot5J/7v2AxEzKDK+DXInrkg91yuhWOXKo0S6zFmln0vle GjwcqbV+iM+g4Xd9yZWaGpDxvfrwzwBXZmXQk8lQkef8H5dVxYtjJ7u5BbIyt50vrh ejc6bE3VlQvspTipYfkKDD+1YCDuZa05aUDV8Ik5M+HmXmKGl68ub2h3hIP4mg/to3 PBselLwMt6Y0EYuUPz1AjTjNYMSTAD+wIaXqbMy0OGRZ0aCW3pRDaW9wZyXVUamFpg o0h1zorQHE/iky8tUo2+8bGiCE/fqLHzCPBC4vF92jb29MhaTspCFwAFJmxozdbXb6 ESQ4IKfFrESOw== From: cel@kernel.org To: Olga Kornievskaia , Anna Schumaker Cc: , Chuck Lever , Olga Kornievskaia Subject: [PATCH v1 6/7] NFS: Use NFSv4.2's OFFLOAD_STATUS operation Date: Tue, 3 Dec 2024 11:29:15 -0500 Message-ID: <20241203162908.302354-15-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203162908.302354-9-cel@kernel.org> References: <20241203162908.302354-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=5001; i=chuck.lever@oracle.com; h=from:subject; bh=Q6g3DzWWmtlJTqfsXYKzi5mDgrK/81uOb/j2wsItDug=; b=kA0DAAgBM2qzM29mf5cByyZiAGdPMdvIWtQtJyuHX0DbyiE8uUR10Vuq62dvt6pUi5F1UjdrZ 4kCMwQAAQgAHRYhBCiy5bASht8kPPI+/jNqszNvZn+XBQJnTzHbAAoJEDNqszNvZn+XnlsP/je/ BeSmnqw//nBd8QAGhBxMeZijtJqdX0QxFjVBKvwd3SuXr1WZQxlJpBJpy7F8kG19PQOJ8TA2W7O zp0LIj0WkVjXjJoRCvSN08PI7zQa9PmlmK6BeGf66CRkJVp2Wxb75FKSaetxjSGR2r0PzTGyC4E 2UQgp792w1Wb/uhxV7WWW6tBuCrU1SVSOy+Ct4qZDxpQchYtsr5Ss2YEnlW7OueBno77PtMb7O9 jdylbu5UB78RPt6TPNAD+kaW+OE0AHOzwshfKvoWbr43qjfB6mlIqZPzdpkVALQpkT7zCqhI9OC n1O6A7Pj60VM3Ep7MX3sqGN8wDV1EqK7b/eCWr3yeywt90CJHDClh1S+VVNuCUTfY3oTIjH0LZG i4sVFxbdB5OGtU3zhZm+mfjAqZZ883xAEBfWF6zHFXxJmeaoCrnYP/AKeOV3GNWUYIBdahEgdjZ ZXWRvcfWnrXRshX7/NhDZy7VZggiaWn3Pf0ap3TmC4XbQ+rGT+k0mwp6kRlier0nYAJS/KUhCMZ ajeT9sLcusKSOAkyx18kGgUa21igiJdajh9svDzwj9Mnww8HWowrwTUsvsACSDjJso+qoIETT2V gZOKYd+zUOx35VkIAjhEoMdeabO1ZLNw8ou3ebnQjA2MSdAh2xCgVHp7siBerogguKiGyDbpblS DWU+v 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 | 68 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index fa180ce7c803..5f2bfca00416 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -175,6 +175,25 @@ 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 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 +203,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,15 +244,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, + NFS42_COPY_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 +259,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 +271,36 @@ 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(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, From patchwork Tue Dec 3 16:29:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13892689 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 522641F8AE4 for ; Tue, 3 Dec 2024 16:29:23 +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=1733243363; cv=none; b=m+Dwy/xkJr2ReM/o9amrvjfmhHtENCc36g8Vj3bdCLDWNWn/D+iSZBZq6Eqw+mC6H8SkqFqhc7HJDD+JtZe4Maw1UOYBuZ2b2tCWNPfyM83uS4Ywx9TgpjJEQzE5URnkg2G5I3258A/QdyLj/wphLsnvz/De05IrGaP+xfjcKH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733243363; c=relaxed/simple; bh=32Sjf0OR2tYDUUyKFLETPQTJi31PZEOK44/hI9p8nts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mlGg7qgjpJ2gWvuuJ45e2couZMBUTdTwOZ+b6oKLxKlSjrz5YhF2p/9yj3eyjgBWjOl6+4rJHY1y22DD03cVuu+VOdp0MIC6ZK43DlFNKiyuv1g3EyHhdBHhz5d3NWQBkK8VRkUPn3aOs3ryhXUw3fcqetny1wzsybSq9R+MNgA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DnonFqIS; 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="DnonFqIS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C08F1C4CED6; Tue, 3 Dec 2024 16:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733243363; bh=32Sjf0OR2tYDUUyKFLETPQTJi31PZEOK44/hI9p8nts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DnonFqISqEA628r/LT0V8AwAsMpPLGQPaeXZ2BpvUhn+w9VS1uhLZNIFTjlbtXyuG UdAZI2l1/LHPQr4bywOxZzHCn+zE4VLcnIlvMXherIr7uZPjIobaoFuuCdbPia4bNd 4IK5dm5wYL/pNcZVBgwc/hyWgXwTy6dBTbLHPBKb5FJ4jMM/kT9Tqjb1IaqucOyUzQ pyFLkL4ZyupAoaqWIh3NfHF6NPiwhyOxIgCFAeiFn4v1KlYSJ+/UcmyP0D88cDHWNG DezrNEbzShTZsLMumh6W5jit4fyRcQ2mZ1oDDg8LcwVqRcrLSMc5Frc3LcHCy/Ue2s a03WYAQxkfh5Q== From: cel@kernel.org To: Olga Kornievskaia , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v1 7/7] NFS: Refactor trace_nfs4_offload_cancel Date: Tue, 3 Dec 2024 11:29:16 -0500 Message-ID: <20241203162908.302354-16-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203162908.302354-9-cel@kernel.org> References: <20241203162908.302354-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=1794; i=chuck.lever@oracle.com; h=from:subject; bh=tf99fkqJuJJ7PbV7qzrKrJFO7yY0YuEHaZ7SEMI35eU=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnTzHb1BTVP0nSede8cgK8oF1rnlHfPOTgTRxpH PoNE2WkkciJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ08x2wAKCRAzarMzb2Z/ l/nID/90Hy787sRyqGydEcH79imOmRE9Isv05ZEaS/pQlOUpvEH2BpieH2AMBfHnuB360+hXn+2 9JcTP2mSXofu2+6duhhpb7nvqXwbt29AJC98ZNN09yr7Kwhz9pairG7TNMa/OaycP7JnvHGGjJy yxeNhWpZ9Ph3Hg7glkGtJKtQg4aB1XMrxQvKI0V5o0kVxeSOELGIIkeuYVutnq8aLPcPMADGwvM D460SQ/t9icSC7TIeR22TkaElJc0t4L4mUUUos2lBcXQ6EzMiV/V7P17GVkxlzh3GhyQt2qDaJj S4Pt8QCkAYBwEdiTtvnhCG6KOkgViv03D8HjT/FXiFO7WnRYdoMKbwto9VkYDp5YkyUcPgD9MEK 6i7zdYnRjybr9SIuenOTt11MFxt6/ptrgQJCJo6K6qZYw8rlygwSHHhFYLd6lBcbtRM75E1mSxj WFa8aII5ckrJYw+kQt///70280QmZzhzQZnZGamiUfgeJxPKuTF44ach7Aig7oBom7qgwR08Ypo HKqXwX8Ra/aiPLs0xY4oNxOP8VkhcaJeOpTYZfwwm2rpPAXX8eJw71fSya06B4zVsfKDfFWjrlk Lnaa7ND2dsC4ySlzEwaUdavGnz5h7OY73zzCz87Ks0M0Y05MO1XJKqw62BPTH/DhgIHoBn8DBf5 H68Ws3YXoAOKpOQ== 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 5f2bfca00416..82efaf8720e4 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -636,6 +636,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); + nfs41_sequence_done(task, &data->res.osr_seq_res); switch (task->tk_status) { case 0: 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(