Changeset View
Standalone View
sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
| Show First 20 Lines • Show All 1,168 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void | static void | ||||
| zfs_set_fuid_feature(zfsvfs_t *zfsvfs) | zfs_set_fuid_feature(zfsvfs_t *zfsvfs) | ||||
| { | { | ||||
| zfsvfs->z_use_fuids = USE_FUIDS(zfsvfs->z_version, zfsvfs->z_os); | zfsvfs->z_use_fuids = USE_FUIDS(zfsvfs->z_version, zfsvfs->z_os); | ||||
| zfsvfs->z_use_sa = USE_SA(zfsvfs->z_version, zfsvfs->z_os); | zfsvfs->z_use_sa = USE_SA(zfsvfs->z_version, zfsvfs->z_os); | ||||
| } | } | ||||
| extern int zfs_xattr_compat; | |||||
| static int | static int | ||||
| zfs_domount(vfs_t *vfsp, char *osname) | zfs_domount(vfs_t *vfsp, char *osname) | ||||
| { | { | ||||
| uint64_t recordsize, fsid_guid; | uint64_t recordsize, fsid_guid; | ||||
| int error = 0; | int error = 0; | ||||
| zfsvfs_t *zfsvfs; | zfsvfs_t *zfsvfs; | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | if (dmu_objset_is_snapshot(zfsvfs->z_os)) { | ||||
| mutex_enter(&zfsvfs->z_os->os_user_ptr_lock); | mutex_enter(&zfsvfs->z_os->os_user_ptr_lock); | ||||
| dmu_objset_set_user(zfsvfs->z_os, zfsvfs); | dmu_objset_set_user(zfsvfs->z_os, zfsvfs); | ||||
| mutex_exit(&zfsvfs->z_os->os_user_ptr_lock); | mutex_exit(&zfsvfs->z_os->os_user_ptr_lock); | ||||
| } else { | } else { | ||||
| if ((error = zfsvfs_setup(zfsvfs, B_TRUE))) | if ((error = zfsvfs_setup(zfsvfs, B_TRUE))) | ||||
| goto out; | goto out; | ||||
| } | } | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| /* | |||||
| * Named attributes can only work if the xattr property is set to | |||||
| * on/dir and not sa. Also, zfs_xattr_compat must be set. | |||||
| */ | |||||
| if ((zfsvfs->z_flags & ZSB_XATTR) != 0 && !zfsvfs->z_xattr_sa && | |||||
mav: `ZSB_XATTR` and `z_xattr_sa` might change in run time, with the `xattr` property. It is not… | |||||
rmacklemAuthorUnsubmitted Not Done Inline ActionsYep. Flipping back and forth between "dir" and "sa" is a little There is also some weirdness w.r.t. "zfs get xattr" I do not understand. If you think this will be too confusing, I could create a new setting for So, I'm not sure what the right answer is for this? rmacklem: Yep. Flipping back and forth between "dir" and "sa" is a little
weird. "setextattr system ..."… | |||||
rmacklemAuthorUnsubmitted Done Inline ActionsThis version of the patch allows "setextattr system ..." to work I think that "setextattr system" needs to work, since some rmacklem: This version of the patch allows "setextattr system ..." to work
for xattr=dir. Not allowing it… | |||||
mavUnsubmitted Not Done Inline Actions
Unfortunately, unlike "on" for "compression", which is a separate value, "on" for "xattr" is just another name for one of explicit options. Originally it mapped to "dir", but lately was changed to "sa", which only increased the confusion.
I don't think adding more options would make it any cleaner. I am trying to think towards any possible better integration between "sa" and "dir". For the existing xattr API it is not very important what way "xattr" property is set -- on get it can get any available (expecting only one to exist), and on set, it makes sure to wipe possible other variant. Sure having some of attributes stores in "sa" via old API invisible via new is annoying, but I think having two variants stored same time may be even worse. I wonder if we could delete "sa" attributes when creating "dir" with the same name via the new API. Though if some attributes are not visible in some way, it may create difficulties and uncertainty for some copy/replication software. mav: > There is also some weirdness w.r.t. "zfs get xattr" I do not understand.
> Sometimes it… | |||||
rmacklemAuthorUnsubmitted Done Inline ActionsAll I can think of is documenting that switching back and forth Something like this could go in the zfsprops man page. I don't think copying the sa attributes into dir attributes will work Since for xattr=sa there can be dir attributes (ones too big to fit in The problematic case occurs when a small attribute is created when rmacklem: All I can think of is documenting that switching back and forth
will cause grief and, if a file… | |||||
| zfs_xattr_compat) | |||||
| vfsp->mnt_flag |= MNT_NAMEDATTR; | |||||
| #endif | |||||
| vfs_mountedfrom(vfsp, osname); | vfs_mountedfrom(vfsp, osname); | ||||
| if (!zfsvfs->z_issnap) | if (!zfsvfs->z_issnap) | ||||
| zfsctl_create(zfsvfs); | zfsctl_create(zfsvfs); | ||||
| out: | out: | ||||
| if (error) { | if (error) { | ||||
| dmu_objset_disown(zfsvfs->z_os, B_TRUE, zfsvfs); | dmu_objset_disown(zfsvfs->z_os, B_TRUE, zfsvfs); | ||||
| zfsvfs_free(zfsvfs); | zfsvfs_free(zfsvfs); | ||||
| ▲ Show 20 Lines • Show All 507 Lines • ▼ Show 20 Lines | zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp) | ||||
| } | } | ||||
| if (err == 0) | if (err == 0) | ||||
| *vpp = ZTOV(zp); | *vpp = ZTOV(zp); | ||||
| zfs_exit(zfsvfs, FTAG); | zfs_exit(zfsvfs, FTAG); | ||||
| if (err == 0) { | if (err == 0) { | ||||
| err = vn_lock(*vpp, flags); | err = vn_lock(*vpp, flags); | ||||
| if (err != 0) | if (err != 0) | ||||
| vrele(*vpp); | vrele(*vpp); | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| else if ((zp->z_pflags & ZFS_XATTR) != 0) { | |||||
| if ((*vpp)->v_type == VDIR) | |||||
| vn_irflag_set_cond(*vpp, VIRF_NAMEDDIR); | |||||
| else | |||||
| vn_irflag_set_cond(*vpp, VIRF_NAMEDATTR); | |||||
| } | } | ||||
| #endif | |||||
| } | |||||
| if (err != 0) | if (err != 0) | ||||
| *vpp = NULL; | *vpp = NULL; | ||||
| return (err); | return (err); | ||||
| } | } | ||||
| static int | static int | ||||
| zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, uint64_t *extflagsp, | zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, uint64_t *extflagsp, | ||||
| struct ucred **credanonp, int *numsecflavors, int *secflavors) | struct ucred **credanonp, int *numsecflavors, int *secflavors) | ||||
| ▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | if (zp->z_unlinked || zp_gen != fid_gen) { | ||||
| vrele(ZTOV(zp)); | vrele(ZTOV(zp)); | ||||
| zfs_exit(zfsvfs, FTAG); | zfs_exit(zfsvfs, FTAG); | ||||
| return (SET_ERROR(EINVAL)); | return (SET_ERROR(EINVAL)); | ||||
| } | } | ||||
| *vpp = ZTOV(zp); | *vpp = ZTOV(zp); | ||||
| zfs_exit(zfsvfs, FTAG); | zfs_exit(zfsvfs, FTAG); | ||||
| err = vn_lock(*vpp, flags); | err = vn_lock(*vpp, flags); | ||||
| if (err == 0) | if (err == 0) { | ||||
| vnode_create_vobject(*vpp, zp->z_size, curthread); | vnode_create_vobject(*vpp, zp->z_size, curthread); | ||||
| #if __FreeBSD_version >= 1500040 | |||||
| if ((zp->z_pflags & ZFS_XATTR) != 0) { | |||||
| if ((*vpp)->v_type == VDIR) | |||||
| vn_irflag_set_cond(*vpp, VIRF_NAMEDDIR); | |||||
| else | else | ||||
| vn_irflag_set_cond(*vpp, VIRF_NAMEDATTR); | |||||
| } | |||||
| #endif | |||||
| } else | |||||
| *vpp = NULL; | *vpp = NULL; | ||||
| return (err); | return (err); | ||||
| } | } | ||||
| /* | /* | ||||
| * Block out VOPs and close zfsvfs_t::z_os | * Block out VOPs and close zfsvfs_t::z_os | ||||
| * | * | ||||
| * Note, if successful, then we return with the 'z_teardown_lock' and | * Note, if successful, then we return with the 'z_teardown_lock' and | ||||
| ▲ Show 20 Lines • Show All 599 Lines • Show Last 20 Lines | |||||
ZSB_XATTR and z_xattr_sa might change in run time, with the xattr property. It is not read-only. The extended attributes code checks both locations on read, so switching it live is not fatal for already existing ones. With names attributes only accessing directories the two KPIs may start returning different values if the property value is changed live. May need consideration.