From: Dominique Martinet <asmadeus@codewreck.org>
To: Sergey Alirzaev <l29ah@cock.li>
Cc: v9fs-developer@lists.sourceforge.net,
Eric Van Hensbergen <ericvh@gmail.com>,
Latchesar Ionkov <lucho@ionkov.net>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] 9pnet: allow making incomplete read requests
Date: Wed, 5 Feb 2020 08:35:04 +0100 [thread overview]
Message-ID: <20200205073504.GA16626@nautica> (raw)
In-Reply-To: <20200205003457.24340-1-l29ah@cock.li>
Sergey Alirzaev wrote on Wed, Feb 05, 2020:
> A user doesn't necessarily want to wait for all the requested data to
> be available, since the waiting time is unbounded.
I'm not sure I agree on the argument there: the waiting time is
unbounded for a single request as well. What's your use case?
I think it would be better to describe what you really do with
O_NONBLOCK that requires this, and not just false theoritical
arguments.
> Signed-off-by: Sergey Alirzaev <l29ah@cock.li>
Code-wise looks mostly good, just a nitpick about keeping the total
variable in p9_client_read_once inline.
> ---
> include/net/9p/client.h | 2 +
> net/9p/client.c | 133 ++++++++++++++++++++++------------------
> 2 files changed, 76 insertions(+), 59 deletions(-)
>
> --- a/net/9p/client.c
> +++ b/net/9p/client.c
> @@ -1548,83 +1548,98 @@ EXPORT_SYMBOL(p9_client_unlinkat);
>
> int
> p9_client_read(struct p9_fid *fid, u64 offset, struct iov_iter *to, int *err)
> +{
> + int total = 0;
> + *err = 0;
> +
> + while (iov_iter_count(to)) {
> + int count;
> +
> + count = p9_client_read_once(fid, offset, to, err);
> + if (!count || *err)
> + break;
> + offset += count;
> + total += count;
> + }
> + return total;
> +}
> +EXPORT_SYMBOL(p9_client_read);
> +
> +int
> +p9_client_read_once(struct p9_fid *fid, u64 offset, struct iov_iter *to,
> + int *err)
> {
> struct p9_client *clnt = fid->clnt;
> struct p9_req_t *req;
> int total = 0;
total only makes sense in an iterating p9_client_read, I think it makes
code harder to read here (can basically use count or 0 directly now)
> - *err = 0;
> + int count = iov_iter_count(to);
> + int rsize, non_zc = 0;
> + char *dataptr;
>
> + *err = 0;
> p9_debug(P9_DEBUG_9P, ">>> TREAD fid %d offset %llu %d\n",
> fid->fid, (unsigned long long) offset, (int)iov_iter_count(to));
>
> - while (iov_iter_count(to)) {
> - int count = iov_iter_count(to);
> - int rsize, non_zc = 0;
> - char *dataptr;
> + rsize = fid->iounit;
> + if (!rsize || rsize > clnt->msize - P9_IOHDRSZ)
> + rsize = clnt->msize - P9_IOHDRSZ;
>
> - rsize = fid->iounit;
> - if (!rsize || rsize > clnt->msize-P9_IOHDRSZ)
> - rsize = clnt->msize - P9_IOHDRSZ;
> + if (count < rsize)
> + rsize = count;
>
> - if (count < rsize)
> - rsize = count;
> + /* Don't bother zerocopy for small IO (< 1024) */
> + if (clnt->trans_mod->zc_request && rsize > 1024) {
> + /* response header len is 11
> + * PDU Header(7) + IO Size (4)
> + */
> + req = p9_client_zc_rpc(clnt, P9_TREAD, to, NULL, rsize,
> + 0, 11, "dqd", fid->fid,
> + offset, rsize);
> + } else {
> + non_zc = 1;
> + req = p9_client_rpc(clnt, P9_TREAD, "dqd", fid->fid, offset,
> + rsize);
> + }
> + if (IS_ERR(req)) {
> + *err = PTR_ERR(req);
> + return total;
> + }
>
> - /* Don't bother zerocopy for small IO (< 1024) */
> - if (clnt->trans_mod->zc_request && rsize > 1024) {
> - /*
> - * response header len is 11
> - * PDU Header(7) + IO Size (4)
> - */
> - req = p9_client_zc_rpc(clnt, P9_TREAD, to, NULL, rsize,
> - 0, 11, "dqd", fid->fid,
> - offset, rsize);
> - } else {
> - non_zc = 1;
> - req = p9_client_rpc(clnt, P9_TREAD, "dqd", fid->fid, offset,
> - rsize);
> - }
> - if (IS_ERR(req)) {
> - *err = PTR_ERR(req);
> - break;
> - }
> + *err = p9pdu_readf(&req->rc, clnt->proto_version,
> + "D", &count, &dataptr);
> + if (*err) {
> + trace_9p_protocol_dump(clnt, &req->rc);
> + p9_tag_remove(clnt, req);
> + return total;
> + }
> + if (rsize < count) {
> + pr_err("bogus RREAD count (%d > %d)\n", count, rsize);
> + count = rsize;
> + }
>
> - *err = p9pdu_readf(&req->rc, clnt->proto_version,
> - "D", &count, &dataptr);
> - if (*err) {
> - trace_9p_protocol_dump(clnt, &req->rc);
> - p9_tag_remove(clnt, req);
> - break;
> - }
> - if (rsize < count) {
> - pr_err("bogus RREAD count (%d > %d)\n", count, rsize);
> - count = rsize;
> - }
> + p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
> + if (!count) {
> + p9_tag_remove(clnt, req);
> + return total;
> + }
>
> - p9_debug(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
> - if (!count) {
> - p9_tag_remove(clnt, req);
> - break;
> - }
> + if (non_zc) {
> + int n = copy_to_iter(dataptr, count, to);
>
> - if (non_zc) {
> - int n = copy_to_iter(dataptr, count, to);
> - total += n;
> - offset += n;
> - if (n != count) {
> - *err = -EFAULT;
> - p9_tag_remove(clnt, req);
> - break;
> - }
> - } else {
> - iov_iter_advance(to, count);
> - total += count;
> - offset += count;
> + total += n;
> + if (n != count) {
> + *err = -EFAULT;
> + p9_tag_remove(clnt, req);
> + return total;
> }
> - p9_tag_remove(clnt, req);
> + } else {
> + iov_iter_advance(to, count);
> + total += count;
> }
> + p9_tag_remove(clnt, req);
> return total;
> }
> -EXPORT_SYMBOL(p9_client_read);
> +EXPORT_SYMBOL(p9_client_read_once);
>
> int
> p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err)
--
Dominique
next prev parent reply other threads:[~2020-02-05 7:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-05 0:34 [PATCH 1/2] 9pnet: allow making incomplete read requests Sergey Alirzaev
2020-02-05 0:34 ` [PATCH 2/2] 9p: read only once on O_NONBLOCK Sergey Alirzaev
2020-02-05 7:41 ` Dominique Martinet
2020-02-05 7:35 ` Dominique Martinet [this message]
2020-02-05 15:48 ` [PATCH 1/2] 9pnet: allow making incomplete read requests l29ah
2020-02-05 16:07 ` Dominique Martinet
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=20200205073504.GA16626@nautica \
--to=asmadeus@codewreck.org \
--cc=davem@davemloft.net \
--cc=ericvh@gmail.com \
--cc=kuba@kernel.org \
--cc=l29ah@cock.li \
--cc=linux-kernel@vger.kernel.org \
--cc=lucho@ionkov.net \
--cc=netdev@vger.kernel.org \
--cc=v9fs-developer@lists.sourceforge.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).