[lkml]   [2004]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
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 and den delete fileX, hit a crash then we would
> have at least the correct file written as

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

[unhandled content-type:application/pgp-signature]
 \ /
  Last update: 2005-03-22 14:03    [W:0.071 / U:0.032 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site