@@ -2541,6 +2541,20 @@ static __be32 *encode_change(__be32 *p, struct kstat *stat, struct inode *inode,
2541
2541
return p ;
2542
2542
}
2543
2543
2544
+ static __be32 nfsd4_encode_nfstime4 (struct xdr_stream * xdr ,
2545
+ struct timespec64 * tv )
2546
+ {
2547
+ __be32 * p ;
2548
+
2549
+ p = xdr_reserve_space (xdr , XDR_UNIT * 3 );
2550
+ if (!p )
2551
+ return nfserr_resource ;
2552
+
2553
+ p = xdr_encode_hyper (p , (s64 )tv -> tv_sec );
2554
+ * p = cpu_to_be32 (tv -> tv_nsec );
2555
+ return nfs_ok ;
2556
+ }
2557
+
2544
2558
/*
2545
2559
* ctime (in NFSv4, time_metadata) is not writeable, and the client
2546
2560
* doesn't really care what resolution could theoretically be stored by
@@ -3352,11 +3366,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
3352
3366
p = xdr_encode_hyper (p , dummy64 );
3353
3367
}
3354
3368
if (bmval1 & FATTR4_WORD1_TIME_ACCESS ) {
3355
- p = xdr_reserve_space (xdr , 12 );
3356
- if (!p )
3357
- goto out_resource ;
3358
- p = xdr_encode_hyper (p , (s64 )stat .atime .tv_sec );
3359
- * p ++ = cpu_to_be32 (stat .atime .tv_nsec );
3369
+ status = nfsd4_encode_nfstime4 (xdr , & stat .atime );
3370
+ if (status )
3371
+ goto out ;
3360
3372
}
3361
3373
if (bmval1 & FATTR4_WORD1_TIME_DELTA ) {
3362
3374
p = xdr_reserve_space (xdr , 12 );
@@ -3365,25 +3377,19 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
3365
3377
p = encode_time_delta (p , d_inode (dentry ));
3366
3378
}
3367
3379
if (bmval1 & FATTR4_WORD1_TIME_METADATA ) {
3368
- p = xdr_reserve_space (xdr , 12 );
3369
- if (!p )
3370
- goto out_resource ;
3371
- p = xdr_encode_hyper (p , (s64 )stat .ctime .tv_sec );
3372
- * p ++ = cpu_to_be32 (stat .ctime .tv_nsec );
3380
+ status = nfsd4_encode_nfstime4 (xdr , & stat .ctime );
3381
+ if (status )
3382
+ goto out ;
3373
3383
}
3374
3384
if (bmval1 & FATTR4_WORD1_TIME_MODIFY ) {
3375
- p = xdr_reserve_space (xdr , 12 );
3376
- if (!p )
3377
- goto out_resource ;
3378
- p = xdr_encode_hyper (p , (s64 )stat .mtime .tv_sec );
3379
- * p ++ = cpu_to_be32 (stat .mtime .tv_nsec );
3385
+ status = nfsd4_encode_nfstime4 (xdr , & stat .mtime );
3386
+ if (status )
3387
+ goto out ;
3380
3388
}
3381
3389
if (bmval1 & FATTR4_WORD1_TIME_CREATE ) {
3382
- p = xdr_reserve_space (xdr , 12 );
3383
- if (!p )
3384
- goto out_resource ;
3385
- p = xdr_encode_hyper (p , (s64 )stat .btime .tv_sec );
3386
- * p ++ = cpu_to_be32 (stat .btime .tv_nsec );
3390
+ status = nfsd4_encode_nfstime4 (xdr , & stat .btime );
3391
+ if (status )
3392
+ goto out ;
3387
3393
}
3388
3394
if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID ) {
3389
3395
u64 ino = stat .ino ;
0 commit comments