Skip to content

Commit

Permalink
WIP xattr_compat for FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Moeller authored and Ryan Moeller committed May 28, 2021
1 parent c817c49 commit b9d3a79
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 77 deletions.
4 changes: 3 additions & 1 deletion include/os/freebsd/zfs/sys/zfs_vfsops_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ struct zfsvfs {
RW_WRITE_HELD(&(zfsvfs)->z_teardown_inactive_lock)
#endif

#define ZSB_XATTR 0x0001 /* Enable user xattrs */
#define ZSB_XATTR 0x0001 /* Enable user xattrs */
#define ZSB_XATTR_COMPAT 0x0002 /* Enable cross-platform user xattrs */

/*
* Normal filesystems (those not under .zfs/snapshot) have a total
* file ID size limited to 12 bytes (including the length field) due to
Expand Down
33 changes: 33 additions & 0 deletions module/os/freebsd/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <sys/sa_impl.h>
#include <sys/policy.h>
#include <sys/atomic.h>
#include <sys/zfeature.h>
#include <sys/zfs_ioctl.h>
#include <sys/zfs_ctldir.h>
#include <sys/zfs_fuid.h>
Expand Down Expand Up @@ -478,6 +479,31 @@ xattr_changed_cb(void *arg, uint64_t newval)
}
}

static void
xattr_compat_changed_cb(void *arg, uint64_t newval)
{
zfsvfs_t *zfsvfs = arg;

/*
* Force the old cross-platform compatible behavior if
* feature@xattr_compat is disabled. This contrasts with
* Linux where the behavior prior to feature@xattr_compat
* was to use the incompatible Linux-only xattr format.
*/
if (!spa_feature_is_enabled(dmu_objset_spa(zfsvfs->z_os),
SPA_FEATURE_XATTR_COMPAT))
newval = ZFS_XATTR_COMPAT_ALL;

switch (newval) {
case ZFS_XATTR_COMPAT_ALL:
zfsvfs->z_flags |= ZSB_XATTR_COMPAT;
break;
case ZFS_XATTR_COMPAT_LINUX:
zfsvfs->z_flags &= ~ZSB_XATTR_COMPAT;
break;
}
}

static void
blksz_changed_cb(void *arg, uint64_t newval)
{
Expand Down Expand Up @@ -721,6 +747,9 @@ zfs_register_callbacks(vfs_t *vfsp)
zfs_prop_to_name(ZFS_PROP_ATIME), atime_changed_cb, zfsvfs);
error = error ? error : dsl_prop_register(ds,
zfs_prop_to_name(ZFS_PROP_XATTR), xattr_changed_cb, zfsvfs);
error = error ? error : dsl_prop_register(ds,
zfs_prop_to_name(ZFS_PROP_XATTR_COMPAT), xattr_compat_changed_cb,
zfsvfs);
error = error ? error : dsl_prop_register(ds,
zfs_prop_to_name(ZFS_PROP_RECORDSIZE), blksz_changed_cb, zfsvfs);
error = error ? error : dsl_prop_register(ds,
Expand Down Expand Up @@ -1237,6 +1266,10 @@ zfs_domount(vfs_t *vfsp, char *osname)
"xattr", &pval, NULL)))
goto out;
xattr_changed_cb(zfsvfs, pval);
if ((error = dsl_prop_get_integer(osname,
"xattr_compat", &pval, NULL)))
goto out;
xattr_compat_changed_cb(zfsvfs, pval);
if ((error = dsl_prop_get_integer(osname,
"acltype", &pval, NULL)))
goto out;
Expand Down
Loading

0 comments on commit b9d3a79

Please sign in to comment.