]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
bdi: Mark congested->bdi as internal
authorJan Kara <jack@suse.cz>
Thu, 23 Mar 2017 00:36:54 +0000 (01:36 +0100)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Thu, 27 Apr 2017 13:04:18 +0000 (10:04 -0300)
BugLink: http://bugs.launchpad.net/bugs/1659111
congested->bdi pointer is used only to be able to remove congested
structure from bdi->cgwb_congested_tree on structure release. Moreover
the pointer can become NULL when we unregister the bdi. Rename the field
to __bdi and add a comment to make it more explicit this is internal
stuff of memcg writeback code and people should not use the field as
such use will be likely race prone.

We do not bother with converting congested->bdi to a proper refcounted
reference. It will be slightly ugly to special-case bdi->wb.congested to
avoid effectively a cyclic reference of bdi to itself and the reference
gets cleared from bdi_unregister() making it impossible to reference
a freed bdi.

Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit b7d680d7bf584bce6023343304b819009a7c3336)
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
include/linux/backing-dev-defs.h
mm/backing-dev.c

index 8f9299aeede20143187202d095b2629af99ef739..5f218afa52005bcc5dc40489619162875bdd6e28 100644 (file)
@@ -54,7 +54,9 @@ struct bdi_writeback_congested {
        atomic_t refcnt;                /* nr of attached wb's and blkg */
 
 #ifdef CONFIG_CGROUP_WRITEBACK
-       struct backing_dev_info *bdi;   /* the associated bdi */
+       struct backing_dev_info *__bdi; /* the associated bdi, set to NULL
+                                        * on bdi unregistration. For memcg-wb
+                                        * internal use only! */
        int blkcg_id;                   /* ID of the associated blkcg */
        struct rb_node rb_node;         /* on bdi->cgwb_congestion_tree */
 #endif
index f3e06b707612f69801d8442dbb86c274066b9c57..7157ccd000696b56a37e74fcbdcd05026d128b53 100644 (file)
@@ -437,7 +437,7 @@ retry:
                return NULL;
 
        atomic_set(&new_congested->refcnt, 0);
-       new_congested->bdi = bdi;
+       new_congested->__bdi = bdi;
        new_congested->blkcg_id = blkcg_id;
        goto retry;
 
@@ -465,10 +465,10 @@ void wb_congested_put(struct bdi_writeback_congested *congested)
        }
 
        /* bdi might already have been destroyed leaving @congested unlinked */
-       if (congested->bdi) {
+       if (congested->__bdi) {
                rb_erase(&congested->rb_node,
-                        &congested->bdi->cgwb_congested_tree);
-               congested->bdi = NULL;
+                        &congested->__bdi->cgwb_congested_tree);
+               congested->__bdi = NULL;
        }
 
        spin_unlock_irqrestore(&cgwb_lock, flags);
@@ -751,7 +751,7 @@ static void cgwb_bdi_exit(struct backing_dev_info *bdi)
                        rb_entry(rbn, struct bdi_writeback_congested, rb_node);
 
                rb_erase(rbn, &bdi->cgwb_congested_tree);
-               congested->bdi = NULL;  /* mark @congested unlinked */
+               congested->__bdi = NULL;        /* mark @congested unlinked */
        }
        spin_unlock_irq(&cgwb_lock);
 }