Commit 54a0f136 authored by Jan Kara's avatar Jan Kara Committed by Thadeu Lima de Souza Cascardo

bdi: Make wb->bdi a proper reference

BugLink: http://bugs.launchpad.net/bugs/1659111

Make wb->bdi a proper refcounted reference to bdi for all bdi_writeback
structures except for the one embedded inside struct backing_dev_info.
That will allow us to simplify bdi unregistration.
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
(cherry picked from commit 810df54a)
Signed-off-by: default avatarThiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
Acked-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Acked-by: default avatarBrad Figg <brad.figg@canonical.com>
Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
parent e96540d5
...@@ -294,6 +294,8 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, ...@@ -294,6 +294,8 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
memset(wb, 0, sizeof(*wb)); memset(wb, 0, sizeof(*wb));
if (wb != &bdi->wb)
bdi_get(bdi);
wb->bdi = bdi; wb->bdi = bdi;
wb->last_old_flush = jiffies; wb->last_old_flush = jiffies;
INIT_LIST_HEAD(&wb->b_dirty); INIT_LIST_HEAD(&wb->b_dirty);
...@@ -313,8 +315,10 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, ...@@ -313,8 +315,10 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
INIT_DELAYED_WORK(&wb->dwork, wb_workfn); INIT_DELAYED_WORK(&wb->dwork, wb_workfn);
wb->congested = wb_congested_get_create(bdi, blkcg_id, gfp); wb->congested = wb_congested_get_create(bdi, blkcg_id, gfp);
if (!wb->congested) if (!wb->congested) {
return -ENOMEM; err = -ENOMEM;
goto out_put_bdi;
}
err = fprop_local_init_percpu(&wb->completions, gfp); err = fprop_local_init_percpu(&wb->completions, gfp);
if (err) if (err)
...@@ -334,6 +338,9 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi, ...@@ -334,6 +338,9 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
fprop_local_destroy_percpu(&wb->completions); fprop_local_destroy_percpu(&wb->completions);
out_put_cong: out_put_cong:
wb_congested_put(wb->congested); wb_congested_put(wb->congested);
out_put_bdi:
if (wb != &bdi->wb)
bdi_put(bdi);
return err; return err;
} }
...@@ -371,6 +378,8 @@ static void wb_exit(struct bdi_writeback *wb) ...@@ -371,6 +378,8 @@ static void wb_exit(struct bdi_writeback *wb)
fprop_local_destroy_percpu(&wb->completions); fprop_local_destroy_percpu(&wb->completions);
wb_congested_put(wb->congested); wb_congested_put(wb->congested);
if (wb != &wb->bdi->wb)
bdi_put(wb->bdi);
} }
#ifdef CONFIG_CGROUP_WRITEBACK #ifdef CONFIG_CGROUP_WRITEBACK
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment