From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03D5EC54FD0 for ; Fri, 24 Apr 2020 12:29:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D744620776 for ; Fri, 24 Apr 2020 12:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587731367; bh=RWfCogi8yjlqHKJ1QYuqiErJGN7ddKARRjGXT+Srvhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=teIp5HFTMwAF1xsqa3p7qUAFYm6VtQebJavOJKDQMu3i1lds5+o86QXp5eairPoMc XDX/I0i/pAEhMcCJW3gwApYnrwI/4bIv3K3su+JH/3EmIyyIjiyy9PjBj0aTpv++7E lhhIQUMvxuVTGnfL1mjinQmJkzNE+99qk5YJrGgI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728292AbgDXM31 (ORCPT ); Fri, 24 Apr 2020 08:29:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:54272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728231AbgDXMYB (ORCPT ); Fri, 24 Apr 2020 08:24:01 -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 272DF21582; Fri, 24 Apr 2020 12:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587731040; bh=RWfCogi8yjlqHKJ1QYuqiErJGN7ddKARRjGXT+Srvhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iMlWZEQW2HKQ7vt1CRTKieuGylhW7lADe5j3q52XTiHpW/eaKqzJytI4rUHbmr+oc 13lLDMfw+40+HmkQLJFKfdDIeuU/BZxmJSOCb9IwKkUTVoPADjKHUFFYs69ZLI9QNG DmM7fTV09U3j7kC5rOgyvVykVijRK8RJINasWo3M= 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 4.19 03/18] xfs: acquire superblock freeze protection on eofblocks scans Date: Fri, 24 Apr 2020 08:23:40 -0400 Message-Id: <20200424122355.10453-3-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424122355.10453-1-sashal@kernel.org> References: <20200424122355.10453-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 245483cc282ba..901f27ac94abc 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -902,7 +902,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); } @@ -929,7 +934,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 bad90479ade2a..6ffb53edf1b4a 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -2182,7 +2182,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