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
45log_onexit cleanup
46log_assert "xattrtest runs concurrently on dataset with large dnodes"
47
48log_must zfs create $TEST_FS
49log_must zfs set dnsize=auto $TEST_FS
50log_must zfs set xattr=sa $TEST_FS
51
52for ((i=0; i < 100; i++)); do
53	dir="/$TEST_FS/dir.$i"
54	log_must mkdir "$dir"
55
56	do_unlink=""
57	if [ $((RANDOM % 2)) -eq 0 ]; then
58		do_unlink="-k -f 1024"
59	else
60		do_unlink="-f $((RANDOM % 1024))"
61	fi
62	log_must eval "xattrtest -R -r -y -x 1 $do_unlink -p $dir >/dev/null 2>&1 &"
63done
64
65log_must wait
66
67log_must zpool export $TESTPOOL
68log_must zpool import $TESTPOOL
69log_must ls -lR "/$TEST_FS/" >/dev/null 2>&1
70log_must zdb -d $TESTPOOL
71log_pass
72