aboutsummaryrefslogtreecommitdiffstats
path: root/mm/backing-dev.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-03-22 20:36:54 -0400
committerJens Axboe <axboe@fb.com>2017-03-22 22:11:24 -0400
commitb7d680d7bf584bce6023343304b819009a7c3336 (patch)
tree84c8dddee7f9e910caeff43ef7724a1f22327f0f /mm/backing-dev.c
parent03e262798884b0a5f948b17433afd80606cb3497 (diff)
bdi: Mark congested->bdi as internal
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>
Diffstat (limited to 'mm/backing-dev.c')
-rw-r--r--mm/backing-dev.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index c6f2a37028c2..12408f86783c 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -438,7 +438,7 @@ retry:
438 return NULL; 438 return NULL;
439 439
440 atomic_set(&new_congested->refcnt, 0); 440 atomic_set(&new_congested->refcnt, 0);
441 new_congested->bdi = bdi; 441 new_congested->__bdi = bdi;
442 new_congested->blkcg_id = blkcg_id; 442 new_congested->blkcg_id = blkcg_id;
443 goto retry; 443 goto retry;
444 444
@@ -466,10 +466,10 @@ void wb_congested_put(struct bdi_writeback_congested *congested)
466 } 466 }
467 467
468 /* bdi might already have been destroyed leaving @congested unlinked */ 468 /* bdi might already have been destroyed leaving @congested unlinked */
469 if (congested->bdi) { 469 if (congested->__bdi) {
470 rb_erase(&congested->rb_node, 470 rb_erase(&congested->rb_node,
471 &congested->bdi->cgwb_congested_tree); 471 &congested->__bdi->cgwb_congested_tree);
472 congested->bdi = NULL; 472 congested->__bdi = NULL;
473 } 473 }
474 474
475 spin_unlock_irqrestore(&cgwb_lock, flags); 475 spin_unlock_irqrestore(&cgwb_lock, flags);
@@ -752,7 +752,7 @@ static void cgwb_bdi_exit(struct backing_dev_info *bdi)
752 rb_entry(rbn, struct bdi_writeback_congested, rb_node); 752 rb_entry(rbn, struct bdi_writeback_congested, rb_node);
753 753
754 rb_erase(rbn, &bdi->cgwb_congested_tree); 754 rb_erase(rbn, &bdi->cgwb_congested_tree);
755 congested->bdi = NULL; /* mark @congested unlinked */ 755 congested->__bdi = NULL; /* mark @congested unlinked */
756 } 756 }
757 spin_unlock_irq(&cgwb_lock); 757 spin_unlock_irq(&cgwb_lock);
758} 758}