All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Liu Bo <bo.liu@linux.alibaba.com>
Cc: virtio-fs@redhat.com
Subject: Re: [Virtio-fs] [PATCH 0/9] virtio-fs fixes
Date: Mon, 29 Apr 2019 09:18:22 -0400	[thread overview]
Message-ID: <20190429131822.GA31835@redhat.com> (raw)
In-Reply-To: <20190427005838.gqulorwvzscpgumz@US-160370MP2.local>

On Fri, Apr 26, 2019 at 05:58:39PM -0700, Liu Bo wrote:
> On Thu, Apr 25, 2019 at 11:10:08AM -0700, Liu Bo wrote:
> > On Thu, Apr 25, 2019 at 10:59:50AM -0400, Vivek Goyal wrote:
> > > On Wed, Apr 24, 2019 at 04:12:59PM -0700, Liu Bo wrote:
> > > > Hi Vivek,
> > > > 
> > > > On Wed, Apr 24, 2019 at 02:41:30PM -0400, Vivek Goyal wrote:
> > > > > Hi Liubo,
> > > > > 
> > > > > I have made some fixes and took some of yours and pushed latest snapshot
> > > > > of my internal tree here.
> > > > > 
> > > > > https://github.com/rhvgoyal/linux/commits/virtio-fs-dev-5.1
> > > > > 
> > > > > Patches have been rebased to 5.1-rc5 kernel. I am thinking of updating
> > > > > this branch frequently with latest code.
> > > > 
> > > > With this branch, generic/476 still got hang, and yes, it's related to
> > > > "async page fault related events" just as what you've mentioned on #irc.
> > > > 
> > > > I confirmed this with kvm and kvmmmu tracepoints.
> > > > 
> > > > The tracepoints[1] showed that
> > > > [1]: https://paste.ubuntu.com/p/N9ngrthKCf/
> > > > 
> > > > ---
> > > > handle_ept_violation
> > > >   kvm_mmu_page_fault(error_code=182)
> > > >     tdp_page_fault
> > > >       fast_page_fault # spte not present
> > > >       try_async_pf #queue a async_pf work and return RETRY
> > > > 
> > > > vcpu_run
> > > >  kvm_check_async_pf_completion
> > > >    kvm_arch_async_page_ready
> > > >      tdp_page_fault(vcpu, work->gva, 0, true);
> > > >        fast_page_fault(error_code == 0);
> > > >        try_async_pf # found hpa
> > > >        __direct_map()
> > > > 	  set_spte(error_code == 0) # won't set the write bit
> > > > 
> > > > handle_ept_violation
> > > >   kvm_mmu_page_fault(error_code=1aa)
> > > >     tdp_page_fault
> > > >       fast_page_fault # spte present but no write bit
> > > >       try_async_pf # no hpa again queue a async_pf work and return RETRY
> > > 
> > > So why there is no "hpa"?
> > >
> > 
> > TBH, I have no idea, __gfn_to_pfn_memslot() did returned a pfn
> > successfully after async pf, but during its following EPT_VIOLATION,
> > __gfn_to_pfn_memslot() returned KVM_PFN_ERR_FAULT and indicated
> > callers to do another async pf, and over and over again.
> >
> 
> So I think I've figured out it, here is the summary,
> 
> virtiofs's dax write implementation sends a fallocate request to extend inode
> size and allocate space on the underlying fs so that the underlying mmap can
> fault in pages on demands.
> 
> There're two problems here,

> 
> 1) virtiofs write(2) only checks if the write range is within inode size,
>    however, this doesn't work all the time because besides write(2) and
>    fallocate(2), inode size can also be extended by truncate(2) which doesn't
>    allocate space on the underlying fs, so when guest VM writes to this address,
>    it then causes a EPT_VIOLATION which will help fault-in the necessary page
>    from the underlying %vma, and if it's a write fault, page_mkwrite() will be
>    called, if the required space is not yet allocated, page_mkwrite() then tries
>    to allocate the space, which may fail with ENOSPC if the underlying fs has
>    already been full,
> 
> 2) async pf doesn't check whether gup is successful.

Ok. So filesystem on host is full but truncate still succeeds (as it did
not reuiqre fs block allocations). But later when a write from guest
process happens, it results in async pf on host and that fails because
fs block can't be allocated.

But this still sounds like an issue with async pf where an error needs
to be captured and somehow communicated back to guest OS. In this
case -ENOSPC.

Thanks
Vivek


  reply	other threads:[~2019-04-29 13:18 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 18:03 [Virtio-fs] [PATCH 0/9] virtio-fs fixes Liu Bo
2019-04-16 18:03 ` [Virtio-fs] [PATCH 1/9] virtio-fs: fix multiple tag support Liu Bo
2019-04-16 18:09   ` Vivek Goyal
2019-04-16 18:03 ` [Virtio-fs] [PATCH 2/9] virtio-fs: clean up dax mapping before aborting connection Liu Bo
2019-04-16 18:18   ` Vivek Goyal
2019-04-16 18:40     ` Liu Bo
2019-04-16 18:03 ` [Virtio-fs] [PATCH 3/9] fuse: export fuse_drop_waiting() Liu Bo
2019-04-16 18:28   ` Vivek Goyal
2019-04-16 18:43     ` Liu Bo
2019-04-16 18:03 ` [Virtio-fs] [PATCH 4/9] virtio-fs: fix use-after-free against virtio_fs_vq's fuse_dev info Liu Bo
2019-04-23 19:51   ` Vivek Goyal
2019-04-25  0:16     ` Liu Bo
2019-04-16 18:03 ` [Virtio-fs] [PATCH 5/9] fuse: do not write whole page while page straddles i_size Liu Bo
2019-04-16 20:16   ` Vivek Goyal
2019-04-17  0:12     ` Liu Bo
2019-04-16 18:03 ` [Virtio-fs] [PATCH 6/9] virtio-fs: let dax style override directIO style when dax+cache=none Liu Bo
2019-04-16 19:38   ` Vivek Goyal
2019-04-17  8:25     ` Miklos Szeredi
2019-04-17 19:35       ` Liu Bo
2019-04-25 18:35         ` Vivek Goyal
2019-04-17 20:56       ` Vivek Goyal
2019-04-22 18:55         ` Liu Bo
2019-04-22 18:14       ` Vivek Goyal
2019-04-16 18:03 ` [Virtio-fs] [PATCH 7/9] fuse: return early if punch_hole fails Liu Bo
2019-04-16 19:51   ` Vivek Goyal
2019-04-16 18:03 ` [Virtio-fs] [PATCH 8/9] virtio-fs: honor RLIMIT_FSIZE in fuse_file_fallocate Liu Bo
2019-04-16 19:57   ` Vivek Goyal
2019-04-16 18:03 ` [Virtio-fs] [PATCH 9/9] fuse: fix deadlock in __fuse_file_fallocate() Liu Bo
2019-04-16 18:07   ` Vivek Goyal
2019-05-02 22:10     ` Liu Bo
2019-05-03 15:22       ` Vivek Goyal
2019-04-24 18:41 ` [Virtio-fs] [PATCH 0/9] virtio-fs fixes Vivek Goyal
2019-04-24 23:12   ` Liu Bo
2019-04-25 14:59     ` Vivek Goyal
2019-04-25 18:10       ` Liu Bo
2019-04-27  0:58         ` Liu Bo
2019-04-29 13:18           ` Vivek Goyal [this message]
2019-04-30  1:38             ` Liu Bo

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=20190429131822.GA31835@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=bo.liu@linux.alibaba.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.