Re: [PATCH v2 12/12] use less confusing names for iov_iter direction initializers

Al Viro
2022-10-28T19:31:11Z

On Fri, Oct 28, 2022 at 11:35:06AM -0700, Linus Torvalds wrote:

> > Umm... How are you going to e.g. copy from ITER_DISCARD? I've no problem
> > with WARN_ON_ONCE(), but when the operation really can't be done, what
> > can we do except returning an error?
>
> Fair enough. But it's the "people got the direction wrong, but the
> code worked" case that I would want tyo make sure still works - just
> with a warning.
>
> Clearly the ITER_DISCARD didn't work before either, but all the cases
> in patches 1-10 were things that _worked_, just with entirely the
> wrong ->data_source (aka iov_iter_rw()) value.
>
> So things like copy_to_iter() should warn if it's not a READ (or
> ITER_DEST), but it should still copy into the destination described by
> the iter, in order to keep broken code working.
>
> That's simply because I worry that your patches 1-10 didn't actually
> catch every single case. I'm not actually sure how you found them all
> - did you have some automation, or was it with "boot and find warnings
> from the first version of patch 11/12"?

Went through the callers, replaced each with the right ITER_... (there's
not that many of them and they are fairly easy to review), then went
through mismatches and split their fixups into the beginning of the
series (READ -> ITER_SOURCE becoming READ -> WRITE -> ITER_SOURCE, that
is).

FWIW, there used to be one case where we really tried to copy the wrong
way - fixed a couple of cycles ago (f615625a44c4 "9p: handling Rerror
without copy_from_iter_full()"). No such catches this time...