xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/large_dnode/large_dnode_002_pos.ksh (revision af34582fe571c99d9f74acf7c271e26c744fef5b)
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. $STF_SUITE/include/libtest.shlib
24
25#
26# DESCRIPTION:
27# Verify that extended attributes can use extra bonus space of a large
28# dnode without kicking in a spill block.
29#
30# STRATEGY:
31# 1. Create a file system with xattr=sa
32# 2. Set dnodesize to a legal literal value
33# 3. Create a file
34# 4  Store an xattr that fits within the dnode size
35# 4. Repeat 2-3 for all legal literal values of dnodesize values
36# 5. Unmount the file system
37# 6. Use zdb to check for missing SPILL_BLKPTR flag
38#
39
40TEST_FS=$TESTPOOL/large_dnode
41
42verify_runnable "both"
43
44function cleanup
45{
46	datasetexists $TEST_FS && log_must zfs destroy $TEST_FS
47}
48
49log_onexit cleanup
50log_assert "extended attributes use extra bonus space of a large dnode"
51
52log_must zfs create -o xattr=sa $TEST_FS
53
54# Store dnode size minus 512 in an xattr
55set -A xattr_sizes "512" "1536" "3584" "7680" "15872"
56set -A prop_values "1k"  "2k"   "4k"   "8k"   "16k"
57set -A inodes
58
59for ((i=0; i < ${#prop_values[*]}; i++)) ; do
60	prop_val=${prop_values[$i]}
61	file=/$TEST_FS/file.$prop_val
62	log_must zfs set dnsize=$prop_val $TEST_FS
63	touch $file
64	xattr_size=${xattr_sizes[$i]}
65	xattr_name=user.foo
66	xattr_val=$(dd if=/dev/urandom bs=1 count=$xattr_size |
67	    openssl enc -a -A)
68	log_must setfattr -n $xattr_name -v 0s$xattr_val $file
69	inodes[$i]=$(ls -li $file | awk '{print $1}')
70done
71
72log_must zfs umount $TEST_FS
73
74for ((i=0; i < ${#inodes[*]}; i++)) ; do
75	log_mustnot eval "zdb -dddd $TEST_FS ${inodes[$i]} | grep SPILL_BLKPTR"
76done
77
78log_pass "extended attributes use extra bonus space of a large dnode"
79