From patchwork Wed Apr 16 04:03:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 3997471 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1F843BFF02 for ; Wed, 16 Apr 2014 04:21:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5DEEC2020F for ; Wed, 16 Apr 2014 04:21:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B88E20200 for ; Wed, 16 Apr 2014 04:21:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754362AbaDPEUG (ORCPT ); Wed, 16 Apr 2014 00:20:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38894 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754327AbaDPEUF (ORCPT ); Wed, 16 Apr 2014 00:20:05 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 99360AB0E; Wed, 16 Apr 2014 04:20:04 +0000 (UTC) From: NeilBrown To: linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 16 Apr 2014 14:03:37 +1000 Subject: [PATCH 19/19] XFS: set PF_FSTRANS while ilock is held in xfs_free_eofblocks Cc: xfs@oss.sgi.com Message-ID: <20140416040337.10604.7488.stgit@notabene.brown> In-Reply-To: <20140416033623.10604.69237.stgit@notabene.brown> References: <20140416033623.10604.69237.stgit@notabene.brown> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP memory allocates can happen while the xfs ilock is held in xfs_free_eofblocks, particularly [] kmem_zone_alloc+0x67/0xc0 [] xfs_trans_add_item+0x25/0x50 [] xfs_trans_ijoin+0x2c/0x60 [] xfs_itruncate_extents+0xbe/0x400 [] xfs_free_eofblocks+0x1c4/0x240 So set PF_FSTRANS to avoid this causing a deadlock. Care is needed here as xfs_trans_reserve() also sets PF_FSTRANS, while xfs_trans_cancel and xfs_trans_commit will clear it. So our extra setting must fully nest these calls. Signed-off-by: NeilBrown --- fs/xfs/xfs_bmap_util.c | 4 ++++ 1 file changed, 4 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index f264616080ca..53761fe4fada 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -889,6 +889,7 @@ xfs_free_eofblocks( xfs_filblks_t map_len; int nimaps; xfs_bmbt_irec_t imap; + unsigned int pflags; /* * Figure out if there are any blocks beyond the end @@ -929,12 +930,14 @@ xfs_free_eofblocks( } } + current_set_flags_nested(&pflags, PF_FSTRANS); error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0); if (error) { ASSERT(XFS_FORCED_SHUTDOWN(mp)); xfs_trans_cancel(tp, 0); if (need_iolock) xfs_iunlock(ip, XFS_IOLOCK_EXCL); + current_restore_flags_nested(&pflags, PF_FSTRANS); return error; } @@ -964,6 +967,7 @@ xfs_free_eofblocks( xfs_inode_clear_eofblocks_tag(ip); } + current_restore_flags_nested(&pflags, PF_FSTRANS); xfs_iunlock(ip, XFS_ILOCK_EXCL); if (need_iolock) xfs_iunlock(ip, XFS_IOLOCK_EXCL);