mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
znode: expose zfs_get_zplprop to libzpool
There's no particular reason this function should be kernel-only, and I want to use it (indirectly) from zdb. I've moved it to zfs_znode.c because libzpool does not compile in zfs_vfsops.c, and this at least matches the header its imported from. Sponsored-By: Klara, Inc. Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Reviewed-by: WHR <msl0000023508@gmail.com> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Closes #14642
This commit is contained in:
committed by
Brian Behlendorf
parent
5ba4025a8d
commit
2b9f8ba673
@@ -2052,91 +2052,6 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a property stored within the master node.
|
||||
*/
|
||||
int
|
||||
zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value)
|
||||
{
|
||||
uint64_t *cached_copy = NULL;
|
||||
|
||||
/*
|
||||
* Figure out where in the objset_t the cached copy would live, if it
|
||||
* is available for the requested property.
|
||||
*/
|
||||
if (os != NULL) {
|
||||
switch (prop) {
|
||||
case ZFS_PROP_VERSION:
|
||||
cached_copy = &os->os_version;
|
||||
break;
|
||||
case ZFS_PROP_NORMALIZE:
|
||||
cached_copy = &os->os_normalization;
|
||||
break;
|
||||
case ZFS_PROP_UTF8ONLY:
|
||||
cached_copy = &os->os_utf8only;
|
||||
break;
|
||||
case ZFS_PROP_CASE:
|
||||
cached_copy = &os->os_casesensitivity;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cached_copy != NULL && *cached_copy != OBJSET_PROP_UNINITIALIZED) {
|
||||
*value = *cached_copy;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the property wasn't cached, look up the file system's value for
|
||||
* the property. For the version property, we look up a slightly
|
||||
* different string.
|
||||
*/
|
||||
const char *pname;
|
||||
int error = ENOENT;
|
||||
if (prop == ZFS_PROP_VERSION)
|
||||
pname = ZPL_VERSION_STR;
|
||||
else
|
||||
pname = zfs_prop_to_name(prop);
|
||||
|
||||
if (os != NULL) {
|
||||
ASSERT3U(os->os_phys->os_type, ==, DMU_OST_ZFS);
|
||||
error = zap_lookup(os, MASTER_NODE_OBJ, pname, 8, 1, value);
|
||||
}
|
||||
|
||||
if (error == ENOENT) {
|
||||
/* No value set, use the default value */
|
||||
switch (prop) {
|
||||
case ZFS_PROP_VERSION:
|
||||
*value = ZPL_VERSION;
|
||||
break;
|
||||
case ZFS_PROP_NORMALIZE:
|
||||
case ZFS_PROP_UTF8ONLY:
|
||||
*value = 0;
|
||||
break;
|
||||
case ZFS_PROP_CASE:
|
||||
*value = ZFS_CASE_SENSITIVE;
|
||||
break;
|
||||
case ZFS_PROP_ACLTYPE:
|
||||
*value = ZFS_ACLTYPE_OFF;
|
||||
break;
|
||||
default:
|
||||
return (error);
|
||||
}
|
||||
error = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If one of the methods for getting the property value above worked,
|
||||
* copy it into the objset_t's cache.
|
||||
*/
|
||||
if (error == 0 && cached_copy != NULL) {
|
||||
*cached_copy = *value;
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if the corresponding vfs's unmounted flag is set.
|
||||
* Otherwise return false.
|
||||
|
||||
@@ -2254,6 +2254,91 @@ zfs_obj_to_stats(objset_t *osp, uint64_t obj, zfs_stat_t *sb,
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a property stored within the master node.
|
||||
*/
|
||||
int
|
||||
zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value)
|
||||
{
|
||||
uint64_t *cached_copy = NULL;
|
||||
|
||||
/*
|
||||
* Figure out where in the objset_t the cached copy would live, if it
|
||||
* is available for the requested property.
|
||||
*/
|
||||
if (os != NULL) {
|
||||
switch (prop) {
|
||||
case ZFS_PROP_VERSION:
|
||||
cached_copy = &os->os_version;
|
||||
break;
|
||||
case ZFS_PROP_NORMALIZE:
|
||||
cached_copy = &os->os_normalization;
|
||||
break;
|
||||
case ZFS_PROP_UTF8ONLY:
|
||||
cached_copy = &os->os_utf8only;
|
||||
break;
|
||||
case ZFS_PROP_CASE:
|
||||
cached_copy = &os->os_casesensitivity;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cached_copy != NULL && *cached_copy != OBJSET_PROP_UNINITIALIZED) {
|
||||
*value = *cached_copy;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the property wasn't cached, look up the file system's value for
|
||||
* the property. For the version property, we look up a slightly
|
||||
* different string.
|
||||
*/
|
||||
const char *pname;
|
||||
int error = ENOENT;
|
||||
if (prop == ZFS_PROP_VERSION)
|
||||
pname = ZPL_VERSION_STR;
|
||||
else
|
||||
pname = zfs_prop_to_name(prop);
|
||||
|
||||
if (os != NULL) {
|
||||
ASSERT3U(os->os_phys->os_type, ==, DMU_OST_ZFS);
|
||||
error = zap_lookup(os, MASTER_NODE_OBJ, pname, 8, 1, value);
|
||||
}
|
||||
|
||||
if (error == ENOENT) {
|
||||
/* No value set, use the default value */
|
||||
switch (prop) {
|
||||
case ZFS_PROP_VERSION:
|
||||
*value = ZPL_VERSION;
|
||||
break;
|
||||
case ZFS_PROP_NORMALIZE:
|
||||
case ZFS_PROP_UTF8ONLY:
|
||||
*value = 0;
|
||||
break;
|
||||
case ZFS_PROP_CASE:
|
||||
*value = ZFS_CASE_SENSITIVE;
|
||||
break;
|
||||
case ZFS_PROP_ACLTYPE:
|
||||
*value = ZFS_ACLTYPE_OFF;
|
||||
break;
|
||||
default:
|
||||
return (error);
|
||||
}
|
||||
error = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If one of the methods for getting the property value above worked,
|
||||
* copy it into the objset_t's cache.
|
||||
*/
|
||||
if (error == 0 && cached_copy != NULL) {
|
||||
*cached_copy = *value;
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
#if defined(_KERNEL)
|
||||
EXPORT_SYMBOL(zfs_create_fs);
|
||||
EXPORT_SYMBOL(zfs_obj_to_path);
|
||||
|
||||
Reference in New Issue
Block a user