Skip to content

Commit

Permalink
btrfs: fix btrfs_submit_compressed_write cgroup attribution
Browse files Browse the repository at this point in the history
This restores the logic from commit 46bcff2 ("btrfs: fix compressed
write bio blkcg attribution") which added cgroup attribution to btrfs
writeback. It also adds back the REQ_CGROUP_PUNT flag for these ios.

Fixes: 9150724 ("btrfs: determine stripe boundary at bio allocation time in btrfs_submit_compressed_write")
CC: [email protected] # 5.16+
Signed-off-by: Dennis Zhou <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
dennisszhou authored and kdave committed Apr 5, 2022
1 parent 168a2f7 commit acee08a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fs/btrfs/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
cb->orig_bio = NULL;
cb->nr_pages = nr_pages;

if (blkcg_css)
kthread_associate_blkcg(blkcg_css);

while (cur_disk_bytenr < disk_start + compressed_len) {
u64 offset = cur_disk_bytenr - disk_start;
unsigned int index = offset >> PAGE_SHIFT;
Expand All @@ -555,6 +558,8 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
bio = NULL;
goto finish_cb;
}
if (blkcg_css)
bio->bi_opf |= REQ_CGROUP_PUNT;
}
/*
* We should never reach next_stripe_start start as we will
Expand Down Expand Up @@ -612,6 +617,9 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
return 0;

finish_cb:
if (blkcg_css)
kthread_associate_blkcg(NULL);

if (bio) {
bio->bi_status = ret;
bio_endio(bio);
Expand Down

0 comments on commit acee08a

Please sign in to comment.