From patchwork Thu May 4 20:47:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13231776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76988C7EE21 for ; Thu, 4 May 2023 20:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbjEDUtH (ORCPT ); Thu, 4 May 2023 16:49:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjEDUsh (ORCPT ); Thu, 4 May 2023 16:48:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41390A5CD for ; Thu, 4 May 2023 13:48:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1015E639ED for ; Thu, 4 May 2023 20:47:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18864C433EF; Thu, 4 May 2023 20:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683233234; bh=FOZ1GrAVh5I0qJWWkitu/EJL95GloK40iE8/Q3F1AX8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iCDlZ05T8MycL/nwI4x+KkOzgsDL6x+bSAbj4qh/k0awpYprdV0gTbboph4MBwANY EDBeiz99FVqcF1UCy7xt9yrK4kHul5zD933UYQYJQMej/TH7ii+3KrrVYEgSMSsv/2 2zQzHPnpNo/fVnanNHCcR8ponUn6mouD0GY/09KIk0LDUnSe+8DrZyRZEBnYEy+nip kbDFqTux1KIyyv2/J8Wy6bavEwCDsY+1HsfODSmI2P9e76HSuhHUHdsFaWBhDP8mT/ qLUQj/zy4G0HROUkT+A81OTGLQxjh9nh6eQBL4B6XJjoSZrhF1tWxM7dOtE/tFuJYj xMObCRynU8VfQ== From: Anna Schumaker Date: Thu, 04 May 2023 16:47:11 -0400 Subject: [PATCH 1/6] NFSv4.2: Clean up: Move the encode_copy_commit() function MIME-Version: 1.0 Message-Id: <20230504-xattr-ctime-v1-1-ac3fc5a00942@Netapp.com> References: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> In-Reply-To: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, Anna Schumaker X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1516; i=Anna.Schumaker@Netapp.com; h=from:subject:message-id; bh=YhAIFcPa9anoSlOC3BpN7M/+TE5eHPyERBNbF0fuIKk=; b=owEBbQKS/ZANAwAIAdfLVL+wpUDrAcsmYgBkVBnQTcoFK5cW2XQya7QPae5Q08cwVc3AxSP5+ +L2dk4L7N+JAjMEAAEIAB0WIQSdnkxBOlHtwtTsoSnXy1S/sKVA6wUCZFQZ0AAKCRDXy1S/sKVA 63xOD/4+EcFEH58zIeooBfYJzrqcSXDmfN2TmnViM3gnkd0huM0GsGU0IW5bTh3cFvVREw9Mw9p P/lGtqXTUWrdr4mI5Aee+6jxhWZ+O4Fz7gN/HlmhYnkDyn6OckD0YgckmiZm2hiX+4Uqqh3xrLl +4aM8R5SJscqvHUEcVSORBPqKQOeXghn2w+63cSNf7COpZWglp8n1F4hNr86Or7O1R87znuT6Ux xN+L7dUV7UA15yO7PjjMKMHKwe/2uSsHJOsDnW5zTd+lWm4UqfO5YOpf2nkMtl/gpJIy1WR8NfR CfZC/5VRNmgXWlA/q5HJzwXRgQHecgfpQ4FS8md3zPQvsf30cnZI2TFdGoyu07WMyLGOp0od66K NTyyPRT/FkOl3ooZeNia0o4CbWTO8876z3PZyw3Q+IuPT21yTDp8npGcopqHR3GKs5TGKjL7emb w+X1MIIe3hbcUbeXIGiVGjeCWlIWRFxVXzackvRfCAa9Wq5NEg3UGjgGMaAaU+Q57l5dW1Wi/LN ZL4+fe6twq0IixNkXmCNgYdpY24Ls3omhFYbAOpaTorU5Um05xuwyfEf5HdEob1nlGcbujK3TvW NUAwotr0/U5Phim8ugdBSV4HV4ODcZUNv2jYeqO1MoT6QHKBZit3ucJ7dJZ253IG521IKF2BC5K 1nU+iEpsdcI+GNw== X-Developer-Key: i=Anna.Schumaker@Netapp.com; a=openpgp; fpr=9D9E4C413A51EDC2D4ECA129D7CB54BFB0A540EB Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker Move the function to be with the other encode_*() functions, instead of in the middle of the nfs4_xdr_enc_*() section. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index a6df815a140c..dfac3f62c7ed 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -317,6 +317,18 @@ static void encode_copy(struct xdr_stream *xdr, encode_nl4_server(xdr, args->cp_src); } +static void encode_copy_commit(struct xdr_stream *xdr, + const struct nfs42_copy_args *args, + struct compound_hdr *hdr) +{ + __be32 *p; + + encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); + p = reserve_space(xdr, 12); + p = xdr_encode_hyper(p, args->dst_pos); + *p = cpu_to_be32(args->count); +} + static void encode_offload_cancel(struct xdr_stream *xdr, const struct nfs42_offload_status_args *args, struct compound_hdr *hdr) @@ -671,18 +683,6 @@ static void nfs4_xdr_enc_allocate(struct rpc_rqst *req, encode_nops(&hdr); } -static void encode_copy_commit(struct xdr_stream *xdr, - const struct nfs42_copy_args *args, - struct compound_hdr *hdr) -{ - __be32 *p; - - encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr); - p = reserve_space(xdr, 12); - p = xdr_encode_hyper(p, args->dst_pos); - *p = cpu_to_be32(args->count); -} - /* * Encode COPY request */ From patchwork Thu May 4 20:47:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13231778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 363E1C7EE29 for ; Thu, 4 May 2023 20:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbjEDUtI (ORCPT ); Thu, 4 May 2023 16:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230046AbjEDUsi (ORCPT ); Thu, 4 May 2023 16:48:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41325A246 for ; Thu, 4 May 2023 13:48:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 84C91639EF for ; Thu, 4 May 2023 20:47:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0059C4339B; Thu, 4 May 2023 20:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683233235; bh=LkyZsGEk0IVqS4b6sAkmOfQ9+/+05DvGiOEGldodzp8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=l8QnJy/RzZo9eGK9BtFMRmB/7+OyQ2eSDhxpJBchsloVKXqB52b6C7PYBxwuFIeA+ MQyJNSS+VR+TThvbtQgurJI7UzFe0WfuDVcaxLBS7PAUEi7xDMQ8leFmwHxCwwbGr2 tCag17TGE6ww3zdTA1f6ZXnIEc2hB0aQeTV+SncD/hAl/SNeMfKHfOeVJ842Qi+ImI 72Hu8oMF0JyUZlyMzGbdr8G0CYNLToC4Quzf5dHeM+L9MpgzBaVdwJlZL6yY4inQRr BeYYRY4E3Ti2b20cXJovcVWR0IjUkIZEY1smLBCOUamKKw2/UFxKgN8PsR2zbeP3/W KUHhDHDklNqfA== From: Anna Schumaker Date: Thu, 04 May 2023 16:47:12 -0400 Subject: [PATCH 2/6] NFSv4.2: Clean up: move decode_*xattr() functions MIME-Version: 1.0 Message-Id: <20230504-xattr-ctime-v1-2-ac3fc5a00942@Netapp.com> References: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> In-Reply-To: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, Anna Schumaker X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8473; i=Anna.Schumaker@Netapp.com; h=from:subject:message-id; bh=6VF3ae9Wbii4Me0VD/bZve2+nZAkzGxF7h2GbljRgDo=; b=owEBbQKS/ZANAwAIAdfLVL+wpUDrAcsmYgBkVBnQsKUzVBPkWluHaDmnQRM80ruSjFt2VqMhY OApmWY6a1mJAjMEAAEIAB0WIQSdnkxBOlHtwtTsoSnXy1S/sKVA6wUCZFQZ0AAKCRDXy1S/sKVA 61sjD/9ayfZMW6w2U5bYLNbfG/sYNt/q/Dhiub2Tj1NZsnm1reTR7uh5FXB9bVgUCklvNs7C3Qj JSToiryKJvjwt2WuwjD2hD2oJxD9eAwzmB/VyJ54uAKHfugbhgh1W7nX9CuY7BM7ZqA95sVIDFF PokFzjj3ViPnu+KkJYxDmXCirlVYBhCxiwBec3JA75XArkJfAO5nRwGEn7tkDzpUy2WsT3uyAEL kloHQEjIOKKa2be5iPXUjXRhQXi+GnbhYK5WcTb66u+ffWt8n6rESaP1IK9QAOjzz5UOKN5lT8T 7kBQyxRtBMW1BkfhEwg5n5zYr1u9ywSslh5ITjTPQYyazulFSbAQ49lQgZNJpYo5CE7wBqyrfOJ RPNJhJMZEij3t3s9Nk2x01G3RHNJ4OF1aXDTjPFJVykrGazorn7fFNSQkdW/yVFLX/w0n1ivdQ/ EN8HLFPdAX0ZH45Dcs4qTM1yBU2Cj4rTJITC9s8QojoaDm0JWd0v29e0fAXPhI8FlEGg1JWGupy dRM36wa7qIxRdip4+CkWpXOPoqKSudhjTQUD+JD3YDLl91SGLXYUwZZ8v673deygGlYnJfPdwPM MzD9JrPi5LaEX7ebmxgevpOMBvDdCDufMOBHHjPz0gM5qGMpIEbnvg6dwZI/Vnx8AAitoxDlPle P+I8x+pabwrzOHQ== X-Developer-Key: i=Anna.Schumaker@Netapp.com; a=openpgp; fpr=9D9E4C413A51EDC2D4ECA129D7CB54BFB0A540EB Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker Move them out of the encode_*() section and into the decode_*() section where it belongs. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 326 +++++++++++++++++++++++++++--------------------------- 1 file changed, 162 insertions(+), 164 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index dfac3f62c7ed..09e735bcee09 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -464,20 +464,6 @@ static void encode_setxattr(struct xdr_stream *xdr, xdr_write_pages(xdr, arg->xattr_pages, 0, arg->xattr_len); } -static int decode_setxattr(struct xdr_stream *xdr, - struct nfs4_change_info *cinfo) -{ - int status; - - status = decode_op_hdr(xdr, OP_SETXATTR); - if (status) - goto out; - status = decode_change_info(xdr, cinfo); -out: - return status; -} - - static void encode_getxattr(struct xdr_stream *xdr, const char *name, struct compound_hdr *hdr) { @@ -485,43 +471,6 @@ static void encode_getxattr(struct xdr_stream *xdr, const char *name, encode_string(xdr, strlen(name), name); } -static int decode_getxattr(struct xdr_stream *xdr, - struct nfs42_getxattrres *res, - struct rpc_rqst *req) -{ - int status; - __be32 *p; - u32 len, rdlen; - - status = decode_op_hdr(xdr, OP_GETXATTR); - if (status) - return status; - - p = xdr_inline_decode(xdr, 4); - if (unlikely(!p)) - return -EIO; - - len = be32_to_cpup(p); - - /* - * Only check against the page length here. The actual - * requested length may be smaller, but that is only - * checked against after possibly caching a valid reply. - */ - if (len > req->rq_rcv_buf.page_len) - return -ERANGE; - - res->xattr_len = len; - - if (len > 0) { - rdlen = xdr_read_pages(xdr, len); - if (rdlen < len) - return -EIO; - } - - return 0; -} - static void encode_removexattr(struct xdr_stream *xdr, const char *name, struct compound_hdr *hdr) { @@ -529,21 +478,6 @@ static void encode_removexattr(struct xdr_stream *xdr, const char *name, encode_string(xdr, strlen(name), name); } - -static int decode_removexattr(struct xdr_stream *xdr, - struct nfs4_change_info *cinfo) -{ - int status; - - status = decode_op_hdr(xdr, OP_REMOVEXATTR); - if (status) - goto out; - - status = decode_change_info(xdr, cinfo); -out: - return status; -} - static void encode_listxattrs(struct xdr_stream *xdr, const struct nfs42_listxattrsargs *arg, struct compound_hdr *hdr) @@ -565,104 +499,6 @@ static void encode_listxattrs(struct xdr_stream *xdr, *p = cpu_to_be32(arg->count + 8 + 4); } -static int decode_listxattrs(struct xdr_stream *xdr, - struct nfs42_listxattrsres *res) -{ - int status; - __be32 *p; - u32 count, len, ulen; - size_t left, copied; - char *buf; - - status = decode_op_hdr(xdr, OP_LISTXATTRS); - if (status) { - /* - * Special case: for LISTXATTRS, NFS4ERR_TOOSMALL - * should be translated to ERANGE. - */ - if (status == -ETOOSMALL) - status = -ERANGE; - /* - * Special case: for LISTXATTRS, NFS4ERR_NOXATTR - * should be translated to success with zero-length reply. - */ - if (status == -ENODATA) { - res->eof = true; - status = 0; - } - goto out; - } - - p = xdr_inline_decode(xdr, 8); - if (unlikely(!p)) - return -EIO; - - xdr_decode_hyper(p, &res->cookie); - - p = xdr_inline_decode(xdr, 4); - if (unlikely(!p)) - return -EIO; - - left = res->xattr_len; - buf = res->xattr_buf; - - count = be32_to_cpup(p); - copied = 0; - - /* - * We have asked for enough room to encode the maximum number - * of possible attribute names, so everything should fit. - * - * But, don't rely on that assumption. Just decode entries - * until they don't fit anymore, just in case the server did - * something odd. - */ - while (count--) { - p = xdr_inline_decode(xdr, 4); - if (unlikely(!p)) - return -EIO; - - len = be32_to_cpup(p); - if (len > (XATTR_NAME_MAX - XATTR_USER_PREFIX_LEN)) { - status = -ERANGE; - goto out; - } - - p = xdr_inline_decode(xdr, len); - if (unlikely(!p)) - return -EIO; - - ulen = len + XATTR_USER_PREFIX_LEN + 1; - if (buf) { - if (ulen > left) { - status = -ERANGE; - goto out; - } - - memcpy(buf, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); - memcpy(buf + XATTR_USER_PREFIX_LEN, p, len); - - buf[ulen - 1] = 0; - buf += ulen; - left -= ulen; - } - copied += ulen; - } - - p = xdr_inline_decode(xdr, 4); - if (unlikely(!p)) - return -EIO; - - res->eof = be32_to_cpup(p); - res->copied = copied; - -out: - if (status == -ERANGE && res->xattr_len == XATTR_LIST_MAX) - status = -E2BIG; - - return status; -} - /* * Encode ALLOCATE request */ @@ -1192,6 +1028,168 @@ static int decode_layouterror(struct xdr_stream *xdr) return decode_op_hdr(xdr, OP_LAYOUTERROR); } +static int decode_setxattr(struct xdr_stream *xdr, + struct nfs4_change_info *cinfo) +{ + int status; + + status = decode_op_hdr(xdr, OP_SETXATTR); + if (status) + goto out; + status = decode_change_info(xdr, cinfo); +out: + return status; +} + +static int decode_getxattr(struct xdr_stream *xdr, + struct nfs42_getxattrres *res, + struct rpc_rqst *req) +{ + int status; + __be32 *p; + u32 len, rdlen; + + status = decode_op_hdr(xdr, OP_GETXATTR); + if (status) + return status; + + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + + len = be32_to_cpup(p); + + /* + * Only check against the page length here. The actual + * requested length may be smaller, but that is only + * checked against after possibly caching a valid reply. + */ + if (len > req->rq_rcv_buf.page_len) + return -ERANGE; + + res->xattr_len = len; + + if (len > 0) { + rdlen = xdr_read_pages(xdr, len); + if (rdlen < len) + return -EIO; + } + + return 0; +} + +static int decode_removexattr(struct xdr_stream *xdr, + struct nfs4_change_info *cinfo) +{ + int status; + + status = decode_op_hdr(xdr, OP_REMOVEXATTR); + if (status) + goto out; + + status = decode_change_info(xdr, cinfo); +out: + return status; +} + +static int decode_listxattrs(struct xdr_stream *xdr, + struct nfs42_listxattrsres *res) +{ + int status; + __be32 *p; + u32 count, len, ulen; + size_t left, copied; + char *buf; + + status = decode_op_hdr(xdr, OP_LISTXATTRS); + if (status) { + /* + * Special case: for LISTXATTRS, NFS4ERR_TOOSMALL + * should be translated to ERANGE. + */ + if (status == -ETOOSMALL) + status = -ERANGE; + /* + * Special case: for LISTXATTRS, NFS4ERR_NOXATTR + * should be translated to success with zero-length reply. + */ + if (status == -ENODATA) { + res->eof = true; + status = 0; + } + goto out; + } + + p = xdr_inline_decode(xdr, 8); + if (unlikely(!p)) + return -EIO; + + xdr_decode_hyper(p, &res->cookie); + + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + + left = res->xattr_len; + buf = res->xattr_buf; + + count = be32_to_cpup(p); + copied = 0; + + /* + * We have asked for enough room to encode the maximum number + * of possible attribute names, so everything should fit. + * + * But, don't rely on that assumption. Just decode entries + * until they don't fit anymore, just in case the server did + * something odd. + */ + while (count--) { + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + + len = be32_to_cpup(p); + if (len > (XATTR_NAME_MAX - XATTR_USER_PREFIX_LEN)) { + status = -ERANGE; + goto out; + } + + p = xdr_inline_decode(xdr, len); + if (unlikely(!p)) + return -EIO; + + ulen = len + XATTR_USER_PREFIX_LEN + 1; + if (buf) { + if (ulen > left) { + status = -ERANGE; + goto out; + } + + memcpy(buf, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); + memcpy(buf + XATTR_USER_PREFIX_LEN, p, len); + + buf[ulen - 1] = 0; + buf += ulen; + left -= ulen; + } + copied += ulen; + } + + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + + res->eof = be32_to_cpup(p); + res->copied = copied; + +out: + if (status == -ERANGE && res->xattr_len == XATTR_LIST_MAX) + status = -E2BIG; + + return status; +} + /* * Decode ALLOCATE request */ From patchwork Thu May 4 20:47:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13231777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C535C7EE22 for ; Thu, 4 May 2023 20:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230056AbjEDUtI (ORCPT ); Thu, 4 May 2023 16:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbjEDUsj (ORCPT ); Thu, 4 May 2023 16:48:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 371668F for ; Thu, 4 May 2023 13:48:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 14B91639F6 for ; Thu, 4 May 2023 20:47:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EA26C433D2; Thu, 4 May 2023 20:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683233235; bh=oBYSQTE9cYZca3/Nl7LnNd72cGaq0A/IjR/ySwOHW9k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=reMN6/W3vJC4gx0Yc3+kesNSbpOQ+EzXTG3uOw6Se1WbT8mc9YoTlFU6cOazbj4u/ VOk66Py4yU5VNHBoqJ25QNavzgTpPBtZF7ca7qtfwSEXBR4C0irLic0pumIxF9Tuq6 1p7+pJwutFBQMgXRhBIoLH36YSSHaEftUzUN3nCIfXqcyynoQ6r4fVTqc+OSkoNVXU i0qDhPtkP4O6dAHtll1NGaBRk9Xf+C0K48cVlnGuLy68MRT/GyA+uqA8mbjAW7itfi F+5EdrPdY8Al+XHhR4QYnQHVyBoxum46hdlm9xq2NAjEckIleL0El9Qv0Qa0fsMR0y pMgFfxFj9F4BA== From: Anna Schumaker Date: Thu, 04 May 2023 16:47:13 -0400 Subject: [PATCH 3/6] NFSv4.2: Clean up: Move nfs4_xdr_enc_*xattr() functions MIME-Version: 1.0 Message-Id: <20230504-xattr-ctime-v1-3-ac3fc5a00942@Netapp.com> References: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> In-Reply-To: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, Anna Schumaker X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6084; i=Anna.Schumaker@Netapp.com; h=from:subject:message-id; bh=LejxEI+D7/LUOB1eLc8MKxgM86cKmVm1M3SpRTEUWaA=; b=owEBbQKS/ZANAwAIAdfLVL+wpUDrAcsmYgBkVBnRvapt9w1IKOt9RXmZsiL6QjJF+98Atv9MR Y/rFDtbXkiJAjMEAAEIAB0WIQSdnkxBOlHtwtTsoSnXy1S/sKVA6wUCZFQZ0QAKCRDXy1S/sKVA 63/PEAD5fyDiDogKtFAhx8osvBwvWgvHme0UT/o60H/HJIcOMIElJUL64sjfV0x6zTqiv2VWYWm A4sZvcz5ndZuqkO/LWFAWnbgEWVVYXghX+JXGzsmm/MJwDjmdVyIgwpP+FbKpciL5BgXw4otRlE fKvdK2CAheWZuOk/6N4cZE0Bx5UnoJKUV0lXfUx3eSF1+pwoFKRVcLm66XBURRVy7EBuQHB1d4n 5o+SnFTHUSCzAp7u59oRpFjdQS0zcciZuKhw2AvmoL9umejLEaxdMLEsJ1SsyUKXsvVV0C2sHHo BOKG/5ZYZXoP00/taGBDvhaewx49N0wrqddHy1CxKR2T0NIG0OCSW3qUvBEpK1hqoglCzqFx6wx LpbGaDFXfybaGDsS4zyfJSyELt0YzyRoAhvLcoliCyEQtgN/m8zjs5j/62oZnEUaxdWhVofR9LJ YSxD+dhLb6bIhZXMxMILtAnEeAd7mvM3XUvj6puz47s5/6BY5Sbx6NiWcbSqgEUPqgYMKREg7N6 1fTg28+Bau+aA287W1+rYFw6dJ+chakNkf8p0bTy/QJeo8kZ5gg55rS2ZIY0NXrCaJgBqR4vden wt26hWtS0gDzEpRVFqQM08KEnFPj4C5AAnuVLWB0DTrbGkTD4n4oRSA5y3eguU7GYR6+yXth3+l szos6kR/P4rTaYQ== X-Developer-Key: i=Anna.Schumaker@Netapp.com; a=openpgp; fpr=9D9E4C413A51EDC2D4ECA129D7CB54BFB0A540EB Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker They should be in the nfs4_xdr_enc_*() section, and not at the bottom of the file. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 154 +++++++++++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 71 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 09e735bcee09..51560c7d468d 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -707,6 +707,89 @@ static void nfs4_xdr_enc_layouterror(struct rpc_rqst *req, encode_nops(&hdr); } +/* + * Encode SETXATTR request + */ +static void nfs4_xdr_enc_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr, + const void *data) +{ + const struct nfs42_setxattrargs *args = data; + struct compound_hdr hdr = { + .minorversion = nfs4_xdr_minorversion(&args->seq_args), + }; + + encode_compound_hdr(xdr, req, &hdr); + encode_sequence(xdr, &args->seq_args, &hdr); + encode_putfh(xdr, args->fh, &hdr); + encode_setxattr(xdr, args, &hdr); + encode_nops(&hdr); +} + +/* + * Encode GETXATTR request + */ +static void nfs4_xdr_enc_getxattr(struct rpc_rqst *req, struct xdr_stream *xdr, + const void *data) +{ + const struct nfs42_getxattrargs *args = data; + struct compound_hdr hdr = { + .minorversion = nfs4_xdr_minorversion(&args->seq_args), + }; + uint32_t replen; + + encode_compound_hdr(xdr, req, &hdr); + encode_sequence(xdr, &args->seq_args, &hdr); + encode_putfh(xdr, args->fh, &hdr); + replen = hdr.replen + op_decode_hdr_maxsz + 1; + encode_getxattr(xdr, args->xattr_name, &hdr); + + rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->xattr_len, + replen); + + encode_nops(&hdr); +} + +/* + * Encode LISTXATTR request + */ +static void nfs4_xdr_enc_listxattrs(struct rpc_rqst *req, + struct xdr_stream *xdr, const void *data) +{ + const struct nfs42_listxattrsargs *args = data; + struct compound_hdr hdr = { + .minorversion = nfs4_xdr_minorversion(&args->seq_args), + }; + uint32_t replen; + + encode_compound_hdr(xdr, req, &hdr); + encode_sequence(xdr, &args->seq_args, &hdr); + encode_putfh(xdr, args->fh, &hdr); + replen = hdr.replen + op_decode_hdr_maxsz + 2 + 1; + encode_listxattrs(xdr, args, &hdr); + + rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->count, replen); + + encode_nops(&hdr); +} + +/* + * Encode REMOVEXATTR request + */ +static void nfs4_xdr_enc_removexattr(struct rpc_rqst *req, + struct xdr_stream *xdr, const void *data) +{ + const struct nfs42_removexattrargs *args = data; + struct compound_hdr hdr = { + .minorversion = nfs4_xdr_minorversion(&args->seq_args), + }; + + encode_compound_hdr(xdr, req, &hdr); + encode_sequence(xdr, &args->seq_args, &hdr); + encode_putfh(xdr, args->fh, &hdr); + encode_removexattr(xdr, args->xattr_name, &hdr); + encode_nops(&hdr); +} + static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) { return decode_op_hdr(xdr, OP_ALLOCATE); @@ -1480,21 +1563,6 @@ static int nfs4_xdr_dec_layouterror(struct rpc_rqst *rqstp, } #ifdef CONFIG_NFS_V4_2 -static void nfs4_xdr_enc_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr, - const void *data) -{ - const struct nfs42_setxattrargs *args = data; - struct compound_hdr hdr = { - .minorversion = nfs4_xdr_minorversion(&args->seq_args), - }; - - encode_compound_hdr(xdr, req, &hdr); - encode_sequence(xdr, &args->seq_args, &hdr); - encode_putfh(xdr, args->fh, &hdr); - encode_setxattr(xdr, args, &hdr); - encode_nops(&hdr); -} - static int nfs4_xdr_dec_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr, void *data) { @@ -1517,27 +1585,6 @@ static int nfs4_xdr_dec_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr, return status; } -static void nfs4_xdr_enc_getxattr(struct rpc_rqst *req, struct xdr_stream *xdr, - const void *data) -{ - const struct nfs42_getxattrargs *args = data; - struct compound_hdr hdr = { - .minorversion = nfs4_xdr_minorversion(&args->seq_args), - }; - uint32_t replen; - - encode_compound_hdr(xdr, req, &hdr); - encode_sequence(xdr, &args->seq_args, &hdr); - encode_putfh(xdr, args->fh, &hdr); - replen = hdr.replen + op_decode_hdr_maxsz + 1; - encode_getxattr(xdr, args->xattr_name, &hdr); - - rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->xattr_len, - replen); - - encode_nops(&hdr); -} - static int nfs4_xdr_dec_getxattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, void *data) { @@ -1559,26 +1606,6 @@ static int nfs4_xdr_dec_getxattr(struct rpc_rqst *rqstp, return status; } -static void nfs4_xdr_enc_listxattrs(struct rpc_rqst *req, - struct xdr_stream *xdr, const void *data) -{ - const struct nfs42_listxattrsargs *args = data; - struct compound_hdr hdr = { - .minorversion = nfs4_xdr_minorversion(&args->seq_args), - }; - uint32_t replen; - - encode_compound_hdr(xdr, req, &hdr); - encode_sequence(xdr, &args->seq_args, &hdr); - encode_putfh(xdr, args->fh, &hdr); - replen = hdr.replen + op_decode_hdr_maxsz + 2 + 1; - encode_listxattrs(xdr, args, &hdr); - - rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->count, replen); - - encode_nops(&hdr); -} - static int nfs4_xdr_dec_listxattrs(struct rpc_rqst *rqstp, struct xdr_stream *xdr, void *data) { @@ -1602,21 +1629,6 @@ static int nfs4_xdr_dec_listxattrs(struct rpc_rqst *rqstp, return status; } -static void nfs4_xdr_enc_removexattr(struct rpc_rqst *req, - struct xdr_stream *xdr, const void *data) -{ - const struct nfs42_removexattrargs *args = data; - struct compound_hdr hdr = { - .minorversion = nfs4_xdr_minorversion(&args->seq_args), - }; - - encode_compound_hdr(xdr, req, &hdr); - encode_sequence(xdr, &args->seq_args, &hdr); - encode_putfh(xdr, args->fh, &hdr); - encode_removexattr(xdr, args->xattr_name, &hdr); - encode_nops(&hdr); -} - static int nfs4_xdr_dec_removexattr(struct rpc_rqst *req, struct xdr_stream *xdr, void *data) { From patchwork Thu May 4 20:47:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13231779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA39CC7EE21 for ; Thu, 4 May 2023 20:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbjEDUtJ (ORCPT ); Thu, 4 May 2023 16:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbjEDUsj (ORCPT ); Thu, 4 May 2023 16:48:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96B2A9EEE for ; Thu, 4 May 2023 13:48:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 355C3639FA for ; Thu, 4 May 2023 20:47:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B097EC4339B; Thu, 4 May 2023 20:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683233236; bh=rGnQAPW0hli7YcR9MsR+dC1QlJ2Z2SQwhGPkYv86Ef4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cDlMs4VBPhWf2n81c7BLRDZOUFS0n+lMjROZtsO2fpa5Se5HMjUndlgno5j0uLCJ7 Y8v+LOPciJFGQl9RqkEjycvv1eDf1LxaUdieUcEnYOPp0xlkr6OEs3QdLfENjOnq1V Gn3BLHR/Uitz24zU/QTZmAqFV2ZU0iCgrxctN3UnE+3+oTpYiTSb1Ja5mD0yhZmfa5 7HxIgmHazdkkXHZFUX+MVC1FimEIFhavyOIYlrrsdR6d8OrCLqRqpvrXqZ7XhKIcEi LDwE5M9PJmT6ncHEQRdqJY54MQA37kA/R2wkq5l0f5hKZPO6SyYSpqkmp9XpYjMxHO /TNodq/RYs/pw== From: Anna Schumaker Date: Thu, 04 May 2023 16:47:14 -0400 Subject: [PATCH 4/6] NFSv4.2: Clean up nfs4_xdr_dec_*xattr() functions MIME-Version: 1.0 Message-Id: <20230504-xattr-ctime-v1-4-ac3fc5a00942@Netapp.com> References: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> In-Reply-To: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, Anna Schumaker X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1771; i=Anna.Schumaker@Netapp.com; h=from:subject:message-id; bh=tg/4V4l4h13B2lvBoryqNit4MB6JNorpHtTPJFUz8q8=; b=owEBbQKS/ZANAwAIAdfLVL+wpUDrAcsmYgBkVBnRLbmwD8Kfp9VYg0TkbluV7cdi0Js2t3DXf zsCE2vXxBKJAjMEAAEIAB0WIQSdnkxBOlHtwtTsoSnXy1S/sKVA6wUCZFQZ0QAKCRDXy1S/sKVA 6/XsD/4zLFIjGupT4jogMmnSt4jzZVf0n3NM01pKwDkvmFiEjo8wptwdyKDdfAzd0PC6alIlNru I9tBxk5iYoZzOKBVtNYo2JJ7ekaeNltLMaEgnxwOohVC2XWJvmXE74aAJGTrcxBZVdNbWHQkzfq U2PBDo22c6Aq33438Dzoy94fD50Kj85nGtJWlH9wobip9i+VVAc77pmGCkYWt45RZim+fnPgw4m G9sRPqr5VkBJYfhdm9ibaOBSEALhnhvTStPFl8GyDls8AFts8TMRYEV0QNWlY19H74MIVLowbJ/ S/jnyAJluZaaHmXhHPyI5Smfyc39HqpBI1sQ9wq00y17nbdRbfOQjpsEo3ccX/mDW7dQ4cB/0BO m6uBJTmoCO7oPIdkEXoPqSRCJHW/NA46j2DPYWFHTfi27keJr81NdA+deWm/GJ06YGdVSLLtwvL 2kwONfTKOBj0L/HRDa0ggVirhdhbAHnCZMJEB4zyZwGiMokOPaojMnC4NLve4z0MToA7uE45jac N6kZfgW1TY1WjvlMQxJy62YJ5IyFyjb+h24LaLvUFk4/0xRvJDIh6ERYLvc6kJ+ptZ+AkkVaGEW l498hNypk/cVosg5r78oz4g8lIc994t3cNNapz1LjW9JqKaOcbSHDah3FsPr/mXV8dyH14G3TGl dd10PN2XIg9QSPA== X-Developer-Key: i=Anna.Schumaker@Netapp.com; a=openpgp; fpr=9D9E4C413A51EDC2D4ECA129D7CB54BFB0A540EB Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker I add commends above each function to match the style of the other nfs4_xdr_dec_*() functions. I also remove the unnecessary #ifdef CONFIG_NFS_V4_2 that was added around this code, since we are already in a v4.2-only file. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 51560c7d468d..1d74135715c5 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -1562,7 +1562,9 @@ static int nfs4_xdr_dec_layouterror(struct rpc_rqst *rqstp, return status; } -#ifdef CONFIG_NFS_V4_2 +/* + * Decode SETXATTR request + */ static int nfs4_xdr_dec_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr, void *data) { @@ -1585,6 +1587,9 @@ static int nfs4_xdr_dec_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr, return status; } +/* + * Decode GETXATTR request + */ static int nfs4_xdr_dec_getxattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, void *data) { @@ -1606,6 +1611,9 @@ static int nfs4_xdr_dec_getxattr(struct rpc_rqst *rqstp, return status; } +/* + * Decode LISTXATTR request + */ static int nfs4_xdr_dec_listxattrs(struct rpc_rqst *rqstp, struct xdr_stream *xdr, void *data) { @@ -1629,6 +1637,9 @@ static int nfs4_xdr_dec_listxattrs(struct rpc_rqst *rqstp, return status; } +/* + * Decode REMOVEXATTR request + */ static int nfs4_xdr_dec_removexattr(struct rpc_rqst *req, struct xdr_stream *xdr, void *data) { @@ -1650,5 +1661,4 @@ static int nfs4_xdr_dec_removexattr(struct rpc_rqst *req, out: return status; } -#endif #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */ From patchwork Thu May 4 20:47:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13231781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0112DC77B73 for ; Thu, 4 May 2023 20:50:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229758AbjEDUuM (ORCPT ); Thu, 4 May 2023 16:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231316AbjEDUuB (ORCPT ); Thu, 4 May 2023 16:50:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF8FC11D80 for ; Thu, 4 May 2023 13:49:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 25E3D639C5 for ; Thu, 4 May 2023 20:47:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F119C433D2; Thu, 4 May 2023 20:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683233236; bh=myqIA0BbvrYLcP6QStGiaNN5xaenVGZ7FwTcgCHdxh4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FV3LrDJilAvDIxnPHKpm00WaRUVVDsyNhfA9h+uFKPXiSpV46e77sJYC/u2YlY5Q/ RH7b0NMWOeN2xI1eIHCT5Q2DHl9AG8pARC4vmLvFBZdT99q0B9AzTdEdbdSWygCGPf T1jr+S1wpD3f8WJwxZ9QxOcniHQw82oHT9SjRygcL0n2PJe+9mtrePKWxFdgk62nEo KXIkBrt4+ZrZhKgw/WP/8+1ZQEmKWDC/kZzLphIVBV1k6PGsFHfidLKLdOvFgE2YHq frrZiMwdZlAbDxCAnSZHjmETQ6f9M7ILFCdyKJPcbHBpIQEwifQqNhj5drzxQb0yFf Kh9bh0WvvLN5A== From: Anna Schumaker Date: Thu, 04 May 2023 16:47:15 -0400 Subject: [PATCH 5/6] NFSv4.2: Clean up xattr size macros MIME-Version: 1.0 Message-Id: <20230504-xattr-ctime-v1-5-ac3fc5a00942@Netapp.com> References: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> In-Reply-To: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, Anna Schumaker X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5187; i=Anna.Schumaker@Netapp.com; h=from:subject:message-id; bh=x0I57N3cKS5WzOUXTzceP0S6UCKe81kc1ZVKdNqosZ0=; b=owEBbQKS/ZANAwAIAdfLVL+wpUDrAcsmYgBkVBnRntTWGJnIsaQRFbAwKH48ppWJ/pi7Dy9wt 3U0YbdJ4vuJAjMEAAEIAB0WIQSdnkxBOlHtwtTsoSnXy1S/sKVA6wUCZFQZ0QAKCRDXy1S/sKVA 68PTEADc/qTTfkOpOeIP1Ry51B/1+8V74EyRQHMItTW5awpoRorz0AIAXgawrmagH0yMM5kvIQh yr41Rmtsm9iEyyz372GKEcQlEi7gZ+69ED8LN2QCix90i2iEFoN/qeE6glDUfFr1Jpf+TW/eJJT SPqRVeoKQdSCg7eMetaRiQmFtj0UexS0kUbdURxDTdu7pMkYeiaSzXvy8vtpt3Et0/7sTV4Ffji Nd/pOwkgF0BhbB6qr+icSNIhRYcTBZdFEhwt4Tsr9ISZwdqFxowOMCQS3LHBR5zCtD60UJmmyuf DMSsco1PJupw9Y+ZrMu9yniUrI/4/gTxLLPBJ5/lT11WGbzMKnf1mvUq+nSph/3t62Jc/zWzkWx rQMInNTLHB7hCBhupb7ECFpfVx9sgAeUdCZDeqdq3c7OCF3t6Jw/7xf2/Pwt5D5CLs3Tn0UMooW QFiuSheE6Gg3oA/gApHy5fIE6Q8oqQIUoZ81/WFoHvMAqbYLsnxWBr4KPuLKV8wYWdrqbyozC7Y CxdSzWUVgqZCFcFHmt3kp/jgWqz69Wx56BCEauoHyETtNJMzYYSQuyC/3E9kKKioVF53tLX/FmG 8JJ/nJtMLZ24gN2Hud0GNwq/zKzm9Ta2Zfeg+qcD4ywwOrPjWNLiiUejQsfeEwdjbgilbqPWALH J9BJniHTl7iFqzw== X-Developer-Key: i=Anna.Schumaker@Netapp.com; a=openpgp; fpr=9D9E4C413A51EDC2D4ECA129D7CB54BFB0A540EB Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker Fold them into the other NFS v4.2 operations in the right spots and adjust spacing to keep the same style. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 96 +++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 1d74135715c5..215b8700e504 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -7,6 +7,9 @@ #include "nfs42.h" +/* Not limited by NFS itself, limited by the generic xattr code */ +#define nfs4_xattr_name_maxsz XDR_QUADLEN(XATTR_NAME_MAX) + #define encode_fallocate_maxsz (encode_stateid_maxsz + \ 2 /* offset */ + \ 2 /* length */) @@ -89,6 +92,18 @@ 2 /* dst offset */ + \ 2 /* count */) #define decode_clone_maxsz (op_decode_hdr_maxsz) +#define encode_getxattr_maxsz (op_encode_hdr_maxsz + 1 + \ + nfs4_xattr_name_maxsz) +#define decode_getxattr_maxsz (op_decode_hdr_maxsz + 1 + pagepad_maxsz) +#define encode_setxattr_maxsz (op_encode_hdr_maxsz + \ + 1 + nfs4_xattr_name_maxsz + 1) +#define decode_setxattr_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) +#define encode_listxattrs_maxsz (op_encode_hdr_maxsz + 2 + 1) +#define decode_listxattrs_maxsz (op_decode_hdr_maxsz + 2 + 1 + 1 + 1) +#define encode_removexattr_maxsz (op_encode_hdr_maxsz + 1 + \ + nfs4_xattr_name_maxsz) +#define decode_removexattr_maxsz (op_decode_hdr_maxsz + \ + decode_change_info_maxsz) #define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ @@ -186,55 +201,38 @@ decode_putfh_maxsz + \ decode_clone_maxsz + \ decode_getattr_maxsz) - -/* Not limited by NFS itself, limited by the generic xattr code */ -#define nfs4_xattr_name_maxsz XDR_QUADLEN(XATTR_NAME_MAX) - -#define encode_getxattr_maxsz (op_encode_hdr_maxsz + 1 + \ - nfs4_xattr_name_maxsz) -#define decode_getxattr_maxsz (op_decode_hdr_maxsz + 1 + pagepad_maxsz) -#define encode_setxattr_maxsz (op_encode_hdr_maxsz + \ - 1 + nfs4_xattr_name_maxsz + 1) -#define decode_setxattr_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz) -#define encode_listxattrs_maxsz (op_encode_hdr_maxsz + 2 + 1) -#define decode_listxattrs_maxsz (op_decode_hdr_maxsz + 2 + 1 + 1 + 1) -#define encode_removexattr_maxsz (op_encode_hdr_maxsz + 1 + \ - nfs4_xattr_name_maxsz) -#define decode_removexattr_maxsz (op_decode_hdr_maxsz + \ - decode_change_info_maxsz) - -#define NFS4_enc_getxattr_sz (compound_encode_hdr_maxsz + \ - encode_sequence_maxsz + \ - encode_putfh_maxsz + \ - encode_getxattr_maxsz) -#define NFS4_dec_getxattr_sz (compound_decode_hdr_maxsz + \ - decode_sequence_maxsz + \ - decode_putfh_maxsz + \ - decode_getxattr_maxsz) -#define NFS4_enc_setxattr_sz (compound_encode_hdr_maxsz + \ - encode_sequence_maxsz + \ - encode_putfh_maxsz + \ - encode_setxattr_maxsz) -#define NFS4_dec_setxattr_sz (compound_decode_hdr_maxsz + \ - decode_sequence_maxsz + \ - decode_putfh_maxsz + \ - decode_setxattr_maxsz) -#define NFS4_enc_listxattrs_sz (compound_encode_hdr_maxsz + \ - encode_sequence_maxsz + \ - encode_putfh_maxsz + \ - encode_listxattrs_maxsz) -#define NFS4_dec_listxattrs_sz (compound_decode_hdr_maxsz + \ - decode_sequence_maxsz + \ - decode_putfh_maxsz + \ - decode_listxattrs_maxsz) -#define NFS4_enc_removexattr_sz (compound_encode_hdr_maxsz + \ - encode_sequence_maxsz + \ - encode_putfh_maxsz + \ - encode_removexattr_maxsz) -#define NFS4_dec_removexattr_sz (compound_decode_hdr_maxsz + \ - decode_sequence_maxsz + \ - decode_putfh_maxsz + \ - decode_removexattr_maxsz) +#define NFS4_enc_getxattr_sz (compound_encode_hdr_maxsz + \ + encode_sequence_maxsz + \ + encode_putfh_maxsz + \ + encode_getxattr_maxsz) +#define NFS4_dec_getxattr_sz (compound_decode_hdr_maxsz + \ + decode_sequence_maxsz + \ + decode_putfh_maxsz + \ + decode_getxattr_maxsz) +#define NFS4_enc_setxattr_sz (compound_encode_hdr_maxsz + \ + encode_sequence_maxsz + \ + encode_putfh_maxsz + \ + encode_setxattr_maxsz) +#define NFS4_dec_setxattr_sz (compound_decode_hdr_maxsz + \ + decode_sequence_maxsz + \ + decode_putfh_maxsz + \ + decode_setxattr_maxsz) +#define NFS4_enc_listxattrs_sz (compound_encode_hdr_maxsz + \ + encode_sequence_maxsz + \ + encode_putfh_maxsz + \ + encode_listxattrs_maxsz) +#define NFS4_dec_listxattrs_sz (compound_decode_hdr_maxsz + \ + decode_sequence_maxsz + \ + decode_putfh_maxsz + \ + decode_listxattrs_maxsz) +#define NFS4_enc_removexattr_sz (compound_encode_hdr_maxsz + \ + encode_sequence_maxsz + \ + encode_putfh_maxsz + \ + encode_removexattr_maxsz) +#define NFS4_dec_removexattr_sz (compound_decode_hdr_maxsz + \ + decode_sequence_maxsz + \ + decode_putfh_maxsz + \ + decode_removexattr_maxsz) /* * These values specify the maximum amount of data that is not From patchwork Thu May 4 20:47:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna Schumaker X-Patchwork-Id: 13231780 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 764E9C7EE22 for ; Thu, 4 May 2023 20:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229459AbjEDUuL (ORCPT ); Thu, 4 May 2023 16:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbjEDUtu (ORCPT ); Thu, 4 May 2023 16:49:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B2A8423C for ; Thu, 4 May 2023 13:49:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AD01E639FB for ; Thu, 4 May 2023 20:47:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1E75C433EF; Thu, 4 May 2023 20:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683233237; bh=BOg+RXnaM1HWtT4oc7eRXJdklZqYq0mCXJAgXZOH+Zw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Pa67KEfuaPBd5Mburdu6YtQ+VUO771Rp+upQ7ahYp8FWhD5+BVmuer35lLR+dEU/5 KpLQiDWF0NoxVsZVJ+ObM098kWqqIVromsXW6WTpWg3g1jVMFvYaa1lJzIEhY9JmVQ 0tEZRKUy0xPik5VaQ9I4v0P2VJRG5teRJJb0NDy6AeX4QBt6mgLmLmPMhKCJ5nDde6 qj3yqHuLeMM4Lbq5xaaNjDOxZYtuLoopgvqYSC74eredCfBzS80xvDefg2gjkkYLWS RaJZFuW2Beck79AaXDwH2NPI4N51Lqp6SpUHhmxBvnQbNFqFZEWZ1ubDm7/VKaFb+W Y8SeKwyzGWpBQ== From: Anna Schumaker Date: Thu, 04 May 2023 16:47:16 -0400 Subject: [PATCH 6/6] NFSv4.2: SETXATTR should update ctime MIME-Version: 1.0 Message-Id: <20230504-xattr-ctime-v1-6-ac3fc5a00942@Netapp.com> References: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> In-Reply-To: <20230504-xattr-ctime-v1-0-ac3fc5a00942@Netapp.com> To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, Anna Schumaker X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4203; i=Anna.Schumaker@Netapp.com; h=from:subject:message-id; bh=hDPbfC3g0DZCj0YbYegv/OqwOUIzuY7OyvJ7CaEibFk=; b=owEBbQKS/ZANAwAIAdfLVL+wpUDrAcsmYgBkVBnRafqQeexkOm6LSpuf/3gu1wQXmyznIQxk3 O38Wus0PzCJAjMEAAEIAB0WIQSdnkxBOlHtwtTsoSnXy1S/sKVA6wUCZFQZ0QAKCRDXy1S/sKVA 600ND/93sHXqgCB7IEA0yU+nR1ezoRcHCj0Wy8WFcDMr3LkSYg8t+Kbt+KJfr3jnh9EpB8nA8E3 ls6OBG9sRlIg38YmD4+WJtQ89j4IJsESuMQm7kN+3WA/62PBzgwa9TmDuFhe/KmFBm46BvxKwkR jlKdQi6DtbUNjPy0Q9PxCRijhLa1DzAPBzOGCdc2+wdG36ua3kyX94NonLp6yugr1wjIFlFNQgn a/2AxIiyJ2swBHVjMrmQbeclKMPNwMV5JKOV5uijFDjlbe7F23cFTTCMGBu671pVqiPzs7FdOeh /p3ZZ5f+AoMX8UJphrg/gyRINcamAMisdJuNWf9DdfDUprQ2weUlgiyLeLmdvtbw+Vc0FbYM0xc n8dXOJUxbeYMlD7XKyyf74+cReyzf+M2ys43UYmOqMJCETkzTS4Dv5bv6NMETLKDafQp6iA9nmD QmFZ3dRvXWuMQp2fNdF2jpGFLIJy+Kl/czom4l9l1pi0TMP8S6K2s/zLHtcIrTD3NAhiKP+aZ4/ VuDL8Plu3ZZiZVOHP14+u729bc3q9rHgyZMskwbK1kr45kgFyj2cLS1DYwyededABb4DZu48gSZ zZ+itE1MnDnU7hjMUCmepTMJAylVqfSQyxu473V+140TFDd/d0lLwvfdRwROdU1XGGpyQn9mAoY 8iVWD4AaxGiRLdg== X-Developer-Key: i=Anna.Schumaker@Netapp.com; a=openpgp; fpr=9D9E4C413A51EDC2D4ECA129D7CB54BFB0A540EB Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker Otherwise, `stat` will report a stale value to users. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42proc.c | 25 +++++++++++++++++++++---- fs/nfs/nfs42xdr.c | 11 ++++++++--- include/linux/nfs_xdr.h | 3 +++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 93e306bf4430..63802d195556 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -1190,15 +1190,19 @@ static int _nfs42_proc_setxattr(struct inode *inode, const char *name, const void *buf, size_t buflen, int flags) { struct nfs_server *server = NFS_SERVER(inode); + __u32 bitmask[NFS_BITMASK_SZ]; struct page *pages[NFS4XATTR_MAXPAGES]; struct nfs42_setxattrargs arg = { .fh = NFS_FH(inode), + .bitmask = bitmask, .xattr_pages = pages, .xattr_len = buflen, .xattr_name = name, .xattr_flags = flags, }; - struct nfs42_setxattrres res; + struct nfs42_setxattrres res = { + .server = server, + }; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETXATTR], .rpc_argp = &arg, @@ -1210,13 +1214,22 @@ static int _nfs42_proc_setxattr(struct inode *inode, const char *name, if (buflen > server->sxasize) return -ERANGE; + res.fattr = nfs_alloc_fattr(); + if (!res.fattr) + return -ENOMEM; + if (buflen > 0) { np = nfs4_buf_to_pages_noslab(buf, buflen, arg.xattr_pages); - if (np < 0) - return np; + if (np < 0) { + ret = np; + goto out; + } } else np = 0; + nfs4_bitmask_set(bitmask, server->cache_consistency_bitmask, + inode, NFS_INO_INVALID_CHANGE); + ret = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); trace_nfs4_setxattr(inode, name, ret); @@ -1224,9 +1237,13 @@ static int _nfs42_proc_setxattr(struct inode *inode, const char *name, for (; np > 0; np--) put_page(pages[np - 1]); - if (!ret) + if (!ret) { nfs4_update_changeattr(inode, &res.cinfo, timestamp, 0); + ret = nfs_post_op_update_inode(inode, res.fattr); + } +out: + kfree(res.fattr); return ret; } diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 215b8700e504..95234208dc9e 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -212,11 +212,13 @@ #define NFS4_enc_setxattr_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_putfh_maxsz + \ - encode_setxattr_maxsz) + encode_setxattr_maxsz + \ + encode_getattr_maxsz) #define NFS4_dec_setxattr_sz (compound_decode_hdr_maxsz + \ decode_sequence_maxsz + \ decode_putfh_maxsz + \ - decode_setxattr_maxsz) + decode_setxattr_maxsz + \ + decode_getattr_maxsz) #define NFS4_enc_listxattrs_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_putfh_maxsz + \ @@ -720,6 +722,7 @@ static void nfs4_xdr_enc_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr, encode_sequence(xdr, &args->seq_args, &hdr); encode_putfh(xdr, args->fh, &hdr); encode_setxattr(xdr, args, &hdr); + encode_getfattr(xdr, args->bitmask, &hdr); encode_nops(&hdr); } @@ -1579,8 +1582,10 @@ static int nfs4_xdr_dec_setxattr(struct rpc_rqst *req, struct xdr_stream *xdr, status = decode_putfh(xdr); if (status) goto out; - status = decode_setxattr(xdr, &res->cinfo); + if (status) + goto out; + status = decode_getfattr(xdr, res->fattr, res->server); out: return status; } diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 29a1b39794bf..12bbb5c63664 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1528,6 +1528,7 @@ struct nfs42_seek_res { struct nfs42_setxattrargs { struct nfs4_sequence_args seq_args; struct nfs_fh *fh; + const u32 *bitmask; const char *xattr_name; u32 xattr_flags; size_t xattr_len; @@ -1537,6 +1538,8 @@ struct nfs42_setxattrargs { struct nfs42_setxattrres { struct nfs4_sequence_res seq_res; struct nfs4_change_info cinfo; + struct nfs_fattr *fattr; + const struct nfs_server *server; }; struct nfs42_getxattrargs {