Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3209568ybg; Sun, 20 Oct 2019 09:00:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk4CJVCGMKt1TjKg9W7k6FmOpnc5k8wz+gbhaoES21+xq1z/fFLeUWzYSbeR2XyeEZhTfa X-Received: by 2002:a05:6402:891:: with SMTP id e17mr2175314edy.236.1571587241355; Sun, 20 Oct 2019 09:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571587241; cv=none; d=google.com; s=arc-20160816; b=H5aoGUkHBODMrz2oZKgZRiVkmCYE4I/KcRKFTxlW3vID+PnkMbVf+/A442sk3sGQ7D 0uqKvV8mo1kd8p7a5CE9OGnwXo+G3jdUJBNIaLNkncN3SHZ2I2y8SWW5oA7e8jwWUKVM L1yKxcA1ChmzpmoFf3QmvsKbkP84CtaNF82UBR/hGuif2384X27RBgNVda3uvgArDM0f A9vCndqC+Qykpv5BCftzPUsKrVTBIzga0R1Z9fMLlkhOV+gNYtp5EsWuOwQrBs6sHf9O HBoinSKnIBg7iW8EZU8lF1gjX6yez9ztFWbcJYjsJCS4NeLUfsurbPrdm3/D10qE1JEc cXXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=W/MGS+VueMGhjPMAb7O89MxxilODd5jxz44sJ8n7h0U=; b=NLoHIjjrn0zduPG5CZ6fjc6K3hr98hdWk4t9oOnpb6YA1dNxs8uWMZYcqgSqSqDAeL nV7heUatEdsJ5wsMveAM2FBoxNMe+hUQDdsxysCXUXqMZT9M2daw9m1x0wT8eAqyBD00 AG0OzalE8IUeniarudz1gW8X3vzB9xDObxuj8CE3g3QNyxHJthFO0QNd/OzYhXjrNDo5 Y2RWQ+qlSdfhKa+BtcGetWkNghpyzmk1ruAelfGkrDdi3qwg/gkimgfS4d8OidgFvpcu umaqEL/cNzEdTASNExyhqkdfbbkfzXXqiYtCpOu1yFRHh3AzKLh0K+VEtZtli5dj6JIC yXmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si6939583ejb.259.2019.10.20.09.00.17; Sun, 20 Oct 2019 09:00:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726692AbfJTQAB (ORCPT + 99 others); Sun, 20 Oct 2019 12:00:01 -0400 Received: from mga01.intel.com ([192.55.52.88]:46720 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbfJTP77 (ORCPT ); Sun, 20 Oct 2019 11:59:59 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Oct 2019 08:59:59 -0700 X-IronPort-AV: E=Sophos;i="5.67,320,1566889200"; d="scan'208";a="227073625" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Oct 2019 08:59:59 -0700 From: ira.weiny@intel.com To: linux-kernel@vger.kernel.org Cc: Ira Weiny , Alexander Viro , "Darrick J. Wong" , Dan Williams , Dave Chinner , Christoph Hellwig , "Theodore Y. Ts'o" , Jan Kara , linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 4/5] fs/xfs: Clean up DAX support check Date: Sun, 20 Oct 2019 08:59:34 -0700 Message-Id: <20191020155935.12297-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191020155935.12297-1-ira.weiny@intel.com> References: <20191020155935.12297-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ira Weiny Rather than open coding xfs_inode_supports_dax() in xfs_ioctl_setattr_dax_invalidate() export xfs_inode_supports_dax() and call it in preparation for swapping dax flags. This also means updating xfs_inode_supports_dax() to return true for a directory. Signed-off-by: Ira Weiny --- fs/xfs/xfs_ioctl.c | 17 +++-------------- fs/xfs/xfs_iops.c | 8 ++++++-- fs/xfs/xfs_iops.h | 2 ++ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 0ea326290cca..d3a7340d3209 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1299,24 +1299,13 @@ xfs_ioctl_setattr_dax_invalidate( int *join_flags) { struct inode *inode = VFS_I(ip); - struct super_block *sb = inode->i_sb; int error; *join_flags = 0; - /* - * It is only valid to set the DAX flag on regular files and - * directories on filesystems where the block size is equal to the page - * size. On directories it serves as an inherited hint so we don't - * have to check the device for dax support or flush pagecache. - */ - if (fa->fsx_xflags & FS_XFLAG_DAX) { - if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) - return -EINVAL; - if (!bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)), - sb->s_blocksize)) - return -EINVAL; - } + if ((fa->fsx_xflags & FS_XFLAG_DAX) == FS_XFLAG_DAX && + !xfs_inode_supports_dax(ip)) + return -EINVAL; /* If the DAX state is not changing, we have nothing to do here. */ if ((fa->fsx_xflags & FS_XFLAG_DAX) && diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 9e5c79aa1b54..535b87ffc135 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1216,14 +1216,18 @@ xfs_inode_mount_is_dax( } /* Figure out if this file actually supports DAX. */ -static bool +bool xfs_inode_supports_dax( struct xfs_inode *ip) { struct xfs_mount *mp = ip->i_mount; /* Only supported on non-reflinked files. */ - if (!S_ISREG(VFS_I(ip)->i_mode) || xfs_is_reflink_inode(ip)) + if (xfs_is_reflink_inode(ip)) + return false; + + /* Only supported on regular files and directories. */ + if (!(S_ISREG(VFS_I(ip)->i_mode) || S_ISDIR(VFS_I(ip)->i_mode))) return false; /* Block size must match page size */ diff --git a/fs/xfs/xfs_iops.h b/fs/xfs/xfs_iops.h index 4d24ff309f59..f24fec8de1d6 100644 --- a/fs/xfs/xfs_iops.h +++ b/fs/xfs/xfs_iops.h @@ -24,4 +24,6 @@ extern int xfs_setattr_nonsize(struct xfs_inode *ip, struct iattr *vap, extern int xfs_vn_setattr_nonsize(struct dentry *dentry, struct iattr *vap); extern int xfs_vn_setattr_size(struct dentry *dentry, struct iattr *vap); +extern bool xfs_inode_supports_dax(struct xfs_inode *ip); + #endif /* __XFS_IOPS_H__ */ -- 2.20.1