/* Handle writeback of dirty data for the device backed by this bdi. Also wakes up periodically and does kupdated style flushing.  */
int bdi_writeback_task(struct bdi_writeback *wb)
/* Handle writeback of dirty data for the device backed by this bdi. Also wakes up periodically and does kupdated style flushing.  */
int bdi_writeback_task(struct bdi_writeback *wb)
{
	unsigned long last_active = jiffies;
	unsigned long wait_jiffies = -1UL;
	long pages_written;
	while (!kthread_should_stop()) {
		pages_written = wb_do_writeback(wb, 0);
		if (pages_written)
			last_active = jiffies;
		else if (wait_jiffies != -1UL) {
			unsigned long max_idle;
			max_idle = max(5UL * 60 * HZ, wait_jiffies);
			if (time_after(jiffies, max_idle + last_active))
				break;
		}
		wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10);
		schedule_timeout_interruptible(wait_jiffies);
		try_to_freeze();
	}
	return 0;
}