]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Fix CCACHE_MAXSIZE with filesystem compression (#444)
authorIvan Volnov <51086293+ivan-volnov@users.noreply.github.com>
Sun, 21 Jul 2019 20:57:51 +0000 (04:57 +0800)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 15 Aug 2019 20:25:41 +0000 (22:25 +0200)
(cherry picked from commit 14d4371b50206fe9dfba45222b63a3d01605e16c)

.travis.yml
doc/NEWS.adoc
src/util.c
test/suites/cleanup.bash

index 2fde4bda9e0e077f7405a27f2173dc3fcbe14054..7669969128351dd2a3d5e490fe71c31553246b7d 100644 (file)
@@ -19,7 +19,7 @@ matrix:
     include:
         - os: linux
           compiler: gcc
-          env: CFLAGS="-m32 -g -O2" LDFLAGS="-m32" HOST="--host=i386-linux-gnu"
+          env: CFLAGS="-m32 -g -O2" LDFLAGS="-m32" HOST="--host=i386-linux-gnu" ENABLE_CACHE_CLEANUP_TESTS=1
           addons:
               apt:
                   packages:
@@ -28,7 +28,7 @@ matrix:
                       - lib32z1-dev
         - os: linux
           compiler: i686-w64-mingw32-gcc
-          env: HOST="--host=i686-w64-mingw32" TEST="unittest/run.exe"
+          env: HOST="--host=i686-w64-mingw32" TEST="unittest/run.exe" ENABLE_CACHE_CLEANUP_TESTS=1
           addons:
               apt:
                   packages:
@@ -36,13 +36,13 @@ matrix:
                       - gperf
         - os: linux
           compiler: clang
-          env: CFLAGS="-fsanitize=undefined" LDFLAGS="-fsanitize=undefined" ASAN_OPTIONS="detect_leaks=0"
+          env: CFLAGS="-fsanitize=undefined" LDFLAGS="-fsanitize=undefined" ASAN_OPTIONS="detect_leaks=0" ENABLE_CACHE_CLEANUP_TESTS=1
         - os: linux
           compiler: clang
-          env: CFLAGS="-fsanitize=address -g" LDFLAGS="-fsanitize=address" ASAN_OPTIONS="detect_leaks=0"
+          env: CFLAGS="-fsanitize=address -g" LDFLAGS="-fsanitize=address" ASAN_OPTIONS="detect_leaks=0" ENABLE_CACHE_CLEANUP_TESTS=1
         - os: linux
           compiler: clang
-          env: PATH="/usr/bin:$PATH" TEST=analyze
+          env: PATH="/usr/bin:$PATH" TEST=analyze ENABLE_CACHE_CLEANUP_TESTS=1
           addons:
               apt:
                   packages:
@@ -50,7 +50,7 @@ matrix:
                       - gperf
         - os: linux
           compiler: gcc
-          env: CUDA=8.0.61-1
+          env: CUDA=8.0.61-1 ENABLE_CACHE_CLEANUP_TESTS=1
           sudo: required
           before_install:
               - source ./.travis/install_cuda.sh
index 8661a3f88a0f3a249e552a9d3976ae08f0687f23..31425128dc66d4eec41417fa0f5893de35129d87 100644 (file)
@@ -1,6 +1,19 @@
 ccache news
 ===========
 
+ccache 3.7.3
+------------
+Unreleased
+
+Bug fixes
+~~~~~~~~~
+
+- The cache size (which is counted in "used disk blocks") is now correct on
+  filesystems that use more or less disk blocks than conventional filesystems,
+  e.g. ecryptfs or btrfs/zfs with transparent compression. This also fixes a
+  related problem with ccache's own test suite.
+
+
 ccache 3.7.2
 ------------
 Release date: 2019-07-19
index 233c932f4a3ddae81067eeefaf09c77158bf7a20..8f4490ffc46df80c20f8d430a6559d492a089308 100644 (file)
@@ -984,12 +984,7 @@ file_size(struct stat *st)
 #ifdef _WIN32
        return (st->st_size + 1023) & ~1023;
 #else
-       size_t size = st->st_blocks * 512;
-       if ((size_t)st->st_size > size) {
-               // Probably a broken stat() call...
-               size = (st->st_size + 1023) & ~1023;
-       }
-       return size;
+       return st->st_blocks * 512;
 #endif
 }
 
index f36dc75c674e8a62e7958a0c6d41890fca51f66f..a907ac499b2cca6b53bc29535b1632d639a90ad8 100644 (file)
@@ -75,32 +75,34 @@ SUITE_cleanup() {
     done
 
     # -------------------------------------------------------------------------
-    TEST "Forced cache cleanup, size limit"
-
-    # NOTE: This test is known to fail on filesystems that have unusual block
-    # sizes, including ecryptfs. The workaround is to place the test directory
-    # elsewhere:
-    #
-    #     cd /tmp
-    #     CCACHE=$DIR/ccache $DIR/test.sh
-
-    prepare_cleanup_test_dir $CCACHE_DIR/a
-
-    $CCACHE -F 0 -M 256K >/dev/null
-    $CCACHE -c >/dev/null
-    expect_file_count 3 '*.o' $CCACHE_DIR
-    expect_file_count 4 '*.d' $CCACHE_DIR
-    expect_file_count 4 '*.stderr' $CCACHE_DIR
-    expect_stat 'files in cache' 11
-    expect_stat 'cleanups performed' 1
-    for i in 0 1 2 3 4 5 6; do
-        file=$CCACHE_DIR/a/result$i-4017.o
-        expect_file_missing $file
-    done
-    for i in 7 8 9; do
-        file=$CCACHE_DIR/a/result$i-4017.o
-        expect_file_exists $file
-    done
+    if [ -n "$ENABLE_CACHE_CLEANUP_TESTS" ]; then
+        TEST "Forced cache cleanup, size limit"
+
+        # NOTE: This test is known to fail on filesystems that have unusual block
+        # sizes, including ecryptfs. The workaround is to place the test directory
+        # elsewhere:
+        #
+        #     cd /tmp
+        #     CCACHE=$DIR/ccache $DIR/test.sh
+
+        prepare_cleanup_test_dir $CCACHE_DIR/a
+
+        $CCACHE -F 0 -M 256K >/dev/null
+        $CCACHE -c >/dev/null
+        expect_file_count 3 '*.o' $CCACHE_DIR
+        expect_file_count 4 '*.d' $CCACHE_DIR
+        expect_file_count 4 '*.stderr' $CCACHE_DIR
+        expect_stat 'files in cache' 11
+        expect_stat 'cleanups performed' 1
+        for i in 0 1 2 3 4 5 6; do
+            file=$CCACHE_DIR/a/result$i-4017.o
+            expect_file_missing $file
+        done
+        for i in 7 8 9; do
+            file=$CCACHE_DIR/a/result$i-4017.o
+            expect_file_exists $file
+        done
+    fi
 
     # -------------------------------------------------------------------------
     TEST "Automatic cache cleanup, limit_multiple 0.9"