Hacker News new | past | comments | ask | show | jobs | submit login

Not a kernel dev but to my knowledge "write B must hit disk after write A" would actually be rather easy to implement: if the storage device supports it: insert a write barrier. For the "let me know when write A is on disk" adding a callback to a write-barrier would do, not sure what the kernel queue looks like though.



In principle, yes. I believe most modern filesystems use (kernel-level) write barriers to ensure filesystem consistency, and those do depend on having hardware barriers as well.

The kernel is not set up to export this interface, however, and there doesn't appear to be any serious work being done to fix that.

EDIT: http://pl.atyp.us/2013-11-fixing-fsync.html has more details.


While a "notify me when this write completes" (but don't feel the need to rush) might be useful, I think it'd be more useful to be able to push both write A and write B to the kernel, along with the condition of "A before B". You not only get the write ordering, but the kernel gets full knowledge of what's going on. Perhaps it could use this to write A and B together (but journaled at the FS level) to guarantee the order, whereas a simple write-complete notification implies at least two writes, and the latency of doing such.


The two-write operation you propose is simpler, but you're losing a lot of generality. Specifically, think about:

  * I want to notify a network client that its write is done
  * When this write is done, I want to delete a temporary file 
etc


Good points — there's definitely a place for a write barrier. It may be that a simple write barrier, while not as efficient for this use case, might be generally more useful.

For your second point, if you take my initial "write B depends on the completion of write A", and extend it allow arbitrary kernel commands to depend on others, then you could still do that, (delete B depends on write A), however, things are probably too complex at this point, and a simple write barrier is better.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: