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

From: Christoph Hellwig
Date: Thu Sep 22 2022 - 10:40:03 EST


On Thu, Sep 22, 2022 at 03:22:48AM +0100, Al Viro wrote:
> What I'd like to have is the understanding of the places where we drop
> the references acquired by iov_iter_get_pages(). How do we decide
> whether to unpin?

Add a iov_iter_unpin_pages that does the right thing based on the
type. (block will need a modified copy of it as it doesn't keep
the pages array around, but logic will be the same).

> E.g. pipe_buffer carries a reference to page and no
> way to tell whether it's a pinned one; results of iov_iter_get_pages()
> on ITER_IOVEC *can* end up there, but thankfully only from data-source
> (== WRITE, aka. ITER_SOURCE) iov_iter. So for those we don't care.
> Then there's nfs_request; AFAICS, we do need to pin the references in
> those if they are coming from nfs_direct_read_schedule_iovec(), but
> not if they come from readpage_async_filler(). How do we deal with
> coalescence, etc.? It's been a long time since I really looked at
> that code... Christoph, could you give any comments on that one?

I think the above should work, but I'll need to look at the NFS code
in more detail to be sure.