public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Mike Fedyk <mfedyk@matchmail.com>, Stephen Tweedie <sct@redhat.com>
Subject: Re: ReiserFS data corruption in very simple configuration
Date: Wed, 26 Sep 2001 15:43:11 +0100	[thread overview]
Message-ID: <20010926154311.C12560@redhat.com> (raw)
In-Reply-To: <200109221000.GAA11263@out-of-band.media.mit.edu> <15276.34915.301069.643178@beta.reiserfs.com> <20010925131304.I23320@mikef-linux.matchmail.com>
In-Reply-To: <20010925131304.I23320@mikef-linux.matchmail.com>; from mfedyk@matchmail.com on Tue, Sep 25, 2001 at 01:13:04PM -0700

Hi,

On Tue, Sep 25, 2001 at 01:13:04PM -0700, Mike Fedyk wrote:

> > Stock reiserfs only provides meta-data journalling. It guarantees that
> > structure of you file-system will be correct after journal replay, not
> > content of a files. It will never "trash" file that wasn't accessed at
> > the moment of crash, though. Full data-journaling comes at cost. There
> > is patch by Chris Mason <Mason@Suse.COM> to support data journaling in
> > reiserfs. Ext3 supports it also.
 
> When files on a ReiserFS mount have data from other files, does that mean
> that it has recovered wrong meta-data, or is it because the meta-data was
> committed before the data?

It can be either, but the former can only be the result of a problem
(either hardware fault or a data-corrupting software bug of some
description).  In the normal case, only the latter scenario happens.

ext3 has a mode to flush all data before metadata gets committed.
That is its default mode, and it avoids this problem without having to
actually journal the data.

> So, if I write a file, does ReiserFS write the structures first, and if the
> data isn't written, whatever else was deleted from the block before will now
> be in the file?

Yep.  ext3 behaves in the same way in its fastest "writeback" data
mode.

> If that's so, then one way to keep old deleted data from getting into
> partially written files after a crash would be to zero out the blocks on
> unlink.  I can imagine that this would prevent undelete, and slow down
> deleting considerably.

Indeed.

> Another way, may be to keep a journal of which blocks have actually been
> committed.  Maybe a bitmap in the journal, or some other structure...

ext3 does exactly that.  It's necessary to keep things in sync if we
have blocks of data being deleted and reallocated as metadata, or
vice-versa.

> If you have data journaling, does that mean there is a possability of
> recovering a complete file -before- it was written?  i.e:

> echo a > test;
> sync;
> cat picture.tif > test
> (writing in progress, only partially in journal)
> power off
 
> Will "a" be in test upon recovery?

If you are using full data journaling (ext3's "journal" data mode) or
the default "ordered" data mode, then no, you never see such
behaviour.

In the ordered mode, it achieves this precisely because it is keeping
a record of which blocks have been committed (or, more accurately,
which *deleted* blocks have had the delete committed).  If you do a
"cat > file", then before the new data is written, the file gets
truncated and all its old data blocks deleted.  ext3 will then refuse
to reuse those blocks until the delete has been committed, so if we
crash and end up rolling back the delete transaction, we'll never see
new data blocks in the old file.

Cheers,
 Stephen

  reply	other threads:[~2001-09-26 15:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-22 10:00 ReiserFS data corruption in very simple configuration foner-reiserfs
2001-09-22 12:47 ` Nikita Danilov
2001-09-22 20:44   ` foner-reiserfs
2001-09-25 13:28     ` Stephen C. Tweedie
2001-09-29  4:44       ` Lenny Foner
2001-09-29 12:52         ` [reiserfs-list] " Lehmann 
2001-10-01  1:00           ` foner-reiserfs
2001-10-01  1:26             ` Lehmann 
2001-10-01  2:32               ` foner-reiserfs
2001-10-03 16:28               ` Toby Dickenson
2001-10-01 11:30         ` Stephen C. Tweedie
2001-09-24  9:25   ` [reiserfs-list] " Jens Benecke
2001-10-14 14:52     ` Chris Mason
2001-10-14 18:19       ` Jens Benecke
2001-10-14 20:04         ` Hans Reiser
2001-10-14 23:32         ` Bernd Eckenfels
2001-09-25 20:13   ` Mike Fedyk
2001-09-26 14:43     ` Stephen C. Tweedie [this message]
2001-10-01  3:38       ` Mike Fedyk
2001-10-03 16:14         ` Stephen C. Tweedie
2001-10-01 15:27 ` Hans Reiser
2001-10-03 16:17   ` Stephen C. Tweedie
2001-10-03 20:06     ` Pascal Schmidt
2001-10-04 11:02       ` Stephen C. Tweedie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010926154311.C12560@redhat.com \
    --to=sct@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mfedyk@matchmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox