btrfs: add back cgroup writeback support for metadata
PATCH 1/1 btrfs: add back cgroup writeback support for metadata
Commit c211fd861077 ("btrfs: don't use btrfs_bio_ctrl for extent buffer writing") removed support for cgroup association for metadata writeback. While cgroup interaction with metadata is somewhat questionable and not done by other file systems, any kind of change to this behaviour should not happen silently and under the hood, so bring it back.
--- fs/btrfs/extent_io.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/extent_io.c +4 -0
@@ -1820,6 +1820,8 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,REQ_OP_WRITE |REQ_META |wbc_to_write_flags (wbc), eb->fs_info, extent_buffer_write_end_io, eb); bbio->bio.bi_iter.bi_sector = eb->start >>SECTOR_SHIFT ; +bio_set_dev (&bbio->bio, fs_info->fs_devices->latest_dev->bdev); +wbc_init_bio (wbc, &bbio->bio); bbio->inode =BTRFS_I (eb->fs_info->btree_inode); bbio->file_offset = eb->start;if (fs_info->nodesize <PAGE_SIZE ) {
@@ -1833,6 +1835,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb, wbc->nr_to_write--; }__bio_add_page (&bbio->bio, p, eb->len, eb->start -page_offset (p)); +wbc_account_cgroup_owner (wbc, p, eb->len);unlock_page (p); }else {for (int i =0 ; i <num_extent_pages (eb); i++) {
@@ -1842,6 +1845,7 @@ static noinline_for_stack void write_one_eb(struct extent_buffer *eb,clear_page_dirty_for_io (p);set_page_writeback (p);__bio_add_page (&bbio->bio, p,PAGE_SIZE ,0 ); +wbc_account_cgroup_owner (wbc, p,PAGE_SIZE ); wbc->nr_to_write--;unlock_page (p); }
Signature · 1 line
2.39.2
Quoted 7 lines · Christoph Hellwig
Commit
c211fd861077("btrfs: don't usebtrfs_bio_ctrlfor extent buffer writing") removed support for cgroup association for metadata writeback. While cgroup interaction with metadata is somewhat questionable and not done by other file systems, any kind of change to this behaviour should not happen silently and under the hood, so bring it back.Fixes c211fd861077 ("btrfs: don't use btrfs_bio_ctrl for extent buffer writing")
Folded to the patch, thanks.