xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/large_dnode/large_dnode_008_pos.ksh (revision 4e5ef1cee66fbfbbd2b3e56b81e2bb5700f4a59e)
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright (c) 2017 by Lawrence Livermore National Security, LLC.
25# Use is subject to license terms.
26#
27
28. $STF_SUITE/include/libtest.shlib
29
30#
31# DESCRIPTION:
32# Run many xattrtests on a dataset with large dnodes and xattr=sa to
33# stress concurrent allocation of large dnodes.
34#
35
36TEST_FS=$TESTPOOL/large_dnode
37
38verify_runnable "both"
39
40function cleanup
41{
42	datasetexists $TEST_FS && log_must zfs destroy $TEST_FS
43}
44
45function verify_dnode_packing
46{
47	zdb -dd $TEST_FS | grep -A 3 'Dnode slots' | awk '
48		/Total used:/ {total_used=$NF}
49		/Max used:/ {max_used=$NF}
50		/Percent empty:/ {print total_used, max_used, int($NF)}
51	' | while read total_used max_used pct_empty
52	do
53		log_note "total_used $total_used max_used $max_used pct_empty $pct_empty"
54		if [ $pct_empty -gt 5 ]; then
55			log_fail "Holes in dnode array: pct empty $pct_empty > 5"
56		fi
57	done
58}
59
60log_onexit cleanup
61log_assert "xattrtest runs concurrently on dataset with large dnodes"
62
63log_must zfs create $TEST_FS
64log_must zfs set dnsize=auto $TEST_FS
65log_must zfs set xattr=sa $TEST_FS
66
67for ((i=0; i < 100; i++)); do
68	dir="/$TEST_FS/dir.$i"
69	log_must mkdir "$dir"
70	log_must eval "xattrtest -R -r -y -x 1 -f 1024 -k -p $dir >/dev/null 2>&1 &"
71done
72
73log_must wait
74
75verify_dnode_packing
76
77log_pass
78