Skip to content

Commit c7c98fd

Browse files
Josef Bacikaxboe
authored andcommitted
block: introduce bio_issue_as_root_blkg
Instead of forcing all file systems to get the right context on their bio's, simply check for REQ_META to see if we need to issue as the root blkg. We don't want to force all bio's to have the root blkg associated with them if REQ_META is set, as some controllers (blk-iolatency) need to know who the originating cgroup is so it can backcharge them for the work they are doing. This helper will make sure that the controllers do the proper thing wrt the IO priority and backcharging. Signed-off-by: Josef Bacik <jbacik@fb.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 08e18ea commit c7c98fd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

include/linux/blk-cgroup.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,22 @@ static inline struct blkcg *bio_blkcg(struct bio *bio)
238238
return css_to_blkcg(task_css(current, io_cgrp_id));
239239
}
240240

241+
/**
242+
* bio_issue_as_root_blkg - see if this bio needs to be issued as root blkg
243+
* @return: true if this bio needs to be submitted with the root blkg context.
244+
*
245+
* In order to avoid priority inversions we sometimes need to issue a bio as if
246+
* it were attached to the root blkg, and then backcharge to the actual owning
247+
* blkg. The idea is we do bio_blkcg() to look up the actual context for the
248+
* bio and attach the appropriate blkg to the bio. Then we call this helper and
249+
* if it is true run with the root blkg for that queue and then do any
250+
* backcharging to the originating cgroup once the io is complete.
251+
*/
252+
static inline bool bio_issue_as_root_blkg(struct bio *bio)
253+
{
254+
return (bio->bi_opf & REQ_META);
255+
}
256+
241257
/**
242258
* blkcg_parent - get the parent of a blkcg
243259
* @blkcg: blkcg of interest

0 commit comments

Comments
 (0)