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