LINUX: Make sysctl definitions more concise

Our sysctl definitions are quite verbose, and adding new ones involves
copying a bunch of lines. Make these a little easier to specify, by
defining some new preprocessor macros.

Reviewed-on: https://gerrit.openafs.org/13700
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 1b0bb8a7fcbd69d513ed30bb76fd0693d1bd3319)

Change-Id: Ib656634ed956b845c89656069aa297253acce785
Reviewed-on: https://gerrit.openafs.org/15521
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Andrew Deason 2019-07-18 22:56:48 -05:00 committed by Stephan Wiesand
parent fef2457693
commit d15c7ab50c

View File

@ -18,6 +18,8 @@
#include <linux/config.h>
#endif
#ifdef CONFIG_SYSCTL
/* From afs_util.c */
extern afs_int32 afs_md5inum;
@ -31,206 +33,48 @@ extern afs_int32 afs_blocksUsed_2;
extern afs_int32 afs_pct1;
extern afs_int32 afs_pct2;
#ifdef CONFIG_SYSCTL
# ifdef STRUCT_CTL_TABLE_HAS_CTL_NAME
# ifdef CTL_UNNUMBERED
# define AFS_SYSCTL_NAME(num) .ctl_name = CTL_UNNUMBERED,
# else
# define AFS_SYSCTL_NAME(num) .ctl_name = num,
# endif
# else
# define AFS_SYSCTL_NAME(num)
# endif
# define AFS_SYSCTL_INT2(num, perms, name, var) { \
AFS_SYSCTL_NAME(num) \
.procname = name, \
.data = &var, \
.maxlen = sizeof(var), \
.mode = perms, \
.proc_handler = &proc_dointvec \
}
# define AFS_SYSCTL_INT(num, perms, var) \
AFS_SYSCTL_INT2(num, perms, #var, var)
static struct ctl_table_header *afs_sysctl = NULL;
static struct ctl_table afs_sysctl_table[] = {
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 1,
#endif
#endif
.procname = "hm_retry_RO",
.data = &hm_retry_RO,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 2,
#endif
#endif
.procname = "hm_retry_RW",
.data = &hm_retry_RW,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 3,
#endif
#endif
.procname = "hm_retry_int",
.data = &hm_retry_int,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 4,
#endif
#endif
.procname = "GCPAGs",
.data = &afs_gcpags,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 5,
#endif
#endif
.procname = "rx_deadtime",
.data = &afs_rx_deadtime,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 6,
#endif
#endif
.procname = "bkVolPref",
.data = &afs_bkvolpref,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 7,
#endif
#endif
.procname = "afs_blocksUsed",
.data = &afs_blocksUsed,
.maxlen = sizeof(afs_int32),
.mode = 0444,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 8,
#endif
#endif
.procname = "afs_blocksUsed_0",
.data = &afs_blocksUsed_0,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 9,
#endif
#endif
.procname = "afs_blocksUsed_1",
.data = &afs_blocksUsed_1,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 10,
#endif
#endif
.procname = "afs_blocksUsed_2",
.data = &afs_blocksUsed_2,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 11,
#endif
#endif
.procname = "afs_pct1",
.data = &afs_pct1,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 12,
#endif
#endif
.procname = "afs_pct2",
.data = &afs_pct2,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 13,
#endif
#endif
.procname = "afs_cacheBlocks",
.data = &afs_cacheBlocks,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 14,
#endif
#endif
.procname = "md5inum",
.data = &afs_md5inum,
.maxlen = sizeof(afs_int32),
.mode = 0644,
.proc_handler = &proc_dointvec
},
AFS_SYSCTL_INT(1, 0644, hm_retry_RO),
AFS_SYSCTL_INT(2, 0644, hm_retry_RW),
AFS_SYSCTL_INT(3, 0644, hm_retry_int),
AFS_SYSCTL_INT2(4, 0644, "GCPAGs", afs_gcpags),
AFS_SYSCTL_INT2(5, 0644, "rx_deadtime", afs_rx_deadtime),
AFS_SYSCTL_INT2(6, 0644, "bkVolPref", afs_bkvolpref),
AFS_SYSCTL_INT( 7, 0444, afs_blocksUsed),
AFS_SYSCTL_INT( 8, 0644, afs_blocksUsed_0),
AFS_SYSCTL_INT( 9, 0644, afs_blocksUsed_1),
AFS_SYSCTL_INT(10, 0644, afs_blocksUsed_2),
AFS_SYSCTL_INT( 11, 0644, afs_pct1),
AFS_SYSCTL_INT( 12, 0644, afs_pct2),
AFS_SYSCTL_INT( 13, 0644, afs_cacheBlocks),
AFS_SYSCTL_INT2(14, 0644, "md5inum", afs_md5inum),
{
.procname = 0
}
@ -238,13 +82,7 @@ static struct ctl_table afs_sysctl_table[] = {
static struct ctl_table fs_sysctl_table[] = {
{
#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
#if defined(CTL_UNNUMBERED)
.ctl_name = CTL_UNNUMBERED,
#else
.ctl_name = 1,
#endif
#endif
AFS_SYSCTL_NAME(1)
.procname = "afs",
.mode = 0555,
.child = afs_sysctl_table
@ -257,11 +95,11 @@ static struct ctl_table fs_sysctl_table[] = {
int
osi_sysctl_init(void)
{
#if defined(REGISTER_SYSCTL_TABLE_NOFLAG)
# if defined(REGISTER_SYSCTL_TABLE_NOFLAG)
afs_sysctl = register_sysctl_table(fs_sysctl_table);
#else
# else
afs_sysctl = register_sysctl_table(fs_sysctl_table, 0);
#endif
# endif
if (!afs_sysctl)
return -1;