Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp298436rdb; Thu, 22 Feb 2024 04:19:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWYouXRMy4be5e8cKT6VQZGuxCdMKu2v9Xq2MBeYN7mPDsQ54MD7LVRB7LoZhKcunsKJ0XCV7GcFz8wB+lCk4mIx6BgsXSATHAwCSd9Vw== X-Google-Smtp-Source: AGHT+IFMBrjaYq7yRaucYCp197bP1oUGIdRyZ1+a7N1MGWHbP8O7OEo/6BhSnGkhPYtKXqqHfhtf X-Received: by 2002:a17:902:a3ce:b0:1db:e494:4b4c with SMTP id q14-20020a170902a3ce00b001dbe4944b4cmr10348861plb.1.1708604354934; Thu, 22 Feb 2024 04:19:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708604354; cv=pass; d=google.com; s=arc-20160816; b=h8VUmwHh1o2v5jaBu0zujcEo4mR6oFPisBaoUljBF51lgJWah62H59SIWv/VC+1qEN d2kg0btiabqLJDbTBeaLF+MOU8io62MqkUiuIizrmHUCbDK+pQLte8oC+lgSCNw3/gTT qq57tcXVN3IoZd9u5R/s94i4tB7Fd6OJuY7yxX5B3ESfdBbILEXn3kuU6Us+h73bwglD DO+JFU4MehBOfMWXPs71olB6MWMzpUNRnQK+v15OX2Fpi+aJ3OHtZCaQREQfhTsVd2ey i5XownKgbZDpSFlVfUrvVAH4fq2+zztG39hRx31HorusU5OjTFQ/my8wFNjw3BUaaBpu PbJA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i8-20020a170902c94800b001dbfebb55fcsi7000883pla.179.2024.02.22.04.19.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 04:19:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76496-linux.lists.archive=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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76496-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 463172889E7 for ; Thu, 22 Feb 2024 12:19:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFE5860BB9; Thu, 22 Feb 2024 12:19:00 +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 ; 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 To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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