On Mon, Aug 31, 2020 at 02:16:26PM -0400, Anna Schumaker wrote: > On Fri, Aug 28, 2020 at 5:56 PM J. Bruce Fields <bfields@xxxxxxxxxx> wrote: > > > > On Fri, Aug 28, 2020 at 05:25:21PM -0400, J. Bruce Fields wrote: > > > On Mon, Aug 17, 2020 at 12:53:07PM -0400, schumaker.anna@xxxxxxxxx wrote: > > > > From: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx> > > > > > > > > This patch adds READ_PLUS support for returning a single > > > > NFS4_CONTENT_DATA segment to the client. This is basically the same as > > > > the READ operation, only with the extra information about data segments. > > > > > > > > Signed-off-by: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx> > > > > --- > > > > fs/nfsd/nfs4proc.c | 17 ++++++++++ > > > > fs/nfsd/nfs4xdr.c | 83 ++++++++++++++++++++++++++++++++++++++++++++-- > > > > 2 files changed, 98 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > > > > index a09c35f0f6f0..9630d33211f2 100644 > > > > --- a/fs/nfsd/nfs4proc.c > > > > +++ b/fs/nfsd/nfs4proc.c > > > > @@ -2523,6 +2523,16 @@ static inline u32 nfsd4_read_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) > > > > return (op_encode_hdr_size + 2 + XDR_QUADLEN(rlen)) * sizeof(__be32); > > > > } > > > > > > > > +static inline u32 nfsd4_read_plus_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) > > > > +{ > > > > + u32 maxcount = svc_max_payload(rqstp); > > > > + u32 rlen = min(op->u.read.rd_length, maxcount); > > > > + /* enough extra xdr space for encoding either a hole or data segment. */ > > > > + u32 segments = 1 + 2 + 2; > > > > + > > > > + return (op_encode_hdr_size + 2 + segments + XDR_QUADLEN(rlen)) * sizeof(__be32); > > > > > > I'm not sure I understand this calculation. > > > > > > In the final code, there's no fixed limit on the number of segments > > > returned by a single READ_PLUS op, right? > > > > I think the worst-case overhead to represent a hole is around 50 bytes. > > > > So as long as we don't encode any holes less than that, then we can just > > use rlen as an upper bound. > > > > We really don't want to bother encoding small holes. I doubt > > filesystems want to bother with them either. Do they give us any > > guarantees as to the minimum size of a hole? > > The minimum size seems to be PAGE_SIZE from everything I've seen. OK, can we make that assumption explicit? It'd simplify stuff like this. --b.