From patchwork Fri Dec 20 15:42:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13916910 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 51497218EAC for ; Fri, 20 Dec 2024 15:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709360; cv=none; b=aXxwE4W7FJGhpoP/UCsC4jThgG9mozkcET/yTyzPkNPq4psBNfpcZHD1vwdrC85ADgQzUwvOpDSiYpE3P1bb3bgaup3BskjvBj95oUbOZLryatAYmWDWOym64qn1GGIn/mi1ii3KjDAL6slc0yrmpEEu+laxAg/BaruyoFKMeQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709360; c=relaxed/simple; bh=mGjyLUC8Tdl3s3Io8OxFN8wjAOa9sgigj2kk4i+JBQo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TNR8DjSE8545RhDpiD7ou/gRC6uAv/Agth+ZoNVZFhdk8cBRvpQRFAfF0+IpprGCQUfw0iI7/fZe8yfciOuPhjNeAYooBR6ygtp6X2hHP2vN/Lajrt+af3ceMn7bN/Bw9UCIqHsF7nEBwWejooAsaKf1/0jxT5+yAEojWpPP4xE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VLQis4cz; 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="VLQis4cz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48601C4CED3; Fri, 20 Dec 2024 15:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734709359; bh=mGjyLUC8Tdl3s3Io8OxFN8wjAOa9sgigj2kk4i+JBQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VLQis4czNY8B4vg7ra2Rea4ivc9GVdI9tgRlwpnYn0bv5hmFVEIBeK0/jiTiNH5sA o57B1I7PtK3/gECGK6JrYdNSWw2Md7go55AZ/DwKYiXcMuQriE/xmwaDFVg8rkJ0H1 hDMw6BD5WbL+GTZbo5xDqpy8Qh6eCd2RwNZ3MYPFoDlfteKvRkrghk7UE2BMGYsmdd I5M8Vku0jmWEdUwquAi+DtkfAZYrUNRnAO1RC7WV+uUky1kRneuJVcPEDWYFLnJlN7 sTRGAnp7ua4vJUuPGItZiaxcGxpTKF0ItH/lZs8eKJ8XqNb5/d1ny+JJW7+wWJdAsA b3b5TAV5UwU+A== From: cel@kernel.org To: Olga Kornievskaia , Trond Myklebust , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v2 1/7] NFS: CB_OFFLOAD can return NFS4ERR_DELAY Date: Fri, 20 Dec 2024 10:42:29 -0500 Message-ID: <20241220154227.16873-10-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241220154227.16873-9-cel@kernel.org> References: <20241220154227.16873-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+XAcsmYgBnZZBplI7zb0ON3ksPyJGdZ3rXRv7V4llY6edT+ 5XQB6PruJuJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ2WQaQAKCRAzarMzb2Z/ l7VED/49r0f39OKr6+DTGV/4qLp1JlAM9sc0h/k5KD+yxfT+ml+wx5aFS59faNjVYVcH8H2kqNi FDpS8QQDzDPWxzHQQovDv2hAWbi6Eztm1mGx2nhC0p03DotdxqCI+2iTNf6Wo3v7RspFrxzhfVR 08zWZtX+ASsjNgYVwzzVTWSQTtIm8Xh6cgFivYw2kOyzP6xzfHmiJHltYOK0VjsNlI0mA93H1hr lbLk7dAtUGiVrktDyac911Lgl9hHVx1baY+NG9YQez/XfYTVirUccv1HL6hhgE0rRc2brcfAdwM NQj7pW+JNfEOYXitu95rggocsjaFnTxQRXok+JjeiwiGRfLpTu68Y+c4Vse4ud4g3bGrBmBZ7sB lQEj4vtZUatic1cSREHkRriMIyGFHUZzquC3xkSC8fr9D4POHzgllCFSiQW8+xN6vzb97jU2/Za 37S+9sXP4HylWVXvKr7M+fFP2dH1w4JLWfdPawJnV9m/J5TWdeXGeX3cIiy2g8CDxk5vN4x7MQl 1/bjnx5L2NgkZEtvo+ZlvmgCzumpVOYkoFOr1PUnsW9ThCRlowIAteGMENG7fsvbmcIzNE+eGUq VWJS7l4qAimtOp5cuOVPpj4Zn3i1XSkxOAH/xoKK9F8/shzQzA7QI041YdlUXeioaeTLqKmjoGn en6xrytlkKEkfQg== 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 Fri Dec 20 15:42:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13916911 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 25E88218EA8 for ; Fri, 20 Dec 2024 15:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709361; cv=none; b=LXLSytrmAoCJCggOEMKb+de2SFJPc87mhO+QGeaXLtWKKx24VHtrKaCuh2D6/x+Ed81Bm1Cb1kxHuIZLFhehOrLa+9+cINK0GVEXvwCITIJW5B5iarm0ZybvO2PHFGd1F0RWhknvslJso0DbCTd3y3PSCkZ1JzXfuEpREWFinaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709361; c=relaxed/simple; bh=xjZby/G+1S0HtB+8hgO8Un9xUZQtgkwttk+DiH1A6IE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L9J9a/S1IhJMI5q1RIEEqKwAwqQHShclinC7bhXdnMQzBB3cgC4XrNOJNHI9KP3PZvc80rF2XcMdkqCcrQaxBap4MFjLZPXq9IyWn74diJZfQYoC6TDFerv/WqnxpSyAoQGfnjaBil6Hke2bxlMZ9FmwRZfAlu+58TYSgcyHax0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XixpTbCp; 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="XixpTbCp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08644C4CEEB; Fri, 20 Dec 2024 15:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734709360; bh=xjZby/G+1S0HtB+8hgO8Un9xUZQtgkwttk+DiH1A6IE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XixpTbCp3pTat/WsMLHgue+aRLupd6yZMuVgOzc+Xzi5DG0KTBxXJCoxH/dKcf66B Y/yvLzVwGYi5PkPI9z6S1H4ZNeIzLgwFloXSMlSPEf3JtZU6cQbzLv9IEqmoN5yy5s mKhDzCLGcEU4GOfdiQRyRuKB18tnJtDjsiYY7pJHrQTNXzQMU4DFdWLou1RMZ7M1nn t5YhKLd5gEmgoVTm3xFKpYguAJyIczYXddCO9vb1qD87fYqUuYGlLG/q7S7elUevnc UF74zK6EaRaLb8viktdPpu3OPYO459Yh5mIpmezE3MRlJLHt6QcuU9/5GsEgq3y00F w1iXpI2Hpr5FQ== From: cel@kernel.org To: Olga Kornievskaia , Trond Myklebust , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v2 2/7] NFS: Fix typo in OFFLOAD_CANCEL comment Date: Fri, 20 Dec 2024 10:42:30 -0500 Message-ID: <20241220154227.16873-11-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241220154227.16873-9-cel@kernel.org> References: <20241220154227.16873-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+XAcsmYgBnZZBpiihnzZWIEfy5TkDaUouIstdQzlq5dvEdo RuUqDbv3wuJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ2WQaQAKCRAzarMzb2Z/ l7YcEAC27zA1PGXHnL+pqThgvWnSrKnlrq3XAn5FuvqtWZym4wMwM3AodvcnwJeyqTQXAkcpVs4 cByf+hgKmISaGqllwOUS4C/QBCl8Hlda6STG1ZqBwV9tEcZTxtIWCm7L+7XhleZqT/TikXI/IM9 qfbZYTOys1Ml6bt98Y6laNabd178YBz9Ed8lc3QN6LzbWyWtV1w9sCQlycPhgLEBmZhevQZbP3M +j58HVL4NNOQTCmU/AiGVWKW8OiMLA33zyzAqmkYHAx06tjGMfhHpQyl4gv2aINYsgXSp8csUIC 9ERwpluitMkUG1YAsdOMKWORxvoB7qRqdwmvMrFvLEVH3dzHR03OgFRdi3RgYT0ZNgyc7s4R5LV cY10ZVi3ojA7jPGV6rFqf8giW7PITNwOWJxcQDj1lmlSxMSfj0G4oYSsE5qXTVdzFP/FOvooG1e 1MuTIG+tv27TiPrX9U8xhO7TrlAdaJB+IUx/yIkWebS5wzUynol1bOM/n19TpptZETjxmPEVUhD JgRdkO6hs22ATfAqYJoFlF3Kom7nBAwQfddtdusXMwCqyxvnxwWgzDhY5q02WWgzHJl0ob6+wMZ 5BWzbNJdSslJQGodGn6si8I8aWHVjs4/rk9EIdaFb4QtPOycCZb6KE9msHWxN/koyziRAjRPnh/ EnRbA50ejD40ewg== 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 Fri Dec 20 15:42:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13916912 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 0257E218EA8 for ; Fri, 20 Dec 2024 15:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709362; cv=none; b=lrKf9ILmmYCoVBq7mTjyuk7xKZVS79TqD95wXISlIaieSb3J6UGAbmKqaxN8Tp3/kS7Ub3TYHLM3gNBPgCz1E9oSxk2nuzGI0m1ovS/T51FBlb13PUd+MubxlPj6rPz+FRTDjUDoRmkQq9/uXFyQ8w7YYeScxZu57QV96tbKFUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709362; c=relaxed/simple; bh=o4OPCvcvzGjpQ2jsC3ajssM6BwUC/ZQrtYpiBuMazYk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MLds6yXw4wgPX6WgkqFL+HqJ/9oZFmApZGSntDNBwagKWizjZlxI9pVlVhX2WdvR/oWvoo3WEjqk+ocjCdGarLYirXqDGA35v8KbtTOw2+l7DO7RlzyF2OipLAvGY3xPLG0uEseVywnMvk/sz06xYHHdqSOQxGUH6dfnqF8l1BU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZtLOpmqG; 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="ZtLOpmqG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0504EC4CED7; Fri, 20 Dec 2024 15:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734709361; bh=o4OPCvcvzGjpQ2jsC3ajssM6BwUC/ZQrtYpiBuMazYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZtLOpmqGGELrrG6eOXvgFpTn8EV3mSs1PG4MGFL5KVxHb6aI88VOE98/zYYhkm6+x mJbsFGYPICc33YOmBYImQzraebwp9/wxk1QTlJ+KQY5jIs+2e9nLXun9OlGf0TyKHg Lxo4fcXArtB0yDD9QXxCsKUMU+AMER3TjVWlr1En9Uk8yabqMYVSI6F8SmH2TcGRY4 kdQt6F5vJ9zUUqjqQvguvPb6YhKMBhjTn5CHROacPHK3gvZhyc4RufTaK7td0AQX6/ 6jtkCnCTAf9/0IEDq06MTwSx1NyrDaWX3WgK4aW/3gSoi/6MRUeyxZb66b1/kHAkEK gCi98uIlRe5Yw== From: cel@kernel.org To: Olga Kornievskaia , Trond Myklebust , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v2 3/7] NFS: Rename struct nfs4_offloadcancel_data Date: Fri, 20 Dec 2024 10:42:31 -0500 Message-ID: <20241220154227.16873-12-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241220154227.16873-9-cel@kernel.org> References: <20241220154227.16873-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+XAcsmYgBnZZBqQUDdD5d36iI9/pYM8QCFMEyhnWZ4TGPJD HbLmfXMYZKJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ2WQagAKCRAzarMzb2Z/ l7kEEACc41ofTG1+A+JeNjmRfiQMIwEzHniouhivb6DYFmsZw/fxGFCONqdh/c687YdzndSK6Cd rVPbKgl8zSLKiAG1RzRvrpQxKY4sQ54SJmTHmCeW1ghhzsJrL3bK8GlOpOzsMFiPo30kMgtkPin 1ygywhz3Y4XgjeWxcTfccdbFFR0urxa5bMkH5C4UtBVA2yLUKuD9RK2PDRFfDCya2GRhPlb7rA8 51K8l9zoROsH1i/VrCHcuwi+KBQBgm/qX2wdt8Sgx78qn0SzyWx1thy5Pb+eaHknQK34qD7kDQp 9FSqFNY4P5qDABzlVg1RWf+CCfteNxXIHc7m3U8p7YYG9GeZsxFSi1uw2Dx0+e/1v7FpRW4N+hE Ojq66bH6Cr14LooHqp/R1MytWnFpnWAR34FIlJfQ6wRzpcI22L5CF/A4kCQwvuffPgXROolQDRq /4zDXjTcE1bq3qBsHQQW0n4XzLOUTK5JRfzFL9cjBVulFFxEXaHShZOQwvsZWHWeHz+HkMzv8Wg elpq8a4gKIYIolFTI5HIrNr7S/+mwuUSWU8mqptuUg6FsHFFslhb4RphANW1hMuNQfS22JQzlup ez5F1BtmNML8dx+AJGV8DU5vldc0703MPb1cox2/z9VVq9JJn/7758IQwdSf9EyZ1ohFRiorOQ+ aPdh9jU+IqaRYGg== 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 Fri Dec 20 15:42:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13916913 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 A6A31218EA8 for ; Fri, 20 Dec 2024 15:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709362; cv=none; b=hxUciLJeYseO13rDu1JmBWGIVexuAd+BEVqvzQpzGH/Yr+rZrrrpf7qEqSY6XDfZEeX0vNTNENPTPSIu9kaG8YUSkXOnprZBM+YfhrgPXR5MSCucaoBOx6q+HK5T5keyI+IZJMigO/z1euvWtGs/kRFVWXJ3gJWzlORsCQeZHjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709362; c=relaxed/simple; bh=UHYvkJ/Qmw8fb6OtUDOkOorY6lSj4IVXt1zWIkSVVuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IniWkLfyY0VoahglE9Z02A7jDzf45cQOWeZCuKEhW41QNq+IvMcQxnf2Xr+AS97lqLUrQ0diyVjpxQ8xJ7vj3jHikbilXvI0pxEN9xVP4EUDWOJMCnwZOreFaAhlsIEbDsgbxhMCRvkuDRmmiwjI45chLeSDfF/6IoQDZDSMiNU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s7ktc4NR; 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="s7ktc4NR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B99C8C4CEDC; Fri, 20 Dec 2024 15:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734709362; bh=UHYvkJ/Qmw8fb6OtUDOkOorY6lSj4IVXt1zWIkSVVuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7ktc4NRX/ZX2ecBMuECi2UkraoCVHPrSgkQ3Oi+5IbOP35dSGpRAGEWV/bAiZ42B ldZGT46FdYPt9FkvPhEi2UolH3tiqlf9Yx7Hxl95mdTfcR6ZTRZ8GZILvaO3XQIzmI +eDgHk+VD7n3dwMj9dWflDAmyLercCHh+dcDZEhRhHXegPiiqOprRI+PeJ7WhReq6/ HbHdo+F0l+zWoGs+v+5cvoLRZKKL2a8/5lo1XTr13S+dMMgwsGCaMpxW8RMaRb7Wug 8hd1ZhXuh4fPOzo3fosKkDbrqLxQ/E9/iPjJfMDgUHPAOVtsVIu8ZSMyZ2PWWvRT36 G6ut+uP1JuQ7Q== From: cel@kernel.org To: Olga Kornievskaia , Trond Myklebust , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v2 4/7] NFS: Implement NFSv4.2's OFFLOAD_STATUS XDR Date: Fri, 20 Dec 2024 10:42:32 -0500 Message-ID: <20241220154227.16873-13-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241220154227.16873-9-cel@kernel.org> References: <20241220154227.16873-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+XAcsmYgBnZZBqhVDTbw1zxqw0jFYj1hGPnXzRPUAwUwLxx gMEHCYAGWKJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ2WQagAKCRAzarMzb2Z/ l6btD/9DzJo6pwmtLFAKTjYP5LVTh+v+rQNIaYDFK5U4E/lnWsXcuXFn6uw1wrFa6jCo3TdQA9Y hGEKt01jpShCBXBmOSOkWLzpo0vTQli116wTp0stbtI2rHpR8cn4xPo7jOPkOOkIpzfvBbnR5kC 26+9BNw4pFDRkB8sf8r06YYmf4SPySEQ13ARxMvu+bQ5XhCIK7lCThYo6MLGwH3zYr66+FYhybn lT/SVoOID6Naq5e8amAK0jvExhipqVEqVqc/+pbwwDTCmywKirw9B1tD/KPtZWEZ8P+CNHevBmt WtgLV4+A31HXAP3RB2N1dHXqeocuwU9WBS41HeYbetNlicwOy6z+m2KB9iUhvXRxMvYdVMZTsRc 9DQ8QzkSegQPJn0/e8a4+12yVWvHslr2PozQmz15OEEOarWJVUsXIAMI1H5sF1CaTm9X4VEPcOM we4UbIVfZppovDWgqRa75NRS4jVna/5zq1JD/LyYdAaELbPiuLIi14NqKG5vWBIvpHOnGwRoIsy RaKLhnuE+6j2ltLLp0FXUovx/xPViMvyshagqGDOCsAWpBNX06N59Op/OO/TBtBlKHHbvwxIk5m MKLjj3K+NcAYRDEVy5e63PrRrLv+Xh/IP851vc8h8tz8e1J627cz7i2Em0oQ/NGzjAbYqTlwxN4 jYekHFd2wi96jow== 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 Fri Dec 20 15:42:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13916914 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 2118221A428 for ; Fri, 20 Dec 2024 15:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709363; cv=none; b=CNkpyVRD7NA+QQLbpN4k9BXTtV7ML37hUzIIdNbLDEKr2ji+y1FYom8A6meZNSX22tScHI7P9enRMLOVrMvXzY+vTcsv9pVK8Q3ETU8sfp+SKt09DLP4s2G++EUi81ep2ObWdd02XIVkIOHqF3V281mkMYrqbqqClbjWWH+06SE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709363; c=relaxed/simple; bh=ISlhW1IQuYeNtxVL0g4+pSklooPJq00V6urddc4CUfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GzmN44LUx8R0yX5c4Du/X7CIXXxO51vtv1pjhxkYCcExBWlVUq9HO0rWmYYa/dx3VruVaI+rkH2F6cN+8J/NmY4/Ym8KxB0yxPCFfr99BsOLJn6wLSlQC6HoBAuKUwvm3APKK+4AN43vJM35vUnDsrE3NXx4mkoku/S7zae2+no= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m78cC58A; 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="m78cC58A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B392C4CECD; Fri, 20 Dec 2024 15:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734709363; bh=ISlhW1IQuYeNtxVL0g4+pSklooPJq00V6urddc4CUfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m78cC58AI8VTnUARpFJU85XtUDKOYWtA9NggSuu1YCtDym85fa1oN32GzfVh4Wvra eMAS1G1XNxOc87A3nc7xzB6RvBAsR+3pr4Ng4K+7Ppwu8/XwwrmIcQ2L7P45CTOSR7 6CF7Cw7A2DPin2SM19yjti7+ymd4TTrUbWV5Gfv8WbOYeIV17Z4phlGxOQSeqt1cTH B9XQYsaXAGT/2ih/HPiO/vOS/YithbbJ/C77sDfFqSmvaYRP5Qr/VhFOirVPHg8fYv moPTNjImo9hyuTCwVZfIAuNq/LhB2p8E1umEv6bEkcjFMVRgbnmqURR/wy+dt6/n8A VbId3qH1X1flg== From: cel@kernel.org To: Olga Kornievskaia , Trond Myklebust , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v2 5/7] NFS: Implement NFSv4.2's OFFLOAD_STATUS operation Date: Fri, 20 Dec 2024 10:42:33 -0500 Message-ID: <20241220154227.16873-14-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241220154227.16873-9-cel@kernel.org> References: <20241220154227.16873-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=5121; i=chuck.lever@oracle.com; h=from:subject; bh=2535XkMAeW/LrAT13jLC3R047rB1D+11KdwMAV8JhqI=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnZZBq2/C5379WGghjLDmJrcKaIoQ9sXl8u1ij3 cHcKfTGcW6JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ2WQagAKCRAzarMzb2Z/ l7taEACUY+0UEUOeAXsa09jIVe+Ah2RWElouG+4ubs4xu6W05K+KofpDBtgt34DBu5AxkWWewaU RbOQd/DKV8qcS25AwLgvypWwn36lKyBxv5dK8Q9lvzyXREVYeDbEu9mMHgxRLpkwui/PkZ8u2nV bzKVjrzqroxt/xKawDMEobCmsA4HVqBnaNusxTKh1Txt4Z8e7wRmyqbAtr46MY+8C6xkAqxstcA KoNYrx0ZDQEHC15ZlhMwfcdP6GFDvo649Qi9eNcdgXlHJto4fI+NaEwjWMIDvmFkrQpSmjS1oFI wb1N118P7vcXXeSSrcQnJo34zQrIVZJnXzhaN7IbxbAESMfzuppvkG4TCaFc0Okbzmu5/vzmVRy J/6rzqprbIQX7x0xDowv59XYcY+u3wyglOYznOeMX3cebYq8A6f0VYo98rmiP2Ke+2APLVn5A4R 3dNgKmiUXoRJDWKgHKcywcGyqzrD0XZ7B/8D3SgsOPejPpdvoJ0VAXQ9rbCZ/FtduVpUE9KqQlv e8Oqv/g6IOXjek0Py/YYgZibIvtoh3joUTdZqvrUOIyoalyHeccDjW+ZZzI0AWaFniDHTVtTQOD uw+PhRYoLLPKMiA8VZy2XvekzR2S35FWS0wB2cvb0ze1Cl/m9tiinp/6qUFUNH+M79HRVbIneL+ f5JmzBnwxS7Xu+Q== 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 | 101 ++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 3 +- include/linux/nfs_fs_sb.h | 1 + 3 files changed, 104 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 9d716907cf30..7fd0f2aa42d4 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,105 @@ 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); + + *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 Fri Dec 20 15:42:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13916915 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 1850021A428 for ; Fri, 20 Dec 2024 15:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709364; cv=none; b=ScwVvG2a97vmc55sguCBcgo84tVkiKBV+F6buSfNEnTtidtnFM8FRMRHNmdKwyrqMDg0a4rWSDrGOLAFZSVf3rYjKLwSt5HVYFn9GMU6ecevzIDhG9Kuo8fVeicWidPbXtBK+RjI1uyuAONr9YBAjjWLN2n4AaH57W3Ls5weZf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709364; c=relaxed/simple; bh=8a1Q+maZqFABNeSYL6UF65bkgRC63Q2S7h6CP2XI2zg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=je8RwFY5mqZMiv9ObjLgzpYsLfF0DbFtEldyNjxPsO0iA4nlD8EEZYjG51o8zT9nNMUynqsQcbGXQhjR8HYCKUOXDMNBKp8t7TIlfK7etZP9tmJpoAURXTspOPFa2L1g41NGwGAqCPaHPLOV1rMLUZrACB6a0cCNQ8xMyBpwy6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MS+coAaG; 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="MS+coAaG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FDDAC4AF09; Fri, 20 Dec 2024 15:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734709364; bh=8a1Q+maZqFABNeSYL6UF65bkgRC63Q2S7h6CP2XI2zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MS+coAaGaz+3+Q7LDQrxjOnGnYJ+Qeps0FK45PRN0vl6kCezUA2EF8XAnjuZgoHCS s3e9cPG+ENGIUwHbLV827Ib2swhi8kC6TDp/RDaJIzdIg9fO7ucbcwRHduYQUOY+Jq E9KJjcnaVgVR2SJXSDjqqYzOQkDUw9rM9uqMUXSU/SrAXfdncZMDU5BlY7G3LEyImg OhfYaS8eUU3sjc28r/QyCH8W3KxTA2lmwdgvEZ0SVNyY5kznNgobqbE5dbqv6b8+uv PC7mNkrGZNybXjwXk++zc5nqdx6ohsF8KIxBaZ3BIr5na0rkTxjxOgnKiZftlK173A koUV0D8X5gXfg== From: cel@kernel.org To: Olga Kornievskaia , Trond Myklebust , Anna Schumaker Cc: , Chuck Lever , Olga Kornievskaia Subject: [PATCH v2 6/7] NFS: Use NFSv4.2's OFFLOAD_STATUS operation Date: Fri, 20 Dec 2024 10:42:34 -0500 Message-ID: <20241220154227.16873-15-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241220154227.16873-9-cel@kernel.org> References: <20241220154227.16873-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=5354; i=chuck.lever@oracle.com; h=from:subject; bh=e9sVK4hJFGQ+MgxLCyDcaat5hynBtznykV0ciFcJ+jc=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnZZBqx5s9J0Nh0OHc2I8joqeFFu7EPhWQ1//Os DqR0iGU/ymJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ2WQagAKCRAzarMzb2Z/ lwI8D/0c5od6E3TxWUEJJTCJanIBELluHtwnQwjSNY4PzfXSxLlmxeK8VplbBP9ZD3CTqYxBQVq bFLR0Gx4T88bnCNZaaD1yY6Sh6xRxc7AfKjDR9S95gskyBfCuKg2/q0dDsPAjNcQhwtJheysciL qZFqZavQw33HGXtlsjMTKo4hVpChtcFaF3UrpZspUa5FMvTsnf6LOPOHU05Rf4Wut8wi5A2OLBO 7ASeso0CP+e9HKRPkLJYXRxRpCUpPsjMtEr5U7wAe+iHN786uC42DrEJXqlwLaRcit/RkZ3JIQl hsAEw7uS7CrFeuxlh+56c92bH5F6p5+t2MrpYc9P6S4qFZ2qsaLo76LO0pv7VfjuGjiHXKCOqfJ NbbjaGVvF9grUXhIAQbUVk6n0uTVUEN9EjHBrObnksaBLPxnPo/UEbaiM5wmivk63zAcc4I3TqW w2NLIBrX4L0ZGNuXqY8/IoAJmYaQO5KvuXReuOCZkRoFP588RwiuOWIFX12yHyauEDChw3sZ9P1 kFtHiwMF3akWXgS0/67c/PedPTjinIsBmDhRWNte8WcGlEFXBdMBM4VMX6edfWvOr6DZioTdahJ OIpt60njx5ZUkV+QW5vnpc5iGaKnwClnArwl55LWuwQ81KPdfqvjjwtqecl5j/5H1xbTBC2gIQh lKLLkRfGB9gFo8Q== 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 | 70 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 7fd0f2aa42d4..65cfdb5c7b02 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, @@ -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 Fri Dec 20 15:42:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13916916 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 6386221A438 for ; Fri, 20 Dec 2024 15:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709365; cv=none; b=XqOAwYUF6xYxsnp0FvxTiEOsgc8stM9VLoAiUUy350PyzviJAVZp3HVUQOSG1RK6Mij5ywGtFZhFTDl21P1tXMiJzwBZuC0RYIAEOsi1i7b93a8R2d+0gJ3tdDQCuVfgVIJZT7Kb88oU2Ethsa67TMvXHK2wEJUTWnG3lJVQTyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734709365; c=relaxed/simple; bh=t0vGty6LVUUZRvHj87X/Y7MsqvPoleODWLsrFyVcrxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tyjp7wSHHXgPMBleLyH+A+546oMz04iO7UhBQ1+FhbQggPj4eK1womQiC/85HAq1kfQKxK8HrMnmVQaYcselA03lTb1yKJT4GQbzfblA4qwgUDdM2frYkhi3+cfu/7JDHnN3IHLzTGQe6OX55Fuua9UEiaVZLJ78wNRQDd3LDpE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eAtav6GZ; 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="eAtav6GZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31D5DC4CEDC; Fri, 20 Dec 2024 15:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734709365; bh=t0vGty6LVUUZRvHj87X/Y7MsqvPoleODWLsrFyVcrxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eAtav6GZfeYvZVBlMWqRFXjgp3/WjHKzkzTbE6ByO8QiTbTGY+krKtQG3v787GM/m D7FOlAsM5gNcDEvfE03kSJ4UqBO7BVLxPJHXe9yuUP1VGIsTL4JBVABARRa2+7iwM1 noHxbUqW20LKWsMxV3xql/WwOPrgyO2JCNWwjpUCsB9Sy0D+FyZt0I2thhROC5kqxT LjHgdcA+HSmFHOYa4xxVeO7HreH+CL3n3f4noDev30VK20A3Hwbt1EjqHeENRb+eZw kRUC5tddiW5vx9rWhd9riW4fZcR0wR//jqGpmfHM9vL6AHog/sIjs/bbsnz1Ev1iof Ggfkc74r7BNxA== From: cel@kernel.org To: Olga Kornievskaia , Trond Myklebust , Anna Schumaker Cc: , Chuck Lever Subject: [PATCH v2 7/7] NFS: Refactor trace_nfs4_offload_cancel Date: Fri, 20 Dec 2024 10:42:35 -0500 Message-ID: <20241220154227.16873-16-cel@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241220154227.16873-9-cel@kernel.org> References: <20241220154227.16873-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=cODENqW5Ok0dx4I8crX8CqX9dO69UuRUXqmbixqES1w=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnZZBqZegPqFmB6In+7dySazamD9zX4rjc3ltul IEjPAL1SgmJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZ2WQagAKCRAzarMzb2Z/ l7tBD/9FlN7rHxkzeTNDhsxysYojUkGP6y7ujTPXkfXhOBOwltEL9rDVRc/j/Dya3KuRIax6gIg a6D0Ip9rtLZAK6hORTYiK6oR8Q5sl3V4BtoYhiYzfIb+NmRC3wc5/AwvU16/IITfsVMuJEi1ryG 909q/7eX2qxv63VM+Bqm/MVFV/ntvwqTHMsEwM24Cpaoz6y4uENq88vmQzTR60Q+kYFrNFQ+DR6 6uYKxY7IqAdDCMPktnoiPL0b9DFK7GCIyX1VwD7BH44Mbin04xEtrBP21viWvPdg7aFSgI6r3Ih bHUm+lz6u6WpdztSVv25sf2JLuV7JJnYMVAM+/x8+bDKrKrZlLukOhs24KzSzvJYV/aEdnoZupn pT1jAEerKHjsRbCfRbS6owxY+Mk5aD0Ncrp1Qji9n9Boj+UDwlc+1+r7Wj7rS3rNsbdP5Z9o7M8 AOTSiaTBPnzSU1cgaMacQr1byU3Vde/J+NE0SLPk8yNRrffl8+YP2zwukuzHh2gpmCtGJ84x5ji K72cmXzjShFKtm5GhzkRh/9y7SzbiVhpIjuaktIMVNp4FXU/PTDxE+VqM4RZNMQu00fZmXyGfzC WiHzWcEXxM0hPKz/1iO7cBb4CCCk98058H9z0K9L7E5AtdUNvKBxLplnOAny+GCtyZvJHMipDlb orCPO7yMiib36qw== 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 | 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 65cfdb5c7b02..3cdd4f6f87e9 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(