Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1483804rdb; Mon, 19 Feb 2024 18:36:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWqzaIaZ0vkK4UfHJKvf6Fu08ar/Vy/m51Ku4PWl2L0/6D8wS9U1yk0e6eJNj/N+5zX/2k90wh4FlPkjUF41lk8eUv395QBeJbB9JZTtg== X-Google-Smtp-Source: AGHT+IFsMEP5IklBjsxcP6HjlTv4RBegO+lfC25d3tEYxfRAbob1WchGYFsW07Mg0PyXjAwguTCo X-Received: by 2002:a17:902:efcc:b0:1db:c390:1fdc with SMTP id ja12-20020a170902efcc00b001dbc3901fdcmr7464655plb.1.1708396611677; Mon, 19 Feb 2024 18:36:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708396611; cv=pass; d=google.com; s=arc-20160816; b=k7Ujs956IaL2eIK6y/BQxrpgfJI+Q2AEsweWNWArnwvWFLEn+Y173K+BbqUXMbkItc /mxkF9FOLUPNxSCyiuxioKBnX2ChIEiz5zeiFboRSJNtKUqslgioiTiSaTZicx3lzh5k Aks6eGFVsfinuR7iOLH6xBE858aULZQLFP47DKJOOj+5iB2wZ/Ti42LWw1UQK1L9PeIv e7+zcdYIFt/hzYeqnsnIspzqHfxdSVaMm2WfcIV6V2BTP6hZP4zDClJyfsapmywusSs+ GETmulcxsB+69YqZQaAGo9lA8lhhFUS6tVa3jv/JzUaUMY3Q27ybSzc3QzzdY0M3wU/U xnJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=OeucudTczSKOnladSFQIbjhIHwAJ5KzM8G4n1miPrq4=; fh=HgIJth7vLaS1hsSS+8bCwbyH6nCGEjdoQ/3vlNbKvFM=; b=vSM89gU+T4EWTw+4hRgGKH1AQcmXFTRoxvX1SxSesGs/BDw3htZrPXsmoURkZNLbUd asw0P6rOLTsrVATDjmSrfO19A1yxrxubXYZyFZHRJVYoJhe4Avw3rniKJybLUXcxy7xJ bTudGdZ1S8lbGZcDZyexCuam37qOwkZliKkyI3BkdM3yauWIfLK+6bwGt/n27NoxaVXX kbnYsujm/laKLkb7LkHWL5QEnllxsXWIVs2zb8bhQmvin7HKthwKynBd9mHN6FrijJ69 BaoAedhztbxBEmAr+VHFETxTI5hRcK3q9fBEaVCJNhyk9gavrYLBOCHh9apkZwQa2FU1 OuFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CFF+bwTk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72220-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72220-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e11-20020a170902744b00b001db45912e65si5262225plt.501.2024.02.19.18.36.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 18:36:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72220-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CFF+bwTk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72220-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72220-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 61CB4284CFD for ; Tue, 20 Feb 2024 02:36:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D44A2C1B9; Tue, 20 Feb 2024 02:36:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CFF+bwTk" 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 AE6298493 for ; Tue, 20 Feb 2024 02:36:44 +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=1708396604; cv=none; b=j/ICtO+VA6j30l5KIRS0YDpJJbXhCBttpUWym6+KsGXavyIDae4AVozsH0JvLqp9pVZTJItt4hKgE0IF42mP+RwLA6dMjhloQjAxXySXyesvLwNqDSaUuOEeWGPWZTX5/IG9XmTA3mXKiP6lqozOVK8WYYp+NKsNVLOsDwylX0o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708396604; c=relaxed/simple; bh=iSqzuEwP5M5h88YQ8/0qjtxCe233s6JS7YQMV0b2XT0=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=kscm3by7NL2gkAUiuTtrnv/Rt62rsfRhCzq2jEIKx6OqPKrE90bjhd36nobeAVw9FhCseQW5yR0zd/wdFpShgmD8W5hdhe2DPU9e/mLKWQgrJsp1yUgWljeCPKRo8mCGwogHxTbO7fQuTXfq9gW9u9Wtyf6Z12KFhKe+2X6wAXM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CFF+bwTk; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50C43C433F1; Tue, 20 Feb 2024 02:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708396604; bh=iSqzuEwP5M5h88YQ8/0qjtxCe233s6JS7YQMV0b2XT0=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=CFF+bwTkDYEfAGpoNEmpskKPYUwflaqHqw2rJ+jEHkpin693UEE3uhkcmzzKxn4q4 Q3uVA7eXjoc2mMdK5nFTqjEdJsjweTE2HVOF2zcmfR9xTylHXy2Xm51rkSZr7StZl/ w5Zi1ZQl+gWFOAQdwYMHt25duTo2eJDfMgSYa95lVhURM42tf9zF8ccptG0K4pH07A b0bUdk/b+qMpu8DYejrUW2eu/26FQ58O+UcNl6ZIx2VYIlpWQm5FFD3NCWrdmENfz0 DqhwhqSUcwfuRbXZLcsm3VPRcj9/Ldnz/mAGGRskBUt74vZzseZveYcBzMCLPj16Qd 1Zd2V5BCYj+Yg== Message-ID: <4bcf0a1c-b21d-4735-bf57-b78439a65df5@kernel.org> Date: Tue, 20 Feb 2024 10:36:34 +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 From: Chao Yu To: Jaegeuk Kim , Zhiguo Niu Cc: 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> In-Reply-To: <17c9e85a-54b6-4e1c-b95f-262c771b0f1d@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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) goto err; + return valid; } break; case META_GENERIC: -- 2.40.1