{"id":829942,"url":"http://patchwork.ozlabs.org/api/1.2/patches/829942/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20171024152415.22864-18-jack@suse.cz/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.2/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171024152415.22864-18-jack@suse.cz>","list_archive_url":null,"date":"2017-10-24T15:24:14","name":"[17/17] xfs: support for synchronous DAX faults","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"57a98c6d01124ad3e817042378ca683e0a2a15fa","submitter":{"id":363,"url":"http://patchwork.ozlabs.org/api/1.2/people/363/?format=json","name":"Jan Kara","email":"jack@suse.cz"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20171024152415.22864-18-jack@suse.cz/mbox/","series":[{"id":10008,"url":"http://patchwork.ozlabs.org/api/1.2/series/10008/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=10008","date":"2017-10-24T15:23:57","name":"dax, ext4, xfs: Synchronous page faults","version":5,"mbox":"http://patchwork.ozlabs.org/series/10008/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/829942/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/829942/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linux-ext4-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-ext4-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yLxtV6vQ0z9t2c\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 25 Oct 2017 02:25:54 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932489AbdJXPZw (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 24 Oct 2017 11:25:52 -0400","from mx2.suse.de ([195.135.220.15]:36150 \"EHLO mx2.suse.de\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S932431AbdJXPZf (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tTue, 24 Oct 2017 11:25:35 -0400","from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])\n\tby mx2.suse.de (Postfix) with ESMTP id 54C55AE18;\n\tTue, 24 Oct 2017 15:25:28 +0000 (UTC)","by quack2.suse.cz (Postfix, from userid 1000)\n\tid 76DCA1E35DA; Tue, 24 Oct 2017 17:25:27 +0200 (CEST)"],"X-Virus-Scanned":"by amavisd-new at test-mx.suse.de","From":"Jan Kara <jack@suse.cz>","To":"Dan Williams <dan.j.williams@intel.com>","Cc":"Ross Zwisler <ross.zwisler@linux.intel.com>,\n\tChristoph Hellwig <hch@infradead.org>,\n\t<linux-ext4@vger.kernel.org>, linux-nvdimm@lists.01.org,\n\t<linux-fsdevel@vger.kernel.org>, <linux-xfs@vger.kernel.org>,\n\tlinux-api@vger.kernel.org, <linux-mm@kvack.org>,\n\tChristoph Hellwig <hch@lst.de>, Jan Kara <jack@suse.cz>","Subject":"[PATCH 17/17] xfs: support for synchronous DAX faults","Date":"Tue, 24 Oct 2017 17:24:14 +0200","Message-Id":"<20171024152415.22864-18-jack@suse.cz>","X-Mailer":"git-send-email 2.12.3","In-Reply-To":"<20171024152415.22864-1-jack@suse.cz>","References":"<20171024152415.22864-1-jack@suse.cz>","Sender":"linux-ext4-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-ext4.vger.kernel.org>","X-Mailing-List":"linux-ext4@vger.kernel.org"},"content":"From: Christoph Hellwig <hch@lst.de>\n\nReturn IOMAP_F_DIRTY from xfs_file_iomap_begin() when asked to prepare\nblocks for writing and the inode is pinned, and has dirty fields other\nthan the timestamps.  In __xfs_filemap_fault() we then detect this case\nand call dax_finish_sync_fault() to make sure all metadata is committed,\nand to insert the page table entry.\n\nNote that this will also dirty corresponding radix tree entry which is\nwhat we want - fsync(2) will still provide data integrity guarantees for\napplications not using userspace flushing. And applications using\nuserspace flushing can avoid calling fsync(2) and thus avoid the\nperformance overhead.\n\n[JK: Added VM_SYNC flag handling]\n\nSigned-off-by: Christoph Hellwig <hch@lst.de>\nSigned-off-by: Jan Kara <jack@suse.cz>\n---\n fs/xfs/xfs_file.c  | 15 ++++++++++++++-\n fs/xfs/xfs_iomap.c |  5 +++++\n 2 files changed, 19 insertions(+), 1 deletion(-)","diff":"diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c\nindex 7c6b8def6eed..02093df4b314 100644\n--- a/fs/xfs/xfs_file.c\n+++ b/fs/xfs/xfs_file.c\n@@ -44,6 +44,7 @@\n #include <linux/falloc.h>\n #include <linux/pagevec.h>\n #include <linux/backing-dev.h>\n+#include <linux/mman.h>\n \n static const struct vm_operations_struct xfs_file_vm_ops;\n \n@@ -1040,7 +1041,11 @@ __xfs_filemap_fault(\n \n \txfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED);\n \tif (IS_DAX(inode)) {\n-\t\tret = dax_iomap_fault(vmf, pe_size, NULL, &xfs_iomap_ops);\n+\t\tpfn_t pfn;\n+\n+\t\tret = dax_iomap_fault(vmf, pe_size, &pfn, &xfs_iomap_ops);\n+\t\tif (ret & VM_FAULT_NEEDDSYNC)\n+\t\t\tret = dax_finish_sync_fault(vmf, pe_size, pfn);\n \t} else {\n \t\tif (write_fault)\n \t\t\tret = iomap_page_mkwrite(vmf, &xfs_iomap_ops);\n@@ -1131,6 +1136,13 @@ xfs_file_mmap(\n \tstruct file\t*filp,\n \tstruct vm_area_struct *vma)\n {\n+\t/*\n+\t * We don't support synchronous mappings for non-DAX files. At least\n+\t * until someone comes with a sensible use case.\n+\t */\n+\tif (!IS_DAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC))\n+\t\treturn -EOPNOTSUPP;\n+\n \tfile_accessed(filp);\n \tvma->vm_ops = &xfs_file_vm_ops;\n \tif (IS_DAX(file_inode(filp)))\n@@ -1149,6 +1161,7 @@ const struct file_operations xfs_file_operations = {\n \t.compat_ioctl\t= xfs_file_compat_ioctl,\n #endif\n \t.mmap\t\t= xfs_file_mmap,\n+\t.mmap_supported_flags = MAP_SYNC,\n \t.open\t\t= xfs_file_open,\n \t.release\t= xfs_file_release,\n \t.fsync\t\t= xfs_file_fsync,\ndiff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c\nindex f179bdf1644d..b43be199fbdf 100644\n--- a/fs/xfs/xfs_iomap.c\n+++ b/fs/xfs/xfs_iomap.c\n@@ -33,6 +33,7 @@\n #include \"xfs_error.h\"\n #include \"xfs_trans.h\"\n #include \"xfs_trans_space.h\"\n+#include \"xfs_inode_item.h\"\n #include \"xfs_iomap.h\"\n #include \"xfs_trace.h\"\n #include \"xfs_icache.h\"\n@@ -1086,6 +1087,10 @@ xfs_file_iomap_begin(\n \t\ttrace_xfs_iomap_found(ip, offset, length, 0, &imap);\n \t}\n \n+\tif ((flags & IOMAP_WRITE) && xfs_ipincount(ip) &&\n+\t    (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP))\n+\t\tiomap->flags |= IOMAP_F_DIRTY;\n+\n \txfs_bmbt_to_iomap(ip, iomap, &imap);\n \n \tif (shared)\n","prefixes":["17/17"]}