Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp677425ybz; Fri, 1 May 2020 06:39:34 -0700 (PDT) X-Google-Smtp-Source: APiQypKiGHRRcyPCtnUTgDKklqqdoDb9SVtDd9fL4nMENUF6tGYlJGm/nIXr0csZlzfYK5f4PHeQ X-Received: by 2002:a17:906:48c:: with SMTP id f12mr3333334eja.93.1588340374739; Fri, 01 May 2020 06:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588340374; cv=none; d=google.com; s=arc-20160816; b=RsuTNJ685SpfgpDYR+R26iMDtnabtRrRBWf9a+Vd1ylmaOHOmnWqmSHeaje9i/6Bzh TnVypDB1dFH4YqjS+L/JvdNeearfQsus/GkowzVoFm2rEMhSAN0i2AevLDUi3nd0bDOu fDVMavMMr4DMNALHJus04vMitk4rQOGluclNAlX0EqtstQiZy1SGn0ZmIYT8oHo3H4fJ yooQ/GDqiKcVILQlppB/gSeHwK4sNrTbujbf+T+q9j2l2r4hJfjhd0oWOcrb9o03oYp9 CXu2t4jX30+9u9XHUqlMD3zNy5DaVRehcFILPhSiQiYkpBjr3xBiZKZd/x+DRkA12M68 nbVw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7yQPZrIgVlq/a5Lpis7ry7sd5Mbi/MXb8HprC5B6iM0=; b=orFoJ83YlXcSvuI6s/qDP6gDeWkux9IFjyWcFACekASH0qjIUa1yUftjaG6V7VhRIz LLeBY94xTwN5jh9HgOqDdHyrMJNid+nyHgOuAFsNjfNsD6bI3aIvso36p74KAcnBRxPi 99M8sq5Hkh1WqoDcctGRV8BVIJhvkte+DikJvHRExrAAdZSkA2Vh1NV+TfoEjc/dvRbk wi5SpeOHvR4jTiOSiu0r5NZmi1rvDaBJ1FTPGw4RNV99jL64uH/GkzolKEAane+zEYKr cwSKJF61ZSWECTVeK5yEw/zvHTW+q93XKK1QpKhOn77XtRQQLMYJfomwKVumCQeVn0Tm w43g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vw+kNrV6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si1783350ejd.315.2020.05.01.06.39.12; Fri, 01 May 2020 06:39:34 -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=vw+kNrV6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730892AbgEANgp (ORCPT + 99 others); Fri, 1 May 2020 09:36:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:35206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730877AbgEANgi (ORCPT ); Fri, 1 May 2020 09:36:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7734E208DB; Fri, 1 May 2020 13:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588340197; bh=DEKOV80S+EgZGm5x0oH/1MuU21eybiRSXazP2DjWCGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vw+kNrV62uLWJ/fZfXCe4CCxeqd6aAUxm0oRtIJCUupGyMlm7vbfA1XHXAI1N+X9S YcRm7XIHEEzE6sGY5Pqr2TwYweFpZYWypZ8TgeVSEzZrm8BI9gYV5AvBPkWriuCB1N b/NQcpqwlrUAsSzXyI7VsiiEGIuvekoUbXLfbaaU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Furtado , Brian Foster , Chandan Rajendra , Christoph Hellwig , Allison Collins , "Darrick J. Wong" Subject: [PATCH 4.19 15/46] xfs: acquire superblock freeze protection on eofblocks scans Date: Fri, 1 May 2020 15:22:40 +0200 Message-Id: <20200501131503.899313616@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200501131457.023036302@linuxfoundation.org> References: <20200501131457.023036302@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 commit 4b674b9ac852937af1f8c62f730c325fb6eadcdb upstream. 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: Greg Kroah-Hartman --- fs/xfs/xfs_icache.c | 10 ++++++++++ fs/xfs/xfs_ioctl.c | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) --- 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); } --- 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: