Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1069459ybl; Fri, 10 Jan 2020 11:31:42 -0800 (PST) X-Google-Smtp-Source: APXvYqy3eMWx8dsaEZWC2CE/xCM3l7/GynDjoxNZpzEvpVNaOBDnok3zRwcjf1LMtFcMV67FcKf6 X-Received: by 2002:aca:48cf:: with SMTP id v198mr3555427oia.35.1578684701913; Fri, 10 Jan 2020 11:31:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578684701; cv=none; d=google.com; s=arc-20160816; b=HpPYSPbo1Yyun+KT9ZRuw6YZAaAYNDF0PiR5SVdHGrWbqWm/4pH8SE6oQp3Oz3nCtG V+6CQvnB7of9OyviVMov6sDeFUIeONY2rrmbD93xy5AaLPkfHztItxlrMYgmyIxkne9I /GNR6m7zseQytecy2w8jh0QRUTB8MpvbtVIb+IjhQC9ImbgYJzWa0TpYi/+v1e0SpYUJ qYmt8WD5ts6pYsYQsWwpy6bQgAHvmv4mDnXoV/9nQ1UnEV0eN24YosCabLEAHLCE+0fh Af3u4OeyqCB0jN75mDyLHp2/20k/o78TTzPSfty6YALovu22RI/wLlNv7mb/hjAmAou6 FORA== 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=XkY81k5eIbT68e/7I5TbgLO94Dr1apF1J2GPOTnqopY=; b=MAtEAhWA3QaTeDMqAB9mZNzfmlRmdwKrocyJYlMEttZfRnKbZcDwWDPTIsFILXIFg2 /am8dPDjJf75A3Wmi+j/NtHy2LDuHXYqmLzpwG8FWCCLlB8/RfXw81sCeu2MbbzK30I5 5ay2eqXl5HFUhuNXTYgCaqP0AAmZDRoV0GEBIsLU7QPoXH1C8wYk1jB4ysyqRHymicof YaeIa1Zuop7Ot/Y/h5b5JQSthLR50l2Z6ixZai8gU3phLEa0cuGb/Gv1RUspabm+nD5O Q5O22+5/Q32pOCThfsbcOk07MvDVaz5I4fDIJyW24XNOrdZ5gf1+Og/ZCkHBHOsgGyS7 Lm5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 l84si1531630oig.5.2020.01.10.11.31.31; Fri, 10 Jan 2020 11:31:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 S1728887AbgAJTaC (ORCPT + 99 others); Fri, 10 Jan 2020 14:30:02 -0500 Received: from mga09.intel.com ([134.134.136.24]:22265 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728883AbgAJTaC (ORCPT ); Fri, 10 Jan 2020 14:30:02 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2020 11:30:01 -0800 X-IronPort-AV: E=Sophos;i="5.69,418,1571727600"; d="scan'208";a="212359212" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2020 11:30:01 -0800 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: [RFC PATCH V2 04/12] fs/xfs: Clean up DAX support check Date: Fri, 10 Jan 2020 11:29:34 -0800 Message-Id: <20200110192942.25021-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200110192942.25021-1-ira.weiny@intel.com> References: <20200110192942.25021-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@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 | 16 +++------------- fs/xfs/xfs_iops.c | 8 ++++++-- fs/xfs/xfs_iops.h | 2 ++ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index fe37708cea8f..b5e00b67c297 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1176,23 +1176,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) { - struct xfs_buftarg *target = xfs_inode_buftarg(ip); - - if (!bdev_dax_supported(target->bt_bdev, 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 0a0ea90259e9..d6843cdb51d0 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1244,14 +1244,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.21.0