From patchwork Thu Sep 20 14:42:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10607857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8520D1390 for ; Thu, 20 Sep 2018 14:42:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74E242DA17 for ; Thu, 20 Sep 2018 14:42:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6948E2DA28; Thu, 20 Sep 2018 14:42:28 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 F415A2DA17 for ; Thu, 20 Sep 2018 14:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732496AbeITU0P (ORCPT ); Thu, 20 Sep 2018 16:26:15 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36142 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730984AbeITU0P (ORCPT ); Thu, 20 Sep 2018 16:26:15 -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=FlwgkNzLUTbeCV/UqZn7Zm0YMeS4Ts4huRpB81Fk3AM=; b=K9T3UlR+zFxYfEJdj/4OjORg1 cJDwTOUSeNj9vNAfHo8z4ue8sd6BMt1ccuEtoX8LrZ1JCYVwwGrcyCQ4bBldlHgk73JgKyqAP+lz1 Ns2F3iFVyWAkVOGrmiT237+lSi1uz1Tp7Ygt0cNKI+BuExTTwpNpYagJ5gkOpb1XZVo7ACA/6DGMf QMUy/YVQX2c/Fq53v13Jozyf9bLTQaUYNMrnvtbSo2Cz7MMhwRA4EGd9QrHLgUVjep6QEQ1etxGgH eaxZO9itYuGTvz+6RRsJGWUdNmc4MCAujkte2KE9JTE3fEy1WgPlsFmrF7FqH72kX4mnBYJXVgZS4 Jc38nbsig==; Received: from 089144198037.atnat0007.highway.a1.net ([89.144.198.37] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g309y-0006fi-MF for linux-xfs@vger.kernel.org; Thu, 20 Sep 2018 14:42:27 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 1/5] xfs: cancel COW blocks before swapext Date: Thu, 20 Sep 2018 16:42:16 +0200 Message-Id: <20180920144220.2181-2-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180920144220.2181-1-hch@lst.de> References: <20180920144220.2181-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 We need to make sure we have no outstanding COW blocks before we swap extents, as there is nothing preventing us from having COW preallocations on an inode that swapext is called on. That case can easily be reproduced by the upcoming always_cow mode. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_bmap_util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 414dbc31139c..e0e9cbc98ccd 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1515,6 +1515,12 @@ xfs_swap_extent_flush( return error; truncate_pagecache_range(VFS_I(ip), 0, -1); + if (xfs_inode_has_cow_data(ip)) { + error = xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, true); + if (error) + return error; + } + /* Verify O_DIRECT for ftmp */ if (VFS_I(ip)->i_mapping->nrpages) return -EINVAL;