From nobody Wed Oct 25 15:03:17 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 4SFsck2J06z4xdCG; Wed, 25 Oct 2023 15:03:18 +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 4SFsck1YSrz4Rgv; Wed, 25 Oct 2023 15:03:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698246198; 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=JVkTjmGgyo3EdWXdfzsOsQYhEFWbboNx/cFZZEIAJTE=; b=aqCcMpQi8hkSlGckbA6GKHudy612ank6saR6bvC8hzdUodlZio+gkMA6iOuguuej+Zb4CU HmmQbQLjPXTJm5XPKBzXzYkvbk8h2Jr14PvCKuL+5gEywvjknBVMRKX0n7z60lp8Du+c64 miz6Ki6aL88Q0aiOJGZilcSkrmO8AZ6dwg1coync2HTAKwVuIT15WbmvqTIdjiYBT7mWaO NJGRgGIV5AtZZJZeP/OMpfj8FAOZ9kequZeTEiBW0EG2wXBkcgQH7KGiFI+oiY48UfOqY+ wHR7X0KhRQF0QwIfzMSjnNY+Nk/8t/MzNB7rbRevvsVfJTEgHdilK6ImgI/maw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698246198; a=rsa-sha256; cv=none; b=oVXrkEQFSPeggGhVCLldjSqElmHCz8Ud42hiLFrucrj/7fzuXuVeYGIiGAh6NsAAOGtifR zgzKPHPOyUWbkGMnjY6gWyqAe4rha6fmhFmbcacpHRr/isF9/QXOT15TwEbBMq+Uth4xB/ /4qNQEtRw6wssQ0F8kpVXnOeW6eR44e/bOnLzJSs1Z3yqln0DYJgwX0GU9H57E4M0qkHvR e3Y3MNuyJCteTTz/PU0P4P56e8YV25JqgADgoszphrlR3hK1CfmWEm8mL+3Ff9ghO+KUhl 5cyAcd9T7OwItLyZkUdHOFvns4/yXlYmeeiaKxYHcblwjQZ++TdvWF7QvpiVkQ== 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=1698246198; 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=JVkTjmGgyo3EdWXdfzsOsQYhEFWbboNx/cFZZEIAJTE=; b=Es7UjzPl4bLlQ3Mt1DXJs9DogF+J7NnIadbonDX8gkPycsHOecU0TZDqsEo2PWQ2nsC4bl RQylhOVxyvwIzYzHKXTT3MxcQsUTPdm2ej4IRuhbwXTNFyXQX5aswRflLLgQa+vNQjcmFZ ZDQNpga6ZS8Hcxw8TvkTC0TpMmynXdUzHOp1Xvv2jqFKFfHd+Lkpw5bGohZdGiVaNUMohv zSsgsDcZZXBPTX8z1AkiZ+q/WBkPqN/kkFeCXvT7SNXboL/WDA75GG09OKRSRgZ/D0d8pL qiYkde5MILEQ/SFMHIFvXCgrmsE6FNJCi2Kkq/CMaKFuAji7y/mtFRrw3nXt+g== 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 4SFsck0dVwz181r; Wed, 25 Oct 2023 15:03:18 +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 39PF3HPR039075; Wed, 25 Oct 2023 15:03:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39PF3HZ5039072; Wed, 25 Oct 2023 15:03:17 GMT (envelope-from git) Date: Wed, 25 Oct 2023 15:03:17 GMT Message-Id: <202310251503.39PF3HZ5039072@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: cfcb53e1a132 - stable/14 - makefs/zfs: Add a regression test which checks the 'used*' properties 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: cfcb53e1a132932bf3d22e87e47e38e64b118c4a Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=cfcb53e1a132932bf3d22e87e47e38e64b118c4a commit cfcb53e1a132932bf3d22e87e47e38e64b118c4a Author: Mark Johnston AuthorDate: 2023-10-23 15:11:26 +0000 Commit: Mark Johnston CommitDate: 2023-10-25 14:27:27 +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