Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13042489rwd; Fri, 23 Jun 2023 14:51:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sh+Si0jx07RDvBp5MsvT0hfx+LbMSKs6fTaX+qhhSw5/nlfeafMMOUSz6X1ct8ENTEyg8 X-Received: by 2002:a05:6358:ce1d:b0:12b:dbed:e021 with SMTP id gt29-20020a056358ce1d00b0012bdbede021mr13482112rwb.31.1687557108902; Fri, 23 Jun 2023 14:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687557108; cv=none; d=google.com; s=arc-20160816; b=VZOX2YumjLq3FFC0Q5fgtyEtvoEOTDY6dN1edHXnXjK8Ivdok+4e+arMd/uMaMutiA L76vW49POEMtaLI+bniUQoNIgJjtUPkqlQQIF4KoBGCZE57bY5Aav24HxJKFlzpurjm2 MR3pms3OhfHwlZF1xPFkew1mvkzAXs4QhG9tu8kmAmorCWqFKFhjbEXBSnjDrRk8bN65 uEE0KXjqFBj6XPjmhpQ6IpAAep8sbmE6RefD38SkMzEO0RFdT1XqUmGdGYV5kEGspd4R h69LGNXQxAyP4uvVNjVImXvRLDnk7KYrYyQHvwiQrvm9In+MhxTZX0DFzmXd8767j5ES mPHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=q1NIdNsIKbeDPXey1b2qYyZNYwzj+VkA8763+OUZtnE=; fh=HENgXPXoNBZ6alqX+b79GKkA+JzG20P0DVWaDCH0zJ8=; b=G2097t49EXh+IucsCS97fI5ciMaJ/yHXMiIhYIb0PAzZigGyp8ExPuGX/fg/5c7gp8 cu/06knLVI287R0YN8vDqIiQTKie6LxKux14uA742Xn/Ib1Hci/myLJ2efdtk0aMjG0e ygEnGAsBYXhipRYpSA+0XE3m2/6+sCJJ6w6GK4s0VRiGAmFYJU3kCByAc6jz3Ym/WHhB vvuuOPAGXByijTLyERMCzdKkrSJuPADD4CdLUBwRSaZ9DKiyNfXBwYjZDamp6UfHJth3 V9vJN6ImDhMZbxoRNQtUJbw7pY6E4mKuQb8n1VI7vYh0MZATFhEGqE1thsyzwRlXsG7L ByFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jYst5Xp7; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 29-20020a63145d000000b0055337cf6342si315071pgu.332.2023.06.23.14.51.30; Fri, 23 Jun 2023 14:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jYst5Xp7; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231817AbjFWVsf (ORCPT + 99 others); Fri, 23 Jun 2023 17:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbjFWVsb (ORCPT ); Fri, 23 Jun 2023 17:48:31 -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 EA52B26BD; Fri, 23 Jun 2023 14:48:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5CA1960A38; Fri, 23 Jun 2023 21:48:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F706C433C8; Fri, 23 Jun 2023 21:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687556901; bh=YyV6B6bNatDDFo2tW2JAoKmXfyIqLGPJxf2ibpnit1s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jYst5Xp7ILlkRwqwQWL4jvYYvRxPM2aJb0macvvkZ4++vwx+tPHjr0dzZuUki8e2g zHP9VqmWZwUcjwZd6wNhKnuI7h1YmWes1WS3aQDTIePXtQPWfnXiRQXaPm9TPrQGpa 44KOsxybvdjFy6UTSOAdqz8X593r9hkZ3Inay+Ptm+mR6ZVqK5+y1hBA0XZYDV/5TK 3CH975FR3ieOzoR1/g3Hyp0Gs47ImHYoMARFc5aC65Qd1XSlt0IR2v+C6XJ6TECMst 5aNUlr5Nhz51r7ffB8+XukOtJlJjFoYpZXU8EF0UhR8KYKQuDHvNZw2Z6ZjuQSbDrI xAivVG3cX2taA== Date: Fri, 23 Jun 2023 17:48:19 -0400 From: Chuck Lever To: tavianator@tavianator.com Cc: linux-nfs@vger.kernel.org, Chuck Lever , Jeff Layton , Ondrej Valousek , linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs/nfsd: Fix creation time serialization order Message-ID: References: <4154eb6503988c2096f5d30af26d06863fb5d973.1687554467.git.tavianator@tavianator.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4154eb6503988c2096f5d30af26d06863fb5d973.1687554467.git.tavianator@tavianator.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Jun 23, 2023 at 05:09:06PM -0400, tavianator@tavianator.com wrote: > From: Tavian Barnes > > In nfsd4_encode_fattr(), TIME_CREATE was being written out after all > other times. However, they should be written out in an order that > matches the bit flags in bmval1, which in this case are > > #define FATTR4_WORD1_TIME_ACCESS (1UL << 15) > #define FATTR4_WORD1_TIME_CREATE (1UL << 18) > #define FATTR4_WORD1_TIME_DELTA (1UL << 19) > #define FATTR4_WORD1_TIME_METADATA (1UL << 20) > #define FATTR4_WORD1_TIME_MODIFY (1UL << 21) > > so TIME_CREATE should come second. > > I noticed this on a FreeBSD NFSv4.2 client, which supports creation > times. On this client, file times were weirdly permuted. With this > patch applied on the server, times looked normal on the client. > > Fixes: e377a3e698fb ("nfsd: Add support for the birth time attribute") > Link: https://unix.stackexchange.com/q/749605/56202 > Signed-off-by: Tavian Barnes I'm not especially familiar with this area of the protocol, but this looks correct at first glance. I've applied this to nfsd-fixes for v6.5. Out of interest, what type of filesystem does your server export? > --- > fs/nfsd/nfs4xdr.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index 76db2fe29624..3037c5b0623e 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -3354,6 +3354,13 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, > p = xdr_encode_hyper(p, (s64)stat.atime.tv_sec); > *p++ = cpu_to_be32(stat.atime.tv_nsec); > } > + if (bmval1 & FATTR4_WORD1_TIME_CREATE) { > + p = xdr_reserve_space(xdr, 12); > + if (!p) > + goto out_resource; > + p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec); > + *p++ = cpu_to_be32(stat.btime.tv_nsec); > + } > if (bmval1 & FATTR4_WORD1_TIME_DELTA) { > p = xdr_reserve_space(xdr, 12); > if (!p) > @@ -3374,13 +3381,6 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, > p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec); > *p++ = cpu_to_be32(stat.mtime.tv_nsec); > } > - if (bmval1 & FATTR4_WORD1_TIME_CREATE) { > - p = xdr_reserve_space(xdr, 12); > - if (!p) > - goto out_resource; > - p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec); > - *p++ = cpu_to_be32(stat.btime.tv_nsec); > - } > if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) { > u64 ino = stat.ino; > > -- > 2.41.0 >