Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1530387

Re: [f2fs-dev] [PATCH 2/2] f2fs: fix redundant block allocation

From Chao Yu <chao@kernel.org>
Newsgroups linux.kernel
Subject Re: [f2fs-dev] [PATCH 2/2] f2fs: fix redundant block allocation
Date 2016-11-25 17:10 +0100
Message-ID <sHrey-2Lj-39@gated-at.bofh.it> (permalink)
References <sCvsu-3K4-13@gated-at.bofh.it> <sCvsu-3K4-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2016/11/12 9:30, Jaegeuk Kim wrote:
> In direct_IO path of f2fs_file_write_iter(),
> 1. f2fs_preallocate_blocks(F2FS_GET_BLOCK_PRE_DIO)
>    -> allocate LBA X
> 2. f2fs_direct_IO()
>    -> return 0;
> 
> Then,
> f2fs_write_data_page() will allocate another LBA X+1.
> 
> This makes EIO triggered by HM-SMR.

Good catch, :) how do you find this problem?

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

> ---
>  fs/f2fs/data.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 2938311..59203a3 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -658,6 +658,13 @@ static int __allocate_data_block(struct dnode_of_data *dn)
>  	return 0;
>  }
>  
> +static inline bool __force_buffered_io(struct inode *inode, int rw)
> +{
> +	return ((f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) ||
> +			(rw == WRITE && test_opt(F2FS_I_SB(inode), LFS)) ||
> +			F2FS_I_SB(inode)->s_ndevs);
> +}
> +
>  int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)
>  {
>  	struct inode *inode = file_inode(iocb->ki_filp);
> @@ -677,7 +684,10 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)
>  		err = f2fs_convert_inline_inode(inode);
>  		if (err)
>  			return err;
> -		return f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_DIO);
> +		return f2fs_map_blocks(inode, &map, 1,
> +			__force_buffered_io(inode, WRITE) ?
> +				F2FS_GET_BLOCK_PRE_AIO :
> +				F2FS_GET_BLOCK_PRE_DIO);
>  	}
>  	if (iocb->ki_pos + iov_iter_count(from) > MAX_INLINE_DATA) {
>  		err = f2fs_convert_inline_inode(inode);
> @@ -1769,11 +1779,7 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
>  	if (err)
>  		return err;
>  
> -	if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
> -		return 0;
> -	if (rw == WRITE && test_opt(F2FS_I_SB(inode), LFS))
> -		return 0;
> -	if (F2FS_I_SB(inode)->s_ndevs)
> +	if (__force_buffered_io(inode, rw))
>  		return 0;
>  
>  	trace_f2fs_direct_IO_enter(inode, offset, count, rw);
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] f2fs: fix redundant block allocation Jaegeuk Kim <jaegeuk@kernel.org> - 2016-11-12 02:40 +0100
  Re: [f2fs-dev] [PATCH 2/2] f2fs: fix redundant block allocation Chao Yu <chao@kernel.org> - 2016-11-25 17:10 +0100
    Re: [f2fs-dev] [PATCH 2/2] f2fs: fix redundant block allocation Jaegeuk Kim <jaegeuk@kernel.org> - 2016-11-25 19:20 +0100

csiph-web