Re: [PATCHSET RFC 0/437] Kill off old fops ->read() and ->write()

From: Jens Axboe
Date: Fri Apr 12 2024 - 09:58:25 EST


On 4/11/24 10:29 PM, Al Viro wrote:
> On Thu, Apr 11, 2024 at 09:12:20AM -0600, Jens Axboe wrote:
>> Hi,
>>
>> This patchset will obviously be split, commit messages updated, and
>> specific driver patches targeted to where they belong. But I figured
>> it'd be useful to blast out the full set at least once for reference,
>> and then I'll continue down the right path for the next one.
>>
>> Subject line says it all, really. 10 years ago we added ->read_iter()
>> and ->write_iter() to struct file_operations. These are great, as they
>> pass in an iov_iter rather than a user buffer + length, and they also
>> take a struct kiocb rather than just a file. Since then we've had two
>> paths for any read or write - one legacy one that can't do per-IO hints
>> like "This read should be non-blocking", they strictly only work with
>> O_NONBLOCK on the file, and a newer one that supports everything the
>> old path does and a bunch more. We've had a few issues with the
>> iov_iter based path being slower, but those have basically been
>> resolved with solutions like ITER_UBUF to optimize the single segment
>> case that is often the fast path.
>>
>> There are basically three parts to this series:
>>
>> 1) Add generic helpers that we need to convert drivers.
>> 2) Convert any use of fops->read() and ->write()
>> 3) Kill off old cruft.
>> 3a) Profit.
>
> The fundamental problem with that is that a bunch of drivers
> do care about the vector boundaries. Very much so. It's very
> common to have this kind of situation:
> write() parses the buffer sloppily, and ignores the junk in
> the end, claiming that everything that been written.
> writev() feeds each vector to write().
>
> From a cursory look through that pile, you seem to have broken
> writev() on at least some (if not all) of those.

I'm aware of some drivers that do different things from write vs writev,
or read vs readv for instance. But those I did cater to, by having a
flag they can now check.

Can you be a bit more specific on an example of a driver that does the
above?

--
Jens Axboe