mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-30 10:44:09 +03:00
FreeBSD: Implement xattr=sa
FreeBSD historically has not cared about the xattr property; it was always treated as xattr=on. With xattr=on, xattrs are stored as files in a hidden xattr directory. With xattr=sa, xattrs are stored as system attributes and get cached in nvlists during xattr operations. This makes SA xattrs simpler and more efficient to manipulate. FreeBSD needs to implement the SA xattr operations for feature parity with Linux and to ensure that SA xattrs are accessible when migrated or replicated from Linux. Following the example set by Linux, refactor our existing extattr vnops to split off the parts handling dir style xattrs, and add the corresponding SA handling parts. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #11997
This commit is contained in:
committed by
Brian Behlendorf
parent
d86debf576
commit
210231ede0
@@ -145,10 +145,13 @@ zfs_znode_cache_constructor(void *buf, void *arg, int kmflags)
|
||||
|
||||
mutex_init(&zp->z_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
mutex_init(&zp->z_acl_lock, NULL, MUTEX_DEFAULT, NULL);
|
||||
rw_init(&zp->z_xattr_lock, NULL, RW_DEFAULT, NULL);
|
||||
|
||||
zfs_rangelock_init(&zp->z_rangelock, zfs_rangelock_cb, zp);
|
||||
|
||||
zp->z_acl_cached = NULL;
|
||||
zp->z_xattr_cached = NULL;
|
||||
zp->z_xattr_parent = 0;
|
||||
zp->z_vnode = NULL;
|
||||
return (0);
|
||||
}
|
||||
@@ -164,9 +167,11 @@ zfs_znode_cache_destructor(void *buf, void *arg)
|
||||
ASSERT(!list_link_active(&zp->z_link_node));
|
||||
mutex_destroy(&zp->z_lock);
|
||||
mutex_destroy(&zp->z_acl_lock);
|
||||
rw_destroy(&zp->z_xattr_lock);
|
||||
zfs_rangelock_fini(&zp->z_rangelock);
|
||||
|
||||
ASSERT3P(zp->z_acl_cached, ==, NULL);
|
||||
ASSERT3P(zp->z_xattr_cached, ==, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +213,10 @@ zfs_znode_alloc_kmem(int flags)
|
||||
static void
|
||||
zfs_znode_free_kmem(znode_t *zp)
|
||||
{
|
||||
|
||||
if (zp->z_xattr_cached) {
|
||||
nvlist_free(zp->z_xattr_cached);
|
||||
zp->z_xattr_cached = NULL;
|
||||
}
|
||||
uma_zfree_smr(znode_uma_zone, zp);
|
||||
}
|
||||
#else
|
||||
@@ -233,7 +241,10 @@ zfs_znode_alloc_kmem(int flags)
|
||||
static void
|
||||
zfs_znode_free_kmem(znode_t *zp)
|
||||
{
|
||||
|
||||
if (zp->z_xattr_cached) {
|
||||
nvlist_free(zp->z_xattr_cached);
|
||||
zp->z_xattr_cached = NULL;
|
||||
}
|
||||
kmem_cache_free(znode_cache, zp);
|
||||
}
|
||||
#endif
|
||||
@@ -1079,8 +1090,15 @@ zfs_rezget(znode_t *zp)
|
||||
zfs_acl_free(zp->z_acl_cached);
|
||||
zp->z_acl_cached = NULL;
|
||||
}
|
||||
|
||||
mutex_exit(&zp->z_acl_lock);
|
||||
|
||||
rw_enter(&zp->z_xattr_lock, RW_WRITER);
|
||||
if (zp->z_xattr_cached) {
|
||||
nvlist_free(zp->z_xattr_cached);
|
||||
zp->z_xattr_cached = NULL;
|
||||
}
|
||||
rw_exit(&zp->z_xattr_lock);
|
||||
|
||||
ASSERT3P(zp->z_sa_hdl, ==, NULL);
|
||||
err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db);
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user