From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Atomic file updates Date: Mon, 13 Jun 2016 17:00:20 +0200 Message-ID: <87twgxcewr.fsf_-_@gnu.org> References: <87wpm3qngd.fsf@gmail.com> <87a8iy68lm.fsf@gnu.org> <877fdyesni.fsf@gmail.com> <87k2hul5hc.fsf@gnu.org> <20160613112138.6a76d09b@scratchpost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCTLo-0006t8-AV for guix-devel@gnu.org; Mon, 13 Jun 2016 11:00:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCTLk-0004Rv-65 for guix-devel@gnu.org; Mon, 13 Jun 2016 11:00:27 -0400 In-Reply-To: <20160613112138.6a76d09b@scratchpost.org> (Danny Milosavljevic's message of "Mon, 13 Jun 2016 11:21:38 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Danny Milosavljevic Cc: guix-devel@gnu.org Danny Milosavljevic skribis: > However, I think the actual point is to have all the "update" actions be = atomic. Because there's something in the Linux kernel config (only on GuixS= D; works just fine on Ubuntu) which makes my laptop crashy (on the first la= rger disk write after standby wakeup) I have some experience with Guix non-= atomicity and let me tell you it's not good. (Just the other day it broke t= he substitute cache - so I couldn't use substitutes at all anymore; I've si= nce found and deleted the cache directory contents) When you stumble upon issues like this, please report them to bug-guix@gnu.org with as many details as possible. In the case of substitutes, files under /var/guix/substitute/cache are written atomically; in guix/scripts/substitute.scm, it looks like this: (with-atomic-file-output file (lambda (out) (write (cache-entry cache-url narinfo) out) and effectively it writes to a temporary file, which is then rename(2)d. I=E2=80=99m adding an fsync(2) call in =E2=80=98with-atomic-file-output=E2= =80=99, which was missing until now. Regardless, you were very unlucky to end up with a truncated file. ;-) Anyway, if your =E2=80=9Ccrashy=E2=80=9D setup allows you to uncover other = issues in this area, please do report them! > Therefore, while I wouldn't replace (or re-symlink) the entire /boot on g= uix reconfiguration (it might be on its own partition, too), it *may* be us= eful to use include files and put these there atomically, one file per vers= ion. I'm not sure whether grub supports something like "include *.inc" with= wildcards but that would be an idea. Under /boot, the only thing that GuixSD=E2=80=99s code controls is grub.cfg, which is created atomically (see =E2=80=98install-grub=E2=80=99 in (gnu bui= ld install).) The other files are installed by =E2=80=98grub-install=E2=80=99. Thanks for your feedback, Ludo=E2=80=99.