Don't rely on st_blocks

It doesn't seem very reliable on ZFS.
This commit is contained in:
Eelco Dolstra 2019-08-29 14:49:58 +02:00
parent 31f5ecfaa5
commit a2c4fcd5e9
3 changed files with 6 additions and 7 deletions

View file

@ -690,9 +690,8 @@ void LocalStore::removeUnusedLinks(const GCState & state)
throw SysError(format("statting '%1%'") % path);
if (st.st_nlink != 1) {
unsigned long long size = st.st_blocks * 512ULL;
actualSize += size;
unsharedSize += (st.st_nlink - 1) * size;
actualSize += st.st_size;
unsharedSize += (st.st_nlink - 1) * st.st_size;
continue;
}
@ -701,7 +700,7 @@ void LocalStore::removeUnusedLinks(const GCState & state)
if (unlink(path.c_str()) == -1)
throw SysError(format("deleting '%1%'") % path);
state.results.bytesFreed += st.st_blocks * 512ULL;
state.results.bytesFreed += st.st_size;
}
struct stat st;

View file

@ -397,7 +397,7 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed)
}
if (!S_ISDIR(st.st_mode) && st.st_nlink == 1)
bytesFreed += st.st_blocks * 512;
bytesFreed += st.st_size;
if (S_ISDIR(st.st_mode)) {
/* Make the directory accessible. */

View file

@ -22,7 +22,7 @@ with import ./config.nix; mkDerivation {
echo foo > \$out/bar
echo 1...
sleep 2
echo 100 > $fake_free
echo 200 > $fake_free
echo 2...
sleep 2
echo 3...
@ -44,7 +44,7 @@ with import ./config.nix; mkDerivation {
echo foo > \$out/bar
echo 1...
sleep 2
echo 100 > $fake_free
echo 200 > $fake_free
echo 2...
sleep 2
echo 3...