[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220331172600.GE15609@twin.jikos.cz>
Date: Thu, 31 Mar 2022 19:26:00 +0200
From: David Sterba <dsterba@...e.cz>
To: Sweet Tea Dorminy <sweettea-kernel@...miny.me>
Cc: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>,
Nick Terrell <terrelln@...com>, linux-kernel@...r.kernel.org,
linux-btrfs@...r.kernel.org, kernel-team@...com,
Nikolay Borisov <nborisov@...e.com>
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;
> +}
Powered by blists - more mailing lists