mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
Move get_temporary_prop to platform code
Temporary property handling at the VFS layer requires platform specific code. Reviewed-by: Sean Eric Fagan <sef@ixsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Matt Macy <mmacy@FreeBSD.org> Closes #9401
This commit is contained in:
parent
6501906280
commit
2516a87821
@ -224,6 +224,8 @@ extern int zfs_statvfs(struct dentry *dentry, struct kstatfs *statp);
|
||||
extern int zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp);
|
||||
extern int zfs_prune(struct super_block *sb, unsigned long nr_to_scan,
|
||||
int *objects);
|
||||
extern int zfs_get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop,
|
||||
uint64_t *val, char *setpoint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -533,6 +533,81 @@ unregister:
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes a dataset, a property, a value and that value's setpoint as
|
||||
* found in the ZAP. Checks if the property has been changed in the vfs.
|
||||
* If so, val and setpoint will be overwritten with updated content.
|
||||
* Otherwise, they are left unchanged.
|
||||
*/
|
||||
int
|
||||
zfs_get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop, uint64_t *val,
|
||||
char *setpoint)
|
||||
{
|
||||
int error;
|
||||
zfsvfs_t *zfvp;
|
||||
vfs_t *vfsp;
|
||||
objset_t *os;
|
||||
uint64_t tmp = *val;
|
||||
|
||||
error = dmu_objset_from_ds(ds, &os);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
if (dmu_objset_type(os) != DMU_OST_ZFS)
|
||||
return (EINVAL);
|
||||
|
||||
mutex_enter(&os->os_user_ptr_lock);
|
||||
zfvp = dmu_objset_get_user(os);
|
||||
mutex_exit(&os->os_user_ptr_lock);
|
||||
if (zfvp == NULL)
|
||||
return (ESRCH);
|
||||
|
||||
vfsp = zfvp->z_vfs;
|
||||
|
||||
switch (zfs_prop) {
|
||||
case ZFS_PROP_ATIME:
|
||||
if (vfsp->vfs_do_atime)
|
||||
tmp = vfsp->vfs_atime;
|
||||
break;
|
||||
case ZFS_PROP_RELATIME:
|
||||
if (vfsp->vfs_do_relatime)
|
||||
tmp = vfsp->vfs_relatime;
|
||||
break;
|
||||
case ZFS_PROP_DEVICES:
|
||||
if (vfsp->vfs_do_devices)
|
||||
tmp = vfsp->vfs_devices;
|
||||
break;
|
||||
case ZFS_PROP_EXEC:
|
||||
if (vfsp->vfs_do_exec)
|
||||
tmp = vfsp->vfs_exec;
|
||||
break;
|
||||
case ZFS_PROP_SETUID:
|
||||
if (vfsp->vfs_do_setuid)
|
||||
tmp = vfsp->vfs_setuid;
|
||||
break;
|
||||
case ZFS_PROP_READONLY:
|
||||
if (vfsp->vfs_do_readonly)
|
||||
tmp = vfsp->vfs_readonly;
|
||||
break;
|
||||
case ZFS_PROP_XATTR:
|
||||
if (vfsp->vfs_do_xattr)
|
||||
tmp = vfsp->vfs_xattr;
|
||||
break;
|
||||
case ZFS_PROP_NBMAND:
|
||||
if (vfsp->vfs_do_nbmand)
|
||||
tmp = vfsp->vfs_nbmand;
|
||||
break;
|
||||
default:
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
if (tmp != *val) {
|
||||
(void) strcpy(setpoint, "temporary");
|
||||
*val = tmp;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
zfs_space_delta_cb(dmu_object_type_t bonustype, void *data,
|
||||
uint64_t *userp, uint64_t *groupp, uint64_t *projectp)
|
||||
|
@ -212,85 +212,6 @@ get_dsl_dir_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes a dataset, a property, a value and that value's setpoint as
|
||||
* found in the ZAP. Checks if the property has been changed in the vfs.
|
||||
* If so, val and setpoint will be overwritten with updated content.
|
||||
* Otherwise, they are left unchanged.
|
||||
*/
|
||||
static int
|
||||
get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop, uint64_t *val,
|
||||
char *setpoint)
|
||||
{
|
||||
#if !defined(_KERNEL)
|
||||
return (0);
|
||||
#else
|
||||
int error;
|
||||
zfsvfs_t *zfvp;
|
||||
vfs_t *vfsp;
|
||||
objset_t *os;
|
||||
uint64_t tmp = *val;
|
||||
|
||||
error = dmu_objset_from_ds(ds, &os);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
if (dmu_objset_type(os) != DMU_OST_ZFS)
|
||||
return (EINVAL);
|
||||
|
||||
mutex_enter(&os->os_user_ptr_lock);
|
||||
zfvp = dmu_objset_get_user(os);
|
||||
mutex_exit(&os->os_user_ptr_lock);
|
||||
if (zfvp == NULL)
|
||||
return (ESRCH);
|
||||
|
||||
vfsp = zfvp->z_vfs;
|
||||
|
||||
switch (zfs_prop) {
|
||||
case ZFS_PROP_ATIME:
|
||||
if (vfsp->vfs_do_atime)
|
||||
tmp = vfsp->vfs_atime;
|
||||
break;
|
||||
case ZFS_PROP_RELATIME:
|
||||
if (vfsp->vfs_do_relatime)
|
||||
tmp = vfsp->vfs_relatime;
|
||||
break;
|
||||
case ZFS_PROP_DEVICES:
|
||||
if (vfsp->vfs_do_devices)
|
||||
tmp = vfsp->vfs_devices;
|
||||
break;
|
||||
case ZFS_PROP_EXEC:
|
||||
if (vfsp->vfs_do_exec)
|
||||
tmp = vfsp->vfs_exec;
|
||||
break;
|
||||
case ZFS_PROP_SETUID:
|
||||
if (vfsp->vfs_do_setuid)
|
||||
tmp = vfsp->vfs_setuid;
|
||||
break;
|
||||
case ZFS_PROP_READONLY:
|
||||
if (vfsp->vfs_do_readonly)
|
||||
tmp = vfsp->vfs_readonly;
|
||||
break;
|
||||
case ZFS_PROP_XATTR:
|
||||
if (vfsp->vfs_do_xattr)
|
||||
tmp = vfsp->vfs_xattr;
|
||||
break;
|
||||
case ZFS_PROP_NBMAND:
|
||||
if (vfsp->vfs_do_nbmand)
|
||||
tmp = vfsp->vfs_nbmand;
|
||||
break;
|
||||
default:
|
||||
return (ENOENT);
|
||||
}
|
||||
|
||||
if (tmp != *val) {
|
||||
(void) strcpy(setpoint, "temporary");
|
||||
*val = tmp;
|
||||
}
|
||||
return (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the property we're looking for is stored at the dsl_dataset or
|
||||
* dsl_dir level. If so, push the property value and source onto the lua stack
|
||||
@ -547,9 +468,14 @@ get_zap_prop(lua_State *state, dsl_dataset_t *ds, zfs_prop_t zfs_prop)
|
||||
error = dsl_prop_get_ds(ds, prop_name, sizeof (numval),
|
||||
1, &numval, setpoint);
|
||||
|
||||
#ifdef _KERNEL
|
||||
/* Fill in temporary value for prop, if applicable */
|
||||
(void) get_temporary_prop(ds, zfs_prop, &numval, setpoint);
|
||||
|
||||
(void) zfs_get_temporary_prop(ds, zfs_prop, &numval, setpoint);
|
||||
#else
|
||||
return (luaL_error(state,
|
||||
"temporary properties only supported in kernel mode",
|
||||
prop_name));
|
||||
#endif
|
||||
/* Push value to lua stack */
|
||||
if (prop_type == PROP_TYPE_INDEX) {
|
||||
const char *propval;
|
||||
|
Loading…
Reference in New Issue
Block a user