Re: Journaling: Surviving or allowing unclean shutdown?

Stephen C. Tweedie (sct@redhat.com)
Fri, 5 Jan 2001 10:31:09 +0000


Hi,

On Fri, Jan 05, 2001 at 01:31:12AM +0100, Daniel Phillips wrote:
> "Stephen C. Tweedie" wrote:
> >
> Yes, and so long as your journal is not on another partition/disk things
> will eventually be set right. The combination of a partially updated
> filesystem and its journal is in some sense a complete, consistent
> filesystem.

Right.

> I'm curious - how does ext3 handle the possibility of a crash during
> journal recovery?

Recovery comes in two parts: replay of the log, and deletion of
orphaned inodes.

The log replay is fully idempotent: it just consists of writing the
appropriate log blocks to their home locations on disk. It doesn't
matter if you do those writes once, twice or a hundred times, you
still get the same result, so crashing mid-recovery and starting again
from scratch is perfectly safe.

Once that recovery is done, the filesystem is marked, atomically, to
be clean.

Secondly, we do the deletion of orphaned inodes. By this time, the
journal itself has been recovered so we are journaling our operations,
so each orphaned inode delete is being logged. A crash will recover
to a consistent state via the normal journaling transaction methods,
and will restart orphan recovery from where it left off.

Cheers,
Stephen
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/