aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bio.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-03-05 16:15:27 -0500
committerJens Axboe <axboe@kernel.dk>2012-03-06 15:27:24 -0500
commit852c788f8365062c8a383c5a93f7f7289977cb50 (patch)
tree561b69e7f2b6bcc16de165b3b988990de7913615 /include/linux/bio.h
parentf6e8d01bee036460e03bd4f6a79d014f98ba712e (diff)
block: implement bio_associate_current()
IO scheduling and cgroup are tied to the issuing task via io_context and cgroup of %current. Unfortunately, there are cases where IOs need to be routed via a different task which makes scheduling and cgroup limit enforcement applied completely incorrectly. For example, all bios delayed by blk-throttle end up being issued by a delayed work item and get assigned the io_context of the worker task which happens to serve the work item and dumped to the default block cgroup. This is double confusing as bios which aren't delayed end up in the correct cgroup and makes using blk-throttle and cfq propio together impossible. Any code which punts IO issuing to another task is affected which is getting more and more common (e.g. btrfs). As both io_context and cgroup are firmly tied to task including userland visible APIs to manipulate them, it makes a lot of sense to match up tasks to bios. This patch implements bio_associate_current() which associates the specified bio with %current. The bio will record the associated ioc and blkcg at that point and block layer will use the recorded ones regardless of which task actually ends up issuing the bio. bio release puts the associated ioc and blkcg. It grabs and remembers ioc and blkcg instead of the task itself because task may already be dead by the time the bio is issued making ioc and blkcg inaccessible and those are all block layer cares about. elevator_set_req_fn() is updated such that the bio elvdata is being allocated for is available to the elevator. This doesn't update block cgroup policies yet. Further patches will implement the support. -v2: #ifdef CONFIG_BLK_CGROUP added around bio->bi_ioc dereference in rq_ioc() to fix build breakage. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Kent Overstreet <koverstreet@google.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r--include/linux/bio.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 129a9c097958..692d3d5b49f5 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -268,6 +268,14 @@ extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set
268extern void bvec_free_bs(struct bio_set *, struct bio_vec *, unsigned int); 268extern void bvec_free_bs(struct bio_set *, struct bio_vec *, unsigned int);
269extern unsigned int bvec_nr_vecs(unsigned short idx); 269extern unsigned int bvec_nr_vecs(unsigned short idx);
270 270
271#ifdef CONFIG_BLK_CGROUP
272int bio_associate_current(struct bio *bio);
273void bio_disassociate_task(struct bio *bio);
274#else /* CONFIG_BLK_CGROUP */
275static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
276static inline void bio_disassociate_task(struct bio *bio) { }
277#endif /* CONFIG_BLK_CGROUP */
278
271/* 279/*
272 * bio_set is used to allow other portions of the IO system to 280 * bio_set is used to allow other portions of the IO system to
273 * allocate their own private memory pools for bio and iovec structures. 281 * allocate their own private memory pools for bio and iovec structures.