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


Groups > linux.kernel > #1714774

Re: [PATCH v2] f2fs: free_user_blocks should use reserved_segments instead

From Yunlong Song <yunlong.song@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] f2fs: free_user_blocks should use reserved_segments instead
Date 2017-08-18 12:10 +0200
Message-ID <ufMo2-29w-29@gated-at.bofh.it> (permalink)
References <uejR9-2n2-31@gated-at.bofh.it> <ueEiR-6If-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


ping...

On 2017/8/15 15:14, Yunlong Song wrote:
> The part (overprovision_segments - reserved_segments) can still be used for LFS
> in some case, e.g., there are lots of invalid block from dirty segments, then
> the part (overprovision_segments - reserved_segments) can be safely used. So
> free_use_blocks should use reserved_segments instead, rather than directly use
> overprovision_segments. BTW, we also add the constraint of sbi->reserved_blocks.
>
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
> ---
>   fs/f2fs/gc.h | 18 +++++++++++++++---
>   1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
> index 9325191..542612a 100644
> --- a/fs/f2fs/gc.h
> +++ b/fs/f2fs/gc.h
> @@ -49,11 +49,23 @@ struct gc_inode_list {
>    */
>   static inline block_t free_user_blocks(struct f2fs_sb_info *sbi)
>   {
> -	if (free_segments(sbi) < overprovision_segments(sbi))
> +	block_t avail_user_block_count, free_blocks, avail_free_blocks;
> +	block_t reserved_blocks;
> +
> +	avail_user_block_count = sbi->user_block_count - sbi->reserved_blocks;
> +
> +	if (unlikely(sbi->total_valid_block_count > avail_user_block_count))
> +		return 0;
> +
> +	free_blocks = free_segments(sbi) << sbi->log_blocks_per_seg;
> +	avail_free_blocks = min(free_blocks, avail_user_block_count -
> +								sbi->total_valid_block_count);
> +	reserved_blocks = reserved_segments(sbi) << sbi->log_blocks_per_seg;
> +
> +	if (avail_free_blocks < reserved_blocks)
>   		return 0;
>   	else
> -		return (free_segments(sbi) - overprovision_segments(sbi))
> -			<< sbi->log_blocks_per_seg;
> +		return avail_free_blocks - reserved_blocks;
>   }
>   
>   static inline block_t limit_invalid_user_blocks(struct f2fs_sb_info *sbi)

-- 
Thanks,
Yunlong Song

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


Thread

[PATCH] f2fs: free_user_blocks should use reserved_segments instead Yunlong Song <yunlong.song@huawei.com> - 2017-08-14 11:30 +0200
  Re: [PATCH] f2fs: free_user_blocks should use reserved_segments  instead Jaegeuk Kim <jaegeuk@kernel.org> - 2017-08-15 05:40 +0200
    Re: [PATCH] f2fs: free_user_blocks should use reserved_segments  instead Yunlong Song <yunlong.song@huawei.com> - 2017-08-15 09:20 +0200
  [PATCH v2] f2fs: free_user_blocks should use reserved_segments instead Yunlong Song <yunlong.song@huawei.com> - 2017-08-15 09:20 +0200
    Re: [PATCH v2] f2fs: free_user_blocks should use reserved_segments  instead Yunlong Song <yunlong.song@huawei.com> - 2017-08-18 12:10 +0200
      Re: [PATCH v2] f2fs: free_user_blocks should use reserved_segments  instead Chao Yu <chao@kernel.org> - 2017-08-18 17:30 +0200

csiph-web