From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:45282 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752718AbdIRIL4 (ORCPT ); Mon, 18 Sep 2017 04:11:56 -0400 Subject: Patch "xfs: fix multi-AG deadlock in xfs_bunmapi" has been added to the 4.9-stable tree To: hch@lst.de, darrick.wong@oracle.com, gregkh@linuxfoundation.org, n.borisov.lkml@gmail.com Cc: , From: Date: Mon, 18 Sep 2017 10:11:58 +0200 In-Reply-To: <20170917210712.10804-16-hch@lst.de> Message-ID: <150572231862149@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled xfs: fix multi-AG deadlock in xfs_bunmapi to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-fix-multi-ag-deadlock-in-xfs_bunmapi.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From hch@lst.de Mon Sep 18 10:09:24 2017 From: Christoph Hellwig Date: Sun, 17 Sep 2017 14:06:40 -0700 Subject: xfs: fix multi-AG deadlock in xfs_bunmapi To: stable@vger.kernel.org Cc: linux-xfs@vger.kernel.org, "Darrick J . Wong" Message-ID: <20170917210712.10804-16-hch@lst.de> commit 5b094d6dac0451ad89b1dc088395c7b399b7e9e8 upstream. Just like in the allocator we must avoid touching multiple AGs out of order when freeing blocks, as freeing still locks the AGF and can cause the same AB-BA deadlocks as in the allocation path. Signed-off-by: Christoph Hellwig Reported-by: Nikolay Borisov Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Greg Kroah-Hartman --- fs/xfs/libxfs/xfs_bmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5556,6 +5556,7 @@ __xfs_bunmapi( xfs_fsblock_t sum; xfs_filblks_t len = *rlen; /* length to unmap in file */ xfs_fileoff_t max_len; + xfs_agnumber_t prev_agno = NULLAGNUMBER, agno; trace_xfs_bunmap(ip, bno, len, flags, _RET_IP_); @@ -5658,6 +5659,17 @@ __xfs_bunmapi( ASSERT(ep != NULL); del = got; wasdel = isnullstartblock(del.br_startblock); + + /* + * Make sure we don't touch multiple AGF headers out of order + * in a single transaction, as that could cause AB-BA deadlocks. + */ + if (!wasdel) { + agno = XFS_FSB_TO_AGNO(mp, del.br_startblock); + if (prev_agno != NULLAGNUMBER && prev_agno > agno) + break; + prev_agno = agno; + } if (got.br_startoff < start) { del.br_startoff = start; del.br_blockcount -= start - got.br_startoff; Patches currently in stable-queue which might be from hch@lst.de are queue-4.9/xfs-fix-inobt-inode-allocation-search-optimization.patch queue-4.9/xfs-try-to-avoid-blowing-out-the-transaction-reservation-when-bunmaping-a-shared-extent.patch queue-4.9/xfs-free-cowblocks-and-retry-on-buffered-write-enospc.patch queue-4.9/xfs-set-firstfsb-to-nullfsblock-before-feeding-it-to-_bmapi_write.patch queue-4.9/xfs-fix-quotacheck-dquot-id-overflow-infinite-loop.patch queue-4.9/xfs-remove-bli-from-ail-before-release-on-transaction-abort.patch queue-4.9/xfs-check-_btree_check_block-value.patch queue-4.9/xfs-don-t-allow-bmap-on-rt-files.patch queue-4.9/xfs-free-uncommitted-transactions-during-log-recovery.patch queue-4.9/xfs-don-t-crash-on-unexpected-holes-in-dir-attr-btrees.patch queue-4.9/xfs-fix-spurious-spin_is_locked-assert-failures-on-non-smp-kernels.patch queue-4.9/xfs-fix-per-inode-dax-flag-inheritance.patch queue-4.9/xfs-fix-multi-ag-deadlock-in-xfs_bunmapi.patch queue-4.9/xfs-release-bli-from-transaction-properly-on-fs-shutdown.patch queue-4.9/xfs-check-_alloc_read_agf-buffer-pointer-before-using.patch