From patchwork Mon Sep 25 23:13:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 9970687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 34A14602CB for ; Mon, 25 Sep 2017 23:17:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27A7A28C57 for ; Mon, 25 Sep 2017 23:17:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2629928CC2; Mon, 25 Sep 2017 23:17:26 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 6030728E38 for ; Mon, 25 Sep 2017 23:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965679AbdIYXO0 (ORCPT ); Mon, 25 Sep 2017 19:14:26 -0400 Received: from mga07.intel.com ([134.134.136.100]:31168 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965652AbdIYXOZ (ORCPT ); Mon, 25 Sep 2017 19:14:25 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 25 Sep 2017 16:14:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,438,1500966000"; d="scan'208";a="139347172" Received: from theros.lm.intel.com ([10.232.112.77]) by orsmga002.jf.intel.com with ESMTP; 25 Sep 2017 16:14:22 -0700 From: Ross Zwisler To: Andrew Morton , linux-kernel@vger.kernel.org Cc: Ross Zwisler , "Darrick J. Wong" , "J. Bruce Fields" , Christoph Hellwig , Dan Williams , Dave Chinner , Jan Kara , Jeff Layton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org Subject: [PATCH 1/7] xfs: always use DAX if mount option is used Date: Mon, 25 Sep 2017 17:13:58 -0600 Message-Id: <20170925231404.32723-2-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170925231404.32723-1-ross.zwisler@linux.intel.com> References: <20170925231404.32723-1-ross.zwisler@linux.intel.com> 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 Before support for the per-inode DAX flag was disabled the XFS the code had an issue where the user couldn't reliably tell whether or not DAX was being used to service page faults and I/O when the DAX mount option was used. In this case each inode within the mounted filesystem started with S_DAX set due to the mount option, but it could be cleared if someone touched the individual inode flag. For example (v4.13 and before): # mount | grep dax /dev/pmem0 on /mnt type xfs (rw,relatime,seclabel,attr2,dax,inode64,sunit=4096,swidth=4096,noquota) # touch /mnt/a /mnt/b # both files currently use DAX # xfs_io -c "lsattr" /mnt/* # neither has the DAX inode option set ----------e----- /mnt/a ----------e----- /mnt/b # xfs_io -c "chattr -x" /mnt/a # this clears S_DAX for /mnt/a # xfs_io -c "lsattr" /mnt/* ----------e----- /mnt/a ----------e----- /mnt/b We end up with both /mnt/a and /mnt/b looking identical from the point of view of the mount option and from lsattr, but one is using DAX and the other is not. Fix this by always doing DAX I/O when either the mount option is set or when the DAX inode flag is set. This means that DAX will always be used for all inodes on a filesystem mounted with -o dax, making the usage reliable and detectable. Signed-off-by: Ross Zwisler Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_ioctl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 5049e8a..26faeb9 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1013,7 +1013,7 @@ xfs_diflags_to_linux( else inode->i_flags &= ~S_NOATIME; #if 0 /* disabled until the flag switching races are sorted out */ - if (xflags & FS_XFLAG_DAX) + if ((xflags & FS_XFLAG_DAX) || (ip->i_mount->m_flags & XFS_MOUNT_DAX)) inode->i_flags |= S_DAX; else inode->i_flags &= ~S_DAX; @@ -1104,7 +1104,14 @@ xfs_ioctl_setattr_dax_invalidate( return -EINVAL; } - /* If the DAX state is not changing, we have nothing to do here. */ + /* + * If the DAX state is not changing, we have nothing to do here. If + * the DAX mount option was used we will update the DAX inode flag as + * the user requested but we will continue to use DAX for I/O and page + * faults regardless of how the inode flag is set. + */ + if (ip->i_mount->m_flags & XFS_MOUNT_DAX) + return 0; if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_DAX(inode)) return 0; if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode))