guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#50327] [PATCH 1/2] daemon: Print which disk(s) are how full.


From: Tobias Geerinckx-Rice
Subject: [bug#50327] [PATCH 1/2] daemon: Print which disk(s) are how full.
Date: Wed, 1 Sep 2021 21:25:44 +0200

* nix/libstore/build.cc (pathFull): New function.
(DerivationGoal::buildDone): Use it.
---
 nix/libstore/build.cc | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 5697ae5a43..963cddb98b 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -1297,6 +1297,25 @@ void replaceValidPath(const Path & storePath, const Path 
tmpPath)
         deletePath(oldPath);
 }
 
+static bool pathFull(Path path)
+{
+#if HAVE_STATVFS
+    unsigned long long required = 8ULL * 1024 * 1024; // FIXME: make 
configurable
+    struct statvfs st;
+
+    if (statvfs(path.c_str(), &st) == 0) {
+        unsigned long long free = (unsigned long long) st.f_bavail * 
st.f_bsize;
+        if (free < required) {
+            printMsg(lvlError, format("note: only %1$.2f MiB available in 
‘%2%’")
+                                      % (free / (1024.0 * 1024.0)) % path);
+            return true;
+        }
+    }
+#endif
+
+    return false;
+}
+
 
 MakeError(NotDeterministic, BuildError)
 
@@ -1355,16 +1374,10 @@ void DerivationGoal::buildDone()
                of knowing whether the build actually got an ENOSPC.
                So instead, check if the disk is (nearly) full now.  If
                so, we don't mark this build as a permanent failure. */
-#if HAVE_STATVFS
-            unsigned long long required = 8ULL * 1024 * 1024; // FIXME: make 
configurable
-            struct statvfs st;
-            if (statvfs(settings.nixStore.c_str(), &st) == 0 &&
-                (unsigned long long) st.f_bavail * st.f_bsize < required)
+            if (pathFull(settings.nixStore))
                 diskFull = true;
-            if (statvfs(tmpDir.c_str(), &st) == 0 &&
-                (unsigned long long) st.f_bavail * st.f_bsize < required)
+            if (pathFull(tmpDir))
                 diskFull = true;
-#endif
 
             deleteTmpDir(false);
 
-- 
2.32.0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]