Re: [PATCH v2 4/7] iov_iter: new iov_iter_pin_pages*() routines

Al Viro
2022-09-22T14:37:43Z

On Thu, Sep 22, 2022 at 07:31:36AM -0700, Christoph Hellwig wrote:
> On Wed, Sep 14, 2022 at 04:51:17AM +0100, Al Viro wrote:
> > Unless I'm misreading Jan, the question is whether they should get or
> > pin.
>
> And I think the answer is: inside ->read_iter or ->write_iter they
> should neither get or pin. The callers of it need to pin the pages
> if they are pagecache pages that can potentially be written to through
> shared mappings, else a get would be enough. But the method instance
> should not have to care and just be able to rely on the caller making
> sure they do not go away.

The interesting part, AFAICS, is where do we _unpin_ them and how do
we keep track which pages (obtained from iov_iter_get_pages et.al.)
need to be unpinned.

> > I'm really tempted to slap
> > if (WARN_ON(i->data_source))
> > return 0;
> > into copy_to_iter() et.al., along with its opposite for copy_from_iter().
>
> Ys, I think that would be useful. And we could use something more
> descriptive than READ/WRITE to start with.

See #work.iov_iter; done, but it took a bit of fixing the places that
create iov_iter instances.