io_uring/memmap: return bool from io_mem_alloc_compound()
io_mem_alloc_compound() returns either ERR_PTR(-ENOMEM) or a virtual address for the allocated memory, but its caller just checks whether the result is an error. Return a bool success value instead. Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>pull/1354/merge
parent
ffce324364
commit
4b25b75c30
|
|
@ -15,26 +15,26 @@
|
|||
#include "rsrc.h"
|
||||
#include "zcrx.h"
|
||||
|
||||
static void *io_mem_alloc_compound(struct page **pages, int nr_pages,
|
||||
size_t size, gfp_t gfp)
|
||||
static bool io_mem_alloc_compound(struct page **pages, int nr_pages,
|
||||
size_t size, gfp_t gfp)
|
||||
{
|
||||
struct page *page;
|
||||
int i, order;
|
||||
|
||||
order = get_order(size);
|
||||
if (order > MAX_PAGE_ORDER)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return false;
|
||||
else if (order)
|
||||
gfp |= __GFP_COMP;
|
||||
|
||||
page = alloc_pages(gfp, order);
|
||||
if (!page)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return false;
|
||||
|
||||
for (i = 0; i < nr_pages; i++)
|
||||
pages[i] = page + i;
|
||||
|
||||
return page_address(page);
|
||||
return true;
|
||||
}
|
||||
|
||||
struct page **io_pin_pages(unsigned long uaddr, unsigned long len, int *npages)
|
||||
|
|
@ -159,14 +159,12 @@ static int io_region_allocate_pages(struct io_ring_ctx *ctx,
|
|||
size_t size = (size_t) mr->nr_pages << PAGE_SHIFT;
|
||||
unsigned long nr_allocated;
|
||||
struct page **pages;
|
||||
void *p;
|
||||
|
||||
pages = kvmalloc_array(mr->nr_pages, sizeof(*pages), gfp);
|
||||
if (!pages)
|
||||
return -ENOMEM;
|
||||
|
||||
p = io_mem_alloc_compound(pages, mr->nr_pages, size, gfp);
|
||||
if (!IS_ERR(p)) {
|
||||
if (io_mem_alloc_compound(pages, mr->nr_pages, size, gfp)) {
|
||||
mr->flags |= IO_REGION_F_SINGLE_REF;
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue