Skip to content

Commit 0fbf6cb

Browse files
adam900710kdave
authored andcommitted
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: Filipe Manana <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent fea9113 commit 0fbf6cb

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

fs/btrfs/extent_io.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,21 +696,21 @@ int btrfs_alloc_folio_array(unsigned int nr_folios, struct folio **folio_array)
696696
}
697697

698698
/*
699-
* Populate every free slot in a provided array with pages.
699+
* Populate every free slot in a provided array with pages, using GFP_NOFS.
700700
*
701701
* @nr_pages: number of pages to allocate
702702
* @page_array: the array to fill with pages; any existing non-null entries in
703-
* the array will be skipped
704-
* @extra_gfp: the extra GFP flags for the allocation.
703+
* the array will be skipped
704+
* @nofail: whether using __GFP_NOFAIL flag
705705
*
706706
* Return: 0 if all pages were able to be allocated;
707707
* -ENOMEM otherwise, the partially allocated pages would be freed and
708708
* the array slots zeroed
709709
*/
710710
int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array,
711-
gfp_t extra_gfp)
711+
bool nofail)
712712
{
713-
const gfp_t gfp = GFP_NOFS | extra_gfp;
713+
const gfp_t gfp = nofail ? (GFP_NOFS | __GFP_NOFAIL) : GFP_NOFS;
714714
unsigned int allocated;
715715

716716
for (allocated = 0; allocated < nr_pages;) {
@@ -734,13 +734,13 @@ int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array,
734734
*
735735
* For now, the folios populated are always in order 0 (aka, single page).
736736
*/
737-
static int alloc_eb_folio_array(struct extent_buffer *eb, gfp_t extra_gfp)
737+
static int alloc_eb_folio_array(struct extent_buffer *eb, bool nofail)
738738
{
739739
struct page *page_array[INLINE_EXTENT_BUFFER_PAGES] = { 0 };
740740
int num_pages = num_extent_pages(eb);
741741
int ret;
742742

743-
ret = btrfs_alloc_page_array(num_pages, page_array, extra_gfp);
743+
ret = btrfs_alloc_page_array(num_pages, page_array, nofail);
744744
if (ret < 0)
745745
return ret;
746746

@@ -2722,7 +2722,7 @@ struct extent_buffer *btrfs_clone_extent_buffer(const struct extent_buffer *src)
27222722
*/
27232723
set_bit(EXTENT_BUFFER_UNMAPPED, &new->bflags);
27242724

2725-
ret = alloc_eb_folio_array(new, 0);
2725+
ret = alloc_eb_folio_array(new, false);
27262726
if (ret) {
27272727
btrfs_release_extent_buffer(new);
27282728
return NULL;
@@ -2755,7 +2755,7 @@ struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
27552755
if (!eb)
27562756
return NULL;
27572757

2758-
ret = alloc_eb_folio_array(eb, 0);
2758+
ret = alloc_eb_folio_array(eb, false);
27592759
if (ret)
27602760
goto err;
27612761

@@ -3121,7 +3121,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
31213121

31223122
reallocate:
31233123
/* Allocate all pages first. */
3124-
ret = alloc_eb_folio_array(eb, __GFP_NOFAIL);
3124+
ret = alloc_eb_folio_array(eb, true);
31253125
if (ret < 0) {
31263126
btrfs_free_subpage(prealloc);
31273127
goto out;

fs/btrfs/extent_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,
364364
struct extent_buffer *buf);
365365

366366
int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array,
367-
gfp_t extra_gfp);
367+
bool nofail);
368368
int btrfs_alloc_folio_array(unsigned int nr_folios, struct folio **folio_array);
369369

370370
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9128,7 +9128,7 @@ static ssize_t btrfs_encoded_read_regular(struct kiocb *iocb,
91289128
pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
91299129
if (!pages)
91309130
return -ENOMEM;
9131-
ret = btrfs_alloc_page_array(nr_pages, pages, 0);
9131+
ret = btrfs_alloc_page_array(nr_pages, pages, false);
91329132
if (ret) {
91339133
ret = -ENOMEM;
91349134
goto out;

fs/btrfs/raid56.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ static int alloc_rbio_pages(struct btrfs_raid_bio *rbio)
10511051
{
10521052
int ret;
10531053

1054-
ret = btrfs_alloc_page_array(rbio->nr_pages, rbio->stripe_pages, 0);
1054+
ret = btrfs_alloc_page_array(rbio->nr_pages, rbio->stripe_pages, false);
10551055
if (ret < 0)
10561056
return ret;
10571057
/* Mapping all sectors */
@@ -1066,7 +1066,7 @@ static int alloc_rbio_parity_pages(struct btrfs_raid_bio *rbio)
10661066
int ret;
10671067

10681068
ret = btrfs_alloc_page_array(rbio->nr_pages - data_pages,
1069-
rbio->stripe_pages + data_pages, 0);
1069+
rbio->stripe_pages + data_pages, false);
10701070
if (ret < 0)
10711071
return ret;
10721072

@@ -1640,7 +1640,7 @@ static int alloc_rbio_data_pages(struct btrfs_raid_bio *rbio)
16401640
const int data_pages = rbio->nr_data * rbio->stripe_npages;
16411641
int ret;
16421642

1643-
ret = btrfs_alloc_page_array(data_pages, rbio->stripe_pages, 0);
1643+
ret = btrfs_alloc_page_array(data_pages, rbio->stripe_pages, false);
16441644
if (ret < 0)
16451645
return ret;
16461646

fs/btrfs/scrub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static int init_scrub_stripe(struct btrfs_fs_info *fs_info,
261261
atomic_set(&stripe->pending_io, 0);
262262
spin_lock_init(&stripe->write_error_lock);
263263

264-
ret = btrfs_alloc_page_array(SCRUB_STRIPE_PAGES, stripe->pages, 0);
264+
ret = btrfs_alloc_page_array(SCRUB_STRIPE_PAGES, stripe->pages, false);
265265
if (ret < 0)
266266
goto error;
267267

0 commit comments

Comments
 (0)