You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Commit f724d6f ("contenthash: implement proper Linux symlink
semantics for needsScan") fixed issues with needScan's handling of
symlinks, but the logic used to figure out if a parent path is in the
cache was incorrect in two ways:
1. The optimisations in getFollowSymlinksCallback to avoid looking up /
or no-op components in the cache lead to the callback not being
called when we go through / (both in for the initial currentPath=/
state and for absolute symlinks). The upshot is that
needsScan(/non-existent-path) would always return true because we
didn't check if / has been scanned.
There were also some issues with the wrong cache record being
returned if you hit a symlink to only /. These optimisations only
make sense if are only returning a path (as in rootPath) and not
anything else.
2. Because needsScan would only store the _last_ good path, cases with
symlink jumps to non-existent paths within directories already
scanned would result in a re-scan that isn't necessary. Fix this by
saving a set of prefix paths we have seen. This change also means
that we can also simplify the logic in the needsScan callback.
Note that in combination with (1) and (2), if / has been scanned
then needsScan will always return false now (because the / prefix is
always checked against, and every path has it as a parent).
The pathSet structure is the "dumb" way of doing it. We could use a
radix tree and LongestPrefix() to implement it in a smarter way, but
in practice the list will be very small and is both short-lived and
write-many-read-few, so go-immutable-radix's node copy cost probably
makes the array better in practice anyway.
Fixes: f724d6f ("contenthash: implement proper Linux symlink semantics for needsScan")
Signed-off-by: Aleksa Sarai <[email protected]>
0 commit comments