Commit 14de5fc3 authored by duguowei's avatar duguowei Committed by Jaegeuk Kim

f2fs: remove redundant code for gc condition

Remove the redundant code and use local variant as the
argument directly. Make it more human-readable.
Signed-off-by: default avatarduguowei <duguowei@xiaomi.com>
[Jaegeuk Kim: make code neat]
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 7a8fc586
...@@ -120,15 +120,13 @@ static inline block_t free_user_blocks(struct f2fs_sb_info *sbi) ...@@ -120,15 +120,13 @@ static inline block_t free_user_blocks(struct f2fs_sb_info *sbi)
return free_blks - ovp_blks; return free_blks - ovp_blks;
} }
static inline block_t limit_invalid_user_blocks(struct f2fs_sb_info *sbi) static inline block_t limit_invalid_user_blocks(block_t user_block_count)
{ {
return (long)(sbi->user_block_count * LIMIT_INVALID_BLOCK) / 100; return (long)(user_block_count * LIMIT_INVALID_BLOCK) / 100;
} }
static inline block_t limit_free_user_blocks(struct f2fs_sb_info *sbi) static inline block_t limit_free_user_blocks(block_t reclaimable_user_blocks)
{ {
block_t reclaimable_user_blocks = sbi->user_block_count -
written_block_count(sbi);
return (long)(reclaimable_user_blocks * LIMIT_FREE_BLOCK) / 100; return (long)(reclaimable_user_blocks * LIMIT_FREE_BLOCK) / 100;
} }
...@@ -163,15 +161,16 @@ static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th, ...@@ -163,15 +161,16 @@ static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th,
static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi) static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi)
{ {
block_t invalid_user_blocks = sbi->user_block_count - block_t user_block_count = sbi->user_block_count;
written_block_count(sbi); block_t invalid_user_blocks = user_block_count -
written_block_count(sbi);
/* /*
* Background GC is triggered with the following conditions. * Background GC is triggered with the following conditions.
* 1. There are a number of invalid blocks. * 1. There are a number of invalid blocks.
* 2. There is not enough free space. * 2. There is not enough free space.
*/ */
if (invalid_user_blocks > limit_invalid_user_blocks(sbi) && return (invalid_user_blocks >
free_user_blocks(sbi) < limit_free_user_blocks(sbi)) limit_invalid_user_blocks(user_block_count) &&
return true; free_user_blocks(sbi) <
return false; limit_free_user_blocks(invalid_user_blocks));
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment