]> www.infradead.org Git - users/hch/misc.git/commit
fs/block: Check for IOCB_DIRECT in generic_atomic_write_valid()
authorJohn Garry <john.g.garry@oracle.com>
Sat, 19 Oct 2024 12:51:07 +0000 (12:51 +0000)
committerJens Axboe <axboe@kernel.dk>
Sat, 19 Oct 2024 22:48:22 +0000 (16:48 -0600)
commitc3be7ebbbce5201e151f17e28a6c807602f369c9
treefa1376bcded0563f136cccbcca6fd45b8df9c471
parent9a8dbdadae509e5717ff6e5aa572ca0974d2101d
fs/block: Check for IOCB_DIRECT in generic_atomic_write_valid()

Currently FMODE_CAN_ATOMIC_WRITE is set if the bdev can atomic write and
the file is open for direct IO. This does not work if the file is not
opened for direct IO, yet fcntl(O_DIRECT) is used on the fd later.

Change to check for direct IO on a per-IO basis in
generic_atomic_write_valid(). Since we want to report -EOPNOTSUPP for
non-direct IO for an atomic write, change to return an error code.

Relocate the block fops atomic write checks to the common write path, as to
catch non-direct IO.

Fixes: c34fc6f26ab8 ("fs: Initial atomic write support")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20241019125113.369994-3-john.g.garry@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/fops.c
fs/read_write.c
include/linux/fs.h