From patchwork Thu Apr 13 08:05:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9678913 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 E9CBD60381 for ; Thu, 13 Apr 2017 08:06:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD00E28654 for ; Thu, 13 Apr 2017 08:06:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D040728658; 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 6FB0528631 for ; Thu, 13 Apr 2017 08:06:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754640AbdDMIF4 (ORCPT ); Thu, 13 Apr 2017 04:05:56 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:38703 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753957AbdDMIFv (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=5lndvZYQcB+iA0xpQ9zdTMHj2M4p3J8hd3JEWTntaG0=; b=O4rv7eIOtwvIRttaAgN1bz82V 9gCrUQIEEsldpeuH98u9XaA05wgeU5Y6k5AqUMsB+iZeia1aGbtAm1ePOopeVaUxSecT56vc5i7ZM L6hbcaPMMBwZAYl0FIyf0jLyqFSlXUO3VKxemrC83qiTt17aGVC4pw0LhybzyNtx717XRi+3cgMl8 kplqa0IO95o9gqJd7kFR69kLlthGdZQyQenmk/H2UthMThlyKyDyg0pgEuMGAzErqNKBWgl0qnjkm 5RRaYyViROvmtGYh9rLt204uOR1gTFxKMv0yJmiz9de7xG+vI4QSyfm7vgB68/NgBOvj5uJAPE+9F +zxBy24Aw==; 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 1cyZlB-0007dK-Mm for linux-xfs@vger.kernel.org; Thu, 13 Apr 2017 08:05:46 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 06/10] xfs: fix bmap minleft calculation Date: Thu, 13 Apr 2017 10:05:13 +0200 Message-Id: <20170413080517.12564-7-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 We need to set a proper minleft value even if we didn't do a previous allocation in the transaction, as we can't switch to a different AG after allocating the data extent. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_bmap.c | 27 +++++++++++++++++---------- fs/xfs/libxfs/xfs_bmap.h | 1 - 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 53f1386b1868..6faefa342748 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3570,6 +3570,22 @@ xfs_bmap_btalloc_filestreams( return 0; } +/* + * Return the minimum number of blocks required for the bmap btree manipulation + * after adding a single extent. + */ +static xfs_extlen_t +xfs_bmap_minleft( + struct xfs_bmalloca *ap) +{ + int whichfork = xfs_bmapi_whichfork(ap->flags); + struct xfs_ifork *ifp = XFS_IFORK_PTR(ap->ip, whichfork); + + if (XFS_IFORK_FORMAT(ap->ip, whichfork) == XFS_DINODE_FMT_BTREE) + return be16_to_cpu(ifp->if_broot->bb_level) + 1; + return 1; +} + STATIC int xfs_bmap_btalloc( struct xfs_bmalloca *ap) /* bmap alloc argument struct */ @@ -3738,7 +3754,7 @@ xfs_bmap_btalloc( args.alignment = 1; args.minalignslop = 0; } - args.minleft = ap->minleft; + args.minleft = xfs_bmap_minleft(ap); args.wasdel = ap->wasdel; args.resv = XFS_AG_RESV_NONE; args.datatype = ap->datatype; @@ -4493,15 +4509,6 @@ xfs_bmapi_write( XFS_STATS_INC(mp, xs_blk_mapw); - if (*firstblock == NULLFSBLOCK) { - if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE) - bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1; - else - bma.minleft = 1; - } else { - bma.minleft = 0; - } - if (!(ifp->if_flags & XFS_IFEXTENTS)) { error = xfs_iread_extents(tp, ip, whichfork); if (error) diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index d9e0b1db4cdb..36a7f36f5f38 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -48,7 +48,6 @@ struct xfs_bmalloca { int logflags;/* flags for transaction logging */ xfs_extlen_t total; /* total blocks needed for xaction */ - xfs_extlen_t minleft; /* amount must be left after alloc */ bool eof; /* set if allocating past last extent */ bool wasdel; /* replacing a delayed allocation */ bool aeof; /* allocated space at eof */