From nobody Fri Dec 1 00:38:55 2023 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 4ShDhJ0M6Sz5320V; Fri, 1 Dec 2023 00:38:56 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ShDhH6k9dz4Mpm; Fri, 1 Dec 2023 00:38:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701391135; 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=w4gZB+2GZlPIJY6Fwialws3Uz6g80otqKBsc3gcw7aY=; b=CtwzCKEZYfK0Wtp0OSdrnFKwjJ8v7MMr576eyP0Ok2/Ln3bTaPARyAzHQEXRy2Zzg0gKbu glhTfb0B+yFZd4pAy6jyHsn28dajcfMr70fGDt8iG7Y4i3zUTe5fj70WNa8YWFVmLM0geN QrkoGLc7w5/uDVRuXiFzqA9ftPAYnYwM8321Id6tS/G+EqCiG1UYP7Ab1/Ci407h0MCpsj IKX/zMcwNomFRbgI8PBtAD3Xwy5hNghkAMFtxLvpt5OEzEcK3tF5HOqeaKEaFrIDbodsby X3s+EVXxdoArJFirvpmuRgyNcM6/Vpe7dPbVgb6XOiW6AlHYz5qe3yFgjJdLag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701391135; 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=w4gZB+2GZlPIJY6Fwialws3Uz6g80otqKBsc3gcw7aY=; b=WubeMzW6yfKrTxqdK4W47ALPelJtUT1jOg/rlEzgIIsvDvXJJQ2Xp5POHpA7ueV8R80FJQ D7blZLJoHJ208CKgTz5yXT16hF7Wo+4m0A/aPoaB8Mx6jK0vw9wuDC5iGMQYVUmxifbJ0W jjAXcFwMw4janz7RPHLMN+KhJyPYOL8wIML5mOcwve+u3UcyxhrzUBWZTxXNy49ZMlDrww PSKuLsH5vbdbst4FIa05CF1pTJwF2XCgJMdCO6WfkVnEMvYSqh1ryMZocYxQ2xxbLrRVF/ cukFuF26k+tKPB5ASt8lGEu7xlBvHbTQpb9lZfILvpgVsgoprs1rA+CrX+oH3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701391135; a=rsa-sha256; cv=none; b=skFxK1sHqibBjY4jh4gnk/aNLNwejDYmLUaIpFjJBgdu8+JN2jMi2ogKbcW0fZLW+dSzF2 FrSFt7fL43lon/YCW9KkTFk05K1JtGwCKFd3zYanxDINtZ7LU8+T6ET6OKCr2cl7uuq4Bu Eyhb4Vn6eVtwflyXQpM+3JakcD2eaYG44UH/DjRyOBb3+H/NeB/o34ammfIb3ys7ZsbiOY AA310AEDJaR9YT2w5sWkVNJodfruLdjzL6WzrvCz9aormUXC9UmOnaCRBc6bryYDPCintJ l6Z6s6m3Qmw/jMqfEj3RYlRXxd3xqHZ3jBBq2xlV+LfyyAGwdVGYY8jQlWPmSg== 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 4ShDhH5m7tz1BbZ; Fri, 1 Dec 2023 00:38:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3B10ctWp057184; Fri, 1 Dec 2023 00:38:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B10ctNZ057181; Fri, 1 Dec 2023 00:38:55 GMT (envelope-from git) Date: Fri, 1 Dec 2023 00:38:55 GMT Message-Id: <202312010038.3B10ctNZ057181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: 7769487a50ff - releng/12.4 - dnode_is_dirty: check dnode and its data for dirtiness 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/12.4 X-Git-Reftype: branch X-Git-Commit: 7769487a50ff81a31c313538d914f0dc8deb5ea1 Auto-Submitted: auto-generated The branch releng/12.4 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=7769487a50ff81a31c313538d914f0dc8deb5ea1 commit 7769487a50ff81a31c313538d914f0dc8deb5ea1 Author: Rob Norris AuthorDate: 2023-11-30 05:14:13 +0000 Commit: Gordon Tetlow CommitDate: 2023-11-30 21:46:13 +0000 dnode_is_dirty: check dnode and its data for dirtiness Over its history this the dirty dnode test has been changed between checking for a dnodes being on `os_dirty_dnodes` (`dn_dirty_link`) and `dn_dirty_record`. It turns out both are actually required. In the case of appending data to a newly created file, the dnode proper is dirtied (at least to change the blocksize) and dirty records are added. Thus, a single logical operation is represented by separate dirty indicators, and must not be separated. The incorrect dirty check becomes a problem when the first block of a file is being appended to while another process is calling lseek to skip holes. There is a small window where the dnode part is undirtied while there are still dirty records. In this case, `lseek(fd, 0, SEEK_DATA)` would not know that the file is dirty, and would go to `dnode_next_offset()`. Since the object has no data blocks yet, it returns `ESRCH`, indicating no data found, which results in `ENXIO` being returned to `lseek()`'s caller. This change simply updates the dirty check to check both types of dirty. If there's anything dirty at all, we immediately go to the "wait for sync" stage, It doesn't really matter after that; both changes are on disk, so the dirty fields should be correct. Sponsored by: Klara, Inc. Sponsored by: Wasabi Technology, Inc. Approved by: so Security: FreeBSD-EN-23:16.openzfs (cherry picked from commit 8959056352256e79a63ba6327f0a0ee4236d3e7f) --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c index 45ac4b796fd2..bd78daf5d517 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c @@ -2557,7 +2557,8 @@ dmu_object_wait_synced(objset_t *os, uint64_t object) } for (i = 0; i < TXG_SIZE; i++) { - if (list_link_active(&dn->dn_dirty_link[i])) { + if (list_link_active(&dn->dn_dirty_link[i]) || + !list_is_empty(&dn->dn_dirty_records[i])) { break; } }