Messages in this thread | | | Date | Thu, 31 Mar 2022 19:26:00 +0200 | From | David Sterba <> | Subject | Re: [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; > +}
| |