From patchwork Wed Sep 1 19:25:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Geerinckx-Rice X-Patchwork-Id: 32493 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B245B27BBE3; Wed, 1 Sep 2021 20:26:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 70A3F27BBE1 for ; Wed, 1 Sep 2021 20:26:13 +0100 (BST) Received: from localhost ([::1]:41886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLVsC-0005DR-Hf for patchwork@mira.cbaines.net; Wed, 01 Sep 2021 15:26:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLVs2-0005Cw-7C for guix-patches@gnu.org; Wed, 01 Sep 2021 15:26:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLVs1-0008US-VD for guix-patches@gnu.org; Wed, 01 Sep 2021 15:26:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mLVs1-0000I2-RM for guix-patches@gnu.org; Wed, 01 Sep 2021 15:26:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50327] [PATCH 1/2] daemon: Print which disk(s) are how full. References: <875yvkaymg.fsf@nckx> In-Reply-To: <875yvkaymg.fsf@nckx> Resent-From: Tobias Geerinckx-Rice Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 01 Sep 2021 19:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50327 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50327@debbugs.gnu.org Received: via spool by 50327-submit@debbugs.gnu.org id=B50327.16305243541088 (code B ref 50327); Wed, 01 Sep 2021 19:26:01 +0000 Received: (at 50327) by debbugs.gnu.org; 1 Sep 2021 19:25:54 +0000 Received: from localhost ([127.0.0.1]:39048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mLVrt-0000HP-N2 for submit@debbugs.gnu.org; Wed, 01 Sep 2021 15:25:53 -0400 Received: from tobias.gr ([80.241.217.52]:52760) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mLVrs-0000HG-CG for 50327@debbugs.gnu.org; Wed, 01 Sep 2021 15:25:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=2018; bh=cTjlcOLaNrG7T zN+6+jPRIKEcP18fy0/86Az9zUr4sQ=; h=date:subject:to:from; d=tobias.gr; b=ejEhjAKy3lAJS2tr7Ys8QnG5C/Xp0oH6ZgEVrx0wrt8Ym0mK0pEZRCgn85WrxavJS+Za OYTohIr3dsCp+R+AXtjjMK+nX3veCUgfg5FR8AKuyiheqJOBZ9wQwJYskXaP7caQaIgdE5 hbzkIjwsUHp+ve3zg7HDlNDjlfRBlgVQz9/hrapIy/7e7TE3i0CNrtP8SIFnkfrdNHMS+i /qKDC6BPqqFQ3ndft0GFeCv34PtBLAsU1t1CDEhN0PlgWYU2sRArbfe5qZmqg4QrT3OGj8 BUzHqRpG4vfsor/xdDiqx+Ewc0bvE66kBVB1izULZYJLCxjFOdtGt7yNJ+oPspmQ== Received: by submission.tobias.gr (OpenSMTPD) with ESMTPSA id 702b486c (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <50327@debbugs.gnu.org>; Wed, 1 Sep 2021 19:25:47 +0000 (UTC) Date: Wed, 1 Sep 2021 21:25:44 +0200 Message-Id: <20210901192545.12347-1-me@tobias.gr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Tobias Geerinckx-Rice X-ACL-Warn: , Tobias Geerinckx-Rice via Guix-patches X-Patchwork-Original-From: Tobias Geerinckx-Rice via Guix-patches via From: Tobias Geerinckx-Rice X-getmail-retrieved-from-mailbox: Patches * 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);