From patchwork Thu Oct 19 06:59:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10016085 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 81D8E60215 for ; Thu, 19 Oct 2017 07:00:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74C2C28C64 for ; Thu, 19 Oct 2017 07:00:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6979C28CA3; Thu, 19 Oct 2017 07:00:29 +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 BADDE28C64 for ; Thu, 19 Oct 2017 07:00:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751582AbdJSHA2 (ORCPT ); Thu, 19 Oct 2017 03:00:28 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:59939 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751576AbdJSHA1 (ORCPT ); Thu, 19 Oct 2017 03:00:27 -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=5fgAiVqt8y7418L4j+6r7nWB/7U8negcHy1YGMFsA6s=; b=uK3em1OkRPkwpE3cLYRirYQ8+ ZnbKURYTp9n7XCbGW5t70ILbxAL+CqbUvx5rdGH299Azv2C4Spp1u3vw+H6+r7KiTdrL5xhvU9cBD LNWczZ+S37kIhUzYFnAY+SfqWnW8z4ZMYVmTRSPNTG1vjq2maF8Osd3hAhHAbxqRSLKu48B/XbVpG GbbX1KOtdrcdnTpZnfEnqkYh47TYpwHH2kda0yuJv8n1WdBeBXZtnudIB9stTT95SiNv+X6dXW8aA 9OLt/qG3V4LsPSSftYKneEJWrEFFzFYsvHpOU7oW8nAe4adTdDhVZktrTELjxpy8T5Yqb/Mf1Yzr4 6pcBHHxeQ==; Received: from 212095007233.public.telering.at ([212.95.7.233] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1e54oc-0005nZ-Qe for linux-xfs@vger.kernel.org; Thu, 19 Oct 2017 07:00:27 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 09/15] xfs: remove XFS_BMAP_MAX_SHIFT_EXTENTS Date: Thu, 19 Oct 2017 08:59:36 +0200 Message-Id: <20171019065942.18813-10-hch@lst.de> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171019065942.18813-1-hch@lst.de> References: <20171019065942.18813-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 The define was always set to 1, which means looping until we reach is was dead code from the start. Also remove an initialization of next_fsb for the done case that doesn't fit the new code flow - it was never checked by the caller in the done case to start with. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_bmap.c | 47 ++++++++++++++++++++--------------------------- fs/xfs/libxfs/xfs_bmap.h | 12 +----------- fs/xfs/xfs_bmap_util.c | 14 ++------------ 3 files changed, 23 insertions(+), 50 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 22e7578e5696..89ea8a5235c0 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5692,8 +5692,7 @@ xfs_bmse_shift_one( /* * Shift extent records to the left/right to cover/create a hole. * - * The maximum number of extents to be shifted in a single operation is - * @num_exts. @stop_fsb specifies the file offset at which to stop shift and the + * @stop_fsb specifies the file offset at which to stop shift and the * file offset where we've left off is returned in @next_fsb. @offset_shift_fsb * is the length by which each extent is shifted. If there is no hole to shift * the extents into, this will be considered invalid operation and we abort @@ -5709,14 +5708,12 @@ xfs_bmap_shift_extents( xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock, struct xfs_defer_ops *dfops, - enum shift_direction direction, - int num_exts) + enum shift_direction direction) { struct xfs_btree_cur *cur = NULL; struct xfs_bmbt_irec got; struct xfs_mount *mp = ip->i_mount; struct xfs_ifork *ifp; - xfs_extnum_t nexts = 0; xfs_extnum_t current_ext; xfs_extnum_t total_extents; xfs_extnum_t stop_extent; @@ -5814,31 +5811,27 @@ xfs_bmap_shift_extents( } } - while (nexts++ < num_exts) { - error = xfs_bmse_shift_one(ip, whichfork, offset_shift_fsb, - ¤t_ext, &got, cur, &logflags, - direction, dfops); - if (error) - goto del_cursor; - /* - * If there was an extent merge during the shift, the extent - * count can change. Update the total and grade the next record. - */ - if (direction == SHIFT_LEFT) { - total_extents = xfs_iext_count(ifp); - stop_extent = total_extents; - } + error = xfs_bmse_shift_one(ip, whichfork, offset_shift_fsb, + ¤t_ext, &got, cur, &logflags, + direction, dfops); + if (error) + goto del_cursor; + /* + * If there was an extent merge during the shift, the extent + * count can change. Update the total and grade the next record. + */ + if (direction == SHIFT_LEFT) { + total_extents = xfs_iext_count(ifp); + stop_extent = total_extents; + } - if (current_ext == stop_extent) { - *done = 1; - *next_fsb = NULLFSBLOCK; - break; - } - xfs_iext_get_extent(ifp, current_ext, &got); + if (current_ext == stop_extent) { + *done = 1; + goto del_cursor; } + xfs_iext_get_extent(ifp, current_ext, &got); - if (!*done) - *next_fsb = got.br_startoff; + *next_fsb = got.br_startoff; del_cursor: if (cur) diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index c837e88ba19a..985b1c26566a 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h @@ -183,15 +183,6 @@ static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec) !isnullstartblock(irec->br_startblock); } -/* - * This macro is used to determine how many extents will be shifted - * in one write transaction. We could require two splits, - * an extent move on the first and an extent merge on the second, - * So it is proper that one extent is shifted inside write transaction - * at a time. - */ -#define XFS_BMAP_MAX_SHIFT_EXTENTS 1 - enum shift_direction { SHIFT_LEFT = 0, SHIFT_RIGHT, @@ -239,8 +230,7 @@ uint xfs_default_attroffset(struct xfs_inode *ip); int xfs_bmap_shift_extents(struct xfs_trans *tp, struct xfs_inode *ip, xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb, int *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock, - struct xfs_defer_ops *dfops, enum shift_direction direction, - int num_exts); + struct xfs_defer_ops *dfops, enum shift_direction direction); int xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset); int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork, xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc, diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 47b53c88de7c..3273f083c496 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1359,14 +1359,9 @@ xfs_collapse_file_space( xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_defer_init(&dfops, &first_block); - - /* - * We are using the write transaction in which max 2 bmbt - * updates are allowed - */ error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb, &done, stop_fsb, &first_block, &dfops, - SHIFT_LEFT, XFS_BMAP_MAX_SHIFT_EXTENTS); + SHIFT_LEFT); if (error) goto out_bmap_cancel; @@ -1438,14 +1433,9 @@ xfs_insert_file_space( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_defer_init(&dfops, &first_block); - - /* - * We are using the write transaction in which max 2 bmbt - * updates are allowed - */ error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb, &done, stop_fsb, &first_block, &dfops, - SHIFT_RIGHT, XFS_BMAP_MAX_SHIFT_EXTENTS); + SHIFT_RIGHT); if (error) goto out_bmap_cancel;