Fix stale parent directory sizes after subtree reindex#354
Fix stale parent directory sizes after subtree reindex#354wangruohui wants to merge 4 commits intozevv:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes stale cached directory sizes when reindexing a subtree by propagating updated subtree sizes into ancestor serialized directory buffers, keeping parent views consistent without a full reindex.
Changes:
- Add helpers to split a path into parent/child and to update a child directory entry inside a parent directory buffer.
- After writing a refreshed subtree report, update the immediate parent entry (exact size + devino) and propagate size deltas up ancestor buffers.
- Hook the propagation into
duc_index()afterdb_write_report().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Thanks for sending in this patch, along with a test case! I need to look it over more but one nit I have is that I don't like how the args passed into fuctions are split one per-line now in some of the new functions you call. Not ideal in my feeling, it spreads the code out a bunch more. I also see where you change some size_t back to int, which I think is wrong too, since we could potentially have large values there. But this will take some more work to look over. |
Summary
This PR fixes a stale-cache issue in
ducwhen reindexing a subtree.Previously, if a user indexed
a, then later modified files undera/band randuc index a/b, the subtree report fora/bwas refreshed, but the cached directory entry stored inawas not. As a result, commands likeduc ui aorduc ls acould still show the old size forb.Root Cause
ducstores directory listings as serialized per-directory buffers, and parent directories cache the size of each child directory entry. Reindexing a subtree updated:but it did not propagate the new size back into ancestor directory buffers.
That meant readers opening
astill saw the old cached size forb.Changes
This PR adds parent-buffer propagation after writing a refreshed subtree report:
devinoThis keeps cached parent views consistent after
duc index <subtree>without forcing a full reindex of the ancestor tree.Example
Before this change:
duc index aa/bduc index a/bduc ui abcould still show the old size insidea.After this change,
bis updated correctly in the parent view.