Message ID | 20240222121851.883141-2-chao@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-76496-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp211410dyb; Thu, 22 Feb 2024 04:19:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXjy6O6GFEm0QOM0HisLnYPtATUv09LZuRUrvf6g+/zVLYGOxCfU30toSWGdgdovhMrJ+kRpejutAqqzRlbEXN+NCYP2w== X-Google-Smtp-Source: AGHT+IEZzVbWHaBvdebgiN+iges2hXpjIpE8UeJ9CIV+oTPwi+scqc63GPNksA83VhLKhOJ9hJsN X-Received: by 2002:a17:90a:5606:b0:299:2924:8bbb with SMTP id r6-20020a17090a560600b0029929248bbbmr16471338pjf.11.1708604365409; Thu, 22 Feb 2024 04:19:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708604365; cv=pass; d=google.com; s=arc-20160816; b=iL5RGCVl0jhi1/mk9xrt9+dfic1+9UkgStf6E1FvKKgWHaaM6Kre7nFt7ezdEzo9y8 wtOOsOaLlbvwC8NK66Gkg3yyhC50wtZAeE900gxFnq1o9X7tFzsIOcWKCMcDqueK78KF sZ/Sizuxeurjax8PeT+6flwNcKJi2/aatFCyyWqk27pqzGfPwKi+hPFy7Sc/M2aFALnS TbDMi3jQETQcvvYPhXYUljNh6NDhlfAPTEhiFqrMWgviZctVe1Jpiv3Zh9i+rteaxidB xseEpCXXNrIj5e9IY3f5ML0XypigSTMWRv7co7+cYB7KNAfWixochYfV9bVYgNnxP6KQ kEbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=egF2uKlkrZrFqBU0WSciNeTzO1/Wffz3bqGISsIOh4Q=; fh=X1/oBJvTGJUQ0YtRp03u+3tPfRw/dXXALWynfOSlfQQ=; b=BuIMxf8yDQsQXdIt8v7AG1G0IUlqjfZtMxoVoxaH7qatTzk41sroDwWD6I7ni5qoRQ H941FKlmpbAdIJdZTFcaUwq+S3O+FpV7tn12+pxGki4GU4cWM7d3y+tybOGglulA+YVo DYwb4bSIltGpJMZgaojhglReHxElV7QBOVj4Ad3UTn+Dx0FqANSqRmsdFc46HTAKRKnt yQ0Owjo2q7D2jRTNb1vp8jEutMpPviA+mAjfMO03NzCZuGxII0bZdzLaz0fcwhIjs3zY eioRqkjwHdGA4sjTdnQJXpNhtEEIfGItOQQUBNsCTQVXDijdloHpnxqfozPowfvxOTXb S+1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mDPZhRsl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76496-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76496-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x59-20020a17090a6c4100b0029962d0c910si3322848pjj.62.2024.02.22.04.19.25 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 04:19:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76496-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mDPZhRsl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76496-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76496-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8C846288A1E for <ouuuleilei@gmail.com>; Thu, 22 Feb 2024 12:19:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB6F0612D0; Thu, 22 Feb 2024 12:19:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mDPZhRsl" 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 EC21E3D54D for <linux-kernel@vger.kernel.org>; Thu, 22 Feb 2024 12:18:59 +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=1708604340; cv=none; b=NQaH3lpqkrfYFjLFxv1H0WeQHJVov5QA/K9ClLBPas2gIvq9tJ6OuJ26gB3oNEGgnQFrQMJuB6FF/g/6as3aujKYpt8mZWKxlLme1rE8uvr4xC8PUTpqPo4AcRdJFIj6Eg3bHveYv5oalHDLFUWDV0rhkvUwy5tJRpdY8qluS6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708604340; c=relaxed/simple; bh=kfTRBKt4Nbx/JzbJcvx90tf0O1Cn9EETCkS6TLsrw28=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K3hotsL/J/HVVNSnWEaPlazkTzWDcblBsVD8QLwX2VGxNm1YSW8x/c6nPEZaYjDHObhH2S6QvN9sy/ek1HtB6CuAmQVen/PeGcJWnHLoAyU99sx/QDW0vfeavZjCgrf6Key8UXTjmpC3tbsqVaiyyhKQCW0YgQiVNlQw34NWiiA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mDPZhRsl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47646C433A6; Thu, 22 Feb 2024 12:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708604339; bh=kfTRBKt4Nbx/JzbJcvx90tf0O1Cn9EETCkS6TLsrw28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mDPZhRslysG7G8AyvkqI8r9ViKpQOP+RQuHHkMeCIcT4GE6xkcFtwtOUwLrA0HTcl e4fhoauXNziXTHN2W1w3JUYD94c04YFog4zl54zZ09EZ6jcyrTi7wexP0TnXtj41nF pZTBiZLeS/XcY5dcSQtyG4jIEVKsl2UBDJqWeNyV9VuhMGrKpv/KdbsVKrGscfycZs QhzasHFMgiDW5BvPoK7K2rKzb71cWIRmOZQwNRDpSSzgNP/yAm26lcgVx8YVM2n2+f DDU+YdTK9Ami/i3bRM0Z+vfc8fG5QArg94/tJ+r/12G9OJ4dloiaGhIVHElja3U7FB kkEf90HRJXeuA== From: Chao Yu <chao@kernel.org> To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org> Subject: [PATCH 2/4] f2fs: fix to don't call f2fs_stop_checkpoint in spinlock coverage Date: Thu, 22 Feb 2024 20:18:49 +0800 Message-Id: <20240222121851.883141-2-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240222121851.883141-1-chao@kernel.org> References: <20240222121851.883141-1-chao@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791601531305147697 X-GMAIL-MSGID: 1791601531305147697 |
Series |
[1/4] f2fs: delete f2fs_get_new_segment() declaration
|
|
Commit Message
Chao Yu
Feb. 22, 2024, 12:18 p.m. UTC
f2fs_stop_checkpoint(, false) is complex and it may sleep, so we should
move it outside segmap_lock spinlock coverage in get_new_segment().
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/segment.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
Comments
On 02/22, Chao Yu wrote: > f2fs_stop_checkpoint(, false) is complex and it may sleep, so we should > move it outside segmap_lock spinlock coverage in get_new_segment(). Chao, I merged this patch into https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=f3b576d209983b5d6e1cb130bfc8ca1f0bbcad6d > > Signed-off-by: Chao Yu <chao@kernel.org> > --- > fs/f2fs/segment.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index d0209ea77dd2..8edc42071e6f 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -2646,6 +2646,7 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); > bool init = true; > int i; > + int ret = 0; > > spin_lock(&free_i->segmap_lock); > > @@ -2671,9 +2672,8 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > secno = find_first_zero_bit(free_i->free_secmap, > MAIN_SECS(sbi)); > if (secno >= MAIN_SECS(sbi)) { > - f2fs_stop_checkpoint(sbi, false, > - STOP_CP_REASON_NO_SEGMENT); > - f2fs_bug_on(sbi, 1); > + ret = -ENOSPC; > + goto out_unlock; > } > } > segno = GET_SEG_FROM_SEC(sbi, secno); > @@ -2704,7 +2704,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); > __set_inuse(sbi, segno); > *newseg = segno; > +out_unlock: > spin_unlock(&free_i->segmap_lock); > + > + if (ret) { > + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT); > + f2fs_bug_on(sbi, 1); > + } > } > > static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) > -- > 2.40.1
On 2024/2/28 1:50, Jaegeuk Kim wrote: > On 02/22, Chao Yu wrote: >> f2fs_stop_checkpoint(, false) is complex and it may sleep, so we should >> move it outside segmap_lock spinlock coverage in get_new_segment(). > > Chao, I merged this patch into > > https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=f3b576d209983b5d6e1cb130bfc8ca1f0bbcad6d It's fine to me. Thanks, > >> >> Signed-off-by: Chao Yu <chao@kernel.org> >> --- >> fs/f2fs/segment.c | 12 +++++++++--- >> 1 file changed, 9 insertions(+), 3 deletions(-) >> >> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >> index d0209ea77dd2..8edc42071e6f 100644 >> --- a/fs/f2fs/segment.c >> +++ b/fs/f2fs/segment.c >> @@ -2646,6 +2646,7 @@ static void get_new_segment(struct f2fs_sb_info *sbi, >> unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); >> bool init = true; >> int i; >> + int ret = 0; >> >> spin_lock(&free_i->segmap_lock); >> >> @@ -2671,9 +2672,8 @@ static void get_new_segment(struct f2fs_sb_info *sbi, >> secno = find_first_zero_bit(free_i->free_secmap, >> MAIN_SECS(sbi)); >> if (secno >= MAIN_SECS(sbi)) { >> - f2fs_stop_checkpoint(sbi, false, >> - STOP_CP_REASON_NO_SEGMENT); >> - f2fs_bug_on(sbi, 1); >> + ret = -ENOSPC; >> + goto out_unlock; >> } >> } >> segno = GET_SEG_FROM_SEC(sbi, secno); >> @@ -2704,7 +2704,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi, >> f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); >> __set_inuse(sbi, segno); >> *newseg = segno; >> +out_unlock: >> spin_unlock(&free_i->segmap_lock); >> + >> + if (ret) { >> + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT); >> + f2fs_bug_on(sbi, 1); >> + } >> } >> >> static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) >> -- >> 2.40.1
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index d0209ea77dd2..8edc42071e6f 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2646,6 +2646,7 @@ static void get_new_segment(struct f2fs_sb_info *sbi, unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); bool init = true; int i; + int ret = 0; spin_lock(&free_i->segmap_lock); @@ -2671,9 +2672,8 @@ static void get_new_segment(struct f2fs_sb_info *sbi, secno = find_first_zero_bit(free_i->free_secmap, MAIN_SECS(sbi)); if (secno >= MAIN_SECS(sbi)) { - f2fs_stop_checkpoint(sbi, false, - STOP_CP_REASON_NO_SEGMENT); - f2fs_bug_on(sbi, 1); + ret = -ENOSPC; + goto out_unlock; } } segno = GET_SEG_FROM_SEC(sbi, secno); @@ -2704,7 +2704,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi, f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); __set_inuse(sbi, segno); *newseg = segno; +out_unlock: spin_unlock(&free_i->segmap_lock); + + if (ret) { + f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_NO_SEGMENT); + f2fs_bug_on(sbi, 1); + } } static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)