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 https://opensource.org/licenses/CDDL-1.0. 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# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23# Use is subject to license terms. 24# 25 26# 27# Copyright 2022 iXsystems, Inc. 28# 29 30. $STF_SUITE/include/libtest.shlib 31 32# 33# DESCRIPTION: 34# The zfs_xattr_compat tunable and fallback works as expected. 35# 36# STRATEGY: 37# For both of xattr=sa and xattr=dir: 38# 1. Create a filesystem with the native zfs_xattr_compat 39# 2. Create a file on the filesystem and add some xattrs to it 40# 3. Change the zfs_xattr_compat to the alternative setting 41# 4. Verify that the xattrs can still be accessed and modified 42# 5. Change zfs_xattr_compat back to the native setting 43# 6. Verify that the xattrs can still be accessed and modified 44# 45 46function cleanup { 47 rm -f $TESTFILE $TMPFILE 48 zfs set xattr=sa $TESTPOOL/$TESTFS 49 set_tunable32 XATTR_COMPAT $NATIVE_XATTR_COMPAT 50} 51 52log_assert "The zfs_xattr_compat tunable and fallback works as expected" 53log_onexit cleanup 54 55TESTFILE=$TESTDIR/testfile.$$ 56TMPFILE=$TEST_BASE_DIR/tmpfile.$$ 57NATIVE_XATTR_COMPAT=$(get_tunable XATTR_COMPAT) 58ALTERNATIVE_XATTR_COMPAT=$((1 - NATIVE_XATTR_COMPAT)) 59 60for x in sa dir; do 61 log_must zfs set xattr=$x $TESTPOOL/$TESTFS 62 log_must touch $TESTFILE 63 log_must set_xattr testattr1 value1 $TESTFILE 64 log_must set_xattr testattr2 value2 $TESTFILE 65 log_must set_xattr testattr3 value3 $TESTFILE 66 log_must ls_xattr $TESTFILE 67 68 log_must set_tunable32 XATTR_COMPAT $ALTERNATIVE_XATTR_COMPAT 69 log_must ls_xattr $TESTFILE 70 log_must eval "get_xattr testattr1 $TESTFILE > $TMPFILE" 71 log_must test $(<$TMPFILE) = value1 72 log_must set_xattr testattr2 newvalue2 $TESTFILE 73 log_must rm_xattr testattr3 $TESTFILE 74 log_must set_xattr testattr4 value4 $TESTFILE 75 log_must ls_xattr $TESTFILE 76 77 log_must set_tunable32 XATTR_COMPAT $NATIVE_XATTR_COMPAT 78 log_must ls_xattr $TESTFILE 79 log_must eval "get_xattr testattr1 $TESTFILE > $TMPFILE" 80 log_must test $(<$TMPFILE) = value1 81 log_must eval "get_xattr testattr2 $TESTFILE > $TMPFILE" 82 log_must test $(<$TMPFILE) = newvalue2 83 log_mustnot get_xattr testattr3 $TESTFILE 84 log_must set_xattr testattr3 value3 $TESTFILE 85 log_must eval "get_xattr testattr4 $TESTFILE > $TMPFILE" 86 log_must test $(<$TMPFILE) = value4 87 log_must ls_xattr $TESTFILE 88 89 log_must rm $TESTFILE 90done 91 92log_pass "The zfs_xattr_compat tunable and fallback works as expected" 93