From patchwork Fri Mar 2 03:54:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10253267 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 CA0DF60211 for ; Fri, 2 Mar 2018 04:03:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B929D287DA for ; Fri, 2 Mar 2018 04:03:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD7D2287DE; Fri, 2 Mar 2018 04:03:30 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0A39F287DA for ; Fri, 2 Mar 2018 04:03:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B833D22546B99; Thu, 1 Mar 2018 19:57:20 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 65C2322546B8C for ; Thu, 1 Mar 2018 19:57:19 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2018 20:03:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="30862327" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by FMSMGA003.fm.intel.com with ESMTP; 01 Mar 2018 20:03:27 -0800 Subject: [PATCH v5 09/12] mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Date: Thu, 01 Mar 2018 19:54:22 -0800 Message-ID: <151996286235.28483.2635632878864807577.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kara , Matthew Wilcox , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, hch@lst.de Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP In preparation for fixing the broken definition of S_DAX in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, convert all IS_DAX() usages to use explicit tests for the DEVDAX and FSDAX sub-cases of DAX functionality. Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 16 +++++++--------- mm/fadvise.c | 3 ++- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 +++- mm/madvise.c | 3 ++- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index bd0c46880572..33e859e7d100 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3208,21 +3208,19 @@ static inline bool io_is_direct(struct file *filp) static inline bool vma_is_dax(struct vm_area_struct *vma) { - return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host); + struct inode *inode; + + if (!vma->vm_file) + return false; + inode = file_inode(vma->vm_file); + return IS_FSDAX(inode) || IS_DEVDAX(inode); } static inline bool vma_is_fsdax(struct vm_area_struct *vma) { - struct inode *inode; - if (!vma->vm_file) return false; - if (!vma_is_dax(vma)) - return false; - inode = file_inode(vma->vm_file); - if (S_ISCHR(inode->i_mode)) - return false; /* device-dax */ - return true; + return IS_FSDAX(file_inode(vma->vm_file)); } static inline int iocb_flags(struct file *file) diff --git a/mm/fadvise.c b/mm/fadvise.c index 767887f5f3bf..00d9317636a2 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -55,7 +55,8 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice) bdi = inode_to_bdi(mapping->host); - if (IS_DAX(inode) || (bdi == &noop_backing_dev_info)) { + if (IS_FSDAX(inode) || IS_DEVDAX(inode) + || (bdi == &noop_backing_dev_info)) { switch (advice) { case POSIX_FADV_NORMAL: case POSIX_FADV_RANDOM: diff --git a/mm/filemap.c b/mm/filemap.c index 693f62212a59..4bc4e067ebf2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2357,7 +2357,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) * DAX files, so don't bother trying. */ if (retval < 0 || !count || iocb->ki_pos >= size || - IS_DAX(inode)) + IS_FSDAX(inode)) goto out; } @@ -3225,7 +3225,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) * not succeed (even if it did, DAX does not handle dirty * page-cache pages correctly). */ - if (written < 0 || !iov_iter_count(from) || IS_DAX(inode)) + if (written < 0 || !iov_iter_count(from) || IS_FSDAX(inode)) goto out; status = generic_perform_write(file, from, pos = iocb->ki_pos); diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 87ab9b8f56b5..ed238936e29b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -529,10 +529,12 @@ unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { loff_t off = (loff_t)pgoff << PAGE_SHIFT; + struct inode *inode; if (addr) goto out; - if (!IS_DAX(filp->f_mapping->host) || !IS_ENABLED(CONFIG_FS_DAX_PMD)) + inode = filp->f_mapping->host; + if (!IS_FSDAX(inode) || !IS_ENABLED(CONFIG_FS_DAX_PMD)) goto out; addr = __thp_get_unmapped_area(filp, len, off, flags, PMD_SIZE); diff --git a/mm/madvise.c b/mm/madvise.c index 4d3c922ea1a1..bdb83cf018b1 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -275,6 +275,7 @@ static long madvise_willneed(struct vm_area_struct *vma, unsigned long start, unsigned long end) { struct file *file = vma->vm_file; + struct inode *inode = file_inode(file); *prev = vma; #ifdef CONFIG_SWAP @@ -293,7 +294,7 @@ static long madvise_willneed(struct vm_area_struct *vma, return -EBADF; #endif - if (IS_DAX(file_inode(file))) { + if (IS_FSDAX(inode) || IS_DEVDAX(inode)) { /* no bad return value, but ignore advice */ return 0; }