From: piaojun <piaojun@huawei.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: virtio-fs@redhat.com
Subject: Re: [Virtio-fs] [PATCH v3 1/2] virtiofsd: add definition of fuse_buf_writev()
Date: Fri, 9 Aug 2019 16:52:51 +0800 [thread overview]
Message-ID: <5D4D3463.7010805@huawei.com> (raw)
In-Reply-To: <20190809081458.GA25286@stefanha-x1.localdomain>
Hi Stefan,
On 2019/8/9 16:14, Stefan Hajnoczi wrote:
> On Thu, Aug 08, 2019 at 10:28:26PM +0800, piaojun wrote:
>> On 2019/8/8 17:38, Stefan Hajnoczi wrote:
>>> On Thu, Aug 08, 2019 at 02:15:27PM +0800, piaojun wrote:
>>>> +{
>>>> + ssize_t res, i, buf_index, iovcnt;
>>>> + struct iovec * iov;
>>>> + int fd = out_buf->buf[0].fd;
>>>> + off_t pos = out_buf->buf[0].pos;
>>>
>>> A struct fuse_bufvec may have multiple elements but this function
>>> assumes it only has 1. Please use struct fuse_buf *out_buf instead.
>>> This way it's clear that only 1 fuse_buf will be written.
>>
>> Do you mean that assign *out_buf with &out_buf->buf[0] in
>> fuse_buf_writev() and then operate out_buf in the following process?
>
> Since this function assumes that out_buf is only a single struct
> fuse_buf, please change the argument to struct fuse_buf instead of
> struct fuse_bufvec. This way it's clear what the function expects.
Agreed, already fixed in PATCH v4.
>
>>>
>>>> +
>>>> + if (in_buf->count > 2)
>>>> + iovcnt = in_buf->count - 1;
>>>> + else
>>>> + iovcnt = 1;
>>>> +
>>>> + iov = calloc(iovcnt, sizeof(struct iovec));
>>>> + if (!iov)
>>>> + return -ENOMEM;
>>>> +
>>>> + for (i = 0, buf_index = 1; i < iovcnt; i++, buf_index++) {
>>>> + iov[i].iov_base = in_buf->buf[buf_index].mem;
>>>> + iov[i].iov_len = in_buf->buf[buf_index].size;
>>>> + }
>>>
>>> Why is in_buf->buf[0] is skipped?
>>
>> This part of code seems a little complex and in_buf->buf[0].count just
>> tricks me. Maybe I need handle two situations:
>> 1. Iterate from in_buf->buf[0].mem when in_buf->buf[0].count is 1;
>> 2. buf[0].size is set 0 in do_write_buf() when in_buf->buf[0].count > 1,
>> and it's better to skip it. Perhaps it's also ok to iterate from buf[0],
>> as writev skip the iov with zero len. This looks like a hack.
>
> I would perform writev() with all of in_buf's buffers, even if some of
> them have 0 length. That way this function does not make any
> assumptions about in_buf's layout.
Agreed, already fixed in PATCH v4.
Jun
>
> The only requirement is that in_buf buffers are all memory buffers (not
> file descriptors).
>
prev parent reply other threads:[~2019-08-09 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-08 6:14 [Virtio-fs] [PATCH v3 0/2] virtiofsd: Improve io bandwidth by replacing pwrite with pwritev piaojun
2019-08-08 6:15 ` [Virtio-fs] [PATCH v3 1/2] virtiofsd: add definition of fuse_buf_writev() piaojun
2019-08-08 6:18 ` [Virtio-fs] [PATCH v3 2/2] virtiofsd: use fuse_buf_writev to replace fuse_buf_write for better performance piaojun
2019-08-08 9:38 ` [Virtio-fs] [PATCH v3 1/2] virtiofsd: add definition of fuse_buf_writev() Stefan Hajnoczi
2019-08-08 14:28 ` piaojun
2019-08-09 8:14 ` Stefan Hajnoczi
2019-08-09 8:52 ` piaojun [this message]
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=5D4D3463.7010805@huawei.com \
--to=piaojun@huawei.com \
--cc=stefanha@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.