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, Miklos Szeredi <mszeredi@redhat.com>
Subject: Re: [Virtio-fs] [PATCH 5/9] fuse: do not write whole page while page straddles i_size
Date: Tue, 16 Apr 2019 16:16:21 -0400	[thread overview]
Message-ID: <20190416201621.GH2222@redhat.com> (raw)
In-Reply-To: <20190416180322.65113-6-bo.liu@linux.alibaba.com>

On Wed, Apr 17, 2019 at 02:03:18AM +0800, Liu Bo wrote:
> From: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
> 
> If page straddles i_size and we write the whole page, the fuse
> user-space filesystem may extend file size, it will confuse users.
> 
> Before this patch:
> xfs_io -t -f \
>         -c "truncate 5120" \
>         -c "pwrite -S 0x58 0 5120"      \
>         -c "mmap -rw 0 5120"            \
>         -c "mwrite -S 0x59 2048 3072" \
>         -c "close"      \
>         testfile
> testfile's length will be 8192 bytes, with this patch, testfile's
> length will be 5120 bytes.
> 
> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>

[cc miklos]

This sounds like a generic fuse issue as well (and not virtio-fs specic)?
If yes, can you please send this fix separately to miklos and fuse
mailing list.

Vivek
> ---
>  fs/fuse/file.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index bb45acc..c6090f5 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -2293,6 +2293,8 @@ static int fuse_writepages_fill(struct page *page,
>  	struct page *tmp_page;
>  	bool is_writeback;
>  	int err;
> +	loff_t size;
> +	unsigned int len;
>  
>  	if (!data->ff) {
>  		err = -EIO;
> @@ -2364,7 +2366,12 @@ static int fuse_writepages_fill(struct page *page,
>  	copy_highpage(tmp_page, page);
>  	req->pages[req->num_pages] = tmp_page;
>  	req->page_descs[req->num_pages].offset = 0;
> -	req->page_descs[req->num_pages].length = PAGE_SIZE;
> +	size = i_size_read(inode);
> +	if (page->index == size >> PAGE_SHIFT)
> +		len = size & ~PAGE_MASK;
> +	else
> +		len = PAGE_SIZE;
> +	req->page_descs[req->num_pages].length = len;
>  
>  	inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK);
>  	inc_node_page_state(tmp_page, NR_WRITEBACK_TEMP);
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Virtio-fs mailing list
> Virtio-fs@redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs


  reply	other threads:[~2019-04-16 20:16 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 [this message]
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
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=20190416201621.GH2222@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=bo.liu@linux.alibaba.com \
    --cc=mszeredi@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.