Re: RFC: Solaris style extended attributes for FreeBSD

From: Andrew Walker <awalker_at_ixsystems.com>
Date: Sun, 09 Mar 2025 12:38:22 UTC
> Since ZFS is already wired for them, adding the basics is pretty
> straightforward. I am not suggesting that they should replace the
> current FreeBSD extended attributes

The ZFS story is more complicated. When ZFS is configured with
`xattr=sa`, xattrs are preferentially written into system attributes
(SA). This was introduced IIRC primarily for performance reasons
This allows tiny xattrs (~100 bytes) to be stored with the dnode and
up to 64 KiB of xattrs to be stored in the dnode spill block. If
additional space is needed then they are written using the older-style
file-backed approach.

What this means is that if someone is using this relatively common
configuration (the default in TrueNAS and in many Linux distros), then
the result would be that only some xattrs written via extattr would be
visible by directly opening the ZFS attr dir. It would also introduce
a mechanism whereby an xattr with the same name is written to two
different ZFS locations, which would potentially cause you to see
different xattr data depending on whether you read it from extattr or
via the attr dir. I don't know off-hand whether this could lead to
corruption / unexpected behavior in ZFS but if you haven't looked into
it yet you may want to make sure you're properly handling the case
where someone has already written SA-backed xattrs.