From patchwork Mon Apr 29 15:16: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: 13647245 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 4DA5F7BB17 for ; Mon, 29 Apr 2024 15:16:56 +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=1714403816; cv=none; b=MMzPNougx52gPXZi9NppjDkm0cfSAcrcNp6z4WOfOzRyi9Zy5ly3fxvxK36hJyV0rdjC6tBIImQTM8Od8ZO66d/S2qmNq1FuTDa89E/pntolrHtOnatFXnl0RfCsLvYK7vbiPn0sytvuoPcIi1UuWAF4H4RmpmqtqL3c/SRVQxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714403816; c=relaxed/simple; bh=Oxg9jNyMjwevoOVLxr01IViPCJyTcFZ1gqUAgfZZ4JU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MTlAsw4DLNoZH9FNE7Gp2/DyTkcpBg5DsuZkUDhd1MKHB8mrZ+W+4EBXafFd1bACeHpUiIChcyxHUyXZJDUfuf49t5ToRkOfSbCBoRx5piyXBWcq6KWHGkPXYTONRDt2qayq8+YHKhlA4g06Hiqa6xgD5xTZPa7NNxUNv3kLL34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wr2Oc+UD; 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="Wr2Oc+UD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 803DBC4AF19; Mon, 29 Apr 2024 15:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714403815; bh=Oxg9jNyMjwevoOVLxr01IViPCJyTcFZ1gqUAgfZZ4JU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wr2Oc+UDsA2DWL4RtAQxU/STCYeoFyhJ/bik2r7ZlQ2La4bMKocWNdfg8mH5Is7xO hAtbhPm+JWnyoVLQhW6iTvMsml+7W4pGVEsMkc9N4FziWsWiyH0sl4k9O4USeA8Qaz 0U1cVKbAyJh4DuFTjN4wpa2bMv3Xvi5PoHRaaByWjtbv53VcTIWGhbb52JPKjuiyHY G4hafZ1xzXuMe7QDTCGCI5c4jmraEfQSsl7sZFY/Juti3lUWdLf5qIE0Q8TXsHvr9P EIQSYzx7qSM6bZ2E5gICE1SbAfIfvDo58cIkavFULRdNf4mZ90Z/s8GRp4ood8W4WA 6FXsVP5/lTblA== From: cel@kernel.org To: Olga Kornievskaia , Dai Ngo Cc: , Chuck Lever Subject: [RFC PATCH 1/4] NFS: Implement NFSv4.2's OFFLOAD_STATUS XDR Date: Mon, 29 Apr 2024 11:16:34 -0400 Message-ID: <20240429151632.212571-7-cel@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429151632.212571-6-cel@kernel.org> References: <20240429151632.212571-6-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=6131; i=chuck.lever@oracle.com; h=from:subject; bh=Z31CFxu5ZCFO0EH+QrNcindRp3z2QGFOEwzcQbNYZHw=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmL7nW9zvkx8p6wYv1JFqilShSaOTnrRCsDhsM/ Qmdw/drCU2JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZi+51gAKCRAzarMzb2Z/ l/YZD/4sYO6UzaxY6lfaoHp3he/eZQbECQnrH+dhJvxuoLVs74NzyVECIOzoxMATw0DsSPnwAOu YzV9eQtLfwG5kc/USF7/aecnEUKo3Dup3q6gsutIb1819+kJ6MSEltaPYyK1+7KhWhnqyC2NBpu 0UrhZe9PMrN6h+o50ibh3OvYuzw46Lt0VOVUj39rK0L+J9uZT+KKNodu69gRivYIYLk1TZZd3D5 OSE4fQ528PqZlY3tqcH7lkw9ATOV73sYbl8AiOXrwu6FaGG0Jy/vozFxuFtUKF/e856EXw32i6v OKXQA1xp6d8K8IHLXya9fcpsolPFidr255y1AqOgQhCX+D4eCfwO0uE/SVU1P+wGz1Fbt4Zc+QD IsLnaLGG3SjDXL1u7B8fK+6GtD9qdEaYwhF2MEyn4yypzoIKYP80HMvcJUr9KDgz9tiyn+pYGSN ZkHOqOHN4eBomap7/w4/pLdnJfF70c7VOta1k+rMpfdwbfOWuFIdi1UbaaICAXqBAZC0VDKT3HM GDA20X20K4Vw1upEclqGh6eTZjn0Q89wKXXWr8qfztIfuNj32IoM6UU7h2MPEQN0toOJ3APm2cd 93hEjWN28CqmPIInyPbQGNNTXOVnbETR6ahO+AG+uvKkcmYHXP/ibB/JRZQqnczOHu13Fd2l6JQ B7WhmpWrbkUSGbA== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Add XDR encoding and decoding functions for NFSv4.2 OFFLOAD_STATUS operation. Signed-off-by: Chuck Lever --- fs/nfs/nfs42xdr.c | 101 +++++++++++++++++++++++++++++++++++++++- fs/nfs/nfs4xdr.c | 1 + include/linux/nfs4.h | 1 + include/linux/nfs_xdr.h | 1 + 4 files changed, 103 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 9e3ae53e2205..bafa0005d038 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) @@ -549,7 +570,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, @@ -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,39 @@ 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) +{ + int status, count; + __be32 *p; + + status = decode_op_hdr(xdr, OP_OFFLOAD_STATUS); + if (status) + return status; + + /* osr_count */ + p = xdr_inline_decode(xdr, 12); + if (unlikely(!p)) + return -EIO; + p = xdr_decode_hyper(p, &res->osr_count); + + res->completed = false; + count = be32_to_cpup(p); + if (unlikely(count > 1)) + return -EIO; + + if (count) { + /* osr_status */ + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + + res->completed = true; + res->osr_status = be32_to_cpup(p); + } + return 0; +} + static int decode_copy_notify(struct xdr_stream *xdr, struct nfs42_copy_notify_res *res) { @@ -1368,6 +1441,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 1416099dfcd1..bcb7de1c1b44 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -7711,6 +7711,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 ef8d2d618d5b..89ed7dd29a9e 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -681,6 +681,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 d09b9773b20c..7b55a4e506e1 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1490,6 +1490,7 @@ struct nfs42_offload_status_res { struct nfs4_sequence_res osr_seq_res; uint64_t osr_count; int osr_status; + bool completed; }; struct nfs42_copy_notify_args { From patchwork Mon Apr 29 15:16: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: 13647246 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 4B61584FB1 for ; Mon, 29 Apr 2024 15:16:58 +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=1714403818; cv=none; b=arRNjYPvyesT0dlZqWAd+Yjk8Z4+2DkexCZLh4BOh21Y11OcEmlDVgr7b6VH3vNeOMkErpcn/piQm4DMcYh9KgAOdCUsPcL1iBftePepe7wBu56A3ozW8PrSxNStnOozudUdSOW9N4EACJ2ppCwDyCFXAe9LC5/8wmGfcSLILL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714403818; c=relaxed/simple; bh=hVDtiqkUVpBr0M36QAEcmy3ez9j1sFFjPq1SVVBzGWM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MrHsvczDuQs6pmQMtnpfy1YI8y6sQ4dA8HHDx7IByBlKn+ZBTfL6YiALVWJoFSoPE6OtJpisXUZhoXSNeNMTaQE8qaHeXjxpCeNfQz0375vtN1jauncxB6EyD4VoIB8OsqChUjTLi32i3ZsSeJHyaTfyqTKGLV7z2y9sV79rAwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EapE+rdM; 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="EapE+rdM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CCF2C116B1; Mon, 29 Apr 2024 15:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714403817; bh=hVDtiqkUVpBr0M36QAEcmy3ez9j1sFFjPq1SVVBzGWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EapE+rdMUOoUALv30emr2Pb+nKSh7VRDTKg8EaSFwPkH7va+CcoJ9LywRaZTTv9WL 5izoJykaUeTYM+Hm9d4UxgN6TD01CvLBjDMSwDdMyAVf4JqQ4CsqBbRbwo8f/a1EzL xg+3m4micGDc5jXpqNkqD7zWbjpcymiUbSMhvLbSKHVFlTIfHXX/hKHjPzsss5FV4H FGJbzTzDDCtbUY7sgcrCBU4cl+7vPtUxKXYe3NhT0uKk69PV9gaBF8+0nOaBYbcktg WvMelqpqRl5uN69K96GbdwIcMk8MqmY/vg9yz7HOzcA8ACQk4zvZ/u+LV0u9cYk/0b MZmsSf81KzNXQ== From: cel@kernel.org To: Olga Kornievskaia , Dai Ngo Cc: , Chuck Lever Subject: [RFC PATCH 2/4] NFS: Refactor trace_nfs4_offload_cancel Date: Mon, 29 Apr 2024 11:16:35 -0400 Message-ID: <20240429151632.212571-8-cel@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429151632.212571-6-cel@kernel.org> References: <20240429151632.212571-6-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=1188; i=chuck.lever@oracle.com; h=from:subject; bh=PFexzvVQS3P5KVYhC39j1YlMZNK/I7/rZcc+TZfynw8=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmL7nWwxjwe14PepKfrata+QZ9OHOo8+Bc/RRyf GIlH+wGOWOJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZi+51gAKCRAzarMzb2Z/ l2qdEACveY5i5wFKeUMScJfgh9Y4q0ZZi1yGhXBS3Pvn1WvtPR5ek9sCWNTVeqTHWIxCWjlXbny lJqNAGHwGFKKXrwtPIctBi6LPNuJlsyTiyZiCI8ujYdcj333zkyEINkLIoEEBXimmkcE/VbgYUZ /I5HshExfMgQ5HZbh8mRcZygWKT2Zbk5GyrnlJoDPY37ql4GGdG77vBKqbnbvRrblaAT4q3ic2M jryLwM1OPeMqKFjdKa80Ka1gitIii3aSr+bHIl4MMulYOkq+54eSMrog54WJ7Jqg7FYFHNA5OII qqEx+lXoXj5qHliL7ayT0sDWpdBmK9Ac/tWoIOTG0jKciYlpptV2Qkl5Oz0AznENYtOSyWN56tz 3hz9WNw4EZVkC/pcbRbGqwBnc5UR54mr+rsMUoyW2LpB72klYg+MRDJ1WhXjaqXaN0V8DYMG7ku ds8ArPTpAfxr8T72+Xuiu7VEc14JmsI0goGy89eEM/8Di8vXST1Z+/OVfYcmauj/EUlu9emVTkb BU6ttT47fud8jPHMDWCggIi3pOUEOf3auuDVR1JTIOUzVo7J0ba1GH5upyGJmkKaLCF168gkpyJ PnG+sJ01SBh/3+SbPqryeGlv8AvJcqAtcDTJma9T1W0kgy7ulJTBRdjFNhBP/8zQDK90ouh6uMZ f5WnZpOyLdVeBQQ== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever I'm about to add a trace_nfs4_offload_status trace point that looks just like this one, so promote trace_nfs4_offload_cancel to a trace class. A subsequent patch adds the new trace_nfs4_offload_status tracepoint. Signed-off-by: Chuck Lever --- fs/nfs/nfs4trace.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index 10985a4b8259..8f32dbf9c91d 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h @@ -2524,7 +2524,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 @@ -2556,6 +2556,14 @@ 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); DECLARE_EVENT_CLASS(nfs4_xattr_event, TP_PROTO( From patchwork Mon Apr 29 15:16:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13647247 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 762B285C69 for ; Mon, 29 Apr 2024 15:17:01 +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=1714403821; cv=none; b=UaZ86QgvkEeJ4bVwNaN2cy61NDiBHxtEBdy2hJzCbO9UIPzLO/klVQo3qqROxD+Ub4SkiC57conxCRdutxH3FyUE2QoUdVjVgm3pU6hh3+tfHRnsZ9dIu+QQqAyUBqO3yoeaBaNW1yzQaITd9CgGhLZDOnQlX0ZkjmRKvKeOxvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714403821; c=relaxed/simple; bh=1HFS83ETpO6ws36oisPwqHU+cyVmKzaTrI1qHJcfrsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e5iMbqRp3ceVItiBI6cxw98cnL0rKhg0eHM1pEhMIV1svcWpZbzSk+8Y+3FN7fKXeejSoELsZrNMtMt+sdwzVGYn7hZA70CswB2HHRqsbqvKtC7n6EvaThtFkyLSARZ/GEPoDOKB31ZR7VyY7xD2ugwwOorelA9w+EwC3VDPEIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RI0Gh9yZ; 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="RI0Gh9yZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97D69C116B1; Mon, 29 Apr 2024 15:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714403821; bh=1HFS83ETpO6ws36oisPwqHU+cyVmKzaTrI1qHJcfrsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RI0Gh9yZUmxALRGLl2mMS3ow2gN7hidbMAlWb2pSPWRvR0e9fdsYv4U1VCzOwtws6 xWU6LYtKPSmNTSD7ewS8K1hg6REhuYUnmK84Pda1aqkAtveZfyPy4UyYvFomcfDt8N cXoOePRf8go3O0BtsdEHTEd1jAlqLOhnwQMpcNG8hENtMUGCMxp+cCuJc47hMHIefa rpVVOdugq5i5/ix4+0gXEcleyk1eqtfFea1rCHIsvakq8iBc3ZGGYn+stY1DDwIF/o fu777BrQb9ONjHb2ntAqStBRGNpPPvlQYXECvyuVx3zD/M+Cw8McWD+qDab7TiBm6j fz/A6oxVMSoBw== From: cel@kernel.org To: Olga Kornievskaia , Dai Ngo Cc: , Chuck Lever Subject: [RFC PATCH 3/4] NFS: Rename struct nfs4_offloadcancel_data Date: Mon, 29 Apr 2024 11:16:36 -0400 Message-ID: <20240429151632.212571-9-cel@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429151632.212571-6-cel@kernel.org> References: <20240429151632.212571-6-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=2754; i=chuck.lever@oracle.com; h=from:subject; bh=pRyWHX7qWM4SQ85D/LANlhFMuiT3HZ64dDk4FUEwRXw=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmL7nWMwLT+K8gBwsgkhjnR+LYwefnnz3358Rd3 3/ek+PBw1iJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZi+51gAKCRAzarMzb2Z/ l5WND/wMbNyyBJ+9ZUy+VuylNuIL36/Ql+ol3AvT1JSvRpcUqmJqoHqr3asw5k5EloIosaOwt86 Gk0i73UithYg3d2p2+ipP2p5RtEhiQk4kH4hWIa89WFc8674hys5ZxUsKFeGq6jJKmK5Hi95tE5 cXyHoxHM8vuu3zIcb3lUkn8/XlW+JPwnxTwIUTTiwdFQ/q5ZXbvPd4q4fCHoFAn+JWY9IXCRBt9 /Outhb97chodtlBflTkqqaaLwJGE0i4xUMFZ5KSa+V01N6pqpQIAauac3SXyS+gP711MvyYgfhN IYrWztF7m0ss++pLskKF6FOIDBC1IcH6TanIG7GrRB1RBsiQmdj3+GRRmk6eEbhgmqt01CMdbOL QTXVaHMnRlWrgq079O70J0sqo75+xZEbSALtIXnpzwnC9sbVE+kDFmCXnetV3gQGCCu3mrdkgLz 37fq3DcMxJE+MRIFn9WP2ADMmjQ12TnqACCe5eIMUZ5W+F3lkOTiuQC+XHC8Vw+X12lnBY3UP42 SfoCbHq58zuUHBoxkt3g3M43D9PKks485sBvgcqDwS4AaPXfs4teU0eUtsxOYZHKHSeXvyO+soO c95sfKT2d5/hQ0gv0XY3s9KaJdLQplwm43iVT+u3QXSXgAdXyphO7SOvco0erLP7upHaFm8CNS3 DFA5X8DBdMte7AQ== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Refactor: This struct can be used unchanged for OFFLOAD_STATUS, so give it a more generic name. Signed-off-by: Chuck Lever --- fs/nfs/nfs42proc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 28704f924612..7656d7c103fa 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -498,7 +498,7 @@ 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; @@ -506,7 +506,7 @@ struct nfs42_offloadcancel_data { static void nfs42_offload_cancel_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,7 +525,7 @@ 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_free_offload_data(void *data) { kfree(data); } @@ -533,14 +533,14 @@ static void nfs42_free_offloadcancel_data(void *data) static const struct rpc_call_ops nfs42_offload_cancel_ops = { .rpc_call_prepare = nfs42_offload_cancel_prepare, .rpc_call_done = nfs42_offload_cancel_done, - .rpc_release = nfs42_free_offloadcancel_data, + .rpc_release = nfs42_free_offload_data, }; static int nfs42_do_offload_cancel_async(struct file *dst, nfs4_stateid *stateid) { struct nfs_server *dst_server = NFS_SERVER(file_inode(dst)); - struct nfs42_offloadcancel_data *data = NULL; + struct nfs42_offload_data *data = NULL; struct nfs_open_context *ctx = nfs_file_open_context(dst); struct rpc_task *task; struct rpc_message msg = { @@ -559,7 +559,7 @@ static int nfs42_do_offload_cancel_async(struct file *dst, if (!(dst_server->caps & NFS_CAP_OFFLOAD_CANCEL)) return -EOPNOTSUPP; - data = kzalloc(sizeof(struct nfs42_offloadcancel_data), GFP_KERNEL); + data = kzalloc(sizeof(struct nfs42_offload_data), GFP_KERNEL); if (data == NULL) return -ENOMEM; From patchwork Mon Apr 29 15:16:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13647248 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 2B58684FB1 for ; Mon, 29 Apr 2024 15:17:03 +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=1714403823; cv=none; b=jCgvvHWBLCuX1mh/7ma4DZzOsJgII3jJwMwU3CPLFDHekSLEW6qGoPyJWEua4aQGKjaWSQOWA76Q/e44cz4tfTTHU/JdoPipSE8n0f6MB9demRebPctuwR1RegCYCxIpPKIkfpDdW98rQFoXQoQhbDnrQVW7K5o+xKqG3CFwn6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714403823; c=relaxed/simple; bh=IYhiips++FpHj6Fd+k1IWsopC0vjCx4Hibz25uAKhAQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Px0DWwo9Y01Onwd0cDUtvw2ue2xcJlXE1akRe0Ubslx1IOwkQ6gnqVFL6gSiehkO4WbQZ3+8y1ageeQ+Y4YUg8WHY6iIr0+iez1m/3ACWkWcvXKX45U39Figpdu+Iku9q3bDf187z95tKSyVeGovDXnYpz1F6by93v6zkSjK5LA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jFwk+VGa; 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="jFwk+VGa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2B2FC113CD; Mon, 29 Apr 2024 15:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714403823; bh=IYhiips++FpHj6Fd+k1IWsopC0vjCx4Hibz25uAKhAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFwk+VGa7Sxh0KsDIzim51QCBi1aJq3VpVIkIYllk7AMrCKR4o28/944SvCqWywzy nBmR91gomEJK/T2LqOf/tLAXZzIGpNJ0vtitDWEIbmFiQhF/HYowc25XDczWO0d5Q7 AVm89yYQmgQcMhzqu7u3SKrGDe6jxZXQYNoOve4rfMTKxkUdiuj8GvP51lik8bNGZJ zcLPYAVSsk4dAXUG0FQsZcTZK1jAfUc/jWZHiddAzqDrSqIux3FZ7/Wz86D7TVu7QM ugfCWd8Zr3C8lUDCNCk16eiNaUHmkeMNLGj+DemiBsAl7MfkvK71YRu7Vmf8tPzNoT lxTG3O2KqLVCQ== From: cel@kernel.org To: Olga Kornievskaia , Dai Ngo Cc: , Chuck Lever Subject: [RFC PATCH 4/4] NFS: Implement NFSv4.2's OFFLOAD_STATUS operation Date: Mon, 29 Apr 2024 11:16:37 -0400 Message-ID: <20240429151632.212571-10-cel@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429151632.212571-6-cel@kernel.org> References: <20240429151632.212571-6-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=6806; i=chuck.lever@oracle.com; h=from:subject; bh=nZ5zM7+VewkFNxzsu9wMz5nLhLUmTnfxmT5JeugnHmA=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBmL7nWGoyQKT14FrG4YPbpUvHehFRb5Zu4+5Zo2 SonOkHzeAiJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZi+51gAKCRAzarMzb2Z/ l6wJEACRDu7EPRVFYYRNE/ZOmi7kL9/NvrnicfzOyB2Wql+2WL7Mu7vAjVweZ8TsWI1a9wleQfM H+dTTtnoUopyKKwf+6lMHdVJF30uXf5umOxQZcOWxQ/U33vMOgcmjA7fO3I23u1DWp/xKliCwPY 79xaPbdyWflxfSybaQWgCh9LOXM00IlFpSasGiU79abP2VtKhFRpAyK+XHWGTbABe6kGSxeniRk XUKscYz2/fthMDVzEo5oUff27RaQJKBblytj9UYcAVjWXPAxW3R9P0KncQBmNXG7gI/vxboVTgZ niEynZEpmVck1WW3m8cbV3IsdbT0un2bRdrdMyaCTOLSN7EOerd0RqpzeIwYtHSDNuazcL0bAkp bQ204C1XeJnOi5xPSCn0zF8GzBA5cyyTKjDKX+jkrUvYnNRIVQdZOU+iVGRreExWYei7An+sHgw 7Yj5EFUOu44ze3RNqTb+KJ8zD5AbxtmUk8iE6hV667upD420tEWAYFSeWLZqI93zHM6QfKmNCLd IVUN49m4emyEKGixA9l+KBvYjwZPoGNEjiF8Fp0enGG99yh8+ev42IpcHNGQNSJ6JaO42RloJFz jnaQo8mwHam1OsTKIgirQIhFydo1/GqA+idGGFM5cCQkVoKlV5cxojEkNnwWZQxLsm4K3ivp4tu nTwXbgXOdj00ZSQ== 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 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 matching 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 | 100 +++++++++++++++++++++++++++++++++++--- fs/nfs/nfs4trace.h | 1 + include/linux/nfs_fs_sb.h | 1 + 3 files changed, 96 insertions(+), 6 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 7656d7c103fa..224fb3b8696a 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -21,6 +21,7 @@ #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); static void nfs42_set_netaddr(struct file *filep, struct nfs42_netaddr *naddr) { @@ -173,6 +174,9 @@ 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 */ +#define NFS42_COPY_TIMEOUT (7 * HZ) + static int handle_async_copy(struct nfs42_copy_res *res, struct nfs_server *dst_server, struct nfs_server *src_server, @@ -222,7 +226,9 @@ static int handle_async_copy(struct nfs42_copy_res *res, spin_unlock(&src_server->nfs_client->cl_lock); } - status = wait_for_completion_interruptible(©->completion); +wait: + status = wait_for_completion_interruptible_timeout(©->completion, + NFS42_COPY_TIMEOUT); spin_lock(&dst_server->nfs_client->cl_lock); list_del_init(©->copies); spin_unlock(&dst_server->nfs_client->cl_lock); @@ -231,12 +237,20 @@ static int handle_async_copy(struct nfs42_copy_res *res, list_del_init(©->src_copies); spin_unlock(&src_server->nfs_client->cl_lock); } - if (status == -ERESTARTSYS) { - goto out_cancel; - } else if (copy->flags || copy->error == NFS4ERR_PARTNER_NO_AUTH) { - status = -EAGAIN; - *restart = true; + switch (status) { + case 0: + status = nfs42_proc_offload_status(src, src_stateid); + if (status && status != -EOPNOTSUPP) + goto wait; + break; + case -ERESTARTSYS: goto out_cancel; + default: + if (copy->flags || copy->error == NFS4ERR_PARTNER_NO_AUTH) { + status = -EAGAIN; + *restart = true; + goto out_cancel; + } } out: res->write_res.count = copy->count; @@ -582,6 +596,80 @@ static int nfs42_do_offload_cancel_async(struct file *dst, return status; } +static void nfs42_offload_status_prepare(struct rpc_task *task, void *calldata) +{ + struct nfs42_offload_data *data = calldata; + + nfs4_setup_sequence(data->seq_server->nfs_client, + &data->args.osa_seq_args, + &data->res.osr_seq_res, task); +} + +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); + if (task->tk_status && + nfs4_async_handle_error(task, data->seq_server, NULL, + NULL) == -EAGAIN) + rpc_restart_call_prepare(task); +} + +static const struct rpc_call_ops nfs42_offload_status_ops = { + .rpc_call_prepare = nfs42_offload_status_prepare, + .rpc_call_done = nfs42_offload_status_done, + .rpc_release = nfs42_free_offload_data, +}; + +static int nfs42_proc_offload_status(struct file *file, nfs4_stateid *stateid) +{ + 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_task *task; + 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, + }; + 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_free_offload_data(data); + return PTR_ERR(task); + } + status = rpc_wait_for_completion_task(task); + if (status == -ENOTSUPP) + server->caps &= ~NFS_CAP_OFFLOAD_STATUS; + 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/nfs4trace.h b/fs/nfs/nfs4trace.h index 8f32dbf9c91d..9bcc525c71d1 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h @@ -2564,6 +2564,7 @@ DECLARE_EVENT_CLASS(nfs4_offload_class, ), \ 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( diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 92de074e63b9..0937e73c4767 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -278,6 +278,7 @@ struct nfs_server { #define NFS_CAP_LGOPEN (1U << 5) #define NFS_CAP_CASE_INSENSITIVE (1U << 6) #define NFS_CAP_CASE_PRESERVING (1U << 7) +#define NFS_CAP_OFFLOAD_STATUS (1U << 8) #define NFS_CAP_POSIX_LOCK (1U << 14) #define NFS_CAP_UIDGID_NOMAP (1U << 15) #define NFS_CAP_STATEID_NFSV41 (1U << 16)