[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4be974aa-2beb-9ae5-3f48-7dde6241b0c7@nvidia.com>
Date: Tue, 24 Jan 2023 12:50:18 -0800
From: John Hubbard <jhubbard@...dia.com>
To: David Howells <dhowells@...hat.com>,
Al Viro <viro@...iv.linux.org.uk>,
Christoph Hellwig <hch@...radead.org>
CC: Matthew Wilcox <willy@...radead.org>, Jens Axboe <axboe@...nel.dk>,
"Jan Kara" <jack@...e.cz>, Jeff Layton <jlayton@...nel.org>,
David Hildenbrand <david@...hat.com>,
Jason Gunthorpe <jgg@...dia.com>,
Logan Gunthorpe <logang@...tatee.com>,
<linux-fsdevel@...r.kernel.org>, <linux-block@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, "Christoph Hellwig" <hch@....de>,
<linux-mm@...ck.org>
Subject: Re: [PATCH v9 2/8] iov_iter: Add a function to extract a page list
from an iterator
On 1/24/23 09:01, David Howells wrote:
...
> +/*
> + * Extract a list of contiguous pages from an ITER_BVEC iterator. This does
> + * not get references on the pages, nor does it get a pin on them.
> + */
> +static ssize_t iov_iter_extract_bvec_pages(struct iov_iter *i,
> + struct page ***pages, size_t maxsize,
> + unsigned int maxpages,
> + unsigned int extraction_flags,
> + size_t *offset0)
> +{
> + struct page **p, *page;
> + size_t skip = i->iov_offset, offset;
> + int k;
> +
> + for (;;) {
> + if (i->nr_segs == 0)
> + return 0;
> + maxsize = min(maxsize, i->bvec->bv_len - skip);
> + if (maxsize)
> + break;
> + i->iov_offset = 0;
> + i->nr_segs--;
> + i->kvec++;
> + skip = 0;
> + }
> +
> + skip += i->bvec->bv_offset;
> + page = i->bvec->bv_page + skip / PAGE_SIZE;
> + offset = skip % PAGE_SIZE;
> + *offset0 = offset;
> +
> + maxpages = want_pages_array(pages, maxsize, offset, maxpages);
> + if (!maxpages)
> + return -ENOMEM;
Is it OK that the iov_iter position has been advanced, and left that way,
in the case of an early -ENOMEM return here?
thanks,
--
John Hubbard
NVIDIA
Powered by blists - more mailing lists