From patchwork Mon Sep 18 15:24:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9956915 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 662DB60568 for ; Mon, 18 Sep 2017 15:24:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5786C28A9B for ; Mon, 18 Sep 2017 15:24:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C3A628AA1; Mon, 18 Sep 2017 15:24:31 +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 E290F28AD7 for ; Mon, 18 Sep 2017 15:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752325AbdIRPY2 (ORCPT ); Mon, 18 Sep 2017 11:24:28 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:59780 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555AbdIRPY0 (ORCPT ); Mon, 18 Sep 2017 11:24:26 -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=ct4PXvLg1mH2bht2fYYrvYd0vdSGsZgBK2YH87sAdFw=; b=c9Au3UpfhTRrfmamzoBiSFFmp wwEjg+1YJbr8cM1/eRvlc4i4rHZv1ThuxQRkSAnueWj5A+hBKQLZ13wOP3eBGNJQUDuvGMicr7wdj 4XQmRonVMo6MujWeK4JsaoF1i7ha1fuhZkV91BD5YuelKF6Nhysprd4JmVKlKRb2s27F8tW6k61Yn JX0rdU5fVVzVGDxCOot0lAyny9Pve3EjyJLU8idr09eJNmNAjdPcvFfO1hZ1oyuCIPlmi9PITQSih 7T9YnXpVETFOLgeLxyU/WcyrOpYXqScnEOoB5Lgv0JpvywClu9X2Zt9wUfI2k1snCM4EABw9woruF Mr1G6WM2Q==; Received: from [107.17.164.65] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dtxuM-0005Dj-4r for linux-xfs@vger.kernel.org; Mon, 18 Sep 2017 15:24:26 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 06/19] xfs: move some more code into xfs_bmap_del_extent_real Date: Mon, 18 Sep 2017 08:24:09 -0700 Message-Id: <20170918152422.24345-7-hch@lst.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170918152422.24345-1-hch@lst.de> References: <20170918152422.24345-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 Reviewed-by: Darrick J. Wong --- 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 4e6c4cc4168f..06f1bd9e144e 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);