Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp440571pxb; Wed, 24 Feb 2021 06:21:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpNHCF6fXuv7/4hTUuv6EUQgonsRyaLR9R8Fi/wL0MJ806GTKZZ0rFRAndkmg10RJ8pRGz X-Received: by 2002:a17:906:c0cd:: with SMTP id bn13mr30195153ejb.368.1614176495281; Wed, 24 Feb 2021 06:21:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614176495; cv=none; d=google.com; s=arc-20160816; b=B6l0kz9pl3SzEVjDT2HUmwkjoSJtmvDCWArX0b6dRzyafnUf5g5mKGC4dxBUr0Skld DLDB8tU3uwZAzvZh+PNXjrW9lFVK1zohMTuKUECuQw7ge4YM8+k7mkXu/znRuokq434d +QtB04cakx+YK+YM3a7+5JSwqo+4/bYAtrLC1OnJd716DIme+ib8XKuBicF/d3/qMQAj EUYHUBobICLTjUPD9IJw2/iZEbcOk3+AAkiSCJ8aks1QNWlhwWJ0XekP1xc7OiSV8+Et 3afOrZWUmWBvLY5JnvIt78CaI4yXJRqgoKXU+2K1PRczOHkequ5fDyGv/1BTQ9SXfTnN lIMA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jeBm5LlXMSe0jZkbfBeXH54LbkyEROEz0MoEvsoPebI=; b=vv3aeRaqWYEbL2fe1Xjihk88hhRR9utqpO0nI6yPmWabBBcq2fsAqddpKnFcBo7+3K S/pdSKhPtzonTo41uM/PJ4bqdSmQFFORKkECzlZPA++497SiIqbRmquufMZpN1Lqr/As oL9SuVV7vmkAgzlOrM3bqdF4g6b1g4h4kZCmhV1+QTmMguQU9e/rhvD4/wyubQklcwcE ykqcTkBsMIEUw6YPE4i+UAZS+773D00WTzFT0WSgGNRUZswhn/3ui/0v7KUG4cD4+3B4 3bD+xM6OD5rX18D0kPJ5E4u0C+NjT+urOQ+4JxXciM+UVIRGFP6uBmW35AXxlkH04gIM hx9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Xv/tzTlo"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si1174812edc.288.2021.02.24.06.20.37; Wed, 24 Feb 2021 06:21:35 -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=@kernel.org header.s=k20201202 header.b="Xv/tzTlo"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236384AbhBXOQR (ORCPT + 99 others); Wed, 24 Feb 2021 09:16:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:59886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235318AbhBXNLR (ORCPT ); Wed, 24 Feb 2021 08:11:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AAE864FAB; Wed, 24 Feb 2021 12:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171330; bh=tTT3vaaLWFWUGeDSfPi7gBR6gJfFg8YTldsjtcflZV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xv/tzTloNmYxn0nmmMcyrL6Vp0udMenG866gLt7jaR9SA+AIudcpk20g9RJOZFIOD sXA+khe3qigtADTbltXAMpPErSvXygy/BFIRAj+rVSt5En/QrUgxfN0uqHdyA/LiBI x58GHPVX65Uzpsz5jYtljk4nCqnPOV5tzmMFbtM5Go1JgF/gYTXdH0dJGY7IgJpvyw ZlT2ccdrQUna7rt5QgqZepBrSP06BTuZBJO7pD7ZLWckCr9IgVJljMYJ4q982bbZY7 rrmrrmO/6ROvOVB7M9BU6Njb9xAAXJPzfJOFIytdhTwsTzhYb/AEeHozgy17+RuuKk 3CnOxInF5LmBw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jaegeuk Kim , Chao Yu , Sasha Levin , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH AUTOSEL 4.14 12/16] f2fs: handle unallocated section and zone on pinned/atgc Date: Wed, 24 Feb 2021 07:55:09 -0500 Message-Id: <20210224125514.483935-12-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125514.483935-1-sashal@kernel.org> References: <20210224125514.483935-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jaegeuk Kim [ Upstream commit 632faca72938f9f63049e48a8c438913828ac7a9 ] If we have large section/zone, unallocated segment makes them corrupted. E.g., - Pinned file: -1 119304647 119304647 - ATGC data: -1 119304647 119304647 Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/segment.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 0d46e936d54ed..00c415131b069 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -91,11 +91,11 @@ #define BLKS_PER_SEC(sbi) \ ((sbi)->segs_per_sec * (sbi)->blocks_per_seg) #define GET_SEC_FROM_SEG(sbi, segno) \ - ((segno) / (sbi)->segs_per_sec) + (((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec) #define GET_SEG_FROM_SEC(sbi, secno) \ ((secno) * (sbi)->segs_per_sec) #define GET_ZONE_FROM_SEC(sbi, secno) \ - ((secno) / (sbi)->secs_per_zone) + (((secno) == -1) ? -1: (secno) / (sbi)->secs_per_zone) #define GET_ZONE_FROM_SEG(sbi, segno) \ GET_ZONE_FROM_SEC(sbi, GET_SEC_FROM_SEG(sbi, segno)) -- 2.27.0