16

I'm trying to work out whether or not, or rather to what extend, xattrs are supported in FreeBSD using ZFS. I've read some conflicting information.

  1. zfs get xattr lists it as on (default) for /, /usr and /var, but as off (temporary) for all other datasets, including children of those mentioned above.
  2. Running zfs set xattr=on zroot/usr/home I get the message

    property 'xattr' not supported on FreeBSD: permission denied.

  3. This agrees with the zfs man page:

    The xattr property is currently not supported on FreeBSD.

  4. setextattr, getextattr and lsextattr seem to work well enough.
  5. I also managed to save and restore a device file node using rsync --fake-super, and could see its data using lsextattr and getextattr.
  6. Wikipedia has some discussion in the xattr talk page. Apparently there once was a claim that ZFS supports xattr since FreeBSD 8, but that was removed later on, with reference to the manpage (see 3.).

Currently I get the impression that extended attributes on zfs work in practice, but that the xattr property which would control their use does not work as it would in other zfs distributions. But I'd like to hear that confirmed (or corrected) before I trust large amounts of backup data to an rsync --fake-super running on such a machine. I'd rather not lose all my metadata due to known xattr problems.

If it matters, this is a very fresh FreeBSD 10.2 install I just set up, with ZFS set up by the installer.

MvG
  • 4,361
  • 2
  • 28
  • 42
  • 1
    I [cross-posted this to the FreeBSD forum](https://forums.freebsd.org/threads/55418/). Let's hope that that, or the bounty, or both, will help obtain an authoritative answer on this. – MvG Mar 07 '16 at 20:02
  • 1
    I also [cross-posted this to the freebsd-fs mailing list](http://comments.gmane.org/gmane.os.freebsd.devel.file-systems/23651). Would be a shame to have the bounty expire without an answer. – MvG Mar 12 '16 at 19:01
  • The mailing list link is dead. – Mateusz Piotrowski Aug 27 '16 at 16:24
  • 1
    @Mateusz: [The creator of gmane discontinued that service](https://lars.ingebrigtsen.no/2016/07/28/the-end-of-gmane/), although apparently there are negotiations for someone else to continue it again. [Here](http://lists.freebsd.org/pipermail/freebsd-fs/2016-March/022898.html) is the post in the FreeBSD archive, or [here](https://www.freebsd.org/cgi/mid.cgi?db=mid&[email protected]) to search my [message id](https://en.wikipedia.org/wiki/Message-ID). – MvG Aug 27 '16 at 18:35

1 Answers1

5

As you have found, xattrs will work, but there are rough edges.

Sometimes you have to approach open source code like an Anthropologist. If this isn't helpful in itself, maybe this will provoke some better contributions (or eventually code fixes!)

I found this in the source code:

https://github.com/freebsd/freebsd/blob/c829c2411ae5da594814773175c728ea816d9a12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c#L514

/*
 * Register property callbacks.
 *
 * It would probably be fine to just check for i/o error from
 * the first prop_register(), but I guess I like to go
 * overboard...
 */
error = dsl_prop_register(ds,
    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_RECORDSIZE), blksz_changed_cb, zfsvfs);

and this https://github.com/freebsd/freebsd/blob/386ddae58459341ec567604707805814a2128a57/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c#L302

and yet this gives you pause: https://github.com/freebsd/freebsd/blob/e95b1e137c604a612291fd223fce89c2095cddf2/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c#L1638

So what I think is actually happening is that xattrs work but the functionality to turn them off (or on) by ZFS dataset properties is broken, so the "not supported" message means "you're on your own."

There is some code in there which sets MNTOPT_XATTR but I haven't traced it out. trying to change it using zfs set gets you the unsupported message. My guess is that explains the zfs xattr property weirdness with /, /usr, /var, and the conflicted setting/behavior of /home.

This sheds some light on things. https://www.lesbonscomptes.com/pages/extattrs.html

Jeremy
  • 176
  • 1
  • 4