writeback: move backing_dev_info->wb_lock and ->worklist into bdi_writeback
authorTejun Heo <tj@kernel.org>
Fri, 22 May 2015 21:13:30 +0000 (17:13 -0400)
committerJens Axboe <axboe@fb.com>
Tue, 2 Jun 2015 14:33:34 +0000 (08:33 -0600)
commitf0054bb1e1f3be03cc33369df640db97f10f6172
treec838fdd0897adc178f93b19e2998e95c978c23fa
parentde1fff37b2781f9caae7bbb7b79fa788a9bb1115
writeback: move backing_dev_info->wb_lock and ->worklist into bdi_writeback

Currently, a bdi (backing_dev_info) embeds single wb (bdi_writeback)
and the role of the separation is unclear.  For cgroup support for
writeback IOs, a bdi will be updated to host multiple wb's where each
wb serves writeback IOs of a different cgroup on the bdi.  To achieve
that, a wb should carry all states necessary for servicing writeback
IOs for a cgroup independently.

This patch moves bdi->wb_lock and ->worklist into wb.

* The lock protects bdi->worklist and bdi->wb.dwork scheduling.  While
  moving, rename it to wb->work_lock as wb->wb_lock is confusing.
  Also, move wb->dwork downwards so that it's colocated with the new
  ->work_lock and ->work_list fields.

* bdi_writeback_workfn() -> wb_workfn()
  bdi_wakeup_thread_delayed(bdi) -> wb_wakeup_delayed(wb)
  bdi_wakeup_thread(bdi) -> wb_wakeup(wb)
  bdi_queue_work(bdi, ...) -> wb_queue_work(wb, ...)
  __bdi_start_writeback(bdi, ...) -> __wb_start_writeback(wb, ...)
  get_next_work_item(bdi) -> get_next_work_item(wb)

* bdi_wb_shutdown() is renamed to wb_shutdown() and now takes @wb.
  The function contained parts which belong to the containing bdi
  rather than the wb itself - testing cap_writeback_dirty and
  bdi_remove_from_list() invocation.  Those are moved to
  bdi_unregister().

* bdi_wb_{init|exit}() are renamed to wb_{init|exit}().
  Initializations of the moved bdi->wb_lock and ->work_list are
  relocated from bdi_init() to wb_init().

* As there's still only one bdi_writeback per backing_dev_info, all
  uses of bdi->state are mechanically replaced with bdi->wb.state
  introducing no behavior changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
fs/fs-writeback.c
include/linux/backing-dev.h
mm/backing-dev.c