FreeBSD: Implement xattr=sa

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.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #11997
This commit is contained in:
Ryan Moeller
2021-04-29 03:27:57 +00:00
committed by Brian Behlendorf
parent d86debf576
commit 210231ede0
4 changed files with 414 additions and 163 deletions
+6 -3
View File
@@ -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
@@ -1793,7 +1793,7 @@ The default value is
This property is not used by OpenZFS.
.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
@@ -1805,7 +1805,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 .
@@ -1818,6 +1818,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