{"id":810302,"url":"http://patchwork.ozlabs.org/api/patches/810302/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20170905223541.20594-3-ross.zwisler@linux.intel.com/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/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":"<20170905223541.20594-3-ross.zwisler@linux.intel.com>","list_archive_url":null,"date":"2017-09-05T22:35:34","name":"[2/9] xfs: always use DAX if mount option is used","commit_ref":null,"pull_url":null,"state":"new","archived":true,"hash":"2c2d1c05f09c7512f0e79d55e591ace0fb075834","submitter":{"id":46514,"url":"http://patchwork.ozlabs.org/api/people/46514/?format=json","name":"Ross Zwisler","email":"ross.zwisler@linux.intel.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20170905223541.20594-3-ross.zwisler@linux.intel.com/mbox/","series":[{"id":1660,"url":"http://patchwork.ozlabs.org/api/series/1660/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=1660","date":"2017-09-05T22:35:36","name":"add ext4 per-inode DAX flag","version":1,"mbox":"http://patchwork.ozlabs.org/series/1660/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/810302/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810302/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 3xn1lw51XNz9sP3\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed,  6 Sep 2017 08:36:28 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753751AbdIEWg0 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 5 Sep 2017 18:36:26 -0400","from mga01.intel.com ([192.55.52.88]:63245 \"EHLO mga01.intel.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752834AbdIEWgR (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tTue, 5 Sep 2017 18:36:17 -0400","from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t05 Sep 2017 15:36:15 -0700","from theros.lm.intel.com ([10.232.112.77])\n\tby fmsmga004.fm.intel.com with ESMTP; 05 Sep 2017 15:36:14 -0700"],"X-ExtLoop1":"1","X-IronPort-AV":"E=Sophos;i=\"5.41,481,1498546800\"; d=\"scan'208\";a=\"308314868\"","From":"Ross Zwisler <ross.zwisler@linux.intel.com>","To":"Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org","Cc":"Ross Zwisler <ross.zwisler@linux.intel.com>,\n\t\"Darrick J. Wong\" <darrick.wong@oracle.com>,\n\t\"Theodore Ts'o\" <tytso@mit.edu>,\n\tAndreas Dilger <adilger.kernel@dilger.ca>,\n\tChristoph Hellwig <hch@lst.de>, Dan Williams <dan.j.williams@intel.com>,\n\tDave Chinner <david@fromorbit.com>, Jan Kara <jack@suse.cz>,\n\tlinux-ext4@vger.kernel.org, linux-nvdimm@lists.01.org,\n\tlinux-xfs@vger.kernel.org, stable@vger.kernel.org","Subject":"[PATCH 2/9] xfs: always use DAX if mount option is used","Date":"Tue,  5 Sep 2017 16:35:34 -0600","Message-Id":"<20170905223541.20594-3-ross.zwisler@linux.intel.com>","X-Mailer":"git-send-email 2.9.5","In-Reply-To":"<20170905223541.20594-1-ross.zwisler@linux.intel.com>","References":"<20170905223541.20594-1-ross.zwisler@linux.intel.com>","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":"The current code has an issue where the user can't reliably tell whether or\nnot DAX is being used to service page faults and I/O when the DAX mount\noption is used.  In this case each inode within the mounted filesystem\nstarts with S_DAX set due to the mount option, but it can be cleared if\nsomeone touches the individual inode flag.\n\nFor example:\n\n  # mount | grep dax\n  /dev/pmem0 on /mnt type xfs\n  (rw,relatime,seclabel,attr2,dax,inode64,sunit=4096,swidth=4096,noquota)\n\n  # touch /mnt/a /mnt/b   # both files currently use DAX\n\n  # xfs_io -c \"lsattr\" /mnt/*  # neither has the DAX inode option set\n  ----------e----- /mnt/a\n  ----------e----- /mnt/b\n\n  # xfs_io -c \"chattr -x\" /mnt/a  # this clears S_DAX for /mnt/a\n\n  # xfs_io -c \"lsattr\" /mnt/*\n  ----------e----- /mnt/a\n  ----------e----- /mnt/b\n\nWe end up with both /mnt/a and /mnt/b looking identical from the point of\nview of the mount option and from lsattr, but one is using DAX and the\nother is not.\n\nFix this by always doing DAX I/O when either the mount option is set or\nwhen the DAX inode flag is set.  This means that DAX will always be used\nfor all inodes on a filesystem mounted with -o dax, making the usage\nreliable and detectable.\n\nSigned-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>\nCC: stable@vger.kernel.org\n---\n fs/xfs/xfs_ioctl.c | 11 +++++++++--\n 1 file changed, 9 insertions(+), 2 deletions(-)","diff":"diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c\nindex 9c0c7a9..8155ddc 100644\n--- a/fs/xfs/xfs_ioctl.c\n+++ b/fs/xfs/xfs_ioctl.c\n@@ -1008,7 +1008,7 @@ xfs_diflags_to_linux(\n \t\tinode->i_flags |= S_NOATIME;\n \telse\n \t\tinode->i_flags &= ~S_NOATIME;\n-\tif (xflags & FS_XFLAG_DAX)\n+\tif ((xflags & FS_XFLAG_DAX) || (ip->i_mount->m_flags & XFS_MOUNT_DAX))\n \t\tinode->i_flags |= S_DAX;\n \telse\n \t\tinode->i_flags &= ~S_DAX;\n@@ -1091,7 +1091,14 @@ xfs_ioctl_setattr_dax_invalidate(\n \t\t\treturn -EINVAL;\n \t}\n \n-\t/* If the DAX state is not changing, we have nothing to do here. */\n+\t/*\n+\t * If the DAX state is not changing, we have nothing to do here.  If\n+\t * the DAX mount option was used we will update the DAX inode flag as\n+\t * the user requested but we will continue to use DAX for I/O and page\n+\t * faults regardless of how the inode flag is set.\n+\t */\n+\tif (ip->i_mount->m_flags & XFS_MOUNT_DAX)\n+\t\treturn 0;\n \tif ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_DAX(inode))\n \t\treturn 0;\n \tif (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode))\n","prefixes":["2/9"]}