unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Tobias Geerinckx-Rice via Guix-patches via <guix-patches@gnu.org>
To: 50327@debbugs.gnu.org
Subject: [bug#50327] [PATCH 1/2] daemon: Print which disk(s) are how full.
Date: Wed,  1 Sep 2021 21:25:44 +0200	[thread overview]
Message-ID: <20210901192545.12347-1-me@tobias.gr> (raw)
In-Reply-To: <875yvkaymg.fsf@nckx>

* 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	other threads:[~2021-09-01 19:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 19:05 [bug#50327] [PATCH 0/2] Improved ‘free disk space’ message + a question Tobias Geerinckx-Rice via Guix-patches via
2021-09-01 19:25 ` Tobias Geerinckx-Rice via Guix-patches via [this message]
2021-09-01 19:25   ` [bug#50327] [PATCH 2/2] daemon: Suspect low disk space sooner Tobias Geerinckx-Rice via Guix-patches via
2021-09-18  9:53   ` [bug#50327] [PATCH 0/2] Improved ‘free disk space’ message + a question Ludovic Courtès
2021-09-18  9:55 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210901192545.12347-1-me@tobias.gr \
    --to=guix-patches@gnu.org \
    --cc=50327@debbugs.gnu.org \
    --cc=me@tobias.gr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).