/* Retrieve work items and do the writeback they describe  */
long wb_do_writeback(struct bdi_writeback *wb, int force_wait)
/* Retrieve work items and do the writeback they describe  */
long wb_do_writeback(struct bdi_writeback *wb, int force_wait)
{
	struct backing_dev_info *bdi = wb->bdi;
	struct bdi_work *work;
	long wrote = 0;
	while ((work = get_next_work_item(bdi, wb)) != NULL) {
		struct wb_writeback_args args = work->args;
		if (force_wait)
			work->args.sync_mode = args.sync_mode = WB_SYNC_ALL;
		if (args.sync_mode == WB_SYNC_NONE)
			wb_clear_pending(wb, work);
		wrote += wb_writeback(wb, &args);
		if (args.sync_mode == WB_SYNC_ALL)
			wb_clear_pending(wb, work);
	}
	wrote += wb_check_old_data_flush(wb);
	return wrote;
}