Skip to content

Add support for FreeBSD's Solaris style extended attribute interface #17540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2025

Conversation

rmacklem
Copy link
Contributor

@rmacklem rmacklem commented Jul 13, 2025

FreeBSD commit 2ec2ba7e232d added the Solaris style syscall interface for extended attributes.
This patch wires this interface into the FreeBSD ZFS port, since this style of extended attributes
is supported by OpenZFS internally when the "xattr" property is set to "dir".

Motivation and Context

The Solaris system call interface to extended attributes, which provides a directory
with the extended attributes in it as files, is preferred by some to the Linux/FreeBSD
system call interface.

Since the Solaris style system call interface is now in FreeBSD, this patch wires in
the support (which already exists in OpenZFS internally) for the FreeBSD port.

Description

The FreeBSD VOP interface now has OPENNAMED as a new flag for looking
up extended attributes and the extended attribute directory. (The named
attribute terminology is used to try and avoid confusion with the Linux/FreeBSD
system call interface for extended attributes.)
FreeBSD marks the vnodes with VIRF_NAMEDDIR and VIRF_NAMEDATTR for
the extended attribute directory and the extended attribute files, respectively.

Most of the changes are done to zfs_freebsd_lookup(), where it recognizes an
extended attribute lookup via the OPENNAMED flag and the extended attribute
directory via the VIRF_NAMEDDIR vnode flag.

zfs_zaccess() is modified by adding the access code that was in the Linux
port and enabling it for these extended attributes, using new LOOKUP_NAMED_ATTR
and V_NAMEDATTR flags.

zfs_freebsd_create() is modified to handle creation of new extended attributes.
A check for the attribute already existing is a "sa" block is missing and will be
added in a future commit.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Jul 14, 2025
@rmacklem
Copy link
Contributor Author

rmacklem commented Jul 14, 2025 via email

@amotin
Copy link
Member

amotin commented Jul 14, 2025

Hopefully I can just update the file, "git commit --amend" and then "git push --force"?

Yes. That would be right.

I don't think the two test failures have anything to do with my code.

It seems an unrelated noise. I've restarted them once more.

@rmacklem
Copy link
Contributor Author

rmacklem commented Jul 14, 2025 via email

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to add some tests so we can exercise this new interface in the CI.

FreeBSD commit 2ec2ba7e232d added the Solaris style syscall interface
for extended attributes.  This patch wires this interface into the
FreeBSD ZFS port, since this style of extended attributes is supported
by OpenZFS internally when the "xattr" property is set to "dir".

Some specific changes:
LOOKUP_NAMED_ATTR is defined to indicate the need to set V_NAMEDATTR
for calls to zfs_zaccess().
V_NAMEDATTR indicates that the access checking does need to be done
for FreeBSD.

The access checking code for extended attributes was copy/pasted from
the Linux port into zfs_zaccess() in the FreeBSD port.

Most of the changes are in zfs_freebsd_lookup() and
zfs_freebsd_create().
The semantics of these functions should remain unchanged unless named
attributes are being manipulated.

All the code changes are enabled for __FreeBSD_version 1500040 and
newer.

Signed-off-by: Rick Macklem <[email protected]>
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Jul 30, 2025
@behlendorf behlendorf merged commit 2957eab into openzfs:master Jul 30, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Ready to integrate (reviewed, tested)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants