diff mbox series

[V9,02/11] fs: Remove unneeded IS_DAX() check in io_is_direct()

Message ID 20200421191754.3372370-3-ira.weiny@intel.com (mailing list archive)
State Superseded, archived
Headers show
Series XFS - Enable per-file/per-directory DAX operations V9 | expand

Commit Message

Ira Weiny April 21, 2020, 7:17 p.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

Remove the check because DAX now has it's own read/write methods and
file systems which support DAX check IS_DAX() prior to IOCB_DIRECT on
their own.  Therefore, it does not matter if the file state is DAX when
the iocb flags are created.

Also remove io_is_direct() as it is just a simple flag check.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
Changes from v8:
	Rebase to latest Linus tree

Changes from v6:
	remove io_is_direct() as well.
	Remove Reviews since this is quite a bit different.

Changes from v3:
	Reword commit message.
	Reordered to be a 'pre-cleanup' patch
---
 drivers/block/loop.c | 6 +++---
 include/linux/fs.h   | 7 +------
 2 files changed, 4 insertions(+), 9 deletions(-)

Comments

Darrick J. Wong April 21, 2020, 8:13 p.m. UTC | #1
On Tue, Apr 21, 2020 at 12:17:44PM -0700, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
> 
> Remove the check because DAX now has it's own read/write methods and
> file systems which support DAX check IS_DAX() prior to IOCB_DIRECT on
> their own.  Therefore, it does not matter if the file state is DAX when
> the iocb flags are created.
> 
> Also remove io_is_direct() as it is just a simple flag check.
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>

Looks fine to me,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> 
> ---
> Changes from v8:
> 	Rebase to latest Linus tree
> 
> Changes from v6:
> 	remove io_is_direct() as well.
> 	Remove Reviews since this is quite a bit different.
> 
> Changes from v3:
> 	Reword commit message.
> 	Reordered to be a 'pre-cleanup' patch
> ---
>  drivers/block/loop.c | 6 +++---
>  include/linux/fs.h   | 7 +------
>  2 files changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index da693e6a834e..14372df0f354 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -634,8 +634,8 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
>  
>  static inline void loop_update_dio(struct loop_device *lo)
>  {
> -	__loop_update_dio(lo, io_is_direct(lo->lo_backing_file) |
> -			lo->use_dio);
> +	__loop_update_dio(lo, (lo->lo_backing_file->f_flags & O_DIRECT) |
> +				lo->use_dio);
>  }
>  
>  static void loop_reread_partitions(struct loop_device *lo,
> @@ -1028,7 +1028,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
>  	if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
>  		blk_queue_write_cache(lo->lo_queue, true, false);
>  
> -	if (io_is_direct(lo->lo_backing_file) && inode->i_sb->s_bdev) {
> +	if ((lo->lo_backing_file->f_flags & O_DIRECT) && inode->i_sb->s_bdev) {
>  		/* In case of direct I/O, match underlying block size */
>  		unsigned short bsize = bdev_logical_block_size(
>  			inode->i_sb->s_bdev);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 4f6f59b4f22a..a87cc5845a02 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -3394,11 +3394,6 @@ extern void setattr_copy(struct inode *inode, const struct iattr *attr);
>  
>  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);
> -}
> -
>  static inline bool vma_is_dax(const struct vm_area_struct *vma)
>  {
>  	return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
> @@ -3423,7 +3418,7 @@ static inline int iocb_flags(struct file *file)
>  	int res = 0;
>  	if (file->f_flags & O_APPEND)
>  		res |= IOCB_APPEND;
> -	if (io_is_direct(file))
> +	if (file->f_flags & O_DIRECT)
>  		res |= IOCB_DIRECT;
>  	if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host))
>  		res |= IOCB_DSYNC;
> -- 
> 2.25.1
>
Jan Kara April 22, 2020, 8:37 a.m. UTC | #2
On Tue 21-04-20 12:17:44, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
> 
> Remove the check because DAX now has it's own read/write methods and
> file systems which support DAX check IS_DAX() prior to IOCB_DIRECT on
> their own.  Therefore, it does not matter if the file state is DAX when
> the iocb flags are created.
> 
> Also remove io_is_direct() as it is just a simple flag check.
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>

Looks good to me. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> 
> ---
> Changes from v8:
> 	Rebase to latest Linus tree
> 
> Changes from v6:
> 	remove io_is_direct() as well.
> 	Remove Reviews since this is quite a bit different.
> 
> Changes from v3:
> 	Reword commit message.
> 	Reordered to be a 'pre-cleanup' patch
> ---
>  drivers/block/loop.c | 6 +++---
>  include/linux/fs.h   | 7 +------
>  2 files changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index da693e6a834e..14372df0f354 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -634,8 +634,8 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
>  
>  static inline void loop_update_dio(struct loop_device *lo)
>  {
> -	__loop_update_dio(lo, io_is_direct(lo->lo_backing_file) |
> -			lo->use_dio);
> +	__loop_update_dio(lo, (lo->lo_backing_file->f_flags & O_DIRECT) |
> +				lo->use_dio);
>  }
>  
>  static void loop_reread_partitions(struct loop_device *lo,
> @@ -1028,7 +1028,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
>  	if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
>  		blk_queue_write_cache(lo->lo_queue, true, false);
>  
> -	if (io_is_direct(lo->lo_backing_file) && inode->i_sb->s_bdev) {
> +	if ((lo->lo_backing_file->f_flags & O_DIRECT) && inode->i_sb->s_bdev) {
>  		/* In case of direct I/O, match underlying block size */
>  		unsigned short bsize = bdev_logical_block_size(
>  			inode->i_sb->s_bdev);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 4f6f59b4f22a..a87cc5845a02 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -3394,11 +3394,6 @@ extern void setattr_copy(struct inode *inode, const struct iattr *attr);
>  
>  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);
> -}
> -
>  static inline bool vma_is_dax(const struct vm_area_struct *vma)
>  {
>  	return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
> @@ -3423,7 +3418,7 @@ static inline int iocb_flags(struct file *file)
>  	int res = 0;
>  	if (file->f_flags & O_APPEND)
>  		res |= IOCB_APPEND;
> -	if (io_is_direct(file))
> +	if (file->f_flags & O_DIRECT)
>  		res |= IOCB_DIRECT;
>  	if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host))
>  		res |= IOCB_DSYNC;
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index da693e6a834e..14372df0f354 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -634,8 +634,8 @@  static int do_req_filebacked(struct loop_device *lo, struct request *rq)
 
 static inline void loop_update_dio(struct loop_device *lo)
 {
-	__loop_update_dio(lo, io_is_direct(lo->lo_backing_file) |
-			lo->use_dio);
+	__loop_update_dio(lo, (lo->lo_backing_file->f_flags & O_DIRECT) |
+				lo->use_dio);
 }
 
 static void loop_reread_partitions(struct loop_device *lo,
@@ -1028,7 +1028,7 @@  static int loop_set_fd(struct loop_device *lo, fmode_t mode,
 	if (!(lo_flags & LO_FLAGS_READ_ONLY) && file->f_op->fsync)
 		blk_queue_write_cache(lo->lo_queue, true, false);
 
-	if (io_is_direct(lo->lo_backing_file) && inode->i_sb->s_bdev) {
+	if ((lo->lo_backing_file->f_flags & O_DIRECT) && inode->i_sb->s_bdev) {
 		/* In case of direct I/O, match underlying block size */
 		unsigned short bsize = bdev_logical_block_size(
 			inode->i_sb->s_bdev);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4f6f59b4f22a..a87cc5845a02 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3394,11 +3394,6 @@  extern void setattr_copy(struct inode *inode, const struct iattr *attr);
 
 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);
-}
-
 static inline bool vma_is_dax(const struct vm_area_struct *vma)
 {
 	return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
@@ -3423,7 +3418,7 @@  static inline int iocb_flags(struct file *file)
 	int res = 0;
 	if (file->f_flags & O_APPEND)
 		res |= IOCB_APPEND;
-	if (io_is_direct(file))
+	if (file->f_flags & O_DIRECT)
 		res |= IOCB_DIRECT;
 	if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host))
 		res |= IOCB_DSYNC;