From patchwork Fri Nov 3 14:45:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10040453 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 6D830603D7 for ; Fri, 3 Nov 2017 14:46:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62F6629680 for ; Fri, 3 Nov 2017 14:46:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57C2529688; Fri, 3 Nov 2017 14:46:32 +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 3C68C29688 for ; Fri, 3 Nov 2017 14:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933255AbdKCOq2 (ORCPT ); Fri, 3 Nov 2017 10:46:28 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:60405 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933219AbdKCOq0 (ORCPT ); Fri, 3 Nov 2017 10:46: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=0q4vb+38xlkWsyMNzjyqnMU8lbfIoQav1pAHwzZVBWc=; b=DLovOBT7IFnK6H7fWaOZ85dZB WRYbudcNgVduVpUw1J59y3fraSNBC7xuez3QFMpt1ueFt/A0kJRDR1YOgkn7Wn6ZMwUo7eUnsu5I6 uJSDnhu6+S7UumTqGbf3wB3e5LoHLqQMCulJi3H7lbZs+Li6CjasYKmJrFl3dcbRuffkr64KUHpeY uCXOgtdqa8e5YhOwZ9Xqe7UlxtcnOy1Qc1eHJSv00QYlRdMCUU1Qi/4xtVMniHSYtW+bzuH74Z+4V Pho3eQ9Pcdeb3EPJo8SL8dQSIDGQ/XqKup1a6MGQ2Dumjkll4HfBeNf+ZxXBsdq7ZZ0OsL9IjrVbf 0XDvisbkA==; Received: from [94.72.11.11] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1eAdEo-0001yP-9T for linux-xfs@vger.kernel.org; Fri, 03 Nov 2017 14:46:26 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 13/21] xfs: iterate backwards in xfs_reflink_cancel_cow_blocks Date: Fri, 3 Nov 2017 17:45:31 +0300 Message-Id: <20171103144539.2187-14-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171103144539.2187-1-hch@lst.de> References: <20171103144539.2187-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 Match the iteration order for extent deletion in the truncate and reflink I/O completion path. This also happens to make implementing the new incore extent list a lot easier. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_reflink.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index d86c4378facf..cf976ed65260 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -569,12 +569,20 @@ xfs_reflink_cancel_cow_blocks( if (!xfs_is_reflink_inode(ip)) return 0; - if (!xfs_iext_lookup_extent(ip, ifp, offset_fsb, &icur, &got)) + if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got)) return 0; - while (got.br_startoff < end_fsb) { + /* Walk backwards until we're out of the I/O range... */ + while (got.br_startoff + got.br_blockcount > offset_fsb) { del = got; xfs_trim_extent(&del, offset_fsb, end_fsb - offset_fsb); + + /* Extent delete may have bumped ext forward */ + if (!del.br_blockcount) { + xfs_iext_prev(ifp, &icur); + goto next_extent; + } + trace_xfs_reflink_cancel_cow(ip, &del); if (isnullstartblock(del.br_startblock)) { @@ -612,8 +620,8 @@ xfs_reflink_cancel_cow_blocks( /* Remove the mapping from the CoW fork. */ xfs_bmap_del_extent_cow(ip, &icur, &got, &del); } - - if (!xfs_iext_next_extent(ifp, &icur, &got)) +next_extent: + if (!xfs_iext_get_extent(ifp, &icur, &got)) break; }