lkml.org 
[lkml]   [2015]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 06/45] writeback, blkcg: associate each blkcg_gq with the corresponding bdi_writeback
Date
A blkg (blkcg_gq) can be congested and decongested independently from
other blkgs on the same request_queue. Accordingly, for cgroup
writeback support, the congestion status at bdi (backing_dev_info)
should be split to per-cgroup wb's (bdi_writeback's) and updated
separately from matching blkg's.

This patch prepares by adding blkg->wb and associating a blkg with its
matching per-cgroup wb on creation.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jan Kara <jack@suse.cz>
Cc: Vivek Goyal <vgoyal@redhat.com>
---
block/blk-cgroup.c | 15 +++++++++++++++
include/linux/blk-cgroup.h | 6 ++++++
2 files changed, 21 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 8bebaa9..6fe085c 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -182,6 +182,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
struct blkcg_gq *new_blkg)
{
struct blkcg_gq *blkg;
+ struct bdi_writeback *wb;
int i, ret;

WARN_ON_ONCE(!rcu_read_lock_held());
@@ -193,6 +194,19 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
goto err_free_blkg;
}

+ /*
+ * Once created, @wb will stay alive longer than @blkg. @wb is
+ * destroyed iff either its bdi or @blkcg is destroyed. The bdi is
+ * part of the request_queue and will outlive @blkg, and, while
+ * @blkcg is being brought down, @wb will be destroyed the last in
+ * ->css_released().
+ */
+ wb = cgwb_lookup_create(&q->backing_dev_info, &blkcg->css);
+ if (!wb) {
+ ret = -ENOMEM;
+ goto err_free_blkg;
+ }
+
/* allocate */
if (!new_blkg) {
new_blkg = blkg_alloc(blkcg, q, GFP_ATOMIC);
@@ -202,6 +216,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
}
}
blkg = new_blkg;
+ blkg->wb = wb;

/* link parent */
if (blkcg_parent(blkcg)) {
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 3033eb1..97ceee3 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -99,6 +99,12 @@ struct blkcg_gq {
struct hlist_node blkcg_node;
struct blkcg *blkcg;

+ /*
+ * Each blkg gets congested separately and the congestion state is
+ * propagated to the matching cgroup wb.
+ */
+ struct bdi_writeback *wb;
+
/* all non-root blkcg_gq's are guaranteed to have access to parent */
struct blkcg_gq *parent;

--
2.1.0


\
 
 \ /
  Last update: 2015-01-06 23:01    [W:0.172 / U:1.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site