Skip to content

Commit 044a840

Browse files
Vitaliy Filippovkawasaki
authored andcommitted
fs: remove power of 2 and length boundary atomic write restrictions
generic_atomic_write_valid() returns EINVAL for non-power-of-2 and for non-length-aligned writes. This check is used for block devices, ext4 and xfs, but neither ext4 nor xfs rely on power of 2 restrictions. For block devices, neither NVMe nor SCSI specification doesn't require length alignment and 2^N length. Both specifications only require to respect the atomic write boundary if it's set (NABSPF/NABO for NVMe and ATOMIC BOUNDARY for SCSI). NVMe subsystem already checks writes against this boundary; SCSI uses an explicit atomic write command so the write is checked by the drive itself. Signed-off-by: Vitaliy Filippov <[email protected]>
1 parent 0ab4e8c commit 044a840

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

fs/read_write.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,17 +1802,9 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out)
18021802

18031803
int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter)
18041804
{
1805-
size_t len = iov_iter_count(iter);
1806-
18071805
if (!iter_is_ubuf(iter))
18081806
return -EINVAL;
18091807

1810-
if (!is_power_of_2(len))
1811-
return -EINVAL;
1812-
1813-
if (!IS_ALIGNED(iocb->ki_pos, len))
1814-
return -EINVAL;
1815-
18161808
if (!(iocb->ki_flags & IOCB_DIRECT))
18171809
return -EOPNOTSUPP;
18181810

0 commit comments

Comments
 (0)