Does msync sync all files on the filesystem to the disk like fsync on ext3?
as far as I know, on most ext3 system with log mode "data=ordered", fsync will not only sync the file specified with the fd, but will sync all files on the filesystem, and this proble开发者_StackOverflow中文版m has not been fixed before kernel 2.6.30
And I got a question, that is, is msync do the same thing as fsync does?
Thanks.
It's not a bug, it's a feature. Ext3 is a journaled file system. data=ordered means you are asking for the changes to the file system to be written in the order they are made.
So, when you are asking to sync the changes to a particular file you have to commit all the previous changes, whether to that files or others, or you are breaking the directive to keep the data in order. For this reason I suspect that msync will behave in the same way, although I haven't checked.
In fact, one can argue that if it doesn't it's a file system bug...
Reading the various articles, I don't think that's true at all. It does not flush all dirty data to disc if you do one fsync. It only flushes the metadata belonging to the same file.
Moreover, the problem described with data=ordered, seems to be that it waits for other pending IO requests to the same device, even though it should logically be higher priority. Not for all dirty data to be flushed (like sync()).
I would like to do an experiment to find out.
精彩评论