Skip to contentSkip to conversation

Getting 'sync' to flush disk cache?

DISCUSSION Jeff Garzik 3 participants 4 messages Aug 14, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

So... has anybody given any thought to enabling fsync(2), fdatasync(2), and sync_file_range(2) issuing a [FLUSH|SYNCHRONIZE] CACHE command?

This has bugged me for _years_, that Linux does not do this. Looking at forums on the web, it bugs a lot of other people too.

My suggestion would be to add a FLUSH op alongside the existing READ and WRITE[_SYNC] ops, rather than passing down WRITE_SYNC. Why? Doing so maintains a 1-1 translation between requests and disk commands, and it would allow MD and DM more flexibility in handling this operation.

But that's just a guess. I'm open to suggestions.

Jeff

#1 lore raw
Quoted 5 lines · Jeff Garzik

So... has anybody given any thought to enabling fsync(2), fdatasync(2), and sync_file_range(2) issuing a [FLUSH|SYNCHRONIZE] CACHE command?

This has bugged me for _years_, that Linux does not do this. Looking at forums on the web, it bugs a lot of other people too.

eh afaik 2.6.17 and such do this if you have barriers enabled...

#2 lore raw
Quoted 8 lines · Arjan van de Ven
Quoted 5 lines · Jeff Garzik

So... has anybody given any thought to enabling fsync(2), fdatasync(2), and sync_file_range(2) issuing a [FLUSH|SYNCHRONIZE] CACHE command?

This has bugged me for _years_, that Linux does not do this. Looking at forums on the web, it bugs a lot of other people too.

eh afaik 2.6.17 and such do this if you have barriers enabled...

That is correct, but it only works on reiserfs and XFS and user space really cannot tell whether it did the right thing or not. File system developers really should take this more seriously...

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 10 lines · Jens Axboe
Quoted 5 lines · Arjan van de Ven
Quoted 3 lines · Jeff Garzik

So... has anybody given any thought to enabling fsync(2), fdatasync(2), and sync_file_range(2) issuing a [FLUSH|SYNCHRONIZE] CACHE command?

This has bugged me for _years_, that Linux does not do this. Looking at forums on the web, it bugs a lot of other people too.

eh afaik 2.6.17 and such do this if you have barriers enabled...

That is correct, but it only works on reiserfs and XFS and user space really cannot tell whether it did the right thing or not. File system developers really should take this more seriously...

IMO the non-journalling fs's should have some sort of common fsync helper via sync_inode(), sync_mapping_buffers(), and similar paths... Should be able get a bunch of fs's in one big swath that way.

Jeff