From nobody Thu Nov 30 12:57:58 2023 X-Original-To: dev-commits-src-branches@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 4Sgx7V5fTPz53Hc4; Thu, 30 Nov 2023 12:57:58 +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 4Sgx7V5B88z3YBJ; Thu, 30 Nov 2023 12:57:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701349078; 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=6puKfbQxbvqaQv5d404juJz8SUb0gmdsyQonp1j9Vfc=; b=WtNrXclcZocndHF2LHOEgADXd4lr6ouccx/FZax0lVyGRiTMc6Ib3ELrdG2+Tt1KbCLpx9 IpEXQWSxI1KBvRel0up3z+OjY1D9LHixVyXsjqK5xbrHNLRYQexNjwc8n5c6lbi2D384Ki 5CgoBl4G0IVwzsL7ZYOIRCCqKHPgyTwEHKTiCvVOPT/662nwruSJN5D8rXvaj6EAaHKtw8 GHQlolb86M+3UmAdYHG5gzU5IV8+4zJqX9AxkNo6+P9fdLAe5XUeGupENCamfr9Nqgho9S UUobPRPysluqKwXe+jQ0Zl4HXW2MwkgcFovRZDcztXBHP84mZKNfqrSJ7+8qCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701349078; 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=6puKfbQxbvqaQv5d404juJz8SUb0gmdsyQonp1j9Vfc=; b=jFE6+K2kx4hkFLu/Kyz1Q5RRsEtHGrdWQvddY+zBwfbiHBXfKjfmoRaa2fiAwML2Nr2PjZ w5ReJNyJK+F3OFfOTle/ezlDkdq00015/Tx8QSy98COvS87HjqlK9DocUayQmNiafr2PgT 7rvQFXsdRcmvtb60fQvKq6YZUnXrHHgRuDD3dpx5pBxnfbr/0sy254VFkruwYC9TU8VMvJ AqZAKBurAx4NXkMxUVQS8p+SuPmpaxr+ajvbc0AVBzjKdUYmb4duc7EeLAherWsdkoQeB+ iUoYeiuatUEbQX2i3y9OkXDdVRQiyWjWnrCWXnR+6FM3ukRJFf/6lDm2TcW9hQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701349078; a=rsa-sha256; cv=none; b=UPrfsgW7TUkPO5NSx9iTeQ3j2jLK3uZ6KD4Wd2oBw1KJFzN3uXhPFq46NjFGF9Wtc02yfE aNNufpJB6ff3/Q5VADIuqgvVqIhuwwHO+ihM+6Y+9S6ADlpo04AIxpUsG0suMe+i4Dg4IO vJECIfFBPAQ0NeZQy+wXcG24kEHJhpotyI26UgL/8aZfer8E5lKNNCUBHl28pfmmV3nS2F gEH2NQemaC5jcIlB6mclqDto8lD0IYyKFdTnaMh9C5H2cNM2E38s5zi3fccI+fW8eGGKPu NZlKMlBonkev+0JQ4Zhrk4VPnuClBoOWXWTSIg9RjMcFOsaTowKbvR4OFdRmpQ== 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 4Sgx7V4Ds1zqMk; Thu, 30 Nov 2023 12:57:58 +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 3AUCvwEX088425; Thu, 30 Nov 2023 12:57:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AUCvwNG088422; Thu, 30 Nov 2023 12:57:58 GMT (envelope-from git) Date: Thu, 30 Nov 2023 12:57:58 GMT Message-Id: <202311301257.3AUCvwNG088422@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 895905635225 - stable/12 - dnode_is_dirty: check dnode and its data for dirtiness List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8959056352256e79a63ba6327f0a0ee4236d3e7f Auto-Submitted: auto-generated The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=8959056352256e79a63ba6327f0a0ee4236d3e7f commit 8959056352256e79a63ba6327f0a0ee4236d3e7f Author: Rob Norris AuthorDate: 2023-11-30 05:14:13 +0000 Commit: Ed Maste CommitDate: 2023-11-30 05:28:33 +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. --- 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; } }