Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1550463rdb; Mon, 19 Feb 2024 22:21:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWDl7yQayuX96WZk/By4KmkeqUxD2GrIiZYCJUEC22JP4KtKdjz4lydNs87v2VHdUAPkDAXn0FrsVvHsek/ZDUWIUt4ThflPuJDRhwE4A== X-Google-Smtp-Source: AGHT+IEc/Azxj94KBRgIgO8ZrVtfIl7UdtgDY72yAzqXSLVof3vI+95OKdu0rWFy5tICGrJDY0s5 X-Received: by 2002:a17:906:4951:b0:a3e:e90f:8c49 with SMTP id f17-20020a170906495100b00a3ee90f8c49mr978026ejt.37.1708410094599; Mon, 19 Feb 2024 22:21:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708410094; cv=pass; d=google.com; s=arc-20160816; b=rSpL75vDinjtoRpWgtyCqOwmWXcbGsXOC6huBYZ5wtRVtJQP/+WG3+m8VI2T6U3gse Mhmz6RGDz7cdELxcGyYSeSSuS0EdjXFHfzr8Y3bzRYHBOW8fGA5ajY/oEdysJbXRqkbc AvPoct6NV/LE3YB/gNPw+Qa5FdqVrAZNkt2jQx9I0imagGvquqdhsWxrGGzyCSoGOAxM CpEPOFr5BQjuOHCzkt3D/t6VXdc6w09bcKc1iaujMLeQTCOjB4/6E0T2eEZ2EDQd9Jyi Rrawfss1o/wEgorfHNAlQaJGU4CM1/REiMPVyqXb9Meum4XFNenf70LT6X440r0l6Tdk 3WMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=hyTRxgZouENAUYYiushBJuUdSN1ibJMaVQTinCKjCMQ=; fh=w2kvI/0mdQM8yTBZ7531irUan64dFf3R9bUB31ELAjA=; b=HFeadRVKtZTB3K5PnIXBrNYqPF8HdSz9hFCqL0nn+Zy0VYXx09IZDfYm+8byB8oSlD rtDkJmyK6UaIeK5ga29DWG942bPKRwbuPCFq5jeyDNLCuYKif2ohs+72u0b2cfMHbVoi 6fsqZ+/T1mPmK3kdnpwBEfwkxjHVEhHEH/c3IbGbI8CIZqgZ3umrGyMtkjmMXv8m3518 mAzQCNKO3liiVzXm/E7qhWn0UJZSeY9gNoOLQ8uAbTSs6ipkFwnYa2O/KkXtPSOTTgad wyT5eBVC5tt8z7X18DZPZAz2H4xcLT2VCrSFIhUFm18NVdwa6Jt0dNYPcbl556VFsAtc hTRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IGi9zuZF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72392-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72392-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u14-20020a1709060b0e00b00a3ee699a0bfsi587832ejg.451.2024.02.19.22.21.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 22:21:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72392-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IGi9zuZF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72392-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72392-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8E87F1F24F26 for ; Tue, 20 Feb 2024 06:14:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E3D65789A; Tue, 20 Feb 2024 06:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IGi9zuZF" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 091235822D for ; Tue, 20 Feb 2024 06:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708409645; cv=none; b=fcuTRazhClp6iHXWicCiwkJ2iNRGQZOUjTmnxCkOwSDRgnf2AkTmxUC9UmhTvyKRbicHG0qJEpfHesWxBtHL7oBfzKexMvgG0+YMiFcOtCGqXGfZ3pf0ss4KSGqLjHWPgGX+TpzCh7oB+d/Rm2nmlcn0IBHCQnFbCInJWcbMGow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708409645; c=relaxed/simple; bh=im/xk8WtovhJ/os0s4GcpOv9OZ51L0bRmgYqEcvT6vo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cmNVXlfCJCSHxeaiMlCunwMmfgezAGQlYO9GxGEz77lUuiNAmTc+vc0qTnfPsAtg5uCZ9Ilroxe9Ch2dbKan90Uy+36v+8SAqdfG/bDn+xDZkSHkheKvF0z4EYHnsOjsvCEG4oSsMjvA4vsR8SSbFyJcxjK7Ks8HmpHHJ+/OsDM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IGi9zuZF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11421C433C7; Tue, 20 Feb 2024 06:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708409644; bh=im/xk8WtovhJ/os0s4GcpOv9OZ51L0bRmgYqEcvT6vo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=IGi9zuZFET8P9j2g0MUwu3V1H5u2I53toTuls49nsgr8KPPmo7gT428SUePHCtLgl 11E4N7Y8t+7nwp1qh5R4yWcog80dCcCIq4OsYGWbbabkGg5621LUAhGkHWdSrxtCqd OvrgY2L4zbzRuvIb0J1oNBnyRvoFxJjhJQJd2CXJQr6rTsiwlFgyVWnlfCXnWtIZJN 0HMw0ldBpMlQPDgFAziT99ZatOnHtzZFupMBXG3Z1RuQDYlu9FutWuwQHxm1RVweh8 mXDl3ZyYFX2M2PIdtm2U64KXYmsSVNPewpM0ruChyhjTErLL6oAQXfgVa6mIBAHyHe bYVKjHCuJGeBw== Message-ID: Date: Tue, 20 Feb 2024 14:13:56 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [f2fs-dev] [PATCH v7] f2fs: unify the error handling of f2fs_is_valid_blkaddr Content-Language: en-US To: Zhiguo Niu Cc: Jaegeuk Kim , ke.wang@unisoc.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, hongyu.jin@unisoc.com, Zhiguo Niu References: <1707103845-17220-1-git-send-email-zhiguo.niu@unisoc.com> <6f01fe1b-d580-4a2a-adc5-7eb3baebeb7a@kernel.org> <17c9e85a-54b6-4e1c-b95f-262c771b0f1d@kernel.org> <4bcf0a1c-b21d-4735-bf57-b78439a65df5@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/2/20 13:34, Zhiguo Niu wrote: > On Tue, Feb 20, 2024 at 10:36 AM Chao Yu wrote: >> >> On 2024/2/19 22:36, Chao Yu wrote: >>>>>> Please think about how to optimize this, which is really ugly now >> --- >> fs/f2fs/checkpoint.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c >> index 87b7c988c8ca..089c26b80be3 100644 >> --- a/fs/f2fs/checkpoint.c >> +++ b/fs/f2fs/checkpoint.c >> @@ -135,7 +135,7 @@ struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index) >> } >> >> static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr, >> - int type) >> + int type, bool *record_error) >> { >> struct seg_entry *se; >> unsigned int segno, offset; >> @@ -160,6 +160,7 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr, >> blkaddr, exist); >> set_sbi_flag(sbi, SBI_NEED_FSCK); >> dump_stack(); >> + *record_error = true; >> } >> >> return exist; >> @@ -209,10 +210,13 @@ static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi, >> dump_stack(); >> goto err; >> } else { >> - valid = __is_bitmap_valid(sbi, blkaddr, type); >> - if ((!valid && type != DATA_GENERIC_ENHANCE_UPDATE) || >> - (valid && type == DATA_GENERIC_ENHANCE_UPDATE)) >> + bool record_error = false; >> + >> + valid = __is_bitmap_valid(sbi, blkaddr, type, >> + &record_error); >> + if (!valid || record_error) > if type == DATA_GENERIC_ENHANCE_UPDATE && bitmap check invalid, it > is a OK case, but !valid > will goto do error handling. Yes, it looks we need to remove !valid condition to avoid error handling, and assign record_error correctly inside __is_bitmap_valid() for all the cases. > I think do f2fs_handle_error in __is_bitmap_valid is a good way. Let me revise the diff patch for comments. Thanks, > >> goto err; >> + return valid; >> } >> break; >> case META_GENERIC: >> -- >> 2.40.1 >>