Unverified Commit 30dac24e authored by Pankaj Raghav's avatar Pankaj Raghav Committed by Christian Brauner
Browse files

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: default avatarPankaj Raghav <p.raghav@samsung.com>
Link: https://lore.kernel.org/r/20240926140121.203821-1-kernel@pankajraghav.com


Acked-by: default avatarDavid Sterba <dsterba@suse.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 8c6e03ff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2945,7 +2945,7 @@ following two functions.
	a queue (device) has been associated with the bio and
	before submission.

  wbc_account_cgroup_owner(@wbc, @page, @bytes)
  wbc_account_cgroup_owner(@wbc, @folio, @bytes)
	Should be called for each data segment being written out.
	While this function doesn't care exactly when it's called
	during the writeback session, it's the easiest and most
+3 −4
Original line number Diff line number Diff line
@@ -785,7 +785,7 @@ static void submit_extent_folio(struct btrfs_bio_ctrl *bio_ctrl,
		}

		if (bio_ctrl->wbc)
			wbc_account_cgroup_owner(bio_ctrl->wbc, &folio->page,
			wbc_account_cgroup_owner(bio_ctrl->wbc, folio,
						 len);

		size -= len;
@@ -1707,7 +1707,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
		ret = bio_add_folio(&bbio->bio, folio, eb->len,
				    eb->start - folio_pos(folio));
		ASSERT(ret);
		wbc_account_cgroup_owner(wbc, folio_page(folio, 0), eb->len);
		wbc_account_cgroup_owner(wbc, folio, eb->len);
		folio_unlock(folio);
	} else {
		int num_folios = num_extent_folios(eb);
@@ -1721,8 +1721,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,
			folio_start_writeback(folio);
			ret = bio_add_folio(&bbio->bio, folio, eb->folio_size, 0);
			ASSERT(ret);
			wbc_account_cgroup_owner(wbc, folio_page(folio, 0),
						 eb->folio_size);
			wbc_account_cgroup_owner(wbc, folio, eb->folio_size);
			wbc->nr_to_write -= folio_nr_pages(folio);
			folio_unlock(folio);
		}
+1 −1
Original line number Diff line number Diff line
@@ -1729,7 +1729,7 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode,
			 * need full accuracy.  Just account the whole thing
			 * against the first page.
			 */
			wbc_account_cgroup_owner(wbc, &locked_folio->page,
			wbc_account_cgroup_owner(wbc, locked_folio,
						 cur_end - start);
			async_chunk[i].locked_folio = locked_folio;
			locked_folio = NULL;
+2 −2
Original line number Diff line number Diff line
@@ -2803,7 +2803,7 @@ static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
	bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
	bio->bi_write_hint = write_hint;

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

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

	if (wbc) {
		wbc_init_bio(wbc, bio);
		wbc_account_cgroup_owner(wbc, bh->b_page, bh->b_size);
		wbc_account_cgroup_owner(wbc, bh->b_folio, bh->b_size);
	}

	submit_bio(bio);
+1 −1
Original line number Diff line number Diff line
@@ -421,7 +421,7 @@ static void io_submit_add_bh(struct ext4_io_submit *io,
		io_submit_init_bio(io, bh);
	if (!bio_add_folio(io->io_bio, io_folio, bh->b_size, bh_offset(bh)))
		goto submit_and_retry;
	wbc_account_cgroup_owner(io->io_wbc, &folio->page, bh->b_size);
	wbc_account_cgroup_owner(io->io_wbc, folio, bh->b_size);
	io->io_next_block++;
}

Loading