Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp430193pxj; Tue, 18 May 2021 06:38:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzquOOm5CrD+yfsl8vO7Xb1+J0j19gOMhlQNsuD6Za3amm3asLkfbHACeVLEmJjbff55eRQ X-Received: by 2002:a05:6602:280d:: with SMTP id d13mr4249647ioe.90.1621345095024; Tue, 18 May 2021 06:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621345095; cv=none; d=google.com; s=arc-20160816; b=0NDC2IpaDkeQxqE+nrrSAK9H/84VXObnLqVJLGON7CAovVs81itmAnNyYsB5wh3OHr PdfE6DBuyay/mw3bBvpOqt5gTuHee0ZEykZZXezaKfm79zgsJE6l5nocl+soy2nd3Byv y7uaqJm/08KSSx5HbII6Zu3ddZ404gt73fi6zDnZHUruWigrwptv9HJHnB110SW6tem1 MmziZgb1SOy8q6GyXJqhhyl/FANgv62yvI1If1wJMRt7MlB0N/vqxwqmrTck2FokFVNn ZbTGwnLZVXo2mjMYxEqdeW3ToPtgOdlGVR4sBLFAcy+Vf9oeiv6T/dH7oMXA0+dBb3Bc h2sw== 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=YXnmge/SvNJkdVVCB7NLniLouN95YwjMPWs/Yo9pV3I=; b=ktJBo47gcDn3diKnsCJL5JhpQGQ/us7sW21+5QS0JgP+VywZRWiJsLI6rMgUE/+my3 1eKFj/Lx3pcGBS41NRZ4YxBJGyeTc4ixMcyphidsb0L+l0LkFrbifRWYZgVGBhlNbgb9 /jk5DQJLBh/V2AtXsF8kbDJ4vDKH7EDPe5lcIIP3Kn7B3PTJ8/7u2Nb6Gs869oDk/seA kqCWt/UBKKVaf9b6PueLUNUgozuIaL3Vq6pK3s1j68ubl6RjFRJN5VCLQk2QpmfWOaCy ieIv3aBEQfBNH01OsdDzO2ZcOasYNh1RZYpeVFCEg4SHLfxJIYHkG/ZrrdjSqewcGBOn vJcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="uH0bVYT/"; 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 g8si11908664ilk.127.2021.05.18.06.38.02; Tue, 18 May 2021 06:38:15 -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="uH0bVYT/"; 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 S243715AbhEQPie (ORCPT + 99 others); Mon, 17 May 2021 11:38:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:41300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244914AbhEQPWg (ORCPT ); Mon, 17 May 2021 11:22:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C274613F8; Mon, 17 May 2021 14:35:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262107; bh=8riokKxH2sHn+YGY/A9V+kGW3Q3eIEgRBSDmyHjbsgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uH0bVYT/w49a8waIFsb6+dq7dB8bU4D3qThc21XqwtrIcpxz/BRvW2zPYyxxZixIx KdOyRR1xCZVFDiDWx+lHpGKG3lT0iBcwHdysjLKz+ExpRzUPKVkYUoC+1XJYSRhUyC F7tlOGgFb1XpJ73fUgo21aoHMnpFv4d0Sd6B9gD8= 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.10 112/289] f2fs: fix to cover __allocate_new_section() with curseg_lock Date: Mon, 17 May 2021 16:00:37 +0200 Message-Id: <20210517140308.944855026@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 661b891aa1ca..ddfc3daebe9b 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2948,19 +2948,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