Skip to content

Commit e1622a0

Browse files
Matthew Wilcox (Oracle)tytso
authored andcommitted
ext4: convert ext4_mb_init_cache() to take a folio
All callers now have a folio, so convert this function from operating on a page to operating on a folio. The folio is assumed to be a single page. Signe-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Link: https://lore.kernel.org/r/20240416172900.244637-4-willy@infradead.org Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 5eea586 commit e1622a0

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

fs/ext4/mballoc.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ static void mb_regenerate_buddy(struct ext4_buddy *e4b)
12741274
* for this page; do not hold this lock when calling this routine!
12751275
*/
12761276

1277-
static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
1277+
static int ext4_mb_init_cache(struct folio *folio, char *incore, gfp_t gfp)
12781278
{
12791279
ext4_group_t ngroups;
12801280
unsigned int blocksize;
@@ -1292,13 +1292,13 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
12921292
char *bitmap;
12931293
struct ext4_group_info *grinfo;
12941294

1295-
inode = page->mapping->host;
1295+
inode = folio->mapping->host;
12961296
sb = inode->i_sb;
12971297
ngroups = ext4_get_groups_count(sb);
12981298
blocksize = i_blocksize(inode);
12991299
blocks_per_page = PAGE_SIZE / blocksize;
13001300

1301-
mb_debug(sb, "init page %lu\n", page->index);
1301+
mb_debug(sb, "init folio %lu\n", folio->index);
13021302

13031303
groups_per_page = blocks_per_page >> 1;
13041304
if (groups_per_page == 0)
@@ -1313,9 +1313,9 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
13131313
} else
13141314
bh = &bhs;
13151315

1316-
first_group = page->index * blocks_per_page / 2;
1316+
first_group = folio->index * blocks_per_page / 2;
13171317

1318-
/* read all groups the page covers into the cache */
1318+
/* read all groups the folio covers into the cache */
13191319
for (i = 0, group = first_group; i < groups_per_page; i++, group++) {
13201320
if (group >= ngroups)
13211321
break;
@@ -1326,10 +1326,11 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
13261326
/*
13271327
* If page is uptodate then we came here after online resize
13281328
* which added some new uninitialized group info structs, so
1329-
* we must skip all initialized uptodate buddies on the page,
1329+
* we must skip all initialized uptodate buddies on the folio,
13301330
* which may be currently in use by an allocating task.
13311331
*/
1332-
if (PageUptodate(page) && !EXT4_MB_GRP_NEED_INIT(grinfo)) {
1332+
if (folio_test_uptodate(folio) &&
1333+
!EXT4_MB_GRP_NEED_INIT(grinfo)) {
13331334
bh[i] = NULL;
13341335
continue;
13351336
}
@@ -1353,7 +1354,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
13531354
err = err2;
13541355
}
13551356

1356-
first_block = page->index * blocks_per_page;
1357+
first_block = folio->index * blocks_per_page;
13571358
for (i = 0; i < blocks_per_page; i++) {
13581359
group = (first_block + i) >> 1;
13591360
if (group >= ngroups)
@@ -1374,7 +1375,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
13741375
* above
13751376
*
13761377
*/
1377-
data = page_address(page) + (i * blocksize);
1378+
data = folio_address(folio) + (i * blocksize);
13781379
bitmap = bh[group - first_group]->b_data;
13791380

13801381
/*
@@ -1389,8 +1390,8 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
13891390
if ((first_block + i) & 1) {
13901391
/* this is block of buddy */
13911392
BUG_ON(incore == NULL);
1392-
mb_debug(sb, "put buddy for group %u in page %lu/%x\n",
1393-
group, page->index, i * blocksize);
1393+
mb_debug(sb, "put buddy for group %u in folio %lu/%x\n",
1394+
group, folio->index, i * blocksize);
13941395
trace_ext4_mb_buddy_bitmap_load(sb, group);
13951396
grinfo->bb_fragments = 0;
13961397
memset(grinfo->bb_counters, 0,
@@ -1408,8 +1409,8 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
14081409
} else {
14091410
/* this is block of bitmap */
14101411
BUG_ON(incore != NULL);
1411-
mb_debug(sb, "put bitmap for group %u in page %lu/%x\n",
1412-
group, page->index, i * blocksize);
1412+
mb_debug(sb, "put bitmap for group %u in folio %lu/%x\n",
1413+
group, folio->index, i * blocksize);
14131414
trace_ext4_mb_bitmap_load(sb, group);
14141415

14151416
/* see comments in ext4_mb_put_pa() */
@@ -1427,7 +1428,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
14271428
incore = data;
14281429
}
14291430
}
1430-
SetPageUptodate(page);
1431+
folio_mark_uptodate(folio);
14311432

14321433
out:
14331434
if (bh) {
@@ -1539,7 +1540,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group, gfp_t gfp)
15391540
}
15401541

15411542
folio = e4b.bd_bitmap_folio;
1542-
ret = ext4_mb_init_cache(&folio->page, NULL, gfp);
1543+
ret = ext4_mb_init_cache(folio, NULL, gfp);
15431544
if (ret)
15441545
goto err;
15451546
if (!folio_test_uptodate(folio)) {
@@ -1558,7 +1559,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group, gfp_t gfp)
15581559
}
15591560
/* init buddy cache */
15601561
folio = e4b.bd_buddy_folio;
1561-
ret = ext4_mb_init_cache(&folio->page, e4b.bd_bitmap, gfp);
1562+
ret = ext4_mb_init_cache(folio, e4b.bd_bitmap, gfp);
15621563
if (ret)
15631564
goto err;
15641565
if (!folio_test_uptodate(folio)) {
@@ -1647,7 +1648,7 @@ ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group,
16471648
goto err;
16481649
}
16491650
if (!folio_test_uptodate(folio)) {
1650-
ret = ext4_mb_init_cache(&folio->page, NULL, gfp);
1651+
ret = ext4_mb_init_cache(folio, NULL, gfp);
16511652
if (ret) {
16521653
folio_unlock(folio);
16531654
goto err;
@@ -1690,7 +1691,7 @@ ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group,
16901691
goto err;
16911692
}
16921693
if (!folio_test_uptodate(folio)) {
1693-
ret = ext4_mb_init_cache(&folio->page, e4b->bd_bitmap,
1694+
ret = ext4_mb_init_cache(folio, e4b->bd_bitmap,
16941695
gfp);
16951696
if (ret) {
16961697
folio_unlock(folio);

0 commit comments

Comments
 (0)