Async I/O
Async I/O
Posted Apr 8, 2009 6:02 UTC (Wed) by bojan (subscriber, #14302)In reply to: Async I/O by butlerm
Parent article: Linux Storage and Filesystem workshop, day 1
Absolutely. No question about it. It's just that Linus is not keen on having it, so that got me thinking as to how the same can be done without a new call. Of course, many of the thought are, shall will say, ill conceived... :-)
> it has completely different user visible semantics
One could also do this:
1. See if "foo~" exists.
2. If it doesn't, do link("foo","foo~") (i.e. create "backup").
3. Open "foo".
4. Read "foo".
5. Open/create/truncate "foo.new".
6. Write into "foo.new".
7. Call aio_fsync() on "foo.new". <-- doesn't block
8. Close "foo.new".
9. Rename "foo.new" into "foo".
In signal handler/thread created on sigevent do:
1. Unlink "foo~".
Then you get full rename semantics with always up to date file (i.e. what I was getting at with inotify example). However, your app then needs to check at startup if "foo~" exists (which means you crashed before the signal handler/thread unlinked you backup) and if it does, rename it to "foo". Then, continue.
