diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-11-18 22:30:09 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-11-18 22:30:09 +0300 |
commit | 241c7ed4d4815cd7d9c52c8f97bf13181e32ca29 (patch) | |
tree | 60471eb5962d73e49236c6febba2f573771810ea /fs/read_write.c | |
parent | 7956186e751bc15541ede638008feedc0e427883 (diff) | |
parent | 54079430c5dbf041363ab39a0c254cd9e4f6aed5 (diff) | |
download | linux-241c7ed4d4815cd7d9c52c8f97bf13181e32ca29.tar.xz |
Merge tag 'vfs-6.13.untorn.writes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs untorn write support from Christian Brauner:
"An atomic write is a write issed with torn-write protection. This
means for a power failure or any hardware failure all or none of the
data from the write will be stored, never a mix of old and new data.
This work is already supported for block devices. If a block device is
opened with O_DIRECT and the block device supports atomic write, then
FMODE_CAN_ATOMIC_WRITE is added to the file of the opened block
device.
This contains the work to expand atomic write support to filesystems,
specifically ext4 and XFS. Currently, only support for writing exactly
one filesystem block atomically is added.
Since it's now possible to have filesystem block size > page size for
XFS, it's possible to write 4K+ blocks atomically on x86"
* tag 'vfs-6.13.untorn.writes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
iomap: drop an obsolete comment in iomap_dio_bio_iter
ext4: Do not fallback to buffered-io for DIO atomic write
ext4: Support setting FMODE_CAN_ATOMIC_WRITE
ext4: Check for atomic writes support in write iter
ext4: Add statx support for atomic writes
xfs: Support setting FMODE_CAN_ATOMIC_WRITE
xfs: Validate atomic writes
xfs: Support atomic write for statx
fs: iomap: Atomic write support
fs: Export generic_atomic_write_valid()
block: Add bdev atomic write limits helpers
fs/block: Check for IOCB_DIRECT in generic_atomic_write_valid()
block/fs: Pass an iocb to generic_atomic_write_valid()
Diffstat (limited to 'fs/read_write.c')
-rw-r--r-- | fs/read_write.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index 64dc24afdb3a..3e5dad12a5b4 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1830,18 +1830,22 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out) return 0; } -bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos) +int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) { size_t len = iov_iter_count(iter); if (!iter_is_ubuf(iter)) - return false; + return -EINVAL; if (!is_power_of_2(len)) - return false; + return -EINVAL; + + if (!IS_ALIGNED(iocb->ki_pos, len)) + return -EINVAL; - if (!IS_ALIGNED(pos, len)) - return false; + if (!(iocb->ki_flags & IOCB_DIRECT)) + return -EOPNOTSUPP; - return true; + return 0; } +EXPORT_SYMBOL_GPL(generic_atomic_write_valid); |