Re: question about possibility of data loss in Ext2/3 file system
From: Theodore Ts'o
Date: Wed Feb 22 2006 - 23:56:44 EST
On Wed, Feb 22, 2006 at 05:34:33PM -0500, Xin Zhao wrote:
> Apparently the scheme you described helps improve the file integrity.
> But still not good enough. For example, if all data blocks are
> flushed, then you will update the metadata. But right after you update
> the block bitmap and before you update the inode, you lose power. You
> will get some dead blocks. Right? Do you know how ext2/3 deal with
> this situation?
Ext3 uses the journal to guarantee that the bitmap blocks are
consistent with the inode. Ext2 will require that e2fsck be run to
fix the consistency problem.
> Also, the scheme you mentioned is just for new file creation. What
> will happen if I want to update an existing file? Say, I open file A,
> seek to offset 5000, write 4096 bytes, and then close. Do you know how
> ext2/3 handle this situation?
If you have a power failure right after the close, the data could be
lost. This is true for pretty much all Unix filesystems, for
performance reasons. If you care about the data hitting disk, the
application must use fsync().
Regards,
- Ted
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/