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 <t...@kernel.org>
Cc: Jens Axboe <ax...@kernel.dk>
Cc: Jan Kara <j...@suse.cz>
Cc: Vivek Goyal <vgo...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to