mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-31 11:14:09 +03:00
Add support for user/group dnode accounting & quota
This patch tracks dnode usage for each user/group in the DMU_USER/GROUPUSED_OBJECT ZAPs. ZAP entries dedicated to dnode accounting have the key prefixed with "obj-" followed by the UID/GID in string format (as done for the block accounting). A new SPA feature has been added for dnode accounting as well as a new ZPL version. The SPA feature must be enabled in the pool before upgrading the zfs filesystem. During the zfs version upgrade, a "quotacheck" will be executed by marking all dnode as dirty. ZoL-bug-id: https://github.com/zfsonlinux/zfs/issues/3500 Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com> Signed-off-by: Johann Lombardi <johann.lombardi@intel.com>
This commit is contained in:
committed by
Brian Behlendorf
parent
af322debaa
commit
1de321e626
@@ -0,0 +1,5 @@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/upgrade
|
||||
dist_pkgdata_SCRIPTS = \
|
||||
setup.ksh \
|
||||
cleanup.ksh \
|
||||
upgrade_userobj_001_pos.ksh
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2016 by Jinshan Xiong. No rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
log_must $ZPOOL destroy $TESTPOOL
|
||||
|
||||
log_must $RM /tmp/zpool_upgrade_test.dat
|
||||
|
||||
default_cleanup
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2016 by Jinshan Xiong. No rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
# create a pool without any features
|
||||
log_must $MKFILE 128m /tmp/zpool_upgrade_test.dat
|
||||
log_must $ZPOOL create -d -m $TESTDIR $TESTPOOL /tmp/zpool_upgrade_test.dat
|
||||
|
||||
log_pass
|
||||
@@ -0,0 +1,98 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2013 by Jinshan Xiong. No rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
#
|
||||
# Check that zfs upgrade for object count accounting works.
|
||||
# Since userobjaccounting is a per dataset feature, this test case
|
||||
# will create multiple dataset and try different upgrade method.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create a pool with all features disabled
|
||||
# 2. Create a few dataset for testing
|
||||
# 3. Make sure automatic upgrade work
|
||||
# 4. Make sure manual upgrade work
|
||||
#
|
||||
|
||||
function cleanup
|
||||
{
|
||||
datasetexists $TESTPOOL/fs1 && log_must $ZFS destroy $TESTPOOL/fs1
|
||||
datasetexists $TESTPOOL/fs2 && log_must $ZFS destroy $TESTPOOL/fs2
|
||||
}
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
log_assert "pool upgrade for userobj accounting should work"
|
||||
log_onexit cleanup
|
||||
|
||||
log_must $MKFILES $TESTDIR/tf $((RANDOM % 1000 + 1))
|
||||
log_must $ZFS create $TESTPOOL/fs1
|
||||
log_must $MKFILES $TESTDIR/fs1/tf $((RANDOM % 1000 + 1))
|
||||
log_must $ZFS create $TESTPOOL/fs2
|
||||
log_must $MKFILES $TESTDIR/fs2/tf $((RANDOM % 1000 + 1))
|
||||
log_must $ZFS umount $TESTPOOL/fs2
|
||||
|
||||
# Make sure userobj accounting is disabled
|
||||
$ZFS userspace -o objused -H $TESTPOOL | $HEAD -n 1 | $GREP -q "-" ||
|
||||
log_fail "userobj accounting should be disabled initially"
|
||||
|
||||
# Upgrade zpool to support all features
|
||||
log_must $ZPOOL upgrade $TESTPOOL
|
||||
|
||||
# Make sure userobj accounting is disabled again
|
||||
$ZFS userspace -o objused -H $TESTPOOL | $HEAD -n 1 | $GREP -q "-" ||
|
||||
log_fail "userobj accounting should be disabled after pool upgrade"
|
||||
|
||||
# Create a file in fs1 should trigger dataset upgrade
|
||||
log_must $MKFILE 1m $TESTDIR/fs1/tf
|
||||
sync_pool
|
||||
|
||||
# Make sure userobj accounting is working for fs1
|
||||
$ZFS userspace -o objused -H $TESTPOOL/fs1 | $HEAD -n 1 | $GREP -q "-" &&
|
||||
log_fail "userobj accounting should be enabled for $TESTPOOL/fs1"
|
||||
|
||||
# Mount a dataset should trigger upgrade
|
||||
log_must $ZFS mount $TESTPOOL/fs2
|
||||
sync_pool
|
||||
|
||||
# Make sure userobj accounting is working for fs2
|
||||
$ZFS userspace -o objused -H $TESTPOOL/fs2 | $HEAD -n 1 | $GREP -q "-" &&
|
||||
log_fail "userobj accounting should be enabled for $TESTPOOL/fs2"
|
||||
|
||||
# All in all, after having been through this, the dataset for testpool
|
||||
# still shouldn't be upgraded
|
||||
$ZFS userspace -o objused -H $TESTPOOL | $HEAD -n 1 | $GREP -q "-" ||
|
||||
log_fail "userobj accounting should be disabled for $TESTPOOL"
|
||||
|
||||
# Manual upgrade root dataset
|
||||
log_must $ZFS set version=current $TESTPOOL
|
||||
$ZFS userspace -o objused -H $TESTPOOL | $HEAD -n 1 | $GREP -q "-" &&
|
||||
log_fail "userobj accounting should be enabled for $TESTPOOL"
|
||||
|
||||
log_pass "all tests passed - what a lucky day!"
|
||||
Reference in New Issue
Block a user