Skip to content

Commit

Permalink
FreeBSD: Implement xattr=sa
Browse files Browse the repository at this point in the history
FreeBSD historically has not cared about the xattr property; it was
always treated as xattr=on.  With xattr=on, xattrs are stored as files
in a hidden xattr directory.  With xattr=sa, xattrs are stored as
system attributes and get cached in nvlists during xattr operations.
This makes SA xattrs simpler and more efficient to manipulate.  FreeBSD
needs to implement the SA xattr operations for feature parity with
Linux and to ensure that SA xattrs are accessible when migrated or
replicated from Linux.

Following the example set by Linux, refactor our existing extattr vnops
to split off the parts handling dir style xattrs, and add the
corresponding SA handling parts.

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
  • Loading branch information
Ryan Moeller authored and Ryan Moeller committed May 6, 2021
1 parent d1e3ecf commit b6246ef
Show file tree
Hide file tree
Showing 4 changed files with 401 additions and 150 deletions.
9 changes: 6 additions & 3 deletions man/man8/zfsprops.8
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
.\" Copyright 2019 Joyent, Inc.
.\" Copyright (c) 2019, Kjeld Schouten-Lebbing
.\"
.Dd September 1, 2020
.Dd May 5, 2021
.Dt ZFSPROPS 8
.Os
.Sh NAME
Expand Down Expand Up @@ -1778,7 +1778,7 @@ The default value is
This property is not used on Linux.
.It Sy xattr Ns = Ns Sy on Ns | Ns Sy off 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
styles of extended attributes are supported: either directory based or system
attribute based.
.Pp
The default value of
Expand All @@ -1790,7 +1790,7 @@ can be set on a file. Although under Linux the
and
.Xr setxattr 2
system calls limit the maximum size to 64K. This is the most compatible
style of extended attribute and is supported by all OpenZFS implementations.
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 .
Expand All @@ -1803,6 +1803,9 @@ based xattr. System attribute based extended attributes are not accessible
on platforms which do not support the
.Sy xattr=sa
feature.
OpenZFS supports
.Sy xattr=sa
on both FreeBSD and Linux.
.Pp
The use of system attribute based xattrs is strongly encouraged for users of
SELinux or POSIX ACLs. Both of these features heavily rely on extended
Expand Down
4 changes: 4 additions & 0 deletions module/os/freebsd/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,10 @@ zfsvfs_init(zfsvfs_t *zfsvfs, objset_t *os)
&sa_obj);
if (error != 0)
return (error);

error = zfs_get_zplprop(os, ZFS_PROP_XATTR, &val);
if (error == 0 && val == ZFS_XATTR_SA)
zfsvfs->z_xattr_sa = B_TRUE;
}

error = sa_setup(os, sa_obj, zfs_attr_table, ZPL_END,
Expand Down
Loading

0 comments on commit b6246ef

Please sign in to comment.