Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp67503rdb; Wed, 21 Feb 2024 17:37:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWvuLhnueyIVmCSGm1VHs7S/98SBZvl274yoBXsZDqEJNpomF6hUfVuoklT/IyeHJkN/cUiYi/G34YG6Sfplf5f+7rDSkMuSUcrEdKulg== X-Google-Smtp-Source: AGHT+IGp/N8b/kBnPIm8Qz0qCeCpUUUcaVtIURXUmQYvaib6/bsHDsj5YgymTkDELHXdTZmh/DZy X-Received: by 2002:a05:6102:521:b0:46e:e03b:cd99 with SMTP id m1-20020a056102052100b0046ee03bcd99mr9437379vsa.21.1708565848106; Wed, 21 Feb 2024 17:37:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708565848; cv=pass; d=google.com; s=arc-20160816; b=NyxgpGEKyEC8Np/jTJDfFOinN+oCm0tZpLgT5PsSfvkrtfBlUB20Sr5ZsfKO10YHpi mq5n2i/dGnqoZVj5qIh2c7N74+rEMtqd11G7B9kGQDiTuntUz+3CjTDjZPXEo5oXJA13 jqei+S3pvUqi+4wCK4T2CxLSiUvL2lbglgmVK9P4YrmmEC3qjPFOP7zlNejCOuruED/6 fbGyF5N8GXaLpYSGvGDGoElgcXzlqGFA0WR134L9wedgqgKoxvjvNIDNBZ6R91ef1cu/ YttOyTi1kJbcOlcooZlRYQxn0driiSJ3VFQX+7M9ALGuyvZbqA824TB5oYgG4REi24aI qCIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=zbcmqlbQoJoNeLaxXAHlhunB0ATnBaqAAq0Z5bYtlVw=; fh=W6COFBd4BX4Q4YpnsinfP4Lifuq45kIfChsHXFM1YEQ=; b=xE3NePg4gPgLJ5MYiPrgp4DG3Bh1WUYlCrxZSGAHp7mttFzFSJtrzEpSBEZcmgr4GQ eRC/j3bCtgb1dX224hftyiXFq9qvkIVngVQkCXPtEDVVlJoFrBpON2ZUcwKaciX5CSaf 7ET9ItXSiV8m6jKOaJascufsygLYZ3C0KO/3j+YCNgEG9vYmr9gQjTtqC1DAfr8QNumL 4w0nFw269ffoF5fMErJ1W36EnTeZ8CNe+a2FVrDDl/cbwDEVIj2/hQoVFQ9+SZZkIiF6 FxhnrnKekq9YwkKOw+xauu94RA3kL7fyOwHZZrIHSG861TnxeL0Zj+S2RQzuf3NlQh87 SYoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BUMp+bj6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75772-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o14-20020ac8554e000000b0042c2eac1cf6si11178210qtr.720.2024.02.21.17.37.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 17:37:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BUMp+bj6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-75772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75772-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D84701C21636 for ; Thu, 22 Feb 2024 01:37:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A33612E40; Thu, 22 Feb 2024 01:37:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BUMp+bj6" 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 51677101F1 for ; Thu, 22 Feb 2024 01:37:21 +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=1708565842; cv=none; b=uwE7he7ZvXQV8OBkk9XlYFPTLMn7ntUSY69M3NntWcEvU37Wt1DRx/70/EtHSUYWQVtx0WRitBv0VeGAEf5SoZGyWRuh9AHpbGZSfaPvKFAF5WasqfOzamPU6TMdlNyiQATW8foIza1dUkljy4MaxnUEhhJAZBbYg7c1b6/G3v4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708565842; c=relaxed/simple; bh=PwtsuWG8E/oFESM40Xvr8zU779YojRz56nkBHgVSrRI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GimbNkeUIlZ7dKDlZz7+zEJOM+kVTS/dExkQakudBXKQS1bSJnqNtFk2GUBTOUu8RinTuu3nPRsCUkup/lK5mwe852hYchOnQAc35zum6TqWxTaT/aMBXElPCo7Nkhdj9B6oEVFSne3ntfr+2VwLrPhyZ1D2+05crCOAy6wI6uI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BUMp+bj6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 720F4C433F1; Thu, 22 Feb 2024 01:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708565841; bh=PwtsuWG8E/oFESM40Xvr8zU779YojRz56nkBHgVSrRI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BUMp+bj6BPcHoZLgv5pdktQ/EWXRevuaUPtFYlEICYHxgy5L1Tkca46yLu+5zQKIN PpzKahw6JzYh3LVEMAYvoN784KIChRNxArGJSqrdQwO9RdyK4TcBaLxk0UWF4YOw1C P/IdR+BWTxxLsEzR0uOmwQ1nSJh9PkqaHU9McK/68XdVi0fKP2p7YFQX0H1D8PO5tO F2HXq2Gk+SfNrVuUNDxRuWUJMz/FdeN9MLs5FFqorHs8FoWCen4g47U22iEtuwMDei c4abj1Q55+ZemaJ17vquvBMrwl9wdgG4TcHm+SgA2avV929XeEF9kSPs8p8qZOapGe 6pa8CQ5EMunzQ== Message-ID: Date: Thu, 22 Feb 2024 09:37:16 +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: [PATCH v4 4/4] f2fs: stop checkpoint when get a out-of-bounds segment Content-Language: en-US To: Zhiguo Niu , jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, niuzhiguo84@gmail.com, ke.wang@unisoc.com, hongyu.jin@unisoc.com References: <1708409484-27326-1-git-send-email-zhiguo.niu@unisoc.com> From: Chao Yu In-Reply-To: <1708409484-27326-1-git-send-email-zhiguo.niu@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/2/20 14:11, 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_NO_SEGMENT. > > Signed-off-by: Zhiguo Niu > --- > changes of v4: use more suitable MACRO name according to Chao's suggestions > changes of v3: correct MACRO spelling and update based on the lastes code > --- > --- > fs/f2fs/segment.c | 7 ++++++- > include/linux/f2fs_fs.h | 1 + > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index c25aaec..e42e34c 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -2665,7 +2665,12 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > if (secno >= MAIN_SECS(sbi)) { > 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_NO_SEGMENT); We should relocate stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT) outside segmap_lock spinlock, due to it may sleep in f2fs_flush_merged_writes(). Thanks, > + f2fs_bug_on(sbi, 1); > + } > + > } > segno = GET_SEG_FROM_SEC(sbi, secno); > zoneno = GET_ZONE_FROM_SEC(sbi, secno); > diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h > index 9b69c50..755e9a4 100644 > --- a/include/linux/f2fs_fs.h > +++ b/include/linux/f2fs_fs.h > @@ -75,6 +75,7 @@ enum stop_cp_reason { > STOP_CP_REASON_CORRUPTED_SUMMARY, > STOP_CP_REASON_UPDATE_INODE, > STOP_CP_REASON_FLUSH_FAIL, > + STOP_CP_REASON_NO_SEGMENT, > STOP_CP_REASON_MAX, > }; >