Fun quirk of sqlite is that if you BEGIN DEFERRED and then do a read
statement and then another process concurrently does a write and then
the first process does a write statement on the same transaction, it
will immediately return SQLITE_BUSY because it's impossible to do a
write against a past version of the database. To fix this we need to use
BEGIN IMMEDIATE to take a write lock upfront on any transaction that
will need to write.
* Turns out, when you create a file such as a symlink using O_WRDONLY,
the resulting fd is cached forever and prevents reading that symlink
in the future.
* After mkdir, we need to open the corresponding fd with O_RDONLY.
Factor out that logic.
* Apparently you need to instantiate the target dentry after creating a
hardlink.