lkml.org 
[lkml]   [2022]   [May]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] fs: prefer read_iter over read and write_iter over write
On Fri, May 20, 2022 at 03:51:03PM +0200, Jason A. Donenfeld wrote:
> Most kernel code prefers read_iter over read and write_iter over write,
> yet the read function pointer is tested first. Reverse these so that the
> iter function is always used first.

NAK. There are some weird devices (at the very least, one in sound)
where data gets interpreted differently for write() and writev().
There are several degrees of messiness:
1) packet-like semantics, where boundaries of iovecs are
significant; writev() is equivalent to loop of write() calls, but
*NOT* to write() on a single concatenated copy. _Any_ short write
on any segment (due to ->write() instance ignoring the rest of data
as well as due to unmapped page halfway through) terminates writev().
2) similar, but more extreme - write() reports consuming all
the data it's been given (assuming the damn thing parses) and
ignores the excess. writev() is equivalent to iterated write() on
all segments, as long as each is valid. Not uncommon, sadly...
3) completely unrelated interpretations of input for write()
and for writev(). writev() is *NOT* equivalent to a loop of write()
there. Yes, such beasts exist. And it's a user-visible ABI.
Example: snd_pcm_write() vs. snd_pcm_writev(). Not a chance to
retire that one any time soon, and the difference in semantics is
that writev() is "feed several channels at once; the chunks for
individual channels are covered by elements of iovec array".
Worse one: qib_write() and qib_write_iter(). There we flat-out
have different command sets for write() and for writev(). That,
at least, might be possible to retire someday.

IIRC, for pcm the readv() vs. read() differences are same as for
writev() vs. write() - parallel reads from different channels,
each to its own iovec.

It's a bad userland ABI design, but we are stuck with it - it's a couple
of decades too late to change.

\
 
 \ /
  Last update: 2022-05-20 17:05    [W:0.252 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site