From patchwork Thu Apr 13 08:05:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9678915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 113E060386 for ; Thu, 13 Apr 2017 08:06:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04AFA28631 for ; Thu, 13 Apr 2017 08:06:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDCC828654; Thu, 13 Apr 2017 08:06:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 908DB28642 for ; Thu, 13 Apr 2017 08:06:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754785AbdDMIF6 (ORCPT ); Thu, 13 Apr 2017 04:05:58 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:55034 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753534AbdDMIFv (ORCPT ); Thu, 13 Apr 2017 04:05:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Xa55B6Z35Z+KtG61JLicXHgHk0HRjr4WoR6GgdbAiTY=; b=sLCT6ilIpfkdbJBRpkVnwj46l GQTHI3ThhiAj19b8M5b6Dtxmfu1w59Ggap4VTEDPA2MKPELjocaCCP069druxPNqMpXAodyyBcCdC yKCYzg392LNX8eXE6FPK8DxzEojMeNlYV5ktmnDW8yBRVQy6kbb9HFWqjHsiqwxeppijtOTLHY8+c PiuPyr6uv2tDzxO4LV2SLCpQRwi4d3K0HL2hzwTDEvcGqRlI1+b18iqJk6uEvdhRCCUDIbRZkU2ew yRh65Ps6/BWfgMTb1ffgRwR884T7Hsip39T9C39IZx+bDg6kVIN6ziP8u0csnUw1/N/v6XxlKIP1B KI23E1Pmg==; Received: from 212095007060.public.telering.at ([212.95.7.60] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cyZlF-0007eO-Vz for linux-xfs@vger.kernel.org; Thu, 13 Apr 2017 08:05:50 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 07/10] xfs: fix space reservation in xfs_bmbt_alloc_block Date: Thu, 13 Apr 2017 10:05:14 +0200 Message-Id: <20170413080517.12564-8-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170413080517.12564-1-hch@lst.de> References: <20170413080517.12564-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP minleft counts the number of blocks that need to be available after the current allocation has been completed. As the total allocation should not be more than the transaction reservation we need to subtract the allocation length. In addition we need to subtract the already used transaction reservation, for that use the new xfs_trans_blk_res helper. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_bmap_btree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c index ce41dd5fbb34..153c969febd4 100644 --- a/fs/xfs/libxfs/xfs_bmap_btree.c +++ b/fs/xfs/libxfs/xfs_bmap_btree.c @@ -442,6 +442,7 @@ xfs_bmbt_alloc_block( args.mp = cur->bc_mp; args.fsbno = cur->bc_private.b.firstblock; args.firstblock = args.fsbno; + args.minlen = args.maxlen = args.prod = 1; xfs_rmap_ino_bmbt_owner(&args.oinfo, cur->bc_private.b.ip->i_ino, cur->bc_private.b.whichfork); @@ -459,14 +460,14 @@ xfs_bmbt_alloc_block( * reservation amount is insufficient then we may fail a * block allocation here and corrupt the filesystem. */ - args.minleft = args.tp->t_blk_res; + if (xfs_trans_blk_res(args.tp)) + args.minleft = xfs_trans_blk_res(args.tp) - args.maxlen; } else if (cur->bc_private.b.dfops->dop_low) { args.type = XFS_ALLOCTYPE_START_BNO; } else { args.type = XFS_ALLOCTYPE_NEAR_BNO; } - args.minlen = args.maxlen = args.prod = 1; args.wasdel = cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL; if (!args.wasdel && args.tp->t_blk_res == 0) { error = -ENOSPC;