linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: fix to avoid slowing down background gc
Date: Mon, 19 Sep 2016 15:12:11 -0700	[thread overview]
Message-ID: <20160919221211.GC68913@jaegeuk> (raw)
In-Reply-To: <20160918115227.130658-1-yuchao0@huawei.com>

Hi Chao,

On Sun, Sep 18, 2016 at 07:52:27PM +0800, Chao Yu wrote:
> Previously, we will choose to speed up background gc when the below
> conditions are both satisfied:
> a. There are a number of invalid blocks
> b. There is not enough free space
> 
> But, when space utilization is high (utilization > 60%), there will be
> not enough invalid blocks, result in slowing down background gc, after
> then there are more opportunities that triggering foreground gc due to
> high fragmented free space in fs.
> 
> Remove condition a) in order to avoid slow down background gc speed in
> a high utilization fs.

There exists a trade-off here: wear-out vs. eager gc for future speed-up.
How about using a kind of f2fs's dirty level (e.g., BDF)?

Thanks,

> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  fs/f2fs/gc.h | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
> index a993967..5d0a19c 100644
> --- a/fs/f2fs/gc.h
> +++ b/fs/f2fs/gc.h
> @@ -16,7 +16,6 @@
>  #define DEF_GC_THREAD_MIN_SLEEP_TIME	30000	/* milliseconds */
>  #define DEF_GC_THREAD_MAX_SLEEP_TIME	60000
>  #define DEF_GC_THREAD_NOGC_SLEEP_TIME	300000	/* wait 5 min */
> -#define LIMIT_INVALID_BLOCK	40 /* percentage over total user space */
>  #define LIMIT_FREE_BLOCK	40 /* percentage over invalid + free space */
>  
>  /* Search max. number of dirty segments to select a victim segment */
> @@ -52,11 +51,6 @@ static inline block_t free_user_blocks(struct f2fs_sb_info *sbi)
>  			<< sbi->log_blocks_per_seg;
>  }
>  
> -static inline block_t limit_invalid_user_blocks(struct f2fs_sb_info *sbi)
> -{
> -	return (long)(sbi->user_block_count * LIMIT_INVALID_BLOCK) / 100;
> -}
> -
>  static inline block_t limit_free_user_blocks(struct f2fs_sb_info *sbi)
>  {
>  	block_t reclaimable_user_blocks = sbi->user_block_count -
> @@ -88,15 +82,9 @@ static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th,
>  
>  static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi)
>  {
> -	block_t invalid_user_blocks = sbi->user_block_count -
> -					written_block_count(sbi);
>  	/*
> -	 * Background GC is triggered with the following conditions.
> -	 * 1. There are a number of invalid blocks.
> -	 * 2. There is not enough free space.
> +	 * Background GC should speed up when there is not enough free blocks
> +	 * in total unused (free + invalid) blocks.
>  	 */
> -	if (invalid_user_blocks > limit_invalid_user_blocks(sbi) &&
> -			free_user_blocks(sbi) < limit_free_user_blocks(sbi))
> -		return true;
> -	return false;
> +	return free_user_blocks(sbi) < limit_free_user_blocks(sbi);
>  }
> -- 
> 2.8.2.311.gee88674

  reply	other threads:[~2016-09-19 22:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-18 11:52 [PATCH] f2fs: fix to avoid slowing down background gc Chao Yu
2016-09-19 22:12 ` Jaegeuk Kim [this message]
2016-09-20  2:22   ` Chao Yu
2016-09-20  2:54     ` Jaegeuk Kim
2016-09-20  3:05       ` Chao Yu

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=20160919221211.GC68913@jaegeuk \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).