From: "J. Bruce Fields" <bfields@fieldses.org>
To: Anna Schumaker <Anna.Schumaker@netapp.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH v3 3/3] NFSD: Add support for encoding multiple segments
Date: Tue, 17 Mar 2015 15:56:33 -0400 [thread overview]
Message-ID: <20150317195633.GC29843@fieldses.org> (raw)
In-Reply-To: <1426540688-32095-4-git-send-email-Anna.Schumaker@Netapp.com>
On Mon, Mar 16, 2015 at 05:18:08PM -0400, Anna Schumaker wrote:
> This patch implements sending an array of segments back to the client.
> Clients should be prepared to handle multiple segment reads to make this
> useful. We try to splice the first data segment into the XDR result,
> and remaining segments are encoded directly.
I'm still interested in what would happen if we started with an
implementation like:
- if the entire requested range falls within a hole, return that
single hole.
- otherwise, just treat the thing as one big data segment.
That would provide a benefit in the case there are large-ish holes
with minimal impact otherwise.
(Though patches for full support are still useful even if only for
client-testing purposes.)
--b.
>
> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
> ---
> fs/nfsd/nfs4proc.c | 4 ++--
> fs/nfsd/nfs4xdr.c | 35 ++++++++++++++++++++++++-----------
> 2 files changed, 26 insertions(+), 13 deletions(-)
>
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index e9f4d8f..6801973 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1862,8 +1862,8 @@ static inline u32 nfsd4_read_plus_rsize(struct svc_rqst *rqstp, struct nfsd4_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 xdr = 5;
> + /* Extra xdr padding for encoding multiple segments. */
> + u32 xdr = 20;
>
> return (op_encode_hdr_size + 2 + xdr + XDR_QUADLEN(rlen)) * sizeof(__be32);
> }
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 799d52c..5eaecd2 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -4117,7 +4117,7 @@ nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr,
>
> static __be32
> nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp, struct nfsd4_read *read,
> - struct file *file)
> + struct file *file, loff_t hole_pos)
> {
> __be32 *p, err;
> unsigned long maxcount;
> @@ -4128,20 +4128,26 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp, struct nfsd4_read *r
> return nfserr_resource;
> xdr_commit_encode(xdr);
>
> + if (hole_pos <= read->rd_offset)
> + hole_pos = i_size_read(file_inode(file));
> +
> maxcount = svc_max_payload(resp->rqstp);
> maxcount = min_t(unsigned long, maxcount, (xdr->buf->buflen - xdr->buf->len));
> maxcount = min_t(unsigned long, maxcount, read->rd_length);
> + maxcount = min_t(unsigned long, maxcount, hole_pos - read->rd_offset);
>
> if (file->f_op->splice_read && test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags))
> err = nfsd4_encode_splice_read(resp, read, file, &maxcount);
> else
> err = nfsd4_encode_readv(resp, read, file, &maxcount);
> + clear_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags);
>
> *p++ = cpu_to_be32(NFS4_CONTENT_DATA);
> p = xdr_encode_hyper(p, read->rd_offset);
> *p++ = cpu_to_be32(maxcount);
>
> read->rd_offset += maxcount;
> + read->rd_length -= maxcount;
> return err;
> }
>
> @@ -4156,7 +4162,7 @@ nfsd4_encode_read_plus_hole(struct nfsd4_compoundres *resp, struct nfsd4_read *r
> if (data_pos == -ENXIO)
> data_pos = i_size_read(file_inode(file));
> if (data_pos <= read->rd_offset)
> - return nfsd4_encode_read_plus_data(resp, read, file);
> + return nfsd4_encode_read_plus_data(resp, read, file, 0);
>
> maxcount = data_pos - read->rd_offset;
> p = xdr_reserve_space(&resp->xdr, 4 + 8 + 8);
> @@ -4165,6 +4171,10 @@ nfsd4_encode_read_plus_hole(struct nfsd4_compoundres *resp, struct nfsd4_read *r
> p = xdr_encode_hyper(p, maxcount);
>
> read->rd_offset += maxcount;
> + if (maxcount > read->rd_length)
> + read->rd_length = 0;
> + else
> + read->rd_length -= maxcount;
> return nfs_ok;
> }
>
> @@ -4197,17 +4207,20 @@ nfsd4_encode_read_plus(struct nfsd4_compoundres *resp, __be32 nfserr,
> goto err_truncate;
> }
>
> - hole_pos = vfs_llseek(file, read->rd_offset, SEEK_HOLE);
> - if (hole_pos == -ENXIO)
> - goto out_encode;
> + do {
> + hole_pos = vfs_llseek(file, read->rd_offset, SEEK_HOLE);
> + if (hole_pos == -ENXIO)
> + break;
>
> - if (hole_pos == read->rd_offset)
> - err = nfsd4_encode_read_plus_hole(resp, read, file);
> - else
> - err = nfsd4_encode_read_plus_data(resp, read, file);
> - segments++;
> + if (hole_pos == read->rd_offset)
> + err = nfsd4_encode_read_plus_hole(resp, read, file);
> + else
> + err = nfsd4_encode_read_plus_data(resp, read, file, hole_pos);
> + if (err)
> + break;
> + segments++;
> + } while (read->rd_length > 0);
>
> -out_encode:
> eof = (read->rd_offset >= i_size_read(file_inode(file)));
> *p++ = cpu_to_be32(eof);
> *p++ = cpu_to_be32(segments);
> --
> 2.3.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-03-17 19:56 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 21:18 [PATCH v3 0/3] NFSD: Add READ_PLUS support Anna Schumaker
2015-03-16 21:18 ` [PATCH v3 1/3] NFSD: nfsd4_encode_read{v}() should encode eof and maxcount Anna Schumaker
2015-03-16 21:18 ` [PATCH v3 2/3] NFSD: Add basic READ_PLUS support Anna Schumaker
2015-03-16 21:18 ` [PATCH v3 3/3] NFSD: Add support for encoding multiple segments Anna Schumaker
2015-03-17 19:56 ` J. Bruce Fields [this message]
2015-03-17 20:07 ` J. Bruce Fields
2015-03-17 21:36 ` J. Bruce Fields
2015-03-18 18:16 ` Anna Schumaker
2015-03-18 18:55 ` J. Bruce Fields
2015-03-18 20:39 ` Anna Schumaker
2015-03-18 20:55 ` J. Bruce Fields
2015-03-18 21:03 ` Anna Schumaker
2015-03-18 21:11 ` J. Bruce Fields
[not found] ` <OFB111A6D8.016B8BD5-ON88257E0D.001D174D-88257E0D.005268D6@us.ibm.com>
2015-03-19 15:36 ` J. Bruce Fields
2015-03-19 16:28 ` Marc Eshel
2015-03-20 15:17 ` J. Bruce Fields
2015-03-20 15:17 ` J. Bruce Fields
2015-03-20 16:23 ` Christoph Hellwig
2015-03-20 16:23 ` Christoph Hellwig
2015-03-20 18:26 ` J. Bruce Fields
2015-03-20 18:26 ` J. Bruce Fields
2015-03-24 12:43 ` Anna Schumaker
2015-03-24 12:43 ` Anna Schumaker
2015-03-24 17:49 ` Christoph Hellwig
2015-03-24 17:49 ` Christoph Hellwig
2015-03-25 17:15 ` Anna Schumaker
2015-03-25 17:15 ` Anna Schumaker
2015-03-26 15:21 ` Anna Schumaker
2015-03-26 15:21 ` Anna Schumaker
2015-03-26 15:32 ` Trond Myklebust
2015-03-26 15:32 ` Trond Myklebust
2015-03-26 15:36 ` Anna Schumaker
2015-03-26 15:36 ` Anna Schumaker
2015-03-26 15:38 ` J. Bruce Fields
2015-03-26 15:38 ` J. Bruce Fields
2015-03-26 15:47 ` Anna Schumaker
2015-03-26 15:47 ` Anna Schumaker
2015-03-26 16:06 ` Trond Myklebust
2015-03-26 16:06 ` Trond Myklebust
2015-03-26 16:11 ` Anna Schumaker
2015-03-26 16:11 ` Anna Schumaker
2015-03-26 16:13 ` Trond Myklebust
2015-03-26 16:13 ` Trond Myklebust
2015-03-26 16:14 ` Anna Schumaker
2015-03-26 16:14 ` Anna Schumaker
2015-03-27 19:04 ` Anna Schumaker
2015-03-27 19:04 ` Anna Schumaker
2015-03-27 20:22 ` Trond Myklebust
2015-03-27 20:22 ` Trond Myklebust
2015-03-27 20:46 ` Anna Schumaker
2015-03-27 20:46 ` Anna Schumaker
2015-03-27 20:54 ` J. Bruce Fields
2015-03-27 20:54 ` J. Bruce Fields
2015-03-27 20:55 ` Anna Schumaker
2015-03-27 20:55 ` Anna Schumaker
2015-03-27 21:08 ` J. Bruce Fields
2015-03-27 21:08 ` J. Bruce Fields
2015-04-15 19:32 ` Anna Schumaker
2015-04-15 19:32 ` Anna Schumaker
2015-04-15 19:56 ` J. Bruce Fields
2015-04-15 19:56 ` J. Bruce Fields
2015-04-15 20:00 ` J. Bruce Fields
2015-04-15 20:00 ` J. Bruce Fields
2015-04-15 22:50 ` Dave Chinner
2015-04-15 22:50 ` Dave Chinner
2015-04-17 22:07 ` J. Bruce Fields
2015-04-17 22:07 ` J. Bruce Fields
2015-04-15 22:57 ` Dave Chinner
2015-04-15 22:57 ` Dave Chinner
2015-03-26 16:11 ` J. Bruce Fields
2015-03-26 16:11 ` J. Bruce Fields
2015-03-26 16:18 ` Anna Schumaker
2015-03-26 16:18 ` Anna Schumaker
2015-03-30 14:06 ` Christoph Hellwig
2015-03-30 14:06 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150317195633.GC29843@fieldses.org \
--to=bfields@fieldses.org \
--cc=Anna.Schumaker@netapp.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.