From nobody Mon Oct 23 15:18:00 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 4SDf2d0plNz4y9hx; Mon, 23 Oct 2023 15:18:01 +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 4SDf2c4HP3z4LKB; Mon, 23 Oct 2023 15:18:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698074280; 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=OfFecCSat0Dswr3vLYIy7srEtdivr4gHH31DGqBvqKk=; b=UeMdCtaS6P6bkISdHLghIArtGFQeVn8fWbcjdX5grCmaq9HOh1YTf8T9WhW41l8HMhE8Up UDcEUH5w8gpmVvf5DxzztsjomMI7iYPZHAVXZKPR2/Dy03HOExH3Ttx+etBpXaSJvuWfG3 JCY2bQDj5C9BZ2SU+htmMkb7yPp+TRPf5rFbWnKyiM/NqI43clN8SSznnvhHoFhEiplaSd wYGQqRWQln4IFxEfdZI9ePespDImxZ1RXbPyJG+hJhZON8ISOYJKT0vULEztX/GrW+yHPW 4rSzR+7Q8q7zRnLvcHTB+Wbh5dO6ui4YDY0w2ozpj0EcWG8Vt14flZXlV+wfkw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698074280; a=rsa-sha256; cv=none; b=q4DP+fttDNK9z9yUfhiw6BtS2Fb3prOHLb4yp8hwnfqgEXJcQ4oSLmlTwCkuAFPNHQ5DyA dcqlpUcuezlvMG+6tYt3QuT1LsmQg9Enzudu9IROrTup4UYL8aB4+6YCcEHEZsbEA/w+ZT ZQ6zqTY3nG4Pjv87SW6WvM7nlmIPom/SejpFfuM9KZc4M9Zlmw04bB/Rn8V+q5oXjkYJI8 KTiLvKiTbfw6PF6F1fSeIYtHlw6qBXXECq49BNkx15H0z1peFYLVuRO8HypG1AqD7rl0yG slqAKI3nz+4zdEYrbD+rUMbL99VKyUpZWl+7VEjsiMdY6Qio2EYchGy9cHsbcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698074280; 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=OfFecCSat0Dswr3vLYIy7srEtdivr4gHH31DGqBvqKk=; b=W5fkUdfONY8PsxEO4a9/sRNh4rqaRstgUBWXl1eU7VOPF0iAuuMWMFZ05o4vzgFrjqxSOW N0EBq2CqpyGWYjTV/k39e/VXMftjWOHoL5U2+9CZcY/kqOO5SSxFfGmJ4/Gc9/U3x+oxfZ TNVtKOdctvdJOr8BP41Tt41loHWhkE5fxxUfZ0qZWRVw60v1kISqpwT9Da3AifZhWvgGee lhVzh0QwV3tQT4bF9Xq9c0hdSHk6c2YMAeVEfoF3OJ6N94Egju3m+kTZE9xqXfGivlqDdN ASgk/+0aDdo7WCvLP7A+6yAa9Ylhq4flfR40MkZ0t1WkZUCe9jBrGjMN4ZpjrA== 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 4SDf2c3KcZzlDb; Mon, 23 Oct 2023 15:18:00 +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 39NFI0qP046137; Mon, 23 Oct 2023 15:18:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39NFI08m046134; Mon, 23 Oct 2023 15:18:00 GMT (envelope-from git) Date: Mon, 23 Oct 2023 15:18:00 GMT Message-Id: <202310231518.39NFI08m046134@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 9f9d18d61e74 - main - makefs/zfs: Add a regression test which checks the 'used*' properties 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9f9d18d61e74e2486d9dc0c0187eb72b02c66743 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9f9d18d61e74e2486d9dc0c0187eb72b02c66743 commit 9f9d18d61e74e2486d9dc0c0187eb72b02c66743 Author: Mark Johnston AuthorDate: 2023-10-23 15:11:26 +0000 Commit: Mark Johnston CommitDate: 2023-10-23 15:15:00 +0000 makefs/zfs: Add a regression test which checks the 'used*' properties PR: 274613 MFC after: 1 week Sponsored by: The FreeBSD Foundation --- usr.sbin/makefs/tests/makefs_zfs_tests.sh | 73 ++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/usr.sbin/makefs/tests/makefs_zfs_tests.sh b/usr.sbin/makefs/tests/makefs_zfs_tests.sh index 9173600dc555..1811b1bc8a8c 100644 --- a/usr.sbin/makefs/tests/makefs_zfs_tests.sh +++ b/usr.sbin/makefs/tests/makefs_zfs_tests.sh @@ -1,7 +1,7 @@ #- # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (c) 2022 The FreeBSD Foundation +# Copyright (c) 2022-2023 The FreeBSD Foundation # # This software was developed by Mark Johnston under sponsorship from # the FreeBSD Foundation. @@ -57,7 +57,7 @@ import_image() atf_check -e empty -o save:$TEST_MD_DEVICE_FILE -s exit:0 \ mdconfig -a -f $TEST_IMAGE atf_check -o ignore -e empty -s exit:0 \ - zdb -e -p /dev/$(cat $TEST_MD_DEVICE_FILE) -mmm -ddddd $ZFS_POOL_NAME + zdb -e -p /dev/$(cat $TEST_MD_DEVICE_FILE) -mmm -ddddd $ZFS_POOL_NAME atf_check zpool import -R $TEST_MOUNT_DIR $ZFS_POOL_NAME echo "$ZFS_POOL_NAME" > $TEST_ZFS_POOL_NAME } @@ -726,6 +726,74 @@ root_props_cleanup() common_cleanup } +# +# Verify that usedds and usedchild props are set properly. +# +atf_test_case used_space_props cleanup +used_space_props_body() +{ + local used usedds usedchild + local rootmb childmb totalmb fudge + local status + + create_test_dirs + cd $TEST_INPUTS_DIR + mkdir dir + + rootmb=17 + childmb=39 + totalmb=$(($rootmb + $childmb)) + fudge=$((2 * 1024 * 1024)) + + atf_check -e ignore dd if=/dev/random of=foo bs=1M count=$rootmb + atf_check -e ignore dd if=/dev/random of=dir/bar bs=1M count=$childmb + + cd - + + atf_check $MAKEFS -s 1g -o rootpath=/ -o poolname=$ZFS_POOL_NAME \ + -o fs=${ZFS_POOL_NAME}/dir \ + $TEST_IMAGE $TEST_INPUTS_DIR + + import_image + + # Make sure that each dataset's space usage is no more than 2MB larger + # than their files. This number is magic and might need to change + # someday. + usedds=$(zfs list -o usedds -Hp ${ZFS_POOL_NAME}) + atf_check test $usedds -gt $(($rootmb * 1024 * 1024)) -a \ + $usedds -le $(($rootmb * 1024 * 1024 + $fudge)) + usedds=$(zfs list -o usedds -Hp ${ZFS_POOL_NAME}/dir) + atf_check test $usedds -gt $(($childmb * 1024 * 1024)) -a \ + $usedds -le $(($childmb * 1024 * 1024 + $fudge)) + + # Make sure that the usedchild property value makes sense: the parent's + # value corresponds to the size of the child, and the child has no + # children. + usedchild=$(zfs list -o usedchild -Hp ${ZFS_POOL_NAME}) + atf_check test $usedchild -gt $(($childmb * 1024 * 1024)) -a \ + $usedchild -le $(($childmb * 1024 * 1024 + $fudge)) + atf_check -o inline:'0\n' \ + zfs list -Hp -o usedchild ${ZFS_POOL_NAME}/dir + + # Make sure that the used property value makes sense: the parent's + # value is the sum of the two sizes, and the child's value is the + # same as its usedds value, which has already been checked. + used=$(zfs list -o used -Hp ${ZFS_POOL_NAME}) + atf_check test $used -gt $(($totalmb * 1024 * 1024)) -a \ + $used -le $(($totalmb * 1024 * 1024 + 2 * $fudge)) + used=$(zfs list -o used -Hp ${ZFS_POOL_NAME}/dir) + atf_check -o inline:$used'\n' \ + zfs list -Hp -o usedds ${ZFS_POOL_NAME}/dir + + # Both datasets do not have snapshots. + atf_check -o inline:'0\n' zfs list -Hp -o usedsnap ${ZFS_POOL_NAME} + atf_check -o inline:'0\n' zfs list -Hp -o usedsnap ${ZFS_POOL_NAME}/dir +} +used_space_props_cleanup() +{ + common_cleanup +} + atf_init_test_cases() { atf_add_test_case autoexpand @@ -748,6 +816,7 @@ atf_init_test_cases() atf_add_test_case snapshot atf_add_test_case soft_links atf_add_test_case root_props + atf_add_test_case used_space_props # XXXMJ tests: # - test with different ashifts (at least, 9 and 12), different image sizes