]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
minix: fix bug when opening a file with O_DIRECT
authorQinghua Jin <qhjin.dev@gmail.com>
Wed, 23 Mar 2022 23:06:23 +0000 (16:06 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:59:22 +0000 (11:59 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969107
[ Upstream commit 9ce3c0d26c42d279b6c378a03cd6a61d828f19ca ]

Testcase:
1. create a minix file system and mount it
2. open a file on the file system with O_RDWR|O_CREAT|O_TRUNC|O_DIRECT
3. open fails with -EINVAL but leaves an empty file behind. All other
   open() failures don't leave the failed open files behind.

It is hard to check the direct_IO op before creating the inode.  Just as
ext4 and btrfs do, this patch will resolve the issue by allowing to
create the file with O_DIRECT but returning error when writing the file.

Link: https://lkml.kernel.org/r/20220107133626.413379-1-qhjin.dev@gmail.com
Signed-off-by: Qinghua Jin <qhjin.dev@gmail.com>
Reported-by: Colin Ian King <colin.king@intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 31e027259ce48cfa06700ad5a1a377768b56bf8b)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
fs/minix/inode.c

index a71f1cf894b9f1218f8c739dda034f100ed20c99..d4bd94234ef73e974e8cddb70f9252c69e57f802 100644 (file)
@@ -447,7 +447,8 @@ static const struct address_space_operations minix_aops = {
        .writepage = minix_writepage,
        .write_begin = minix_write_begin,
        .write_end = generic_write_end,
-       .bmap = minix_bmap
+       .bmap = minix_bmap,
+       .direct_IO = noop_direct_IO
 };
 
 static const struct inode_operations minix_symlink_inode_operations = {