linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* metadata operation reordering regards to crash
@ 2018-09-14  9:06 焦晓冬
  2018-09-14 22:23 ` Dave Chinner
  0 siblings, 1 reply; 5+ messages in thread
From: 焦晓冬 @ 2018-09-14  9:06 UTC (permalink / raw)
  To: linux-fsdevel, linux-ext4, adilger.kernel; +Cc: linux-kernel

Hi, all,

A probably bit of complex question:
Does nowadays practical filesystems, eg., extX, btfs, preserve metadata
operation order through a crash/power failure?

What I know is modern filesystems ensure metadata consistency
after crash/power failure. Journal filesystems like extX do that by
write-ahead logging of metadata operations into transactions. Other
filesystems do that in various ways as btfs do that by COW.

What I'm not so far clear is whether these filesystems preserve
metadata operation order after a crash.

For example,
op 1.  rename(A, B)
op 2.  rename(C, D)

As mentioned above,  metadata consistency is ensured after a crash.
Thus, B is either the original B(or not exists) or has been replaced by A.
The same to D.

Is it possible that, after a crash, D has been replaced by C but B is still
the original file(or not exists)?

Or, from the view of implementation, before the crash
- in a journal filesystem,
Is the atomic transaction `rename(C, D)` permitted to be written to disk journal
before the transaction `rename(A, B)`?
- in other filesystems, say btfs,
Is it permit to reorder `rename(C,D)` and `rename(A,B)` atomic operation hiting
disk?

The question is meaningful as many applications do that:
if (flag_file_says_need_generate_data) {
    open_write_sync_close(data_tmp);
    rename(data_tmp, data);

    open_write_sync_close(flag_file_tmp, no_need_to_generate_data);
    rename(flag_file_tmp, flag_file)
}
use_data_file()

If flag is here but data is not after a crash, that is a problem.

Thanks,
Trol

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-16  6:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14  9:06 metadata operation reordering regards to crash 焦晓冬
2018-09-14 22:23 ` Dave Chinner
2018-09-15  6:58   ` 焦晓冬
2018-09-15 18:04     ` Andreas Dilger
2018-09-16  1:18     ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).