From patchwork Fri Sep 22 13:59:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9966189 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 090DB6035E for ; Fri, 22 Sep 2017 13:59:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06EBB1FE85 for ; Fri, 22 Sep 2017 13:59:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0080298E8; Fri, 22 Sep 2017 13:59:51 +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 93B481FE85 for ; Fri, 22 Sep 2017 13:59:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752210AbdIVN7u (ORCPT ); Fri, 22 Sep 2017 09:59:50 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:34679 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751980AbdIVN7t (ORCPT ); Fri, 22 Sep 2017 09:59:49 -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=xHIaB23/B77nOW/eMpOrlIo1eVKwsEoQjg7ELU/DzOA=; b=scQwxP4eFXAPqH+uCGMVBP2H+ ox4yRTJl0NJf1wH0B9VGwvr55lCHLVPFSLvL2X44+UsxF9G4EG+7Ulm5qWFVTr4g2QZh0++w14P2Z fymAoMgVBfGgWCpqz6IPL0/SPH2DiG3sVJ42jYSSUtzHRdY5fBTmha9TA2aVL1CkwZxd8ubZpuhRk i1gzaJKyJk2tU2dum84N5w15o5oJdBVo9BeEo3xmPwipMnGqx9b7W4UvKQkSnvYFAzNfMbrNMiQgT wsFij5pYc2VXWpupVdvSvZvyX4rnuq9XMBh3X8NviKA32iDy3kMolas4rb/+uM+xrMOzQrDbNfBSf 20lAyR3iA==; Received: from ip-64-134-232-11.public.wayport.net ([64.134.232.11] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dvOUf-0001AO-62 for linux-xfs@vger.kernel.org; Fri, 22 Sep 2017 13:59:49 +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: Fri, 22 Sep 2017 06:59:32 -0700 Message-Id: <20170922135945.31574-7-hch@lst.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170922135945.31574-1-hch@lst.de> References: <20170922135945.31574-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);