]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nfsd: Fix creation time serialization order
authorTavian Barnes <tavianator@tavianator.com>
Fri, 23 Jun 2023 21:09:06 +0000 (17:09 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:28 +0000 (16:19 +0200)
[ Upstream commit d7dbed457c2ef83709a2a2723a2d58de43623449 ]

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 <tavianator@tavianator.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4xdr.c

index c40876daf60c0514256d03ea2d607098ec8ce6dc..5b95499a1f344592ad8af9ffa7f582707ee90adf 100644 (file)
@@ -3365,6 +3365,11 @@ out_acl:
                if (status)
                        goto out;
        }
+       if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
+               status = nfsd4_encode_nfstime4(xdr, &stat.btime);
+               if (status)
+                       goto out;
+       }
        if (bmval1 & FATTR4_WORD1_TIME_DELTA) {
                p = xdr_reserve_space(xdr, 12);
                if (!p)
@@ -3381,11 +3386,6 @@ out_acl:
                if (status)
                        goto out;
        }
-       if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
-               status = nfsd4_encode_nfstime4(xdr, &stat.btime);
-               if (status)
-                       goto out;
-       }
        if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
                u64 ino = stat.ino;