summaryrefslogtreecommitdiff
path: root/fs/f2fs/gc.h
diff options
context:
space:
mode:
authorduguowei <duguowei@xiaomi.com>2022-06-20 16:39:45 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2022-07-31 06:16:20 +0300
commit14de5fc3ddf3dee89068a54a4d137fc17c2c971c (patch)
tree99a24844180525bb55c22e9f11b6fda1d7da367a /fs/f2fs/gc.h
parent7a8fc586180d8c57db5cc1e2acb32bb9986f642b (diff)
downloadlinux-14de5fc3ddf3dee89068a54a4d137fc17c2c971c.tar.xz
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: duguowei <duguowei@xiaomi.com> [Jaegeuk Kim: make code neat] Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/gc.h')
-rw-r--r--fs/f2fs/gc.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
index 3fe145e8e594..19b956c2d697 100644
--- a/fs/f2fs/gc.h
+++ b/fs/f2fs/gc.h
@@ -120,15 +120,13 @@ static inline block_t free_user_blocks(struct f2fs_sb_info *sbi)
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;
}
@@ -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)
{
- block_t invalid_user_blocks = sbi->user_block_count -
- written_block_count(sbi);
+ block_t user_block_count = sbi->user_block_count;
+ block_t invalid_user_blocks = 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.
*/
- if (invalid_user_blocks > limit_invalid_user_blocks(sbi) &&
- free_user_blocks(sbi) < limit_free_user_blocks(sbi))
- return true;
- return false;
+ return (invalid_user_blocks >
+ limit_invalid_user_blocks(user_block_count) &&
+ free_user_blocks(sbi) <
+ limit_free_user_blocks(invalid_user_blocks));
}