From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 20 Aug 2019 11:39:26 -0400 From: Vivek Goyal Message-ID: <20190820153926.GC4233@redhat.com> References: <5D53D882.5090803@huawei.com> <5D5A4692.9060006@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5D5A4692.9060006@huawei.com> Subject: Re: [Virtio-fs] [PATCH RESEND][RFC] virtiofsd: do not fall back to buffer io when cache=auto/always List-Id: Development discussions about virtio-fs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: piaojun Cc: virtio-fs@redhat.com 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? Thanks Vivek > That causes inconsistency between Guest and Host. > > The cache option in virtiofsd should not affect the file io mode, so > set 'fi->direct_io' according to 'fi->flags'. > > Signed-off-by: Jun Piao > --- > contrib/virtiofsd/passthrough_ll.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c > index ca11764..a9c98d0 100644 > --- a/contrib/virtiofsd/passthrough_ll.c > +++ b/contrib/virtiofsd/passthrough_ll.c > @@ -1774,8 +1774,10 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name, > fi->fh = fh; > err = lo_do_lookup(req, parent, name, &e); > } > - if (lo->cache == CACHE_NONE) > + if (fi->flags & O_DIRECT) > fi->direct_io = 1; > + if (lo->cache == CACHE_NONE) > + fi->keep_cache = 0; > else if (lo->cache == CACHE_ALWAYS) > fi->keep_cache = 1; > > @@ -1982,8 +1984,11 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) > } > > fi->fh = fh; > - if (lo->cache == CACHE_NONE) > + > + if (fi->flags & O_DIRECT) > fi->direct_io = 1; > + if (lo->cache == CACHE_NONE) > + fi->keep_cache = 0; > else if (lo->cache == CACHE_ALWAYS) > fi->keep_cache = 1; > fuse_reply_open(req, fi); > -- > > _______________________________________________ > Virtio-fs mailing list > Virtio-fs@redhat.com > https://www.redhat.com/mailman/listinfo/virtio-fs