aboutsummaryrefslogtreecommitdiff
path: root/nix/libstore
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-01-11 18:46:23 +0100
committerLudovic Courtès <ludo@gnu.org>2020-01-12 00:19:09 +0100
commit7033c7692ccbbbad8f7b9952015de071a5588e87 (patch)
treeb9745bafa5fc88819f55224aa06a048d760ca063 /nix/libstore
parent79154f0a09ad748839f88120ddd61a0e1e147b5e (diff)
downloadguix-7033c7692ccbbbad8f7b9952015de071a5588e87.tar
guix-7033c7692ccbbbad8f7b9952015de071a5588e87.tar.gz
daemon: Account for deleted store files when deduplication is on.
Previously, a store item that is a regular file would not be accounted for in the 'bytesFreed' value computed by 'deletePath' because its 'st_nlink' count would always be >= 2. This commit fixes that. * nix/libutil/util.hh (deletePath): Add optional 'linkThreshold' argument. * nix/libutil/util.cc (_deletePath): Add 'linkThreshold' argument and honor it. Pass it down in recursive call. (deletePath): Add 'linkThreshold' and honor it. * nix/libstore/gc.cc (LocalStore::deleteGarbage): Pass 'linkThreshold' argument to 'deletePath', with a value of 2 when PATH is a store item and deduplication is on.
Diffstat (limited to 'nix/libstore')
-rw-r--r--nix/libstore/gc.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc
index 29b75aa875..5043963fa2 100644
--- a/nix/libstore/gc.cc
+++ b/nix/libstore/gc.cc
@@ -392,7 +392,14 @@ bool LocalStore::isActiveTempFile(const GCState & state,
void LocalStore::deleteGarbage(GCState & state, const Path & path)
{
unsigned long long bytesFreed;
- deletePath(path, bytesFreed);
+
+ /* When deduplication is on, store items always have at least two links:
+ the one at PATH, and one in /gnu/store/.links. In that case, increase
+ bytesFreed when PATH has two or fewer links. */
+ size_t linkThreshold =
+ (settings.autoOptimiseStore && isStorePath(path)) ? 2 : 1;
+
+ deletePath(path, bytesFreed, linkThreshold);
state.results.bytesFreed += bytesFreed;
}