fix(posix): don't inflate tree sizes when assimilating a file fails - #797
Open
NickWalters wants to merge 1 commit into
Open
fix(posix): don't inflate tree sizes when assimilating a file fails#797NickWalters wants to merge 1 commit into
NickWalters wants to merge 1 commit into
Conversation
updateFile propagated a file's size to its parents before writing the file's attributes. When writing them failed, the file still had no blobsize, so the next attempt propagated the whole size again and every failed attempt inflated the tree sizes of all parent directories. Propagate only once the attributes are stored, like TouchFile and Move already do. Refs opencloud-eu/opencloud#3498
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
updateFilea file's size is propagated to its parent directories before the file's own attributes are written. If writing the attributes fails, the parents have already been updated but the file still has noblobsize. The next attempt sees a previous size of 0 and propagates the whole size again, so every failed attempt inflates the tree size of every parent directory by the size of the file.I ran into this while looking into opencloud-eu/opencloud#3498, where files couldn't be assimilated because the opencloud user had no write permission on them. They were retried over and over, and I think this is why the space root ended up claiming 6.3 TB and a 52 GB copy showed up as 70 GB. The sizes only went back to normal after a restart, when the initial scan recalculated them.
This moves the propagation after the attributes are stored, which is the order
TouchFileandMovein the posix tree already use. The downside is the same as there: if propagating fails after the attributes are written, a retry won't propagate the size again. The next scan of that directory sets its tree size from what's on disk, so it sorts itself out.The new spec in
tree_non_watching_test.golists a folder with a read-only file in it and checks that the folder's tree size is still 0 afterwards. It fails on main (12) and passes with this change. It skips as root, since root can set xattrs on read-only files.go test -race ./pkg/storage/fs/posix/...passes locally and golangci-lint is clean on the package.This is separate from #796, which stops those files from being retried constantly in the first place. The two don't depend on each other and merge cleanly in either order.