Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_sa.c
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void | void | ||||
zfs_sa_get_scanstamp(znode_t *zp, xvattr_t *xvap) | zfs_sa_get_scanstamp(znode_t *zp, xvattr_t *xvap) | ||||
{ | { | ||||
zfsvfs_t *zfsvfs = zp->z_zfsvfs; | zfsvfs_t *zfsvfs = zp->z_zfsvfs; | ||||
xoptattr_t *xoap; | xoptattr_t *xoap; | ||||
ASSERT(MUTEX_HELD(&zp->z_lock)); | ASSERT_VOP_LOCKED(ZTOV(zp), "zfs_sa_get_scanstamp"); | ||||
VERIFY((xoap = xva_getxoptattr(xvap)) != NULL); | VERIFY((xoap = xva_getxoptattr(xvap)) != NULL); | ||||
if (zp->z_is_sa) { | if (zp->z_is_sa) { | ||||
if (sa_lookup(zp->z_sa_hdl, SA_ZPL_SCANSTAMP(zfsvfs), | if (sa_lookup(zp->z_sa_hdl, SA_ZPL_SCANSTAMP(zfsvfs), | ||||
&xoap->xoa_av_scanstamp, | &xoap->xoa_av_scanstamp, | ||||
sizeof (xoap->xoa_av_scanstamp)) != 0) | sizeof (xoap->xoa_av_scanstamp)) != 0) | ||||
return; | return; | ||||
} else { | } else { | ||||
dmu_object_info_t doi; | dmu_object_info_t doi; | ||||
Show All 17 Lines | |||||
} | } | ||||
void | void | ||||
zfs_sa_set_scanstamp(znode_t *zp, xvattr_t *xvap, dmu_tx_t *tx) | zfs_sa_set_scanstamp(znode_t *zp, xvattr_t *xvap, dmu_tx_t *tx) | ||||
{ | { | ||||
zfsvfs_t *zfsvfs = zp->z_zfsvfs; | zfsvfs_t *zfsvfs = zp->z_zfsvfs; | ||||
xoptattr_t *xoap; | xoptattr_t *xoap; | ||||
ASSERT(MUTEX_HELD(&zp->z_lock)); | ASSERT_VOP_ELOCKED(ZTOV(zp), "zfs_sa_set_scanstamp"); | ||||
VERIFY((xoap = xva_getxoptattr(xvap)) != NULL); | VERIFY((xoap = xva_getxoptattr(xvap)) != NULL); | ||||
if (zp->z_is_sa) | if (zp->z_is_sa) | ||||
VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_SCANSTAMP(zfsvfs), | VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_SCANSTAMP(zfsvfs), | ||||
&xoap->xoa_av_scanstamp, | &xoap->xoa_av_scanstamp, | ||||
sizeof (xoap->xoa_av_scanstamp), tx)); | sizeof (xoap->xoa_av_scanstamp), tx)); | ||||
else { | else { | ||||
dmu_object_info_t doi; | dmu_object_info_t doi; | ||||
dmu_buf_t *db = sa_get_db(zp->z_sa_hdl); | dmu_buf_t *db = sa_get_db(zp->z_sa_hdl); | ||||
Show All 30 Lines | zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) | ||||
sa_bulk_attr_t bulk[20]; | sa_bulk_attr_t bulk[20]; | ||||
int count = 0; | int count = 0; | ||||
sa_bulk_attr_t sa_attrs[20] = { 0 }; | sa_bulk_attr_t sa_attrs[20] = { 0 }; | ||||
zfs_acl_locator_cb_t locate = { 0 }; | zfs_acl_locator_cb_t locate = { 0 }; | ||||
uint64_t uid, gid, mode, rdev, xattr, parent; | uint64_t uid, gid, mode, rdev, xattr, parent; | ||||
uint64_t crtime[2], mtime[2], ctime[2]; | uint64_t crtime[2], mtime[2], ctime[2]; | ||||
zfs_acl_phys_t znode_acl; | zfs_acl_phys_t znode_acl; | ||||
char scanstamp[AV_SCANSTAMP_SZ]; | char scanstamp[AV_SCANSTAMP_SZ]; | ||||
boolean_t drop_lock = B_FALSE; | |||||
/* | /* | ||||
* No upgrade if ACL isn't cached | * No upgrade if ACL isn't cached | ||||
* since we won't know which locks are held | * since we won't know which locks are held | ||||
* and ready the ACL would require special "locked" | * and ready the ACL would require special "locked" | ||||
* interfaces that would be messy | * interfaces that would be messy | ||||
*/ | */ | ||||
if (zp->z_acl_cached == NULL || ZTOV(zp)->v_type == VLNK) | if (zp->z_acl_cached == NULL || ZTOV(zp)->v_type == VLNK) | ||||
return; | return; | ||||
/* | /* | ||||
* If the z_lock is held and we aren't the owner | * If the vnode lock is held and we aren't the owner | ||||
* the just return since we don't want to deadlock | * then just return since we don't want to deadlock | ||||
* trying to update the status of z_is_sa. This | * trying to update the status of z_is_sa. This | ||||
* file can then be upgraded at a later time. | * file can then be upgraded at a later time. | ||||
* | * | ||||
* Otherwise, we know we are doing the | * Otherwise, we know we are doing the | ||||
* sa_update() that caused us to enter this function. | * sa_update() that caused us to enter this function. | ||||
*/ | */ | ||||
if (mutex_owner(&zp->z_lock) != curthread) { | if (vn_lock(ZTOV(zp), LK_EXCLUSIVE | LK_NOWAIT) != 0) | ||||
if (mutex_tryenter(&zp->z_lock) == 0) | |||||
return; | return; | ||||
else | |||||
drop_lock = B_TRUE; | |||||
} | |||||
/* First do a bulk query of the attributes that aren't cached */ | /* First do a bulk query of the attributes that aren't cached */ | ||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL, &mtime, 16); | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL, &mtime, 16); | ||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL, &ctime, 16); | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL, &ctime, 16); | ||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zfsvfs), NULL, &crtime, 16); | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zfsvfs), NULL, &crtime, 16); | ||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zfsvfs), NULL, &mode, 8); | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zfsvfs), NULL, &mode, 8); | ||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_PARENT(zfsvfs), NULL, &parent, 8); | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_PARENT(zfsvfs), NULL, &parent, 8); | ||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_XATTR(zfsvfs), NULL, &xattr, 8); | SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_XATTR(zfsvfs), NULL, &xattr, 8); | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) | ||||
VERIFY(sa_replace_all_by_template_locked(hdl, sa_attrs, | VERIFY(sa_replace_all_by_template_locked(hdl, sa_attrs, | ||||
count, tx) == 0); | count, tx) == 0); | ||||
if (znode_acl.z_acl_extern_obj) | if (znode_acl.z_acl_extern_obj) | ||||
VERIFY(0 == dmu_object_free(zfsvfs->z_os, | VERIFY(0 == dmu_object_free(zfsvfs->z_os, | ||||
znode_acl.z_acl_extern_obj, tx)); | znode_acl.z_acl_extern_obj, tx)); | ||||
zp->z_is_sa = B_TRUE; | zp->z_is_sa = B_TRUE; | ||||
done: | done: | ||||
if (drop_lock) | VOP_UNLOCK(ZTOV(zp), 0); | ||||
mutex_exit(&zp->z_lock); | |||||
} | } | ||||
void | void | ||||
zfs_sa_upgrade_txholds(dmu_tx_t *tx, znode_t *zp) | zfs_sa_upgrade_txholds(dmu_tx_t *tx, znode_t *zp) | ||||
{ | { | ||||
if (!zp->z_zfsvfs->z_use_sa || zp->z_is_sa) | if (!zp->z_zfsvfs->z_use_sa || zp->z_is_sa) | ||||
return; | return; | ||||
Show All 10 Lines |