From efbe3c2493d2f7a1e1a753780fe727b34709ebd2 Mon Sep 17 00:00:00 2001
From: Ira Weiny <ira.weiny@intel.com>
Date: Thu, 30 Apr 2020 07:41:33 -0700
Subject: [PATCH] fs: Remove unneeded IS_DAX() check in io_is_direct()
Git-commit: efbe3c2493d2f7a1e1a753780fe727b34709ebd2
Patch-mainline: v5.8-rc1
References: jsc#SLE-13451
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: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Jan Kara <jack@suse.cz>
---
drivers/block/loop.c | 9 +++++----
include/linux/fs.h | 7 +------
2 files changed, 6 insertions(+), 10 deletions(-)
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -644,8 +644,8 @@ static int do_req_filebacked(struct loop
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,
@@ -1149,10 +1149,11 @@ static int loop_configure(struct loop_de
if (config->block_size)
bsize = config->block_size;
- else if (io_is_direct(lo->lo_backing_file) && inode->i_sb->s_bdev)
+ else if ((lo->lo_backing_file->f_flags & O_DIRECT) &&
+ inode->i_sb->s_bdev) {
/* In case of direct I/O, match underlying block size */
bsize = bdev_logical_block_size(inode->i_sb->s_bdev);
- else
+ } else
bsize = 512;
blk_queue_logical_block_size(lo->lo_queue, bsize);
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3306,11 +3306,6 @@ extern void setattr_copy(struct inode *i
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);
@@ -3335,7 +3330,7 @@ static inline int iocb_flags(struct 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;