diff mbox series

[f2fs-dev,1/3] f2fs-tools: use 'IS_CUR_SEGNO()' to check if it is current segment

Message ID cc15b558e202197a424323e44ccece7bbb807434.1694768423.git.bo.wu@vivo.com (mailing list archive)
State Superseded
Headers show
Series f2fs-tools: cache free segments count to improve perfmance | expand

Commit Message

Wu Bo Sept. 15, 2023, 9:04 a.m. UTC
Use IS_CUR_SEGNO() here can make code more concise and readable.
---
 fsck/mount.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

Comments

Chao Yu Sept. 20, 2023, 8:49 a.m. UTC | #1
On 2023/9/15 17:04, Wu Bo wrote:
> Use IS_CUR_SEGNO() here can make code more concise and readable.
> ---
>   fsck/mount.c | 17 ++++-------------
>   1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/fsck/mount.c b/fsck/mount.c
> index df0314d..00940b8 100644
> --- a/fsck/mount.c
> +++ b/fsck/mount.c
> @@ -2531,20 +2531,11 @@ void build_sit_area_bitmap(struct f2fs_sb_info *sbi)
>   		memcpy(ptr, se->cur_valid_map, SIT_VBLOCK_MAP_SIZE);
>   		ptr += SIT_VBLOCK_MAP_SIZE;
>   
> -		if (se->valid_blocks == 0x0 && is_usable_seg(sbi, segno)) {
> -			if (le32_to_cpu(sbi->ckpt->cur_node_segno[0]) == segno ||
> -				le32_to_cpu(sbi->ckpt->cur_data_segno[0]) == segno ||
> -				le32_to_cpu(sbi->ckpt->cur_node_segno[1]) == segno ||
> -				le32_to_cpu(sbi->ckpt->cur_data_segno[1]) == segno ||
> -				le32_to_cpu(sbi->ckpt->cur_node_segno[2]) == segno ||
> -				le32_to_cpu(sbi->ckpt->cur_data_segno[2]) == segno) {
> -				continue;
> -			} else {
> -				free_segs++;
> -			}
> -		} else {
> +		if (se->valid_blocks == 0x0 && is_usable_seg(sbi, segno) &&
> +				!IS_CUR_SEGNO(sbi, segno))
> +			free_segs++;
> +		else
>   			sum_vblocks += se->valid_blocks;

IIUC, it should be?

if (se->valid_blocks == 0x0 && is_usable_seg(sbi, segno)) {
	if (!IS_CUR_SEGNO(sbi, segno))
		free_segs++;
} else {
	sum_vblocks += se->valid_blocks;
}

Thanks,

> -		}
>   	}
>   	fsck->chk.sit_valid_blocks = sum_vblocks;
>   	fsck->chk.sit_free_segs = free_segs;
diff mbox series

Patch

diff --git a/fsck/mount.c b/fsck/mount.c
index df0314d..00940b8 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -2531,20 +2531,11 @@  void build_sit_area_bitmap(struct f2fs_sb_info *sbi)
 		memcpy(ptr, se->cur_valid_map, SIT_VBLOCK_MAP_SIZE);
 		ptr += SIT_VBLOCK_MAP_SIZE;
 
-		if (se->valid_blocks == 0x0 && is_usable_seg(sbi, segno)) {
-			if (le32_to_cpu(sbi->ckpt->cur_node_segno[0]) == segno ||
-				le32_to_cpu(sbi->ckpt->cur_data_segno[0]) == segno ||
-				le32_to_cpu(sbi->ckpt->cur_node_segno[1]) == segno ||
-				le32_to_cpu(sbi->ckpt->cur_data_segno[1]) == segno ||
-				le32_to_cpu(sbi->ckpt->cur_node_segno[2]) == segno ||
-				le32_to_cpu(sbi->ckpt->cur_data_segno[2]) == segno) {
-				continue;
-			} else {
-				free_segs++;
-			}
-		} else {
+		if (se->valid_blocks == 0x0 && is_usable_seg(sbi, segno) &&
+				!IS_CUR_SEGNO(sbi, segno))
+			free_segs++;
+		else
 			sum_vblocks += se->valid_blocks;
-		}
 	}
 	fsck->chk.sit_valid_blocks = sum_vblocks;
 	fsck->chk.sit_free_segs = free_segs;