UBIFS: remove duplicated code

We have duplicated code in 'ubifs_garbage_collect()' and
'ubifs_rcvry_gc_commit()', which is about handling the special case of free
LEB. In both cases we just want to garbage-collect the LEB using
'ubifs_garbage_collect_leb()'.

This patch teaches 'ubifs_garbage_collect_leb()' to handle free LEB's so that
the caller does not have to do this and the duplicated code is removed.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Este commit está contenido en:
Artem Bityutskiy
2011-04-26 09:49:32 +03:00
padre 2cd0a60cf4
commit 2405f59481
Se han modificado 2 ficheros con 33 adiciones y 48 borrados

Ver fichero

@@ -1125,25 +1125,10 @@ int ubifs_rcvry_gc_commit(struct ubifs_info *c)
}
return err;
}
ubifs_assert(!(lp.flags & LPROPS_INDEX));
lnum = lp.lnum;
if (lp.free + lp.dirty == c->leb_size) {
/* An empty LEB was returned */
if (lp.free != c->leb_size) {
err = ubifs_change_one_lp(c, lnum, c->leb_size,
0, 0, 0, 0);
if (err)
return err;
}
err = ubifs_leb_unmap(c, lnum);
if (err)
return err;
c->gc_lnum = lnum;
dbg_rcvry("allocated LEB %d for GC", lnum);
/* Run the commit */
dbg_rcvry("committing");
return ubifs_run_commit(c);
}
/*
* There was no empty LEB so the used space in the dirtiest LEB must fit
* in the GC head LEB.