diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-03-13 21:58:14 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-04-15 16:10:26 +0200 |
commit | 1943f96b3816e0f0d3d6686374d6e1d617c8b42c (patch) | |
tree | d3a5fdc9ea0f1b535f459e65b866ea981ebf5db8 /io_uring/rsrc.c | |
parent | io_uring: use vmap() for ring mapping (diff) | |
download | linux-1943f96b3816e0f0d3d6686374d6e1d617c8b42c.tar.xz linux-1943f96b3816e0f0d3d6686374d6e1d617c8b42c.zip |
io_uring: unify io_pin_pages()
Move it into io_uring.c where it belongs, and use it in there as well
rather than have two implementations of this.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.c')
-rw-r--r-- | io_uring/rsrc.c | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c index 7b8a056f98ed..8a34181c97ab 100644 --- a/io_uring/rsrc.c +++ b/io_uring/rsrc.c @@ -870,42 +870,6 @@ static int io_buffer_account_pin(struct io_ring_ctx *ctx, struct page **pages, return ret; } -struct page **io_pin_pages(unsigned long ubuf, unsigned long len, int *npages) -{ - unsigned long start, end, nr_pages; - struct page **pages = NULL; - int ret; - - end = (ubuf + len + PAGE_SIZE - 1) >> PAGE_SHIFT; - start = ubuf >> PAGE_SHIFT; - nr_pages = end - start; - WARN_ON(!nr_pages); - - pages = kvmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL); - if (!pages) - return ERR_PTR(-ENOMEM); - - mmap_read_lock(current->mm); - ret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM, pages); - mmap_read_unlock(current->mm); - - /* success, mapped all pages */ - if (ret == nr_pages) { - *npages = nr_pages; - return pages; - } - - /* partial map, or didn't map anything */ - if (ret >= 0) { - /* if we did partial map, release any pages we did get */ - if (ret) - unpin_user_pages(pages, ret); - ret = -EFAULT; - } - kvfree(pages); - return ERR_PTR(ret); -} - static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, struct io_mapped_ubuf **pimu, struct page **last_hpage) |