From owner-freebsd-questions@freebsd.org Thu Jun 17 09:19:07 2021 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 83E0664FFF1 for ; Thu, 17 Jun 2021 09:19:07 +0000 (UTC) (envelope-from grahamperrin@gmail.com) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G5GhV3cxjz3w1L for ; Thu, 17 Jun 2021 09:19:06 +0000 (UTC) (envelope-from grahamperrin@gmail.com) Received: by mail-wr1-x432.google.com with SMTP id n7so5926224wri.3 for ; Thu, 17 Jun 2021 02:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=qGN/tDd2ZxThZJOJmgRG4KEW0xlYKOxCoxel+YsHA0M=; b=Z0+DR1nXarrKfFIame/Ui522g7NlNU/enCUgKY1YjzzDHkaKeNBrkUAdHVGMYjpWBM v4f0t6xBgyxpWVZ8Vot+LwnuoDqxp2QXynKY3F0xaIkw65oy/yhpTRaMYZ2aM5+99cg1 VgkBx1YB5zyVBfjQSBKUgv8EZgylLYMnIN72vQVW/1KRRsj0yoT49mCdMYkXxcufqMMP PPyTTU58emNbFvwzxo3e1cRZS3xlUH+BPhTSAghAD4QUDmnck2IsrUIY89kTU0GY7iSf KdxUnu3ONEnxdaZoImkpKDwQgT8weloIhCTaaQJv5siag71xDOftS+0k7ECNwIqUz4lG kQtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=qGN/tDd2ZxThZJOJmgRG4KEW0xlYKOxCoxel+YsHA0M=; b=rKsrLDqjH/XxD0DJebIXlUC7U3FVS13zhZmkG43CRc4K77+Bn+bPAgcByY6yoR8VjQ dBaGZMF4RKFNQkiEtF2xJwsyrPsFRX7UjeZGcdK7wHwL/NGTGvRyJAuVFLM9VueD6fMv wHb0uT1BJHi244cOChROWAjF3AXyiQ+IJg4QZThFTo0uWTABHT//rZe2IOZyUADxeS9z 9wYzxfAOfNtorhwICcEut8dxZ5qu8DYsLvOOQGRb3GnTpGERbtIIPxW1z0nZLqBlbZAd Bh2o2cjahrOxyqDaC2zWN/lp9I+SXK/SLWOGgtklmKzAi5ov1pE5LTmDqfwKTCKbw1Ai H92A== X-Gm-Message-State: AOAM532iW9N2QUoPnDJwDO+W5DuKhgOGmd6ICKXSptximI4YEMPYTHRI w1h2qNpGn/i3uHXbqK/Qo1UjbRNqsrnc2FO1 X-Google-Smtp-Source: ABdhPJyutGWgn5sE3ASHKGtGXtP8tLa98xaIh9FvWoghD2aHXaGhgdSoSssZxq/81XKTa5zvIdvXYw== X-Received: by 2002:a05:6000:1110:: with SMTP id z16mr4376091wrw.277.1623921544148; Thu, 17 Jun 2021 02:19:04 -0700 (PDT) Received: from ?IPv6:2001:470:1f1c:a0::2? (tunnel642390-pt.tunnel.tserv1.lon2.ipv6.he.net. [2001:470:1f1c:a0::2]) by smtp.gmail.com with ESMTPSA id n7sm6909688wmq.37.2021.06.17.02.19.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Jun 2021 02:19:03 -0700 (PDT) Subject: Safety harnesses (was: Is a successful call to write(2) atomic?) To: freebsd-questions@freebsd.org References: <26258.1623802141@segfault.tristatelogic.com> <7801a6e8-2428-619e-5722-7317841595a1@qeng-ho.org> From: Graham Perrin Message-ID: Date: Thu, 17 Jun 2021 10:19:02 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <7801a6e8-2428-619e-5722-7317841595a1@qeng-ho.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-Rspamd-Queue-Id: 4G5GhV3cxjz3w1L X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=Z0+DR1nX; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of grahamperrin@gmail.com designates 2a00:1450:4864:20::432 as permitted sender) smtp.mailfrom=grahamperrin@gmail.com X-Spamd-Result: default: False [-3.98 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-0.99)[-0.986]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; SUBJECT_HAS_QUESTION(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::432:from]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; NEURAL_HAM_MEDIUM(-1.00)[-0.998]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::432:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::432:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2021 09:19:07 -0000 On 16/06/2021 14:17, Arthur Chance wrote: > … More like "we think the builders may have installed the floors in this > darkened building, but we suggest a flashlight and safety harness" … Vaguely related, from the perspective of someone who's not a developer, I was recently surprised by the potential downsides of defaults when FreeBSD is installed to UFS. For a moment, back to the opening post from Ronald F. Guilmette: >> … Is a block of data that is successfully written … The surprise, to me, was losing fifty-something seconds' worth of data in a kernel panic situation. Subsequently found, in the FreeBSD Handbook under '12.10.2. Soft Updates' : >>> … Soft Updates guarantee file system consistency in the case of a >>> crash, but could easily be several seconds or even a minute behind >>> updating the physical disk. If the system crashes, unwritten data >>> may be lost. … (I expected _some_ data loss, but sixty seconds surprised me.) It was suggested that disabling UFS soft updates might improve the situation. Through subsequent tests, with a disposable installation – soft updates disabled, carefully timed interruptions whilst using pkg-install(8) – I soon produced what seemed to be a wrecked base system. Photographs after the crash: – and after booting from a usable operating system, to check then repair the file system: With the file system repaired: still, the base system was broken. Metaphorically, dropped without a safety harness from a height of more than one floor :-) From this end result, I assume that: 1. for guaranteed file system consistency with UFS, soft updates may be _highly_ desirable, in some situations 2. some other approach should be taken to reducing the potential scope (sixty seconds) of data loss. --- Some surprise at the default delays for syncing files, directories and metadata. Respectively: 30, 29 and 28 seconds. syncer(4) ---- For the computer where I wrecked the file system, I imagine that (for a future test installation) this combination will be reasonable: - soft updates disabled - mount(8) option 'sync' set in /etc/fstab (does this reduce the risk of   wreckage with soft updates disabled?) - reduced delays for syncer(4). That's my imagination, although honestly, the whole thing messed with my mind. I'm much happier to simply use OpenZFS (or ZFS).