]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
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>
Fri, 20 May 2022 13:19:50 +0000 (15:19 +0200)
commita682bda96b97210c71ae3612854a2a6d024d825c
tree291903d894269288b64d7594bce3ec512bd6ec1a
parent239d440247fc096d8099be14db3202969eccac8e
minix: fix bug when opening a file with O_DIRECT

BugLink: https://bugs.launchpad.net/bugs/1971497
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/minix/inode.c