From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 2 Mar 2018 23:54:55 +0100 From: Christoph Hellwig Subject: Re: [PATCH v5 09/12] mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() Message-ID: <20180302225455.GD31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996286235.28483.2635632878864807577.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996286235.28483.2635632878864807577.stgit@dwillia2-desk3.amr.corp.intel.com> Sender: owner-linux-mm@kvack.org To: Dan Williams Cc: linux-nvdimm@lists.01.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org List-ID: On Thu, Mar 01, 2018 at 07:54:22PM -0800, Dan Williams wrote: > 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); If you look at the definition of IS_FSDAX and IS_DEVDAX this is going to evaluate into some bullshit code. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) Subject: [PATCH v5 09/12] mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() From: Dan Williams 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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org 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 List-ID: 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; } _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from newverein.lst.de (verein.lst.de [213.95.11.211]) (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 CF33622492727 for ; Fri, 2 Mar 2018 14:47:07 -0800 (PST) Date: Fri, 2 Mar 2018 23:53:16 +0100 From: Christoph Hellwig Subject: Re: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() Message-ID: <20180302225316.GC31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Dan Williams Cc: Theodore Ts'o , Matthew Wilcox , "Darrick J. Wong" , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Andreas Dilger , Alexander Viro , linux-fsdevel@vger.kernel.org, Jan Kara , hch@lst.de List-ID: > +static inline bool IS_DEVDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_DEV_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (!S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > +static inline bool IS_FSDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_FS_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (S_ISCHR(inode->i_mode)) > + return false; > + return true; Encoding the is char device or not thing here is just nasty. I think this is going entirely in the wrong direction. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 2 Mar 2018 11:58:11 -0800 From: "Darrick J. Wong" Subject: Re: [PATCH v6] dax: introduce IS_DEVDAX() and IS_FSDAX() Message-ID: <20180302195811.GA18989@magnolia> References: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> Sender: owner-linux-mm@kvack.org To: Dan Williams Cc: linux-nvdimm@lists.01.org, Theodore Ts'o , Andreas Dilger , Alexander Viro , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org List-ID: On Fri, Mar 02, 2018 at 11:06:36AM -0800, Dan Williams wrote: > The current IS_DAX() helper that checks if a file is in DAX mode serves > two purposes. It is a control flow branch condition for DAX vs > non-DAX paths and it is a mechanism to perform dead code elimination. The > dead code elimination is required in the CONFIG_FS_DAX=n case since > there are symbols in fs/dax.c that will be elided. While the > dead code elimination can be addressed with nop stubs for the fs/dax.c > symbols that does not address the need for a DAX control flow helper > where fs/dax.c symbols are not involved. > > Moreover, the control flow changes, in some cases, need to be cognizant > of whether the DAX file is a typical file or a Device-DAX special file. > Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the > file-type control flow and dead-code elimination use cases. IS_DAX() > will be deleted after all sites are converted to use the file-type > specific helper. > > Note, this change is also a pre-requisite for fixing the definition of > the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. > The flag needs to be defined, non-zero, if either DAX facility is > enabled. > > Cc: "Theodore Ts'o" > Cc: Andreas Dilger > Cc: Alexander Viro > Cc: "Darrick J. Wong" > Cc: linux-xfs@vger.kernel.org > Cc: Matthew Wilcox > Cc: Ross Zwisler > Cc: > Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") > Reported-by: Jan Kara > Reviewed-by: Jan Kara > Signed-off-by: Dan Williams > --- > Changes since v5: > * add comments to clarify the S_ISCHR() checks (Darrick) Looks ok, Reviewed-by: Darrick J. Wong --D > > include/linux/fs.h | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 79c413985305..751975b8b29b 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1909,6 +1909,30 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags > #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ > (inode)->i_rdev == WHITEOUT_DEV) > > +static inline bool IS_DEVDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_DEV_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + /* regular files with S_DAX are filesystem-dax instances */ > + if (!S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > +static inline bool IS_FSDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_FS_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + /* character devices with S_DAX are device-dax instances */ > + if (S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > static inline bool HAS_UNMAPPED_ID(struct inode *inode) > { > return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 553332250EDFF for ; Fri, 2 Mar 2018 11:09:32 -0800 (PST) Subject: [PATCH v6] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams Date: Fri, 02 Mar 2018 11:06:36 -0800 Message-ID: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: References: MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Matthew Wilcox , "Darrick J. Wong" , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Andreas Dilger , Alexander Viro , linux-fsdevel@vger.kernel.org, Jan Kara List-ID: The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- Changes since v5: * add comments to clarify the S_ISCHR() checks (Darrick) include/linux/fs.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..751975b8b29b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,30 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* regular files with S_DAX are filesystem-dax instances */ + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* character devices with S_DAX are device-dax instances */ + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x244.google.com (mail-oi0-x244.google.com [IPv6:2607:f8b0:4003:c06::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 576D022352282 for ; Fri, 2 Mar 2018 10:31:31 -0800 (PST) Received: by mail-oi0-x244.google.com with SMTP id x12so7708360oie.13 for ; Fri, 02 Mar 2018 10:37:41 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20180302174530.GV19312@magnolia> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302174530.GV19312@magnolia> From: Dan Williams Date: Fri, 2 Mar 2018 10:37:40 -0800 Message-ID: Subject: Re: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: "Darrick J. Wong" Cc: Theodore Ts'o , Matthew Wilcox , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Andreas Dilger , Alexander Viro , linux-fsdevel , Jan Kara , Christoph Hellwig List-ID: On Fri, Mar 2, 2018 at 9:45 AM, Darrick J. Wong wrote: > On Thu, Mar 01, 2018 at 07:53:44PM -0800, Dan Williams wrote: >> The current IS_DAX() helper that checks if a file is in DAX mode serves >> two purposes. It is a control flow branch condition for DAX vs >> non-DAX paths and it is a mechanism to perform dead code elimination. The >> dead code elimination is required in the CONFIG_FS_DAX=n case since >> there are symbols in fs/dax.c that will be elided. While the >> dead code elimination can be addressed with nop stubs for the fs/dax.c >> symbols that does not address the need for a DAX control flow helper >> where fs/dax.c symbols are not involved. >> >> Moreover, the control flow changes, in some cases, need to be cognizant >> of whether the DAX file is a typical file or a Device-DAX special file. >> Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the >> file-type control flow and dead-code elimination use cases. IS_DAX() >> will be deleted after all sites are converted to use the file-type >> specific helper. >> >> Note, this change is also a pre-requisite for fixing the definition of >> the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. >> The flag needs to be defined, non-zero, if either DAX facility is >> enabled. >> >> Cc: "Theodore Ts'o" >> Cc: Andreas Dilger >> Cc: Alexander Viro >> Cc: "Darrick J. Wong" >> Cc: linux-xfs@vger.kernel.org >> Cc: Matthew Wilcox >> Cc: Ross Zwisler >> Cc: >> Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") >> Reported-by: Jan Kara >> Reviewed-by: Jan Kara >> Signed-off-by: Dan Williams >> --- >> include/linux/fs.h | 22 ++++++++++++++++++++++ >> 1 file changed, 22 insertions(+) >> >> diff --git a/include/linux/fs.h b/include/linux/fs.h >> index 79c413985305..bd0c46880572 100644 >> --- a/include/linux/fs.h >> +++ b/include/linux/fs.h >> @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags >> #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ >> (inode)->i_rdev == WHITEOUT_DEV) >> >> +static inline bool IS_DEVDAX(struct inode *inode) >> +{ >> + if (!IS_ENABLED(CONFIG_DEV_DAX)) >> + return false; >> + if ((inode->i_flags & S_DAX) == 0) >> + return false; >> + if (!S_ISCHR(inode->i_mode)) >> + return false; >> + return true; >> +} >> + >> +static inline bool IS_FSDAX(struct inode *inode) >> +{ >> + if (!IS_ENABLED(CONFIG_FS_DAX)) >> + return false; > > I echo Jan's complaint from the last round that the dead code > elimination here is subtle, as compared to: > > #if IS_ENABLED(CONFIG_FS_DAX) > static inline bool IS_FSDAX(struct inode *inode) { ... } > #else > # define IS_FSDAX(inode) (false) > #endif > > But I guess even with that we're relying on dead code elimination higher > up in the call stack... If IS_FSDAX() was only a dead-code elimination mechanism rather than a runtime branch condition then I agree. Otherwise I think IS_ENABLED() is suitable and not subtle, especially when used in a header file. >> + if ((inode->i_flags & S_DAX) == 0) >> + return false; >> + if (S_ISCHR(inode->i_mode)) >> + return false; > > I'm curious, do we have character devices with S_DAX set? Yes, Device-DAX, see: ab68f2622136 /dev/dax, pmem: direct access to persistent memory > I /think/ we're expecting that only block/char devices and files will > ever have S_DAX set, so IS_FSDAX is only true for block devices and > files. Right? We had S_DAX on block-devices for a short while, but deleted it and went with the Device-DAX interface instead. So it's only regular files and /dev/daxX.Y nodes these days. > (A comment here about why S_ISCHR->false here would be helpful.) Ok. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 2 Mar 2018 09:45:30 -0800 From: "Darrick J. Wong" Subject: Re: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() Message-ID: <20180302174530.GV19312@magnolia> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> Sender: owner-linux-mm@kvack.org To: Dan Williams Cc: linux-nvdimm@lists.01.org, Theodore Ts'o , Andreas Dilger , Alexander Viro , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org List-ID: On Thu, Mar 01, 2018 at 07:53:44PM -0800, Dan Williams wrote: > The current IS_DAX() helper that checks if a file is in DAX mode serves > two purposes. It is a control flow branch condition for DAX vs > non-DAX paths and it is a mechanism to perform dead code elimination. The > dead code elimination is required in the CONFIG_FS_DAX=n case since > there are symbols in fs/dax.c that will be elided. While the > dead code elimination can be addressed with nop stubs for the fs/dax.c > symbols that does not address the need for a DAX control flow helper > where fs/dax.c symbols are not involved. > > Moreover, the control flow changes, in some cases, need to be cognizant > of whether the DAX file is a typical file or a Device-DAX special file. > Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the > file-type control flow and dead-code elimination use cases. IS_DAX() > will be deleted after all sites are converted to use the file-type > specific helper. > > Note, this change is also a pre-requisite for fixing the definition of > the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. > The flag needs to be defined, non-zero, if either DAX facility is > enabled. > > Cc: "Theodore Ts'o" > Cc: Andreas Dilger > Cc: Alexander Viro > Cc: "Darrick J. Wong" > Cc: linux-xfs@vger.kernel.org > Cc: Matthew Wilcox > Cc: Ross Zwisler > Cc: > Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") > Reported-by: Jan Kara > Reviewed-by: Jan Kara > Signed-off-by: Dan Williams > --- > include/linux/fs.h | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 79c413985305..bd0c46880572 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags > #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ > (inode)->i_rdev == WHITEOUT_DEV) > > +static inline bool IS_DEVDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_DEV_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (!S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > +static inline bool IS_FSDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_FS_DAX)) > + return false; I echo Jan's complaint from the last round that the dead code elimination here is subtle, as compared to: #if IS_ENABLED(CONFIG_FS_DAX) static inline bool IS_FSDAX(struct inode *inode) { ... } #else # define IS_FSDAX(inode) (false) #endif But I guess even with that we're relying on dead code elimination higher up in the call stack... > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (S_ISCHR(inode->i_mode)) > + return false; I'm curious, do we have character devices with S_DAX set? I /think/ we're expecting that only block/char devices and files will ever have S_DAX set, so IS_FSDAX is only true for block devices and files. Right? (A comment here about why S_ISCHR->false here would be helpful.) --D > + return true; > +} > + > static inline bool HAS_UNMAPPED_ID(struct inode *inode) > { > return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 46A6622485A9D for ; Thu, 1 Mar 2018 19:56:41 -0800 (PST) Subject: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams Date: Thu, 01 Mar 2018 19:53:44 -0800 Message-ID: <151996282448.28483.10415125852182473579.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Matthew Wilcox , "Darrick J. Wong" , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Andreas Dilger , Alexander Viro , linux-fsdevel@vger.kernel.org, Jan Kara , hch@lst.de List-ID: The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..bd0c46880572 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 8BD6022546B8C for ; Thu, 1 Mar 2018 19:57:25 -0800 (PST) Subject: [PATCH v5 10/12] fs, dax: kill IS_DAX() From: Dan Williams Date: Thu, 01 Mar 2018 19:54:28 -0800 Message-ID: <151996286805.28483.12933227722062678008.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org 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 List-ID: In preparation for fixing the broken definition of S_DAX in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, convert all the remaining IS_DAX() usages to use explicit tests for FSDAX. 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 --- fs/iomap.c | 2 +- include/linux/dax.h | 2 +- include/linux/fs.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index afd163586aa0..fe379d8949fd 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -377,7 +377,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, offset = pos & (PAGE_SIZE - 1); /* Within page */ bytes = min_t(loff_t, PAGE_SIZE - offset, count); - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) status = iomap_dax_zero(pos, offset, bytes, iomap); else status = iomap_zero(inode, pos, offset, bytes, iomap); diff --git a/include/linux/dax.h b/include/linux/dax.h index 47edbce4fc52..ce520e932adc 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -124,7 +124,7 @@ static inline ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, static inline bool dax_mapping(struct address_space *mapping) { - return mapping->host && IS_DAX(mapping->host); + return mapping->host && IS_FSDAX(mapping->host); } struct writeback_control; diff --git a/include/linux/fs.h b/include/linux/fs.h index 33e859e7d100..b2b2e15d227b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1903,7 +1903,6 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_IMA(inode) ((inode)->i_flags & S_IMA) #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) -#define IS_DAX(inode) ((inode)->i_flags & S_DAX) #define IS_ENCRYPTED(inode) ((inode)->i_flags & S_ENCRYPTED) #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ @@ -3203,7 +3202,7 @@ extern int file_update_time(struct file *file); static inline bool io_is_direct(struct file *filp) { - return (filp->f_flags & O_DIRECT) || IS_DAX(filp->f_mapping->host); + return (filp->f_flags & O_DIRECT) || IS_FSDAX(filp->f_mapping->host); } static inline bool vma_is_dax(struct vm_area_struct *vma) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 49DAC223522B6 for ; Thu, 1 Mar 2018 19:56:52 -0800 (PST) Subject: [PATCH v5 04/12] ext2, dax: define ext2_dax_*() infrastructure in all cases From: Dan Williams Date: Thu, 01 Mar 2018 19:53:55 -0800 Message-ID: <151996283559.28483.2221179891176741624.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Jan Kara , 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 List-ID: In preparation for fixing S_DAX to be defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, move the definition of these routines outside of the "#ifdef CONFIG_FS_DAX" guard. This is also a coding-style fix to move all ifdef handling to header files rather than in the source. The compiler will still be able to determine that all the related code can be discarded in the CONFIG_FS_DAX=n case. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext2/file.c | 8 -------- include/linux/dax.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 1c7ea1bcddde..5ac98d074323 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -29,7 +29,6 @@ #include "xattr.h" #include "acl.h" -#ifdef CONFIG_FS_DAX static ssize_t ext2_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct inode *inode = iocb->ki_filp->f_mapping->host; @@ -128,9 +127,6 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) vma->vm_flags |= VM_MIXEDMAP; return 0; } -#else -#define ext2_file_mmap generic_file_mmap -#endif /* * Called when filp is released. This happens when all file descriptors @@ -162,19 +158,15 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync) static ssize_t ext2_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { -#ifdef CONFIG_FS_DAX if (IS_DAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_read_iter(iocb, to); -#endif return generic_file_read_iter(iocb, to); } static ssize_t ext2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { -#ifdef CONFIG_FS_DAX if (IS_DAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_write_iter(iocb, from); -#endif return generic_file_write_iter(iocb, from); } diff --git a/include/linux/dax.h b/include/linux/dax.h index 0185ecdae135..47edbce4fc52 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -93,8 +93,6 @@ void dax_flush(struct dax_device *dax_dev, void *addr, size_t size); void dax_write_cache(struct dax_device *dax_dev, bool wc); bool dax_write_cache_enabled(struct dax_device *dax_dev); -ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, - const struct iomap_ops *ops); int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size, pfn_t *pfnp, int *errp, const struct iomap_ops *ops); int dax_finish_sync_fault(struct vm_fault *vmf, enum page_entry_size pe_size, @@ -107,6 +105,8 @@ int dax_invalidate_mapping_entry_sync(struct address_space *mapping, int __dax_zero_page_range(struct block_device *bdev, struct dax_device *dax_dev, sector_t sector, unsigned int offset, unsigned int length); +ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops); #else static inline int __dax_zero_page_range(struct block_device *bdev, struct dax_device *dax_dev, sector_t sector, @@ -114,6 +114,12 @@ static inline int __dax_zero_page_range(struct block_device *bdev, { return -ENXIO; } + +static inline ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops) +{ + return -ENXIO; +} #endif static inline bool dax_mapping(struct address_space *mapping) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 6A26922546B8C for ; Thu, 1 Mar 2018 19:57:35 -0800 (PST) Subject: [PATCH v5 12/12] vfio: disable filesystem-dax page pinning From: Dan Williams Date: Thu, 01 Mar 2018 19:54:39 -0800 Message-ID: <151996287917.28483.16157329534570989926.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Michal Hocko , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Alex Williamson , linux-fsdevel@vger.kernel.org, Christoph Hellwig List-ID: Filesystem-DAX is incompatible with 'longterm' page pinning. Without page cache indirection a DAX mapping maps filesystem blocks directly. This means that the filesystem must not modify a file's block map while any page in a mapping is pinned. In order to prevent the situation of userspace holding of filesystem operations indefinitely, disallow 'longterm' Filesystem-DAX mappings. RDMA has the same conflict and the plan there is to add a 'with lease' mechanism to allow the kernel to notify userspace that the mapping is being torn down for block-map maintenance. Perhaps something similar can be put in place for vfio. Note that xfs and ext4 still report: "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" ...at mount time, and resolving the dax-dma-vs-truncate problem is one of the last hurdles to remove that designation. Acked-by: Alex Williamson Cc: Michal Hocko Cc: Christoph Hellwig Cc: kvm@vger.kernel.org Cc: Reported-by: Haozhong Zhang Tested-by: Haozhong Zhang Fixes: d475c6346a38 ("dax,ext2: replace XIP read and write with DAX I/O") Signed-off-by: Dan Williams --- drivers/vfio/vfio_iommu_type1.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index e30e29ae4819..45657e2b1ff7 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, { struct page *page[1]; struct vm_area_struct *vma; + struct vm_area_struct *vmas[1]; int ret; if (mm == current->mm) { - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), - page); + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), + page, vmas); } else { unsigned int flags = 0; @@ -351,7 +352,18 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, down_read(&mm->mmap_sem); ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, - NULL, NULL); + vmas, NULL); + /* + * The lifetime of a vaddr_get_pfn() page pin is + * userspace-controlled. In the fs-dax case this could + * lead to indefinite stalls in filesystem operations. + * Disallow attempts to pin fs-dax pages via this + * interface. + */ + if (ret > 0 && vma_is_fsdax(vmas[0])) { + ret = -EOPNOTSUPP; + put_page(page[0]); + } up_read(&mm->mmap_sem); } _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 042F4223522B6 for ; Thu, 1 Mar 2018 19:56:46 -0800 (PST) Subject: [PATCH v5 03/12] ext2, dax: finish implementing dax_sem helpers From: Dan Williams Date: Thu, 01 Mar 2018 19:53:50 -0800 Message-ID: <151996283005.28483.12905745385121745420.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Jan Kara , 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 List-ID: dax_sem_{up,down}_write_sem() allow the ext2 dax semaphore to be compiled out in the CONFIG_FS_DAX=n case. However there are still some open coded uses of the semaphore. Add dax_sem_{up_read,down_read}() and dax_sem_assert_held() helpers. Use them to convert all open-coded usages of the semaphore to the helpers. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext2/ext2.h | 6 ++++++ fs/ext2/file.c | 5 ++--- fs/ext2/inode.c | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 032295e1d386..203c31dfe549 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h @@ -711,9 +711,15 @@ struct ext2_inode_info { #ifdef CONFIG_FS_DAX #define dax_sem_down_write(ext2_inode) down_write(&(ext2_inode)->dax_sem) #define dax_sem_up_write(ext2_inode) up_write(&(ext2_inode)->dax_sem) +#define dax_sem_assert_held(ei) WARN_ON(!rwsem_is_locked(&(ei)->dax_sem)) +#define dax_sem_down_read(ext2_inode) down_read(&(ext2_inode)->dax_sem) +#define dax_sem_up_read(ext2_inode) up_read(&(ext2_inode)->dax_sem) #else #define dax_sem_down_write(ext2_inode) #define dax_sem_up_write(ext2_inode) +#define dax_sem_assert_held(ext2_inode) +#define dax_sem_down_read(ext2_inode) +#define dax_sem_up_read(ext2_inode) #endif /* diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 09640220fda8..1c7ea1bcddde 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -91,18 +91,17 @@ static ssize_t ext2_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) static int ext2_dax_fault(struct vm_fault *vmf) { struct inode *inode = file_inode(vmf->vma->vm_file); - struct ext2_inode_info *ei = EXT2_I(inode); int ret; if (vmf->flags & FAULT_FLAG_WRITE) { sb_start_pagefault(inode->i_sb); file_update_time(vmf->vma->vm_file); } - down_read(&ei->dax_sem); + dax_sem_down_read(EXT2_I(inode)); ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops); - up_read(&ei->dax_sem); + dax_sem_up_read(EXT2_I(inode)); if (vmf->flags & FAULT_FLAG_WRITE) sb_end_pagefault(inode->i_sb); return ret; diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 9b2ac55ac34f..4783db0e4873 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1187,9 +1187,7 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset) blocksize = inode->i_sb->s_blocksize; iblock = (offset + blocksize-1) >> EXT2_BLOCK_SIZE_BITS(inode->i_sb); -#ifdef CONFIG_FS_DAX - WARN_ON(!rwsem_is_locked(&ei->dax_sem)); -#endif + dax_sem_assert_held(ei); n = ext2_block_to_path(inode, iblock, offsets, NULL); if (n == 0) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 B6EE622546B81 for ; Thu, 1 Mar 2018 19:57:02 -0800 (PST) Subject: [PATCH v5 06/12] ext2, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams Date: Thu, 01 Mar 2018 19:54:06 -0800 Message-ID: <151996284593.28483.4922911524438696817.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org 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 List-ID: 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 FSDAX since DAX is ambiguous. 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 --- fs/ext2/file.c | 6 +++--- fs/ext2/inode.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 5ac98d074323..702a36df6c01 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -119,7 +119,7 @@ static const struct vm_operations_struct ext2_dax_vm_ops = { static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) { - if (!IS_DAX(file_inode(file))) + if (!IS_FSDAX(file_inode(file))) return generic_file_mmap(file, vma); file_accessed(file); @@ -158,14 +158,14 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync) static ssize_t ext2_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { - if (IS_DAX(iocb->ki_filp->f_mapping->host)) + if (IS_FSDAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_read_iter(iocb, to); return generic_file_read_iter(iocb, to); } static ssize_t ext2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { - if (IS_DAX(iocb->ki_filp->f_mapping->host)) + if (IS_FSDAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_write_iter(iocb, from); return generic_file_write_iter(iocb, from); } diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 4783db0e4873..5352207da9d5 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -733,7 +733,7 @@ static int ext2_get_blocks(struct inode *inode, goto cleanup; } - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { /* * We must unmap blocks before zeroing so that writeback cannot * overwrite zeros with stale data from block device page cache. @@ -940,7 +940,7 @@ ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) loff_t offset = iocb->ki_pos; ssize_t ret; - if (WARN_ON_ONCE(IS_DAX(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode))) return -EIO; ret = blockdev_direct_IO(iocb, inode, iter, ext2_get_block); @@ -1294,7 +1294,7 @@ static int ext2_setsize(struct inode *inode, loff_t newsize) inode_dio_wait(inode); - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { error = iomap_zero_range(inode, newsize, PAGE_ALIGN(newsize) - newsize, NULL, &ext2_iomap_ops); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from newverein.lst.de (verein.lst.de [213.95.11.211]) (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 7CC9121E256AF for ; Fri, 2 Mar 2018 14:46:02 -0800 (PST) Date: Fri, 2 Mar 2018 23:52:10 +0100 From: Christoph Hellwig Subject: Re: [PATCH v5 01/12] dax: fix vma_is_fsdax() helper Message-ID: <20180302225210.GB31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996281881.28483.2616406435517031167.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <151996281881.28483.2616406435517031167.stgit@dwillia2-desk3.amr.corp.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Dan Williams Cc: Jane Chu , Jan Kara , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Gerd Rausch , linux-fsdevel@vger.kernel.org, hch@lst.de List-ID: Looks good, Reviewed-by: Christoph Hellwig _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 D49E72255D6FE for ; Thu, 1 Mar 2018 19:56:35 -0800 (PST) Subject: [PATCH v5 01/12] dax: fix vma_is_fsdax() helper From: Dan Williams Date: Thu, 01 Mar 2018 19:53:38 -0800 Message-ID: <151996281881.28483.2616406435517031167.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Jane Chu , Jan Kara , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Gerd Rausch , linux-fsdevel@vger.kernel.org, hch@lst.de List-ID: Gerd reports that ->i_mode may contain other bits besides S_IFCHR. Use S_ISCHR() instead. Otherwise, get_user_pages_longterm() may fail on device-dax instances when those are meant to be explicitly allowed. Fixes: 2bb6d2837083 ("mm: introduce get_user_pages_longterm") Cc: Reported-by: Gerd Rausch Acked-by: Jane Chu Reported-by: Haozhong Zhang Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 2a815560fda0..79c413985305 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3198,7 +3198,7 @@ static inline bool vma_is_fsdax(struct vm_area_struct *vma) if (!vma_is_dax(vma)) return false; inode = file_inode(vma->vm_file); - if (inode->i_mode == S_IFCHR) + if (S_ISCHR(inode->i_mode)) return false; /* device-dax */ return true; } _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x243.google.com (mail-oi0-x243.google.com [IPv6:2607:f8b0:4003:c06::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C3BB021F0DA76 for ; Fri, 2 Mar 2018 18:13:07 -0800 (PST) Received: by mail-oi0-x243.google.com with SMTP id u73so8433470oie.3 for ; Fri, 02 Mar 2018 18:19:17 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> <20180302225734.GE31240@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 18:19:16 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Christoph Hellwig Cc: Michal Hocko , Jan Kara , Matthew Wilcox , KVM list , "Darrick J. Wong" , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel , Theodore Ts'o List-ID: On Fri, Mar 2, 2018 at 3:49 PM, Dan Williams wrote: > On Fri, Mar 2, 2018 at 2:57 PM, Christoph Hellwig wrote: >> On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: >>> They are indeed a hodge-podge. The problem is that the current >>> IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with >>> IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks >>> you propose for the next merge window. >> >> The only thing broken about IS_DAX are the code elimination games >> based on the CONFIG_* flags. Remove those and just add proper stubs >> for the dax routines and everything will be fine for now until we can >> kill that inode flag. >> >> IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't >> helping anyone. > > Ok, I'll take another shot at something suitable for 4.16, but without > these new helpers... I'll drop patches 2-11 for now, and just get the high priority fixes in for the next rc. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x244.google.com (mail-oi0-x244.google.com [IPv6:2607:f8b0:4003:c06::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 878FD21E082B8 for ; Fri, 2 Mar 2018 15:43:36 -0800 (PST) Received: by mail-oi0-x244.google.com with SMTP id c12so8256967oic.7 for ; Fri, 02 Mar 2018 15:49:46 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20180302225734.GE31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> <20180302225734.GE31240@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 15:49:45 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Christoph Hellwig Cc: Jane Chu , Michal Hocko , Jan Kara , Matthew Wilcox , KVM list , "Darrick J. Wong" , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel , Theodore Ts'o List-ID: On Fri, Mar 2, 2018 at 2:57 PM, Christoph Hellwig wrote: > On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: >> They are indeed a hodge-podge. The problem is that the current >> IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with >> IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks >> you propose for the next merge window. > > The only thing broken about IS_DAX are the code elimination games > based on the CONFIG_* flags. Remove those and just add proper stubs > for the dax routines and everything will be fine for now until we can > kill that inode flag. > > IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't > helping anyone. Ok, I'll take another shot at something suitable for 4.16, but without these new helpers... _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from newverein.lst.de (verein.lst.de [213.95.11.211]) (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 525B021E08291 for ; Fri, 2 Mar 2018 14:51:26 -0800 (PST) Date: Fri, 2 Mar 2018 23:57:34 +0100 From: Christoph Hellwig Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Message-ID: <20180302225734.GE31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Dan Williams Cc: Jane Chu , Michal Hocko , Jan Kara , Matthew Wilcox , KVM list , "Darrick J. Wong" , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel , Theodore Ts'o , Christoph Hellwig List-ID: On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: > They are indeed a hodge-podge. The problem is that the current > IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with > IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks > you propose for the next merge window. The only thing broken about IS_DAX are the code elimination games based on the CONFIG_* flags. Remove those and just add proper stubs for the dax routines and everything will be fine for now until we can kill that inode flag. IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't helping anyone. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x22f.google.com (mail-oi0-x22f.google.com [IPv6:2607:f8b0:4003:c06::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B77EB223522A6 for ; Fri, 2 Mar 2018 14:15:31 -0800 (PST) Received: by mail-oi0-x22f.google.com with SMTP id c83so8152467oib.1 for ; Fri, 02 Mar 2018 14:21:41 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20180302221020.GA30722@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 14:21:40 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Christoph Hellwig Cc: Jane Chu , Michal Hocko , Jan Kara , Matthew Wilcox , KVM list , "Darrick J. Wong" , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel , Theodore Ts'o List-ID: On Fri, Mar 2, 2018 at 2:10 PM, Christoph Hellwig wrote: > I really don't like these IS_DEVDAX and IS_FSDAX flags. We should > stop pretending DAX is a global per-inode choice and get rid of these > magic flags entirely. So please convert the instances inside the > various file systems to checking the file system mount options instead. > > For the core ones we'll need to differentiate: > > - the checks in generic_file_read_iter and __generic_file_write_iter > seem to not be needed anymore at all since we stopped abusing the > direct I/O code for DAX, so they should probably be removed. > - io_is_direct is a weird check and should probably just go away, > as there is not point in always setting IOCB_DIRECT for DAX I/O > - fadvise should either become a file op, or a flag on the inode that > fadvice is supported instead of the nasty noop_backing_dev_info or > DAX check. > - Ditto for madvise > - vma_is_dax should probably be replaced with a VMA flag. > - thp_get_unmapped_area I don't really understand why we have a dax > check there. > - dax_mapping will be much harder to sort out. > > But all these DAX flags certainly look like a major hodge podge to me. They are indeed a hodge-podge. The problem is that the current IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks you propose for the next merge window. Acceptable? _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 2 Mar 2018 23:10:20 +0100 From: Christoph Hellwig Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Message-ID: <20180302221020.GA30722@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> Sender: owner-linux-mm@kvack.org To: Dan Williams Cc: linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org, "Darrick J. Wong" , kvm@vger.kernel.org, Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable@vger.kernel.org, Jan Kara , Michal Hocko , Andreas Dilger , Christoph Hellwig , Ross Zwisler , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Alex Williamson , Theodore Ts'o , linux-mm@kvack.org, linux-kernel@vger.kernel.org List-ID: I really don't like these IS_DEVDAX and IS_FSDAX flags. We should stop pretending DAX is a global per-inode choice and get rid of these magic flags entirely. So please convert the instances inside the various file systems to checking the file system mount options instead. For the core ones we'll need to differentiate: - the checks in generic_file_read_iter and __generic_file_write_iter seem to not be needed anymore at all since we stopped abusing the direct I/O code for DAX, so they should probably be removed. - io_is_direct is a weird check and should probably just go away, as there is not point in always setting IOCB_DIRECT for DAX I/O - fadvise should either become a file op, or a flag on the inode that fadvice is supported instead of the nasty noop_backing_dev_info or DAX check. - Ditto for madvise - vma_is_dax should probably be replaced with a VMA flag. - thp_get_unmapped_area I don't really understand why we have a dax check there. - dax_mapping will be much harder to sort out. But all these DAX flags certainly look like a major hodge podge to me. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 88D822255D6FE for ; Thu, 1 Mar 2018 19:56:30 -0800 (PST) Subject: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes From: Dan Williams Date: Thu, 01 Mar 2018 19:53:33 -0800 Message-ID: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Jane Chu , Michal Hocko , Jan Kara , kvm@vger.kernel.org, "Darrick J. Wong" , Matthew Wilcox , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel@vger.kernel.org, Theodore Ts'o , Christoph Hellwig List-ID: Changes since v4 [1]: * Fix the changelog of "dax: introduce IS_DEVDAX() and IS_FSDAX()" to better clarify the need for new helpers (Jan) * Replace dax_sem_is_locked() with dax_sem_assert_held() (Jan) * Use file_inode() in vma_is_dax() (Jan) * Resend the full series to linux-xfs@ (Dave) * Collect Jan's Reviewed-by [1]: https://lists.01.org/pipermail/linux-nvdimm/2018-February/014271.html --- The vfio interface, like RDMA, wants to setup long term (indefinite) pins of the pages backing an address range so that a guest or userspace driver can perform DMA to the with physical address. Given that this pinning may lead to filesystem operations deadlocking in the filesystem-dax case, the pinning request needs to be rejected. The longer term fix for vfio, RDMA, and any other long term pin user, is to provide a 'pin with lease' mechanism. Similar to the leases that are hold for pNFS RDMA layouts, this userspace lease gives the kernel a way to notify userspace that the block layout of the file is changing and the kernel is revoking access to pinned pages. Related to this change is the discovery that vma_is_fsdax() was causing device-dax inode detection to fail. That lead to series of fixes and cleanups to make sure that S_DAX is defined correctly in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. --- Dan Williams (12): dax: fix vma_is_fsdax() helper dax: introduce IS_DEVDAX() and IS_FSDAX() ext2, dax: finish implementing dax_sem helpers ext2, dax: define ext2_dax_*() infrastructure in all cases ext4, dax: define ext4_dax_*() infrastructure in all cases ext2, dax: replace IS_DAX() with IS_FSDAX() ext4, dax: replace IS_DAX() with IS_FSDAX() xfs, dax: replace IS_DAX() with IS_FSDAX() mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() fs, dax: kill IS_DAX() dax: fix S_DAX definition vfio: disable filesystem-dax page pinning drivers/vfio/vfio_iommu_type1.c | 18 ++++++++++++++-- fs/ext2/ext2.h | 6 +++++ fs/ext2/file.c | 19 +++++------------ fs/ext2/inode.c | 10 ++++----- fs/ext4/file.c | 18 +++++----------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- fs/iomap.c | 2 +- fs/xfs/xfs_file.c | 14 ++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++-- fs/xfs/xfs_reflink.c | 2 +- include/linux/dax.h | 12 ++++++++--- include/linux/fs.h | 43 ++++++++++++++++++++++++++++----------- mm/fadvise.c | 3 ++- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 +++- mm/madvise.c | 3 ++- 19 files changed, 102 insertions(+), 74 deletions(-) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 0D015224E691C for ; Thu, 1 Mar 2018 19:57:31 -0800 (PST) Subject: [PATCH v5 11/12] dax: fix S_DAX definition From: Dan Williams Date: Thu, 01 Mar 2018 19:54:34 -0800 Message-ID: <151996287403.28483.8962319815764432894.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Jan Kara , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Alexander Viro , linux-fsdevel@vger.kernel.org, Christoph Hellwig List-ID: Make sure S_DAX is defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. Otherwise vma_is_dax() may incorrectly return false in the Device-DAX case. Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index b2b2e15d227b..1242511b1c46 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1859,7 +1859,7 @@ struct super_operations { #define S_IMA 1024 /* Inode has an associated IMA struct */ #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ #define S_NOSEC 4096 /* no suid or xattr security attributes */ -#ifdef CONFIG_FS_DAX +#if IS_ENABLED(CONFIG_FS_DAX) || IS_ENABLED(CONFIG_DEV_DAX) #define S_DAX 8192 /* Direct Access, avoiding the page cache */ #else #define S_DAX 0 /* Make all the DAX code disappear */ _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 F22D722423828 for ; Thu, 1 Mar 2018 19:56:56 -0800 (PST) Subject: [PATCH v5 05/12] ext4, dax: define ext4_dax_*() infrastructure in all cases From: Dan Williams Date: Thu, 01 Mar 2018 19:54:00 -0800 Message-ID: <151996284080.28483.11296105582801541424.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Jan Kara , 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 List-ID: In preparation for fixing S_DAX to be defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, move the definition of these routines outside of the "#ifdef CONFIG_FS_DAX" guard. This is also a coding-style fix to move all ifdef handling to header files rather than in the source. The compiler will still be able to determine that all the related code can be discarded in the CONFIG_FS_DAX=n case. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext4/file.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index fb6f023622fe..51854e7608f0 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -34,7 +34,6 @@ #include "xattr.h" #include "acl.h" -#ifdef CONFIG_FS_DAX static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct inode *inode = file_inode(iocb->ki_filp); @@ -60,7 +59,6 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) file_accessed(iocb->ki_filp); return ret; } -#endif static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { @@ -70,10 +68,8 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (!iov_iter_count(to)) return 0; /* skip atime */ -#ifdef CONFIG_FS_DAX if (IS_DAX(file_inode(iocb->ki_filp))) return ext4_dax_read_iter(iocb, to); -#endif return generic_file_read_iter(iocb, to); } @@ -179,7 +175,6 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from) return iov_iter_count(from); } -#ifdef CONFIG_FS_DAX static ssize_t ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) { @@ -208,7 +203,6 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) ret = generic_write_sync(iocb, ret); return ret; } -#endif static ssize_t ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 0575D20955F3E for ; Thu, 1 Mar 2018 19:57:07 -0800 (PST) Subject: [PATCH v5 07/12] ext4, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams Date: Thu, 01 Mar 2018 19:54:11 -0800 Message-ID: <151996285107.28483.10237358640480864296.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Matthew Wilcox , linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Andreas Dilger , Alexander Viro , linux-fsdevel@vger.kernel.org, Jan Kara , hch@lst.de List-ID: 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 FSDAX since DAX is ambiguous. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro 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 --- fs/ext4/file.c | 12 +++++------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 51854e7608f0..561ea843b458 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -48,7 +48,7 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) * Recheck under inode lock - at this point we are sure it cannot * change anymore */ - if (!IS_DAX(inode)) { + if (!IS_FSDAX(inode)) { inode_unlock_shared(inode); /* Fallback to buffered IO in case we cannot support DAX */ return generic_file_read_iter(iocb, to); @@ -68,7 +68,7 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (!iov_iter_count(to)) return 0; /* skip atime */ - if (IS_DAX(file_inode(iocb->ki_filp))) + if (IS_FSDAX(file_inode(iocb->ki_filp))) return ext4_dax_read_iter(iocb, to); return generic_file_read_iter(iocb, to); } @@ -216,10 +216,8 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; -#ifdef CONFIG_FS_DAX - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) return ext4_dax_write_iter(iocb, from); -#endif if (!o_direct && (iocb->ki_flags & IOCB_NOWAIT)) return -EOPNOTSUPP; @@ -361,11 +359,11 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) * We don't support synchronous mappings for non-DAX files. At least * until someone comes with a sensible use case. */ - if (!IS_DAX(file_inode(file)) && (vma->vm_flags & VM_SYNC)) + if (!IS_FSDAX(file_inode(file)) && (vma->vm_flags & VM_SYNC)) return -EOPNOTSUPP; file_accessed(file); - if (IS_DAX(file_inode(file))) { + if (IS_FSDAX(file_inode(file))) { vma->vm_ops = &ext4_dax_vm_ops; vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; } else { diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c94780075b04..1879b33aa391 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3858,7 +3858,7 @@ static ssize_t ext4_direct_IO(struct kiocb *iocb, struct iov_iter *iter) return 0; /* DAX uses iomap path now */ - if (WARN_ON_ONCE(IS_DAX(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode))) return 0; trace_ext4_direct_IO_enter(inode, offset, count, iov_iter_rw(iter)); @@ -4076,7 +4076,7 @@ static int ext4_block_zero_page_range(handle_t *handle, if (length > max || length < 0) length = max; - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { return iomap_zero_range(inode, from, length, NULL, &ext4_iomap_ops); } diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 7e99ad02f1ba..040fc6570ddb 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -790,7 +790,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) "Online defrag not supported with bigalloc"); err = -EOPNOTSUPP; goto mext_out; - } else if (IS_DAX(inode)) { + } else if (IS_FSDAX(inode)) { ext4_msg(sb, KERN_ERR, "Online defrag not supported with DAX"); err = -EOPNOTSUPP; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 39bf464c35f1..933e12940181 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1161,7 +1161,7 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, if (inode->i_ino == EXT4_ROOT_INO) return -EPERM; - if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode) && i_size_read(inode))) return -EINVAL; res = ext4_convert_inline_data(inode); _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 2 Mar 2018 09:46:07 -0800 From: "Darrick J. Wong" Subject: Re: [PATCH v5 08/12] xfs, dax: replace IS_DAX() with IS_FSDAX() Message-ID: <20180302174607.GW19312@magnolia> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996285683.28483.13394624369523668388.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996285683.28483.13394624369523668388.stgit@dwillia2-desk3.amr.corp.intel.com> Sender: owner-linux-mm@kvack.org To: Dan Williams Cc: linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org List-ID: On Thu, Mar 01, 2018 at 07:54:16PM -0800, Dan Williams wrote: > 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 FSDAX since DAX is ambiguous. > > Cc: "Darrick J. Wong" > Cc: linux-xfs@vger.kernel.org > 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 Looks ok, Reviewed-by: Darrick J. Wong --D > --- > fs/xfs/xfs_file.c | 14 +++++++------- > fs/xfs/xfs_ioctl.c | 4 ++-- > fs/xfs/xfs_iomap.c | 6 +++--- > fs/xfs/xfs_reflink.c | 2 +- > 4 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index 9ea08326f876..46a098b90fd0 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -288,7 +288,7 @@ xfs_file_read_iter( > if (XFS_FORCED_SHUTDOWN(mp)) > return -EIO; > > - if (IS_DAX(inode)) > + if (IS_FSDAX(inode)) > ret = xfs_file_dax_read(iocb, to); > else if (iocb->ki_flags & IOCB_DIRECT) > ret = xfs_file_dio_aio_read(iocb, to); > @@ -726,7 +726,7 @@ xfs_file_write_iter( > if (XFS_FORCED_SHUTDOWN(ip->i_mount)) > return -EIO; > > - if (IS_DAX(inode)) > + if (IS_FSDAX(inode)) > ret = xfs_file_dax_write(iocb, from); > else if (iocb->ki_flags & IOCB_DIRECT) { > /* > @@ -1045,7 +1045,7 @@ __xfs_filemap_fault( > } > > xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED); > - if (IS_DAX(inode)) { > + if (IS_FSDAX(inode)) { > pfn_t pfn; > > ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &xfs_iomap_ops); > @@ -1070,7 +1070,7 @@ xfs_filemap_fault( > { > /* DAX can shortcut the normal fault path on write faults! */ > return __xfs_filemap_fault(vmf, PE_SIZE_PTE, > - IS_DAX(file_inode(vmf->vma->vm_file)) && > + IS_FSDAX(file_inode(vmf->vma->vm_file)) && > (vmf->flags & FAULT_FLAG_WRITE)); > } > > @@ -1079,7 +1079,7 @@ xfs_filemap_huge_fault( > struct vm_fault *vmf, > enum page_entry_size pe_size) > { > - if (!IS_DAX(file_inode(vmf->vma->vm_file))) > + if (!IS_FSDAX(file_inode(vmf->vma->vm_file))) > return VM_FAULT_FALLBACK; > > /* DAX can shortcut the normal fault path on write faults! */ > @@ -1124,12 +1124,12 @@ xfs_file_mmap( > * We don't support synchronous mappings for non-DAX files. At least > * until someone comes with a sensible use case. > */ > - if (!IS_DAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) > + if (!IS_FSDAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) > return -EOPNOTSUPP; > > file_accessed(filp); > vma->vm_ops = &xfs_file_vm_ops; > - if (IS_DAX(file_inode(filp))) > + if (IS_FSDAX(file_inode(filp))) > vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; > return 0; > } > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c > index 89fb1eb80aae..234279ff66ce 100644 > --- a/fs/xfs/xfs_ioctl.c > +++ b/fs/xfs/xfs_ioctl.c > @@ -1108,9 +1108,9 @@ xfs_ioctl_setattr_dax_invalidate( > } > > /* If the DAX state is not changing, we have nothing to do here. */ > - if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_DAX(inode)) > + if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_FSDAX(inode)) > return 0; > - if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode)) > + if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_FSDAX(inode)) > return 0; > > /* lock, flush and invalidate mapping in preparation for flag change */ > diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c > index 66e1edbfb2b2..cf794d429aec 100644 > --- a/fs/xfs/xfs_iomap.c > +++ b/fs/xfs/xfs_iomap.c > @@ -241,7 +241,7 @@ xfs_iomap_write_direct( > * the reserve block pool for bmbt block allocation if there is no space > * left but we need to do unwritten extent conversion. > */ > - if (IS_DAX(VFS_I(ip))) { > + if (IS_FSDAX(VFS_I(ip))) { > bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO; > if (imap->br_state == XFS_EXT_UNWRITTEN) { > tflags |= XFS_TRANS_RESERVE; > @@ -952,7 +952,7 @@ static inline bool imap_needs_alloc(struct inode *inode, > return !nimaps || > imap->br_startblock == HOLESTARTBLOCK || > imap->br_startblock == DELAYSTARTBLOCK || > - (IS_DAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); > + (IS_FSDAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); > } > > static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags) > @@ -988,7 +988,7 @@ xfs_file_iomap_begin( > return -EIO; > > if (((flags & (IOMAP_WRITE | IOMAP_DIRECT)) == IOMAP_WRITE) && > - !IS_DAX(inode) && !xfs_get_extsz_hint(ip)) { > + !IS_FSDAX(inode) && !xfs_get_extsz_hint(ip)) { > /* Reserve delalloc blocks for regular writeback. */ > return xfs_file_iomap_begin_delay(inode, offset, length, iomap); > } > diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c > index 270246943a06..a126e00e05e3 100644 > --- a/fs/xfs/xfs_reflink.c > +++ b/fs/xfs/xfs_reflink.c > @@ -1351,7 +1351,7 @@ xfs_reflink_remap_range( > goto out_unlock; > > /* Don't share DAX file data for now. */ > - if (IS_DAX(inode_in) || IS_DAX(inode_out)) > + if (IS_FSDAX(inode_in) || IS_FSDAX(inode_out)) > goto out_unlock; > > ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 B837A22546B8F for ; Thu, 1 Mar 2018 19:57:13 -0800 (PST) Subject: [PATCH v5 08/12] xfs, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams Date: Thu, 01 Mar 2018 19:54:16 -0800 Message-ID: <151996285683.28483.13394624369523668388.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> MIME-Version: 1.0 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: linux-nvdimm@lists.01.org Cc: Jan Kara , Matthew Wilcox , "Darrick J. Wong" , 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 List-ID: 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 FSDAX since DAX is ambiguous. Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org 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 --- fs/xfs/xfs_file.c | 14 +++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++--- fs/xfs/xfs_reflink.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 9ea08326f876..46a098b90fd0 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -288,7 +288,7 @@ xfs_file_read_iter( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) ret = xfs_file_dax_read(iocb, to); else if (iocb->ki_flags & IOCB_DIRECT) ret = xfs_file_dio_aio_read(iocb, to); @@ -726,7 +726,7 @@ xfs_file_write_iter( if (XFS_FORCED_SHUTDOWN(ip->i_mount)) return -EIO; - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) ret = xfs_file_dax_write(iocb, from); else if (iocb->ki_flags & IOCB_DIRECT) { /* @@ -1045,7 +1045,7 @@ __xfs_filemap_fault( } xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED); - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { pfn_t pfn; ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &xfs_iomap_ops); @@ -1070,7 +1070,7 @@ xfs_filemap_fault( { /* DAX can shortcut the normal fault path on write faults! */ return __xfs_filemap_fault(vmf, PE_SIZE_PTE, - IS_DAX(file_inode(vmf->vma->vm_file)) && + IS_FSDAX(file_inode(vmf->vma->vm_file)) && (vmf->flags & FAULT_FLAG_WRITE)); } @@ -1079,7 +1079,7 @@ xfs_filemap_huge_fault( struct vm_fault *vmf, enum page_entry_size pe_size) { - if (!IS_DAX(file_inode(vmf->vma->vm_file))) + if (!IS_FSDAX(file_inode(vmf->vma->vm_file))) return VM_FAULT_FALLBACK; /* DAX can shortcut the normal fault path on write faults! */ @@ -1124,12 +1124,12 @@ xfs_file_mmap( * We don't support synchronous mappings for non-DAX files. At least * until someone comes with a sensible use case. */ - if (!IS_DAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) + if (!IS_FSDAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) return -EOPNOTSUPP; file_accessed(filp); vma->vm_ops = &xfs_file_vm_ops; - if (IS_DAX(file_inode(filp))) + if (IS_FSDAX(file_inode(filp))) vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; return 0; } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 89fb1eb80aae..234279ff66ce 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1108,9 +1108,9 @@ xfs_ioctl_setattr_dax_invalidate( } /* If the DAX state is not changing, we have nothing to do here. */ - if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_DAX(inode)) + if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_FSDAX(inode)) return 0; - if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode)) + if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_FSDAX(inode)) return 0; /* lock, flush and invalidate mapping in preparation for flag change */ diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 66e1edbfb2b2..cf794d429aec 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -241,7 +241,7 @@ xfs_iomap_write_direct( * the reserve block pool for bmbt block allocation if there is no space * left but we need to do unwritten extent conversion. */ - if (IS_DAX(VFS_I(ip))) { + if (IS_FSDAX(VFS_I(ip))) { bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO; if (imap->br_state == XFS_EXT_UNWRITTEN) { tflags |= XFS_TRANS_RESERVE; @@ -952,7 +952,7 @@ static inline bool imap_needs_alloc(struct inode *inode, return !nimaps || imap->br_startblock == HOLESTARTBLOCK || imap->br_startblock == DELAYSTARTBLOCK || - (IS_DAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); + (IS_FSDAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); } static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags) @@ -988,7 +988,7 @@ xfs_file_iomap_begin( return -EIO; if (((flags & (IOMAP_WRITE | IOMAP_DIRECT)) == IOMAP_WRITE) && - !IS_DAX(inode) && !xfs_get_extsz_hint(ip)) { + !IS_FSDAX(inode) && !xfs_get_extsz_hint(ip)) { /* Reserve delalloc blocks for regular writeback. */ return xfs_file_iomap_begin_delay(inode, offset, length, iomap); } diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 270246943a06..a126e00e05e3 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1351,7 +1351,7 @@ xfs_reflink_remap_range( goto out_unlock; /* Don't share DAX file data for now. */ - if (IS_DAX(inode_in) || IS_DAX(inode_out)) + if (IS_FSDAX(inode_in) || IS_FSDAX(inode_out)) goto out_unlock; ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-494696-1519963603-2-3719804177391959387 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963602; b=PwgxoFSqrpgaNvRghYxFqMF/RWpD8RO3DEVWxaHOomeduOx o+qSNuC8CGRUQkehL4C2KLS+cuWKs2JZmarbM5CfhLZI0O/eWqaH6bmRR+QJt2QX WZegdeGF3vPRbodcTwsyapx11vIv0u72OcNr759NU1XHKIHxYDRrS6oZaWzoponM GMNsNxBlH6MWOA+uxUWMPWDO7CTEkrdPf5SavtDNwrmUrOg0TVKmtq0K+W390N0U olTCoBRQDZ1gtp+RQNqLFRn4x7uRHN6i0+85mmTy70+pmoJYIyRVFOiE920506hV 7bfh2hn3/Orj9I691lU9vHXH1mXcVyDAQ7bunkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :mime-version:content-type:content-transfer-encoding:sender :list-id; s=arctest; t=1519963602; bh=aE2QBStWHO9FABnDJIvZw/bC6J QJbz9+OOEsXbOnpDk=; b=iganM9CYtzukK3YdSSDU8nRVMc4F9qB0nQwsjlySy9 OCdmmXsvP+HLKpHQq80LbNwRjOQuCLNrieygPdmx3N44U/4s3ERJynQExh4uOIUJ pdnD7tDN78U3g+aEfqde/u3zGRwjIzb78MqGKaaYwpwZAlyLvsFT7sIlTwXsJsAJ G75YlmxHA93ewTmJHwqvaF4pSUsAITxk1dV1vyInM0wlFV7KrD+yMoaBjzyldfzi GsznV3zqw7l7Rhf19VLEqBnjXcc9M3kZ1ZnYuoov0huUGw/r1tA7pLAeK5IkmLnl sbk9uqPLnsAVKlEVq2W2+HOPNbEiq+Aq8cQwtD8yVjIw== ARC-Authentication-Results: i=1; mx2.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx2.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164120AbeCBECm (ORCPT ); Thu, 1 Mar 2018 23:02:42 -0500 Received: from mga17.intel.com ([192.55.52.151]:20032 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163935AbeCBECk (ORCPT ); Thu, 1 Mar 2018 23:02:40 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="38656139" Subject: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes From: Dan Williams To: linux-nvdimm@lists.01.org Cc: linux-xfs@vger.kernel.org, "Darrick J. Wong" , kvm@vger.kernel.org, Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable@vger.kernel.org, Jan Kara , Michal Hocko , Andreas Dilger , Christoph Hellwig , Ross Zwisler , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Alex Williamson , Theodore Ts'o , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:33 -0800 Message-ID: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Changes since v4 [1]: * Fix the changelog of "dax: introduce IS_DEVDAX() and IS_FSDAX()" to better clarify the need for new helpers (Jan) * Replace dax_sem_is_locked() with dax_sem_assert_held() (Jan) * Use file_inode() in vma_is_dax() (Jan) * Resend the full series to linux-xfs@ (Dave) * Collect Jan's Reviewed-by [1]: https://lists.01.org/pipermail/linux-nvdimm/2018-February/014271.html --- The vfio interface, like RDMA, wants to setup long term (indefinite) pins of the pages backing an address range so that a guest or userspace driver can perform DMA to the with physical address. Given that this pinning may lead to filesystem operations deadlocking in the filesystem-dax case, the pinning request needs to be rejected. The longer term fix for vfio, RDMA, and any other long term pin user, is to provide a 'pin with lease' mechanism. Similar to the leases that are hold for pNFS RDMA layouts, this userspace lease gives the kernel a way to notify userspace that the block layout of the file is changing and the kernel is revoking access to pinned pages. Related to this change is the discovery that vma_is_fsdax() was causing device-dax inode detection to fail. That lead to series of fixes and cleanups to make sure that S_DAX is defined correctly in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. --- Dan Williams (12): dax: fix vma_is_fsdax() helper dax: introduce IS_DEVDAX() and IS_FSDAX() ext2, dax: finish implementing dax_sem helpers ext2, dax: define ext2_dax_*() infrastructure in all cases ext4, dax: define ext4_dax_*() infrastructure in all cases ext2, dax: replace IS_DAX() with IS_FSDAX() ext4, dax: replace IS_DAX() with IS_FSDAX() xfs, dax: replace IS_DAX() with IS_FSDAX() mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() fs, dax: kill IS_DAX() dax: fix S_DAX definition vfio: disable filesystem-dax page pinning drivers/vfio/vfio_iommu_type1.c | 18 ++++++++++++++-- fs/ext2/ext2.h | 6 +++++ fs/ext2/file.c | 19 +++++------------ fs/ext2/inode.c | 10 ++++----- fs/ext4/file.c | 18 +++++----------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- fs/iomap.c | 2 +- fs/xfs/xfs_file.c | 14 ++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++-- fs/xfs/xfs_reflink.c | 2 +- include/linux/dax.h | 12 ++++++++--- include/linux/fs.h | 43 ++++++++++++++++++++++++++++----------- mm/fadvise.c | 3 ++- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 +++- mm/madvise.c | 3 ++- 19 files changed, 102 insertions(+), 74 deletions(-) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2667167-1520028642-2-9413127492653734514 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='de', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520028641; b=JKKtcwfBGTYO4tRbJq/mpglAfpwpMbi1mxpUNYfNk61qyim ec6KA7ld/j29QdLj4KPsmEZ7poqvD51WP+y47t3wvqkxzvw9+JNacepAsyfckRWZ ZOHHpVYwSqfLyERWV+vdy0wP1ijnTe7pO0XQOSBlBS7r+B/o8cY/rvk/vJAKVvPy 1cqBTxVsms5vjrvcUjb/bqBvVfBHvSzuCvrZGgxWD0d60t/2qtRT7/2ejhv2KY8v qQRMVD63tHTDyuiJ55McwH/Dc4NNTX0jtN8Ca0Qeroe60/TOzZhLWj6BttJiqSLP gwfF3/EVsE8nuvdLbiDUob2ucwFMuw8WvGHPRtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1520028641; bh=xOWlEpdFCZ6TFEHam/qm0jtcfd g7enJblunQBAAGuC0=; b=OfbDpSeiVznypitNM9KkcfbSf0zPoVawqYRhJ7R1kp 57KmD3vPZ8O6tn+iz3C2A3QKz+GEAXTBP1anJY68p/HHLIR8/PoVJeFyIWQ93sXT HV8l2fk+brNxtRddIZWQjVnX2Dc9sPGacEbyJxMy0aimgsFrHf0tHlyNN5YfcNOR jjMZM8COcBORdkcM/lPcfE0g1ubT0iPy18H9PVFlLMmGkOuktSPkwxTgSZnYH/bL EvxttWbYFhcCOg6VdMtHhB5zEM14FnQMFdn/sixMlUr2sxky9erLKe2Wp1H4ETME +vKhsDT8E9kEIPWjn8KIWBONWW0TULcpuwWPO96ksmyg== ARC-Authentication-Results: i=1; mx6.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Authentication-Results: mx6.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932365AbeCBWKZ (ORCPT ); Fri, 2 Mar 2018 17:10:25 -0500 Received: from verein.lst.de ([213.95.11.211]:38217 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932197AbeCBWKX (ORCPT ); Fri, 2 Mar 2018 17:10:23 -0500 Date: Fri, 2 Mar 2018 23:10:20 +0100 From: Christoph Hellwig To: Dan Williams Cc: linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org, "Darrick J. Wong" , kvm@vger.kernel.org, Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable@vger.kernel.org, Jan Kara , Michal Hocko , Andreas Dilger , Christoph Hellwig , Ross Zwisler , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Alex Williamson , Theodore Ts'o , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Message-ID: <20180302221020.GA30722@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: I really don't like these IS_DEVDAX and IS_FSDAX flags. We should stop pretending DAX is a global per-inode choice and get rid of these magic flags entirely. So please convert the instances inside the various file systems to checking the file system mount options instead. For the core ones we'll need to differentiate: - the checks in generic_file_read_iter and __generic_file_write_iter seem to not be needed anymore at all since we stopped abusing the direct I/O code for DAX, so they should probably be removed. - io_is_direct is a weird check and should probably just go away, as there is not point in always setting IOCB_DIRECT for DAX I/O - fadvise should either become a file op, or a flag on the inode that fadvice is supported instead of the nasty noop_backing_dev_info or DAX check. - Ditto for madvise - vma_is_dax should probably be replaced with a VMA flag. - thp_get_unmapped_area I don't really understand why we have a dax check there. - dax_mapping will be much harder to sort out. But all these DAX flags certainly look like a major hodge podge to me. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2667167-1520029305-2-17816871591294811657 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='UTF-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520029304; b=nCs6MCLfkkWTacT745Vzm067fomhODcqcA2f671dIWOb1d2 PV5vDRkpjVIs+cyAl3cBPr2sSja3tAuxUUqz5cwC0fNbEgbLZuMatt+VFQjS+/Bc nUz24CqYnbmwPtPcuUSyqp4lQmt9M8S5RN6w6uc+x6T8v/Wxyz1c3gz5dYJptV6G PZSlY/6PTeqv9DhLrxbKIOlJMPNRwKzarNqii48vkc+oNnstfR9PpmmqzY57ej3a vEYWgxyY4lu5Aj52xnj5C8h0cKSrQaduvT7a6NbqD2V1TL0L4/IlIaLMsJA2DVtx mLN03pkbnmQR7GMxW0AX8g7ubLFkPpfgItJtJbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=mime-version:in-reply-to:references:from :date:message-id:subject:to:cc:content-type:sender:list-id; s= arctest; t=1520029304; bh=z70g2VGzpNjaOHYPEYfTdJFSxj0ZN2Vfb6IZaX qJ+r4=; b=uvc4r27XxZ9B2b85ePK+NfzJBni1xKcz6S8CxNB78Hhpgw6O6L1Dg4 4j8r2dO82X+cX2vrmDOWEakD/G1qzijHopQit2v/U/tGIxRnEsNiX8nVg7NCAeua RouI2EqLMNjUqq6sukAFNc6I9ZSIdjNbRXWfb1dygpYmXiHEWoIdz/Pc2sHWL1Wv 0zqduX2YoFbNn2kPmXxyvNrpbdijMBGkLrB43UHkzpIwNf4U7J+wb4J4kE7Vgmq9 OQ1HbXOOr14bJke7gHd8Uf+5JVV3esW8P1Slnxf4DiW3IxEhGDYEp9zA2y65Leqc +8f9swfCRgD5wlTOmBDkt2sJEWumHpbg== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b=2BseVqP/ x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20150623; dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=MD78MWhn; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b=2BseVqP/ x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20150623; dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=MD78MWhn; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752850AbeCBWVn (ORCPT ); Fri, 2 Mar 2018 17:21:43 -0500 Received: from mail-oi0-f53.google.com ([209.85.218.53]:42346 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751608AbeCBWVl (ORCPT ); Fri, 2 Mar 2018 17:21:41 -0500 X-Google-Smtp-Source: AG47ELsIo1M8rXeanEqknYMz1WIpfcqUFO5HRUX0WZ1dABl+M8hyVDog6u87AoJ/sUuEYqH+uAqV3Pcbt9FL/lemPgQ= MIME-Version: 1.0 In-Reply-To: <20180302221020.GA30722@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 14:21:40 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes To: Christoph Hellwig Cc: linux-nvdimm , linux-xfs , "Darrick J. Wong" , KVM list , Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable , Jan Kara , Michal Hocko , Andreas Dilger , Ross Zwisler , Matthew Wilcox , linux-fsdevel , Alex Williamson , "Theodore Ts'o" , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Fri, Mar 2, 2018 at 2:10 PM, Christoph Hellwig wrote: > I really don't like these IS_DEVDAX and IS_FSDAX flags. We should > stop pretending DAX is a global per-inode choice and get rid of these > magic flags entirely. So please convert the instances inside the > various file systems to checking the file system mount options instead. > > For the core ones we'll need to differentiate: > > - the checks in generic_file_read_iter and __generic_file_write_iter > seem to not be needed anymore at all since we stopped abusing the > direct I/O code for DAX, so they should probably be removed. > - io_is_direct is a weird check and should probably just go away, > as there is not point in always setting IOCB_DIRECT for DAX I/O > - fadvise should either become a file op, or a flag on the inode that > fadvice is supported instead of the nasty noop_backing_dev_info or > DAX check. > - Ditto for madvise > - vma_is_dax should probably be replaced with a VMA flag. > - thp_get_unmapped_area I don't really understand why we have a dax > check there. > - dax_mapping will be much harder to sort out. > > But all these DAX flags certainly look like a major hodge podge to me. They are indeed a hodge-podge. The problem is that the current IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks you propose for the next merge window. Acceptable? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2765994-1520031478-2-7256592002143751764 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='de', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520031477; b=qQ2k29I9PgcucP9xGL/7w2ZM19uUPU3HuTQIi983TGudMKT vxr+eEaiziRhl8zOt5tzezhNPvUiQPLIblOUOyWBAjcOKQB8FwlOnTq3rEFaibf2 wdXu2AvHoOmSKtZf7Pn95rfmQa+pf7QgaEGkJeq/uPUl2uX4vcNIMTLcYug0eZo/ p2SB44Nl9Ppgv1AjwXHwuMXsJA+XKXQwUrz0G7Za6PZYXdldOL/rOkO8MgwMSJUH Kvyegb8WttROGdHCm6Dnxitf/eRyVFZS6lBkNPinb122lCTk8efVze9BJ0XajMMH UHB4sjDyuibhCkSbzNRCtwnRrcAHIbZLz5z5YRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1520031477; bh=u35BaRl8gNr9DdhcfjTegwN15n HOxeF6Na6eBymVC8M=; b=LiJJIy6CkD+8BDI3WnVYrv8cxZiLrJmKQfcX8fmvJI A7vkal297u2h2kHBqbhX3tEN2O1ckTENqiFzfH3CdnGObtbVseJl+lqzcvA1FBJm buzJlrMW7ABRcw4YbwFk4fgUPfTwF4YbF4VRTidC5aUiETrQBf55YE755KyYwdgu EYsrMmcGGGf8gIkfc8vzwBeb36vgPnbZW28GU1UHVQOZ7PWdY4bLBeBp2B6oSUbW 9ZzhS0aHSiDAsm5qjId/8P+546kDRXerQlFPRjNXNsxsiN27zPas66nqhyaQYLwx EZSEDNBVTSrAG4HDgBE1TjJwTwtdieXbc5o5HlMHRi6Q== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934016AbeCBW5i (ORCPT ); Fri, 2 Mar 2018 17:57:38 -0500 Received: from verein.lst.de ([213.95.11.211]:38367 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932836AbeCBW5h (ORCPT ); Fri, 2 Mar 2018 17:57:37 -0500 Date: Fri, 2 Mar 2018 23:57:34 +0100 From: Christoph Hellwig To: Dan Williams Cc: Christoph Hellwig , linux-nvdimm , linux-xfs , "Darrick J. Wong" , KVM list , Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable , Jan Kara , Michal Hocko , Andreas Dilger , Ross Zwisler , Matthew Wilcox , linux-fsdevel , Alex Williamson , Theodore Ts'o , Linux MM , Linux Kernel Mailing List Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Message-ID: <20180302225734.GE31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: > They are indeed a hodge-podge. The problem is that the current > IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with > IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks > you propose for the next merge window. The only thing broken about IS_DAX are the code elimination games based on the CONFIG_* flags. Remove those and just add proper stubs for the dax routines and everything will be fine for now until we can kill that inode flag. IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't helping anyone. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2835548-1520034600-2-16026145717476423587 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='UTF-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520034600; b=RP6XJl3KubE0EKlfP3FcfXjFo6k6wZhbJeqE9WJjz1AaYKU XcrTbAdJw6hNHbbUNKSXkyM7FpOkYNpxHuXCFtEh1hftDsTJIMjQR1Wh/OPjg4id 1+8c22aYbibLbnmyOWJn4QpDzSnAl+4liQV/VrW6CtS8mcTLyY6L0Smirb69GaGd 9Cyf2q8eQGXxCtpeKUiG6PjOhvLj3yEQkU38VMQyRIrw+yH9mOth7xr0/mZgOAcN qKli0aiwnx2Z+tPcakp8+5GHMIJ6Xj/rpUZb/nUQj4ghACLHlD2gcnNPqA9wXX8B +584UhFJjuAH8KNUvE7+pTBsUrT50UNykX0kvyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=mime-version:in-reply-to:references:from :date:message-id:subject:to:cc:content-type:sender:list-id; s= arctest; t=1520034600; bh=urjZkcb2GAQ2TrO9uTJ4CzRTLWv85tzExX21wa pSCBQ=; b=mStMn076WRqtL/9EcN3GD/m3+En1xsneJTLS/VdwFbObVGdUlRP4OE m3Mft6Ka3DDIGt+qbDALJeVDCNdYlILaZOVuz/yvKRmMb9oQPncEAyIjVYinJwCA YwAQGYInNnnCiKJKFZgLUtp8HCZuJZaCwrOrR3nzxlm3df58cKgpBfjvS8JPz0Z1 UsFwUgv8WzY1v8b0Su5yXFYXkq73SxBlwL6DlRtqwNm1iTsuW8wFDGyQ/CeVIK1R 2KkvhSolnXiL2Hk2G5WjAgv47H4vSCYTy15ADjLPdonPE1IEz5PtIL6PDQPDhNLD wuXesbuhfohQyU954qisijLrYOF7f0fg== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b=HWczYa5q x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20150623; dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=dkb8P4dD; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b=HWczYa5q x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20150623; dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=dkb8P4dD; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935105AbeCBXts (ORCPT ); Fri, 2 Mar 2018 18:49:48 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:34344 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935099AbeCBXtq (ORCPT ); Fri, 2 Mar 2018 18:49:46 -0500 X-Google-Smtp-Source: AG47ELv8PoxUyLDELlfVGlStUsghoRvg3kvKLuQoPfDUfq4YvzwtXtphvHy+Y7K9sDQRQnD9qXcCwjbOzPiPVwzD1xQ= MIME-Version: 1.0 In-Reply-To: <20180302225734.GE31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> <20180302225734.GE31240@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 15:49:45 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes To: Christoph Hellwig Cc: linux-nvdimm , linux-xfs , "Darrick J. Wong" , KVM list , Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable , Jan Kara , Michal Hocko , Andreas Dilger , Ross Zwisler , Matthew Wilcox , linux-fsdevel , Alex Williamson , "Theodore Ts'o" , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Fri, Mar 2, 2018 at 2:57 PM, Christoph Hellwig wrote: > On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: >> They are indeed a hodge-podge. The problem is that the current >> IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with >> IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks >> you propose for the next merge window. > > The only thing broken about IS_DAX are the code elimination games > based on the CONFIG_* flags. Remove those and just add proper stubs > for the dax routines and everything will be fine for now until we can > kill that inode flag. > > IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't > helping anyone. Ok, I'll take another shot at something suitable for 4.16, but without these new helpers... From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2979411-1520043563-2-8133042926655713136 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='UTF-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520043563; b=w/HAvvimiKgJZTLTCpj0GLf9CA8jbSBveeHQnJbup2DBlM9 Pv45/VfxbT0TktbZjFlmML9FhhKep+ZuCoi8IxGAH4ItpCPEEp1ygENwJSY2lUsD H/RhOuKS3DQ1uU9XUs8UN6wDD19jXw6h2rGYH3w1e9R4LSu8WzowwwiaY3s7UIP7 kZlXh1bdzMYV1747HMPYRn5Yp9LA0zIyzgXa+W/TX/C3wzx7iT5AQBM41PayTLQp SJtFSj5nVwOHSMKO+c9MY1h29lmLjA4zv8mqEXWgBRQ1V1me0QZIdVYpm+3pDIkC dmPt/MeZMFjzZWf7zXub7tnGV35M+w5VDXdOG9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=mime-version:in-reply-to:references:from :date:message-id:subject:to:cc:content-type:sender:list-id; s= arctest; t=1520043563; bh=qjpsXh8moTIrfIc1Nxa1kTTCCLW/kJC9SUxsEs D+Lxs=; b=uVp39kEWcicqYeirGYFX0pwgtLjYBTlEvVxbmjFtvRYU+jXOTF1Hsw msP49a2Is7OALB9NGg9bfzhZ5NQHRfyfoYlabg4Ypr379sKamoFUKcyM8WcXe4i/ S7u5dnsgGC+cFKDgQu+72nNJjSCUzpVNcknOcnnbjxNnvuUhTKFjqvGW4WujORg8 K9rJVDMo0vVOI9WxMMGqWV0aJZnDQ9ljhv9N1q2mOtoktsoLi9H/Fh5KAQBBP1Rx PvqzxEne8BVg676GsbQQ2Ms46e6vviC7kyHMCamcLAoblaexFbYUmMyeA4PxdCQu hp//nryPjOn7vlvzOK90D6MQmS56i1Jw== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b=vu2+Vq9n x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20150623; dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=bfQzPlgf; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b=vu2+Vq9n x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20150623; dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=bfQzPlgf; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935740AbeCCCTT (ORCPT ); Fri, 2 Mar 2018 21:19:19 -0500 Received: from mail-oi0-f67.google.com ([209.85.218.67]:46551 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933609AbeCCCTR (ORCPT ); Fri, 2 Mar 2018 21:19:17 -0500 X-Google-Smtp-Source: AG47ELv8zz4lHxTJ/JltNXKlHV7jcjK8FQe+hPwi3bXp6k/ufbaUIIM2xPay/IuJ6p+YtV2f0wXxOlBGTjkalUSuw0o= MIME-Version: 1.0 In-Reply-To: References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> <20180302225734.GE31240@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 18:19:16 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes To: Christoph Hellwig Cc: linux-nvdimm , linux-xfs , "Darrick J. Wong" , KVM list , Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable , Jan Kara , Michal Hocko , Andreas Dilger , Ross Zwisler , Matthew Wilcox , linux-fsdevel , Alex Williamson , "Theodore Ts'o" , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Fri, Mar 2, 2018 at 3:49 PM, Dan Williams wrote: > On Fri, Mar 2, 2018 at 2:57 PM, Christoph Hellwig wrote: >> On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: >>> They are indeed a hodge-podge. The problem is that the current >>> IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with >>> IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks >>> you propose for the next merge window. >> >> The only thing broken about IS_DAX are the code elimination games >> based on the CONFIG_* flags. Remove those and just add proper stubs >> for the dax routines and everything will be fine for now until we can >> kill that inode flag. >> >> IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't >> helping anyone. > > Ok, I'll take another shot at something suitable for 4.16, but without > these new helpers... I'll drop patches 2-11 for now, and just get the high priority fixes in for the next rc. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-441027-1519963425-2-4449114833517442178 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963425; b=QVtw5Rhx2KfqGfe9kJY+FLqa/+/u1duk/fBDJNcBHYuXnfm bPwMdRsLSoNmwlDj5b8NsCBD9dTK4D6GHIbm1HdphAhbTzc74Y5XzjbMFp2lEbDy yB2x3zNVqmsEqKPMV84Rg0qbMetjUYpAujEbW5B8xpT/hg10VOo/jbZK8I9wtJBp oXBvDYWdYpSF0iK5Y710kHcfg1ZZnMmRk3LGzmVO7Kj5zpMK/exfwTFq2v1NuAmH mDKcOK6SRycxQbsEfRIiHJWxWgRGp6YnwXfCp0umuW7epGDQN/Ho2R6OWr+7NA88 vU9jCn7vooIfOnpaVb4x9GTSLdwu4r04H7IO7Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963425; bh=RMdT8uFwVDxzR+dlyKngaErTFPWHbsX/n4zHefiW93s=; b=q 3/5d8009m6uGdfCMmYOSDDbJN/hut9inLKSPUwe8KBCROUYU99ONXPxfcFetUCGE wWDcILEFy37akNBSL6r8HG1yLFon4QZXw74nglXyAkhqEY8Er8wykXtKPipmUZiJ UaOcaoWdlwr2oX+b+wQCgpiO34A3au81z9yar88XUa42wPVqMl4Xz6ab0hxbE6+z TYZ65V8xyZ5myYtNs6xKmApuNzaqm8uxH6hAD/YinSFPE0erS1sFnD5xJZqE3mPk jRgca1Xw3tXGh1kJKd2IiB30+l9mTClDDPTiKispnZolhmPOXtzKY49yzEgXi3Xj g9vUw2qoIBXRTcDmmELFg== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164861AbeCBEDb (ORCPT ); Thu, 1 Mar 2018 23:03:31 -0500 Received: from mga06.intel.com ([134.134.136.31]:54050 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164868AbeCBED3 (ORCPT ); Thu, 1 Mar 2018 23:03:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="30862327" 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 Cc: Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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; } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2738277-1520031300-2-18361503457391515971 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES enroda, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='de', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520031299; b=X3PtbH4/U13Q6cwJ/1Lk6KrZqa+js2zB+2Ds+95uPMKC+Tn drTD1wJv8MtGbe5XRHvyvrGErs5Aal1g6hEj5zaNgjrXomLZmc55vpgfKBM9SJe2 wjOh+JYYVO/60WgCV4NN87JFRru3DmAbS+MlrMkDSl4NbvOBgKrZV88PzmTSB6GS mVObk8JDTGk8O998CLdiMGucoQoVJ6RlGzV8b0bNCeIiZWTNnrkU1s/f6bBfrFNy cOMAO/nDPKc0wMY+Lz9FgrB7H1dJMGn6QsQqnJMu2NArG+cMEjayq6mbgg5Jjkwg 8jw2MuOi45tv8apXgcCr8NBTDA/OC528BZ2lDEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1520031299; bh=sMSbh4Q8YGTwIWwMKxxIdF15tA 6KiGtghD09R7VgMi0=; b=LUJOWj7j5ypIW2rEzaFSUP3VEHNneg/jgtYB5FNOLG rWFWuSE+nWl4WjZ2ZpL0QMMIMOlFFL/BujfmmfvHsq0eRmQYq9X/t4zedK0cU75A FlA5lZeqYmou7V+tDgD3Hst7B6/Y1V8pFGG8ucnV5DhTTlp8k/ugG42rG9MaILkH /eBigJIKnUYE8HulR3W2X2uF5RqMopAkrZUFfd24gtk5ZGdHz3qYnA0Fzzk72cy3 NDoZ/U7zsXCl1g1tVJ0vvvBroc01ZGMNSB4BgHbAR3IIrBx2MzhIERpx9jqXTYjO xVUswmvO1TR0JVLE+asWb0lKwCBDJZiSOKIkzLkg4ptg== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933962AbeCBWy5 (ORCPT ); Fri, 2 Mar 2018 17:54:57 -0500 Received: from verein.lst.de ([213.95.11.211]:38351 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933561AbeCBWy4 (ORCPT ); Fri, 2 Mar 2018 17:54:56 -0500 Date: Fri, 2 Mar 2018 23:54:55 +0100 From: Christoph Hellwig To: Dan Williams Cc: linux-nvdimm@lists.01.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 09/12] mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() Message-ID: <20180302225455.GD31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996286235.28483.2635632878864807577.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996286235.28483.2635632878864807577.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Thu, Mar 01, 2018 at 07:54:22PM -0800, Dan Williams wrote: > 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); If you look at the definition of IS_FSDAX and IS_DEVDAX this is going to evaluate into some bullshit code. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-441027-1519963577-2-13982896103520901134 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963576; b=UbFISQLen4vASGO+BUO/AbS6So0MrH+YteHMCHdSKNw3mNs Fp0eBSPfLR8GyAz5cveeTi5hE57yF4zLz2wLAN8TXaw23dj+ZqjndXptCiylBrmQ GQq8YBl2Z19ZCtqMlfPuENUNnr3UoAZJ7zIzuliyA/cy32kvy3181F93rATgJkIr lfI03BvYLP9vgO43AbqkYyjyRbfO608YUVdiLVFu6ArXyB4Efi0oaoKkRLbLjRzq fFOuqjE0px2ml3w+nWk7dgJcc0B62wfyGFEcrAnoRQRkY4O8n9rZVo4Fvfypm8z+ Y3H03M3vI+Ps9Vmggs7marj4nV7m85/XdLKIYSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963576; bh=WTMQFatoo3GkSxZLdyMJLfRuIsvJffvqAxxlnjQ4974=; b=I 4kh+6LTP29g12t/+LmQTZpT/2QCrrGZN/R7mYD5oMLVphmsaJ2vbdmiRV1cMJ+BO xwQTGwMDgNwhdQ9vRz9oGiCQUrxRomvd56fCtPzRku4sjI5bp5Nm9S8yOq/KYalP XRKhQhUzbiYkAMPxsdP1lpTupyQl095QypVXzMy4PuMnpuVJeLqsf/+dV0TrMWu0 AFZ0vEmEa/PHkz+ZhJtqXPsJC89EdguNPkFXb/CMIesYDGb35zY8s7hSAqC95qlq ILCwdLF3t6jbXhY4HIjXswQR2gmiaJ7o30ZHlOPmSK1ErwndKLVyhlITRQVSqJEk Q/WAKSeKFr9C0u9tG7oOg== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164609AbeCBECy (ORCPT ); Thu, 1 Mar 2018 23:02:54 -0500 Received: from mga06.intel.com ([134.134.136.31]:54020 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163935AbeCBECv (ORCPT ); Thu, 1 Mar 2018 23:02:51 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="24498643" Subject: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:44 -0800 Message-ID: <151996282448.28483.10415125852182473579.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..bd0c46880572 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2738277-1520031219-2-2320527782933865481 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES enroda, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='de', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520031218; b=pSotGOjkBTUyHOSP06fNcOvXHw3EbEuy9OLpTd2hPi0mwtS pCHVDyLu5iDi1IqqhL0mNo5W6f5xt4A0edbLyguXVqZf2Jw2IXSpDWqEWxnH8m3a zC5SGh9k4Xod0w15vlIx1+keS3QON4OM3dxreClw90uWgOWOif0QFjxsa6fkSm5Z JBVVDguuZQEW8VlSPw71ToCFGwVLA8wkmvksKNVFNfLbGnlhDl5EIgZkWtQn2M2Y UaXh+OIisUoCxlKapfM2X5S3jjK1BWFSxfe6Skr51N/I6ft8pdLKBfKByUNTJ1K/ 0E/ZVNENbwg+2BWIiQ/YpZSSFhJCD7BZkwaNgTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1520031218; bh=8CpxzIGCKw5dMoaTf7kjD0C35j RExspITjyWDraWvF8=; b=ZCIj5YbSmH852gdbogWTuPDsqbE8GCr6Sf0Q+DFTCC hpVHyi+Bhc44XkrzOSjeM4bmZ+byve9rQNEkUsAaza89ng7emIQkU72PhN/0FrAz tBR4vT1mQ9DXgoQC2poEJEjIXnVal+2bbb+gkITXtAuSzeWcdNvTfbV3p7Hkpr3m PoQEjR9JUPwyeD2rXfLA0oQ56YaG1fH8VnY1Egasb3YL/dgivFxMr9WDwf3OjSo0 tcp4Vzlfqi4P3mXvFSX+4rVv/Dozm90kvNkb1dzjg7dPFzJveApHUKRscHrZhRTL xEQj8V3dwQyi46iDReCT0UOz8qUiQWRAQ8i3bNajDSEA== ARC-Authentication-Results: i=1; mx4.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Authentication-Results: mx4.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933904AbeCBWxT (ORCPT ); Fri, 2 Mar 2018 17:53:19 -0500 Received: from verein.lst.de ([213.95.11.211]:38343 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933561AbeCBWxS (ORCPT ); Fri, 2 Mar 2018 17:53:18 -0500 Date: Fri, 2 Mar 2018 23:53:16 +0100 From: Christoph Hellwig To: Dan Williams Cc: linux-nvdimm@lists.01.org, Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() Message-ID: <20180302225316.GC31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: > +static inline bool IS_DEVDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_DEV_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (!S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > +static inline bool IS_FSDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_FS_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (S_ISCHR(inode->i_mode)) > + return false; > + return true; Encoding the is char device or not thing here is just nasty. I think this is going entirely in the wrong direction. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2080671-1520012757-2-12728960360616617064 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, UNPARSEABLE_RELAY 0.001, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520012756; b=Jetqt+ApWER6yDcNBVZZjhvO2LLEwFTKmJi0j0+V3ELGHaZ wVgVhF6cZBsT6rQRXx2nBlWcZaBf9zOYpQ2NOqKc+ilLZdZX73GngB1djvXg0BS8 6P4h1tlUqoCXlUkHlnm1uNc1YTPj/0aFilvF8mXniQBuzJk8Meu4zL9GMtENGBIQ e6POKsvHLFxYG7NAu3fo4R8xLwQSz/3nf3euUykDvPg6uCzGOCJxynwzVs7HWOdE HXyksQzonjcWpG8t6vw2J9HcrQwdr8UMcCPMqmzfUuJ7GuQwOCMSHy+59xb7LqXz uupxOC1c+Vh6jIAIfYQkReZzyOPGudgCPNuZAvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1520012756; bh=oQv/naU0ffRqEAxYEVpNgigqhl EK8I6ogIeAyTAJVFk=; b=Atbf0tGmBZq0qAZLLEIm00bHzP7Xnz8gCkNKsPP530 et22KM4Cp7wmGqp192sDUqqMMWoc8K3cCUMj9KxU+y6AcQBRZqVfqqyWZqyigbDy nUsxai7BkCOCmbXpXxHATu69HPJs1jEpVA7YHkQJTB3MNUJYnYkgCsqjJ2kPOvmc WaNj15jL93gi/ES172/LAyFl766mqdz0hkN1qcy4iPrRyXbSAM/a/lJg6kmmbq3s a6oQR0Eby9E8ptSbQDctpfyJPOmIRGE2dzKKQm4Vb/9GAGW7JXfJ9Q3rmdoN/qXK vk/u5fYTKMvWJWRFYhSHLak8uYYJzN3ALgubZ88uQuNw== ARC-Authentication-Results: i=1; mx6.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=oracle.com header.i=@oracle.com header.b=cIB8YQHZ x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=corp-2017-10-26; dmarc=pass (p=none,has-list-id=yes,d=none) header.from=oracle.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=oracle.com header.result=pass header_is_org_domain=yes Authentication-Results: mx6.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=oracle.com header.i=@oracle.com header.b=cIB8YQHZ x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=corp-2017-10-26; dmarc=pass (p=none,has-list-id=yes,d=none) header.from=oracle.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=oracle.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946825AbeCBRpy (ORCPT ); Fri, 2 Mar 2018 12:45:54 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:57008 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946824AbeCBRpw (ORCPT ); Fri, 2 Mar 2018 12:45:52 -0500 Date: Fri, 2 Mar 2018 09:45:30 -0800 From: "Darrick J. Wong" To: Dan Williams Cc: linux-nvdimm@lists.01.org, "Theodore Ts'o" , Andreas Dilger , Alexander Viro , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() Message-ID: <20180302174530.GV19312@magnolia> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8820 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803020209 Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Thu, Mar 01, 2018 at 07:53:44PM -0800, Dan Williams wrote: > The current IS_DAX() helper that checks if a file is in DAX mode serves > two purposes. It is a control flow branch condition for DAX vs > non-DAX paths and it is a mechanism to perform dead code elimination. The > dead code elimination is required in the CONFIG_FS_DAX=n case since > there are symbols in fs/dax.c that will be elided. While the > dead code elimination can be addressed with nop stubs for the fs/dax.c > symbols that does not address the need for a DAX control flow helper > where fs/dax.c symbols are not involved. > > Moreover, the control flow changes, in some cases, need to be cognizant > of whether the DAX file is a typical file or a Device-DAX special file. > Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the > file-type control flow and dead-code elimination use cases. IS_DAX() > will be deleted after all sites are converted to use the file-type > specific helper. > > Note, this change is also a pre-requisite for fixing the definition of > the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. > The flag needs to be defined, non-zero, if either DAX facility is > enabled. > > Cc: "Theodore Ts'o" > Cc: Andreas Dilger > Cc: Alexander Viro > Cc: "Darrick J. Wong" > Cc: linux-xfs@vger.kernel.org > Cc: Matthew Wilcox > Cc: Ross Zwisler > Cc: > Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") > Reported-by: Jan Kara > Reviewed-by: Jan Kara > Signed-off-by: Dan Williams > --- > include/linux/fs.h | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 79c413985305..bd0c46880572 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags > #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ > (inode)->i_rdev == WHITEOUT_DEV) > > +static inline bool IS_DEVDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_DEV_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (!S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > +static inline bool IS_FSDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_FS_DAX)) > + return false; I echo Jan's complaint from the last round that the dead code elimination here is subtle, as compared to: #if IS_ENABLED(CONFIG_FS_DAX) static inline bool IS_FSDAX(struct inode *inode) { ... } #else # define IS_FSDAX(inode) (false) #endif But I guess even with that we're relying on dead code elimination higher up in the call stack... > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (S_ISCHR(inode->i_mode)) > + return false; I'm curious, do we have character devices with S_DAX set? I /think/ we're expecting that only block/char devices and files will ever have S_DAX set, so IS_FSDAX is only true for block devices and files. Right? (A comment here about why S_ISCHR->false here would be helpful.) --D > + return true; > +} > + > static inline bool HAS_UNMAPPED_ID(struct inode *inode) > { > return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2196896-1520015866-2-4498093399607060202 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='UTF-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520015865; b=UAECPVMi/AhmZ/UN6czZZ7F4oTFiw2Rr0cUzDl/0l2vodTL iN8M+ZEu49y4KyQwi2RkEHOJjfkkzV0B2JCtq3tAdWTFiIxrX20hy91qnxMgbmWA j4aqKf9csgdmT5R9g0hq4kpEUATeZ4deZ7eUimFAvJsEntRz2y3rQDsPVWwJn8kj TMcuavVi7n4Gzs+j+1FFWc7qVbnAL2uvaT/ZYJ7liiee1T4l6nHrycG7JIuA3ZRb 7NQAWFaT3z07joyzVchIEfhClaWJ3gvMPNYpunMC7Mj0Xcpthffas9rxDok4oUYg aZS2TWDoXecXppkePf9x3KbSMwEpsF70yglvPwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=mime-version:in-reply-to:references:from :date:message-id:subject:to:cc:content-type:sender:list-id; s= arctest; t=1520015865; bh=oCqnKKcOWN0ZV3NxI8KlUkpWK8aXcFvIHaKvGS BORwQ=; b=dyx8iz63sjgSDfLcYm8moiFMkxUeomXZXoe/i8Qv1BbRuSqRSxNU5t keaIliglkDVVJCtTHaRnH3aqX3EerQddDrjuPFMoAcXgiwN2b99kiJu4NfD2yZDv Uv5rhuFkwbDdRFmO55lrj5rd1Y+9sBK4H8fn0jF/2AGqhZ7Vj51DMKuvihLRX48u SD7krXY715z7lcQd1oiKk+O/YAgZi7T0Qr8PRFBBmba4D5/NTnzZxT2i4D/qr6Bk 73ZjrtYFFKIzUGlThIu29QtQDrWQvnrHjQRB0oFBlNtFHV08BA1LfYn44TpIbPqs RZVE9upoiueBieyMh2pj+vbSkRbOdHnQ== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b=avO5DZ05 x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20150623; dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=EwiOSITn; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b=avO5DZ05 x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=20150623; dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-google-dkim=pass (2048-bit rsa key) header.d=1e100.net header.i=@1e100.net header.b=EwiOSITn; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947319AbeCBShn (ORCPT ); Fri, 2 Mar 2018 13:37:43 -0500 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34426 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1947293AbeCBShl (ORCPT ); Fri, 2 Mar 2018 13:37:41 -0500 X-Google-Smtp-Source: AG47ELsYl4z0vP7TKUSautJsZzsKlqsFVg1egPCHOT4fTb9LXb0RCH5ziRfkPXxG+a02XjH2nsfD4BJzWyVUZ1//YSs= MIME-Version: 1.0 In-Reply-To: <20180302174530.GV19312@magnolia> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302174530.GV19312@magnolia> From: Dan Williams Date: Fri, 2 Mar 2018 10:37:40 -0800 Message-ID: Subject: Re: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() To: "Darrick J. Wong" Cc: linux-nvdimm , "Theodore Ts'o" , Andreas Dilger , Alexander Viro , linux-xfs , Matthew Wilcox , Ross Zwisler , stable , Jan Kara , Christoph Hellwig , linux-fsdevel , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Fri, Mar 2, 2018 at 9:45 AM, Darrick J. Wong wrote: > On Thu, Mar 01, 2018 at 07:53:44PM -0800, Dan Williams wrote: >> The current IS_DAX() helper that checks if a file is in DAX mode serves >> two purposes. It is a control flow branch condition for DAX vs >> non-DAX paths and it is a mechanism to perform dead code elimination. The >> dead code elimination is required in the CONFIG_FS_DAX=n case since >> there are symbols in fs/dax.c that will be elided. While the >> dead code elimination can be addressed with nop stubs for the fs/dax.c >> symbols that does not address the need for a DAX control flow helper >> where fs/dax.c symbols are not involved. >> >> Moreover, the control flow changes, in some cases, need to be cognizant >> of whether the DAX file is a typical file or a Device-DAX special file. >> Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the >> file-type control flow and dead-code elimination use cases. IS_DAX() >> will be deleted after all sites are converted to use the file-type >> specific helper. >> >> Note, this change is also a pre-requisite for fixing the definition of >> the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. >> The flag needs to be defined, non-zero, if either DAX facility is >> enabled. >> >> Cc: "Theodore Ts'o" >> Cc: Andreas Dilger >> Cc: Alexander Viro >> Cc: "Darrick J. Wong" >> Cc: linux-xfs@vger.kernel.org >> Cc: Matthew Wilcox >> Cc: Ross Zwisler >> Cc: >> Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") >> Reported-by: Jan Kara >> Reviewed-by: Jan Kara >> Signed-off-by: Dan Williams >> --- >> include/linux/fs.h | 22 ++++++++++++++++++++++ >> 1 file changed, 22 insertions(+) >> >> diff --git a/include/linux/fs.h b/include/linux/fs.h >> index 79c413985305..bd0c46880572 100644 >> --- a/include/linux/fs.h >> +++ b/include/linux/fs.h >> @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags >> #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ >> (inode)->i_rdev == WHITEOUT_DEV) >> >> +static inline bool IS_DEVDAX(struct inode *inode) >> +{ >> + if (!IS_ENABLED(CONFIG_DEV_DAX)) >> + return false; >> + if ((inode->i_flags & S_DAX) == 0) >> + return false; >> + if (!S_ISCHR(inode->i_mode)) >> + return false; >> + return true; >> +} >> + >> +static inline bool IS_FSDAX(struct inode *inode) >> +{ >> + if (!IS_ENABLED(CONFIG_FS_DAX)) >> + return false; > > I echo Jan's complaint from the last round that the dead code > elimination here is subtle, as compared to: > > #if IS_ENABLED(CONFIG_FS_DAX) > static inline bool IS_FSDAX(struct inode *inode) { ... } > #else > # define IS_FSDAX(inode) (false) > #endif > > But I guess even with that we're relying on dead code elimination higher > up in the call stack... If IS_FSDAX() was only a dead-code elimination mechanism rather than a runtime branch condition then I agree. Otherwise I think IS_ENABLED() is suitable and not subtle, especially when used in a header file. >> + if ((inode->i_flags & S_DAX) == 0) >> + return false; >> + if (S_ISCHR(inode->i_mode)) >> + return false; > > I'm curious, do we have character devices with S_DAX set? Yes, Device-DAX, see: ab68f2622136 /dev/dax, pmem: direct access to persistent memory > I /think/ we're expecting that only block/char devices and files will > ever have S_DAX set, so IS_FSDAX is only true for block devices and > files. Right? We had S_DAX on block-devices for a short while, but deleted it and went with the Device-DAX interface instead. So it's only regular files and /dev/daxX.Y nodes these days. > (A comment here about why S_ISCHR->false here would be helpful.) Ok. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2297825-1520018149-2-13032804188052999206 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520018147; b=KxxlYbU51IuswUjb3OKwxSjo68llhJPPc3HBODRTe2txHMp bVYYfPtczP1k1pQrZhBBSHuzpIPDkS8/CCBIgJPu0LCK4rTqxVJGTA6gEpZ+pcnB PX+p/NafoS67wr+kc9uxbPpAUyZDDjIwQVjCZ3bVu61BXciKF0jm0vHNgeTn1HLk BEVHcI2sfhyJl5m5SS4Pp0k9+bxuHvJdsexZddgv8x+IberZMKiyNtpyRW8ANT2O AtO8yjKoGXEiQ2G2tKM79Sj4jQMo+dzQ3Het4IOmQOy/xAsKBHpVLwI1pejtHWtD dyxVcDuUzkAY1s8atcWrmMqKPCWh5L+/yOs6T6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1520018147; bh=Hhhu/8+HWBL0A7i2E4Qu43/EN7uCC0MrFyET/cxd9Y0=; b=U iDI3KpNbmou8Bs+k2sM6ts613abwI/LQ4F2aKEI2ykdv4JRWYl/8NKNb5WEkHVJS 53vsC5Ik2MDGoPyvXwgxmAzshD+ukCaFjk/AmkRD6xc/wnYiDFO2EzOVrWqo9sSp FjlpUaLBAV9aoqclF8GP6bYNkoLcxg/FtoUTvEs5RshDShL2QQ+P4xrv7BY58Sm/ GgWpCGI6/14I579HRNpxzYibrvLUfK1uF1kMxJlIMLM9++nop0ATFKMUfl3SzAA0 08gUnE3rDS+BnPnIXUh5OWs9i4xZ5PlRxOA0gvW+vjeqcCNec/Pyz/+HtKfM6AEs iSWoYk0+trS+k/n4xLp4w== ARC-Authentication-Results: i=1; mx6.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx6.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1426302AbeCBTPo (ORCPT ); Fri, 2 Mar 2018 14:15:44 -0500 Received: from mga06.intel.com ([134.134.136.31]:4817 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423640AbeCBTPn (ORCPT ); Fri, 2 Mar 2018 14:15:43 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,413,1515484800"; d="scan'208";a="22401525" Subject: [PATCH v6] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , Jan Kara , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Date: Fri, 02 Mar 2018 11:06:36 -0800 Message-ID: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: References: User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- Changes since v5: * add comments to clarify the S_ISCHR() checks (Darrick) include/linux/fs.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..751975b8b29b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,30 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* regular files with S_DAX are filesystem-dax instances */ + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* character devices with S_DAX are device-dax instances */ + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2351456-1520020723-2-5775380285938129295 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, UNPARSEABLE_RELAY 0.001, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520020723; b=K/QBM2sIi/P1KOiqAmX30Hbhdidtdoh20kQZEz1ljuacau2 9msEBUwHeJ3XsdYDinx3HSAe2Ax4BXCPoJ2zOs45SboW9TGfLZ+gq5L0eE4BBueF yp2BYLGubpwqeKUN8okwO7tDgyfnU0ICCFaCDjiBEB0Kxnb1bvLB2fWuCxLTAWfx RXOgnaVF5wjl8Tw5pEWgFhnb9oD8/Edrj4gv6EPRjTepxuQppQdzoVWpx4QlKjoD P76lK41VHEAuTz3UiWaAsYvNBDDh5uHcbVVcTDW096OWbOlekgA5VId398jEbmaW d5kgj8+mLejWlBnYrw71GK6wqus93abYnWvFPjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1520020723; bh=65LEN5xTWlQB/3uXYAZgDeJUe+ lXVuUdeRDIZqrd/q4=; b=oZ9yWyH+xFQlbUEDwtSSzMsMgJW6IKlvkjjIsuyQu0 cX6SYyiJZMfdLRXIR88sOM0PUapNJMVoUXagFmnrWjuvulthyYDfH/sd2OPOZJTO ef4siSE2K0AztPoZL5yQz6kZjDThU3SWY9t3u5Azjdy/1cFG4l+Q2//6VzA4RJq0 IkIPR0wujKKBbxEHsf5EkyTxK3Jo3y3OgEDnO9AvLi+ZvFfjUyhHY9MUsvo8x3NS LCdGIg2IjTRS430Os4EFiW7eEkZNotTSr3SPAefWmJFq7IsUqNBnH4+//47rxG28 Ver01CnX5xAgfrFHOy1/F2jgADKwze5GUYIgEhZ32u3w== ARC-Authentication-Results: i=1; mx6.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=oracle.com header.i=@oracle.com header.b=kDCsoWSN x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=corp-2017-10-26; dmarc=pass (p=none,has-list-id=yes,d=none) header.from=oracle.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=oracle.com header.result=pass header_is_org_domain=yes Authentication-Results: mx6.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=oracle.com header.i=@oracle.com header.b=kDCsoWSN x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=corp-2017-10-26; dmarc=pass (p=none,has-list-id=yes,d=none) header.from=oracle.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=oracle.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932494AbeCBT61 (ORCPT ); Fri, 2 Mar 2018 14:58:27 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60816 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932131AbeCBT60 (ORCPT ); Fri, 2 Mar 2018 14:58:26 -0500 Date: Fri, 2 Mar 2018 11:58:11 -0800 From: "Darrick J. Wong" To: Dan Williams Cc: linux-nvdimm@lists.01.org, "Theodore Ts'o" , Andreas Dilger , Alexander Viro , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6] dax: introduce IS_DEVDAX() and IS_FSDAX() Message-ID: <20180302195811.GA18989@magnolia> References: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8820 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803020235 Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Fri, Mar 02, 2018 at 11:06:36AM -0800, Dan Williams wrote: > The current IS_DAX() helper that checks if a file is in DAX mode serves > two purposes. It is a control flow branch condition for DAX vs > non-DAX paths and it is a mechanism to perform dead code elimination. The > dead code elimination is required in the CONFIG_FS_DAX=n case since > there are symbols in fs/dax.c that will be elided. While the > dead code elimination can be addressed with nop stubs for the fs/dax.c > symbols that does not address the need for a DAX control flow helper > where fs/dax.c symbols are not involved. > > Moreover, the control flow changes, in some cases, need to be cognizant > of whether the DAX file is a typical file or a Device-DAX special file. > Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the > file-type control flow and dead-code elimination use cases. IS_DAX() > will be deleted after all sites are converted to use the file-type > specific helper. > > Note, this change is also a pre-requisite for fixing the definition of > the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. > The flag needs to be defined, non-zero, if either DAX facility is > enabled. > > Cc: "Theodore Ts'o" > Cc: Andreas Dilger > Cc: Alexander Viro > Cc: "Darrick J. Wong" > Cc: linux-xfs@vger.kernel.org > Cc: Matthew Wilcox > Cc: Ross Zwisler > Cc: > Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") > Reported-by: Jan Kara > Reviewed-by: Jan Kara > Signed-off-by: Dan Williams > --- > Changes since v5: > * add comments to clarify the S_ISCHR() checks (Darrick) Looks ok, Reviewed-by: Darrick J. Wong --D > > include/linux/fs.h | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 79c413985305..751975b8b29b 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1909,6 +1909,30 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags > #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ > (inode)->i_rdev == WHITEOUT_DEV) > > +static inline bool IS_DEVDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_DEV_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + /* regular files with S_DAX are filesystem-dax instances */ > + if (!S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > +static inline bool IS_FSDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_FS_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + /* character devices with S_DAX are device-dax instances */ > + if (S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > static inline bool HAS_UNMAPPED_ID(struct inode *inode) > { > return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-441027-1519963591-2-2243823388985738490 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES enro, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963590; b=t4+e+6PeCwTfMYyuA037ZzZo5dO10LmyzRh03YRot81GNcS OT2P97maMdtCssa9wgW1gaP60NzVZ2oIwpccTUn9m1Ynrn5c9Nq7IRPWNZ77bA6l Su83Wn+3tgtp2wT35jec4JABWjNZ7hIhj7dF/X5X36ahB7QH3gxYOsF13an+UgOy tXTI27dJWzwhnrf3KFujGYWYB9jehN0oCdSahE7rblMDofJw715dlPsIxEod4p4U x6PFtcPOJRTC5G569YhDLa85oYNby/7JI4o9D1kdt47znzaM2qUTJUmRHcFyx1h4 5YQdppwzWghdaUtdHyjNilN5HSRQJhjnrbowK6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963590; bh=rffv3sWQ2L3MU3KEtL1teeUI4C8j3LVdPhVLCJeRu+s=; b=H R/2F/9HX0G9xch86VmC0UKUnVDE0diz4hRsqYD3qf+yxJqmS4Nof7Zax7oM/J2Fb 3U1RoOuVaKXMfjC/LeK128LOt+GMx6rTNI59BvF99/DbsfYkJDv9iIFdC7dbJqS6 Vpb7wSUAKjx1PeYtOWt1IMB+NIkOsc7sL3EtV7BxKp725nBzwD08YdmiEZjKT/PG PSeAU2EGS7mER8FTCZOxmJn4AUhTHNiu7GYLGwAqZEafdbFc4GfWP7T6/a7YkH9z VCdN8Fq7mjNr9Gmw4UOHb9jh0u9rmV43ciFlPqFgpGHKT/FDntte3aRWZkh5r5RJ ii4B1HwqAPWGGaCLsxTxA== ARC-Authentication-Results: i=1; mx6.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx6.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164462AbeCBECs (ORCPT ); Thu, 1 Mar 2018 23:02:48 -0500 Received: from mga04.intel.com ([192.55.52.120]:16694 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163935AbeCBECp (ORCPT ); Thu, 1 Mar 2018 23:02:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="208265690" Subject: [PATCH v5 01/12] dax: fix vma_is_fsdax() helper From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Gerd Rausch , Jane Chu , Haozhong Zhang , Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:38 -0800 Message-ID: <151996281881.28483.2616406435517031167.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Gerd reports that ->i_mode may contain other bits besides S_IFCHR. Use S_ISCHR() instead. Otherwise, get_user_pages_longterm() may fail on device-dax instances when those are meant to be explicitly allowed. Fixes: 2bb6d2837083 ("mm: introduce get_user_pages_longterm") Cc: Reported-by: Gerd Rausch Acked-by: Jane Chu Reported-by: Haozhong Zhang Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 2a815560fda0..79c413985305 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3198,7 +3198,7 @@ static inline bool vma_is_fsdax(struct vm_area_struct *vma) if (!vma_is_dax(vma)) return false; inode = file_inode(vma->vm_file); - if (inode->i_mode == S_IFCHR) + if (S_ISCHR(inode->i_mode)) return false; /* device-dax */ return true; } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2738277-1520031136-2-5978192732442332101 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='de', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520031136; b=WBZ2Rxm9wA5G82f10uvTIjaNpQ/Wi8oA7Bd7ffUaQtlbEfu rr9RvmgfXIApRn9mWA3SJA/XE+4dmq1TQLHtHXGN50P+0Irg37tQOQk5WfRGavWd GFkk7QJg5wzF+o5eQClK1KiGIse6GGtXgZ3xnpuh2dScS1pq8OArq9z5srcTEN0C Yhe9aB+VvptMa7S9COvergsOswWTVCi7aLDhxJOaqsu1FvOeKMY3ssDRHAFd49nt nh3yY7e/1+wGBchxSRly1RPbiBO+n3XHmqSEHxbozQnqNI64vmkxH7ktv/9JLVEu W8zqNkgTY5S76upwCfACunHhEedqSAZpn6c/MvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1520031136; bh=l2WBiCb5duYJRA9nKpihqrJOH1 Qjg6utSrFiu8qAdtc=; b=SPm8N7WKlnWUSNvM+C+wSYHDYced1/pkYKaFTHfwBF 0ds8zVVBsWJ0wsfOosu0uLBwRHbYrPEU/iO6Ps8RDhxxcHVdLTenQw/Yx5FhEFpA LtkKDUUw4vp2OW/JmpsHKRDw0ts1BEsDXLGE5xwvtvNzUem0B8KuAPxuq271DX3v WOYhhdd8KTKpaXfCcFHEOXHZESdWSUu5hJvmhA9NW+urMk97Ax9beZtjo8CRm7bp v7dgX4ZROKWYtuqDxf19UbWGAKewX/nEXuwmC0e0n2D2JI3v4w9I5GgOk92dA+06 12omVK2ly3u1Dwj0XGUcBtVBX+7bMvykKkJM/c15Kfkg== ARC-Authentication-Results: i=1; mx4.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Authentication-Results: mx4.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=lst.de; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=lst.de header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933838AbeCBWwN (ORCPT ); Fri, 2 Mar 2018 17:52:13 -0500 Received: from verein.lst.de ([213.95.11.211]:38330 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933561AbeCBWwM (ORCPT ); Fri, 2 Mar 2018 17:52:12 -0500 Date: Fri, 2 Mar 2018 23:52:10 +0100 From: Christoph Hellwig To: Dan Williams Cc: linux-nvdimm@lists.01.org, stable@vger.kernel.org, Gerd Rausch , Jane Chu , Haozhong Zhang , Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 01/12] dax: fix vma_is_fsdax() helper Message-ID: <20180302225210.GB31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996281881.28483.2616406435517031167.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996281881.28483.2616406435517031167.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Looks good, Reviewed-by: Christoph Hellwig From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-441027-1519963499-2-17772319386195351383 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963498; b=ur/dSsUAQ0fAlc2aJ9+ELYJYcw7WSTNmbWlmWomDHp85Oqs dhF6E4votEe8llZ5jsXTWW3o3AemvwairXyCnL/sq3vwSTysUawZdAzxqKsJU4T0 ZEFLQXOR7phtB/DZuODqHHvNlKRyA0Em6VfOZJKEyTdSLCOpLNfYfyw5GP0gP7RG XGMQ+l4Qmiy4Ln5rl6Bs+5ySs08GYUnq7hKXdzNMjPKZEGmiONqt1W9YkdH/sDfP +DRP594+mMQGHXZPkYPYuR+Ex6Dvkj8VNshbLfsvGYTxtjsqDY08lSB6BKiKHjNd zfY8A8vLT3l9bh84nxjAcr9nXKUSAXU47oPYhMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963498; bh=G0zukMsoR1s8ueyW2JTSCJK1fOmV/HKxp/3Ex38whRE=; b=s oi9Yq+layR6MTTZBugfXw4Oh3Xya2XH3o3FJAIz5Vbci4ynGBAK1LrP4fjLzZ+7T Pi4MoGMt87hjLIuis7H72HDGzrlpQvVDo9Gqv0G14TXAkmAXEwXXvLf5qWQXUqTY EMr12qv2EaETlJokyA3NyDSeb9eC5DcWeBDmL1tjwctZGlPgC/fqxiAxoXdcKbV0 c3C4c0yBstmpsSwA9xowHnereiPPWRMOGiHzwyJKUrPctcO1WV4auPAyC/DVHoP4 uwHmJfkzhfFao9OFbRnkL/T1HjF/VsvVtyJGqgxhk66O8/9jqMMePWs06GE1qNdR t0mK1PEIIuLI6ZTabhQrg== ARC-Authentication-Results: i=1; mx4.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx4.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164859AbeCBED2 (ORCPT ); Thu, 1 Mar 2018 23:03:28 -0500 Received: from mga07.intel.com ([134.134.136.100]:9465 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164734AbeCBEDX (ORCPT ); Thu, 1 Mar 2018 23:03:23 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="21317069" Subject: [PATCH v5 08/12] xfs, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:16 -0800 Message-ID: <151996285683.28483.13394624369523668388.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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 FSDAX since DAX is ambiguous. Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org 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 --- fs/xfs/xfs_file.c | 14 +++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++--- fs/xfs/xfs_reflink.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 9ea08326f876..46a098b90fd0 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -288,7 +288,7 @@ xfs_file_read_iter( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) ret = xfs_file_dax_read(iocb, to); else if (iocb->ki_flags & IOCB_DIRECT) ret = xfs_file_dio_aio_read(iocb, to); @@ -726,7 +726,7 @@ xfs_file_write_iter( if (XFS_FORCED_SHUTDOWN(ip->i_mount)) return -EIO; - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) ret = xfs_file_dax_write(iocb, from); else if (iocb->ki_flags & IOCB_DIRECT) { /* @@ -1045,7 +1045,7 @@ __xfs_filemap_fault( } xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED); - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { pfn_t pfn; ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &xfs_iomap_ops); @@ -1070,7 +1070,7 @@ xfs_filemap_fault( { /* DAX can shortcut the normal fault path on write faults! */ return __xfs_filemap_fault(vmf, PE_SIZE_PTE, - IS_DAX(file_inode(vmf->vma->vm_file)) && + IS_FSDAX(file_inode(vmf->vma->vm_file)) && (vmf->flags & FAULT_FLAG_WRITE)); } @@ -1079,7 +1079,7 @@ xfs_filemap_huge_fault( struct vm_fault *vmf, enum page_entry_size pe_size) { - if (!IS_DAX(file_inode(vmf->vma->vm_file))) + if (!IS_FSDAX(file_inode(vmf->vma->vm_file))) return VM_FAULT_FALLBACK; /* DAX can shortcut the normal fault path on write faults! */ @@ -1124,12 +1124,12 @@ xfs_file_mmap( * We don't support synchronous mappings for non-DAX files. At least * until someone comes with a sensible use case. */ - if (!IS_DAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) + if (!IS_FSDAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) return -EOPNOTSUPP; file_accessed(filp); vma->vm_ops = &xfs_file_vm_ops; - if (IS_DAX(file_inode(filp))) + if (IS_FSDAX(file_inode(filp))) vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; return 0; } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 89fb1eb80aae..234279ff66ce 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1108,9 +1108,9 @@ xfs_ioctl_setattr_dax_invalidate( } /* If the DAX state is not changing, we have nothing to do here. */ - if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_DAX(inode)) + if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_FSDAX(inode)) return 0; - if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode)) + if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_FSDAX(inode)) return 0; /* lock, flush and invalidate mapping in preparation for flag change */ diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 66e1edbfb2b2..cf794d429aec 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -241,7 +241,7 @@ xfs_iomap_write_direct( * the reserve block pool for bmbt block allocation if there is no space * left but we need to do unwritten extent conversion. */ - if (IS_DAX(VFS_I(ip))) { + if (IS_FSDAX(VFS_I(ip))) { bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO; if (imap->br_state == XFS_EXT_UNWRITTEN) { tflags |= XFS_TRANS_RESERVE; @@ -952,7 +952,7 @@ static inline bool imap_needs_alloc(struct inode *inode, return !nimaps || imap->br_startblock == HOLESTARTBLOCK || imap->br_startblock == DELAYSTARTBLOCK || - (IS_DAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); + (IS_FSDAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); } static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags) @@ -988,7 +988,7 @@ xfs_file_iomap_begin( return -EIO; if (((flags & (IOMAP_WRITE | IOMAP_DIRECT)) == IOMAP_WRITE) && - !IS_DAX(inode) && !xfs_get_extsz_hint(ip)) { + !IS_FSDAX(inode) && !xfs_get_extsz_hint(ip)) { /* Reserve delalloc blocks for regular writeback. */ return xfs_file_iomap_begin_delay(inode, offset, length, iomap); } diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 270246943a06..a126e00e05e3 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1351,7 +1351,7 @@ xfs_reflink_remap_range( goto out_unlock; /* Don't share DAX file data for now. */ - if (IS_DAX(inode_in) || IS_DAX(inode_out)) + if (IS_FSDAX(inode_in) || IS_FSDAX(inode_out)) goto out_unlock; ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-2080671-1520012800-2-11987067582355093521 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, UNPARSEABLE_RELAY 0.001, LANGUAGES unknown, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1520012798; b=NMEq588IhrqSQaTifPGK7oQOCE6DLkG54fydfHDT0SpPp3c R7GcirZjftLvaHTBIMIz36g0t06LQXqUW6yVyUnYq+hMS68YRiCpWzeJI3DBfEpa yjrMuTiNGW1px70+D6C7/xKFNRtpK5iYl8m9UGiNmp/GoNC8uoe0sovDcVAtCrmM VNxCHEDpIn0AaX/40iPxZBjg3qEW+dzbU2u4WWppgDgFrIpHvfxDGzqRXBgb8hCY cvn0Da3SKLwUHW53lRoefo5gh4eSko9N5W3ZLBarXXgq0WdSbJNS/mL/D7UVqCL9 VB2hxr3SpOKSnByheRsQIyiHuHkJVkbW6ULyZdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=arctest; t=1520012798; bh=KEVISQNpVV5gbc8Pf5mCWARvxv Z1Ngb98vA57BsW7ng=; b=CIIXa6lVlZRW1W5K5qfjJSE4zgV1fiPtKNEoqNUADn q4hqHloNltbuv77/zhIiGwHpS8c7TmuS3qMUHqso/o5vJSCpr0IH1hr2HOlUFNez FviNASSBBTzpn0wGoeE0ssqvfmPnv23R4fREZs1hvjRC0ipfMVIUbG/O6S0rTkXq 1s+MVB4bhy+K1sxMpGjUjGOTX0+ret6UjtxqNOQFJyKnQFo1EkUKW9B6bG6aClWH EO81Cp+VJLMjN71Hb0VF0vG23MTmRKbKHU7kb5XGwPXqlg2JA8Hid3vHrxKgMFBY /0x6nD5U7b1Fe8K5FA4HaJa1w59qt022xzl8Hf7Hi24A== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=oracle.com header.i=@oracle.com header.b=MaovFMsm x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=corp-2017-10-26; dmarc=pass (p=none,has-list-id=yes,d=none) header.from=oracle.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=oracle.com header.result=pass header_is_org_domain=yes Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=pass (2048-bit rsa key sha256) header.d=oracle.com header.i=@oracle.com header.b=MaovFMsm x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=corp-2017-10-26; dmarc=pass (p=none,has-list-id=yes,d=none) header.from=oracle.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=oracle.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946854AbeCBRqV (ORCPT ); Fri, 2 Mar 2018 12:46:21 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:47588 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946197AbeCBRqU (ORCPT ); Fri, 2 Mar 2018 12:46:20 -0500 Date: Fri, 2 Mar 2018 09:46:07 -0800 From: "Darrick J. Wong" To: Dan Williams Cc: linux-nvdimm@lists.01.org, linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 08/12] xfs, dax: replace IS_DAX() with IS_FSDAX() Message-ID: <20180302174607.GW19312@magnolia> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996285683.28483.13394624369523668388.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996285683.28483.13394624369523668388.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8820 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803020209 Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Thu, Mar 01, 2018 at 07:54:16PM -0800, Dan Williams wrote: > 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 FSDAX since DAX is ambiguous. > > Cc: "Darrick J. Wong" > Cc: linux-xfs@vger.kernel.org > 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 Looks ok, Reviewed-by: Darrick J. Wong --D > --- > fs/xfs/xfs_file.c | 14 +++++++------- > fs/xfs/xfs_ioctl.c | 4 ++-- > fs/xfs/xfs_iomap.c | 6 +++--- > fs/xfs/xfs_reflink.c | 2 +- > 4 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index 9ea08326f876..46a098b90fd0 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -288,7 +288,7 @@ xfs_file_read_iter( > if (XFS_FORCED_SHUTDOWN(mp)) > return -EIO; > > - if (IS_DAX(inode)) > + if (IS_FSDAX(inode)) > ret = xfs_file_dax_read(iocb, to); > else if (iocb->ki_flags & IOCB_DIRECT) > ret = xfs_file_dio_aio_read(iocb, to); > @@ -726,7 +726,7 @@ xfs_file_write_iter( > if (XFS_FORCED_SHUTDOWN(ip->i_mount)) > return -EIO; > > - if (IS_DAX(inode)) > + if (IS_FSDAX(inode)) > ret = xfs_file_dax_write(iocb, from); > else if (iocb->ki_flags & IOCB_DIRECT) { > /* > @@ -1045,7 +1045,7 @@ __xfs_filemap_fault( > } > > xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED); > - if (IS_DAX(inode)) { > + if (IS_FSDAX(inode)) { > pfn_t pfn; > > ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &xfs_iomap_ops); > @@ -1070,7 +1070,7 @@ xfs_filemap_fault( > { > /* DAX can shortcut the normal fault path on write faults! */ > return __xfs_filemap_fault(vmf, PE_SIZE_PTE, > - IS_DAX(file_inode(vmf->vma->vm_file)) && > + IS_FSDAX(file_inode(vmf->vma->vm_file)) && > (vmf->flags & FAULT_FLAG_WRITE)); > } > > @@ -1079,7 +1079,7 @@ xfs_filemap_huge_fault( > struct vm_fault *vmf, > enum page_entry_size pe_size) > { > - if (!IS_DAX(file_inode(vmf->vma->vm_file))) > + if (!IS_FSDAX(file_inode(vmf->vma->vm_file))) > return VM_FAULT_FALLBACK; > > /* DAX can shortcut the normal fault path on write faults! */ > @@ -1124,12 +1124,12 @@ xfs_file_mmap( > * We don't support synchronous mappings for non-DAX files. At least > * until someone comes with a sensible use case. > */ > - if (!IS_DAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) > + if (!IS_FSDAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) > return -EOPNOTSUPP; > > file_accessed(filp); > vma->vm_ops = &xfs_file_vm_ops; > - if (IS_DAX(file_inode(filp))) > + if (IS_FSDAX(file_inode(filp))) > vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; > return 0; > } > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c > index 89fb1eb80aae..234279ff66ce 100644 > --- a/fs/xfs/xfs_ioctl.c > +++ b/fs/xfs/xfs_ioctl.c > @@ -1108,9 +1108,9 @@ xfs_ioctl_setattr_dax_invalidate( > } > > /* If the DAX state is not changing, we have nothing to do here. */ > - if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_DAX(inode)) > + if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_FSDAX(inode)) > return 0; > - if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode)) > + if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_FSDAX(inode)) > return 0; > > /* lock, flush and invalidate mapping in preparation for flag change */ > diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c > index 66e1edbfb2b2..cf794d429aec 100644 > --- a/fs/xfs/xfs_iomap.c > +++ b/fs/xfs/xfs_iomap.c > @@ -241,7 +241,7 @@ xfs_iomap_write_direct( > * the reserve block pool for bmbt block allocation if there is no space > * left but we need to do unwritten extent conversion. > */ > - if (IS_DAX(VFS_I(ip))) { > + if (IS_FSDAX(VFS_I(ip))) { > bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO; > if (imap->br_state == XFS_EXT_UNWRITTEN) { > tflags |= XFS_TRANS_RESERVE; > @@ -952,7 +952,7 @@ static inline bool imap_needs_alloc(struct inode *inode, > return !nimaps || > imap->br_startblock == HOLESTARTBLOCK || > imap->br_startblock == DELAYSTARTBLOCK || > - (IS_DAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); > + (IS_FSDAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); > } > > static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags) > @@ -988,7 +988,7 @@ xfs_file_iomap_begin( > return -EIO; > > if (((flags & (IOMAP_WRITE | IOMAP_DIRECT)) == IOMAP_WRITE) && > - !IS_DAX(inode) && !xfs_get_extsz_hint(ip)) { > + !IS_FSDAX(inode) && !xfs_get_extsz_hint(ip)) { > /* Reserve delalloc blocks for regular writeback. */ > return xfs_file_iomap_begin_delay(inode, offset, length, iomap); > } > diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c > index 270246943a06..a126e00e05e3 100644 > --- a/fs/xfs/xfs_reflink.c > +++ b/fs/xfs/xfs_reflink.c > @@ -1351,7 +1351,7 @@ xfs_reflink_remap_range( > goto out_unlock; > > /* Don't share DAX file data for now. */ > - if (IS_DAX(inode_in) || IS_DAX(inode_out)) > + if (IS_FSDAX(inode_in) || IS_FSDAX(inode_out)) > goto out_unlock; > > ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-494696-1519963563-2-16931887403135139728 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES ro, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963563; b=rhwRcS4wLc9I4BJjFwmBnBuoXm5BIpDXoH/Kx9CNqiA+lHh MNAiqlCWXekSkhYg3x13lQwrcxc5BcU6H0hGsBzXitH6Un2ro8h4JAHP7qwTTmia UBxys5mcfvAfd4etIJLyadEM5tRNVMP+w+6fvaDrPzfNySvrlFeVAAEYlaCnuzdR ikWfDymU7DdFS2h7nA3kEdklA7pahld3qKUQmejuac9Er/HEoKjXKyuwEH6PPZOU m76XYyVtbESIWc7bTlu8Cj4u9E4mVclQRosG5DHaaQp90mn6JZ2ZA+6EfC3jxZtA 182PZKAk/8uWNi0XL6lw4fmTslqD+mOz3lAnhRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963563; bh=BBaIw/5RTsiBcoiFheAo7gX1O+npXLPg41anVwNwR+M=; b=Y yGFgmSS7K2RAPN9Oyykj7kedOtQHvEWGFpg+qn4kZXgF38yiuEeY+PTohPK86RMB 3WL3pj7zcIzyyh2Y3o9bdGit80aTlsD6gOL3sLKboseNYjVWwgs800ema3ZprLuS yIruWPrPl1gC+UEMcBXIfpWaBDmku9GjTIzyAeYOJuARqTKOm3b/4ghgIxBsK5+Q YdUMc/B59Uh5D8/SlS5V8i1dJxWugUO+gAcfnes7o8GyFGLZtiMcCCSo2R2HkQGv aGaowIKYsQ/vEUTU+26KwNr1RgwRNE0LKpd6BOUQ2apW9eCNcbFQUHVLyf2w9nvZ KyQjAtf5OnjVCNvMJ3CvQ== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164679AbeCBEDB (ORCPT ); Thu, 1 Mar 2018 23:03:01 -0500 Received: from mga09.intel.com ([134.134.136.24]:10205 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163935AbeCBEC6 (ORCPT ); Thu, 1 Mar 2018 23:02:58 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="208218814" Subject: [PATCH v5 03/12] ext2, dax: finish implementing dax_sem helpers From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:50 -0800 Message-ID: <151996283005.28483.12905745385121745420.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: dax_sem_{up,down}_write_sem() allow the ext2 dax semaphore to be compiled out in the CONFIG_FS_DAX=n case. However there are still some open coded uses of the semaphore. Add dax_sem_{up_read,down_read}() and dax_sem_assert_held() helpers. Use them to convert all open-coded usages of the semaphore to the helpers. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext2/ext2.h | 6 ++++++ fs/ext2/file.c | 5 ++--- fs/ext2/inode.c | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 032295e1d386..203c31dfe549 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h @@ -711,9 +711,15 @@ struct ext2_inode_info { #ifdef CONFIG_FS_DAX #define dax_sem_down_write(ext2_inode) down_write(&(ext2_inode)->dax_sem) #define dax_sem_up_write(ext2_inode) up_write(&(ext2_inode)->dax_sem) +#define dax_sem_assert_held(ei) WARN_ON(!rwsem_is_locked(&(ei)->dax_sem)) +#define dax_sem_down_read(ext2_inode) down_read(&(ext2_inode)->dax_sem) +#define dax_sem_up_read(ext2_inode) up_read(&(ext2_inode)->dax_sem) #else #define dax_sem_down_write(ext2_inode) #define dax_sem_up_write(ext2_inode) +#define dax_sem_assert_held(ext2_inode) +#define dax_sem_down_read(ext2_inode) +#define dax_sem_up_read(ext2_inode) #endif /* diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 09640220fda8..1c7ea1bcddde 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -91,18 +91,17 @@ static ssize_t ext2_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) static int ext2_dax_fault(struct vm_fault *vmf) { struct inode *inode = file_inode(vmf->vma->vm_file); - struct ext2_inode_info *ei = EXT2_I(inode); int ret; if (vmf->flags & FAULT_FLAG_WRITE) { sb_start_pagefault(inode->i_sb); file_update_time(vmf->vma->vm_file); } - down_read(&ei->dax_sem); + dax_sem_down_read(EXT2_I(inode)); ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops); - up_read(&ei->dax_sem); + dax_sem_up_read(EXT2_I(inode)); if (vmf->flags & FAULT_FLAG_WRITE) sb_end_pagefault(inode->i_sb); return ret; diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 9b2ac55ac34f..4783db0e4873 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1187,9 +1187,7 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset) blocksize = inode->i_sb->s_blocksize; iblock = (offset + blocksize-1) >> EXT2_BLOCK_SIZE_BITS(inode->i_sb); -#ifdef CONFIG_FS_DAX - WARN_ON(!rwsem_is_locked(&ei->dax_sem)); -#endif + dax_sem_assert_held(ei); n = ext2_block_to_path(inode, iblock, offsets, NULL); if (n == 0) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-494696-1519963560-2-3090719118467583089 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES roensk.us-ascii, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963560; b=dYu0QddpD3cLobJ7YV4M2+t+Ge3UJzJn80uZ8U2I8/geNRP nvJh3Ua68s4Y5clO3YVw+G9uAoXxoffU1NCx4clgIo/kYF7WMOrXKocnn6jt+diA iGla+PYPqGX9ECMw1EQ1yMMOyXL1Tnr7lRTqIRoVr7k+MUhv5a7m7THCTnKqAtqe C2s1MeptyNZpSKAd+f8CHEIhIDNcG79duIgSPRoKZFP7HpRnN7Vy41+ZiaHvii5Y wuXv2BKpUxLvK2K3XY3x1TGcql6W2BxorBBR+lqom2MbVDUqfWXo0iJNkdWOMhfE plJFjGT0+fR/aYxjHyhb0MjXUfOVHJDK2xAHAHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963560; bh=7TtV1NR8LFL9+SMyCFxDxmD6Eow65InNOCr7926kUbw=; b=h IqAJ0aZEFL7nBfiLg0ijHcC4b2K6Y2d5peRtnoqsY07ycFGEfTcyzl9wvvz/icBC M0Z45pbEbZhKZON+yVxQWwDlCFEowXN30NpU0ps/2HWTR0Y3ODWdYRu0Fy7YpyQE 4ajMQ2P7HFVvqiqoeqTWeZEatP3d5byOxrp/ZVhK/74fUn9+CItNcEnxNEXtxbNL t5PA/+64q7POvkzQBA4+ALIp7rrVduYMlEXTh2+OGMXC9Q4pY3xR1sCTsq6I1UcV /KAZaw2EC00ad9fCFK4gL40mbap1482pAqm2bSLWe/Fh5rOksOkLRVhJ97qaO604 NIdA0LqYXiukOSonVryAg== ARC-Authentication-Results: i=1; mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx5.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164701AbeCBEFW (ORCPT ); Thu, 1 Mar 2018 23:05:22 -0500 Received: from mga05.intel.com ([192.55.52.43]:30878 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164696AbeCBEDM (ORCPT ); Thu, 1 Mar 2018 23:03:12 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="35314024" Subject: [PATCH v5 06/12] ext2, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:06 -0800 Message-ID: <151996284593.28483.4922911524438696817.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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 FSDAX since DAX is ambiguous. 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 --- fs/ext2/file.c | 6 +++--- fs/ext2/inode.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 5ac98d074323..702a36df6c01 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -119,7 +119,7 @@ static const struct vm_operations_struct ext2_dax_vm_ops = { static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) { - if (!IS_DAX(file_inode(file))) + if (!IS_FSDAX(file_inode(file))) return generic_file_mmap(file, vma); file_accessed(file); @@ -158,14 +158,14 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync) static ssize_t ext2_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { - if (IS_DAX(iocb->ki_filp->f_mapping->host)) + if (IS_FSDAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_read_iter(iocb, to); return generic_file_read_iter(iocb, to); } static ssize_t ext2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { - if (IS_DAX(iocb->ki_filp->f_mapping->host)) + if (IS_FSDAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_write_iter(iocb, from); return generic_file_write_iter(iocb, from); } diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 4783db0e4873..5352207da9d5 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -733,7 +733,7 @@ static int ext2_get_blocks(struct inode *inode, goto cleanup; } - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { /* * We must unmap blocks before zeroing so that writeback cannot * overwrite zeros with stale data from block device page cache. @@ -940,7 +940,7 @@ ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) loff_t offset = iocb->ki_pos; ssize_t ret; - if (WARN_ON_ONCE(IS_DAX(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode))) return -EIO; ret = blockdev_direct_IO(iocb, inode, iter, ext2_get_block); @@ -1294,7 +1294,7 @@ static int ext2_setsize(struct inode *inode, loff_t newsize) inode_dio_wait(inode); - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { error = iomap_zero_range(inode, newsize, PAGE_ALIGN(newsize) - newsize, NULL, &ext2_iomap_ops); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-494696-1519963547-2-13705776996967296762 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES enro, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963546; b=c1hpbwp1EpCFpsiRQWPPUl8k+l54bhgsquu9+24L0iwm47Z fzx+ZJFfiGp5E2tWoBSSWArTn0k0adxxAw0UtNQWhZJYHaQsH3TO6DN4bW7o7+Wz Ikp9BNYH3hK7yopU8AsL6MpaZRyD0YUuDE+4hAYlu8HM1RMgrnL9ACYwiyXhWKmV quSUy3v7Qs/HqOL5bgHxM7hfoSXrAifQMGkqeDMVQc4Qj/VRtLUX0EPOVJy7a3h0 FkIpWQu21qUKSoLv4MeN6gjL80L8g7nwisgtRCptWVizCORpfksLeQqbTQCO6d21 xnEAKXmKSQTf+Oztk0s3xHXRzD7jCqDZKhu4iew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963546; bh=hIzffaiosM/Lp4vPpVMOX11XJU4GR3K5dh6LhngJAg8=; b=O XqbWNaVIG1wP57mNTqZMVKPALlBhenA5pBBc1rJmj+0u/pK0epQjwRffyTbHynRC yOEKAdtwS3lHlSdi38AW8uCbpTw8g/HRuI1Eftcm0DMsdsfbqiThhbntt8NgIqoW n3EXpvsHAPKEUuxbUYPeQh94AorXPVSTCPwwb/aIgnAHHBzYlJg8pvFzkIyuJRfU H9xOpM52m0CHgmlWX61l8CaeowzJ6yRb54rrIWQXpgbVPDL0dmDcdEbeZbQQv6CQ KUlhr/pUEEzZYAVIOWmb2i24AEvuy3LEx5mmx6HE0ZFGZSQrPxQ3HQpZxQ+HdqFh uu1t+FGYf7BpMDIFKJXow== ARC-Authentication-Results: i=1; mx2.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx2.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422656AbeCBEFY (ORCPT ); Thu, 1 Mar 2018 23:05:24 -0500 Received: from mga14.intel.com ([192.55.52.115]:55261 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164684AbeCBEDB (ORCPT ); Thu, 1 Mar 2018 23:03:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="21948180" Subject: [PATCH v5 04/12] ext2, dax: define ext2_dax_*() infrastructure in all cases From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:55 -0800 Message-ID: <151996283559.28483.2221179891176741624.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: In preparation for fixing S_DAX to be defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, move the definition of these routines outside of the "#ifdef CONFIG_FS_DAX" guard. This is also a coding-style fix to move all ifdef handling to header files rather than in the source. The compiler will still be able to determine that all the related code can be discarded in the CONFIG_FS_DAX=n case. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext2/file.c | 8 -------- include/linux/dax.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 1c7ea1bcddde..5ac98d074323 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -29,7 +29,6 @@ #include "xattr.h" #include "acl.h" -#ifdef CONFIG_FS_DAX static ssize_t ext2_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct inode *inode = iocb->ki_filp->f_mapping->host; @@ -128,9 +127,6 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) vma->vm_flags |= VM_MIXEDMAP; return 0; } -#else -#define ext2_file_mmap generic_file_mmap -#endif /* * Called when filp is released. This happens when all file descriptors @@ -162,19 +158,15 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync) static ssize_t ext2_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { -#ifdef CONFIG_FS_DAX if (IS_DAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_read_iter(iocb, to); -#endif return generic_file_read_iter(iocb, to); } static ssize_t ext2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { -#ifdef CONFIG_FS_DAX if (IS_DAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_write_iter(iocb, from); -#endif return generic_file_write_iter(iocb, from); } diff --git a/include/linux/dax.h b/include/linux/dax.h index 0185ecdae135..47edbce4fc52 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -93,8 +93,6 @@ void dax_flush(struct dax_device *dax_dev, void *addr, size_t size); void dax_write_cache(struct dax_device *dax_dev, bool wc); bool dax_write_cache_enabled(struct dax_device *dax_dev); -ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, - const struct iomap_ops *ops); int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size, pfn_t *pfnp, int *errp, const struct iomap_ops *ops); int dax_finish_sync_fault(struct vm_fault *vmf, enum page_entry_size pe_size, @@ -107,6 +105,8 @@ int dax_invalidate_mapping_entry_sync(struct address_space *mapping, int __dax_zero_page_range(struct block_device *bdev, struct dax_device *dax_dev, sector_t sector, unsigned int offset, unsigned int length); +ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops); #else static inline int __dax_zero_page_range(struct block_device *bdev, struct dax_device *dax_dev, sector_t sector, @@ -114,6 +114,12 @@ static inline int __dax_zero_page_range(struct block_device *bdev, { return -ENXIO; } + +static inline ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops) +{ + return -ENXIO; +} #endif static inline bool dax_mapping(struct address_space *mapping) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-441027-1519963524-2-10709133843812783671 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES enro, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963524; b=GQtfPlypRTx6hQsDNgPYmMPUJzk1ND8pmh+QmAXX1Xf6NHZ uvAcFl+Yz9OXNkYmCpPJHPeADgwWDHga8lU3o4A/FCfkAKPXB0m8wEv8I6IhRTJN opMeY4S0MXGiNUgoJd8Rit7b/6b3bHYDZX92iTb5jSu6R+B8LgFqDhbmXIB/j25b CrH9C069+unAxNgBVowzD5sBwxfWFJQqs8NLE1JR6qbL+iddaugip40i14IBaY2d r43DV+ygcUZ5fvQGvrDtPqIw6W1yEaabzAljH2gdKSNobZzIE8BiOYyynzFtzHGq JjsYRKPv0SFv9CJYz5OICTsrPyXlg5w5IUObZkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963524; bh=u4IuOfrAzISw4leA9y+RRtNKQVsXBmq2+1ouBMeF5fo=; b=r mBvCTMU7zvajnJgNiahk9Zp8vqjMCMSGaCm3TeU0F75C1Zbzn9sW2a7oyDx1v3if FWv03ZBFigsxhxKnNTb67uo4fkFYxcdhBLb6pCxxSMfvlXUF7UmTnSQweUhF+SeT dHWM9ndTgD0BSONmRbCk6CeiVUMgwuu1MIM5YNxT5CWI0Xxwy7LodZ87y9vzGIbA PekSbHh2csPpUJYSJTSY/7idnixEj1cQuSlf/fWQXO/TY5Hs8ZwNRa3lcbnWAIT0 qyJr6YVVMRt6G1Wp9gjSiJ7yPOgblqkGd/gTav2Gr2e4sV6C9oK1y//J52iW4M0D DIg/IVZ6HyEH3RSs7FbCw== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164756AbeCBEDN (ORCPT ); Thu, 1 Mar 2018 23:03:13 -0500 Received: from mga07.intel.com ([134.134.136.100]:9457 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164734AbeCBEDG (ORCPT ); Thu, 1 Mar 2018 23:03:06 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="204910831" Subject: [PATCH v5 05/12] ext4, dax: define ext4_dax_*() infrastructure in all cases From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:00 -0800 Message-ID: <151996284080.28483.11296105582801541424.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: In preparation for fixing S_DAX to be defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, move the definition of these routines outside of the "#ifdef CONFIG_FS_DAX" guard. This is also a coding-style fix to move all ifdef handling to header files rather than in the source. The compiler will still be able to determine that all the related code can be discarded in the CONFIG_FS_DAX=n case. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext4/file.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index fb6f023622fe..51854e7608f0 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -34,7 +34,6 @@ #include "xattr.h" #include "acl.h" -#ifdef CONFIG_FS_DAX static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct inode *inode = file_inode(iocb->ki_filp); @@ -60,7 +59,6 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) file_accessed(iocb->ki_filp); return ret; } -#endif static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { @@ -70,10 +68,8 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (!iov_iter_count(to)) return 0; /* skip atime */ -#ifdef CONFIG_FS_DAX if (IS_DAX(file_inode(iocb->ki_filp))) return ext4_dax_read_iter(iocb, to); -#endif return generic_file_read_iter(iocb, to); } @@ -179,7 +175,6 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from) return iov_iter_count(from); } -#ifdef CONFIG_FS_DAX static ssize_t ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) { @@ -208,7 +203,6 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) ret = generic_write_sync(iocb, ret); return ret; } -#endif static ssize_t ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-494696-1519963512-2-11127142447504888257 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES enro, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963512; b=trN+rMh3wgLnb8KNFGq3ibUPjOVu4yAwhMknHidOUK1ahm3 4WVHSUg4Yk4j9FtEit5WYQES5CEDKHivDRZqWjhqA9tc3s8ujUCAZAsQcG/HE8Cq 9ei/AYqBdE0sgAlvls9ry2uiw2syCZdXVklJYlMVDfb7Djh7kPenLiAw7BbK/5dE 1bdyq9YTOcc5eKOCLYy/TDBbw4AFTwr/81eyvpZUo+22nIksMI6uHFJ7/tC14vvO PJagZWD2Iv0l7vMmmMtL/0IOVrZ9PxGgP8NfXatxr5JMcksf67G9Nl+dX8LuVX5u jPNBVxWdfT2BCPB6PiVWuvSVu02EVLK+a10QixA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963512; bh=wKOsQN7Tny/lVMXe0jo6uyeKglm0sEA694t1DT3IMb8=; b=M Wgpjgl1cQkgofhJGnYEalb+Gj12aobr3YESrnPk+tOh+Tx22Zk9Qr07IM9uRfn1I i218R6HpufMR0T0aZsxRm21yx8rTbAitDdAeB8GutDoBRYzbjhczZsK6rIqDH0go z6jzF1yeTrA+xH8xCeLy1uAchaibHiB3KMgOy3n00DxMSFLb6Rp9Q5lwIlYbT7RC WSMSDTY0mOjon1RfaMUxyYI96hP0igZvjcKDyFQnRMaJKQllFFCpp8g6orCofMil rhWFL6jE6P2IyKKEQCmp8YhLnbK1MgJEp4qgfBlQwPEXqpvWoT0iJNBPS4J/Bd6G /ecO/zvhBYeT227BoIkZQ== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164841AbeCBEDU (ORCPT ); Thu, 1 Mar 2018 23:03:20 -0500 Received: from mga02.intel.com ([134.134.136.20]:28338 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164734AbeCBEDS (ORCPT ); Thu, 1 Mar 2018 23:03:18 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="208265819" Subject: [PATCH v5 07/12] ext4, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:11 -0800 Message-ID: <151996285107.28483.10237358640480864296.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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 FSDAX since DAX is ambiguous. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro 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 --- fs/ext4/file.c | 12 +++++------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 51854e7608f0..561ea843b458 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -48,7 +48,7 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) * Recheck under inode lock - at this point we are sure it cannot * change anymore */ - if (!IS_DAX(inode)) { + if (!IS_FSDAX(inode)) { inode_unlock_shared(inode); /* Fallback to buffered IO in case we cannot support DAX */ return generic_file_read_iter(iocb, to); @@ -68,7 +68,7 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (!iov_iter_count(to)) return 0; /* skip atime */ - if (IS_DAX(file_inode(iocb->ki_filp))) + if (IS_FSDAX(file_inode(iocb->ki_filp))) return ext4_dax_read_iter(iocb, to); return generic_file_read_iter(iocb, to); } @@ -216,10 +216,8 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; -#ifdef CONFIG_FS_DAX - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) return ext4_dax_write_iter(iocb, from); -#endif if (!o_direct && (iocb->ki_flags & IOCB_NOWAIT)) return -EOPNOTSUPP; @@ -361,11 +359,11 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) * We don't support synchronous mappings for non-DAX files. At least * until someone comes with a sensible use case. */ - if (!IS_DAX(file_inode(file)) && (vma->vm_flags & VM_SYNC)) + if (!IS_FSDAX(file_inode(file)) && (vma->vm_flags & VM_SYNC)) return -EOPNOTSUPP; file_accessed(file); - if (IS_DAX(file_inode(file))) { + if (IS_FSDAX(file_inode(file))) { vma->vm_ops = &ext4_dax_vm_ops; vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; } else { diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c94780075b04..1879b33aa391 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3858,7 +3858,7 @@ static ssize_t ext4_direct_IO(struct kiocb *iocb, struct iov_iter *iter) return 0; /* DAX uses iomap path now */ - if (WARN_ON_ONCE(IS_DAX(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode))) return 0; trace_ext4_direct_IO_enter(inode, offset, count, iov_iter_rw(iter)); @@ -4076,7 +4076,7 @@ static int ext4_block_zero_page_range(handle_t *handle, if (length > max || length < 0) length = max; - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { return iomap_zero_range(inode, from, length, NULL, &ext4_iomap_ops); } diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 7e99ad02f1ba..040fc6570ddb 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -790,7 +790,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) "Online defrag not supported with bigalloc"); err = -EOPNOTSUPP; goto mext_out; - } else if (IS_DAX(inode)) { + } else if (IS_FSDAX(inode)) { ext4_msg(sb, KERN_ERR, "Online defrag not supported with DAX"); err = -EOPNOTSUPP; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 39bf464c35f1..933e12940181 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1161,7 +1161,7 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, if (inode->i_ino == EXT4_ROOT_INO) return -EPERM; - if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode) && i_size_read(inode))) return -EINVAL; res = ext4_convert_inline_data(inode); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-441027-1519963459-2-3975813036716436846 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963458; b=bWusnzC7Nqs2RJkerGR9g+2sX1z7JkfBfik+gHtEaVB3oME nx2xmGm5rimF4PDIkyT+ZQpp80MsMvN1+HRfATn8CZIoJlJrfVE5+LIMGhROmwOh YPUs1UFDy8Y+pfz4izO5qGrXjMEiWUQr4RB8OMiogAVBuB96xaQSZU+si81ye7Cw B2r0cpquV1MgKOnuviwPCay5coDRZOyOnrTwBODkLaW5cPHTc9kLgU680PrDe7EF dsZQ8spmYtUKPhrS5aTjqpIVgyxGtLSSzQTs4nFrZ3VknKgA+tSHrBHLygWLtFmO 1WlkFtgeAkmiT/lwBzc2WCztLsfyIYcAQtrvDjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963458; bh=rEB95E/ATwxTmP2l2XrhYNjl2ql9TRoxEkgyJ5GI2bE=; b=A qGy9YJWlcVG8GVWni6/CzPHeaIcBRqIxqpfRyn4piALStce9h1x7bJK4gVTJFWFQ rUZ+BMk5Hc4IXHysTOcUz2aWP+R1Qj6OyR0nI5gQU8FfkEozImjT2XFngFTUIXaj 9BEIthXQVwMTupF5ubsY2QkXrg9pfX/Y4thgOOac3BIUegIFduw9paXaXeihSwf1 x+5MEmIkSWGLJ6hT/lNl2BR8vsAWz434ajlDoShl1x4fycoBAhieur6K0TAscMtt B+IV+STuZ72kYEwu+AY7NuRoWOk9t+ICmkgKy9Nn3Qbcyc9yfH2ql1CZYw3eOgDp afhPMwON4JoVCBiAWhBWA== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164921AbeCBEDn (ORCPT ); Thu, 1 Mar 2018 23:03:43 -0500 Received: from mga01.intel.com ([192.55.52.88]:19606 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164868AbeCBEDk (ORCPT ); Thu, 1 Mar 2018 23:03:40 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="21455146" Subject: [PATCH v5 11/12] dax: fix S_DAX definition From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Christoph Hellwig , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:34 -0800 Message-ID: <151996287403.28483.8962319815764432894.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Make sure S_DAX is defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. Otherwise vma_is_dax() may incorrectly return false in the Device-DAX case. Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index b2b2e15d227b..1242511b1c46 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1859,7 +1859,7 @@ struct super_operations { #define S_IMA 1024 /* Inode has an associated IMA struct */ #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ #define S_NOSEC 4096 /* no suid or xattr security attributes */ -#ifdef CONFIG_FS_DAX +#if IS_ENABLED(CONFIG_FS_DAX) || IS_ENABLED(CONFIG_DEV_DAX) #define S_DAX 8192 /* Direct Access, avoiding the page cache */ #else #define S_DAX 0 /* Make all the DAX code disappear */ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-441027-1519963450-2-1175390780109863595 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963449; b=tNJBTqqP2vP1OvCU+34P8dj6Ls2b5mq+CMjWgApqqubFeqb wkV9c+hoi2OVgTZQaYyvOWen4Dar28IkbIlT8dDCqLy0gyFcUK7/0Gdw2j2a9k8o TEYyXGoWtioRI2ZPH8UI4INxxxHnIobScYNapZKF5dKbL94/r64Mc+RYuSg2CaK2 blGWq8gY9Gdydvy/fn6n2PNZfw+m4q86v9Ba7RZrRF/6RFvEadsdevtyvxNBf08d 5AvCntoSxTLZJtYWI/gKPmJTGA7flm5ca/ohF9OnPRr9TDAk0Aabbhf/TT/RxciT p2/xUIdgQGKCsrHGKP8yfNe5G6KtgqI81F8vIOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963449; bh=KYXc4jrVaWYhHTFY5eYhnfYPjwewDRYi878d94WD7bU=; b=t zbLKX9FMWL+sFw4Wrjr0qZnVnkc6yV8tgFNiaakDpH6LKmv6/qeS6oj5eSLw+hO2 ecybxAWSZdsMvcAsJc/MMJhrQlLAxiKsAugd81nIGskItBaLITUeqOIr93Rz66SN 2foLRJ5rFWsrueyA8ZESj+xNcI/O0EgdoirPdd3Zk37oh/9tPrvDw8sAUssVqzhL u5xUxzV6r7YgENy2RfRzOTTa03obmdtDZM+NX5vfhTPPRPvC/pND/mz8v5oRw7q7 4BNWF3W+rURSfW2tZSDvmNcu03SN2wn5xMBz/nJg7+NVRoxEWMqOoYlsnkUWDhoU EHEPozwsw89CUPBkxnHzQ== ARC-Authentication-Results: i=1; mx2.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx2.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164936AbeCBEDs (ORCPT ); Thu, 1 Mar 2018 23:03:48 -0500 Received: from mga06.intel.com ([134.134.136.31]:54060 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164868AbeCBEDp (ORCPT ); Thu, 1 Mar 2018 23:03:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="38656244" Subject: [PATCH v5 12/12] vfio: disable filesystem-dax page pinning From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Alex Williamson , Michal Hocko , Christoph Hellwig , kvm@vger.kernel.org, stable@vger.kernel.org, Haozhong Zhang , Haozhong Zhang , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:39 -0800 Message-ID: <151996287917.28483.16157329534570989926.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Filesystem-DAX is incompatible with 'longterm' page pinning. Without page cache indirection a DAX mapping maps filesystem blocks directly. This means that the filesystem must not modify a file's block map while any page in a mapping is pinned. In order to prevent the situation of userspace holding of filesystem operations indefinitely, disallow 'longterm' Filesystem-DAX mappings. RDMA has the same conflict and the plan there is to add a 'with lease' mechanism to allow the kernel to notify userspace that the mapping is being torn down for block-map maintenance. Perhaps something similar can be put in place for vfio. Note that xfs and ext4 still report: "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" ...at mount time, and resolving the dax-dma-vs-truncate problem is one of the last hurdles to remove that designation. Acked-by: Alex Williamson Cc: Michal Hocko Cc: Christoph Hellwig Cc: kvm@vger.kernel.org Cc: Reported-by: Haozhong Zhang Tested-by: Haozhong Zhang Fixes: d475c6346a38 ("dax,ext2: replace XIP read and write with DAX I/O") Signed-off-by: Dan Williams --- drivers/vfio/vfio_iommu_type1.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index e30e29ae4819..45657e2b1ff7 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, { struct page *page[1]; struct vm_area_struct *vma; + struct vm_area_struct *vmas[1]; int ret; if (mm == current->mm) { - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), - page); + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), + page, vmas); } else { unsigned int flags = 0; @@ -351,7 +352,18 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, down_read(&mm->mmap_sem); ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, - NULL, NULL); + vmas, NULL); + /* + * The lifetime of a vaddr_get_pfn() page pin is + * userspace-controlled. In the fs-dax case this could + * lead to indefinite stalls in filesystem operations. + * Disallow attempts to pin fs-dax pages via this + * interface. + */ + if (ret > 0 && vma_is_fsdax(vmas[0])) { + ret = -EOPNOTSUPP; + put_page(page[0]); + } up_read(&mm->mmap_sem); } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-441027-1519963426-6-6845323425006523341 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.249, ME_NOAUTH 0.01, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES roensk.us-ascii, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='CN', FromHeader='com', MailFrom='org' X-Spam-charsets: plain='utf-8' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1519963426; b=IiN/H27tzN+jGyXGx5wJjBCFjXiUk4/YWvQaxKipKlCYvB6 hwk8jJcHrtRsAWOvLdOPnARFstp3P7Nxk/seLZmIyfRA0pLWSXBnTUC6Or90ba78 NbGmMVoS9jOzeCLyC/lcJAOLGU/tRDoxcxNcKNE8UKBuABMu9bZK2F6CJVIfVu7P UnbmnpfKIvsb5y1pXOgzLbhQOY0cTSc0b6jP+Jp5/VFrzil9uCSzDsjrZpcSlXYi mTlui0llt54vXZkJmq5+Yk26CHB7LGqT2C0pmdpYBN0wyLDJOIwmUSnpfrfgsnns ESl+1IgXUkboymqXyALA7op64D/pk4Le0NgLAnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=subject:from:to:cc:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:list-id; s=arctest; t= 1519963426; bh=/1nntOixSjJqsq6Bne4BEbkJKNtooycqZokXgvYb64o=; b=l O/abu0T/cs7AkE9UZcCxXl7TB0RXnpiFnpJ6ML1PGO/IBlgUpxuiqAX4lXoXtGF/ QZEGuPM+OKuU3uOM4yRhFGCNjln00Ziax3NDkKlUmgHZWEmo1PiHcB1lEjZVWrVV 0NtD3szW4KlcUXIYtQ3RlDw3oAOdxWZm3wETLMlqBnDPIdsmnPP8bXsJPdaiVA+r 5ULS0K27aCOpPwy3bxhXyToF7uPZfex5j+fTfmSaKoUEo0kc0tOaLl4N64baRjpm oTprCuCAQ/nWFj0jaiBCa0woNb7wkepICF6pCrSwoBugFLkHFchiXKrIExHK51no Q8xmoK6qQLUiVbOoEgQgA== ARC-Authentication-Results: i=1; mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Authentication-Results: mx3.messagingengine.com; arc=none (no signatures found); dkim=none (no signatures found); dmarc=none (p=none,has-list-id=yes,d=none) header.from=intel.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=intel.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1164896AbeCBEDi (ORCPT ); Thu, 1 Mar 2018 23:03:38 -0500 Received: from mga09.intel.com ([134.134.136.24]:10237 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164868AbeCBEDf (ORCPT ); Thu, 1 Mar 2018 23:03:35 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,409,1515484800"; d="scan'208";a="34878637" Subject: [PATCH v5 10/12] fs, dax: kill IS_DAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:28 -0800 Message-ID: <151996286805.28483.12933227722062678008.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: In preparation for fixing the broken definition of S_DAX in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, convert all the remaining IS_DAX() usages to use explicit tests for FSDAX. 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 --- fs/iomap.c | 2 +- include/linux/dax.h | 2 +- include/linux/fs.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index afd163586aa0..fe379d8949fd 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -377,7 +377,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, offset = pos & (PAGE_SIZE - 1); /* Within page */ bytes = min_t(loff_t, PAGE_SIZE - offset, count); - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) status = iomap_dax_zero(pos, offset, bytes, iomap); else status = iomap_zero(inode, pos, offset, bytes, iomap); diff --git a/include/linux/dax.h b/include/linux/dax.h index 47edbce4fc52..ce520e932adc 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -124,7 +124,7 @@ static inline ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, static inline bool dax_mapping(struct address_space *mapping) { - return mapping->host && IS_DAX(mapping->host); + return mapping->host && IS_FSDAX(mapping->host); } struct writeback_control; diff --git a/include/linux/fs.h b/include/linux/fs.h index 33e859e7d100..b2b2e15d227b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1903,7 +1903,6 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_IMA(inode) ((inode)->i_flags & S_IMA) #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) -#define IS_DAX(inode) ((inode)->i_flags & S_DAX) #define IS_ENCRYPTED(inode) ((inode)->i_flags & S_ENCRYPTED) #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ @@ -3203,7 +3202,7 @@ extern int file_update_time(struct file *file); static inline bool io_is_direct(struct file *filp) { - return (filp->f_flags & O_DIRECT) || IS_DAX(filp->f_mapping->host); + return (filp->f_flags & O_DIRECT) || IS_FSDAX(filp->f_mapping->host); } static inline bool vma_is_dax(struct vm_area_struct *vma) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 11/12] dax: fix S_DAX definition From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Christoph Hellwig , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:34 -0800 Message-ID: <151996287403.28483.8962319815764432894.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: Make sure S_DAX is defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. Otherwise vma_is_dax() may incorrectly return false in the Device-DAX case. Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index b2b2e15d227b..1242511b1c46 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1859,7 +1859,7 @@ struct super_operations { #define S_IMA 1024 /* Inode has an associated IMA struct */ #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ #define S_NOSEC 4096 /* no suid or xattr security attributes */ -#ifdef CONFIG_FS_DAX +#if IS_ENABLED(CONFIG_FS_DAX) || IS_ENABLED(CONFIG_DEV_DAX) #define S_DAX 8192 /* Direct Access, avoiding the page cache */ #else #define S_DAX 0 /* Make all the DAX code disappear */ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 12/12] vfio: disable filesystem-dax page pinning From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Alex Williamson , Michal Hocko , Christoph Hellwig , kvm@vger.kernel.org, stable@vger.kernel.org, Haozhong Zhang , Haozhong Zhang , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:39 -0800 Message-ID: <151996287917.28483.16157329534570989926.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: Filesystem-DAX is incompatible with 'longterm' page pinning. Without page cache indirection a DAX mapping maps filesystem blocks directly. This means that the filesystem must not modify a file's block map while any page in a mapping is pinned. In order to prevent the situation of userspace holding of filesystem operations indefinitely, disallow 'longterm' Filesystem-DAX mappings. RDMA has the same conflict and the plan there is to add a 'with lease' mechanism to allow the kernel to notify userspace that the mapping is being torn down for block-map maintenance. Perhaps something similar can be put in place for vfio. Note that xfs and ext4 still report: "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" ...at mount time, and resolving the dax-dma-vs-truncate problem is one of the last hurdles to remove that designation. Acked-by: Alex Williamson Cc: Michal Hocko Cc: Christoph Hellwig Cc: kvm@vger.kernel.org Cc: Reported-by: Haozhong Zhang Tested-by: Haozhong Zhang Fixes: d475c6346a38 ("dax,ext2: replace XIP read and write with DAX I/O") Signed-off-by: Dan Williams --- drivers/vfio/vfio_iommu_type1.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index e30e29ae4819..45657e2b1ff7 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, { struct page *page[1]; struct vm_area_struct *vma; + struct vm_area_struct *vmas[1]; int ret; if (mm == current->mm) { - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), - page); + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), + page, vmas); } else { unsigned int flags = 0; @@ -351,7 +352,18 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, down_read(&mm->mmap_sem); ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, - NULL, NULL); + vmas, NULL); + /* + * The lifetime of a vaddr_get_pfn() page pin is + * userspace-controlled. In the fs-dax case this could + * lead to indefinite stalls in filesystem operations. + * Disallow attempts to pin fs-dax pages via this + * interface. + */ + if (ret > 0 && vma_is_fsdax(vmas[0])) { + ret = -EOPNOTSUPP; + put_page(page[0]); + } up_read(&mm->mmap_sem); } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> <20180302225734.GE31240@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 18:19:16 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes To: Christoph Hellwig Cc: linux-nvdimm , linux-xfs , "Darrick J. Wong" , KVM list , Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable , Jan Kara , Michal Hocko , Andreas Dilger , Ross Zwisler , Matthew Wilcox , linux-fsdevel , Alex Williamson , "Theodore Ts'o" , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: On Fri, Mar 2, 2018 at 3:49 PM, Dan Williams wrote: > On Fri, Mar 2, 2018 at 2:57 PM, Christoph Hellwig wrote: >> On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: >>> They are indeed a hodge-podge. The problem is that the current >>> IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with >>> IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks >>> you propose for the next merge window. >> >> The only thing broken about IS_DAX are the code elimination games >> based on the CONFIG_* flags. Remove those and just add proper stubs >> for the dax routines and everything will be fine for now until we can >> kill that inode flag. >> >> IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't >> helping anyone. > > Ok, I'll take another shot at something suitable for 4.16, but without > these new helpers... I'll drop patches 2-11 for now, and just get the high priority fixes in for the next rc. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <20180302225734.GE31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> <20180302225734.GE31240@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 15:49:45 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes To: Christoph Hellwig Cc: linux-nvdimm , linux-xfs , "Darrick J. Wong" , KVM list , Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable , Jan Kara , Michal Hocko , Andreas Dilger , Ross Zwisler , Matthew Wilcox , linux-fsdevel , Alex Williamson , "Theodore Ts'o" , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: On Fri, Mar 2, 2018 at 2:57 PM, Christoph Hellwig wrote: > On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: >> They are indeed a hodge-podge. The problem is that the current >> IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with >> IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks >> you propose for the next merge window. > > The only thing broken about IS_DAX are the code elimination games > based on the CONFIG_* flags. Remove those and just add proper stubs > for the dax routines and everything will be fine for now until we can > kill that inode flag. > > IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't > helping anyone. Ok, I'll take another shot at something suitable for 4.16, but without these new helpers... -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 2 Mar 2018 23:57:34 +0100 From: Christoph Hellwig To: Dan Williams Cc: Christoph Hellwig , linux-nvdimm , linux-xfs , "Darrick J. Wong" , KVM list , Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable , Jan Kara , Michal Hocko , Andreas Dilger , Ross Zwisler , Matthew Wilcox , linux-fsdevel , Alex Williamson , Theodore Ts'o , Linux MM , Linux Kernel Mailing List Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Message-ID: <20180302225734.GE31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: > They are indeed a hodge-podge. The problem is that the current > IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with > IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks > you propose for the next merge window. The only thing broken about IS_DAX are the code elimination games based on the CONFIG_* flags. Remove those and just add proper stubs for the dax routines and everything will be fine for now until we can kill that inode flag. IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't helping anyone. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <20180302221020.GA30722@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> From: Dan Williams Date: Fri, 2 Mar 2018 14:21:40 -0800 Message-ID: Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes To: Christoph Hellwig Cc: linux-nvdimm , linux-xfs , "Darrick J. Wong" , KVM list , Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable , Jan Kara , Michal Hocko , Andreas Dilger , Ross Zwisler , Matthew Wilcox , linux-fsdevel , Alex Williamson , "Theodore Ts'o" , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: On Fri, Mar 2, 2018 at 2:10 PM, Christoph Hellwig wrote: > I really don't like these IS_DEVDAX and IS_FSDAX flags. We should > stop pretending DAX is a global per-inode choice and get rid of these > magic flags entirely. So please convert the instances inside the > various file systems to checking the file system mount options instead. > > For the core ones we'll need to differentiate: > > - the checks in generic_file_read_iter and __generic_file_write_iter > seem to not be needed anymore at all since we stopped abusing the > direct I/O code for DAX, so they should probably be removed. > - io_is_direct is a weird check and should probably just go away, > as there is not point in always setting IOCB_DIRECT for DAX I/O > - fadvise should either become a file op, or a flag on the inode that > fadvice is supported instead of the nasty noop_backing_dev_info or > DAX check. > - Ditto for madvise > - vma_is_dax should probably be replaced with a VMA flag. > - thp_get_unmapped_area I don't really understand why we have a dax > check there. > - dax_mapping will be much harder to sort out. > > But all these DAX flags certainly look like a major hodge podge to me. They are indeed a hodge-podge. The problem is that the current IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks you propose for the next merge window. Acceptable? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes From: Dan Williams To: linux-nvdimm@lists.01.org Cc: linux-xfs@vger.kernel.org, "Darrick J. Wong" , kvm@vger.kernel.org, Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable@vger.kernel.org, Jan Kara , Michal Hocko , Andreas Dilger , Christoph Hellwig , Ross Zwisler , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Alex Williamson , Theodore Ts'o , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:33 -0800 Message-ID: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: Changes since v4 [1]: * Fix the changelog of "dax: introduce IS_DEVDAX() and IS_FSDAX()" to better clarify the need for new helpers (Jan) * Replace dax_sem_is_locked() with dax_sem_assert_held() (Jan) * Use file_inode() in vma_is_dax() (Jan) * Resend the full series to linux-xfs@ (Dave) * Collect Jan's Reviewed-by [1]: https://lists.01.org/pipermail/linux-nvdimm/2018-February/014271.html --- The vfio interface, like RDMA, wants to setup long term (indefinite) pins of the pages backing an address range so that a guest or userspace driver can perform DMA to the with physical address. Given that this pinning may lead to filesystem operations deadlocking in the filesystem-dax case, the pinning request needs to be rejected. The longer term fix for vfio, RDMA, and any other long term pin user, is to provide a 'pin with lease' mechanism. Similar to the leases that are hold for pNFS RDMA layouts, this userspace lease gives the kernel a way to notify userspace that the block layout of the file is changing and the kernel is revoking access to pinned pages. Related to this change is the discovery that vma_is_fsdax() was causing device-dax inode detection to fail. That lead to series of fixes and cleanups to make sure that S_DAX is defined correctly in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. --- Dan Williams (12): dax: fix vma_is_fsdax() helper dax: introduce IS_DEVDAX() and IS_FSDAX() ext2, dax: finish implementing dax_sem helpers ext2, dax: define ext2_dax_*() infrastructure in all cases ext4, dax: define ext4_dax_*() infrastructure in all cases ext2, dax: replace IS_DAX() with IS_FSDAX() ext4, dax: replace IS_DAX() with IS_FSDAX() xfs, dax: replace IS_DAX() with IS_FSDAX() mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() fs, dax: kill IS_DAX() dax: fix S_DAX definition vfio: disable filesystem-dax page pinning drivers/vfio/vfio_iommu_type1.c | 18 ++++++++++++++-- fs/ext2/ext2.h | 6 +++++ fs/ext2/file.c | 19 +++++------------ fs/ext2/inode.c | 10 ++++----- fs/ext4/file.c | 18 +++++----------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- fs/iomap.c | 2 +- fs/xfs/xfs_file.c | 14 ++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++-- fs/xfs/xfs_reflink.c | 2 +- include/linux/dax.h | 12 ++++++++--- include/linux/fs.h | 43 ++++++++++++++++++++++++++++----------- mm/fadvise.c | 3 ++- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 +++- mm/madvise.c | 3 ++- 19 files changed, 102 insertions(+), 74 deletions(-) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: 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; } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 2 Mar 2018 23:53:16 +0100 From: Christoph Hellwig To: Dan Williams Cc: linux-nvdimm@lists.01.org, Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() Message-ID: <20180302225316.GC31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> Sender: owner-linux-mm@kvack.org List-ID: > +static inline bool IS_DEVDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_DEV_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (!S_ISCHR(inode->i_mode)) > + return false; > + return true; > +} > + > +static inline bool IS_FSDAX(struct inode *inode) > +{ > + if (!IS_ENABLED(CONFIG_FS_DAX)) > + return false; > + if ((inode->i_flags & S_DAX) == 0) > + return false; > + if (S_ISCHR(inode->i_mode)) > + return false; > + return true; Encoding the is char device or not thing here is just nasty. I think this is going entirely in the wrong direction. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v6] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , Jan Kara , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Date: Fri, 02 Mar 2018 11:06:36 -0800 Message-ID: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- Changes since v5: * add comments to clarify the S_ISCHR() checks (Darrick) include/linux/fs.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..751975b8b29b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,30 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* regular files with S_DAX are filesystem-dax instances */ + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* character devices with S_DAX are device-dax instances */ + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <20180302174530.GV19312@magnolia> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996282448.28483.10415125852182473579.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302174530.GV19312@magnolia> From: Dan Williams Date: Fri, 2 Mar 2018 10:37:40 -0800 Message-ID: Subject: Re: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() To: "Darrick J. Wong" Cc: linux-nvdimm , "Theodore Ts'o" , Andreas Dilger , Alexander Viro , linux-xfs , Matthew Wilcox , Ross Zwisler , stable , Jan Kara , Christoph Hellwig , linux-fsdevel , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: On Fri, Mar 2, 2018 at 9:45 AM, Darrick J. Wong wrote: > On Thu, Mar 01, 2018 at 07:53:44PM -0800, Dan Williams wrote: >> The current IS_DAX() helper that checks if a file is in DAX mode serves >> two purposes. It is a control flow branch condition for DAX vs >> non-DAX paths and it is a mechanism to perform dead code elimination. The >> dead code elimination is required in the CONFIG_FS_DAX=n case since >> there are symbols in fs/dax.c that will be elided. While the >> dead code elimination can be addressed with nop stubs for the fs/dax.c >> symbols that does not address the need for a DAX control flow helper >> where fs/dax.c symbols are not involved. >> >> Moreover, the control flow changes, in some cases, need to be cognizant >> of whether the DAX file is a typical file or a Device-DAX special file. >> Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the >> file-type control flow and dead-code elimination use cases. IS_DAX() >> will be deleted after all sites are converted to use the file-type >> specific helper. >> >> Note, this change is also a pre-requisite for fixing the definition of >> the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. >> The flag needs to be defined, non-zero, if either DAX facility is >> enabled. >> >> Cc: "Theodore Ts'o" >> Cc: Andreas Dilger >> Cc: Alexander Viro >> Cc: "Darrick J. Wong" >> Cc: linux-xfs@vger.kernel.org >> Cc: Matthew Wilcox >> Cc: Ross Zwisler >> Cc: >> Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") >> Reported-by: Jan Kara >> Reviewed-by: Jan Kara >> Signed-off-by: Dan Williams >> --- >> include/linux/fs.h | 22 ++++++++++++++++++++++ >> 1 file changed, 22 insertions(+) >> >> diff --git a/include/linux/fs.h b/include/linux/fs.h >> index 79c413985305..bd0c46880572 100644 >> --- a/include/linux/fs.h >> +++ b/include/linux/fs.h >> @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags >> #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ >> (inode)->i_rdev == WHITEOUT_DEV) >> >> +static inline bool IS_DEVDAX(struct inode *inode) >> +{ >> + if (!IS_ENABLED(CONFIG_DEV_DAX)) >> + return false; >> + if ((inode->i_flags & S_DAX) == 0) >> + return false; >> + if (!S_ISCHR(inode->i_mode)) >> + return false; >> + return true; >> +} >> + >> +static inline bool IS_FSDAX(struct inode *inode) >> +{ >> + if (!IS_ENABLED(CONFIG_FS_DAX)) >> + return false; > > I echo Jan's complaint from the last round that the dead code > elimination here is subtle, as compared to: > > #if IS_ENABLED(CONFIG_FS_DAX) > static inline bool IS_FSDAX(struct inode *inode) { ... } > #else > # define IS_FSDAX(inode) (false) > #endif > > But I guess even with that we're relying on dead code elimination higher > up in the call stack... If IS_FSDAX() was only a dead-code elimination mechanism rather than a runtime branch condition then I agree. Otherwise I think IS_ENABLED() is suitable and not subtle, especially when used in a header file. >> + if ((inode->i_flags & S_DAX) == 0) >> + return false; >> + if (S_ISCHR(inode->i_mode)) >> + return false; > > I'm curious, do we have character devices with S_DAX set? Yes, Device-DAX, see: ab68f2622136 /dev/dax, pmem: direct access to persistent memory > I /think/ we're expecting that only block/char devices and files will > ever have S_DAX set, so IS_FSDAX is only true for block devices and > files. Right? We had S_DAX on block-devices for a short while, but deleted it and went with the Device-DAX interface instead. So it's only regular files and /dev/daxX.Y nodes these days. > (A comment here about why S_ISCHR->false here would be helpful.) Ok. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:44 -0800 Message-ID: <151996282448.28483.10415125852182473579.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..bd0c46880572 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 2 Mar 2018 23:52:10 +0100 From: Christoph Hellwig To: Dan Williams Cc: linux-nvdimm@lists.01.org, stable@vger.kernel.org, Gerd Rausch , Jane Chu , Haozhong Zhang , Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 01/12] dax: fix vma_is_fsdax() helper Message-ID: <20180302225210.GB31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <151996281881.28483.2616406435517031167.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <151996281881.28483.2616406435517031167.stgit@dwillia2-desk3.amr.corp.intel.com> Sender: owner-linux-mm@kvack.org List-ID: Looks good, Reviewed-by: Christoph Hellwig -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 01/12] dax: fix vma_is_fsdax() helper From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Gerd Rausch , Jane Chu , Haozhong Zhang , Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:38 -0800 Message-ID: <151996281881.28483.2616406435517031167.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: Gerd reports that ->i_mode may contain other bits besides S_IFCHR. Use S_ISCHR() instead. Otherwise, get_user_pages_longterm() may fail on device-dax instances when those are meant to be explicitly allowed. Fixes: 2bb6d2837083 ("mm: introduce get_user_pages_longterm") Cc: Reported-by: Gerd Rausch Acked-by: Jane Chu Reported-by: Haozhong Zhang Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 2a815560fda0..79c413985305 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3198,7 +3198,7 @@ static inline bool vma_is_fsdax(struct vm_area_struct *vma) if (!vma_is_dax(vma)) return false; inode = file_inode(vma->vm_file); - if (inode->i_mode == S_IFCHR) + if (S_ISCHR(inode->i_mode)) return false; /* device-dax */ return true; } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 10/12] fs, dax: kill IS_DAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:28 -0800 Message-ID: <151996286805.28483.12933227722062678008.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: In preparation for fixing the broken definition of S_DAX in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, convert all the remaining IS_DAX() usages to use explicit tests for FSDAX. 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 --- fs/iomap.c | 2 +- include/linux/dax.h | 2 +- include/linux/fs.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index afd163586aa0..fe379d8949fd 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -377,7 +377,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, offset = pos & (PAGE_SIZE - 1); /* Within page */ bytes = min_t(loff_t, PAGE_SIZE - offset, count); - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) status = iomap_dax_zero(pos, offset, bytes, iomap); else status = iomap_zero(inode, pos, offset, bytes, iomap); diff --git a/include/linux/dax.h b/include/linux/dax.h index 47edbce4fc52..ce520e932adc 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -124,7 +124,7 @@ static inline ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, static inline bool dax_mapping(struct address_space *mapping) { - return mapping->host && IS_DAX(mapping->host); + return mapping->host && IS_FSDAX(mapping->host); } struct writeback_control; diff --git a/include/linux/fs.h b/include/linux/fs.h index 33e859e7d100..b2b2e15d227b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1903,7 +1903,6 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_IMA(inode) ((inode)->i_flags & S_IMA) #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) -#define IS_DAX(inode) ((inode)->i_flags & S_DAX) #define IS_ENCRYPTED(inode) ((inode)->i_flags & S_ENCRYPTED) #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ @@ -3203,7 +3202,7 @@ extern int file_update_time(struct file *file); static inline bool io_is_direct(struct file *filp) { - return (filp->f_flags & O_DIRECT) || IS_DAX(filp->f_mapping->host); + return (filp->f_flags & O_DIRECT) || IS_FSDAX(filp->f_mapping->host); } static inline bool vma_is_dax(struct vm_area_struct *vma) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 05/12] ext4, dax: define ext4_dax_*() infrastructure in all cases From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:00 -0800 Message-ID: <151996284080.28483.11296105582801541424.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: In preparation for fixing S_DAX to be defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, move the definition of these routines outside of the "#ifdef CONFIG_FS_DAX" guard. This is also a coding-style fix to move all ifdef handling to header files rather than in the source. The compiler will still be able to determine that all the related code can be discarded in the CONFIG_FS_DAX=n case. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext4/file.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index fb6f023622fe..51854e7608f0 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -34,7 +34,6 @@ #include "xattr.h" #include "acl.h" -#ifdef CONFIG_FS_DAX static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct inode *inode = file_inode(iocb->ki_filp); @@ -60,7 +59,6 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) file_accessed(iocb->ki_filp); return ret; } -#endif static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { @@ -70,10 +68,8 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (!iov_iter_count(to)) return 0; /* skip atime */ -#ifdef CONFIG_FS_DAX if (IS_DAX(file_inode(iocb->ki_filp))) return ext4_dax_read_iter(iocb, to); -#endif return generic_file_read_iter(iocb, to); } @@ -179,7 +175,6 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from) return iov_iter_count(from); } -#ifdef CONFIG_FS_DAX static ssize_t ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) { @@ -208,7 +203,6 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) ret = generic_write_sync(iocb, ret); return ret; } -#endif static ssize_t ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 04/12] ext2, dax: define ext2_dax_*() infrastructure in all cases From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:55 -0800 Message-ID: <151996283559.28483.2221179891176741624.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: In preparation for fixing S_DAX to be defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case, move the definition of these routines outside of the "#ifdef CONFIG_FS_DAX" guard. This is also a coding-style fix to move all ifdef handling to header files rather than in the source. The compiler will still be able to determine that all the related code can be discarded in the CONFIG_FS_DAX=n case. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext2/file.c | 8 -------- include/linux/dax.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 1c7ea1bcddde..5ac98d074323 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -29,7 +29,6 @@ #include "xattr.h" #include "acl.h" -#ifdef CONFIG_FS_DAX static ssize_t ext2_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct inode *inode = iocb->ki_filp->f_mapping->host; @@ -128,9 +127,6 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) vma->vm_flags |= VM_MIXEDMAP; return 0; } -#else -#define ext2_file_mmap generic_file_mmap -#endif /* * Called when filp is released. This happens when all file descriptors @@ -162,19 +158,15 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync) static ssize_t ext2_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { -#ifdef CONFIG_FS_DAX if (IS_DAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_read_iter(iocb, to); -#endif return generic_file_read_iter(iocb, to); } static ssize_t ext2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { -#ifdef CONFIG_FS_DAX if (IS_DAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_write_iter(iocb, from); -#endif return generic_file_write_iter(iocb, from); } diff --git a/include/linux/dax.h b/include/linux/dax.h index 0185ecdae135..47edbce4fc52 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -93,8 +93,6 @@ void dax_flush(struct dax_device *dax_dev, void *addr, size_t size); void dax_write_cache(struct dax_device *dax_dev, bool wc); bool dax_write_cache_enabled(struct dax_device *dax_dev); -ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, - const struct iomap_ops *ops); int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size, pfn_t *pfnp, int *errp, const struct iomap_ops *ops); int dax_finish_sync_fault(struct vm_fault *vmf, enum page_entry_size pe_size, @@ -107,6 +105,8 @@ int dax_invalidate_mapping_entry_sync(struct address_space *mapping, int __dax_zero_page_range(struct block_device *bdev, struct dax_device *dax_dev, sector_t sector, unsigned int offset, unsigned int length); +ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops); #else static inline int __dax_zero_page_range(struct block_device *bdev, struct dax_device *dax_dev, sector_t sector, @@ -114,6 +114,12 @@ static inline int __dax_zero_page_range(struct block_device *bdev, { return -ENXIO; } + +static inline ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, + const struct iomap_ops *ops) +{ + return -ENXIO; +} #endif static inline bool dax_mapping(struct address_space *mapping) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 07/12] ext4, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:11 -0800 Message-ID: <151996285107.28483.10237358640480864296.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: 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 FSDAX since DAX is ambiguous. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro 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 --- fs/ext4/file.c | 12 +++++------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 51854e7608f0..561ea843b458 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -48,7 +48,7 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) * Recheck under inode lock - at this point we are sure it cannot * change anymore */ - if (!IS_DAX(inode)) { + if (!IS_FSDAX(inode)) { inode_unlock_shared(inode); /* Fallback to buffered IO in case we cannot support DAX */ return generic_file_read_iter(iocb, to); @@ -68,7 +68,7 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) if (!iov_iter_count(to)) return 0; /* skip atime */ - if (IS_DAX(file_inode(iocb->ki_filp))) + if (IS_FSDAX(file_inode(iocb->ki_filp))) return ext4_dax_read_iter(iocb, to); return generic_file_read_iter(iocb, to); } @@ -216,10 +216,8 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; -#ifdef CONFIG_FS_DAX - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) return ext4_dax_write_iter(iocb, from); -#endif if (!o_direct && (iocb->ki_flags & IOCB_NOWAIT)) return -EOPNOTSUPP; @@ -361,11 +359,11 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) * We don't support synchronous mappings for non-DAX files. At least * until someone comes with a sensible use case. */ - if (!IS_DAX(file_inode(file)) && (vma->vm_flags & VM_SYNC)) + if (!IS_FSDAX(file_inode(file)) && (vma->vm_flags & VM_SYNC)) return -EOPNOTSUPP; file_accessed(file); - if (IS_DAX(file_inode(file))) { + if (IS_FSDAX(file_inode(file))) { vma->vm_ops = &ext4_dax_vm_ops; vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; } else { diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c94780075b04..1879b33aa391 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3858,7 +3858,7 @@ static ssize_t ext4_direct_IO(struct kiocb *iocb, struct iov_iter *iter) return 0; /* DAX uses iomap path now */ - if (WARN_ON_ONCE(IS_DAX(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode))) return 0; trace_ext4_direct_IO_enter(inode, offset, count, iov_iter_rw(iter)); @@ -4076,7 +4076,7 @@ static int ext4_block_zero_page_range(handle_t *handle, if (length > max || length < 0) length = max; - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { return iomap_zero_range(inode, from, length, NULL, &ext4_iomap_ops); } diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 7e99ad02f1ba..040fc6570ddb 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -790,7 +790,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) "Online defrag not supported with bigalloc"); err = -EOPNOTSUPP; goto mext_out; - } else if (IS_DAX(inode)) { + } else if (IS_FSDAX(inode)) { ext4_msg(sb, KERN_ERR, "Online defrag not supported with DAX"); err = -EOPNOTSUPP; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 39bf464c35f1..933e12940181 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1161,7 +1161,7 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len, if (inode->i_ino == EXT4_ROOT_INO) return -EPERM; - if (WARN_ON_ONCE(IS_DAX(inode) && i_size_read(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode) && i_size_read(inode))) return -EINVAL; res = ext4_convert_inline_data(inode); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 06/12] ext2, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:06 -0800 Message-ID: <151996284593.28483.4922911524438696817.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: 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 FSDAX since DAX is ambiguous. 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 --- fs/ext2/file.c | 6 +++--- fs/ext2/inode.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 5ac98d074323..702a36df6c01 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -119,7 +119,7 @@ static const struct vm_operations_struct ext2_dax_vm_ops = { static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) { - if (!IS_DAX(file_inode(file))) + if (!IS_FSDAX(file_inode(file))) return generic_file_mmap(file, vma); file_accessed(file); @@ -158,14 +158,14 @@ int ext2_fsync(struct file *file, loff_t start, loff_t end, int datasync) static ssize_t ext2_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { - if (IS_DAX(iocb->ki_filp->f_mapping->host)) + if (IS_FSDAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_read_iter(iocb, to); return generic_file_read_iter(iocb, to); } static ssize_t ext2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) { - if (IS_DAX(iocb->ki_filp->f_mapping->host)) + if (IS_FSDAX(iocb->ki_filp->f_mapping->host)) return ext2_dax_write_iter(iocb, from); return generic_file_write_iter(iocb, from); } diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 4783db0e4873..5352207da9d5 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -733,7 +733,7 @@ static int ext2_get_blocks(struct inode *inode, goto cleanup; } - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { /* * We must unmap blocks before zeroing so that writeback cannot * overwrite zeros with stale data from block device page cache. @@ -940,7 +940,7 @@ ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) loff_t offset = iocb->ki_pos; ssize_t ret; - if (WARN_ON_ONCE(IS_DAX(inode))) + if (WARN_ON_ONCE(IS_FSDAX(inode))) return -EIO; ret = blockdev_direct_IO(iocb, inode, iter, ext2_get_block); @@ -1294,7 +1294,7 @@ static int ext2_setsize(struct inode *inode, loff_t newsize) inode_dio_wait(inode); - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { error = iomap_zero_range(inode, newsize, PAGE_ALIGN(newsize) - newsize, NULL, &ext2_iomap_ops); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 03/12] ext2, dax: finish implementing dax_sem helpers From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.org, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:53:50 -0800 Message-ID: <151996283005.28483.12905745385121745420.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: dax_sem_{up,down}_write_sem() allow the ext2 dax semaphore to be compiled out in the CONFIG_FS_DAX=n case. However there are still some open coded uses of the semaphore. Add dax_sem_{up_read,down_read}() and dax_sem_assert_held() helpers. Use them to convert all open-coded usages of the semaphore to the helpers. Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- fs/ext2/ext2.h | 6 ++++++ fs/ext2/file.c | 5 ++--- fs/ext2/inode.c | 4 +--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 032295e1d386..203c31dfe549 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h @@ -711,9 +711,15 @@ struct ext2_inode_info { #ifdef CONFIG_FS_DAX #define dax_sem_down_write(ext2_inode) down_write(&(ext2_inode)->dax_sem) #define dax_sem_up_write(ext2_inode) up_write(&(ext2_inode)->dax_sem) +#define dax_sem_assert_held(ei) WARN_ON(!rwsem_is_locked(&(ei)->dax_sem)) +#define dax_sem_down_read(ext2_inode) down_read(&(ext2_inode)->dax_sem) +#define dax_sem_up_read(ext2_inode) up_read(&(ext2_inode)->dax_sem) #else #define dax_sem_down_write(ext2_inode) #define dax_sem_up_write(ext2_inode) +#define dax_sem_assert_held(ext2_inode) +#define dax_sem_down_read(ext2_inode) +#define dax_sem_up_read(ext2_inode) #endif /* diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 09640220fda8..1c7ea1bcddde 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -91,18 +91,17 @@ static ssize_t ext2_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) static int ext2_dax_fault(struct vm_fault *vmf) { struct inode *inode = file_inode(vmf->vma->vm_file); - struct ext2_inode_info *ei = EXT2_I(inode); int ret; if (vmf->flags & FAULT_FLAG_WRITE) { sb_start_pagefault(inode->i_sb); file_update_time(vmf->vma->vm_file); } - down_read(&ei->dax_sem); + dax_sem_down_read(EXT2_I(inode)); ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops); - up_read(&ei->dax_sem); + dax_sem_up_read(EXT2_I(inode)); if (vmf->flags & FAULT_FLAG_WRITE) sb_end_pagefault(inode->i_sb); return ret; diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 9b2ac55ac34f..4783db0e4873 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1187,9 +1187,7 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset) blocksize = inode->i_sb->s_blocksize; iblock = (offset + blocksize-1) >> EXT2_BLOCK_SIZE_BITS(inode->i_sb); -#ifdef CONFIG_FS_DAX - WARN_ON(!rwsem_is_locked(&ei->dax_sem)); -#endif + dax_sem_assert_held(ei); n = ext2_block_to_path(inode, iblock, offsets, NULL); if (n == 0) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: [PATCH v5 08/12] xfs, dax: replace IS_DAX() with IS_FSDAX() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 01 Mar 2018 19:54:16 -0800 Message-ID: <151996285683.28483.13394624369523668388.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: 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 FSDAX since DAX is ambiguous. Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org 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 --- fs/xfs/xfs_file.c | 14 +++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++--- fs/xfs/xfs_reflink.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 9ea08326f876..46a098b90fd0 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -288,7 +288,7 @@ xfs_file_read_iter( if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) ret = xfs_file_dax_read(iocb, to); else if (iocb->ki_flags & IOCB_DIRECT) ret = xfs_file_dio_aio_read(iocb, to); @@ -726,7 +726,7 @@ xfs_file_write_iter( if (XFS_FORCED_SHUTDOWN(ip->i_mount)) return -EIO; - if (IS_DAX(inode)) + if (IS_FSDAX(inode)) ret = xfs_file_dax_write(iocb, from); else if (iocb->ki_flags & IOCB_DIRECT) { /* @@ -1045,7 +1045,7 @@ __xfs_filemap_fault( } xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED); - if (IS_DAX(inode)) { + if (IS_FSDAX(inode)) { pfn_t pfn; ret = dax_iomap_fault(vmf, pe_size, &pfn, NULL, &xfs_iomap_ops); @@ -1070,7 +1070,7 @@ xfs_filemap_fault( { /* DAX can shortcut the normal fault path on write faults! */ return __xfs_filemap_fault(vmf, PE_SIZE_PTE, - IS_DAX(file_inode(vmf->vma->vm_file)) && + IS_FSDAX(file_inode(vmf->vma->vm_file)) && (vmf->flags & FAULT_FLAG_WRITE)); } @@ -1079,7 +1079,7 @@ xfs_filemap_huge_fault( struct vm_fault *vmf, enum page_entry_size pe_size) { - if (!IS_DAX(file_inode(vmf->vma->vm_file))) + if (!IS_FSDAX(file_inode(vmf->vma->vm_file))) return VM_FAULT_FALLBACK; /* DAX can shortcut the normal fault path on write faults! */ @@ -1124,12 +1124,12 @@ xfs_file_mmap( * We don't support synchronous mappings for non-DAX files. At least * until someone comes with a sensible use case. */ - if (!IS_DAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) + if (!IS_FSDAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) return -EOPNOTSUPP; file_accessed(filp); vma->vm_ops = &xfs_file_vm_ops; - if (IS_DAX(file_inode(filp))) + if (IS_FSDAX(file_inode(filp))) vma->vm_flags |= VM_MIXEDMAP | VM_HUGEPAGE; return 0; } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 89fb1eb80aae..234279ff66ce 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -1108,9 +1108,9 @@ xfs_ioctl_setattr_dax_invalidate( } /* If the DAX state is not changing, we have nothing to do here. */ - if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_DAX(inode)) + if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_FSDAX(inode)) return 0; - if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode)) + if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_FSDAX(inode)) return 0; /* lock, flush and invalidate mapping in preparation for flag change */ diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 66e1edbfb2b2..cf794d429aec 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -241,7 +241,7 @@ xfs_iomap_write_direct( * the reserve block pool for bmbt block allocation if there is no space * left but we need to do unwritten extent conversion. */ - if (IS_DAX(VFS_I(ip))) { + if (IS_FSDAX(VFS_I(ip))) { bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO; if (imap->br_state == XFS_EXT_UNWRITTEN) { tflags |= XFS_TRANS_RESERVE; @@ -952,7 +952,7 @@ static inline bool imap_needs_alloc(struct inode *inode, return !nimaps || imap->br_startblock == HOLESTARTBLOCK || imap->br_startblock == DELAYSTARTBLOCK || - (IS_DAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); + (IS_FSDAX(inode) && imap->br_state == XFS_EXT_UNWRITTEN); } static inline bool need_excl_ilock(struct xfs_inode *ip, unsigned flags) @@ -988,7 +988,7 @@ xfs_file_iomap_begin( return -EIO; if (((flags & (IOMAP_WRITE | IOMAP_DIRECT)) == IOMAP_WRITE) && - !IS_DAX(inode) && !xfs_get_extsz_hint(ip)) { + !IS_FSDAX(inode) && !xfs_get_extsz_hint(ip)) { /* Reserve delalloc blocks for regular writeback. */ return xfs_file_iomap_begin_delay(inode, offset, length, iomap); } diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 270246943a06..a126e00e05e3 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1351,7 +1351,7 @@ xfs_reflink_remap_range( goto out_unlock; /* Don't share DAX file data for now. */ - if (IS_DAX(inode_in) || IS_DAX(inode_out)) + if (IS_FSDAX(inode_in) || IS_FSDAX(inode_out)) goto out_unlock; ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com ([192.55.52.88]:19606 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164868AbeCBEDk (ORCPT ); Thu, 1 Mar 2018 23:03:40 -0500 Subject: [PATCH v5 11/12] dax: fix S_DAX definition From: Dan Williams Date: Thu, 01 Mar 2018 19:54:34 -0800 Message-ID: <151996287403.28483.8962319815764432894.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: linux-nvdimm@lists.01.org Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Christoph Hellwig , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.orglinux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Make sure S_DAX is defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. Otherwise vma_is_dax() may incorrectly return false in the Device-DAX case. Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index b2b2e15d227b..1242511b1c46 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1859,7 +1859,7 @@ struct super_operations { #define S_IMA 1024 /* Inode has an associated IMA struct */ #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ #define S_NOSEC 4096 /* no suid or xattr security attributes */ -#ifdef CONFIG_FS_DAX +#if IS_ENABLED(CONFIG_FS_DAX) || IS_ENABLED(CONFIG_DEV_DAX) #define S_DAX 8192 /* Direct Access, avoiding the page cache */ #else #define S_DAX 0 /* Make all the DAX code disappear */ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com ([134.134.136.31]:54060 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164868AbeCBEDp (ORCPT ); Thu, 1 Mar 2018 23:03:45 -0500 Subject: [PATCH v5 12/12] vfio: disable filesystem-dax page pinning From: Dan Williams Date: Thu, 01 Mar 2018 19:54:39 -0800 Message-ID: <151996287917.28483.16157329534570989926.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: linux-nvdimm@lists.01.org Cc: Alex Williamson , Michal Hocko , Christoph Hellwig , kvm@vger.kernel.org, stable@vger.kernel.org, Haozhong Zhang Haozhong Zhang , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Filesystem-DAX is incompatible with 'longterm' page pinning. Without page cache indirection a DAX mapping maps filesystem blocks directly. This means that the filesystem must not modify a file's block map while any page in a mapping is pinned. In order to prevent the situation of userspace holding of filesystem operations indefinitely, disallow 'longterm' Filesystem-DAX mappings. RDMA has the same conflict and the plan there is to add a 'with lease' mechanism to allow the kernel to notify userspace that the mapping is being torn down for block-map maintenance. Perhaps something similar can be put in place for vfio. Note that xfs and ext4 still report: "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" ...at mount time, and resolving the dax-dma-vs-truncate problem is one of the last hurdles to remove that designation. Acked-by: Alex Williamson Cc: Michal Hocko Cc: Christoph Hellwig Cc: kvm@vger.kernel.org Cc: Reported-by: Haozhong Zhang Tested-by: Haozhong Zhang Fixes: d475c6346a38 ("dax,ext2: replace XIP read and write with DAX I/O") Signed-off-by: Dan Williams --- drivers/vfio/vfio_iommu_type1.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index e30e29ae4819..45657e2b1ff7 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, { struct page *page[1]; struct vm_area_struct *vma; + struct vm_area_struct *vmas[1]; int ret; if (mm == current->mm) { - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), - page); + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), + page, vmas); } else { unsigned int flags = 0; @@ -351,7 +352,18 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, down_read(&mm->mmap_sem); ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, - NULL, NULL); + vmas, NULL); + /* + * The lifetime of a vaddr_get_pfn() page pin is + * userspace-controlled. In the fs-dax case this could + * lead to indefinite stalls in filesystem operations. + * Disallow attempts to pin fs-dax pages via this + * interface. + */ + if (ret > 0 && vma_is_fsdax(vmas[0])) { + ret = -EOPNOTSUPP; + put_page(page[0]); + } up_read(&mm->mmap_sem); } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com ([192.55.52.151]:20032 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163935AbeCBECk (ORCPT ); Thu, 1 Mar 2018 23:02:40 -0500 Subject: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes From: Dan Williams Date: Thu, 01 Mar 2018 19:53:33 -0800 Message-ID: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: linux-nvdimm@lists.01.org Cc: linux-xfs@vger.kernel.org, "Darrick J. Wong" , kvm@vger.kernel.org, Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable@vger.kernel.org, Jan Kara , Michal Hocko , Andreas Dilger , Christoph Hellwig , Ross Zwisler , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Alex Williamson , Theodore Ts'o linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Changes since v4 [1]: * Fix the changelog of "dax: introduce IS_DEVDAX() and IS_FSDAX()" to better clarify the need for new helpers (Jan) * Replace dax_sem_is_locked() with dax_sem_assert_held() (Jan) * Use file_inode() in vma_is_dax() (Jan) * Resend the full series to linux-xfs@ (Dave) * Collect Jan's Reviewed-by [1]: https://lists.01.org/pipermail/linux-nvdimm/2018-February/014271.html --- The vfio interface, like RDMA, wants to setup long term (indefinite) pins of the pages backing an address range so that a guest or userspace driver can perform DMA to the with physical address. Given that this pinning may lead to filesystem operations deadlocking in the filesystem-dax case, the pinning request needs to be rejected. The longer term fix for vfio, RDMA, and any other long term pin user, is to provide a 'pin with lease' mechanism. Similar to the leases that are hold for pNFS RDMA layouts, this userspace lease gives the kernel a way to notify userspace that the block layout of the file is changing and the kernel is revoking access to pinned pages. Related to this change is the discovery that vma_is_fsdax() was causing device-dax inode detection to fail. That lead to series of fixes and cleanups to make sure that S_DAX is defined correctly in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. --- Dan Williams (12): dax: fix vma_is_fsdax() helper dax: introduce IS_DEVDAX() and IS_FSDAX() ext2, dax: finish implementing dax_sem helpers ext2, dax: define ext2_dax_*() infrastructure in all cases ext4, dax: define ext4_dax_*() infrastructure in all cases ext2, dax: replace IS_DAX() with IS_FSDAX() ext4, dax: replace IS_DAX() with IS_FSDAX() xfs, dax: replace IS_DAX() with IS_FSDAX() mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() fs, dax: kill IS_DAX() dax: fix S_DAX definition vfio: disable filesystem-dax page pinning drivers/vfio/vfio_iommu_type1.c | 18 ++++++++++++++-- fs/ext2/ext2.h | 6 +++++ fs/ext2/file.c | 19 +++++------------ fs/ext2/inode.c | 10 ++++----- fs/ext4/file.c | 18 +++++----------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- fs/iomap.c | 2 +- fs/xfs/xfs_file.c | 14 ++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++-- fs/xfs/xfs_reflink.c | 2 +- include/linux/dax.h | 12 ++++++++--- include/linux/fs.h | 43 ++++++++++++++++++++++++++++----------- mm/fadvise.c | 3 ++- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 +++- mm/madvise.c | 3 ++- 19 files changed, 102 insertions(+), 74 deletions(-) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com ([134.134.136.31]:54020 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163935AbeCBECv (ORCPT ); Thu, 1 Mar 2018 23:02:51 -0500 Subject: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams Date: Thu, 01 Mar 2018 19:53:44 -0800 Message-ID: <151996282448.28483.10415125852182473579.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..bd0c46880572 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com ([134.134.136.31]:4817 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423640AbeCBTPn (ORCPT ); Fri, 2 Mar 2018 14:15:43 -0500 Subject: [PATCH v6] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams Date: Fri, 02 Mar 2018 11:06:36 -0800 Message-ID: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara Jan Kara , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.orglinux-xfs@vger.kernel.org The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- Changes since v5: * add comments to clarify the S_ISCHR() checks (Darrick) include/linux/fs.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..751975b8b29b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,30 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* regular files with S_DAX are filesystem-dax instances */ + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* character devices with S_DAX are device-dax instances */ + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Date: Fri, 2 Mar 2018 23:10:20 +0100 Message-ID: <20180302221020.GA30722@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Jane Chu , Michal Hocko , Jan Kara , Matthew Wilcox , kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Darrick J. Wong" , linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-xfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Theodore Ts'o , Christoph Hellwig To: Dan Williams Return-path: Content-Disposition: inline In-Reply-To: <151996281307.28483.12343847096989509127.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" List-Id: kvm.vger.kernel.org I really don't like these IS_DEVDAX and IS_FSDAX flags. We should stop pretending DAX is a global per-inode choice and get rid of these magic flags entirely. So please convert the instances inside the various file systems to checking the file system mount options instead. For the core ones we'll need to differentiate: - the checks in generic_file_read_iter and __generic_file_write_iter seem to not be needed anymore at all since we stopped abusing the direct I/O code for DAX, so they should probably be removed. - io_is_direct is a weird check and should probably just go away, as there is not point in always setting IOCB_DIRECT for DAX I/O - fadvise should either become a file op, or a flag on the inode that fadvice is supported instead of the nasty noop_backing_dev_info or DAX check. - Ditto for madvise - vma_is_dax should probably be replaced with a VMA flag. - thp_get_unmapped_area I don't really understand why we have a dax check there. - dax_mapping will be much harder to sort out. But all these DAX flags certainly look like a major hodge podge to me. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Williams Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Date: Fri, 2 Mar 2018 14:21:40 -0800 Message-ID: References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Jane Chu , Michal Hocko , Jan Kara , Matthew Wilcox , KVM list , "Darrick J. Wong" , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel , Theodore Ts'o To: Christoph Hellwig Return-path: In-Reply-To: <20180302221020.GA30722-jcswGhMUV9g@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" List-Id: kvm.vger.kernel.org On Fri, Mar 2, 2018 at 2:10 PM, Christoph Hellwig wrote: > I really don't like these IS_DEVDAX and IS_FSDAX flags. We should > stop pretending DAX is a global per-inode choice and get rid of these > magic flags entirely. So please convert the instances inside the > various file systems to checking the file system mount options instead. > > For the core ones we'll need to differentiate: > > - the checks in generic_file_read_iter and __generic_file_write_iter > seem to not be needed anymore at all since we stopped abusing the > direct I/O code for DAX, so they should probably be removed. > - io_is_direct is a weird check and should probably just go away, > as there is not point in always setting IOCB_DIRECT for DAX I/O > - fadvise should either become a file op, or a flag on the inode that > fadvice is supported instead of the nasty noop_backing_dev_info or > DAX check. > - Ditto for madvise > - vma_is_dax should probably be replaced with a VMA flag. > - thp_get_unmapped_area I don't really understand why we have a dax > check there. > - dax_mapping will be much harder to sort out. > > But all these DAX flags certainly look like a major hodge podge to me. They are indeed a hodge-podge. The problem is that the current IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks you propose for the next merge window. Acceptable? From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Date: Fri, 2 Mar 2018 23:57:34 +0100 Message-ID: <20180302225734.GE31240@lst.de> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Jane Chu , Michal Hocko , Jan Kara , Matthew Wilcox , KVM list , "Darrick J. Wong" , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel , Theodore Ts'o , Christoph Hellwig To: Dan Williams Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" List-Id: kvm.vger.kernel.org On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: > They are indeed a hodge-podge. The problem is that the current > IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with > IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks > you propose for the next merge window. The only thing broken about IS_DAX are the code elimination games based on the CONFIG_* flags. Remove those and just add proper stubs for the dax routines and everything will be fine for now until we can kill that inode flag. IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't helping anyone. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Williams Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Date: Fri, 2 Mar 2018 15:49:45 -0800 Message-ID: References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> <20180302225734.GE31240@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Jane Chu , Michal Hocko , Jan Kara , Matthew Wilcox , KVM list , "Darrick J. Wong" , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel , Theodore Ts'o To: Christoph Hellwig Return-path: In-Reply-To: <20180302225734.GE31240-jcswGhMUV9g@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" List-Id: kvm.vger.kernel.org On Fri, Mar 2, 2018 at 2:57 PM, Christoph Hellwig wrote: > On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: >> They are indeed a hodge-podge. The problem is that the current >> IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with >> IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks >> you propose for the next merge window. > > The only thing broken about IS_DAX are the code elimination games > based on the CONFIG_* flags. Remove those and just add proper stubs > for the dax routines and everything will be fine for now until we can > kill that inode flag. > > IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't > helping anyone. Ok, I'll take another shot at something suitable for 4.16, but without these new helpers... From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Williams Subject: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Date: Thu, 01 Mar 2018 19:53:33 -0800 Message-ID: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Jane Chu , Michal Hocko , Jan Kara , kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Darrick J. Wong" , Matthew Wilcox , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-xfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Theodore Ts'o , Christoph Hellwig To: linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" List-Id: kvm.vger.kernel.org Changes since v4 [1]: * Fix the changelog of "dax: introduce IS_DEVDAX() and IS_FSDAX()" to better clarify the need for new helpers (Jan) * Replace dax_sem_is_locked() with dax_sem_assert_held() (Jan) * Use file_inode() in vma_is_dax() (Jan) * Resend the full series to linux-xfs@ (Dave) * Collect Jan's Reviewed-by [1]: https://lists.01.org/pipermail/linux-nvdimm/2018-February/014271.html --- The vfio interface, like RDMA, wants to setup long term (indefinite) pins of the pages backing an address range so that a guest or userspace driver can perform DMA to the with physical address. Given that this pinning may lead to filesystem operations deadlocking in the filesystem-dax case, the pinning request needs to be rejected. The longer term fix for vfio, RDMA, and any other long term pin user, is to provide a 'pin with lease' mechanism. Similar to the leases that are hold for pNFS RDMA layouts, this userspace lease gives the kernel a way to notify userspace that the block layout of the file is changing and the kernel is revoking access to pinned pages. Related to this change is the discovery that vma_is_fsdax() was causing device-dax inode detection to fail. That lead to series of fixes and cleanups to make sure that S_DAX is defined correctly in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. --- Dan Williams (12): dax: fix vma_is_fsdax() helper dax: introduce IS_DEVDAX() and IS_FSDAX() ext2, dax: finish implementing dax_sem helpers ext2, dax: define ext2_dax_*() infrastructure in all cases ext4, dax: define ext4_dax_*() infrastructure in all cases ext2, dax: replace IS_DAX() with IS_FSDAX() ext4, dax: replace IS_DAX() with IS_FSDAX() xfs, dax: replace IS_DAX() with IS_FSDAX() mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() fs, dax: kill IS_DAX() dax: fix S_DAX definition vfio: disable filesystem-dax page pinning drivers/vfio/vfio_iommu_type1.c | 18 ++++++++++++++-- fs/ext2/ext2.h | 6 +++++ fs/ext2/file.c | 19 +++++------------ fs/ext2/inode.c | 10 ++++----- fs/ext4/file.c | 18 +++++----------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- fs/iomap.c | 2 +- fs/xfs/xfs_file.c | 14 ++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++-- fs/xfs/xfs_reflink.c | 2 +- include/linux/dax.h | 12 ++++++++--- include/linux/fs.h | 43 ++++++++++++++++++++++++++++----------- mm/fadvise.c | 3 ++- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 +++- mm/madvise.c | 3 ++- 19 files changed, 102 insertions(+), 74 deletions(-) From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Williams Subject: [PATCH v5 12/12] vfio: disable filesystem-dax page pinning Date: Thu, 01 Mar 2018 19:54:39 -0800 Message-ID: <151996287917.28483.16157329534570989926.stgit@dwillia2-desk3.amr.corp.intel.com> References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Michal Hocko , kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-xfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Alex Williamson , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Christoph Hellwig To: linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Return-path: In-Reply-To: <151996281307.28483.12343847096989509127.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" List-Id: kvm.vger.kernel.org Filesystem-DAX is incompatible with 'longterm' page pinning. Without page cache indirection a DAX mapping maps filesystem blocks directly. This means that the filesystem must not modify a file's block map while any page in a mapping is pinned. In order to prevent the situation of userspace holding of filesystem operations indefinitely, disallow 'longterm' Filesystem-DAX mappings. RDMA has the same conflict and the plan there is to add a 'with lease' mechanism to allow the kernel to notify userspace that the mapping is being torn down for block-map maintenance. Perhaps something similar can be put in place for vfio. Note that xfs and ext4 still report: "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" ...at mount time, and resolving the dax-dma-vs-truncate problem is one of the last hurdles to remove that designation. Acked-by: Alex Williamson Cc: Michal Hocko Cc: Christoph Hellwig Cc: kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Reported-by: Haozhong Zhang Tested-by: Haozhong Zhang Fixes: d475c6346a38 ("dax,ext2: replace XIP read and write with DAX I/O") Signed-off-by: Dan Williams --- drivers/vfio/vfio_iommu_type1.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index e30e29ae4819..45657e2b1ff7 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, { struct page *page[1]; struct vm_area_struct *vma; + struct vm_area_struct *vmas[1]; int ret; if (mm == current->mm) { - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), - page); + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), + page, vmas); } else { unsigned int flags = 0; @@ -351,7 +352,18 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, down_read(&mm->mmap_sem); ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, - NULL, NULL); + vmas, NULL); + /* + * The lifetime of a vaddr_get_pfn() page pin is + * userspace-controlled. In the fs-dax case this could + * lead to indefinite stalls in filesystem operations. + * Disallow attempts to pin fs-dax pages via this + * interface. + */ + if (ret > 0 && vma_is_fsdax(vmas[0])) { + ret = -EOPNOTSUPP; + put_page(page[0]); + } up_read(&mm->mmap_sem); } From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Williams Subject: Re: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes Date: Fri, 2 Mar 2018 18:19:16 -0800 Message-ID: References: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> <20180302221020.GA30722@lst.de> <20180302225734.GE31240@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Michal Hocko , Jan Kara , Matthew Wilcox , KVM list , "Darrick J. Wong" , linux-nvdimm , Linux Kernel Mailing List , stable , linux-xfs , Linux MM , Alex Williamson , Gerd Rausch , Andreas Dilger , Alexander Viro , linux-fsdevel , Theodore Ts'o To: Christoph Hellwig Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org Sender: "Linux-nvdimm" List-Id: kvm.vger.kernel.org On Fri, Mar 2, 2018 at 3:49 PM, Dan Williams wrote: > On Fri, Mar 2, 2018 at 2:57 PM, Christoph Hellwig wrote: >> On Fri, Mar 02, 2018 at 02:21:40PM -0800, Dan Williams wrote: >>> They are indeed a hodge-podge. The problem is that the current >>> IS_DAX() is broken. So I'd like to propose fixing IS_DAX() with >>> IS_FSDAX() + IS_DEVDAX() for 4.16-rc4 and queue up these wider reworks >>> you propose for the next merge window. >> >> The only thing broken about IS_DAX are the code elimination games >> based on the CONFIG_* flags. Remove those and just add proper stubs >> for the dax routines and everything will be fine for now until we can >> kill that inode flag. >> >> IS_FSDAX and IS_DEVDAX on the other hand are a giant mess that isn't >> helping anyone. > > Ok, I'll take another shot at something suitable for 4.16, but without > these new helpers... I'll drop patches 2-11 for now, and just get the high priority fixes in for the next rc. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 1CAE96B0011 for ; Thu, 1 Mar 2018 23:02:52 -0500 (EST) Received: by mail-pf0-f200.google.com with SMTP id u188so4572949pfb.6 for ; Thu, 01 Mar 2018 20:02:52 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id v6si3434356pgq.146.2018.03.01.20.02.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 20:02:50 -0800 (PST) Subject: [PATCH v5 02/12] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams Date: Thu, 01 Mar 2018 19:53:44 -0800 Message-ID: <151996282448.28483.10415125852182473579.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara Jan Kara , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..bd0c46880572 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,28 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id EA8E36B0033 for ; Thu, 1 Mar 2018 23:03:40 -0500 (EST) Received: by mail-pg0-f72.google.com with SMTP id b2so1574482pgt.6 for ; Thu, 01 Mar 2018 20:03:40 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com. [134.134.136.31]) by mx.google.com with ESMTPS id u27si4132634pfk.241.2018.03.01.20.03.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 20:03:39 -0800 (PST) Subject: [PATCH v5 11/12] dax: fix S_DAX definition From: Dan Williams Date: Thu, 01 Mar 2018 19:54:34 -0800 Message-ID: <151996287403.28483.8962319815764432894.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-nvdimm@lists.01.org Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Christoph Hellwig , stable@vger.kernel.org, Jan Kara , linux-xfs@vger.kernel.orglinux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Make sure S_DAX is defined in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. Otherwise vma_is_dax() may incorrectly return false in the Device-DAX case. Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Christoph Hellwig Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index b2b2e15d227b..1242511b1c46 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1859,7 +1859,7 @@ struct super_operations { #define S_IMA 1024 /* Inode has an associated IMA struct */ #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ #define S_NOSEC 4096 /* no suid or xattr security attributes */ -#ifdef CONFIG_FS_DAX +#if IS_ENABLED(CONFIG_FS_DAX) || IS_ENABLED(CONFIG_DEV_DAX) #define S_DAX 8192 /* Direct Access, avoiding the page cache */ #else #define S_DAX 0 /* Make all the DAX code disappear */ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 8F47F6B000E for ; Thu, 1 Mar 2018 23:02:40 -0500 (EST) Received: by mail-pg0-f72.google.com with SMTP id m19so3552826pgv.5 for ; Thu, 01 Mar 2018 20:02:40 -0800 (PST) Received: from mga09.intel.com (mga09.intel.com. [134.134.136.24]) by mx.google.com with ESMTPS id c18si4138928pfe.335.2018.03.01.20.02.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 20:02:39 -0800 (PST) Subject: [PATCH v5 00/12] vfio, dax: prevent long term filesystem-dax pins and other fixes From: Dan Williams Date: Thu, 01 Mar 2018 19:53:33 -0800 Message-ID: <151996281307.28483.12343847096989509127.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-nvdimm@lists.01.org Cc: linux-xfs@vger.kernel.org, "Darrick J. Wong" , kvm@vger.kernel.org, Haozhong Zhang , Jane Chu , Alexander Viro , Gerd Rausch , stable@vger.kernel.org, Jan Kara , Michal Hocko , Andreas Dilger , Christoph Hellwig , Ross Zwisler , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Alex Williamson , Theodore Ts'o linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Changes since v4 [1]: * Fix the changelog of "dax: introduce IS_DEVDAX() and IS_FSDAX()" to better clarify the need for new helpers (Jan) * Replace dax_sem_is_locked() with dax_sem_assert_held() (Jan) * Use file_inode() in vma_is_dax() (Jan) * Resend the full series to linux-xfs@ (Dave) * Collect Jan's Reviewed-by [1]: https://lists.01.org/pipermail/linux-nvdimm/2018-February/014271.html --- The vfio interface, like RDMA, wants to setup long term (indefinite) pins of the pages backing an address range so that a guest or userspace driver can perform DMA to the with physical address. Given that this pinning may lead to filesystem operations deadlocking in the filesystem-dax case, the pinning request needs to be rejected. The longer term fix for vfio, RDMA, and any other long term pin user, is to provide a 'pin with lease' mechanism. Similar to the leases that are hold for pNFS RDMA layouts, this userspace lease gives the kernel a way to notify userspace that the block layout of the file is changing and the kernel is revoking access to pinned pages. Related to this change is the discovery that vma_is_fsdax() was causing device-dax inode detection to fail. That lead to series of fixes and cleanups to make sure that S_DAX is defined correctly in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. --- Dan Williams (12): dax: fix vma_is_fsdax() helper dax: introduce IS_DEVDAX() and IS_FSDAX() ext2, dax: finish implementing dax_sem helpers ext2, dax: define ext2_dax_*() infrastructure in all cases ext4, dax: define ext4_dax_*() infrastructure in all cases ext2, dax: replace IS_DAX() with IS_FSDAX() ext4, dax: replace IS_DAX() with IS_FSDAX() xfs, dax: replace IS_DAX() with IS_FSDAX() mm, dax: replace IS_DAX() with IS_DEVDAX() or IS_FSDAX() fs, dax: kill IS_DAX() dax: fix S_DAX definition vfio: disable filesystem-dax page pinning drivers/vfio/vfio_iommu_type1.c | 18 ++++++++++++++-- fs/ext2/ext2.h | 6 +++++ fs/ext2/file.c | 19 +++++------------ fs/ext2/inode.c | 10 ++++----- fs/ext4/file.c | 18 +++++----------- fs/ext4/inode.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/ext4/super.c | 2 +- fs/iomap.c | 2 +- fs/xfs/xfs_file.c | 14 ++++++------- fs/xfs/xfs_ioctl.c | 4 ++-- fs/xfs/xfs_iomap.c | 6 +++-- fs/xfs/xfs_reflink.c | 2 +- include/linux/dax.h | 12 ++++++++--- include/linux/fs.h | 43 ++++++++++++++++++++++++++++----------- mm/fadvise.c | 3 ++- mm/filemap.c | 4 ++-- mm/huge_memory.c | 4 +++- mm/madvise.c | 3 ++- 19 files changed, 102 insertions(+), 74 deletions(-) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 05E056B0055 for ; Thu, 1 Mar 2018 23:03:46 -0500 (EST) Received: by mail-pl0-f69.google.com with SMTP id j6-v6so4442920pll.10 for ; Thu, 01 Mar 2018 20:03:45 -0800 (PST) Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id 73-v6si4088485ple.829.2018.03.01.20.03.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 20:03:44 -0800 (PST) Subject: [PATCH v5 12/12] vfio: disable filesystem-dax page pinning From: Dan Williams Date: Thu, 01 Mar 2018 19:54:39 -0800 Message-ID: <151996287917.28483.16157329534570989926.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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-nvdimm@lists.01.org Cc: Alex Williamson , Michal Hocko , Christoph Hellwig , kvm@vger.kernel.org, stable@vger.kernel.org, Haozhong Zhang Haozhong Zhang , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Filesystem-DAX is incompatible with 'longterm' page pinning. Without page cache indirection a DAX mapping maps filesystem blocks directly. This means that the filesystem must not modify a file's block map while any page in a mapping is pinned. In order to prevent the situation of userspace holding of filesystem operations indefinitely, disallow 'longterm' Filesystem-DAX mappings. RDMA has the same conflict and the plan there is to add a 'with lease' mechanism to allow the kernel to notify userspace that the mapping is being torn down for block-map maintenance. Perhaps something similar can be put in place for vfio. Note that xfs and ext4 still report: "DAX enabled. Warning: EXPERIMENTAL, use at your own risk" ...at mount time, and resolving the dax-dma-vs-truncate problem is one of the last hurdles to remove that designation. Acked-by: Alex Williamson Cc: Michal Hocko Cc: Christoph Hellwig Cc: kvm@vger.kernel.org Cc: Reported-by: Haozhong Zhang Tested-by: Haozhong Zhang Fixes: d475c6346a38 ("dax,ext2: replace XIP read and write with DAX I/O") Signed-off-by: Dan Williams --- drivers/vfio/vfio_iommu_type1.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index e30e29ae4819..45657e2b1ff7 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -338,11 +338,12 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, { struct page *page[1]; struct vm_area_struct *vma; + struct vm_area_struct *vmas[1]; int ret; if (mm == current->mm) { - ret = get_user_pages_fast(vaddr, 1, !!(prot & IOMMU_WRITE), - page); + ret = get_user_pages_longterm(vaddr, 1, !!(prot & IOMMU_WRITE), + page, vmas); } else { unsigned int flags = 0; @@ -351,7 +352,18 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr, down_read(&mm->mmap_sem); ret = get_user_pages_remote(NULL, mm, vaddr, 1, flags, page, - NULL, NULL); + vmas, NULL); + /* + * The lifetime of a vaddr_get_pfn() page pin is + * userspace-controlled. In the fs-dax case this could + * lead to indefinite stalls in filesystem operations. + * Disallow attempts to pin fs-dax pages via this + * interface. + */ + if (ret > 0 && vma_is_fsdax(vmas[0])) { + ret = -EOPNOTSUPP; + put_page(page[0]); + } up_read(&mm->mmap_sem); } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id D0E596B0006 for ; Fri, 2 Mar 2018 14:15:45 -0500 (EST) Received: by mail-pf0-f200.google.com with SMTP id y20so5748975pfm.1 for ; Fri, 02 Mar 2018 11:15:45 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id f1-v6si5234888plb.73.2018.03.02.11.15.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Mar 2018 11:15:43 -0800 (PST) Subject: [PATCH v6] dax: introduce IS_DEVDAX() and IS_FSDAX() From: Dan Williams Date: Fri, 02 Mar 2018 11:06:36 -0800 Message-ID: <152001757529.22146.17936438768625217740.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-nvdimm@lists.01.org Cc: Theodore Ts'o , Andreas Dilger , Alexander Viro , "Darrick J. Wong" , linux-xfs@vger.kernel.org, Matthew Wilcox , Ross Zwisler , stable@vger.kernel.org, Jan Kara Jan Kara , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.orglinux-xfs@vger.kernel.org The current IS_DAX() helper that checks if a file is in DAX mode serves two purposes. It is a control flow branch condition for DAX vs non-DAX paths and it is a mechanism to perform dead code elimination. The dead code elimination is required in the CONFIG_FS_DAX=n case since there are symbols in fs/dax.c that will be elided. While the dead code elimination can be addressed with nop stubs for the fs/dax.c symbols that does not address the need for a DAX control flow helper where fs/dax.c symbols are not involved. Moreover, the control flow changes, in some cases, need to be cognizant of whether the DAX file is a typical file or a Device-DAX special file. Introduce IS_DEVDAX() and IS_FSDAX() to simultaneously address the file-type control flow and dead-code elimination use cases. IS_DAX() will be deleted after all sites are converted to use the file-type specific helper. Note, this change is also a pre-requisite for fixing the definition of the S_DAX inode flag in the CONFIG_FS_DAX=n + CONFIG_DEV_DAX=y case. The flag needs to be defined, non-zero, if either DAX facility is enabled. Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Cc: Matthew Wilcox Cc: Ross Zwisler Cc: Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap") Reported-by: Jan Kara Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- Changes since v5: * add comments to clarify the S_ISCHR() checks (Darrick) include/linux/fs.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 79c413985305..751975b8b29b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1909,6 +1909,30 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ (inode)->i_rdev == WHITEOUT_DEV) +static inline bool IS_DEVDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_DEV_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* regular files with S_DAX are filesystem-dax instances */ + if (!S_ISCHR(inode->i_mode)) + return false; + return true; +} + +static inline bool IS_FSDAX(struct inode *inode) +{ + if (!IS_ENABLED(CONFIG_FS_DAX)) + return false; + if ((inode->i_flags & S_DAX) == 0) + return false; + /* character devices with S_DAX are device-dax instances */ + if (S_ISCHR(inode->i_mode)) + return false; + return true; +} + static inline bool HAS_UNMAPPED_ID(struct inode *inode) { return !uid_valid(inode->i_uid) || !gid_valid(inode->i_gid); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org