mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
ext4: Check for atomic writes support in write iter
Let's validate the given constraints for atomic write request. Otherwise it will fail with -EINVAL. Currently atomic write is only supported on DIO, so for buffered-io it will return -EOPNOTSUPP. Reviewed-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Jan Kara <jack@suse.cz>
This commit is contained in:
committed by
Darrick J. Wong
parent
6dfc1c1d59
commit
43c696f9d0
@@ -692,6 +692,20 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
|
||||
if (IS_DAX(inode))
|
||||
return ext4_dax_write_iter(iocb, from);
|
||||
#endif
|
||||
|
||||
if (iocb->ki_flags & IOCB_ATOMIC) {
|
||||
size_t len = iov_iter_count(from);
|
||||
int ret;
|
||||
|
||||
if (len < EXT4_SB(inode->i_sb)->s_awu_min ||
|
||||
len > EXT4_SB(inode->i_sb)->s_awu_max)
|
||||
return -EINVAL;
|
||||
|
||||
ret = generic_atomic_write_valid(iocb, from);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (iocb->ki_flags & IOCB_DIRECT)
|
||||
return ext4_dio_write_iter(iocb, from);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user