Drive has no replacing rename, so rename(2) over an existing name
removes the destination first and renames the source second. A stop
between the two left the destination in Drive's trash, or with its
trash queued and no rename, and nothing recorded that a rename was
half done.
A replacing rename now writes a journal entry with a synced commit
before it removes the destination, and ends it when it returns. The
entry lives in sync_state, so the schema does not change, and carries
the opening of the database that wrote it, so a rename in progress is
never settled under it.
At mount, and on the drain's idle passes while online, Recovery
settles each entry from an earlier run with the rules in
pdfs_vfs::namespace: a queued rename stands, a queued trash with no
rename is dropped, and otherwise Drive decides whether the rename
happened or the destination comes back from the trash.
- merge_over_pending and copy_pending_for_truncate, which fold a queued
revision into a newer write, move to pdfs_vfs::open with their tests.
- The last release of an unlinked inode becomes State::release_unlinked,
and listed_children moves to pdfs_vfs::tree.
- Which nodes a folder shows, how queued changes lie over a listing, and
the node a create makes before Drive has seen it move to pdfs_vfs::nodes.
- The component-name and rename-replace checks move to pdfs_vfs::names
and return NameError and ReplaceError. The FUSE adapter maps them to
the same errno values as before.
Rebuilding the queue after a restart ran as methods on `Core`.
`recovery::Recovery` now holds the database, the content cache and the
write-back's state. It rebuilds the pending map, reconciles the staging
area and recovers fsynced writes. Queueing a recovered write goes through
`RecoveryHost`, which has one method.
Rebuilding the tree (`Core::hydrate`) stays on `Core`, because the tree is
part of the mounted-files service.
`pending`, `hidden` and `self_changes` move off `Core` into
`writes::WriteState`. The read path, listings, the pin keeper and the event
feed now ask it through methods (`queued`, `is_queued`, `queued_len`,
`queued_sizes`, `hidden`, `hide`, `unhide`, `note_echo`, `take_echo`)
instead of taking its locks. `hidden` and `self_changes` are private to the
module. `pending` stays visible to the queue, the drain and recovery, which
update it together with the database under one lock.
- enqueue.rs: turning what the mount was asked into queued ops, and
taking them back (17 methods).
- listing.rs: when a folder is listed again and what a listing from
Drive is merged with (10 methods).
- pins.rs: pin, unpin and the pin listings (8 methods).
- recovery.rs: rebuilding the tree and the queue at startup, and
recovering fsynced writes (5 methods).
- search.rs: the search requests (4 methods).
- echoes.rs: our own changes echoed back by the event feed, with
SelfChange and its helpers.
The source-order tests read Core's code through CORE_SOURCE, lib.rs and
the modules its methods were split into. No behaviour changes.