From da2f0f74cf7d074e5a8918c8efdf6aba4a989b4a Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Thu, 2 Jul 2015 13:57:22 -0700 Subject: Btrfs: add support for blkio controllers This attaches accounting information to bios as we submit them so the new blkio controllers can throttle on btrfs filesystems. Not much is required, we're just associating bios with blkcgs during clone, calling wbc_init_bio()/wbc_account_io() during writepages submission, and attaching the bios to the current context during direct IO. Finally if we are splitting bios during btrfs_map_bio, this attaches accounting information to the split. The end result is able to throttle nicely on single disk filesystems. A little more work is required for multi-device filesystems. Signed-off-by: Chris Mason --- fs/btrfs/volumes.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'fs/btrfs/volumes.c') diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index fb9abf1678d0..88e2fe931bde 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -5942,6 +5942,14 @@ again: if (!bio) return -ENOMEM; + if (first_bio->bi_ioc) { + get_io_context_active(first_bio->bi_ioc); + bio->bi_ioc = first_bio->bi_ioc; + } + if (first_bio->bi_css) { + css_get(first_bio->bi_css); + bio->bi_css = first_bio->bi_css; + } while (bvec <= (first_bio->bi_io_vec + first_bio->bi_vcnt - 1)) { if (bio_add_page(bio, bvec->bv_page, bvec->bv_len, bvec->bv_offset) < bvec->bv_len) { -- cgit v1.2.3