Re: [PATCH 5.10 045/306] f2fs: fix to do sanity check for sb/cp fields correctly
From: Pavel Machek
Date: Sun Sep 19 2021 - 15:06:44 EST
Hi!
This code looks quite confused: part of function returns 1 on
corruption, part returns -errno. The problem is not stable-specific.
Best regards,
Pavel
> @@ -3058,6 +3061,17 @@ int f2fs_sanity_check_ckpt(struct f2fs_s
> return 1;
> }
>
> + nat_blocks = nat_segs << log_blocks_per_seg;
> + nat_bits_bytes = nat_blocks / BITS_PER_BYTE;
> + nat_bits_blocks = F2FS_BLK_ALIGN((nat_bits_bytes << 1) + 8);
> + if (__is_set_ckpt_flags(ckpt, CP_NAT_BITS_FLAG) &&
> + (cp_payload + F2FS_CP_PACKS +
> + NR_CURSEG_PERSIST_TYPE + nat_bits_blocks >= blocks_per_seg)) {
> + f2fs_warn(sbi, "Insane cp_payload: %u, nat_bits_blocks: %u)",
> + cp_payload, nat_bits_blocks);
> + return -EFSCORRUPTED;
> + }
> +
> if (unlikely(f2fs_cp_error(sbi))) {
> f2fs_err(sbi, "A bug case: need to run fsck");
> return 1;
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Attachment:
signature.asc
Description: Digital signature