Skip to content

Commit 30dac24

Browse files
Panky-codesbrauner
authored andcommitted
fs/writeback: convert wbc_account_cgroup_owner to take a folio
Most of the callers of wbc_account_cgroup_owner() are converting a folio to page before calling the function. wbc_account_cgroup_owner() is converting the page back to a folio to call mem_cgroup_css_from_folio(). Convert wbc_account_cgroup_owner() to take a folio instead of a page, and convert all callers to pass a folio directly except f2fs. Convert the page to folio for all the callers from f2fs as they were the only callers calling wbc_account_cgroup_owner() with a page. As f2fs is already in the process of converting to folios, these call sites might also soon be calling wbc_account_cgroup_owner() with a folio directly in the future. No functional changes. Only compile tested. Signed-off-by: Pankaj Raghav <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: David Sterba <[email protected]> Acked-by: Tejun Heo <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 8c6e03f commit 30dac24

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ following two functions.
29452945
a queue (device) has been associated with the bio and
29462946
before submission.
29472947

2948-
wbc_account_cgroup_owner(@wbc, @page, @bytes)
2948+
wbc_account_cgroup_owner(@wbc, @folio, @bytes)
29492949
Should be called for each data segment being written out.
29502950
While this function doesn't care exactly when it's called
29512951
during the writeback session, it's the easiest and most

fs/btrfs/extent_io.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ static void submit_extent_folio(struct btrfs_bio_ctrl *bio_ctrl,
785785
}
786786

787787
if (bio_ctrl->wbc)
788-
wbc_account_cgroup_owner(bio_ctrl->wbc, &folio->page,
788+
wbc_account_cgroup_owner(bio_ctrl->wbc, folio,
789789
len);
790790

791791
size -= len;
@@ -1707,7 +1707,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
17071707
ret = bio_add_folio(&bbio->bio, folio, eb->len,
17081708
eb->start - folio_pos(folio));
17091709
ASSERT(ret);
1710-
wbc_account_cgroup_owner(wbc, folio_page(folio, 0), eb->len);
1710+
wbc_account_cgroup_owner(wbc, folio, eb->len);
17111711
folio_unlock(folio);
17121712
} else {
17131713
int num_folios = num_extent_folios(eb);
@@ -1721,8 +1721,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
17211721
folio_start_writeback(folio);
17221722
ret = bio_add_folio(&bbio->bio, folio, eb->folio_size, 0);
17231723
ASSERT(ret);
1724-
wbc_account_cgroup_owner(wbc, folio_page(folio, 0),
1725-
eb->folio_size);
1724+
wbc_account_cgroup_owner(wbc, folio, eb->folio_size);
17261725
wbc->nr_to_write -= folio_nr_pages(folio);
17271726
folio_unlock(folio);
17281727
}

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode,
17291729
* need full accuracy. Just account the whole thing
17301730
* against the first page.
17311731
*/
1732-
wbc_account_cgroup_owner(wbc, &locked_folio->page,
1732+
wbc_account_cgroup_owner(wbc, locked_folio,
17331733
cur_end - start);
17341734
async_chunk[i].locked_folio = locked_folio;
17351735
locked_folio = NULL;

fs/buffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,7 @@ static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
28032803
bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
28042804
bio->bi_write_hint = write_hint;
28052805

2806-
__bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh));
2806+
bio_add_folio_nofail(bio, bh->b_folio, bh->b_size, bh_offset(bh));
28072807

28082808
bio->bi_end_io = end_bio_bh_io_sync;
28092809
bio->bi_private = bh;
@@ -2813,7 +2813,7 @@ static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
28132813

28142814
if (wbc) {
28152815
wbc_init_bio(wbc, bio);
2816-
wbc_account_cgroup_owner(wbc, bh->b_page, bh->b_size);
2816+
wbc_account_cgroup_owner(wbc, bh->b_folio, bh->b_size);
28172817
}
28182818

28192819
submit_bio(bio);

fs/ext4/page-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static void io_submit_add_bh(struct ext4_io_submit *io,
421421
io_submit_init_bio(io, bh);
422422
if (!bio_add_folio(io->io_bio, io_folio, bh->b_size, bh_offset(bh)))
423423
goto submit_and_retry;
424-
wbc_account_cgroup_owner(io->io_wbc, &folio->page, bh->b_size);
424+
wbc_account_cgroup_owner(io->io_wbc, folio, bh->b_size);
425425
io->io_next_block++;
426426
}
427427

fs/f2fs/data.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,8 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
711711
}
712712

713713
if (fio->io_wbc && !is_read_io(fio->op))
714-
wbc_account_cgroup_owner(fio->io_wbc, fio->page, PAGE_SIZE);
714+
wbc_account_cgroup_owner(fio->io_wbc, page_folio(fio->page),
715+
PAGE_SIZE);
715716

716717
inc_page_count(fio->sbi, is_read_io(fio->op) ?
717718
__read_io_type(page) : WB_DATA_TYPE(fio->page, false));
@@ -911,7 +912,8 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio)
911912
}
912913

913914
if (fio->io_wbc)
914-
wbc_account_cgroup_owner(fio->io_wbc, fio->page, PAGE_SIZE);
915+
wbc_account_cgroup_owner(fio->io_wbc, page_folio(fio->page),
916+
PAGE_SIZE);
915917

916918
inc_page_count(fio->sbi, WB_DATA_TYPE(page, false));
917919

@@ -1011,7 +1013,8 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
10111013
}
10121014

10131015
if (fio->io_wbc)
1014-
wbc_account_cgroup_owner(fio->io_wbc, fio->page, PAGE_SIZE);
1016+
wbc_account_cgroup_owner(fio->io_wbc, page_folio(fio->page),
1017+
PAGE_SIZE);
10151018

10161019
io->last_block_in_bio = fio->new_blkaddr;
10171020

fs/fs-writeback.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -890,17 +890,16 @@ EXPORT_SYMBOL_GPL(wbc_detach_inode);
890890
/**
891891
* wbc_account_cgroup_owner - account writeback to update inode cgroup ownership
892892
* @wbc: writeback_control of the writeback in progress
893-
* @page: page being written out
893+
* @folio: folio being written out
894894
* @bytes: number of bytes being written out
895895
*
896-
* @bytes from @page are about to written out during the writeback
896+
* @bytes from @folio are about to written out during the writeback
897897
* controlled by @wbc. Keep the book for foreign inode detection. See
898898
* wbc_detach_inode().
899899
*/
900-
void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page,
900+
void wbc_account_cgroup_owner(struct writeback_control *wbc, struct folio *folio,
901901
size_t bytes)
902902
{
903-
struct folio *folio;
904903
struct cgroup_subsys_state *css;
905904
int id;
906905

@@ -913,7 +912,6 @@ void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page,
913912
if (!wbc->wb || wbc->no_cgroup_owner)
914913
return;
915914

916-
folio = page_folio(page);
917915
css = mem_cgroup_css_from_folio(folio);
918916
/* dead cgroups shouldn't contribute to inode ownership arbitration */
919917
if (!(css->flags & CSS_ONLINE))

fs/iomap/buffered-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ static int iomap_add_to_ioend(struct iomap_writepage_ctx *wpc,
18331833
if (ifs)
18341834
atomic_add(len, &ifs->write_bytes_pending);
18351835
wpc->ioend->io_size += len;
1836-
wbc_account_cgroup_owner(wbc, &folio->page, len);
1836+
wbc_account_cgroup_owner(wbc, folio, len);
18371837
return 0;
18381838
}
18391839

fs/mpage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,
606606
* the confused fail path above (OOM) will be very confused when
607607
* it finds all bh marked clean (i.e. it will not write anything)
608608
*/
609-
wbc_account_cgroup_owner(wbc, &folio->page, folio_size(folio));
609+
wbc_account_cgroup_owner(wbc, folio, folio_size(folio));
610610
length = first_unmapped << blkbits;
611611
if (!bio_add_folio(bio, folio, length, 0)) {
612612
bio = mpage_bio_submit_write(bio);

include/linux/writeback.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
217217
struct inode *inode)
218218
__releases(&inode->i_lock);
219219
void wbc_detach_inode(struct writeback_control *wbc);
220-
void wbc_account_cgroup_owner(struct writeback_control *wbc, struct page *page,
220+
void wbc_account_cgroup_owner(struct writeback_control *wbc, struct folio *folio,
221221
size_t bytes);
222222
int cgroup_writeback_by_id(u64 bdi_id, int memcg_id,
223223
enum wb_reason reason, struct wb_completion *done);
@@ -324,7 +324,7 @@ static inline void wbc_init_bio(struct writeback_control *wbc, struct bio *bio)
324324
}
325325

326326
static inline void wbc_account_cgroup_owner(struct writeback_control *wbc,
327-
struct page *page, size_t bytes)
327+
struct folio *folio, size_t bytes)
328328
{
329329
}
330330

0 commit comments

Comments
 (0)