From patchwork Wed Apr 17 01:27:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruan Shiyang X-Patchwork-Id: 10904305 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 1350D161F for ; Wed, 17 Apr 2019 01:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F06E928A20 for ; Wed, 17 Apr 2019 01:27:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4E8628A27; Wed, 17 Apr 2019 01:27:30 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AA8F428A20 for ; Wed, 17 Apr 2019 01:27:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 98FEB212108C2; Tue, 16 Apr 2019 18:27:30 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=183.91.158.132; helo=heian.cn.fujitsu.com; envelope-from=ruansy.fnst@cn.fujitsu.com; receiver=linux-nvdimm@lists.01.org Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by ml01.01.org (Postfix) with ESMTP id E1C39212017C0 for ; Tue, 16 Apr 2019 18:27:28 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.60,359,1549900800"; d="scan'208";a="59482919" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Apr 2019 09:27:25 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 26AF94CD8478; Wed, 17 Apr 2019 09:27:24 +0800 (CST) Received: from iridescent.g08.fujitsu.local (10.167.225.140) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 17 Apr 2019 09:27:27 +0800 From: Shiyang Ruan To: , Subject: [RFC PATCH 1/4] fs/iomap: Introduce src_addr for COW in fsdax mode. Date: Wed, 17 Apr 2019 09:27:12 +0800 Message-ID: <20190417012715.8287-2-ruansy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com> References: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.140] X-yoursite-MailScanner-ID: 26AF94CD8478.A42A0 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP When using reflink, coping the source blocks before writing data into new allocated blocks is required. In fsdax mode, we need a source blocks' start address to handle the COW operation. Signed-off-by: Shiyang Ruan --- include/linux/iomap.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 0fefb5455bda..3b3aec2311c5 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -61,6 +61,10 @@ struct iomap { u16 flags; /* flags for mapping */ struct block_device *bdev; /* block device for I/O */ struct dax_device *dax_dev; /* dax_dev for dax operations */ + u64 src_addr; /* disk offset of mapping, bytes, + * the source blocks' start address + * for cow in dax + */ void *inline_data; void *private; /* filesystem private */ From patchwork Wed Apr 17 01:27:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruan Shiyang X-Patchwork-Id: 10904309 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 5437A161F for ; Wed, 17 Apr 2019 01:27:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D0EA28A20 for ; Wed, 17 Apr 2019 01:27:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 311BF28A26; Wed, 17 Apr 2019 01:27: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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E45F228A20 for ; Wed, 17 Apr 2019 01:27:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CF58621945DC7; Tue, 16 Apr 2019 18:27:30 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=183.91.158.132; helo=heian.cn.fujitsu.com; envelope-from=ruansy.fnst@cn.fujitsu.com; receiver=linux-nvdimm@lists.01.org Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by ml01.01.org (Postfix) with ESMTP id CD30F2194EB76 for ; Tue, 16 Apr 2019 18:27:29 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.60,359,1549900800"; d="scan'208";a="59482920" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Apr 2019 09:27:25 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 140904CD80E1; Wed, 17 Apr 2019 09:27:25 +0800 (CST) Received: from iridescent.g08.fujitsu.local (10.167.225.140) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 17 Apr 2019 09:27:28 +0800 From: Shiyang Ruan To: , Subject: [RFC PATCH 2/4] fs/xfs: iomap: add handle for reflink in fsdax mode Date: Wed, 17 Apr 2019 09:27:13 +0800 Message-ID: <20190417012715.8287-3-ruansy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com> References: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.140] X-yoursite-MailScanner-ID: 140904CD80E1.A3A5F X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP xfs_file_iomap_begin() is supposed to allocate new extents for reflinked inode and pass the source blocks' start address to the actor functions. Signed-off-by: Shiyang Ruan --- fs/xfs/xfs_iomap.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 63d323916bba..a45b4e5a1d87 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -255,7 +255,11 @@ xfs_iomap_write_direct( * left but we need to do unwritten extent conversion. */ if (IS_DAX(VFS_I(ip))) { - bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO; + if (xfs_is_cow_inode(ip)) + /* we need to allocate new extents for reflink */ + bmapi_flags = XFS_BMAPI_COWFORK; + else + bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO; if (imap->br_state == XFS_EXT_UNWRITTEN) { tflags |= XFS_TRANS_RESERVE; resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0) << 1; @@ -983,7 +987,8 @@ xfs_file_iomap_begin( */ if (xfs_is_cow_inode(ip)) { struct xfs_bmbt_irec cmap; - bool directio = (flags & IOMAP_DIRECT); + bool convert = (flags & IOMAP_DIRECT) + || IS_DAX(inode); /* if zeroing doesn't need COW allocation, then we are done. */ if ((flags & IOMAP_ZERO) && @@ -993,10 +998,16 @@ xfs_file_iomap_begin( /* may drop and re-acquire the ilock */ cmap = imap; error = xfs_reflink_allocate_cow(ip, &cmap, &shared, &lockmode, - directio); + convert); if (error) goto out_unlock; + if (shared && IS_DAX(inode)) { + /* get source address and pass it to actor functions */ + iomap->src_addr = BBTOB(xfs_fsb_to_db(ip, + imap.br_startblock)); + } + /* * For buffered writes we need to report the address of the * previous block (if there was any) so that the higher level @@ -1005,8 +1016,9 @@ xfs_file_iomap_begin( * I/O, which must be block aligned, we need to report the * newly allocated address. If the data fork has a hole, copy * the COW fork mapping to avoid allocating to the data fork. + * If is DAX, we need to allocate new address. */ - if (directio || imap.br_startblock == HOLESTARTBLOCK) + if (convert || imap.br_startblock == HOLESTARTBLOCK) imap = cmap; end_fsb = imap.br_startoff + imap.br_blockcount; From patchwork Wed Apr 17 01:27:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruan Shiyang X-Patchwork-Id: 10904303 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 8BDCC922 for ; Wed, 17 Apr 2019 01:27:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74B0E28A20 for ; Wed, 17 Apr 2019 01:27:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 690A828A24; Wed, 17 Apr 2019 01:27:30 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04F8428A26 for ; Wed, 17 Apr 2019 01:27:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7E6A92120ADC4; Tue, 16 Apr 2019 18:27:29 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=183.91.158.132; helo=heian.cn.fujitsu.com; envelope-from=ruansy.fnst@cn.fujitsu.com; receiver=linux-nvdimm@lists.01.org Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by ml01.01.org (Postfix) with ESMTP id 016AF212017C0 for ; Tue, 16 Apr 2019 18:27:27 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.60,359,1549900800"; d="scan'208";a="59482917" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Apr 2019 09:27:25 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id A7D284CD84C5; Wed, 17 Apr 2019 09:27:25 +0800 (CST) Received: from iridescent.g08.fujitsu.local (10.167.225.140) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 17 Apr 2019 09:27:29 +0800 From: Shiyang Ruan To: , Subject: [RFC PATCH 3/4] fs/dax: copy source blocks before writing when COW Date: Wed, 17 Apr 2019 09:27:14 +0800 Message-ID: <20190417012715.8287-4-ruansy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com> References: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.140] X-yoursite-MailScanner-ID: A7D284CD84C5.A5D9C X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP The actor functions get the source blocks' start address from iomap->src_addr, and then copy these blocks to the new allocated blocks before writing the user data. Signed-off-by: Shiyang Ruan cc: linux-nvdimm@lists.01.org --- fs/dax.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/fs/dax.c b/fs/dax.c index ca0671d55aa6..28519bdecf7c 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -982,6 +982,11 @@ static sector_t dax_iomap_sector(struct iomap *iomap, loff_t pos) return (iomap->addr + (pos & PAGE_MASK) - iomap->offset) >> 9; } +static sector_t dax_iomap_src_sector(struct iomap *iomap, loff_t pos) +{ + return (iomap->src_addr + (pos & PAGE_MASK) - iomap->offset) >> 9; +} + static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, pfn_t *pfnp) { @@ -1014,6 +1019,51 @@ static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, return rc; } +static int dax_iomap_addr(struct iomap *iomap, sector_t sector, size_t size, + void **kaddr) +{ + pgoff_t pgoff; + int id, rc; + long length; + + rc = bdev_dax_pgoff(iomap->bdev, sector, size, &pgoff); + if (rc) + return rc; + + id = dax_read_lock(); + length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), + kaddr, NULL); + if (length < 0) + rc = length; + if (!*kaddr) + rc = -EFAULT; + + dax_read_unlock(id); + return rc; +} + +static int dax_iomap_cow_copy(struct iomap *iomap, loff_t pos, size_t size) +{ + void *kaddr = 0, *src_kaddr = 0; + int error = 0; + const sector_t src_sector = dax_iomap_src_sector(iomap, pos); + const sector_t sector = dax_iomap_sector(iomap, pos); + + error = dax_iomap_addr(iomap, src_sector, size, &src_kaddr); + if (error < 0) + return error; + error = dax_iomap_addr(iomap, sector, size, &kaddr); + if (error < 0) + return error; + + /* + * Copy data from source blocks to the new allocated blocks before + * writing user data. + */ + memcpy(kaddr, src_kaddr, size); + return 0; +} + /* * The user has performed a load from a hole in the file. Allocating a new * page in the file would cause excessive storage usage for workloads with @@ -1149,6 +1199,12 @@ dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data, if (map_len > end - pos) map_len = end - pos; + if (iomap->src_addr) { + ret = dax_iomap_cow_copy(iomap, pos, size); + if (ret < 0) + break; + } + /* * The userspace address for the memory copy has already been * validated via access_ok() in either vfs_read() or @@ -1336,6 +1392,7 @@ static vm_fault_t dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, count_memcg_event_mm(vma->vm_mm, PGMAJFAULT); major = VM_FAULT_MAJOR; } + error = dax_iomap_pfn(&iomap, pos, PAGE_SIZE, &pfn); if (error < 0) goto error_finish_iomap; @@ -1358,6 +1415,13 @@ static vm_fault_t dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, ret = VM_FAULT_NEEDDSYNC | major; goto finish_iomap; } + + if (iomap.src_addr) { + error = dax_iomap_cow_copy(&iomap, pos, PAGE_SIZE); + if (error < 0) + goto error_finish_iomap; + } + trace_dax_insert_mapping(inode, vmf, entry); if (write) ret = vmf_insert_mixed_mkwrite(vma, vaddr, pfn); @@ -1559,6 +1623,12 @@ static vm_fault_t dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp, goto finish_iomap; } + if (iomap.src_addr) { + error = dax_iomap_cow_copy(&iomap, pos, PMD_SIZE); + if (error < 0) + goto finish_iomap; + } + trace_dax_pmd_insert_mapping(inode, vmf, PMD_SIZE, pfn, entry); result = vmf_insert_pfn_pmd(vma, vmf->address, vmf->pmd, pfn, write); From patchwork Wed Apr 17 01:27:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruan Shiyang X-Patchwork-Id: 10904313 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 793A0922 for ; Wed, 17 Apr 2019 01:27:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62E5028A24 for ; Wed, 17 Apr 2019 01:27:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5734A28A20; Wed, 17 Apr 2019 01:27:34 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 13EB728A24 for ; Wed, 17 Apr 2019 01:27:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id ED397212108CC; Tue, 16 Apr 2019 18:27:33 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=183.91.158.132; helo=heian.cn.fujitsu.com; envelope-from=ruansy.fnst@cn.fujitsu.com; receiver=linux-nvdimm@lists.01.org Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by ml01.01.org (Postfix) with ESMTP id AB4E0212017C0 for ; Tue, 16 Apr 2019 18:27:32 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.60,359,1549900800"; d="scan'208";a="59482931" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Apr 2019 09:27:31 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 3E4CE4CD8477; Wed, 17 Apr 2019 09:27:26 +0800 (CST) Received: from iridescent.g08.fujitsu.local (10.167.225.140) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 17 Apr 2019 09:27:29 +0800 From: Shiyang Ruan To: , Subject: [RFC PATCH 4/4] fs/xfs: iomap: update the extent list after a COW Date: Wed, 17 Apr 2019 09:27:15 +0800 Message-ID: <20190417012715.8287-5-ruansy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com> References: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.140] X-yoursite-MailScanner-ID: 3E4CE4CD8477.A68CE X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP COW allocated new extents, which are new part of the inode, So we need to update the metadata. Signed-off-by: Shiyang Ruan --- fs/xfs/xfs_iomap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index a45b4e5a1d87..5c05c11e0cb2 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1146,6 +1146,9 @@ xfs_file_iomap_end( if ((flags & IOMAP_WRITE) && iomap->type == IOMAP_DELALLOC) return xfs_file_iomap_end_delalloc(XFS_I(inode), offset, length, written, iomap); + /* update the extent list after a COW operation */ + if (iomap->flags & IOMAP_F_SHARED && iomap->src_addr) + return xfs_reflink_end_cow(XFS_I(inode), offset, length); return 0; }