lkml.org 
[lkml]   [2004]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: mode data=journal in ext3. Is it safe to use?
On Jun 17, 2004  13:23 +0200, Petter Larsen wrote:
> But think of your scenario of copy, delete and make a new file with the
> new content. First we copy the contents of the file, then we do our
> modifications. When we are done we delete the original file. Then we hit
> a crash. The content we had of the file in our process are gone, the
> original file is deleted. This is not a good idea. But if we write the new
> file first as fileX.new and den delete fileX, hit a crash then we would
> have at least the correct file written as fileX.new.

The rename operation is guaranteed to be atomic. You implement updates as:
1) create new file
2) write data to new file
3) rename new file over old filename

If the system crashes at any time you are guaranteed that the old filename
has valid data in it. Even if you use data=journal mode while overwriting
the old filename directly you wouldn't be guaranteed to have valid data
unless your application was only e.g. writing aligned records to fixed file
offsets, and those records were <= 4kB in size.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://members.shaw.ca/adilger/ http://members.shaw.ca/golinux/

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2005-03-22 14:03    [W:0.113 / U:0.168 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site