lkml.org 
[lkml]   [2022]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 1/2] btrfs: factor out allocating an array of pages
On Wed, Mar 30, 2022 at 04:11:22PM -0400, Sweet Tea Dorminy wrote:
> +/**
> + * Populate every slot in a provided array with pages.
> + *
> + * @nr_pages: the number of pages to request
> + * @page_array: the array to fill with pages; any existing non-null entries in
> + * the array will be skipped
> + *
> + * Return: 0 if all pages were able to be allocated; -ENOMEM otherwise, and the
> + * caller is responsible for freeing all non-null page pointers in the array.
> + */
> +int btrfs_alloc_page_array(unsigned long nr_pages, struct page **page_array)

I've switched nr_pages to 'unsigned int', that's what all callers use
and I don't see a reason for long.

> +{
> + int i;
> +
> + for (i = 0; i < nr_pages; i++) {
> + struct page *page;
> +
> + if (page_array[i])
> + continue;
> + page = alloc_page(GFP_NOFS);
> + if (!page)
> + return -ENOMEM;
> + page_array[i] = page;
> + }
> + return 0;
> +}

\
 
 \ /
  Last update: 2022-03-31 19:30    [W:0.052 / U:0.980 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site