Skip to content

Commit 073b34b

Browse files
Paul Dagnelietonyhutter
authored andcommitted
Fix display of default xattr to show 'sa'
When the default value of the xattr property was changed from 'dir' to 'sa', the code that displays the property's value was not affected. The problem with this state of affairs is that 1) user tooling that specifically looked for 'sa' before will be confused now that the code displays 'on' instead. And 2) users may be confused when manually running the commands about which specific type of xattr is in use unless they are up to date on the latest zfs changes. The fix here is to show the actual type always, rather than 'on' if we happen to be using the default. This turns out to be easy to do, by simply reordering the list of xattr values in the properties code. When the property is displayed, we iterate down the table until we find a row with a matching value, and use that row's name as the display. Reordering the row fixes the display without affecting any other code. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Rob Norris <[email protected]> Reviewed-by: George Melikov <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes openzfs#17801
1 parent c0d63f5 commit 073b34b

File tree

6 files changed

+61
-6
lines changed

6 files changed

+61
-6
lines changed

module/zcommon/zfs_prop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ zfs_prop_init(void)
364364

365365
static const zprop_index_t xattr_table[] = {
366366
{ "off", ZFS_XATTR_OFF },
367-
{ "on", ZFS_XATTR_SA },
368367
{ "sa", ZFS_XATTR_SA },
368+
{ "on", ZFS_XATTR_SA },
369369
{ "dir", ZFS_XATTR_DIR },
370370
{ NULL }
371371
};

tests/runfiles/common.run

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,8 @@ tags = ['functional', 'write_dirs']
10901090
[tests/functional/xattr]
10911091
tests = ['xattr_001_pos', 'xattr_002_neg', 'xattr_003_neg', 'xattr_004_pos',
10921092
'xattr_005_pos', 'xattr_006_pos', 'xattr_007_neg',
1093-
'xattr_011_pos', 'xattr_012_pos', 'xattr_013_pos', 'xattr_compat']
1093+
'xattr_011_pos', 'xattr_012_pos', 'xattr_013_pos', 'xattr_014_pos',
1094+
'xattr_compat']
10941095
tags = ['functional', 'xattr']
10951096

10961097
[tests/functional/zvol/zvol_ENOSPC]

tests/runfiles/sanity.run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ tags = ['functional', 'vdev_zaps']
622622
[tests/functional/xattr]
623623
tests = ['xattr_001_pos', 'xattr_002_neg', 'xattr_003_neg', 'xattr_004_pos',
624624
'xattr_005_pos', 'xattr_006_pos', 'xattr_007_neg',
625-
'xattr_011_pos', 'xattr_013_pos', 'xattr_compat']
625+
'xattr_011_pos', 'xattr_013_pos', 'xattr_014_pos', 'xattr_compat']
626626
tags = ['functional', 'xattr']
627627

628628
[tests/functional/zvol/zvol_ENOSPC]

tests/zfs-tests/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
22342234
functional/xattr/xattr_011_pos.ksh \
22352235
functional/xattr/xattr_012_pos.ksh \
22362236
functional/xattr/xattr_013_pos.ksh \
2237+
functional/xattr/xattr_014_pos.ksh \
22372238
functional/xattr/xattr_compat.ksh \
22382239
functional/zap_shrink/cleanup.ksh \
22392240
functional/zap_shrink/zap_shrink_001_pos.ksh \

tests/zfs-tests/tests/functional/delegate/delegate_common.kshlib

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,10 +1234,10 @@ function verify_fs_aedsx
12341234
typeset oldval
12351235
set -A modes "on" "off"
12361236
oldval=$(get_prop $perm $fs)
1237-
if [[ $oldval == "on" ]]; then
1238-
n=1
1239-
elif [[ $oldval == "off" ]]; then
1237+
if [[ $oldval == "off" ]]; then
12401238
n=0
1239+
else
1240+
n=1
12411241
fi
12421242
log_note "$user zfs set $perm=${modes[$n]} $fs"
12431243
user_run $user zfs set $perm=${modes[$n]} $fs
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/ksh -p
2+
# SPDX-License-Identifier: CDDL-1.0
3+
#
4+
# CDDL HEADER START
5+
#
6+
# The contents of this file are subject to the terms of the
7+
# Common Development and Distribution License (the "License").
8+
# You may not use this file except in compliance with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or https://opensource.org/licenses/CDDL-1.0.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
24+
#
25+
# Copyright (c) 2025 by Klara, Inc.
26+
#
27+
28+
. $STF_SUITE/include/libtest.shlib
29+
. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
30+
31+
#
32+
# DESCRIPTION:
33+
# The default xattr should be shown as 'sa', not 'on', for clarity.
34+
#
35+
# STRATEGY:
36+
# 1. Create a filesystem.
37+
# 2. Verify that the xattra is shown as 'sa'.
38+
# 3. Manually set the value to 'dir', 'sa', 'on', and 'off'.
39+
# 4. Verify that it is shown as 'dir', 'sa', 'sa', and 'off.
40+
#
41+
42+
log_assert "The default and specific xattr values are displayed correctly."
43+
44+
set -A args "dir" "sa" "on" "off"
45+
set -A display "dir" "sa" "sa" "off"
46+
47+
log_must eval "[[ 'sa' == '$(zfs get -Hpo value xattr $TESTPOOL)' ]]"
48+
49+
for i in `seq 0 3`; do
50+
log_must zfs set xattr="${args[$i]}" $TESTPOOL
51+
log_must eval "[[ '${display[$i]}' == '$(zfs get -Hpo value xattr $TESTPOOL)' ]]"
52+
done
53+
log_pass "The default and specific xattr values are displayed correctly."

0 commit comments

Comments
 (0)