Refactor to change StatCache class and add StatCacheNode classes #2681
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.
Relevant Issue (if applicable)
#2674 #2675 #2676
Advance information
This PR is Phase 3 of fixes to refactor and improve StatCache.
(Draft until #2676 is merged. Subsequent PRs will follow based on this PR codes.)
This is the main purpose of refactorings for StatCache.
Reviewing this refactoring may take some time, so thank you in advance for your help.
(The basic idea is that the cache map in
StatCache
has been changed to a dedicated tree class(StatCacheNode
).)Background
Stat information/Meta headers are managed by the
StatCache
class, but it has become complicated due to past modifications.Since it is difficult to implement further modifications in the current
StatCache
class, I decided to review theStatCache
class.Summary
Currently,
StatCache
caches and manages stat information and meta headers.The cache is complicated, with regular file and directory caches, symbolic link caches, negative caches, and maps to prevent cache deletion.
So, these are implemented by new
StaCacheNode
base class and its derived classes, and the currentStatCache
has been changed to manage theStaCacheNode
map.There are no changes to the specifications in terms of functionality (support for files, directories, and symbolic links, expiration date, cache out block, negative cache, etc.).
Major changes
StatCache class
As before, this is a singleton cache management object and serves as an accessor to cached data.
Previous cache types(file, directory, symbolic link, negative cache) are managed and implemented by new
StatCacheNode
classes.StatCacheNode base class and derived classes
The
StatCacheNode
class is the base class for each cache type.The derived classes are
FileStatCache
,DirStatCache
,SymlinkStatCache
, andNegativeStatCache
.The Truncate(cache out) and expiration Handling for each cache are also implemented in these classes.
The blocking cache out function is managed by a flag in thess classes.
As described above, the cache data operations that were previously implemented in the
StatCache
class are now implemented in these classes.Structure of Cache data
Currently, the structure of cache data was
path
<->cache data
as a simple mapping.(These maps are
stat_cache_t
,symlink_cache_t
,notruncate_dir_map_t
, etc.)In the new structure, the cache data is a directory tree structure with the mount point at the top.
Cache type definition
Currently, the cache type was defined in a complicated way using
dirtype
(enum) for mainly type, and flags using the type of directory.(This dues to historical reasons due to the modification.)
The new type can now be expressed only with
objtype_t
(enum).This
objtype_t
corresponds to the eachStatCacheNode
derived class.In addition, directory types (
dir/
,dir
,dir_$folder$
,<no directory entity>
) are all expressed with thisobjtype_t
.Utility functions such as determining
objtype_t
variables have also been unified.Others
The above changes to the
StatCache
class and the addition of theStatCacheNode
class have resulted in changes to the implementation of each file. (This was mainly done in the s3fs.cpp file.)Notes
The data managed by the
StatCacheNode
class (including derived classes) includesstat
andmeta
headers.Previously
StatCache
class, this data was registered in themeta
header, andstat
data was created and registered through internal processing.In the new code, it can register with
stat
andmeta
, or registerstat
only. (meta
only registration is not possible.)Registering
stat
only will be used when implementing future performance tuning.(Currently, we are not using it yet)About s3proxy
@gaul
Due to the s3proxy specifications, some code changes were required.
As commented in the code, s3proxy responds as success to Head requests by
dir
path when the onlydir/
object exists.