Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3038371pxj; Mon, 17 May 2021 16:11:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2eB0xh3h93heCodM1LeVu/kYpD7o2itc8rIIpSUp9x8Bv3VO8nOidGgU4CdE0n45aQE6x X-Received: by 2002:a92:2a0a:: with SMTP id r10mr1761802ile.274.1621293073910; Mon, 17 May 2021 16:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621293073; cv=none; d=google.com; s=arc-20160816; b=xQSDSwHjatGicIdnOMHgF5q0OhoBJDT5L/QevGbQPu+vvIcErwxbgyBT9M+sRZBLRf 8ACrVfzPrnPd4H+eFRBFox/qI6xSpCmWBZbU2ZujZXSAXISJi7uwBLRVtDk8RcUP/jsK UZgjitgBHJ/yE8tBisOM4tjJx0anOP75rvP8ehHXceyNUhcgFQLoIqQGgdRw3GAAKFqk 41Sit8EEhqA5w8JCs0DcK6gPb0CTSGqYy53eG2t0JcFsCpvr/enqr17qsMtT6OyKrrJn zhw3dVmFl/TaSAGobq1DmKe8mnjrc+KdkLsYIa1RZI3qdI9Elme90l4Ry2+PqGi4+yV9 XnNw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9P1pZbXoeagAix4vyww5sUlez8O6odXB8P/49Plzxzo=; b=0IjynrT1BTUJmTKl0rbkGA9YhsSD1P2iSKIh8IQ8Uez5aA29a/0ewu7yzqEO/v4J7+ EiiqnHdDrBxUGQPQrdL18CjVIAiKLm4+1LIn3/k8qoXUTaEhcONBHvb7/SD7u85MPhih Azvq0FW4MtZDjpdbdH3WS8Ift8eIq1LRpOsPCvsoVp49nbCKnLBRREqHM554TzJ9Dxne OJn5xg24GTtit0Wc3oMHFaWxsZVh/c8OnC9ShbYR+wb/3Z5lSoP+14dM9S2k+Hb6DbJc WX97QLzgnmpklMlt9hu7cmjVSTq2vvSkNP5+fsU9oAQLty5EDLF4DuRaxdeOUEiq+e4k 2NZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aEV3bcMt; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f11si21942859ila.138.2021.05.17.16.10.58; Mon, 17 May 2021 16:11:13 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=aEV3bcMt; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238472AbhEQOVp (ORCPT + 99 others); Mon, 17 May 2021 10:21:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:35962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239123AbhEQOSr (ORCPT ); Mon, 17 May 2021 10:18:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 094E361414; Mon, 17 May 2021 14:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260629; bh=E+D5WvyGjYNJgCxXQuHsbbTLunrv9TbfSyoYaHX1xgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aEV3bcMtkTEeNy2A0XaJjRHB4HyD06xTA+Peb+231s6p2gwjoN1mu+ok3F9vsrL7x 0NzWLhjbKdousjEyKJAFPJfyvuM9PGNr97qr2+g+oswa8NVoVWt0Pri/M+t/lQgxZj nW+3K3dIg5Ra2aprVh+xv5dV9lRPN6KshlnQdo3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.12 141/363] f2fs: fix to cover __allocate_new_section() with curseg_lock Date: Mon, 17 May 2021 16:00:07 +0200 Message-Id: <20210517140307.387602462@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu [ Upstream commit 823d13e12b6cbaef2f6e5d63c648643e7bc094dd ] In order to avoid race with f2fs_do_replace_block(). Fixes: f5a53edcf01e ("f2fs: support aligned pinned file") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/segment.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 0fbb0e07ca53..4fba82294a73 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2938,19 +2938,23 @@ static void __allocate_new_section(struct f2fs_sb_info *sbi, int type) void f2fs_allocate_new_section(struct f2fs_sb_info *sbi, int type) { + down_read(&SM_I(sbi)->curseg_lock); down_write(&SIT_I(sbi)->sentry_lock); __allocate_new_section(sbi, type); up_write(&SIT_I(sbi)->sentry_lock); + up_read(&SM_I(sbi)->curseg_lock); } void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi) { int i; + down_read(&SM_I(sbi)->curseg_lock); down_write(&SIT_I(sbi)->sentry_lock); for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) __allocate_new_segment(sbi, i, false); up_write(&SIT_I(sbi)->sentry_lock); + up_read(&SM_I(sbi)->curseg_lock); } static const struct segment_allocation default_salloc_ops = { -- 2.30.2