fuse: remove useless IOCB_DIRECT in fuse_direct_read/write_iter
authoryangyun <yangyun50@huawei.com>
Mon, 26 Aug 2024 13:06:12 +0000 (21:06 +0800)
committerMiklos Szeredi <mszeredi@redhat.com>
Fri, 25 Oct 2024 15:05:49 +0000 (17:05 +0200)
Commit 23c94e1cdcbf ("fuse: Switch to using async direct IO
for FOPEN_DIRECT_IO") gave the async direct IO code path in the
fuse_direct_read_iter() and fuse_direct_write_iter(). But since
these two functions are only called under FOPEN_DIRECT_IO is set,
it seems that we can also use the async direct IO even the flag
IOCB_DIRECT is not set to enjoy the async direct IO method. Also
move the definition of fuse_io_priv to where it is used in fuse_
direct_write_iter.

Signed-off-by: yangyun <yangyun50@huawei.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/file.c

index dafdf76..5d240d8 100644 (file)
@@ -1650,7 +1650,7 @@ static ssize_t fuse_direct_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
        ssize_t res;
 
-       if (!is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) {
+       if (!is_sync_kiocb(iocb)) {
                res = fuse_direct_IO(iocb, to);
        } else {
                struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb);
@@ -1664,7 +1664,6 @@ static ssize_t fuse_direct_read_iter(struct kiocb *iocb, struct iov_iter *to)
 static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
        struct inode *inode = file_inode(iocb->ki_filp);
-       struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb);
        ssize_t res;
        bool exclusive;
 
@@ -1672,9 +1671,11 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from)
        res = generic_write_checks(iocb, from);
        if (res > 0) {
                task_io_account_write(res);
-               if (!is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) {
+               if (!is_sync_kiocb(iocb)) {
                        res = fuse_direct_IO(iocb, from);
                } else {
+                       struct fuse_io_priv io = FUSE_IO_PRIV_SYNC(iocb);
+
                        res = fuse_direct_io(&io, from, &iocb->ki_pos,
                                             FUSE_DIO_WRITE);
                        fuse_write_update_attr(inode, iocb->ki_pos, res);