LWN.net Logo

extreemly informative and interesting, but...

extreemly informative and interesting, but...

Posted Mar 29, 2009 21:16 UTC (Sun) by tstover (subscriber, #56283)
In reply to: extreemly informative and interesting, but... by cortana
Parent article: Filesystems? *I'll* give ya fileysytems!

I get volatility part, what needs some big time disambiguation is all the talk of writes arriving on disk out of order. Of course writes to different files might be interwoven unpredictably, but what I want to know is - can call sequences like this arrive on platter out of order?

lseek(fd, 0, SEEK_CUR);
write(fd, "a", 1);
lseek(fd, 0, SEEK_CUR);
write(fd, "b", 1);
lseek(fd, 0, SEEK_CUR);
write(fd, "c", 1);

or with mmap()ed io:

x = 'a';
msync(&x, 1, MS_SYNC);
x = 'b';
msync(&x, 1, MS_SYNC);
x = 'c';
msync(&x, 1, MS_SYNC);

I would love to find this out as I have never seen a straight answer. Think about it though, if you could get data like this out of order on platter then userspace journaling (database transactions) would be a complete fantasy. Unless there is another file interface I don't know of.


(Log in to post comments)

extreemly informative and interesting, but...

Posted Apr 5, 2009 10:31 UTC (Sun) by dlang (✭ supporter ✭, #313) [Link]

the answer is yes

unless you do fsync or add a barrier (not currently possible from userspace)

this is the big issue with write barriers in ext3. without such barriers the writes to the journal can end up out of order. since the journal is laied out as a sequential block on disk, it's relativly unlikely to happen, but it is possible.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds