Skip to content

Commit

Permalink
xattr dataset prop: change defaults to sa
Browse files Browse the repository at this point in the history
It's the main recommendation to set xattr=sa
even in man pages, so let's set it by default.

xattr=sa don't use feature flag, so in the worst
case we'll have non-readable xattrs by other
non-openzfs platforms.

Non-overridden default `xattr` prop of existing pools
will automatically use `sa` after this commit too.

Signed-off-by: George Melikov <[email protected]>
  • Loading branch information
gmelikov committed Sep 19, 2024
1 parent 4d469ac commit e5a6291
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions man/man7/zfsprops.7
Original file line number Diff line number Diff line change
Expand Up @@ -1961,14 +1961,13 @@ enabled for virus scanning to occur.
The default value is
.Sy off .
This property is not used by OpenZFS.
.It Sy xattr Ns = Ns Sy on Ns | Ns Sy off Ns | Ns Sy sa
.It Sy xattr Ns = Ns Sy on Ns | Ns Sy off Ns | Ns Sy dir Ns | Ns Sy sa
Controls whether extended attributes are enabled for this file system.
Two styles of extended attributes are supported: either directory-based
or system-attribute-based.
.Pp
The default value of
.Sy on
enables directory-based extended attributes.
Directory-based extended attributes can be enabled by setting the value to
.Sy dir .
This style of extended attribute imposes no practical limit
on either the size or number of attributes which can be set on a file.
Although under Linux the
Expand All @@ -1981,7 +1980,10 @@ This is the most compatible
style of extended attribute and is supported by all ZFS implementations.
.Pp
System-attribute-based xattrs can be enabled by setting the value to
.Sy sa .
.Sy sa
(default and equal to
.Sy on
) .
The key advantage of this type of xattr is improved performance.
Storing extended attributes as system attributes
significantly decreases the amount of disk I/O required.
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ zfsvfs_parse_option(char *option, int token, substring_t *args, vfs_t *vfsp)
vfsp->vfs_do_xattr = B_TRUE;
break;
case TOKEN_XATTR:
vfsp->vfs_xattr = ZFS_XATTR_DIR;
vfsp->vfs_xattr = ZFS_XATTR_SA;
vfsp->vfs_do_xattr = B_TRUE;
break;
case TOKEN_NOXATTR:
Expand Down
4 changes: 2 additions & 2 deletions module/zcommon/zfs_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ zfs_prop_init(void)

static const zprop_index_t xattr_table[] = {
{ "off", ZFS_XATTR_OFF },
{ "on", ZFS_XATTR_DIR },
{ "on", ZFS_XATTR_SA },
{ "sa", ZFS_XATTR_SA },
{ "dir", ZFS_XATTR_DIR },
{ NULL }
Expand Down Expand Up @@ -474,7 +474,7 @@ zfs_prop_init(void)
zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
"latency | throughput", "LOGBIAS", logbias_table, sfeatures);
zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_DIR,
zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_SA,
PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
"on | off | dir | sa", "XATTR", xattr_table, sfeatures);
zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ log_onexit cleanup

log_assert "Check changing project ID with directory-based extended attributes"

log_must zfs set xattr=on $QFS
log_must zfs set xattr=dir $QFS

log_must touch $PRJGUARD
log_must chattr -p $PRJID1 $PRJGUARD
Expand All @@ -76,6 +76,6 @@ sync_pool
typeset prj_aft=$(project_obj_count $QFS $PRJID1)

[[ $prj_aft -ge $((prj_bef + 5)) ]] ||
log_fail "new value ($prj_aft) is NOT 5 largr than old one ($prj_bef)"
log_fail "new value ($prj_aft) is NOT 5 larger than old one ($prj_bef)"

log_pass "Changing project ID with directory-based extended attributes pass"
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/xattr/xattr_001_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function cleanup {
fi
}

set -A args "on" "sa"
set -A args "dir" "sa"

log_assert "Create/read/write/append of xattrs works"
log_onexit cleanup
Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/xattr/xattr_002_neg.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function cleanup {

}

set -A args "on" "sa"
set -A args "dir" "sa"

log_assert "A read of a non-existent xattr fails"
log_onexit cleanup
Expand Down

0 comments on commit e5a6291

Please sign in to comment.