[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-btrfs
Subject: Re: [PATCH v3 1/2] btrfs: factor out allocating an array of pages
From: David Sterba <dsterba () suse ! cz>
Date: 2022-03-31 17:26:00
Message-ID: 20220331172600.GE15609 () twin ! jikos ! cz
[Download RAW message or body]
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;
> +}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic