/* Note, other stuff like background garbage collection may be added here in future.  */
int ubifs_bg_thread(void *info)
/* Note, other stuff like background garbage collection may be added here in future.  */
int ubifs_bg_thread(void *info)
{
	int err;
	struct ubifs_info *c = info;
	dbg_msg("background thread \"%s\" started, PID %d",
		c->bgt_name, current->pid);
	set_freezable();
	while (1) {
		if (kthread_should_stop())
			break;
		if (try_to_freeze())
			continue;
		set_current_state(TASK_INTERRUPTIBLE);
		if (!c->need_bgt) {
			if (kthread_should_stop())
				break;
			schedule();
			continue;
		} else
			__set_current_state(TASK_RUNNING);
		c->need_bgt = 0;
		err = ubifs_bg_wbufs_sync(c);
		if (err)
			ubifs_ro_mode(c, err);
		run_bg_commit(c);
		cond_resched();
	}
	dbg_msg("background thread \"%s\" stops", c->bgt_name);
	return 0;
}