All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: virtio-fs-list <virtio-fs@redhat.com>
Subject: Re: [Virtio-fs] Few queries about virtiofsd read implementation
Date: Mon, 10 May 2021 17:40:05 -0400	[thread overview]
Message-ID: <20210510214005.GA207370@horse> (raw)
In-Reply-To: <YJlsJB/Ami4/jq4X@work-vm>

On Mon, May 10, 2021 at 06:23:48PM +0100, Dr. David Alan Gilbert wrote:
> * Vivek Goyal (vgoyal@redhat.com) wrote:
> > Hi David/Stefan,
> > 
> > I am browsing through the code of read requests (FUSE_READ) in virtiofsd
> > (and in virtiofs) and I have few questions. You folks probably know the
> > answers.
> > 
> > 1. virtio_send_data_iov(), reads the data from file into the scatter list.
> >   Some of the code looks strange.
> > 
> >   We seem to be retrying read if we read less number of bytes than what
> >   client asked for. I am wondering shoudl this really be our
> >   responsibility or client should deal with it. I am assuming that client
> >   should be ready to deal with less number of bytes read.
> > 
> >   So what was the thought process behind retrying.
> > 
> >           if (ret < len && ret) {
> >             fuse_log(FUSE_LOG_DEBUG, "%s: ret < len\n", __func__);
> >             /* Skip over this much next time around */
> >             skip_size = ret;
> >             buf->buf[0].pos += ret;
> >             len -= ret;
> > 
> >             /* Lets do another read */
> >             continue;
> >         }
> > 
> > - After this we have code where if number of bytes read are not same
> >   as we expect to, then we return EIO.
> > 
> >           if (ret != len) {
> >             fuse_log(FUSE_LOG_DEBUG, "%s: ret!=len\n", __func__);
> >             ret = EIO;
> >             free(in_sg_cpy);
> >             goto err;
> >         }
> > 
> >   When do we hit this. IIUC, preadv() will return.
> > 
> >   A. Either number of bytes we expected (no issues)
> >   B. 0 in case of EOF (We break out of loop and just return to client with
> >   		      number of bytes we have read so far).
> >   C. <0 (This is error case and we return error to client)
> >   D. X bytes which is less than len. 
> > 
> > To handle D we have code to retry. So when do we hit the above if
> > condition where "ret !=len). Is this a dead code. Or I missed something.
> 
> I think you're right, that's dead.
> And oyu're probably also right that we could just take it easy and
> return less data to the client if preadv just gives us part of it.

Also, looks like we never return error to client.  virtio_send_data_iov()
only sends reply back if preadv() reads requested bytes or reads less due
to EOF. If preadv() returnes error, then we return to caller with error.
And I don't see anybody propagating that error back to client.

lo_read()
  fuse_reply_data()
    fuse_send_data_iov()
      fuse_send_data_iov_fallback()
        virtio_send_data_iov()

fuse_reply_data() returns error only if ret > 0 and that's not the case
here. In fact that seems to be another piece of dead code for virtiofs.

Thanks
Vivek


  reply	other threads:[~2021-05-10 21:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 18:59 [Virtio-fs] Few queries about virtiofsd read implementation Vivek Goyal
2021-05-07 21:14 ` Edward McClanahan
2021-05-10 13:10   ` Vivek Goyal
2021-05-10 17:23 ` Dr. David Alan Gilbert
2021-05-10 21:40   ` Vivek Goyal [this message]
2021-05-10 21:45     ` Vivek Goyal

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=20210510214005.GA207370@horse \
    --to=vgoyal@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=virtio-fs@redhat.com \
    /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.