UBIFS: seek journal heads to the latest bud in replay
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 25 Apr 2011 15:46:31 +0000 (18:46 +0300)
committerSteve Conklin <sconklin@canonical.com>
Thu, 2 Jun 2011 19:23:11 +0000 (14:23 -0500)
commitdaa853e42c17c50833220f4c96ac9843820dc3d1
treee6f2d405e345f8804314cdb13775b17282c72268
parentdda8c5d7178b8f6d28a1b04db32dac452a47ea1e
UBIFS: seek journal heads to the latest bud in replay

BugLink: http://bugs.launchpad.net/bugs/780546

commit 52c6e6f990669deac3f370f1603815adb55a1dbd upstream.

This is the second fix of the following symptom:

UBIFS error (pid 34456): could not find an empty LEB

which sometimes happens after power cuts when we mount the file-system - UBIFS
refuses it with the above error message which comes from the
'ubifs_rcvry_gc_commit()' function. I can reproduce this using the integck test
with the UBIFS power cut emulation enabled.

Analysis of the problem.

Currently UBIFS replay seeks the journal heads to the last _replayed_ bud.
But the buds are replayed out-of-order, so the replay basically seeks journal
heads to the "random" bud belonging to this head, and not to the _last_ one.

The result of this is that the GC head may be seeked to a full LEB with no free
space, or very little free space. And 'ubifs_rcvry_gc_commit()' tries to find a
fully or mostly dirty LEB to match the current GC head (because we need to
garbage-collect that dirty LEB at one go, because we do not have @c->gc_lnum).
So 'ubifs_find_dirty_leb()' fails and we fall back to finding an empty LEB and
also fail. As a result - recovery fails and mounting fails.

This patch teaches the replay to initialize the GC heads exactly to the latest
buds, i.e. the buds which have the largest sequence number in corresponding
log reference nodes.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
fs/ubifs/replay.c