mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Yangtao Li <frank.li@vivo.com>, Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: fix to call invalidate_mapping_pages in f2fs_move_file_range
Date: Fri, 5 May 2023 20:21:53 +0800	[thread overview]
Message-ID: <c0fbc92e-2ba1-0500-023e-743ac297d587@kernel.org> (raw)
In-Reply-To: <20230504185238.19488-1-frank.li@vivo.com>

On 2023/5/5 2:52, Yangtao Li wrote:
> In the following scenario, after executing the move_range ioctl syscall,
> the block size of the source file is 0, but data can still be read.
> 
>    # stat test
>    File: test
>    Size: 6               Blocks: 8          IO Block: 4096   regular file
>    # ./new_f2fs_io move_range test test_move_range 0 0 0
>    move range ret=0
>    # stat test
>    File: test
>    Size: 6               Blocks: 0          IO Block: 4096   regular file
>    # cat test
>    nihao
> 
> Let's fix to call invalidate_mapping_pages() after __exchange_data_block()
> success.
> 
> Fixes: 4dd6f977fc77 ("f2fs: support an ioctl to move a range of data blocks")
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/f2fs/file.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 78aa8cff4b41..ae7752c5cd0a 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2870,6 +2870,9 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
>   			f2fs_i_size_write(dst, dst_max_i_size);
>   		else if (dst_osize != dst->i_size)
>   			f2fs_i_size_write(dst, dst_osize);
> +
> +		invalidate_mapping_pages(src->i_mapping,
> +				pos_out, pos_in + len);

It needs to consider error cases?

Should we call this to drop page cache of src_inode after __clone_blkaddrs()
for each round exchange in __exchange_data_block()? and also drop page cache
of dst_indoe in roll_back case?

Thanks,

>   	}
>   	f2fs_unlock_op(sbi);
>   

      reply	other threads:[~2023-05-05 12:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-04 18:52 Yangtao Li
2023-05-05 12:21 ` Chao Yu [this message]

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=c0fbc92e-2ba1-0500-023e-743ac297d587@kernel.org \
    --to=chao@kernel.org \
    --cc=frank.li@vivo.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®