From: Joel Rosdahl Date: Sun, 7 Nov 2021 12:37:47 +0000 (+0100) Subject: fix: Disable hard link and file clone with enabled secondary storage X-Git-Tag: v4.5~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=182eeb9fefaf7f1dedd5eb4b7c88d194ba6c3005;p=thirdparty%2Fccache.git fix: Disable hard link and file clone with enabled secondary storage --- diff --git a/src/Config.hpp b/src/Config.hpp index acb09e990..9383106bd 100644 --- a/src/Config.hpp +++ b/src/Config.hpp @@ -92,6 +92,8 @@ public: void set_debug(bool value); void set_depend_mode(bool value); void set_direct_mode(bool value); + void set_file_clone(bool value); + void set_hard_link(bool value); void set_ignore_options(const std::string& value); void set_inode_cache(bool value); void set_max_files(uint64_t value); @@ -489,6 +491,18 @@ Config::set_direct_mode(bool value) m_direct_mode = value; } +inline void +Config::set_file_clone(const bool value) +{ + m_file_clone = value; +} + +inline void +Config::set_hard_link(const bool value) +{ + m_hard_link = value; +} + inline void Config::set_ignore_options(const std::string& value) { diff --git a/src/ccache.cpp b/src/ccache.cpp index c32200f40..406ae738e 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -2024,6 +2024,17 @@ do_cache_compilation(Context& ctx, const char* const* argv) ctx.config.set_depend_mode(false); } + if (ctx.storage.has_secondary_storage()) { + if (ctx.config.file_clone()) { + LOG_RAW("Disabling file clone mode since secondary storage is enabled"); + ctx.config.set_file_clone(false); + } + if (ctx.config.hard_link()) { + LOG_RAW("Disabling hard link mode since secondary storage is enabled"); + ctx.config.set_hard_link(false); + } + } + LOG("Source file: {}", ctx.args_info.input_file); if (ctx.args_info.generating_dependencies) { LOG("Dependency file: {}", ctx.args_info.output_dep); diff --git a/src/storage/Storage.cpp b/src/storage/Storage.cpp index 497bfcb9c..f5ba67e3f 100644 --- a/src/storage/Storage.cpp +++ b/src/storage/Storage.cpp @@ -329,6 +329,12 @@ Storage::remove(const Digest& key, const core::CacheEntryType type) remove_from_secondary_storage(key); } +bool +Storage::has_secondary_storage() const +{ + return !m_secondary_storages.empty(); +} + std::string Storage::get_secondary_storage_config_for_logging() const { diff --git a/src/storage/Storage.hpp b/src/storage/Storage.hpp index 3e596745a..2b245d1a1 100644 --- a/src/storage/Storage.hpp +++ b/src/storage/Storage.hpp @@ -61,6 +61,7 @@ public: void remove(const Digest& key, core::CacheEntryType type); + bool has_secondary_storage() const; std::string get_secondary_storage_config_for_logging() const; private: