On Tue, May 7, 2019 at 1:58 PM Liu Bo <[email protected]> wrote:
>
> We'll have to make sure filesystem has allocated space for the dax
> mapping, otherwise, guest writes from virtiofs may hang since write
> page fault is not able to be resolved if host fs is full
> (->page_mkwrite() return -ENOSPC).
>
> Signed-off-by: Liu Bo <[email protected]>
Reviewed-by: Peng Tao <[email protected]>

> ---
>  contrib/virtiofsd/passthrough_ll.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/contrib/virtiofsd/passthrough_ll.c 
> b/contrib/virtiofsd/passthrough_ll.c
> index f14f471..1ddb68f 100644
> --- a/contrib/virtiofsd/passthrough_ll.c
> +++ b/contrib/virtiofsd/passthrough_ll.c
> @@ -1897,12 +1897,28 @@ static void lo_setupmapping(fuse_req_t req, 
> fuse_ino_t ino, uint64_t foffset,
>
>         }
>
> +        if (flags & O_WRONLY) {
> +                /* this may allocate more space than we need. */
> +                ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, foffset, len);
> +                if (ret < 0) {
> +                        ret = errno;
> +                        fprintf(stderr, "%s: fallocate fail (ino=%" PRId64 
> "fd=%d foffset=0x%" PRIx64 ")\n",
> +                                __func__, ino, fi ? (int)fi->fh : lo_fd(req, 
> ino), foffset);
> +                        goto err;
> +                }
> +
> +                if (lo_debug(req))
> +                        fprintf(stderr, "fallocate (foffset=%" PRIx64 
> "moffset=%" PRIx64 ")\n",
> +                                foffset, moffset);
> +        }
> +
>          if (fuse_virtio_map(req, &msg, fd)) {
>                  fprintf(stderr, "%s: map over virtio failed (ino=%" PRId64 
> "fd=%d moffset=0x%" PRIx64 ")\n",
>                          __func__, ino, fi ? (int)fi->fh : lo_fd(req, ino), 
> moffset);
>                  ret = EINVAL;
>          }
>
> +err:
>         if (!fi)
>                 close(fd);
>         fuse_reply_err(req, ret);
> --
> 1.8.3.1
>
> _______________________________________________
> Virtio-fs mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/virtio-fs



-- 
[email protected]

Reply via email to