From patchwork Sun Sep 3 07:29:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9936011 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 0E3016037D for ; Sun, 3 Sep 2017 07:30:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F402D28632 for ; Sun, 3 Sep 2017 07:30:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E90F52868D; Sun, 3 Sep 2017 07:30:19 +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 8B43628632 for ; Sun, 3 Sep 2017 07:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751611AbdICHaT (ORCPT ); Sun, 3 Sep 2017 03:30:19 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:50816 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbdICHaS (ORCPT ); Sun, 3 Sep 2017 03:30:18 -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=sd2vh/cpVIPs9CZ//fUo4XNgxPcs4KVHFnv7pzxl6Gs=; b=ccMYI2+ryqsNVLoRpIIQ8T8OF +GTSQu8+pBr8gJH/W9IAstG3acra27A4XTZ4c7xqA0py8cFd3k84pz3RzM8TJt9v5/399EuzZ4hEb Yf6c9/uXhd1NySMu5/wT6f2iHhk55JEI7cWTZY6jMJ+n8aPt7X9UH26KZAglhh6JSh+7QZH9Oh2T6 T8IOiUYNvyAlhj0P8TyckofsV+vI2wT9m/jPjdfa2Yyk3S1/hjS9TdoXuD59NMwamZQWJRSbLb0bT f2qGvl2l9LAXrYHN8bkdl7+wacVPt74rHQRKec4v1rv/oAWroLtZkjHYzEpmm8lY4Us3PNikq/oBN MEmWCN+2w==; Received: from [91.114.64.3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1doPMI-0006w2-1Y for linux-xfs@vger.kernel.org; Sun, 03 Sep 2017 07:30:18 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 06/17] xfs: move some more code into xfs_bmap_del_extent_real Date: Sun, 3 Sep 2017 09:29:45 +0200 Message-Id: <20170903072956.3175-7-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170903072956.3175-1-hch@lst.de> References: <20170903072956.3175-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 Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster --- fs/xfs/libxfs/xfs_bmap.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index e6feb71298ba..add690cb19a3 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5080,7 +5080,7 @@ xfs_bmap_del_extent_real( int do_fx; /* free extent at end of routine */ xfs_bmbt_rec_host_t *ep; /* current extent entry pointer */ int error; /* error return value */ - int flags; /* inode logging flags */ + int flags = 0;/* inode logging flags */ xfs_bmbt_irec_t got; /* current extent entry */ xfs_fileoff_t got_endoff; /* first offset past got */ int i; /* temp state */ @@ -5112,10 +5112,25 @@ xfs_bmap_del_extent_real( got_endoff = got.br_startoff + got.br_blockcount; ASSERT(got_endoff >= del_endoff); ASSERT(!isnullstartblock(got.br_startblock)); - flags = XFS_ILOG_CORE; qfield = 0; error = 0; + /* + * If it's the case where the directory code is running with no block + * reservation, and the deleted block is in the middle of its extent, + * and the resulting insert of an extent would cause transformation to + * btree format, then reject it. The calling code will then swap blocks + * around instead. We have to do this now, rather than waiting for the + * conversion to btree format, since the transaction will be dirty then. + */ + if (tp->t_blk_res == 0 && + XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS && + XFS_IFORK_NEXTENTS(ip, whichfork) >= + XFS_IFORK_MAXEXT(ip, whichfork) && + del->br_startoff > got.br_startoff && del_endoff < got_endoff) + return -ENOSPC; + + flags = XFS_ILOG_CORE; if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) { xfs_fsblock_t bno; xfs_filblks_t len; @@ -5601,28 +5616,6 @@ __xfs_bunmapi( error = xfs_bmap_del_extent_delay(ip, whichfork, &lastx, &got, &del); } else { - /* - * If it's the case where the directory code is running - * with no block reservation, and the deleted block is - * in the middle of its extent, and the resulting insert - * of an extent would cause transformation to btree - * format, then reject it. The calling code will then - * swap blocks around instead. We have to do this now, - * rather than waiting for the conversion to btree - * format, since the transaction will be dirty. - */ - if (tp->t_blk_res == 0 && - XFS_IFORK_FORMAT(ip, whichfork) == - XFS_DINODE_FMT_EXTENTS && - XFS_IFORK_NEXTENTS(ip, whichfork) >= - XFS_IFORK_MAXEXT(ip, whichfork) && - del.br_startoff > got.br_startoff && - del.br_startoff + del.br_blockcount < - got.br_startoff + got.br_blockcount) { - error = -ENOSPC; - goto error0; - } - error = xfs_bmap_del_extent_real(ip, tp, &lastx, dfops, cur, &del, &tmp_logflags, whichfork, flags);