Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp567496ybz; Fri, 24 Apr 2020 05:34:42 -0700 (PDT) X-Google-Smtp-Source: APiQypL7Sw3ei/yZexn/NGuq4XyMIKn5NSaCob3dFqL/wc6/iJ7spa1XeT++LrC/S4+vzFqQjSUy X-Received: by 2002:a50:8716:: with SMTP id i22mr6859127edb.248.1587731682558; Fri, 24 Apr 2020 05:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587731682; cv=none; d=google.com; s=arc-20160816; b=pfhXiM2AKTSItY8qgrqGdXVPEG10HsoPJPshBRknIRxUph/dREVzr59cWcw9eJIm37 1fZRI6QtBtDIma639PVo0vHPlS0gO3MSsi10S6K5apnosrmhpgwzCBTnULL27pqtCKee CfhRgxqJ4n8UjtZkGXoeH3SZDrZidd0q3I1kwAsgzdC8oRSs6336nfYGXS7WnolEH4b9 aIPZmIVRIKQhOkuonUCptFNifXFjAJ2qfLWTH94WpCsmTcsrlwazQbtj4YzhzJK+iV9A RKR+28G7JLigDZjSvCNWRV3lxaG6+zcxy7w7Z4cu2X6Tx51qj/Wo3C4XhkKHHXXj/PMf Y/qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L7CoZtjNDs1lz7kg+lJzz1eFULkAMFiXXe1cNUoJkc8=; b=iJwfA8PmJNAoJmalELD6cSIB2IlW37I0GipIKG9PfllFoFT6KbagLessu9xnPKC2FS X2qDGKoxAT+x0LOBk8264lUcd/zUXgUJPuqNREKntWiak9lqE1TXNdLEUexmwYBaLbAK ZHJbtdpoMK6Goj7oTHev8LyRe5dD17RCnejdl+HUOA33yxjHZpWA+ZAY/e2bKJ0iU1K+ 9W6ar8PruC6EWwr6XoDSvD6icrpXuBciZtWMYqrBjECEWGECN+1JTYuQc4dOU6AwN5a0 CKFGWns7PiEih8v8DEunRjktmv6AX6qsBm1fKPHpfM6wLF04CLGcxYd1dM3FQVZranKK IGmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yX1HqBiV; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oz15si3134868ejb.24.2020.04.24.05.34.19; Fri, 24 Apr 2020 05:34:42 -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=@kernel.org header.s=default header.b=yX1HqBiV; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728223AbgDXMcx (ORCPT + 99 others); Fri, 24 Apr 2020 08:32:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:51962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbgDXMWr (ORCPT ); Fri, 24 Apr 2020 08:22:47 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E1F1120767; Fri, 24 Apr 2020 12:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587730966; bh=hpb5Dlgj/A1AFNx7ZyVBlCM4ijqWSGiYBG2UZcu/z1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yX1HqBiVNs+SqB/zuBJF66zliN8l9Do+ApTawuSoKLhEcg2AN/5VDGqRBXENtbmcM EnheEZDL2HXdO2q92eXEDBzSf9usaTsfDCh1Hi+eJ7O6IfYQhkxrmnWNT1+ciP4HZd JiImzBFov8/U7lzPgAkY+tfzDlzVpRdVo9sdPG8A= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Brian Foster , Paul Furtado , Chandan Rajendra , Christoph Hellwig , Allison Collins , "Darrick J . Wong" , Sasha Levin , linux-xfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.6 08/38] xfs: acquire superblock freeze protection on eofblocks scans Date: Fri, 24 Apr 2020 08:22:06 -0400 Message-Id: <20200424122237.9831-8-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424122237.9831-1-sashal@kernel.org> References: <20200424122237.9831-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brian Foster [ Upstream commit 4b674b9ac852937af1f8c62f730c325fb6eadcdb ] The filesystem freeze sequence in XFS waits on any background eofblocks or cowblocks scans to complete before the filesystem is quiesced. At this point, the freezer has already stopped the transaction subsystem, however, which means a truncate or cowblock cancellation in progress is likely blocked in transaction allocation. This results in a deadlock between freeze and the associated scanner. Fix this problem by holding superblock write protection across calls into the block reapers. Since protection for background scans is acquired from the workqueue task context, trylock to avoid a similar deadlock between freeze and blocking on the write lock. Fixes: d6b636ebb1c9f ("xfs: halt auto-reclamation activities while rebuilding rmap") Reported-by: Paul Furtado Signed-off-by: Brian Foster Reviewed-by: Chandan Rajendra Reviewed-by: Christoph Hellwig Reviewed-by: Allison Collins Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- fs/xfs/xfs_icache.c | 10 ++++++++++ fs/xfs/xfs_ioctl.c | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 8dc2e54142768..00932d2b503b6 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -907,7 +907,12 @@ xfs_eofblocks_worker( { struct xfs_mount *mp = container_of(to_delayed_work(work), struct xfs_mount, m_eofblocks_work); + + if (!sb_start_write_trylock(mp->m_super)) + return; xfs_icache_free_eofblocks(mp, NULL); + sb_end_write(mp->m_super); + xfs_queue_eofblocks(mp); } @@ -934,7 +939,12 @@ xfs_cowblocks_worker( { struct xfs_mount *mp = container_of(to_delayed_work(work), struct xfs_mount, m_cowblocks_work); + + if (!sb_start_write_trylock(mp->m_super)) + return; xfs_icache_free_cowblocks(mp, NULL); + sb_end_write(mp->m_super); + xfs_queue_cowblocks(mp); } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index d42de92cb2833..4a99e0b0f3333 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -2264,7 +2264,10 @@ xfs_file_ioctl( if (error) return error; - return xfs_icache_free_eofblocks(mp, &keofb); + sb_start_write(mp->m_super); + error = xfs_icache_free_eofblocks(mp, &keofb); + sb_end_write(mp->m_super); + return error; } default: -- 2.20.1