From: Eric Biggers <ebiggers@google.com>
Date: Wed, 24 May 2017 22:20:31 +0000 (-0400)
Subject: ext4: remove redundant check for encrypted file on dio write path
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c41d342b39f15acbdc61948bab0cb3c567ec992a;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git

ext4: remove redundant check for encrypted file on dio write path

Currently we don't allow direct I/O on encrypted regular files, so in
such cases we return 0 early in ext4_direct_IO().  There was also an
additional BUG_ON() check in ext4_direct_IO_write(), but it can never be
hit because of the earlier check for the exact same condition in
ext4_direct_IO().  There was also no matching check on the read path,
which made the write path specific check seem very ad-hoc.

Just remove the unnecessary BUG_ON().

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: David Gstir <david@sigma-star.at>
Reviewed-by: Jan Kara <jack@suse.cz>
---

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 90b264928742..074aeba78259 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3629,9 +3629,6 @@ static ssize_t ext4_direct_IO_write(struct kiocb *iocb, struct iov_iter *iter)
 		get_block_func = ext4_dio_get_block_unwritten_async;
 		dio_flags = DIO_LOCKING;
 	}
-#ifdef CONFIG_EXT4_FS_ENCRYPTION
-	BUG_ON(ext4_encrypted_inode(inode) && S_ISREG(inode->i_mode));
-#endif
 	ret = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
 				   get_block_func, ext4_end_io_dio, NULL,
 				   dio_flags);