From patchwork Mon Sep 25 23:14:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 9970697 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 9D7CC602CB for ; Mon, 25 Sep 2017 23:17:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 907AB26E56 for ; Mon, 25 Sep 2017 23:17:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DEEE28E33; Mon, 25 Sep 2017 23:17:27 +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=ham 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 02FF528E62 for ; Mon, 25 Sep 2017 23:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965420AbdIYXPM (ORCPT ); Mon, 25 Sep 2017 19:15:12 -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 S965718AbdIYXOa (ORCPT ); Mon, 25 Sep 2017 19:14:30 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP; 25 Sep 2017 16:14:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,438,1500966000"; d="scan'208";a="139347302" Received: from theros.lm.intel.com ([10.232.112.77]) by orsmga002.jf.intel.com with ESMTP; 25 Sep 2017 16:14:27 -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 5/7] xfs: introduce xfs_is_dax_state_changing Date: Mon, 25 Sep 2017 17:14:02 -0600 Message-Id: <20170925231404.32723-6-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 Pull this code out of xfs_ioctl_setattr_dax_invalidate() as it will be used in multiple places soon. Signed-off-by: Ross Zwisler --- fs/xfs/xfs_ioctl.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 0433aef..386b437 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1020,6 +1020,27 @@ xfs_diflags_to_linux( #endif } +static bool +xfs_is_dax_state_changing( + unsigned int xflags, + struct xfs_inode *ip) +{ + struct inode *inode = VFS_I(ip); + + /* + * 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 false; + if ((xflags & FS_XFLAG_DAX) && IS_DAX(inode)) + return false; + if (!(xflags & FS_XFLAG_DAX) && !IS_DAX(inode)) + return false; + return true; +} + static int xfs_ioctl_setattr_xflags( struct xfs_trans *tp, @@ -1105,17 +1126,8 @@ xfs_ioctl_setattr_dax_invalidate( return -EINVAL; } - /* - * 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)) + /* If the DAX state is not changing, we have nothing to do here. */ + if (!xfs_is_dax_state_changing(fa->fsx_xflags, ip)) return 0; /* lock, flush and invalidate mapping in preparation for flag change */