Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp420115pxb; Wed, 24 Feb 2021 05:56:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwR2jayE266a/37rF79g8PN4D1+QHjRikIsqaFMiABMeq2MrH9/2wkghCv7prQQmEOn/MN4 X-Received: by 2002:aa7:dc4f:: with SMTP id g15mr32062789edu.184.1614174984894; Wed, 24 Feb 2021 05:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614174984; cv=none; d=google.com; s=arc-20160816; b=ZNtG+yR0IC/APRxOTPt/T3cI4XuQh1PKVVdd+kI/0yqfl/EUPyd6kkmPmWrfFl0q9h v0q9bo4j9gW6c7SibDUoJO7ny8X9bzRpSicE88TMv5sn96IT/ooXGNVhfAzjOPxM0koo IrDUxbc91WxudvtkhC60/xG5oGNA/wWmq5CTCfFEmas/bG3U5tS5y+3dAXLuXQj6APmZ jhU8RFvoHNzzdEWwpPbl6n+bF54ZiPSJxlnQWjEkxuweG4YRJsFT/c4mdWDDxZRl0t88 MDyNa/ixd/PnclokFb21B19jq493LIx/+MLLzxCoue1kEnWUX7Yxc2grXg6QLk3u0aWM vIuQ== 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=r559HUYycb69vb718k0xoZMbWa9OdnkoVHpYdNdc6Z8=; b=FOhBg58wpbeE0U/ySzQzoOfZ74BNCoC9XDDFJrzl11Whth1ttj/97KsiiK0xXPzsIN 5PArsX6VHAxIIyq3snH/L1rF9xf0L93O1dgx1iho/HFdgmnKX6c7jZOJZNW1RvF+LLEs 7YACZiyQ9H7xLB6pdXW5Z59wB4jqKB0a5aXVVEJGRJKZNwvbkZZ5HVU/3SkjlL92M7YZ xJg1TpZADND9OfHx+HGJRGlzDCRW9cHliNxpeIj699I8KIhN0oN1FQJ7IK1qxOiOwxFZ GcALBVHmrKpOwkm4SEVM0plr3lp2PEDknF9OlaDtK69bL4+4FtElt1cVZL6i3HAP4QON MBlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tmcEQW+w; 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 l20si1382819eje.712.2021.02.24.05.55.54; Wed, 24 Feb 2021 05:56:24 -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=tmcEQW+w; 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 S238058AbhBXNuJ (ORCPT + 99 others); Wed, 24 Feb 2021 08:50:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:58106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235744AbhBXNGH (ORCPT ); Wed, 24 Feb 2021 08:06:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F157364F84; Wed, 24 Feb 2021 12:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171252; bh=ehgJ3IMWWrx00CYOP8miAjtNa1ImwWvNCz/P8PnmuXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmcEQW+w/RQ6gNd3lGVFghYBEBL1SV3rhb9Ha1PgBZAdTaa6QyvzOd8uB0jb0q9ZV v0vvqnMhGxuH2YLvghbmzjt7D2ZLob/aycZ3XJtHzdNux2flr01dxm/RmHG8YxEaem P0bR+HcC8jR0KdR6auCCUt98l7EiUPyUzU2/4KonGoIOxGABY5lZK2/YtvK21eVKB1 gBflfIJc1SSKjWyBfrr2ZQDV4mBaTOieXP3dNkvbl2rIG6YZze0IAoEI4UwyMdJMGr Xq4RizFcqh18SknnodToTmCQK9T9Cd91bLsAwJxLWRob12K0shJaZXa3aDApIBLjg5 3y80EM8mEvXHw== 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 5.4 23/40] f2fs: handle unallocated section and zone on pinned/atgc Date: Wed, 24 Feb 2021 07:53:23 -0500 Message-Id: <20210224125340.483162-23-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125340.483162-1-sashal@kernel.org> References: <20210224125340.483162-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 325781a1ae4d6..2034b9a07d632 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -88,11 +88,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