[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: how ext3 works



On Tue, Dec 18, 2007 at 22:11:19 +0100,
  Bart <bart bas gmail com> wrote:
> n the past few days, I've been reading about ext3/journalling/... In order
> to fully understand how it works I have a few questions.
> 
> *Imagine the following situation: you opened a file in vi(m), you are
> editing, but haven't yet saved your work. The system crashes: what will be
> the result? Will the metadata be modified (assume both atime and noatime)?
> Will the data itself be corrupted? Or will there be no modification
> whatsoever because you hadn't saved yet (your work will simply be lost)?
> *What happens when the system crashes during a write to the journal? Can the
> journal be corrupted?

vi keeps data in a scratch file, so if you haven't forced a save your original
file will be intact. You should be able to use vi -r to recover at least
some of the changes you were working on. This is mostly independent of what
is going on in the file system.

What you really are looking for with journaling is that when you are told
data is safe on disk, it is in fact safe on disk.

You also need to worry about drive caching when dealing with this. You
can either turn write caching off, have it backed by battery (common with
real raid controllers) or use write barriers (this is a mount option) to
force cache flushes when needed (not all drives support this), or use disk
drives that can report back when commands have really been completed (which
is not available for PATA drives).

> *About ext3's ordered mode
> [quote]from Wikipedia:
> Ordered
>     (medium speed, medium risk) Ordered is as with writeback, but forces
> file contents to be written before its associated metadata is marked as
> committed in the journal.[/quote]

Note that for some workloads data=journal can be as fast as data=ordered.

Are you really having a throughput problem with your disk drives? If not then
you probably want to use data=journal (assuming that reliability is of high
concern to you). If you are having throughput problems there are other
potential solutions than reducing the effectiveness of journalling.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]