Skip to content

Commit

Permalink
NFSD: Add nfsd4_encode_fattr4_time_access()
Browse files Browse the repository at this point in the history
Refactor the encoder for FATTR4_TIME_ACCESS into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
  • Loading branch information
Chuck Lever committed Oct 16, 2023
1 parent 6d37ac3 commit eed4d1a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions fs/nfsd/nfs4xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2536,16 +2536,16 @@ static __be32 nfsd4_encode_nfs_fh4(struct xdr_stream *xdr,
return nfsd4_encode_opaque(xdr, fh_handle->fh_raw, fh_handle->fh_size);
}

/* This is a frequently-encoded type; open-coded for speed */
static __be32 nfsd4_encode_nfstime4(struct xdr_stream *xdr,
struct timespec64 *tv)
const struct timespec64 *tv)
{
__be32 *p;

p = xdr_reserve_space(xdr, XDR_UNIT * 3);
if (!p)
return nfserr_resource;

p = xdr_encode_hyper(p, (s64)tv->tv_sec);
p = xdr_encode_hyper(p, tv->tv_sec);
*p = cpu_to_be32(tv->tv_nsec);
return nfs_ok;
}
Expand Down Expand Up @@ -3255,6 +3255,12 @@ static __be32 nfsd4_encode_fattr4_space_used(struct xdr_stream *xdr,
return nfsd4_encode_uint64_t(xdr, (u64)args->stat.blocks << 9);
}

static __be32 nfsd4_encode_fattr4_time_access(struct xdr_stream *xdr,
const struct nfsd4_fattr_args *args)
{
return nfsd4_encode_nfstime4(xdr, &args->stat.atime);
}

/*
* Note: @fhp can be NULL; in this case, we might have to compose the filehandle
* ourselves.
Expand Down Expand Up @@ -3583,7 +3589,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
goto out;
}
if (bmval1 & FATTR4_WORD1_TIME_ACCESS) {
status = nfsd4_encode_nfstime4(xdr, &args.stat.atime);
status = nfsd4_encode_fattr4_time_access(xdr, &args);
if (status)
goto out;
}
Expand Down

0 comments on commit eed4d1a

Please sign in to comment.