Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3972332pxb; Tue, 25 Jan 2022 00:20:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+fHsQAF0Ewks1WJjkLSvfaDJC+qrt2lgyxxgtz7z+wEr7SNXgsvc2KM+pm11U5i/bDh2v X-Received: by 2002:a17:90a:34ca:: with SMTP id m10mr2368328pjf.38.1643098801974; Tue, 25 Jan 2022 00:20:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098801; cv=none; d=google.com; s=arc-20160816; b=UYg+0luQxDt1BURNccZRv2sreLbcGd69ZMszDTVT4wUcWAq/Jj1Uey+c8/xoguCUPo SysKgAZeCi6eMmgtnrLhd287LaxZn0OjGwE8bA21LQHPzyc9I+I9/OS4PiBqXOc1AUUj sh+wRJLk8IYh459rSOe1fAD/19DK8MvQoA5cfh9WwwZDy6JD0+mrYBTYx9UeypjqDG/a 3Soc51Uta2WkgHOjQTEaz2CalBfcWFLGpj3EbYQ57hSRNKBEoQ43Lvbh1z73xmSOZJ3l b0yr8vHqJR6AT6ZXuiN2HMN8596i8DPROT76QLrZec7GMsf9Uda8ZfwVxD8/Sce5zAs0 p8Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iX13QL6JLVV6AxFiJLuQdErTWWZ9wxlgokVHhaAfDhE=; b=hSZLwkFTv1uZGpAIK/zSj4nm5j9M2rvF1Ih2hIwjGFHij1L5bq9EdTTtc0eewXmCcg fOV/cmZth3lEuyT1qOlZQBEEJr67LW+j31T3w9GNViBnPUaOUdh4cprIFPon2dzsoBnk 8uICSSlkbEbGU5tOFB18xIbFODlXGX3lvu/nRNn4jELs0IyOCY/Hv6Ks7C1mdoKp9k5f gN4ecWHnkgj7i+FrHY8A/9u5iKSASNjIyPdCYDuycyNoJFzkS/MVK0kK69ZFHWCGny4Z EvNhgK3xwFMOnLZy/cAAb9xjgCsPz1PhFzlImzBZmfUK95FbgyqIF/ruY6k3mB7s3KMU 6EpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=joH1g3i3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n193si12911060pfd.121.2022.01.25.00.19.50; Tue, 25 Jan 2022 00:20:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=joH1g3i3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3413511AbiAYAjO (ORCPT + 99 others); Mon, 24 Jan 2022 19:39:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2363975AbiAXXq1 (ORCPT ); Mon, 24 Jan 2022 18:46:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C997C034004; Mon, 24 Jan 2022 13:41:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 28E0661491; Mon, 24 Jan 2022 21:41:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F31F5C340E4; Mon, 24 Jan 2022 21:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060469; bh=clJKJIMLveFPr341YCQwA2mBwhvvUxBYHR+Sa1luDz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=joH1g3i3h+XhkHuOmqoqDlVDfsPGDrEKPUOpqi3eBUeyd4yW7shZB6Lzd9u4fh1zD 7XDKAwevdZ7PXBSOMKi2nBAUK7Fbri2g4HrmpGYGlgmOfdXkw2ZsbMT9NKksFT8Lbz EJNpyIaWiKg2Ab3Moh1tqkLYs1E1BgjQvzgkAQAw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim Subject: [PATCH 5.16 0958/1039] f2fs: fix to check available space of CP area correctly in update_ckpt_flags() Date: Mon, 24 Jan 2022 19:45:47 +0100 Message-Id: <20220124184157.498540022@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu commit b702c83e2eaa2fa2d72e957c55c0321535cc8b9f upstream. Otherwise, nat_bit area may be persisted across boundary of CP area during nat_bit rebuilding. Fixes: 94c821fb286b ("f2fs: rebuild nat_bits during umount") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/checkpoint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -1302,8 +1302,8 @@ static void update_ckpt_flags(struct f2f unsigned long flags; if (cpc->reason & CP_UMOUNT) { - if (le32_to_cpu(ckpt->cp_pack_total_block_count) > - sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks) { + if (le32_to_cpu(ckpt->cp_pack_total_block_count) + + NM_I(sbi)->nat_bits_blocks > sbi->blocks_per_seg) { clear_ckpt_flags(sbi, CP_NAT_BITS_FLAG); f2fs_notice(sbi, "Disable nat_bits due to no space"); } else if (!is_set_ckpt_flags(sbi, CP_NAT_BITS_FLAG) &&