Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp651525rdh; Wed, 7 Feb 2024 16:18:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbPzuiI+2HNhOZr0GOukwULEkxWMKSElXYkV4EasLMTjQIUT8GwGE1CHTpRRk82TFQ0LOQ5OA67XUEP2hgJvjONeidu98HZNwnfZJvgQ== X-Google-Smtp-Source: AGHT+IHqDccLML6sk43gyXvkKIVRPD0CSF3xmGZBBkqQVWd4MjlSr7s5fVWa3bbmh9T0iOHIs4mT X-Received: by 2002:a17:906:53c4:b0:a38:5b3c:7c9b with SMTP id p4-20020a17090653c400b00a385b3c7c9bmr928683ejo.18.1707351515567; Wed, 07 Feb 2024 16:18:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707351515; cv=pass; d=google.com; s=arc-20160816; b=gfnOxCLM7SRLsnLEiygazLh7DzlId78dSRQplVUNSTM80x7RpJZXsXsg+JaiBIYY7h kCKsEww6VOSW120ihHZFKsZHZWvhq2+AyqnlUG6XGml3o7zzD8eJvkEk1ghcHlJOXqRQ fi85GAkdtNlqPlyrVsnyilQqMAP2iSjGEvbFubImQy3AFMkt/pybnEOZy4i+FpLX+I4+ VDfXdhw9r5ELO6gJVe05UsCxKtjCvZR+Cgri7RTMtFYyXCQPBhNF0u17O4G19HyqNrpK Xur8L4HdHK2yOTC4GI1uMeF1M+iFSyb2sSAbRRWWbkTJ+/6REOiH3vklWAbr6KFUzVE1 Elxw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wsjZZoiG5KTBz2iFXb/gdtjQVB57krENnMRb7VLv+TY=; fh=LappKOQwibGJW36zQyxCab0XN+24z2F68seAFyeja5I=; b=0EcMSmm6D6o2QHAhMQYxj1nxUrZrfvDJGNt//dnl7brclNBZTJAVdHnaXR+pkPg3Q7 Sg4ZeZCMD8PcrSCy/a1TsXPVsRGXSalSJg/dxsRPvgzlSChJNT6KLomWt/jglpl2Vw0U ++FZ890ps6hsVbYdswVDPcLjCbagJy8GZVklabB+oD6oz8qGt80NXl9CVIZJ2ZO5Xw7o G8fToRAikdSrAO8Oxe1qR3wMFkiUGeAqpA0nYkDRnQZuSd/a8YH7v6AJVo9QqdHNxWay uiHMBzOuQ/DY4Nj/949tp2QVQevm5uNx7jjZwKcYfzCTvWzN9Dt6kfa+4y3kKQqZu2Rn fBHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EQzIFv1B; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57329-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57329-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVfazKuHuRi/Cu0k77FD83u5zn8KIoHL+eqZAx7MYjn5Rx37z5Yqoyv7IAW/rCKDS9pbNJ6Z1NHm4Oxj3Ao1QAPkAooccByDrGOP8tm8Q== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e7-20020a170906248700b00a3b4fab9a34si107193ejb.991.2024.02.07.16.18.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 16:18:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57329-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EQzIFv1B; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-57329-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57329-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 4ABE91F21559 for ; Thu, 8 Feb 2024 00:18:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBE4B1E535; Thu, 8 Feb 2024 00:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EQzIFv1B" 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 E30781E49D for ; Thu, 8 Feb 2024 00:16:58 +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=1707351419; cv=none; b=D8rtuwimPNjLGw9sJ/89nDb4cQeyIY5g4dIPfQREj9PUjAVraO8fpI1oBCyleTlR/OA3pEfbNUhTjt1nVH61X76TIgel2sar8PTDZgSAPlYuqSyvaMG9VMN/ygnXPINBlbHVRP5DNvRKc7VCQS+4qpH63PfHoXT4KZQYVRIsAc4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707351419; c=relaxed/simple; bh=2egm5jFqueRjaknu6E3h71ZQadfGobiAaLx45nwM9Hw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kZF2lGfU9Pp3hZagEbgx/JO6OxMnf53QinUAD21cO8X91i2R7E3b7pUPLAaBC4mmAk0wsdQaqs7Vswt0QjPr79YqBKgP6PHVYmy1UL7tZCr9Jk5IRBpPDR5z9dSxYjvvFJcAaEV63V/AVLlDBpUt4lMr1CSQSY+RxnneYGA/tz8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EQzIFv1B; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F04FC433C7; Thu, 8 Feb 2024 00:16:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707351418; bh=2egm5jFqueRjaknu6E3h71ZQadfGobiAaLx45nwM9Hw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EQzIFv1BZLrFWf4h0rnDxPP9adLZD6yoVFpeVsHTIpdoxkKoChEcGwXyQh0Zar9x5 3qdzFj0z5ciW4kd15ko/hCrAuZbN1yc2cTa+jckrKHdKQgr0q08er/c2FPOfTApzV3 1bSnlCsMZ9eIYTD/3wGAth+cZ4u3DNOY6VCympad9heCzANDrZQkLk5ADgZXRjwkPe /qeZJPMpJTRulmKCPtWpHnIFs3G5XvlOBE/oyAVb1XhwWxtrYUdhk3iMHnJPlvJaJz 4EPM2jzGQtnM6NigHZ8Okd3SWrMVecicim94SFd0Q4SBrzos8ltLrrE7G5pbHgUo3F BeLWyix3PJghw== Date: Wed, 7 Feb 2024 16:16:56 -0800 From: Jaegeuk Kim To: Zhiguo Niu Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, niuzhiguo84@gmail.com, ke.wang@unisoc.com, hongyu.jin@unisoc.com Subject: Re: [PATCH v2 4/4] f2fs: stop checkpoint when get a out-of-bounds segment Message-ID: References: <1707271264-5551-1-git-send-email-zhiguo.niu@unisoc.com> <1707271264-5551-5-git-send-email-zhiguo.niu@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1707271264-5551-5-git-send-email-zhiguo.niu@unisoc.com> On 02/07, Zhiguo Niu wrote: > There is low probability that an out-of-bounds segment will be got > on a small-capacity device. In order to prevent subsequent write requests > allocating block address from this invalid segment, which may cause > unexpected issue, stop checkpoint should be performed. > > Also introduce a new stop cp reason: STOP_CP_REASON_OUTOF_RAGNE. OUT_OF_RANGE? > > Signed-off-by: Zhiguo Niu > --- > fs/f2fs/segment.c | 12 ++++++++++-- > include/linux/f2fs_fs.h | 1 + > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 6772ad4..6fe2baf 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -2666,7 +2666,11 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > if (dir == ALLOC_RIGHT) { > secno = find_first_zero_bit(free_i->free_secmap, > MAIN_SECS(sbi)); > - f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); > + if (secno >= MAIN_SECS(sbi)) { > + f2fs_stop_checkpoint(sbi, false, > + STOP_CP_REASON_OUTOF_RAGNE); > + f2fs_bug_on(sbi, 1); > + } > } else { > go_left = 1; > left_start = hint - 1; > @@ -2682,7 +2686,11 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > } > left_start = find_first_zero_bit(free_i->free_secmap, > MAIN_SECS(sbi)); > - f2fs_bug_on(sbi, left_start >= MAIN_SECS(sbi)); > + if (left_start >= MAIN_SECS(sbi)) { > + f2fs_stop_checkpoint(sbi, false, > + STOP_CP_REASON_OUTOF_RAGNE); > + f2fs_bug_on(sbi, 1); > + } > break; > } > secno = left_start; > diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h > index 053137a0..72c6782 100644 > --- a/include/linux/f2fs_fs.h > +++ b/include/linux/f2fs_fs.h > @@ -81,6 +81,7 @@ enum stop_cp_reason { > STOP_CP_REASON_CORRUPTED_SUMMARY, > STOP_CP_REASON_UPDATE_INODE, > STOP_CP_REASON_FLUSH_FAIL, > + STOP_CP_REASON_OUTOF_RAGNE, > STOP_CP_REASON_MAX, > }; > > -- > 1.9.1