/* So this function tries to do the above. Returns %-EAGAIN if some free space was presumably made and the caller has to re-try budgeting the operation. Returns %-ENOSPC if it couldn't do more free space, and other negative error codes on failures.  */
static int make_free_space(struct ubifs_info *c)
/* So this function tries to do the above. Returns %-EAGAIN if some free space was presumably made and the caller has to re-try budgeting the operation. Returns %-ENOSPC if it couldn't do more free space, and other negative error codes on failures.  */
static int make_free_space(struct ubifs_info *c)
{
	int err, retries = 0;
	long long liab1, liab2;
	do {
		liab1 = get_liability(c);
		dbg_budg("liability %lld, run write-back", liab1);
		shrink_liability(c, NR_TO_WRITE);
		liab2 = get_liability(c);
		if (liab2 < liab1)
			return -EAGAIN;
		dbg_budg("new liability %lld (not shrinked)", liab2);
		dbg_budg("Run GC");
		err = run_gc(c);
		if (!err)
			return -EAGAIN;
		if (err != -EAGAIN && err != -ENOSPC)
			return err;
		dbg_budg("Run commit (retries %d)", retries);
		err = ubifs_run_commit(c);
		if (err)
			return err;
	} while (retries++ < MAX_MKSPC_RETRIES);
	return -ENOSPC;
}