Skip to content

Commit d7dbed4

Browse files
tavianatorchucklever
authored andcommitted
nfsd: Fix creation time serialization order
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: e377a3e ("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>
1 parent 75bfb70 commit d7dbed4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,6 +3370,11 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
33703370
if (status)
33713371
goto out;
33723372
}
3373+
if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
3374+
status = nfsd4_encode_nfstime4(xdr, &stat.btime);
3375+
if (status)
3376+
goto out;
3377+
}
33733378
if (bmval1 & FATTR4_WORD1_TIME_DELTA) {
33743379
p = xdr_reserve_space(xdr, 12);
33753380
if (!p)
@@ -3386,11 +3391,6 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
33863391
if (status)
33873392
goto out;
33883393
}
3389-
if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
3390-
status = nfsd4_encode_nfstime4(xdr, &stat.btime);
3391-
if (status)
3392-
goto out;
3393-
}
33943394
if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
33953395
u64 ino = stat.ino;
33963396

0 commit comments

Comments
 (0)