aboutsummaryrefslogtreecommitdiffstats
path: root/module/zcommon
diff options
context:
space:
mode:
authorнаб <[email protected]>2022-01-15 00:37:55 +0100
committerGitHub <[email protected]>2022-01-14 15:37:55 -0800
commit18168da727427e28914235137daebe06c23069cd (patch)
tree71a8769a2a12dd4add4f7abfb5a1e4f51f09cf18 /module/zcommon
parent7adc19009817303af10c8b3b7617850994cfb9e2 (diff)
module/*.ko: prune .data, global .rodata
Evaluated every variable that lives in .data (and globals in .rodata) in the kernel modules, and constified/eliminated/localised them appropriately. This means that all read-only data is now actually read-only data, and, if possible, at file scope. A lot of previously- global-symbols became inlinable (and inlined!) constants. Probably not in a big Wowee Performance Moment, but hey. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12899
Diffstat (limited to 'module/zcommon')
-rw-r--r--module/zcommon/zfeature_common.c2
-rw-r--r--module/zcommon/zfs_comutil.c18
-rw-r--r--module/zcommon/zfs_deleg.c9
-rw-r--r--module/zcommon/zfs_prop.c2
4 files changed, 10 insertions, 21 deletions
diff --git a/module/zcommon/zfeature_common.c b/module/zcommon/zfeature_common.c
index c7278fa00..529c52316 100644
--- a/module/zcommon/zfeature_common.c
+++ b/module/zcommon/zfeature_common.c
@@ -325,7 +325,7 @@ zfeature_register(spa_feature_t fid, const char *guid, const char *name,
const struct zfs_mod_supported_features *sfeatures)
{
zfeature_info_t *feature = &spa_feature_table[fid];
- static spa_feature_t nodeps[] = { SPA_FEATURE_NONE };
+ static const spa_feature_t nodeps[] = { SPA_FEATURE_NONE };
ASSERT(name != NULL);
ASSERT(desc != NULL);
diff --git a/module/zcommon/zfs_comutil.c b/module/zcommon/zfs_comutil.c
index 886167759..020e7e86c 100644
--- a/module/zcommon/zfs_comutil.c
+++ b/module/zcommon/zfs_comutil.c
@@ -158,13 +158,11 @@ static zfs_version_spa_map_t zfs_version_table[] = {
int
zfs_zpl_version_map(int spa_version)
{
- int i;
int version = -1;
- for (i = 0; zfs_version_table[i].version_spa; i++) {
+ for (int i = 0; zfs_version_table[i].version_spa; i++)
if (spa_version >= zfs_version_table[i].version_spa)
version = zfs_version_table[i].version_zpl;
- }
return (version);
}
@@ -176,22 +174,18 @@ zfs_zpl_version_map(int spa_version)
int
zfs_spa_version_map(int zpl_version)
{
- int i;
- int version = -1;
-
- for (i = 0; zfs_version_table[i].version_zpl; i++) {
+ for (int i = 0; zfs_version_table[i].version_zpl; i++)
if (zfs_version_table[i].version_zpl >= zpl_version)
return (zfs_version_table[i].version_spa);
- }
- return (version);
+ return (-1);
}
/*
* This is the table of legacy internal event names; it should not be modified.
* The internal events are now stored in the history log as strings.
*/
-const char *zfs_history_event_names[ZFS_NUM_LEGACY_HISTORY_EVENTS] = {
+const char *const zfs_history_event_names[ZFS_NUM_LEGACY_HISTORY_EVENTS] = {
"invalid event",
"pool create",
"vdev add",
@@ -243,9 +237,7 @@ zfs_dataset_name_hidden(const char *name)
* internal datasets (which have a $ in their name), and
* temporary datasets (which have a % in their name).
*/
- if (strchr(name, '$') != NULL)
- return (B_TRUE);
- if (strchr(name, '%') != NULL)
+ if (strpbrk(name, "$%") != NULL)
return (B_TRUE);
if (!INGLOBALZONE(curproc) && !zone_dataset_visible(name, NULL))
return (B_TRUE);
diff --git a/module/zcommon/zfs_deleg.c b/module/zcommon/zfs_deleg.c
index e1f5a353b..8a4a6ca86 100644
--- a/module/zcommon/zfs_deleg.c
+++ b/module/zcommon/zfs_deleg.c
@@ -42,7 +42,7 @@
#include "zfs_deleg.h"
#include "zfs_namecheck.h"
-zfs_deleg_perm_tab_t zfs_deleg_perm_tab[] = {
+const zfs_deleg_perm_tab_t zfs_deleg_perm_tab[] = {
{ZFS_DELEG_PERM_ALLOW},
{ZFS_DELEG_PERM_BOOKMARK},
{ZFS_DELEG_PERM_CLONE},
@@ -89,15 +89,12 @@ zfs_valid_permission_name(const char *perm)
const char *
zfs_deleg_canonicalize_perm(const char *perm)
{
- int i;
- zfs_prop_t prop;
-
- for (i = 0; zfs_deleg_perm_tab[i].z_perm != NULL; i++) {
+ for (int i = 0; zfs_deleg_perm_tab[i].z_perm != NULL; i++) {
if (strcmp(perm, zfs_deleg_perm_tab[i].z_perm) == 0)
return (perm);
}
- prop = zfs_name_to_prop(perm);
+ zfs_prop_t prop = zfs_name_to_prop(perm);
if (prop != ZPROP_INVAL && zfs_prop_delegatable(prop))
return (zfs_prop_to_name(prop));
return (NULL);
diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c
index 800885ee6..36f30859d 100644
--- a/module/zcommon/zfs_prop.c
+++ b/module/zcommon/zfs_prop.c
@@ -50,7 +50,7 @@
static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
/* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
-const char *zfs_userquota_prop_prefixes[] = {
+const char *const zfs_userquota_prop_prefixes[] = {
"userused@",
"userquota@",
"groupused@",