linux/fs/xfs/xfs_sysctl.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2/*
   3 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
   4 * All Rights Reserved.
   5 */
   6#include "xfs.h"
   7#include "xfs_error.h"
   8
   9static struct ctl_table_header *xfs_table_header;
  10
  11#ifdef CONFIG_PROC_FS
  12STATIC int
  13xfs_stats_clear_proc_handler(
  14        struct ctl_table        *ctl,
  15        int                     write,
  16        void                    *buffer,
  17        size_t                  *lenp,
  18        loff_t                  *ppos)
  19{
  20        int             ret, *valp = ctl->data;
  21
  22        ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  23
  24        if (!ret && write && *valp) {
  25                xfs_stats_clearall(xfsstats.xs_stats);
  26                xfs_stats_clear = 0;
  27        }
  28
  29        return ret;
  30}
  31
  32STATIC int
  33xfs_panic_mask_proc_handler(
  34        struct ctl_table        *ctl,
  35        int                     write,
  36        void                    *buffer,
  37        size_t                  *lenp,
  38        loff_t                  *ppos)
  39{
  40        int             ret, *valp = ctl->data;
  41
  42        ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  43        if (!ret && write) {
  44                xfs_panic_mask = *valp;
  45#ifdef DEBUG
  46                xfs_panic_mask |= (XFS_PTAG_SHUTDOWN_CORRUPT | XFS_PTAG_LOGRES);
  47#endif
  48        }
  49        return ret;
  50}
  51#endif /* CONFIG_PROC_FS */
  52
  53STATIC int
  54xfs_deprecate_irix_sgid_inherit_proc_handler(
  55        struct ctl_table        *ctl,
  56        int                     write,
  57        void                    *buffer,
  58        size_t                  *lenp,
  59        loff_t                  *ppos)
  60{
  61        if (write) {
  62                printk_once(KERN_WARNING
  63                                "XFS: " "%s sysctl option is deprecated.\n",
  64                                ctl->procname);
  65        }
  66        return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  67}
  68
  69STATIC int
  70xfs_deprecate_irix_symlink_mode_proc_handler(
  71        struct ctl_table        *ctl,
  72        int                     write,
  73        void                    *buffer,
  74        size_t                  *lenp,
  75        loff_t                  *ppos)
  76{
  77        if (write) {
  78                printk_once(KERN_WARNING
  79                                "XFS: " "%s sysctl option is deprecated.\n",
  80                                ctl->procname);
  81        }
  82        return proc_dointvec_minmax(ctl, write, buffer, lenp, ppos);
  83}
  84
  85static struct ctl_table xfs_table[] = {
  86        {
  87                .procname       = "irix_sgid_inherit",
  88                .data           = &xfs_params.sgid_inherit.val,
  89                .maxlen         = sizeof(int),
  90                .mode           = 0644,
  91                .proc_handler   = xfs_deprecate_irix_sgid_inherit_proc_handler,
  92                .extra1         = &xfs_params.sgid_inherit.min,
  93                .extra2         = &xfs_params.sgid_inherit.max
  94        },
  95        {
  96                .procname       = "irix_symlink_mode",
  97                .data           = &xfs_params.symlink_mode.val,
  98                .maxlen         = sizeof(int),
  99                .mode           = 0644,
 100                .proc_handler   = xfs_deprecate_irix_symlink_mode_proc_handler,
 101                .extra1         = &xfs_params.symlink_mode.min,
 102                .extra2         = &xfs_params.symlink_mode.max
 103        },
 104        {
 105                .procname       = "panic_mask",
 106                .data           = &xfs_params.panic_mask.val,
 107                .maxlen         = sizeof(int),
 108                .mode           = 0644,
 109                .proc_handler   = xfs_panic_mask_proc_handler,
 110                .extra1         = &xfs_params.panic_mask.min,
 111                .extra2         = &xfs_params.panic_mask.max
 112        },
 113
 114        {
 115                .procname       = "error_level",
 116                .data           = &xfs_params.error_level.val,
 117                .maxlen         = sizeof(int),
 118                .mode           = 0644,
 119                .proc_handler   = proc_dointvec_minmax,
 120                .extra1         = &xfs_params.error_level.min,
 121                .extra2         = &xfs_params.error_level.max
 122        },
 123        {
 124                .procname       = "xfssyncd_centisecs",
 125                .data           = &xfs_params.syncd_timer.val,
 126                .maxlen         = sizeof(int),
 127                .mode           = 0644,
 128                .proc_handler   = proc_dointvec_minmax,
 129                .extra1         = &xfs_params.syncd_timer.min,
 130                .extra2         = &xfs_params.syncd_timer.max
 131        },
 132        {
 133                .procname       = "inherit_sync",
 134                .data           = &xfs_params.inherit_sync.val,
 135                .maxlen         = sizeof(int),
 136                .mode           = 0644,
 137                .proc_handler   = proc_dointvec_minmax,
 138                .extra1         = &xfs_params.inherit_sync.min,
 139                .extra2         = &xfs_params.inherit_sync.max
 140        },
 141        {
 142                .procname       = "inherit_nodump",
 143                .data           = &xfs_params.inherit_nodump.val,
 144                .maxlen         = sizeof(int),
 145                .mode           = 0644,
 146                .proc_handler   = proc_dointvec_minmax,
 147                .extra1         = &xfs_params.inherit_nodump.min,
 148                .extra2         = &xfs_params.inherit_nodump.max
 149        },
 150        {
 151                .procname       = "inherit_noatime",
 152                .data           = &xfs_params.inherit_noatim.val,
 153                .maxlen         = sizeof(int),
 154                .mode           = 0644,
 155                .proc_handler   = proc_dointvec_minmax,
 156                .extra1         = &xfs_params.inherit_noatim.min,
 157                .extra2         = &xfs_params.inherit_noatim.max
 158        },
 159        {
 160                .procname       = "inherit_nosymlinks",
 161                .data           = &xfs_params.inherit_nosym.val,
 162                .maxlen         = sizeof(int),
 163                .mode           = 0644,
 164                .proc_handler   = proc_dointvec_minmax,
 165                .extra1         = &xfs_params.inherit_nosym.min,
 166                .extra2         = &xfs_params.inherit_nosym.max
 167        },
 168        {
 169                .procname       = "rotorstep",
 170                .data           = &xfs_params.rotorstep.val,
 171                .maxlen         = sizeof(int),
 172                .mode           = 0644,
 173                .proc_handler   = proc_dointvec_minmax,
 174                .extra1         = &xfs_params.rotorstep.min,
 175                .extra2         = &xfs_params.rotorstep.max
 176        },
 177        {
 178                .procname       = "inherit_nodefrag",
 179                .data           = &xfs_params.inherit_nodfrg.val,
 180                .maxlen         = sizeof(int),
 181                .mode           = 0644,
 182                .proc_handler   = proc_dointvec_minmax,
 183                .extra1         = &xfs_params.inherit_nodfrg.min,
 184                .extra2         = &xfs_params.inherit_nodfrg.max
 185        },
 186        {
 187                .procname       = "filestream_centisecs",
 188                .data           = &xfs_params.fstrm_timer.val,
 189                .maxlen         = sizeof(int),
 190                .mode           = 0644,
 191                .proc_handler   = proc_dointvec_minmax,
 192                .extra1         = &xfs_params.fstrm_timer.min,
 193                .extra2         = &xfs_params.fstrm_timer.max,
 194        },
 195        {
 196                .procname       = "speculative_prealloc_lifetime",
 197                .data           = &xfs_params.eofb_timer.val,
 198                .maxlen         = sizeof(int),
 199                .mode           = 0644,
 200                .proc_handler   = proc_dointvec_minmax,
 201                .extra1         = &xfs_params.eofb_timer.min,
 202                .extra2         = &xfs_params.eofb_timer.max,
 203        },
 204        {
 205                .procname       = "speculative_cow_prealloc_lifetime",
 206                .data           = &xfs_params.cowb_timer.val,
 207                .maxlen         = sizeof(int),
 208                .mode           = 0644,
 209                .proc_handler   = proc_dointvec_minmax,
 210                .extra1         = &xfs_params.cowb_timer.min,
 211                .extra2         = &xfs_params.cowb_timer.max,
 212        },
 213        /* please keep this the last entry */
 214#ifdef CONFIG_PROC_FS
 215        {
 216                .procname       = "stats_clear",
 217                .data           = &xfs_params.stats_clear.val,
 218                .maxlen         = sizeof(int),
 219                .mode           = 0644,
 220                .proc_handler   = xfs_stats_clear_proc_handler,
 221                .extra1         = &xfs_params.stats_clear.min,
 222                .extra2         = &xfs_params.stats_clear.max
 223        },
 224#endif /* CONFIG_PROC_FS */
 225
 226        {}
 227};
 228
 229static struct ctl_table xfs_dir_table[] = {
 230        {
 231                .procname       = "xfs",
 232                .mode           = 0555,
 233                .child          = xfs_table
 234        },
 235        {}
 236};
 237
 238static struct ctl_table xfs_root_table[] = {
 239        {
 240                .procname       = "fs",
 241                .mode           = 0555,
 242                .child          = xfs_dir_table
 243        },
 244        {}
 245};
 246
 247int
 248xfs_sysctl_register(void)
 249{
 250        xfs_table_header = register_sysctl_table(xfs_root_table);
 251        if (!xfs_table_header)
 252                return -ENOMEM;
 253        return 0;
 254}
 255
 256void
 257xfs_sysctl_unregister(void)
 258{
 259        unregister_sysctl_table(xfs_table_header);
 260}
 261