mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Fast Dedup: ZAP Shrinking
This allows ZAPs to shrink. When there are two empty sibling leafs, one of them is collapsed and its storage space is reused. This improved performance on directories that at one time contained a large number of files, but many or all of those files have since been deleted. This also applies to all other types of ZAPs as well. Sponsored-by: iXsystems, Inc. Sponsored-by: Klara, Inc. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Alexander Stetsenko <alex.stetsenko@klarasystems.com> Closes #15888
This commit is contained in:
@@ -643,6 +643,10 @@ tags = ['functional', 'compression']
|
||||
tests = ['cp_files_001_pos', 'cp_files_002_pos', 'cp_stress']
|
||||
tags = ['functional', 'cp_files']
|
||||
|
||||
[tests/functional/zap_shrink]
|
||||
tests = ['zap_shrink_001_pos']
|
||||
tags = ['functional', 'zap_shrink']
|
||||
|
||||
[tests/functional/crtime]
|
||||
tests = ['crtime_001_pos' ]
|
||||
tags = ['functional', 'crtime']
|
||||
|
||||
@@ -2074,6 +2074,9 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/xattr/xattr_012_pos.ksh \
|
||||
functional/xattr/xattr_013_pos.ksh \
|
||||
functional/xattr/xattr_compat.ksh \
|
||||
functional/zap_shrink/cleanup.ksh \
|
||||
functional/zap_shrink/zap_shrink_001_pos.ksh \
|
||||
functional/zap_shrink/setup.ksh \
|
||||
functional/zpool_influxdb/cleanup.ksh \
|
||||
functional/zpool_influxdb/setup.ksh \
|
||||
functional/zpool_influxdb/zpool_influxdb.ksh \
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#!/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 https://opensource.org/licenses/CDDL-1.0.
|
||||
# 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.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
default_cleanup
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#!/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 https://opensource.org/licenses/CDDL-1.0.
|
||||
# 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.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
DISK=${DISKS%% *}
|
||||
default_setup $DISK
|
||||
@@ -0,0 +1,81 @@
|
||||
#! /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 https://opensource.org/licenses/CDDL-1.0.
|
||||
# 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 2024, Klara Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Create a large number of files in a directory. Then remove all files and
|
||||
# check that the directory zap was shrunk. Use zdb to check that the zap object
|
||||
# contains only one leaf block using zdb.
|
||||
#
|
||||
|
||||
verify_runnable "global"
|
||||
|
||||
DIR=largedir
|
||||
|
||||
NR_FILES=100000
|
||||
BATCH=1000
|
||||
CWD=$PWD
|
||||
|
||||
log_assert "Create a large number of files ($NR_FILES) in a directory. " \
|
||||
"Make sure that the directory ZAP object was shrunk."
|
||||
|
||||
log_must mkdir $TESTDIR/$DIR
|
||||
|
||||
cd $TESTDIR/$DIR
|
||||
# In order to prevent arguments overflowing, create NR_FILES in BATCH at once.
|
||||
for i in $(seq $(($NR_FILES/$BATCH))); do
|
||||
touch $(seq $((($i-1)*$BATCH+1)) $(($i*$BATCH)));
|
||||
done
|
||||
cd $CWD
|
||||
|
||||
log_must test $NR_FILES -eq $(ls -U $TESTDIR/$DIR | wc -l)
|
||||
|
||||
# remove all files in $DIR directory
|
||||
cd $TESTDIR/$DIR
|
||||
for i in $(seq $(($NR_FILES/$BATCH))); do
|
||||
rm $(seq $((($i-1)*$BATCH+1)) $(($i*$BATCH)))
|
||||
done
|
||||
cd $CWD
|
||||
sync_pool $TESTPOOL
|
||||
|
||||
log_must test 0 -eq $(ls -U $TESTDIR/$DIR | wc -l)
|
||||
|
||||
# check whether zap_shrink works
|
||||
zapobj=$(zdb -v -O $TESTPOOL/$TESTFS $DIR)
|
||||
nleafs=$(echo "$zapobj" | grep "Leaf blocks:" | awk -F\: '{print($2);}')
|
||||
log_must test 1 -eq $nleafs
|
||||
|
||||
log_must zpool export $TESTPOOL
|
||||
log_must zpool import $TESTPOOL
|
||||
|
||||
# check whether zap_shrink works
|
||||
zapobj=$(zdb -v -O $TESTPOOL/$TESTFS $DIR)
|
||||
nleafs=$(echo "$zapobj" | grep "Leaf blocks:" | awk -F\: '{print($2);}')
|
||||
log_must test 1 -eq $nleafs
|
||||
|
||||
log_pass
|
||||
Reference in New Issue
Block a user