]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/features/large_dnode/large_dnode_001_pos.ksh
Implement large_dnode pool feature
[mirror_zfs.git] / tests / zfs-tests / tests / functional / features / large_dnode / large_dnode_001_pos.ksh
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 the dnode sizes of newly created files are consistent
28 # with the dnodesize dataset property.
29 #
30 # STRATEGY:
31 # 1. Create a file system
32 # 2. Set dnodesize to a legal literal value
33 # 3. Create a file
34 # 4. Repeat 2-3 for all legal literal values of dnodesize values
35 # 5. Unmount the file system
36 # 6. Use zdb to check expected dnode sizes
37 #
38
39 TEST_FS=$TESTPOOL/large_dnode
40
41 verify_runnable "both"
42
43 function cleanup
44 {
45 datasetexists $TEST_FS && log_must $ZFS destroy $TEST_FS
46 }
47
48 log_onexit cleanup
49 log_assert "dnode sizes are consistent with dnodesize dataset property"
50
51 log_must $ZFS create $TEST_FS
52
53 set -A dnsizes "512" "1k" "2k" "4k" "8k" "16k"
54 set -A inodes
55
56 for ((i=0; i < ${#dnsizes[*]}; i++)) ; do
57 size=${dnsizes[$i]}
58 if [[ $size == "512" ]] ; then
59 size="legacy"
60 fi
61 file=/$TEST_FS/file.$size
62 log_must $ZFS set dnsize=$size $TEST_FS
63 touch $file
64 inodes[$i]=$(ls -li $file | awk '{print $1}')
65 done
66
67 log_must $ZFS umount $TEST_FS
68
69 for ((i=0; i < ${#dnsizes[*]}; i++)) ; do
70 dnsize=$($ZDB -dddd $TEST_FS ${inodes[$i]} |
71 awk '/ZFS plain file/ {print $6}' | tr K k)
72 if [[ "$dnsize" != "${dnsizes[$i]}" ]]; then
73 log_fail "dnode size is $dnsize (expected ${dnsizes[$i]})"
74 fi
75 done
76
77 log_pass "dnode sizes are consistent with dnodesize dataset property"