All of lore.kernel.org
 help / color / mirror / Atom feed
From: piaojun <piaojun@huawei.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: virtio-fs@redhat.com
Subject: Re: [Virtio-fs] [PATCH RESEND][RFC] virtiofsd: do not fall back to buffer io when cache=auto/always
Date: Fri, 23 Aug 2019 09:55:49 +0800	[thread overview]
Message-ID: <5D5F47A5.3020109@huawei.com> (raw)
In-Reply-To: <20190821131136.GA2304@redhat.com>



On 2019/8/21 21:11, Vivek Goyal wrote:
> On Wed, Aug 21, 2019 at 09:48:18AM +0800, piaojun wrote:
>>
>>
>> On 2019/8/21 1:56, Vivek Goyal wrote:
>>> On Tue, Aug 20, 2019 at 11:39:26AM -0400, Vivek Goyal wrote:
>>>> On Mon, Aug 19, 2019 at 02:49:54PM +0800, piaojun wrote:
>>>>> When O_DIRECT flags is set by Guest, virtiofsd will open file with
>>>>> O_DIRECT, but unset 'fi->direct_io' which makes Guest go buffer io path.
>>>>
>>>> Where is virtiofsd unset fi->direct_io flag? All I can see is that it
>>>> sets this flag if cache=none?
>>>>
>>>
>>> Ok, I looked at it little bit more closely and I don't think it is a
>>> problem. With cache=always/auto, we don't set fi->direct_io. That means
>>> server is not enforcing a direct I/O policy on client.
>>>
>>> Now if client decides to direct I/O by opening file with O_DIRECT, it
>>> will still take direct I/O path and call fuse_direct_IO(). Look at
>>> fuse_file_aops->fuse_direct_IO().
>>
>> The problem is that when Guest open with O_DIRECT, the Host won't set
>> open_flags with FOPEN_DIRECT_IO if CACHE_AUTO is set. It makes Guest
>> goes into fuse_cache_write_iter() rather than fuse_direct_write_iter().
>> In other words, the Guest's I/O mode will be changed by virtiofsd.
> 
> I think there are two direct I/O paths. One is where server requests
> that direct I/O be done on the file and in that case FOPEN_DIRECT_IO
> is set.
> 
> Other case is where client initiates direct I/O and in that case
> FOPEN_DIRECT_IO is not set and we take regular path which is
> capable of doing both direct and buffered I/O. For example, for
> reads we do following.
> 
> fuse_file_read_iter()
>    fuse_cache_read_iter()
>       generic_file_read_iter()
> 	mapping->a_ops->direct_IO() <--- (If iocb->ki_flags & IOCB_DIRECT)
> 	  fuse_direct_IO()
> 
> Similary for write path.
> 
> fuse_file_write_iter()
>   fuse_cache_write_iter()
>      generic_file_direct_write() <----- (If iocb->ki_flags & IOCB_DIRECT)
>         mapping->a_ops->direct_IO()
> 	   fuse_direct_IO()
> 
> Can you give it a try. I don't think we have the problem what you
> are describing.
> 

I make a try as you said, and it indeed goes direct path in guest even
if cache=always. So my doubt has been cleared.

Thanks,
Jun


  parent reply	other threads:[~2019-08-23  1:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14  9:46 [Virtio-fs] [PATCH][RFC] viriofsd: do not fall back to buffer io when cache=auto piaojun
2019-08-19  0:48 ` piaojun
2019-08-19  3:15 ` Eryu Guan
2019-08-19  3:51   ` piaojun
2019-08-19  5:07     ` Eryu Guan
2019-08-19  6:07       ` piaojun
2019-08-19  6:49 ` [Virtio-fs] [PATCH RESEND][RFC] virtiofsd: do not fall back to buffer io when cache=auto/always piaojun
2019-08-19  7:34   ` Eryu Guan
2019-08-19 14:16     ` piaojun
2019-08-20 15:39   ` Vivek Goyal
2019-08-20 17:56     ` Vivek Goyal
2019-08-21  1:48       ` piaojun
2019-08-21 13:11         ` Vivek Goyal
2019-08-21 14:38           ` piaojun
2019-08-21 14:47             ` Vivek Goyal
2019-08-22  5:01               ` piaojun
2019-08-23  1:55           ` piaojun [this message]
2019-08-20 15:31 ` [Virtio-fs] [PATCH][RFC] viriofsd: do not fall back to buffer io when cache=auto 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=5D5F47A5.3020109@huawei.com \
    --to=piaojun@huawei.com \
    --cc=vgoyal@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.