ext4: support direct I/O with fscrypt using blk-crypto
[linux-2.6-microblaze.git] / fs / ext4 / file.c
index 8cc1171..8bd66cd 100644 (file)
 #include "acl.h"
 #include "truncate.h"
 
-static bool ext4_dio_supported(struct inode *inode)
+static bool ext4_dio_supported(struct kiocb *iocb, struct iov_iter *iter)
 {
-       if (IS_ENABLED(CONFIG_FS_ENCRYPTION) && IS_ENCRYPTED(inode))
+       struct inode *inode = file_inode(iocb->ki_filp);
+
+       if (!fscrypt_dio_supported(iocb, iter))
                return false;
        if (fsverity_active(inode))
                return false;
@@ -61,7 +63,7 @@ static ssize_t ext4_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)
                inode_lock_shared(inode);
        }
 
-       if (!ext4_dio_supported(inode)) {
+       if (!ext4_dio_supported(iocb, to)) {
                inode_unlock_shared(inode);
                /*
                 * Fallback to buffered I/O if the operation being performed on
@@ -509,7 +511,7 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
        }
 
        /* Fallback to buffered I/O if the inode does not support direct I/O. */
-       if (!ext4_dio_supported(inode)) {
+       if (!ext4_dio_supported(iocb, from)) {
                if (ilock_shared)
                        inode_unlock_shared(inode);
                else