From patchwork Thu Dec 1 15:28:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13061447 Received: from mail3.bemta32.messagelabs.com (mail3.bemta32.messagelabs.com [195.245.230.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 670FB6FD7 for ; Thu, 1 Dec 2022 15:29:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1669908559; i=@fujitsu.com; bh=sW0O04zZ8nMkiVbvumEcLtFp7gSnPMgrurjjHklR19o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nhMHVvm1Is+yywEXkcKGUP2GAd0j9IfkD1XyfNCkEtt1RlV46cNOp6XqfPg7NdhpV Xnco3EAj0zszQV7wkL89XCMWoy6nqTyK5p5J6IqdG513CiQZWmomT+j2ILWwpicbjx 8n3qP7B+1RrZ/wGJwuCoUwbdho1Rnh6YJs1ayHjxWsujVqCUIBRzbfACnTCEk0e5U9 xV6ngwaYFok0xgUcz4jNFVVxQMJd2SNdWPStO4hFa+5ihApkXmee3vm59VEw/+Cd6r OVP7lxj4PB/pkIuFkbMz2bwDd7YVQL9Ng2qjKYfa27V8LM9n7xPy8jOlXUUCplzKVb VvgfJHhhs5HvQ== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRWlGSWpSXmKPExsViZ8ORpOt/oiP Z4Mwdbos569ewWUyfeoHRYsuxe4wWl5/wWezZe5LF4vKuOWwWu/7sYLdY+eMPqwOHx6lFEh6L 97xk8ti0qpPN48SM3yweLzbPZPT4vEkugC2KNTMvKb8igTXjwEedgt3KFRvbFzI1MO6R7WLk4 hAS2MgoMeVLOwuEs4RJYuajU6wQzh5GiW8rjgFlODnYBHQkLiz4C5Tg4BARqJa4tZQNJMwskC Fx/MofZhBbWMBP4ta6C2DlLAIqEu8P97CD2LwCLhLdj2aA1UsIKEhMefgerJ5TwFXi5d+NYDV CQDXXmw8yQ9QLSpyc+YQFYr6ExMEXL5hB1koIKEnM7I6HGFMhMWtWGxOErSZx9dwm5gmMgrOQ dM9C0r2AkWkVo1lxalFZapGukYFeUlFmekZJbmJmjl5ilW6iXmqpbnlqcYmuoV5iebFeanGxX nFlbnJOil5easkmRmCspBQzTtnB2LPsj94hRkkOJiVRXu19HclCfEn5KZUZicUZ8UWlOanFhx hlODiUJHhT9gDlBItS01Mr0jJzgHELk5bg4FES4eU7BpTmLS5IzC3OTIdInWJUlBLnvQiSEAB JZJTmwbXBUsUlRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK827YBTeHJzCuBm/4KaDET0OJI sTaQxSWJCCmpBibTy0detRiIdCxQ6pvk+IntYOmPk/wXFug/ubNsb8X+aOesKZe3rmTYp6vpV ilteytrK0fOQ/kWv4yfjiUvM93efMvxkzmpzf3fbbZd/9wtX9S+fvwnvrPvvdaq6082mxaePL 72dKEAc/32D6oxmlqepTIf1jTa3U440jd55m6H5qPh0bOVfzSuObbMUWjGN5MXl2a8Nf2/5qp Iyp24YjXOBpYVbYd8dFJ09+oZXe42M9RdJ37FdWrsDqsTHf6z9LpnzYt7sPYLD9+KLWkvxHL/ sYQnbToT/bHNc88P+0UTUirrjY7lS3VaTkpJ6WvcKpPqFnhj9aGZUYd+bFm58uTVxxuqGg80b NV69cxAQbtHiaU4I9FQi7moOBEAIg/U2JADAAA= X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-9.tower-585.messagelabs.com!1669908558!94255!1 X-Originating-IP: [62.60.8.98] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.101.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29783 invoked from network); 1 Dec 2022 15:29:19 -0000 Received: from unknown (HELO n03ukasimr03.n03.fujitsu.local) (62.60.8.98) by server-9.tower-585.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Dec 2022 15:29:19 -0000 Received: from n03ukasimr03.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTP id AB80F1B6; Thu, 1 Dec 2022 15:29:18 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTPS id 9FFF31B5; Thu, 1 Dec 2022 15:29:18 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 15:29:15 +0000 From: Shiyang Ruan To: , , , CC: , , , Subject: [PATCH v2 1/8] fsdax: introduce page->share for fsdax in reflink mode Date: Thu, 1 Dec 2022 15:28:51 +0000 Message-ID: <1669908538-55-2-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP fsdax page is used not only when CoW, but also mapread. To make the it easily understood, use 'share' to indicate that the dax page is shared by more than one extent. And add helper functions to use it. Also, the flag needs to be renamed to PAGE_MAPPING_DAX_SHARED. Signed-off-by: Shiyang Ruan --- fs/dax.c | 38 ++++++++++++++++++++++---------------- include/linux/mm_types.h | 5 ++++- include/linux/page-flags.h | 2 +- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 1c6867810cbd..85b81963ea31 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -334,35 +334,41 @@ static unsigned long dax_end_pfn(void *entry) for (pfn = dax_to_pfn(entry); \ pfn < dax_end_pfn(entry); pfn++) -static inline bool dax_mapping_is_cow(struct address_space *mapping) +static inline bool dax_mapping_is_shared(struct page *page) { - return (unsigned long)mapping == PAGE_MAPPING_DAX_COW; + return (unsigned long)page->mapping == PAGE_MAPPING_DAX_SHARED; } /* - * Set the page->mapping with FS_DAX_MAPPING_COW flag, increase the refcount. + * Set the page->mapping with PAGE_MAPPING_DAX_SHARED flag, increase the + * refcount. */ -static inline void dax_mapping_set_cow(struct page *page) +static inline void dax_mapping_set_shared(struct page *page) { - if ((uintptr_t)page->mapping != PAGE_MAPPING_DAX_COW) { + if ((uintptr_t)page->mapping != PAGE_MAPPING_DAX_SHARED) { /* * Reset the index if the page was already mapped * regularly before. */ if (page->mapping) - page->index = 1; - page->mapping = (void *)PAGE_MAPPING_DAX_COW; + page->share = 1; + page->mapping = (void *)PAGE_MAPPING_DAX_SHARED; } - page->index++; + page->share++; +} + +static inline unsigned long dax_mapping_decrease_shared(struct page *page) +{ + return --page->share; } /* - * When it is called in dax_insert_entry(), the cow flag will indicate that + * When it is called in dax_insert_entry(), the shared flag will indicate that * whether this entry is shared by multiple files. If so, set the page->mapping - * FS_DAX_MAPPING_COW, and use page->index as refcount. + * PAGE_MAPPING_DAX_SHARED, and use page->share as refcount. */ static void dax_associate_entry(void *entry, struct address_space *mapping, - struct vm_area_struct *vma, unsigned long address, bool cow) + struct vm_area_struct *vma, unsigned long address, bool shared) { unsigned long size = dax_entry_size(entry), pfn, index; int i = 0; @@ -374,8 +380,8 @@ static void dax_associate_entry(void *entry, struct address_space *mapping, for_each_mapped_pfn(entry, pfn) { struct page *page = pfn_to_page(pfn); - if (cow) { - dax_mapping_set_cow(page); + if (shared) { + dax_mapping_set_shared(page); } else { WARN_ON_ONCE(page->mapping); page->mapping = mapping; @@ -396,9 +402,9 @@ static void dax_disassociate_entry(void *entry, struct address_space *mapping, struct page *page = pfn_to_page(pfn); WARN_ON_ONCE(trunc && page_ref_count(page) > 1); - if (dax_mapping_is_cow(page->mapping)) { - /* keep the CoW flag if this page is still shared */ - if (page->index-- > 0) + if (dax_mapping_is_shared(page)) { + /* keep the shared flag if this page is still shared */ + if (dax_mapping_decrease_shared(page) > 0) continue; } else WARN_ON_ONCE(page->mapping && page->mapping != mapping); diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 500e536796ca..f46cac3657ad 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -103,7 +103,10 @@ struct page { }; /* See page-flags.h for PAGE_MAPPING_FLAGS */ struct address_space *mapping; - pgoff_t index; /* Our offset within mapping. */ + union { + pgoff_t index; /* Our offset within mapping. */ + unsigned long share; /* share count for fsdax */ + }; /** * @private: Mapping-private opaque data. * Usually used for buffer_heads if PagePrivate. diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 0b0ae5084e60..c8a3aa02278d 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -641,7 +641,7 @@ PAGEFLAG_FALSE(VmemmapSelfHosted, vmemmap_self_hosted) * Different with flags above, this flag is used only for fsdax mode. It * indicates that this page->mapping is now under reflink case. */ -#define PAGE_MAPPING_DAX_COW 0x1 +#define PAGE_MAPPING_DAX_SHARED 0x1 static __always_inline bool folio_mapping_flags(struct folio *folio) { From patchwork Thu Dec 1 15:28:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13061448 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8040A6FD7 for ; Thu, 1 Dec 2022 15:29:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1669908562; i=@fujitsu.com; bh=vBpyht6zBsjBSm3ky1RkPkN8vgWTjrJcf3ER0ebcTM4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qi3K4Nn2GwqiVoc9sZrDhXcYMFaiZVRWJN+sNxi34ibHfwYNBIAgRpcOb9brLWi4w mLThtJ5hx485wqlSNyDUs6Qr1gOvEBZJObrQM6m56uuj8hT1nBxVYaTzLnauzJWl+2 UKkTIh/rRg1sdnaYaYXFYuWjdaQGUifsKS1zz6o/jLXkdQW1+2Vle2d8FWl8kEI1Yw w4R0agFm/4ZLOFlxf1WyCJril8z9EllDIPul0rWW+O8Pj3ye0g6Plt1/hvAT+lnP2j RPyUhjJ4VV0yGHG8WZxmhdA+KojPi1LzsnpjPFwRjLz6YijfW8FCQRm7l9NgKUBqO/ H0HJ5ikyyxnSQ== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRWlGSWpSXmKPExsViZ8MxSTfoREe ywaoLMhZz1q9hs5g+9QKjxZZj9xgtLj/hs9iz9ySLxeVdc9gsdv3ZwW6x8scfVgcOj1OLJDwW 73nJ5LFpVSebx4kZv1k8XmyeyejxeZNcAFsUa2ZeUn5FAmvGttmnWAvWClV032hjbGC8zdfFy MUhJLCFUeL6nCksEM5yJok7szYwQzh7GCXWvb3N1MXIycEmoCNxYcFf1i5GDg4RgWqJW0vZQM LMAhkSx6/8YQaxhQUsJFZM7mcFsVkEVCT27bvDAmLzCrhItD5YDVYjIaAgMeXhezCbU8BV4uX fjewgthBQzfXmg8wQ9YISJ2c+YYGYLyFx8MULZpC1EgJKEjO74yHGVEjMmtXGBGGrSVw9t4l5 AqPgLCTds5B0L2BkWsVoWpxaVJZapGupl1SUmZ5RkpuYmaOXWKWbqJdaqlueWlyia6SXWF6sl 1pcrFdcmZuck6KXl1qyiREYKynF6qo7GM8t+6N3iFGSg0lJlFd7X0eyEF9SfkplRmJxRnxRaU 5q8SFGGQ4OJQnelD1AOcGi1PTUirTMHGDcwqQlOHiURHj5jgGleYsLEnOLM9MhUqcYFaXEeS+ CJARAEhmleXBtsFRxiVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iw77ZtQFN4MvNK4Ka/AlrM BLQ4UqwNZHFJIkJKqoFp2vyPr7W7A/UXyz6e/bIrJFS+5Npl5k/JnQstSvsqoz59lAq1E27Nj jnCE1u05b5g/MtUE7k/bxuKvG+8vFkdGmV0J7W95d5T3y+bjJXWb1ySU7aMx/Uvb3Ds2T+buw VaZl8uU97CsKbuwl5Nvp2ZvqzLZ1a98vT/tnmBV1B9vtsPF5EeV+GHBs8sc/QWPHly78D2W/u 3/5P0W/tvnaZReF++5Sb+wOW+ldMz73d0XJ409fYptQfn3x0T5FqQNDfZ//OVndf3yPOcUJwu M0uE0/mj5vbpOhtv+ybePSDuYNb1TeH7Y7W9eSp/e2sY5VK2yfwKXfCMXb7pQv5Hb8mjfdrzp UVuBXCtVGx7rTpBiaU4I9FQi7moOBEA4UmsiZADAAA= X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-7.tower-571.messagelabs.com!1669908562!94882!1 X-Originating-IP: [62.60.8.146] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.101.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15045 invoked from network); 1 Dec 2022 15:29:22 -0000 Received: from unknown (HELO n03ukasimr02.n03.fujitsu.local) (62.60.8.146) by server-7.tower-571.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Dec 2022 15:29:22 -0000 Received: from n03ukasimr02.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTP id 23ED01000DB; Thu, 1 Dec 2022 15:29:22 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTPS id 16F0E1000C1; Thu, 1 Dec 2022 15:29:22 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 15:29:18 +0000 From: Shiyang Ruan To: , , , CC: , , , Subject: [PATCH v2 2/8] fsdax: invalidate pages when CoW Date: Thu, 1 Dec 2022 15:28:52 +0000 Message-ID: <1669908538-55-3-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP CoW changes the share state of a dax page, but the share count of the page isn't updated. The next time access this page, it should have been a newly accessed, but old association exists. So, we need to clear the share state when CoW happens, in both dax_iomap_rw() and dax_zero_iter(). Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/dax.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 85b81963ea31..482dda85ccaf 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1264,6 +1264,15 @@ static s64 dax_zero_iter(struct iomap_iter *iter, bool *did_zero) if (srcmap->type == IOMAP_HOLE || srcmap->type == IOMAP_UNWRITTEN) return length; + /* + * invalidate the pages whose sharing state is to be changed + * because of CoW. + */ + if (iomap->flags & IOMAP_F_SHARED) + invalidate_inode_pages2_range(iter->inode->i_mapping, + pos >> PAGE_SHIFT, + (pos + length - 1) >> PAGE_SHIFT); + do { unsigned offset = offset_in_page(pos); unsigned size = min_t(u64, PAGE_SIZE - offset, length); @@ -1324,12 +1333,13 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, struct iov_iter *iter) { const struct iomap *iomap = &iomi->iomap; - const struct iomap *srcmap = &iomi->srcmap; + const struct iomap *srcmap = iomap_iter_srcmap(iomi); loff_t length = iomap_length(iomi); loff_t pos = iomi->pos; struct dax_device *dax_dev = iomap->dax_dev; loff_t end = pos + length, done = 0; bool write = iov_iter_rw(iter) == WRITE; + bool cow = write && iomap->flags & IOMAP_F_SHARED; ssize_t ret = 0; size_t xfer; int id; @@ -1356,7 +1366,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, * into page tables. We have to tear down these mappings so that data * written by write(2) is visible in mmap. */ - if (iomap->flags & IOMAP_F_NEW) { + if (iomap->flags & IOMAP_F_NEW || cow) { invalidate_inode_pages2_range(iomi->inode->i_mapping, pos >> PAGE_SHIFT, (end - 1) >> PAGE_SHIFT); @@ -1390,8 +1400,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, break; } - if (write && - srcmap->type != IOMAP_HOLE && srcmap->addr != iomap->addr) { + if (cow) { ret = dax_iomap_cow_copy(pos, length, PAGE_SIZE, srcmap, kaddr); if (ret) From patchwork Thu Dec 1 15:28:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13061449 Received: from mail1.bemta37.messagelabs.com (mail1.bemta37.messagelabs.com [85.158.142.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B67336FD7 for ; Thu, 1 Dec 2022 15:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1669908566; i=@fujitsu.com; bh=VAWKmEy62InpmeBtKPSmv+Xw3NA5QI6vwuyFpplRjqk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DsC2GpwQm5wa98lPuyqdM4AC65/eDdzTKWnns5zNber7NrfsO6g+fwK1vgZq2cr16 8BQCF9Il1mlaTQMZ9saWkfxeaATdfvt5CwBy2oeZa13wEdFJNAUxQYqH5fpasTim2A 4YLYU0siS3y2PNRPyKAlvqBkF+BGKlWAYQlkNbtn83lZpW3jl/xl3152ks17JOrHq6 ojkUc2BQ8BXP45PytLDs+UJ+bLuKZaYWLYBrEDoXWFjYHNjIJI3FQbknfbIg46HBfI n0gbFwPrSlwMFztdeG+uVPiY13+fbo9NOeKf2ePF1II8kC2s90/kBw/Ej2ld409kx0 ahbl8p9ESKgXg== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRWlGSWpSXmKPExsViZ8ORqBt2oiP Z4PNaTos569ewWUyfeoHRYsuxe4wWl5/wWezZe5LF4vKuOWwWu/7sYLdY+eMPqwOHx6lFEh6L 97xk8ti0qpPN48SM3yweLzbPZPT4vEkugC2KNTMvKb8igTWjcVcra8Fs7Yp/bVOZGhhfKHUxc nEICWxhlDjX2sLaxcgJ5Cxnkjj90hEisYdR4u6nNWAJNgEdiQsL/gLZHBwiAtUSt5aygYSZBT Ikjl/5wwxiCwv4SDx+OAusnEVAReL0shVMIDavgIvEk2kTweISAgoSUx6+B6vnFHCVePl3Izv EXheJ680HmSHqBSVOznzCAjFfQuLgixfMIGslBJQkZnbHQ4ypkJg1q40JwlaTuHpuE/MERsFZ SLpnIelewMi0itGsOLWoLLVI11gvqSgzPaMkNzEzRy+xSjdRL7VUNy+/qCRD11AvsbxYL7W4W K+4Mjc5J0UvL7VkEyMwVlKK09fvYHy39I/eIUZJDiYlUV7tfR3JQnxJ+SmVGYnFGfFFpTmpxY cYZTg4lCR4U/YA5QSLUtNTK9Iyc4BxC5OW4OBREuHlOwaU5i0uSMwtzkyHSJ1iVJQS570IkhA ASWSU5sG1wVLFJUZZKWFeRgYGBiGegtSi3MwSVPlXjOIcjErCvNu2AU3hycwrgZv+CmgxE9Di SLE2kMUliQgpqQamdZOehtgfNfukyHzSdmaP2BLDZ+KqEU3r5uzeab4yLM/vc81/F4vsXSuaj sjEm6TtjZmxePr2K+uyWPfucp2XtLTwm0iPzAuZtzcPden9XeSqlHBQTMCuVrel8QCnzj3V9/ OCsi01M7SOlzHnvnXfEGDyNqEzL7fYX+DqlDnzQ+dz6PTXd2huv2WSpfqrfn2kpHhk9f0nibL XjWdO4jO63ffh3Qlx0YRknkneDCqb/wv4H3/QbBF9/qgPx9Q96x3320rf23/4z7ZQHe+O3Bmh cySX3BOqqbsf36ymYOFZX/rqy5m1Asb8j9jn5ZmWthpuYpzveDr9bvxZwUD1RP/qikjBSynGt cu79okaGCixFGckGmoxFxUnAgChjXzJkAMAAA== X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-4.tower-728.messagelabs.com!1669908565!130706!1 X-Originating-IP: [62.60.8.97] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.101.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23126 invoked from network); 1 Dec 2022 15:29:26 -0000 Received: from unknown (HELO n03ukasimr01.n03.fujitsu.local) (62.60.8.97) by server-4.tower-728.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Dec 2022 15:29:26 -0000 Received: from n03ukasimr01.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTP id 898641001A4; Thu, 1 Dec 2022 15:29:25 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTPS id 7DA1810019E; Thu, 1 Dec 2022 15:29:25 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 15:29:22 +0000 From: Shiyang Ruan To: , , , CC: , , , Subject: [PATCH v2 3/8] fsdax: zero the edges if source is HOLE or UNWRITTEN Date: Thu, 1 Dec 2022 15:28:53 +0000 Message-ID: <1669908538-55-4-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP If srcmap contains invalid data, such as HOLE and UNWRITTEN, the dest page should be zeroed. Otherwise, since it's a pmem, old data may remains on the dest page, the result of CoW will be incorrect. The function name is also not easy to understand, rename it to "dax_iomap_copy_around()", which means it copys data around the range. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/dax.c | 78 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 482dda85ccaf..6b6e07ad8d80 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1092,7 +1092,7 @@ static int dax_iomap_direct_access(const struct iomap *iomap, loff_t pos, } /** - * dax_iomap_cow_copy - Copy the data from source to destination before write + * dax_iomap_copy_around - Copy the data from source to destination before write * @pos: address to do copy from. * @length: size of copy operation. * @align_size: aligned w.r.t align_size (either PMD_SIZE or PAGE_SIZE) @@ -1101,35 +1101,50 @@ static int dax_iomap_direct_access(const struct iomap *iomap, loff_t pos, * * This can be called from two places. Either during DAX write fault (page * aligned), to copy the length size data to daddr. Or, while doing normal DAX - * write operation, dax_iomap_actor() might call this to do the copy of either + * write operation, dax_iomap_iter() might call this to do the copy of either * start or end unaligned address. In the latter case the rest of the copy of - * aligned ranges is taken care by dax_iomap_actor() itself. + * aligned ranges is taken care by dax_iomap_iter() itself. + * If the srcmap contains invalid data, such as HOLE and UNWRITTEN, zero the + * area to make sure no old data remains. */ -static int dax_iomap_cow_copy(loff_t pos, uint64_t length, size_t align_size, +static int dax_iomap_copy_around(loff_t pos, uint64_t length, size_t align_size, const struct iomap *srcmap, void *daddr) { loff_t head_off = pos & (align_size - 1); size_t size = ALIGN(head_off + length, align_size); loff_t end = pos + length; loff_t pg_end = round_up(end, align_size); + /* copy_all is usually in page fault case */ bool copy_all = head_off == 0 && end == pg_end; + /* zero the edges if srcmap is a HOLE or IOMAP_UNWRITTEN */ + bool zero_edge = srcmap->flags & IOMAP_F_SHARED || + srcmap->type == IOMAP_UNWRITTEN; void *saddr = 0; int ret = 0; - ret = dax_iomap_direct_access(srcmap, pos, size, &saddr, NULL); - if (ret) - return ret; + if (!zero_edge) { + ret = dax_iomap_direct_access(srcmap, pos, size, &saddr, NULL); + if (ret) + return ret; + } if (copy_all) { - ret = copy_mc_to_kernel(daddr, saddr, length); - return ret ? -EIO : 0; + if (zero_edge) + memset(daddr, 0, size); + else + ret = copy_mc_to_kernel(daddr, saddr, length); + goto out; } /* Copy the head part of the range */ if (head_off) { - ret = copy_mc_to_kernel(daddr, saddr, head_off); - if (ret) - return -EIO; + if (zero_edge) + memset(daddr, 0, head_off); + else { + ret = copy_mc_to_kernel(daddr, saddr, head_off); + if (ret) + return -EIO; + } } /* Copy the tail part of the range */ @@ -1137,12 +1152,19 @@ static int dax_iomap_cow_copy(loff_t pos, uint64_t length, size_t align_size, loff_t tail_off = head_off + length; loff_t tail_len = pg_end - end; - ret = copy_mc_to_kernel(daddr + tail_off, saddr + tail_off, - tail_len); - if (ret) - return -EIO; + if (zero_edge) + memset(daddr + tail_off, 0, tail_len); + else { + ret = copy_mc_to_kernel(daddr + tail_off, + saddr + tail_off, tail_len); + if (ret) + return -EIO; + } } - return 0; +out: + if (zero_edge) + dax_flush(srcmap->dax_dev, daddr, size); + return ret ? -EIO : 0; } /* @@ -1241,13 +1263,10 @@ static int dax_memzero(struct iomap_iter *iter, loff_t pos, size_t size) if (ret < 0) return ret; memset(kaddr + offset, 0, size); - if (srcmap->addr != iomap->addr) { - ret = dax_iomap_cow_copy(pos, size, PAGE_SIZE, srcmap, - kaddr); - if (ret < 0) - return ret; - dax_flush(iomap->dax_dev, kaddr, PAGE_SIZE); - } else + if (iomap->flags & IOMAP_F_SHARED) + ret = dax_iomap_copy_around(pos, size, PAGE_SIZE, srcmap, + kaddr); + else dax_flush(iomap->dax_dev, kaddr + offset, size); return ret; } @@ -1401,8 +1420,8 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, } if (cow) { - ret = dax_iomap_cow_copy(pos, length, PAGE_SIZE, srcmap, - kaddr); + ret = dax_iomap_copy_around(pos, length, PAGE_SIZE, + srcmap, kaddr); if (ret) break; } @@ -1547,7 +1566,7 @@ static vm_fault_t dax_fault_iter(struct vm_fault *vmf, struct xa_state *xas, void **entry, bool pmd) { const struct iomap *iomap = &iter->iomap; - const struct iomap *srcmap = &iter->srcmap; + const struct iomap *srcmap = iomap_iter_srcmap(iter); size_t size = pmd ? PMD_SIZE : PAGE_SIZE; loff_t pos = (loff_t)xas->xa_index << PAGE_SHIFT; bool write = iter->flags & IOMAP_WRITE; @@ -1578,9 +1597,8 @@ static vm_fault_t dax_fault_iter(struct vm_fault *vmf, *entry = dax_insert_entry(xas, vmf, iter, *entry, pfn, entry_flags); - if (write && - srcmap->type != IOMAP_HOLE && srcmap->addr != iomap->addr) { - err = dax_iomap_cow_copy(pos, size, size, srcmap, kaddr); + if (write && iomap->flags & IOMAP_F_SHARED) { + err = dax_iomap_copy_around(pos, size, size, srcmap, kaddr); if (err) return dax_fault_return(err); } From patchwork Thu Dec 1 15:28:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13061450 Received: from mail1.bemta32.messagelabs.com (mail1.bemta32.messagelabs.com [195.245.230.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A2587466 for ; Thu, 1 Dec 2022 15:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1669908569; i=@fujitsu.com; bh=VLgjPObXgDpD1EhbJ2E6IzLMPYjKp+jmi2A+kdHqNOM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZHqViv6f4ubT/O7/fDQ/o7jHdDwUCU+09tQjn10UaML/hPQfxjU7njJU00mskzezU w86eFLSpAETBvOb8DDYGnQYnMBcPOfMHwYI98jHsMkp5Li8JxoGTdmI+AYzPjz/Hue OCksRXQBYfQdHvb2/BwA3p5jWB/VOJt0J7zCQQEU9SxJgsnvL6SuIF9cjxmxvhFeC4 BYwKO9Dfm4OHXY8xNndOfN6WEvjFuZ4hAMCOgNsYDaUSQy2ZEqMWVLn4COlK0cqVau X7+TRnwfMXlfQVvZNdM70oIjbiayo2z3pcBo1M3Dk0Vfk/pYzlQdTJf9Te8z7FhkAn lpNHs0HfI0owg== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkleJIrShJLcpLzFFi42Kxs+FI0o080ZF s8OKhuMWc9WvYLKZPvcBoseXYPUaLy0/4LPbsPclicXnXHDaLXX92sFus/PGH1YHD49QiCY/F e14yeWxa1cnmcWLGbxaPF5tnMnp83iQXwBbFmpmXlF+RwJqxdsZW1oIWiYp9FxpZGhi7RLoYu TiEBDYyShxu38QI4SxmkmhvmMYM4exhlLh9dhKQw8nBJqAjcWHBX9YuRg4OEYFqiVtL2UDCzA IZEsev/AErERYIlLj2djkriM0ioCKxd+8RJhCbV8BF4sSUyewgtoSAgsSUh+/B6jkFXCVe/t0 IFhcCqrnefJAZol5Q4uTMJywQ8yUkDr54wQyyVkJASWJmdzzEmAqJWbPamCBsNYmr5zYxT2AU nIWkexaS7gWMTKsYTYtTi8pSi3RN9JKKMtMzSnITM3P0Eqt0E/VSS3XLU4tLdA31EsuL9VKLi /WKK3OTc1L08lJLNjECYyWlmM1nB+O/pX/0DjFKcjApifJq7+tIFuJLyk+pzEgszogvKs1JLT 7EKMPBoSTBm7IHKCdYlJqeWpGWmQOMW5i0BAePkggv3zGgNG9xQWJucWY6ROoUoy7H2oYDe5m FWPLy81KlxHkvghQJgBRllObBjYClkEuMslLCvIwMDAxCPAWpRbmZJajyrxjFORiVhHm3bQOa wpOZVwK36RXQEUxAR0SKtYEcUZKIkJJqYDJO4H37W+l94N/vNzJ450xeZBC0buuvbGV2Hs7pr ueZ81LnZjcF7tKvXPhekz/0p4Tgo6pSxW/nPaqStx1xjFure2DK4pcy3gsqed5U1fzzPZq3rO CryNZJMfOafNWmKB1O58mOPvJgztcv62XeMAXMqvptePvNE9sUi4f33kfzpIlcibFptX84b03 CDYGbdRfOtKqnh0S/yuKYHdldEyxRNOtTxK47V/5eW5klqWS1ccISdha2p+GpFxqb/UoPzF/J E/b3kdGr/af3W/+sdeoKlQ+75DtRV7zlZdaeH8943Gafjbo89ai29DfvrV+qvJ/9z+PK8arp/ 5ciy7KZ8eGNzMdzG713a6/S5Xw6c54SS3FGoqEWc1FxIgCPb58anAMAAA== X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-11.tower-591.messagelabs.com!1669908569!125677!1 X-Originating-IP: [62.60.8.98] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.101.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15571 invoked from network); 1 Dec 2022 15:29:29 -0000 Received: from unknown (HELO n03ukasimr03.n03.fujitsu.local) (62.60.8.98) by server-11.tower-591.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Dec 2022 15:29:29 -0000 Received: from n03ukasimr03.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTP id ECD0B1B6; Thu, 1 Dec 2022 15:29:28 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTPS id E13417B; Thu, 1 Dec 2022 15:29:28 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 15:29:25 +0000 From: Shiyang Ruan To: , , , CC: , , , Subject: [PATCH v2 4/8] fsdax,xfs: set the shared flag when file extent is shared Date: Thu, 1 Dec 2022 15:28:54 +0000 Message-ID: <1669908538-55-5-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP If a dax page is shared, mapread at different offsets can also trigger page fault on same dax page. So, change the flag from "cow" to "shared". And get the shared flag from filesystem when read. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/dax.c | 19 +++++++------------ fs/xfs/xfs_iomap.c | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 6b6e07ad8d80..f1eb59bee0b5 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -846,12 +846,6 @@ static bool dax_fault_is_synchronous(const struct iomap_iter *iter, (iter->iomap.flags & IOMAP_F_DIRTY); } -static bool dax_fault_is_cow(const struct iomap_iter *iter) -{ - return (iter->flags & IOMAP_WRITE) && - (iter->iomap.flags & IOMAP_F_SHARED); -} - /* * By this point grab_mapping_entry() has ensured that we have a locked entry * of the appropriate size so we don't have to worry about downgrading PMDs to @@ -865,13 +859,14 @@ static void *dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, { struct address_space *mapping = vmf->vma->vm_file->f_mapping; void *new_entry = dax_make_entry(pfn, flags); - bool dirty = !dax_fault_is_synchronous(iter, vmf->vma); - bool cow = dax_fault_is_cow(iter); + bool write = iter->flags & IOMAP_WRITE; + bool dirty = write && !dax_fault_is_synchronous(iter, vmf->vma); + bool shared = iter->iomap.flags & IOMAP_F_SHARED; if (dirty) __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); - if (cow || (dax_is_zero_entry(entry) && !(flags & DAX_ZERO_PAGE))) { + if (shared || (dax_is_zero_entry(entry) && !(flags & DAX_ZERO_PAGE))) { unsigned long index = xas->xa_index; /* we are replacing a zero page with block mapping */ if (dax_is_pmd_entry(entry)) @@ -883,12 +878,12 @@ static void *dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, xas_reset(xas); xas_lock_irq(xas); - if (cow || dax_is_zero_entry(entry) || dax_is_empty_entry(entry)) { + if (shared || dax_is_zero_entry(entry) || dax_is_empty_entry(entry)) { void *old; dax_disassociate_entry(entry, mapping, false); dax_associate_entry(new_entry, mapping, vmf->vma, vmf->address, - cow); + shared); /* * Only swap our new entry into the page cache if the current * entry is a zero page or an empty entry. If a normal PTE or @@ -908,7 +903,7 @@ static void *dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, if (dirty) xas_set_mark(xas, PAGECACHE_TAG_DIRTY); - if (cow) + if (write && shared) xas_set_mark(xas, PAGECACHE_TAG_TOWRITE); xas_unlock_irq(xas); diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 07da03976ec1..881de99766ca 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1215,7 +1215,7 @@ xfs_read_iomap_begin( return error; error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap, &nimaps, 0); - if (!error && (flags & IOMAP_REPORT)) + if (!error && ((flags & IOMAP_REPORT) || IS_DAX(inode))) error = xfs_reflink_trim_around_shared(ip, &imap, &shared); xfs_iunlock(ip, lockmode); From patchwork Thu Dec 1 15:31:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13061465 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D606A6FD7 for ; Thu, 1 Dec 2022 15:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1669908714; i=@fujitsu.com; bh=DwmuvltIcEZwsFYpJnduqk+5Mi19vbbqL3UVPwHv6IA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GUNhchbEYqDQg5nKnK2Rb676L2BzsMHVeuLJWYylN0YAVcdC5WaLPG63F1J1wspdx N6cJAnil+pVslYr2ehL5kQruHi98wnc0hh06BYGABgka82tbs/oweLkeXMMKmWOvO7 DEcUvh5J6ft+cdE53f5IZGJtY5sY8DQtN0+Wc369quLHGMlpzV1kJKRi435C6i349j TDmuMzm5yp0PASL0abVz3SCHiVr7wXq/be0PdmSoOfuaAA3aTzFFRuW+v1Wdqi8Y0R JZeyboJYp7sBt5Y5fZebvdXGqYQ6No414Nqv8ZdmBcItaS0nt1BThkKsuUEBLpU+tO t3K4mpdINYAyg== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRWlGSWpSXmKPExsViZ8ORpPvyREe ywfLbBhZz1q9hs5g+9QKjxZZj9xgtLj/hs9iz9ySLxeVdc9gsdv3ZwW6x8scfVgcOj1OLJDwW 73nJ5LFpVSebx4kZv1k8XmyeyejxeZNcAFsUa2ZeUn5FAmvGvkmFBds4K/bOecnSwHiavYuRi 0NIYCOjRNuBLywQzhImiYOfp7JCOHsYJTb9e8rUxcjJwSagI3FhwV+gBAeHiEC1xK2lbCBhZo EMieNX/jCD2MICbhLPWqcwgpSwCKhI3PrgABLmFXCROH9+L1iJhICCxJSH78FsTgFXiZd/N7K D2EJANdebDzJD1AtKnJz5hAVivITEwRcvmEFGSggoSczsjocYUyExa1YbE4StJnH13CbmCYyC s5B0z0LSvYCRaRWjWXFqUVlqka6RgV5SUWZ6RkluYmaOXmKVbqJeaqlueWpxia6RXmJ5sV5qc bFecWVuck6KXl5qySZGYKSkFKtf3MHYueyP3iFGSQ4mJVFe7X0dyUJ8SfkplRmJxRnxRaU5qc WHGGU4OJQkeFP2AOUEi1LTUyvSMnOAUQuTluDgURLh5TsGlOYtLkjMLc5Mh0idYlSUEucNPA6 UEABJZJTmwbXBEsUlRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK827YBTeHJzCuBm/4KaDET 0OJIsTaQxSWJCCmpBibBN2zhWmnfRI8qygql/uz7ksV6dWr5InnZJqVzt1iPbOLynTTV8ceB3 bcn7Xzt7JZWKtNUf1LINrSO5U5whprO46+u2plf5N48DWi/tdNkyq7yrtrXHbxvV6ydH1KnvK vxotuUeXt+p6lKP5WQb8/bJpA9nXNDROrc88XXznm+FzEL00qIPcE3N2LxrtvLfe0F979au1N IVniC6sQjhl2Nsuq7v3ja1Lq+sFL07FdQuHdTeLFC+Md3hfsPe64+X3O38se5xptmex8dZTeQ 0zbla7JMOaadVBn4JPnNXb+O+TVBxXaytX0TdfxMJrcl9jvsLO5fVDTpmuN9r4ff9JcnxnOIy Yck/K/h+28zV4mlOCPRUIu5qDgRAJTqiO2PAwAA X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-13.tower-565.messagelabs.com!1669908713!237383!1 X-Originating-IP: [62.60.8.98] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.101.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21145 invoked from network); 1 Dec 2022 15:31:53 -0000 Received: from unknown (HELO n03ukasimr03.n03.fujitsu.local) (62.60.8.98) by server-13.tower-565.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Dec 2022 15:31:53 -0000 Received: from n03ukasimr03.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTP id 723ED1B5; Thu, 1 Dec 2022 15:31:53 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr03.n03.fujitsu.local (Postfix) with ESMTPS id 65B421B6; Thu, 1 Dec 2022 15:31:53 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 15:31:50 +0000 From: Shiyang Ruan To: , , , CC: , , , Subject: [PATCH v2 5/8] fsdax: dedupe: iter two files at the same time Date: Thu, 1 Dec 2022 15:31:41 +0000 Message-ID: <1669908701-93-1-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP The iomap_iter() on a range of one file may loop more than once. In this case, the inner dst_iter can update its iomap but the outer src_iter can't. This may cause the wrong remapping in filesystem. Let them called at the same time. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/dax.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index f1eb59bee0b5..354be56750c2 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1964,15 +1964,15 @@ int dax_dedupe_file_range_compare(struct inode *src, loff_t srcoff, .len = len, .flags = IOMAP_DAX, }; - int ret; + int ret, compared = 0; - while ((ret = iomap_iter(&src_iter, ops)) > 0) { - while ((ret = iomap_iter(&dst_iter, ops)) > 0) { - dst_iter.processed = dax_range_compare_iter(&src_iter, - &dst_iter, len, same); - } - if (ret <= 0) - src_iter.processed = ret; + while ((ret = iomap_iter(&src_iter, ops)) > 0 && + (ret = iomap_iter(&dst_iter, ops)) > 0) { + compared = dax_range_compare_iter(&src_iter, &dst_iter, len, + same); + if (compared < 0) + return ret; + src_iter.processed = dst_iter.processed = compared; } return ret; } From patchwork Thu Dec 1 15:32:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13061466 Received: from mail1.bemta34.messagelabs.com (mail1.bemta34.messagelabs.com [195.245.231.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 733B76FD7 for ; Thu, 1 Dec 2022 15:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1669908744; i=@fujitsu.com; bh=JjMcfKen5VZCgTZ82chMW2jTyW7XOSibUTqR+JCgv6E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F6FPe0vPKYARkkBfBNWIrO2wwURKUo00B4sm6BNbela+9AxFfmRGoOSlGvcFrQMSP K01kod0KmjTn+cAMF3pEGTY82ojdxWbtZHCUnD8CFrRFdWkcBxcn6aaQ6GQO0kumqG EKvV9IzU1ofKXyiv4E7CBOrqJIrLRbTRCn49y3e8wZreGZoRFI4WyrZNgv5VEy7Hxj Y+8QanT4Y7IONz3wvFMIOhgBcQr7BWuiHbkxp1W2dJ7lDVnrzJUrPBoFK9Mf5NvAlb vIeasW7o6qoIxzq7JhCe19OXpTur5cJJ/7+u7w7UYS3EAuk2ilkJXwgelh9SsZ/GXZ 6aTte5nKR3aug== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupileJIrShJLcpLzFFi42Kxs+HYrMt+siP ZYM5MKYs569ewWUyfeoHRYsuxe4wWl5/wWezZe5LF4vKuOWwWu/7sYLdY+eMPqwOHx6lFEh6L 97xk8ti0qpPN48SM3yweLzbPZPT4vEkugC2KNTMvKb8igTVj6tJTzAU72SsWvNvG1sA4i62Lk YtDSGAjo8T0I6+YIZwlTBIfbtxkhXD2MEpcW30KyOHkYBPQkbiw4C+QzcEhIlAtcWspG0iYWS BD4viVP8wgtrCAj8TyM8vZQWwWARWJPbcugcV5BVwlJr2fAWZLCChITHn4HszmBIq//LsRrF5 IwEXievNBqHpBiZMzn7BAzJeQOPjiBTPIWgkBJYmZ3fEQYyokZs1qY4Kw1SSuntvEPIFRcBaS 7llIuhcwMq1iNCtOLSpLLdI1NNBLKspMzyjJTczM0Uus0k3USy3VLU8tLtE10kssL9ZLLS7WK 67MTc5J0ctLLdnECIyWlGKVvh2Mb5f90TvEKMnBpCTKq72vI1mILyk/pTIjsTgjvqg0J7X4EK MMB4eSBG/KHqCcYFFqempFWmYOMHJh0hIcPEoivHzHgNK8xQWJucWZ6RCpU4y6HGsbDuxlFmL Jy89LlRLnDTwOVCQAUpRRmgc3ApZELjHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5t22DWgK T2ZeCdymV0BHMAEdESnWBnJESSJCSqqBKWaj8/t58aVf9tZ1VN7fe34+u+XZo++0f2yb+Pxi1 u6ee6LCzVU98kHt4UyNeo37P5qbSvYcZmv80PbuQ9gWUcMLP0Ibz+8tOq3x8PSDXttfy15ov6 vjXWr9WYrj8O17TGksW3bpekddnvzU7FIzi870Xzs22myedGV5kO2faL4Xu40Wlk/K3PJr4r5 7k7bdqr2eLqHNE9EpvorNXf/JbO3HEWsrS3+f46/Y13Xxq8PnlQLXGF/VX3bTnMb3ceZ/7onF m2W+aD1WVIiZ8k0pw/+ApK5eSHB0zAQFTy6R1zZHpoosyPjAzP2Vf23OtPVn/ASWmmpIveHN1 jk35c0K8bsqp66pnnx8VeJ+anKa4iwlluKMREMt5qLiRACtlAd/nQMAAA== X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-6.tower-548.messagelabs.com!1669908743!72999!1 X-Originating-IP: [62.60.8.179] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.101.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24259 invoked from network); 1 Dec 2022 15:32:23 -0000 Received: from unknown (HELO n03ukasimr04.n03.fujitsu.local) (62.60.8.179) by server-6.tower-548.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Dec 2022 15:32:23 -0000 Received: from n03ukasimr04.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr04.n03.fujitsu.local (Postfix) with ESMTP id 1EF7315A; Thu, 1 Dec 2022 15:32:23 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr04.n03.fujitsu.local (Postfix) with ESMTPS id 1233E153; Thu, 1 Dec 2022 15:32:23 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 15:32:19 +0000 From: Shiyang Ruan To: , , , CC: , , , Subject: [PATCH v2 6/8] xfs: use dax ops for zero and truncate in fsdax mode Date: Thu, 1 Dec 2022 15:32:10 +0000 Message-ID: <1669908730-131-1-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Zero and truncate on a dax file may execute CoW. So use dax ops which contains end work for CoW. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_iomap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 881de99766ca..d9401d0300ad 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1370,7 +1370,7 @@ xfs_zero_range( if (IS_DAX(inode)) return dax_zero_range(inode, pos, len, did_zero, - &xfs_direct_write_iomap_ops); + &xfs_dax_write_iomap_ops); return iomap_zero_range(inode, pos, len, did_zero, &xfs_buffered_write_iomap_ops); } @@ -1385,7 +1385,7 @@ xfs_truncate_page( if (IS_DAX(inode)) return dax_truncate_page(inode, pos, did_zero, - &xfs_direct_write_iomap_ops); + &xfs_dax_write_iomap_ops); return iomap_truncate_page(inode, pos, did_zero, &xfs_buffered_write_iomap_ops); } From patchwork Thu Dec 1 15:32:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13061467 Received: from mail1.bemta32.messagelabs.com (mail1.bemta32.messagelabs.com [195.245.230.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F279D6FD7 for ; Thu, 1 Dec 2022 15:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1669908767; i=@fujitsu.com; bh=9IQSXH/mBJ0Rz36RhWdtV/CNJuRmPioRHTD0RIk1xlI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R8uXsH9yOqUsRPaoxjUGuV1g3UHH/LUIaiR0k/bP5MjwbiaqqRWA7fljFcQ2YAdQj Mq3EHaOLmR3DXasTotl3VZEs08QCdzpAhMPitHVel+EABJeMD8PJYJv39OJMJyKcjM kTCFX2YchTMSxYQwO59WfbI4KgfeDUIhXC/H2NaDc3KvIx5LymlVRB0M0La1d3X//w NbICES275v2veOWEyySMOXwTyhMn+dfq/wSHUmiUZ7MiW9rEPWXlAEGbRE5LN+5RJ9 AjhVBR8w5xlNySX0B7ZRK/dVnqXaPJTsdamYbAnTJtGIf7HJIXhKX/87TIS2z9eSc4 IxL0IzbvIPo3A== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjleJIrShJLcpLzFFi42Kxs+GYpCt3siP Z4HqbkcWc9WvYLKZPvcBoseXYPUaLy0/4LPbsPclicXnXHDaLXX92sFus/PGH1YHD49QiCY/F e14yeWxa1cnmcWLGbxaPF5tnMnp83iQXwBbFmpmXlF+RwJrxZtcxpoIdEhXnb3xiaWA8J9LFy MUhJLCFUeL22gb2LkZOIGc5k8SkD84QiT2MElte3WEDSbAJ6EhcWPCXtYuRg0NEoFri1lKwML NAhsTxK3+YQWxhAQuJtl2bweawCKhI/JixlxXE5hVwlXg86SoTiC0hoCAx5eF7sHpOoPjLvxu h9rpIXG8+yAxRLyhxcuYTFoj5EhIHX7xgBlkrIaAkMbM7HmJMhcSsWW1QI9Ukrp7bxDyBUXAW ku5ZSLoXMDKtYjQtTi0qSy3SNdFLKspMzyjJTczM0Uus0k3USy3VLU8tLtE11EssL9ZLLS7WK 67MTc5J0ctLLdnECIyUlGI2nx2M/5b+0TvEKMnBpCTKq72vI1mILyk/pTIjsTgjvqg0J7X4EK MMB4eSBG/KHqCcYFFqempFWmYOMGph0hIcPEoivHzHgNK8xQWJucWZ6RCpU4zGHGsbDuxl5pg 6+99+ZiGWvPy8VClx3sDjQKUCIKUZpXlwg2DJ5BKjrJQwLyMDA4MQT0FqUW5mCar8K0ZxDkYl Yd5t24Cm8GTmlcDtewV0ChPQKZFibSCnlCQipKQamIzLMj/o6NwuimRbyrtgc0zLJy5zBaZf+ tNPyJy1s7CyWPX4ZXFU48mJe2ptS2L5GD+6vJY02RC3J9+KeU0Gd479HR2NP53nJZiFmNg8Lb +tfmVvaexgf0JD7YBHv4nvdanFk+bVxP/atu7oRfeupr0/ymcWu8VL3vo9q+Tn5bLQmvOeZ1/ NVyx+ncPZrc5l0GbRLay/wvOLl6na0x8bJ7FbMJyTsj2ZOK3IzWm5U5fxkZq9Rp+e37P2/J5X Gi91Y+u58y+4S9fe7HvyzN7w0yaX6YbuSccuzjqw9+7JpHtCE8Nmn9x69qPAuXXz1yyUZT0S3 dyo8vuT9Jp3By22O8178iam5SmXJh9ru8Ceg0osxRmJhlrMRcWJAFpNk5yhAwAA X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-22.tower-587.messagelabs.com!1669908766!107085!1 X-Originating-IP: [62.60.8.146] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.101.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27136 invoked from network); 1 Dec 2022 15:32:46 -0000 Received: from unknown (HELO n03ukasimr02.n03.fujitsu.local) (62.60.8.146) by server-22.tower-587.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Dec 2022 15:32:46 -0000 Received: from n03ukasimr02.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTP id 5C5231000D5; Thu, 1 Dec 2022 15:32:46 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr02.n03.fujitsu.local (Postfix) with ESMTPS id 4F77B1000C1; Thu, 1 Dec 2022 15:32:46 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 15:32:42 +0000 From: Shiyang Ruan To: , , , CC: , , , Subject: [PATCH v2 7/8] fsdax,xfs: port unshare to fsdax Date: Thu, 1 Dec 2022 15:32:33 +0000 Message-ID: <1669908753-169-1-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Implement unshare in fsdax mode: copy data from srcmap to iomap. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/dax.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_reflink.c | 8 +++++-- include/linux/dax.h | 2 ++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 354be56750c2..a57e320e7971 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1244,6 +1244,58 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, } #endif /* CONFIG_FS_DAX_PMD */ +static s64 dax_unshare_iter(struct iomap_iter *iter) +{ + struct iomap *iomap = &iter->iomap; + const struct iomap *srcmap = iomap_iter_srcmap(iter); + loff_t pos = iter->pos; + loff_t length = iomap_length(iter); + int id = 0; + s64 ret = 0; + void *daddr = NULL, *saddr = NULL; + + /* don't bother with blocks that are not shared to start with */ + if (!(iomap->flags & IOMAP_F_SHARED)) + return length; + /* don't bother with holes or unwritten extents */ + if (srcmap->type == IOMAP_HOLE || srcmap->type == IOMAP_UNWRITTEN) + return length; + + id = dax_read_lock(); + ret = dax_iomap_direct_access(iomap, pos, length, &daddr, NULL); + if (ret < 0) + goto out_unlock; + + ret = dax_iomap_direct_access(srcmap, pos, length, &saddr, NULL); + if (ret < 0) + goto out_unlock; + + ret = copy_mc_to_kernel(daddr, saddr, length); + if (ret) + ret = -EIO; + +out_unlock: + dax_read_unlock(id); + return ret; +} + +int dax_file_unshare(struct inode *inode, loff_t pos, loff_t len, + const struct iomap_ops *ops) +{ + struct iomap_iter iter = { + .inode = inode, + .pos = pos, + .len = len, + .flags = IOMAP_WRITE | IOMAP_UNSHARE | IOMAP_DAX, + }; + int ret; + + while ((ret = iomap_iter(&iter, ops)) > 0) + iter.processed = dax_unshare_iter(&iter); + return ret; +} +EXPORT_SYMBOL_GPL(dax_file_unshare); + static int dax_memzero(struct iomap_iter *iter, loff_t pos, size_t size) { const struct iomap *iomap = &iter->iomap; diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 93bdd25680bc..fe46bce8cae6 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1693,8 +1693,12 @@ xfs_reflink_unshare( inode_dio_wait(inode); - error = iomap_file_unshare(inode, offset, len, - &xfs_buffered_write_iomap_ops); + if (IS_DAX(inode)) + error = dax_file_unshare(inode, offset, len, + &xfs_dax_write_iomap_ops); + else + error = iomap_file_unshare(inode, offset, len, + &xfs_buffered_write_iomap_ops); if (error) goto out; diff --git a/include/linux/dax.h b/include/linux/dax.h index ba985333e26b..2b5ecb591059 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -205,6 +205,8 @@ static inline void dax_unlock_mapping_entry(struct address_space *mapping, } #endif +int dax_file_unshare(struct inode *inode, loff_t pos, loff_t len, + const struct iomap_ops *ops); int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, const struct iomap_ops *ops); int dax_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, From patchwork Thu Dec 1 15:32:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 13061468 Received: from mail3.bemta32.messagelabs.com (mail3.bemta32.messagelabs.com [195.245.230.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A192D6FD7 for ; Thu, 1 Dec 2022 15:33:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fujitsu.com; s=170520fj; t=1669908800; i=@fujitsu.com; bh=N56u62cITdKOZ72UbsVRhOqgpDhCsAHPIjg3XTUEUqo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZqX9Ng/A5FRaOBokMqIa1rXjoF/vL4mEWMY9qBs6VW9pt/CrHzwlPyE0l++hjl5/y dtYF0f14NOEulZWC7nEIWnb0MVrKLdXclRd4PbV0I3QmTfGl6qOnbvHaWRalVL75Vs /9PQhTnveAm247+CIRT9N4gAExtzOGHADFYJt0qw0rWWprL4i+1sk7fVBv4KXws/5L 1j1sveZ9b55rwjadsclvaaNYq9IvzA0uqiVTdNMrSm1CDhcb+YkMxU22Y1NWU/K1DQ w1ywzpvnWTBiguOaldpkj/8aOEh+GrjOwwMhxfVDEmcKWNDYcgQXPm2lGbyvFEpbBG 74+OhpNxjmhvw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnleJIrShJLcpLzFFi42Kxs+FI1LU/2ZF s8OuMssWc9WvYLKZPvcBoseXYPUaLy0/4LPbsPclicXnXHDaLXX92sFus/PGH1YHD49QiCY/F e14yeWxa1cnmcWLGbxaPF5tnMnp83iQXwBbFmpmXlF+RwJpx8d4FpoIVXBWXn89gbmB8ztHFy MUhJLCFUaJxywVmCGc5k8SMwyvZIJw9jBLTv01i7GLk5GAT0JG4sOAvaxcjB4eIQLXEraVsIG FmgQyJ41f+MIPYwgJuEp9vPwezWQRUJOa3H2QFsXkFXCV+d95hAbElBBQkpjx8D1bDCRR/+Xc jO4gtJOAicb35IDNEvaDEyZlPWCDmS0gcfPGCGWSthICSxMzueIgxFRKzZrUxQdhqElfPbWKe wCg4C0n3LCTdCxiZVjGaFqcWlaUW6RrpJRVlpmeU5CZm5uglVukm6qWW6panFpfoGuollhfrp RYX6xVX5ibnpOjlpZZsYgTGSkoxy+wdjD1L/+gdYpTkYFIS5dXe15EsxJeUn1KZkVicEV9Ump NafIhRhoNDSYI3ZQ9QTrAoNT21Ii0zBxi3MGkJDh4lEV6+Y0Bp3uKCxNzizHSI1ClGY461DQf 2MnNMnf1vP7MQS15+XqqUOG/gcaBSAZDSjNI8uEGwdHKJUVZKmJeRgYFBiKcgtSg3swRV/hWj OAejkjDvtm1AU3gy80rg9r0COoUJ6JRIsTaQU0oSEVJSDUx7StSUf/q9cbwdxXSDReDKiie6G nqBtyar6LrxKldu2lt5SVzgbDqn6lOrxxP2SGje/nAus+VBsc3PhntM/VyH1uuvs5xy/5yHC5 fQ8bBV663V9sSf3eL3vWWJqJd9uu57ceE8h2v5TUfj3Dq7uSJ6C55+iJundn7ngu77p7+GtNi 7S79nvWO2r9pddZXyx1nT/rX26ruuWfjRKn3HdLv4mUZsOpePGMrd7Ht7o1dTz08iLXtqzUqH uwv/aiUbyQVW7znk+/6K2IMVUdErJrH2dCx9kbd0VY7unK+zPKxtncqd7ETXpOY7lcbN2P1h5 xKFhMVB7J1WbO8m7mz6/qQjoyF1yqceVxc+9fh5/5VYijMSDbWYi4oTActQn4KiAwAA X-Env-Sender: ruansy.fnst@fujitsu.com X-Msg-Ref: server-20.tower-585.messagelabs.com!1669908799!42492!1 X-Originating-IP: [62.60.8.97] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.101.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23032 invoked from network); 1 Dec 2022 15:33:19 -0000 Received: from unknown (HELO n03ukasimr01.n03.fujitsu.local) (62.60.8.97) by server-20.tower-585.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Dec 2022 15:33:19 -0000 Received: from n03ukasimr01.n03.fujitsu.local (localhost [127.0.0.1]) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTP id 297E81001A3; Thu, 1 Dec 2022 15:33:19 +0000 (GMT) Received: from R01UKEXCASM126.r01.fujitsu.local (R01UKEXCASM126 [10.183.43.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by n03ukasimr01.n03.fujitsu.local (Postfix) with ESMTPS id 1D4EB10019E; Thu, 1 Dec 2022 15:33:19 +0000 (GMT) Received: from localhost.localdomain (10.167.225.141) by R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 15:33:15 +0000 From: Shiyang Ruan To: , , , CC: , , , Subject: [PATCH v2 8/8] xfs: remove restrictions for fsdax and reflink Date: Thu, 1 Dec 2022 15:32:53 +0000 Message-ID: <1669908773-207-1-git-send-email-ruansy.fnst@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> References: <1669908538-55-1-git-send-email-ruansy.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Originating-IP: [10.167.225.141] X-ClientProxiedBy: G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) To R01UKEXCASM126.r01.fujitsu.local (10.183.43.178) X-Virus-Scanned: ClamAV using ClamSMTP Since the basic function for fsdax and reflink has been implemented, remove the restrictions of them for widly test. Signed-off-by: Shiyang Ruan Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_ioctl.c | 4 ---- fs/xfs/xfs_iops.c | 4 ---- 2 files changed, 8 deletions(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 1f783e979629..13f1b2add390 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1138,10 +1138,6 @@ xfs_ioctl_setattr_xflags( if ((fa->fsx_xflags & FS_XFLAG_REALTIME) && xfs_is_reflink_inode(ip)) ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; - /* Don't allow us to set DAX mode for a reflinked file for now. */ - if ((fa->fsx_xflags & FS_XFLAG_DAX) && xfs_is_reflink_inode(ip)) - return -EINVAL; - /* diflags2 only valid for v3 inodes. */ i_flags2 = xfs_flags2diflags2(ip, fa->fsx_xflags); if (i_flags2 && !xfs_has_v3inodes(mp)) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 2e10e1c66ad6..bf0495f7a5e1 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1185,10 +1185,6 @@ xfs_inode_supports_dax( if (!S_ISREG(VFS_I(ip)->i_mode)) return false; - /* Only supported on non-reflinked files. */ - if (xfs_is_reflink_inode(ip)) - return false; - /* Block size must match page size */ if (mp->m_sb.sb_blocksize != PAGE_SIZE) return false;