1

Is there a way to impose the order in which pages are flushed from memory to disk in Linux, except updating pages in the desired order and performing fsync()/msync() after each page update, separately? Relates to the linux page cache flush order, where I haven't found a clear answer also.

Community
  • 1
  • 1
leventov
  • 14,760
  • 11
  • 69
  • 98
  • Why would you want to? – John Zwinck Jan 05 '15 at 08:56
  • 1
    @JohnZwinck it is the only way to prevent data store corruption, when update touches several pages. Even if I perform `fsync` after each query, if page flushing order is not guaranteed, data store could be corrupted on power loss during flushing. Otherwise I can distinguish the page to be flushed last => guarantees other pages involved into the update already flushed. – leventov Jan 05 '15 at 09:01
  • 2
    Something to consider is if you can revise your storage/update mechanism in some way, e.g. so that you write a bunch of "pending" updates, then flush once, then write a "commit message" and flush again. The "commit message" would be very small, perhaps just updating a counter, so it could be guaranteed to exist on a single page. This might give the safety you need with the performance you desire. – John Zwinck Jan 05 '15 at 09:11

0 Answers0