From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wPqIINPTL2F0PwEAgWs5BA (envelope-from ) for ; Wed, 01 Sep 2021 21:26:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id gGk2HNPTL2FsUgAAB5/wlQ (envelope-from ) for ; Wed, 01 Sep 2021 19:26:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E57A8195E2 for ; Wed, 1 Sep 2021 21:26:10 +0200 (CEST) Received: from localhost ([::1]:41886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLVsA-0005DR-32 for larch@yhetil.org; Wed, 01 Sep 2021 15:26:10 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Tobias Geerinckx-Rice X-ACL-Warn: , Tobias Geerinckx-Rice via Guix-patches From: Tobias Geerinckx-Rice via Guix-patches via X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630524371; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=cTjlcOLaNrG7TzN+6+jPRIKEcP18fy0/86Az9zUr4sQ=; b=ddNY+SRDEfaTl2lY81aS0scggl+brum+GJwUKMZ4fWWykqBP5UcXEa0f2xWJswlgTxVyUN wUrRYp7v1nZrBwtDund9hTpA/7xIA6T9E3IdeNTJyuaVeq3DtMvCGuJUFg/ijOz4lG4cNm 6oL+HSS9r4gc8ZlMJ/bKfjm11/H5C5NHM3PaEcSJA4jtTUqXUbyvgPrwS9LVC05fpEbxsI JS89edqjoDhTG1MnC8hov+6YpzbmsPpTh+g0iZu0bPNcr3AJCdfif/rHfl3uW8aThL9E2+ MjF5Li+Q03X909tDyb9nBLzMPGV7evHdIxKi+tyfsDCknjb6pTszOFZo9JIEww== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630524371; a=rsa-sha256; cv=none; b=R9nZtkMuQE3J+raimRmzrnc8yd1G1s2e7gOcy5cB+aKdQNZuMS9TOmO7rSHMEDAv/l2HV6 6dpL3pPf0VV1JZ+FE5DwnVzmhSwlKS5wmt4miH6Nmso7AWwmD1JKbCqeMUOHOvHIgezG9W FImOjO5c4sjqVjmoLfmu3BnLq7m1KyKATyBlJnstrF0KJupj06HxOINAmPyNSx6SJ0jttJ TIYU1CyO2r14GfLlyfhBw6lS/MujCe+DV/i34e014Lg8Ba7QLpsEL1e/EjAaln9qF7a5p1 dBu5B4En2f3I90/8m/I434B85IZK0jBVMAJIQACqyMSM5GYhfgX+hxg6X50r8w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tobias.gr header.s=2018 header.b=ejEhjAKy; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.42 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tobias.gr header.s=2018 header.b=ejEhjAKy; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: E57A8195E2 X-Spam-Score: -1.42 X-Migadu-Scanner: scn1.migadu.com X-TUID: rc4Pd5QityT+ * 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