From 4595a0e8f118db6c81aeb38e0b0286ee34d3bc40 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 4 Feb 2025 12:54:19 +0100 Subject: just-mr gc-repo: support drop only As opposed to the regular CAS/cache, for the git repository implicit in the repository cache we cannot guarantee that data from older generation is always promoted via hard links. Therefore, a certain amount of data can be duplicated between the repo-cache generations. In order to allow compacting storage to the minimum, add an option to gc-repo to only remove the older generation, without rotating. --- src/other_tools/just_mr/cli.hpp | 13 +++++++++++++ src/other_tools/just_mr/main.cpp | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp index 0c3e63a9..96f7cba2 100644 --- a/src/other_tools/just_mr/cli.hpp +++ b/src/other_tools/just_mr/cli.hpp @@ -85,6 +85,10 @@ struct MultiRepoUpdateArguments { std::vector repos_to_update; }; +struct MultiRepoGcArguments { + bool drop_only{false}; +}; + struct MultiRepoJustSubCmdsArguments { std::optional subcmd_name{std::nullopt}; std::vector additional_just_args; @@ -124,6 +128,7 @@ struct CommandLineArguments { MultiRepoSetupArguments setup; MultiRepoFetchArguments fetch; MultiRepoUpdateArguments update; + MultiRepoGcArguments gc; MultiRepoJustSubCmdsArguments just_cmd; MultiRepoRemoteAuthArguments auth; ForwardOnlyArguments launch_fwd; @@ -338,6 +343,14 @@ static inline void SetupMultiRepoUpdateArguments( ->type_name(""); } +static inline void SetupMultiRepoGcArguments( + gsl::not_null const& app, + gsl::not_null const& clargs) { + app->add_flag("--drop-only", + clargs->drop_only, + "Only drop old repository generations"); +} + static inline auto SetupMultiRepoRemoteAuthArguments( gsl::not_null const& app, gsl::not_null const& authargs) { diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index 28d4669f..d65cbb50 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -82,6 +82,13 @@ void SetupUpdateCommandArguments( SetupMultiRepoUpdateArguments(app, &clargs->update); } +/// \brief Setup arguments for subcommand "just-mr gc-repo". +void SetupUpdateGcArguments( + gsl::not_null const& app, + gsl::not_null const& clargs) { + SetupMultiRepoGcArguments(app, &clargs->gc); +} + /// \brief Setup arguments for subcommand "just-mr setup" and /// "just-mr setup-env". void SetupSetupCommandArguments( @@ -133,6 +140,7 @@ void SetupSetupCommandArguments( SetupSetupCommandArguments(cmd_setup_env, &clargs); SetupFetchCommandArguments(cmd_fetch, &clargs); SetupUpdateCommandArguments(cmd_update, &clargs); + SetupUpdateGcArguments(cmd_gc_repo, &clargs); // for 'just' calls, allow extra arguments cmd_do->allow_extras(); @@ -336,7 +344,7 @@ auto main(int argc, char* argv[]) -> int { if (arguments.cmd == SubCommand::kGcRepo) { return RepositoryGarbageCollector::TriggerGarbageCollection( - *native_storage_config) + *native_storage_config, arguments.gc.drop_only) ? kExitSuccess : kExitBuiltinCommandFailure; } -- cgit v1.2.3