From nobody Fri Oct 31 14:41:34 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cykFW1kb0z6FvM5; Fri, 31 Oct 2025 14:41:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cykFV4nVWz3SXx; Fri, 31 Oct 2025 14:41:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761921694; h=from:from: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; bh=8CQ5OPkT+EYVaKSA2rs4YTwMIKyvX+8IlKZdREFIneY=; b=AyDccVuPQ8xDygmvqXxeX6GDBrJt3KhB9R9dMukWFz8yWabU1XPBB0rrDA55AlsMDEwFSC LFvWQ+FzvDYTc2+FmHBNjiXW1bgnX1O1ZMMk8YRmdvcOF+1vXIQG87JVMwHgnW1nlemkFL SPJJeYFME6LxZ76AFFk3dFDTv174ABAnf4HPDfTlK0u+q7hwfCjPqyrFkEk/85WRUSGYXd bWE6MxXEbd7/walrq0FldLqzGEd96hILlLXiEGcEq/bG79ikUQKPW+MyI670So5rwwao6/ yfu6EH+7hGKJUJb+iWuVshDW+hmzPoK/MTVmYio04/6A+NOLhcJPgUufVxLu5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761921694; h=from:from: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; bh=8CQ5OPkT+EYVaKSA2rs4YTwMIKyvX+8IlKZdREFIneY=; b=g5hITBsruropON7yRDHu2vd279sCvhu29VlGIiVyDj78lsRjy7AWMs4fkxZE81Qmh2HKko 7PZCXjI1gwg4X/gPBqn8NxnQWHFTeD5FnoAMSz30igQkPQcMhHwRa1t3tycqTo9c8YiA5r RAGnaBzl5bZcx4ZT+u+PBuMbJwFqIPrTejScASv/5GTMCqXo04CEJQe+qIJ5JI3ZkNZiQw V7FDzhrEquJ1XZkQWJsW3X1A24TxcqhYkHNpJVFowskRcI6IEiGrkGFVoZI3Aj0UvVo2nm NPNfW8xIFDANLHQkArSfAr3Ka9K9buhuS7/pZF7eQ1Su/VW2yNiQy8eD+KdIaA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761921694; a=rsa-sha256; cv=none; b=Viyb9gBiKIhzVmi/hzUI46L40SuwD+4bBg25iRJMYUtBJyvxVq8Pbm3kMGSbBpqPWkvMnE 2Tn7I2lQmb1WAJ1DANfIkGwquvsP4AoRgR9ABwmoacAxAPB5cNUp0IT2mA3bgHdkhrUs/c VvEvoh0F9MxpFCR0P7agjPdoNoY1Xk7oLQeRWACiDu8ZkvrpQcfA1BB0gyYCmfXTDqrpgR rHxOQ81DOcMWxcM/iW+x+JzbtoFiwTTBBZm5eBE2bCY91sx6hSpykBrOhyU7Zihul5FF02 F69LdgnF+kstaAC/9wHHcQsmJ7AMR3EeExvMZn2w8Uf1tNvclVaOO0AOqGkJlg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cykFV4NzQz1BmV; Fri, 31 Oct 2025 14:41:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59VEfY6t063231; Fri, 31 Oct 2025 14:41:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59VEfYw6063228; Fri, 31 Oct 2025 14:41:34 GMT (envelope-from git) Date: Fri, 31 Oct 2025 14:41:34 GMT Message-Id: <202510311441.59VEfYw6063228@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 514c8f173ce0 - stable/15 - write.2: explain the atomicity guarantees of the writes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 514c8f173ce0597c51b5f651a4ef6863aeb2aa33 Auto-Submitted: auto-generated The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=514c8f173ce0597c51b5f651a4ef6863aeb2aa33 commit 514c8f173ce0597c51b5f651a4ef6863aeb2aa33 Author: Konstantin Belousov AuthorDate: 2025-10-26 14:57:16 +0000 Commit: Konstantin Belousov CommitDate: 2025-10-31 14:41:03 +0000 write.2: explain the atomicity guarantees of the writes (cherry picked from commit 1c8d7bb4cf7a6b19262333b2a9b1dacf3094b938) --- lib/libsys/write.2 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/libsys/write.2 b/lib/libsys/write.2 index d2ff41ceead9..77067893ab4c 100644 --- a/lib/libsys/write.2 +++ b/lib/libsys/write.2 @@ -132,6 +132,26 @@ and may write fewer bytes than requested; the return value must be noted, and the remainder of the operation should be retried when possible. +.Sh ATOMICITY OF WRITES +When operating on regular files on local file systems, the effects of +.Fn write +are atomic. +As required by the POSIX standard, +the +.Fn read , +.Fn write , +and +.Fn ftruncate +functions and their variations are atomic with respect to +each other on the file data and metadata for regular files. +See for instance +.St -p1003.1-2024 +Volume 2, Section 2.9.7 for more information. +.Pp +.Fx +implements the requirement by taking +a read/write range lock on the file byte range +affected by the corresponding function. .Sh RETURN VALUES Upon successful completion the number of bytes which were written is returned.