From nobody Tue Jul 29 21:01:54 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 4bs77l1mJhz63Plc; Tue, 29 Jul 2025 21:01:55 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bs77l0DwYz43t4; Tue, 29 Jul 2025 21:01:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753822915; 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=wboaQW3rf2UNKnMRZ7VzPrXqKdlDq6hfBarZYqSgntY=; b=ZcRiIYyDVZjsuDtsEGlbI9E4UtbGlyX/crM4WsqZK3pDI5UoyNS2XTTzsdjCCKa/LfdErK wAjxYwIbPBRhrTpc4LdwkUHB+TqoZUSfv3xquuac+Sk3hkXNJBEwijWIUCZpMw22UFZQQL qN1J2gGfi1bUKdY1amsuRzDtd6eSOOosmhUCZia2EsMa7Ei8KW9KgzJ7d+DIquLlvX8E9s vb7Sl4nxXlJY5xE02XobutwQTGm09znb1Xm7ZdPzAmD3/Y7uSxdkwjpkqVWQ4ldhNxEN6C FodkR7PuPuy0wDvgLbUEPccekD/HuEXqDZmluYeelQLeC8vi8HCfecV04oj/Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753822915; 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=wboaQW3rf2UNKnMRZ7VzPrXqKdlDq6hfBarZYqSgntY=; b=qiK6dQSw87FOus6Nfq6DPOpkTeErEcT1cA3Ud3RggbMbR/NbbZNOJARW02RAnCpvST/CB5 VON+s2GlTNl3wwlFIdbAwaZofOBV6mDP84SxAxUv0VYz0aHlvmPTsa5OVCawu3YKggrxht vjBT3fe93/6l0FFIR+MpLtsVwx5KP+I9xGr3Ge0+yDrb8mc1stMKlAbQABBior/mgYLOxy MQH+3WI5A7S2AOn1DGatO02oA/M5TB1GBMoZrKxikIMKYDYXyQOtJ2nE7GtOXbDhp+tHqX HV/JmuttQnqTPDyxsGlaAPUW06J4bV8vGgSkm9tO2PpJFOrx0VdDbbl8HNhklQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753822915; a=rsa-sha256; cv=none; b=EUjDukviFskCtwRW/WCb9qNkqaYRc3ddmLlqMJs8DBZoIRu9Phz28Gi0jaZPtfYNASUMOm 3w3qvWiAGrfK28OmdApqluGdN/XwDl8L9xIL6saIkeR24DNg+t7GR9Ftf1NnTgt0tn+8Nd 0YWmPc8clrlol+fNYC5NWxPrDG3X6G4DF8dmX7Lom3Rt5ks05WiyarQCJKUyhuF06UeApe LuwDlyZzoeXGQbZU1FB2td9FvGxJhwuAJMZhAe3FZ8FOS50/892IniXTA0Rz3HAGdWbnms 7N4B1xjzXyqhatXRxlpw68wA1SeWRRnxWtnLGvmBbLD4ly7epTvtpZBiX66qvw== 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 4bs77k6RyjznxF; Tue, 29 Jul 2025 21:01:54 +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 56TL1sre075534; Tue, 29 Jul 2025 21:01:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56TL1stQ075531; Tue, 29 Jul 2025 21:01:54 GMT (envelope-from git) Date: Tue, 29 Jul 2025 21:01:54 GMT Message-Id: <202507292101.56TL1stQ075531@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Toomas Soome Subject: git: 507f8523f5f6 - main - makefs: zfs dataset mountpoints are considered non-empty 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: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 507f8523f5f6795ad40dc6c13c84e480925f48c0 Auto-Submitted: auto-generated The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=507f8523f5f6795ad40dc6c13c84e480925f48c0 commit 507f8523f5f6795ad40dc6c13c84e480925f48c0 Author: Toomas Soome AuthorDate: 2025-07-25 21:01:46 +0000 Commit: Toomas Soome CommitDate: 2025-07-29 21:01:26 +0000 makefs: zfs dataset mountpoints are considered non-empty The dataset mountpoints get link count and size calculated by content of dataset root directory, but this will break libzfs dir_is_empty_stat() test. For fix, we need to check if the directory is mountpoint for dataset, and calculate the link count and size accordingly. Reviewed by: markj Differential revision: https://reviews.freebsd.org/D51593 --- usr.sbin/makefs/zfs/fs.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/usr.sbin/makefs/zfs/fs.c b/usr.sbin/makefs/zfs/fs.c index 0194089a357d..75f6e30e1500 100644 --- a/usr.sbin/makefs/zfs/fs.c +++ b/usr.sbin/makefs/zfs/fs.c @@ -384,22 +384,34 @@ fs_populate_sattrs(struct fs_populate_arg *arg, const fsnode *cur, links = 1; /* .. */ objsize = 1; /* .. */ - /* - * The size of a ZPL directory is the number of entries - * (including "." and ".."), and the link count is the number of - * entries which are directories (including "." and ".."). - */ - for (fsnode *c = fsnode_isroot(cur) ? cur->next : cur->child; - c != NULL; c = c->next) { - switch (c->type) { - case S_IFDIR: - links++; - /* FALLTHROUGH */ - case S_IFREG: - case S_IFLNK: - objsize++; - break; + if ((cur->inode->flags & FI_ROOT) == 0 ) { + /* + * The size of a ZPL directory is the number of entries + * (including "." and ".."), and the link count is the + * number of entries which are directories + * (including "." and ".."). + */ + for (fsnode *c = + fsnode_isroot(cur) ? cur->next : cur->child; + c != NULL; c = c->next) { + switch (c->type) { + case S_IFDIR: + links++; + /* FALLTHROUGH */ + case S_IFREG: + case S_IFLNK: + objsize++; + break; + } } + } else { + /* + * Root directory children do belong to + * different dataset and this directory is + * empty in the current objset. + */ + links++; /* . */ + objsize++; /* . */ } /* The root directory is its own parent. */