Commit 0fbf6cbd authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: rename the extra_gfp parameter of btrfs_alloc_page_array()

There is only one caller utilizing the @extra_gfp parameter,
alloc_eb_folio_array().  And in that case the extra_gfp is only assigned
to __GFP_NOFAIL.

Rename the @extra_gfp parameter to @nofail to indicate that.
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent fea91134
...@@ -696,21 +696,21 @@ int btrfs_alloc_folio_array(unsigned int nr_folios, struct folio **folio_array) ...@@ -696,21 +696,21 @@ int btrfs_alloc_folio_array(unsigned int nr_folios, struct folio **folio_array)
} }
/* /*
* Populate every free slot in a provided array with pages. * Populate every free slot in a provided array with pages, using GFP_NOFS.
* *
* @nr_pages: number of pages to allocate * @nr_pages: number of pages to allocate
* @page_array: the array to fill with pages; any existing non-null entries in * @page_array: the array to fill with pages; any existing non-null entries in
* the array will be skipped * the array will be skipped
* @extra_gfp: the extra GFP flags for the allocation. * @nofail: whether using __GFP_NOFAIL flag
* *
* Return: 0 if all pages were able to be allocated; * Return: 0 if all pages were able to be allocated;
* -ENOMEM otherwise, the partially allocated pages would be freed and * -ENOMEM otherwise, the partially allocated pages would be freed and
* the array slots zeroed * the array slots zeroed
*/ */
int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array, int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array,
gfp_t extra_gfp) bool nofail)
{ {
const gfp_t gfp = GFP_NOFS | extra_gfp; const gfp_t gfp = nofail ? (GFP_NOFS | __GFP_NOFAIL) : GFP_NOFS;
unsigned int allocated; unsigned int allocated;
for (allocated = 0; allocated < nr_pages;) { for (allocated = 0; allocated < nr_pages;) {
...@@ -734,13 +734,13 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array, ...@@ -734,13 +734,13 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array,
* *
* For now, the folios populated are always in order 0 (aka, single page). * For now, the folios populated are always in order 0 (aka, single page).
*/ */
static int alloc_eb_folio_array(struct extent_buffer *eb, gfp_t extra_gfp) static int alloc_eb_folio_array(struct extent_buffer *eb, bool nofail)
{ {
struct page *page_array[INLINE_EXTENT_BUFFER_PAGES] = { 0 }; struct page *page_array[INLINE_EXTENT_BUFFER_PAGES] = { 0 };
int num_pages = num_extent_pages(eb); int num_pages = num_extent_pages(eb);
int ret; int ret;
ret = btrfs_alloc_page_array(num_pages, page_array, extra_gfp); ret = btrfs_alloc_page_array(num_pages, page_array, nofail);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -2722,7 +2722,7 @@ struct extent_buffer *btrfs_clone_extent_buffer(const struct extent_buffer *src) ...@@ -2722,7 +2722,7 @@ struct extent_buffer *btrfs_clone_extent_buffer(const struct extent_buffer *src)
*/ */
set_bit(EXTENT_BUFFER_UNMAPPED, &new->bflags); set_bit(EXTENT_BUFFER_UNMAPPED, &new->bflags);
ret = alloc_eb_folio_array(new, 0); ret = alloc_eb_folio_array(new, false);
if (ret) { if (ret) {
btrfs_release_extent_buffer(new); btrfs_release_extent_buffer(new);
return NULL; return NULL;
...@@ -2755,7 +2755,7 @@ struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -2755,7 +2755,7 @@ struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
if (!eb) if (!eb)
return NULL; return NULL;
ret = alloc_eb_folio_array(eb, 0); ret = alloc_eb_folio_array(eb, false);
if (ret) if (ret)
goto err; goto err;
...@@ -3121,7 +3121,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -3121,7 +3121,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
reallocate: reallocate:
/* Allocate all pages first. */ /* Allocate all pages first. */
ret = alloc_eb_folio_array(eb, __GFP_NOFAIL); ret = alloc_eb_folio_array(eb, true);
if (ret < 0) { if (ret < 0) {
btrfs_free_subpage(prealloc); btrfs_free_subpage(prealloc);
goto out; goto out;
......
...@@ -364,7 +364,7 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans, ...@@ -364,7 +364,7 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,
struct extent_buffer *buf); struct extent_buffer *buf);
int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array, int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array,
gfp_t extra_gfp); bool nofail);
int btrfs_alloc_folio_array(unsigned int nr_folios, struct folio **folio_array); int btrfs_alloc_folio_array(unsigned int nr_folios, struct folio **folio_array);
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
......
...@@ -9128,7 +9128,7 @@ static ssize_t btrfs_encoded_read_regular(struct kiocb *iocb, ...@@ -9128,7 +9128,7 @@ static ssize_t btrfs_encoded_read_regular(struct kiocb *iocb,
pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS); pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
if (!pages) if (!pages)
return -ENOMEM; return -ENOMEM;
ret = btrfs_alloc_page_array(nr_pages, pages, 0); ret = btrfs_alloc_page_array(nr_pages, pages, false);
if (ret) { if (ret) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
......
...@@ -1051,7 +1051,7 @@ static int alloc_rbio_pages(struct btrfs_raid_bio *rbio) ...@@ -1051,7 +1051,7 @@ static int alloc_rbio_pages(struct btrfs_raid_bio *rbio)
{ {
int ret; int ret;
ret = btrfs_alloc_page_array(rbio->nr_pages, rbio->stripe_pages, 0); ret = btrfs_alloc_page_array(rbio->nr_pages, rbio->stripe_pages, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Mapping all sectors */ /* Mapping all sectors */
...@@ -1066,7 +1066,7 @@ static int alloc_rbio_parity_pages(struct btrfs_raid_bio *rbio) ...@@ -1066,7 +1066,7 @@ static int alloc_rbio_parity_pages(struct btrfs_raid_bio *rbio)
int ret; int ret;
ret = btrfs_alloc_page_array(rbio->nr_pages - data_pages, ret = btrfs_alloc_page_array(rbio->nr_pages - data_pages,
rbio->stripe_pages + data_pages, 0); rbio->stripe_pages + data_pages, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1640,7 +1640,7 @@ static int alloc_rbio_data_pages(struct btrfs_raid_bio *rbio) ...@@ -1640,7 +1640,7 @@ static int alloc_rbio_data_pages(struct btrfs_raid_bio *rbio)
const int data_pages = rbio->nr_data * rbio->stripe_npages; const int data_pages = rbio->nr_data * rbio->stripe_npages;
int ret; int ret;
ret = btrfs_alloc_page_array(data_pages, rbio->stripe_pages, 0); ret = btrfs_alloc_page_array(data_pages, rbio->stripe_pages, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -261,7 +261,7 @@ static int init_scrub_stripe(struct btrfs_fs_info *fs_info, ...@@ -261,7 +261,7 @@ static int init_scrub_stripe(struct btrfs_fs_info *fs_info,
atomic_set(&stripe->pending_io, 0); atomic_set(&stripe->pending_io, 0);
spin_lock_init(&stripe->write_error_lock); spin_lock_init(&stripe->write_error_lock);
ret = btrfs_alloc_page_array(SCRUB_STRIPE_PAGES, stripe->pages, 0); ret = btrfs_alloc_page_array(SCRUB_STRIPE_PAGES, stripe->pages, false);
if (ret < 0) if (ret < 0)
goto error; goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment