io_uring/rsrc: use unpin_user_folio

We want to have a full folio to be left pinned but with only one
reference, for that we "unpin" all but the first page with
unpin_user_pages(), which can be confusing. There is a new helper to
achieve that called unpin_user_folio(), so use that.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Anuj Gupta <anuj20.g@samsung.com>
Link: https://lore.kernel.org/r/e0b2be8f9ea68f6b351ec3bb046f04f437f68491.1745083025.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
pull/1250/head
Pavel Begunkov 2025-04-19 18:47:04 +01:00 committed by Jens Axboe
parent 8a2dacd49f
commit ea76925614
1 changed files with 2 additions and 3 deletions

View File

@ -699,10 +699,9 @@ static bool io_coalesce_buffer(struct page ***pages, int *nr_pages,
* The pages are bound to the folio, it doesn't * The pages are bound to the folio, it doesn't
* actually unpin them but drops all but one reference, * actually unpin them but drops all but one reference,
* which is usually put down by io_buffer_unmap(). * which is usually put down by io_buffer_unmap().
* Note, needs a better helper.
*/ */
if (data->nr_pages_head > 1) if (data->nr_pages_head > 1)
unpin_user_pages(&page_array[1], data->nr_pages_head - 1); unpin_user_folio(page_folio(new_array[0]), data->nr_pages_head - 1);
j = data->nr_pages_head; j = data->nr_pages_head;
nr_pages_left -= data->nr_pages_head; nr_pages_left -= data->nr_pages_head;
@ -713,7 +712,7 @@ static bool io_coalesce_buffer(struct page ***pages, int *nr_pages,
nr_unpin = min_t(unsigned int, nr_pages_left - 1, nr_unpin = min_t(unsigned int, nr_pages_left - 1,
data->nr_pages_mid - 1); data->nr_pages_mid - 1);
if (nr_unpin) if (nr_unpin)
unpin_user_pages(&page_array[j+1], nr_unpin); unpin_user_folio(page_folio(new_array[i]), nr_unpin);
j += data->nr_pages_mid; j += data->nr_pages_mid;
nr_pages_left -= data->nr_pages_mid; nr_pages_left -= data->nr_pages_mid;
} }