From: John Garry <john.g.garry@oracle.com>
To: Vitaliy Filippov <vitalifster@gmail.com>,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: remove power of 2 and length boundary atomic write restrictions
Date: Tue, 30 Dec 2025 07:54:23 +0000 [thread overview]
Message-ID: <cc83c3fa-1bee-48b0-bfda-3a807c0b46bd@oracle.com> (raw)
In-Reply-To: <20251224115312.27036-1-vitalifster@gmail.com>
On 24/12/2025 11:53, Vitaliy Filippov wrote:
> 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.
>
Yes, they do check it - this is a safeguard against being sent something
which cannot be atomically written. But we should not be sending
something to the driver or disk which cannot be atomically written. So
we are providing protection against kernel bugs.
The user should not be concerned about atomic boundaries. They should
not encounter a scenario where they try a write which crosses a boundary
(and cannot be atomically written). Hence the power-of-2 and alignment
rule to avoid this.
> Signed-off-by: Vitaliy Filippov <vitalifster@gmail.com>
> ---
> fs/read_write.c | 8 --------
> 1 file changed, 8 deletions(-)
>
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 833bae068770..5467d710108d 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -1802,17 +1802,9 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out)
>
> 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 -EINVAL;
>
> - if (!is_power_of_2(len))
> - return -EINVAL;
> -
> - if (!IS_ALIGNED(iocb->ki_pos, len))
> - return -EINVAL;
> -
> if (!(iocb->ki_flags & IOCB_DIRECT))
> return -EOPNOTSUPP;
>
next prev parent reply other threads:[~2025-12-30 7:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-24 11:53 [PATCH] fs: remove power of 2 and length boundary atomic write restrictions Vitaliy Filippov
2025-12-29 7:15 ` kernel test robot
2025-12-30 7:54 ` John Garry [this message]
2025-12-30 9:01 ` Vitaliy Filippov
2026-01-02 17:41 ` John Garry
2026-01-05 18:58 ` Vitaliy Filippov
2026-01-06 9:06 ` John Garry
2026-01-06 10:50 ` Vitaliy Filippov
2026-01-06 11:26 ` John Garry
2026-01-06 13:08 ` Vitaliy Filippov
2026-01-07 10:51 ` John Garry
2026-01-07 13:05 ` Vitaliy Filippov
2026-01-07 15:42 ` John Garry
2026-01-07 16:21 ` Vitaliy Filippov
2026-01-08 18:18 ` Vitaliy Filippov
2026-01-13 14:25 ` Vitaliy Filippov
2026-01-05 19:29 ` Vitaliy Filippov
2026-01-05 19:44 ` Vitaliy Filippov
2026-01-06 10:55 ` Vitaliy Filippov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cc83c3fa-1bee-48b0-bfda-3a807c0b46bd@oracle.com \
--to=john.g.garry@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=vitalifster@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox