Re: [PATCH 2/2] iomap: remove the atomic write length check in iomap_dio_bio_iter_one()
From: Tal Zussman
Date: Mon Nov 09 2026 - 17:46:50 EST
On 11/9/26 1:44 PM, John Garry wrote:
>>
>>> This looks ok. But I am just thinking that a CoW-based atomic write does
>>> not have the single bio restriction, so we don't need to fail the atomic
>>> in this case. However, we should have consistent rules for iovec's
>>> whether it's a block device or regular file for ext4 or xfs, so this
>>> makes sense.
>>>
>>> thanks
>>>
>>> BTW, you could be a real hero and add an xfstests case for this also.
>>>
>>
>> What specifically would you want to see tested? I can do an atomic write with
>> a partially unmapped buffer, with and without stable writes, and check that it
>> fails and that nothing is written.
>
> Just something similar to the blktests case which you added.
>
Sounds good, I'll add it to the queue.
> BTW, have you tested this partially-unmapped case for CoW-based atomics
> on xfs? You can just do that by setting atomic_wr=0
>
Yeah, I just tested it. It behaves as expected: returns -EFAULT with the file
unchanged, both with and without bouncing.
The single-bio check depends on REQ_ATOMIC, which only the HW atomic path sets,
so it doesn't apply to CoW writes, both before and after this series.
In terms of consistency, the unmapped buffer returns -EINVAL on the non-bounce
HW path (from bio_iov_iter_get_pages()) but -EFAULT for all other paths. That
should probably be made consistent across HW and SW and bounce vs. non-bounce,
but that's a separate change.
Thanks,
Tal
> Thanks,
> John
>
>>
>>>> ---
>>>> fs/iomap/direct-io.c | 14 --------------
>>>> 1 file changed, 14 deletions(-)
>>>>
>>>> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
>>>> index ad041ac3252a..aca7cbaea4af 100644
>>>> --- a/fs/iomap/direct-io.c
>>>> +++ b/fs/iomap/direct-io.c
>>>> @@ -370,15 +370,6 @@ static ssize_t iomap_dio_bio_iter_one(struct iomap_iter *iter,
>>>> goto out_put_bio;
>>>> ret = bio->bi_iter.bi_size;
>>>>
>>>> - /*
>>>> - * An atomic write bio must cover the complete length. If it doesn't,
>>>> - * error out.
>>>> - */
>>>> - if ((op & REQ_ATOMIC) && WARN_ON_ONCE(ret != iomap_length(iter))) {
>>>> - ret = -EINVAL;
>>>> - goto out_bio_release_pages;
>>>> - }
>>>> -
>>>> if (dio->flags & IOMAP_DIO_WRITE)
>>>> task_io_account_write(ret);
>>>> else if ((dio->flags & IOMAP_DIO_USER_BACKED) &&
>>>> @@ -393,11 +384,6 @@ static ssize_t iomap_dio_bio_iter_one(struct iomap_iter *iter,
>>>> iomap_dio_submit_bio(iter, dio, bio, pos);
>>>> return ret;
>>>>
>>>> -out_bio_release_pages:
>>>> - if (dio->flags & IOMAP_DIO_BOUNCE)
>>>> - bio_free_folios(bio);
>>>> - else
>>>> - bio_release_pages(bio, false);
>>>> out_put_bio:
>>>> bio_put(bio);
>>>> return ret;
>>>>
>>>
>>
>