root/branches/Orange-Branch/src/kernel/linux-2.6/pvfs2-proc.c @ 8847

Revision 8847, 22.5 KB (checked in by mtmoore, 2 years ago)

fix kernel panic when kernel uses unnumbered sysctl entries. pass CTL_NONE through to UNNUMBERED_OR_VAL #define so the end of the tables are well defined as 0.

Line 
1/*
2 * (C) 2001 Clemson University and The University of Chicago
3 *
4 * Changes by Acxiom Corporation to add proc file handler for pvfs2 client
5 * parameters, Copyright © Acxiom Corporation, 2005.
6 *
7 * See COPYING in top-level directory.
8 */
9
10#include "pvfs2-kernel.h"
11#include "pvfs2-internal.h"
12
13#include <linux/sysctl.h>
14#include <linux/proc_fs.h>
15#include "pvfs2-proc.h"
16
17#ifndef PVFS2_VERSION
18#define PVFS2_VERSION "Unknown"
19#endif
20
21#ifdef CONFIG_SYSCTL
22#include <linux/sysctl.h>
23
24#define KERNEL_DEBUG "kernel-debug"
25#define CLIENT_DEBUG "client-debug"
26#define DEBUG_HELP "debug-help"
27
28/* these functions are defined in pvfs2-utils.c */
29uint64_t PVFS_proc_debug_eventlog_to_mask(const char *);
30uint64_t PVFS_proc_kmod_eventlog_to_mask(const char *event_logging);
31int PVFS_proc_kmod_mask_to_eventlog(uint64_t mask, char *debug_string);
32int PVFS_proc_mask_to_eventlog(uint64_t mask, char *debug_string);
33
34/* these strings will be initialized by invoking the PVFS_DEV_DEBUG ioctl
35 * command when the client-core is started.  otherwise, these variables are
36 * only set via the proc sys calls.
37*/
38char client_debug_string[PVFS2_MAX_DEBUG_STRING_LEN] = "none";
39char kernel_debug_string[PVFS2_MAX_DEBUG_STRING_LEN] = "none";
40extern char debug_help_string[];
41
42
43/* extra parameters provided to pvfs2 param proc handlers */
44struct pvfs2_param_extra
45{
46    int op;  /* parameter type */
47    int min; /* minimum value */
48    int max; /* maximum value */
49};
50
51/* pvfs2_proc_debug_mask_handler()
52 * proc file handler that will take a debug string and convert it
53 * into the proper debug value and then send a request to update the
54 * debug mask if client or update the local debug mask if kernel.
55*/
56#if defined(HAVE_PROC_HANDLER_FILE_ARG)
57static int pvfs2_proc_debug_mask_handler(
58    ctl_table       *ctl,
59    int             write,
60    struct file     *filp,
61    void            *buffer,
62    size_t          *lenp,
63    loff_t          *ppos)
64#elif defined(HAVE_PROC_HANDLER_PPOS_ARG)
65static int pvfs2_proc_debug_mask_handler(
66    ctl_table       *ctl,
67    int             write,
68    void            *buffer,
69    size_t          *lenp,
70    loff_t          *ppos)
71#else
72static int pvfs2_proc_debug_mask_handler(
73    ctl_table       *ctl,
74    int             write,
75    struct file     *filp,
76    void            *buffer,
77    size_t          *lenp)
78#endif
79{
80  int ret=0;
81  pvfs2_kernel_op_t *new_op = NULL;
82
83  gossip_debug(GOSSIP_PROC_DEBUG,"Executing pvfs2_proc_debug_mask_handler...\n");
84
85  /* use generic proc string handling function to retrieve/set string. */
86#if defined(HAVE_PROC_HANDLER_FILE_ARG)
87        ret = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
88#elif defined(HAVE_PROC_HANDLER_PPOS_ARG)
89        ret = proc_dostring(ctl, write, buffer, lenp, ppos);
90#else
91        ret = proc_dostring(ctl, write, filp, buffer, lenp);
92#endif
93
94  if (ret != 0)
95  {
96     return(ret);
97  }
98
99  gossip_debug(GOSSIP_PROC_DEBUG,"%s: debug string: %s\n"
100                                ,"pvfs2_proc_debug_mask_handler"
101                                ,(char *)ctl->data);
102
103  /*For a user write, ctl->data will now contain the new debug string as given
104   *by the user.  For a user read, the user's "buffer" will now contain the string
105   *stored in ctl->data.
106  */
107
108  /*For a write, we must convert the debug string into the proper debug mask.
109   *The conversion will ignore any invalid keywords sent in by the user, so we
110   *re-convert the debug mask back into the correct debug string.
111  */
112  if (write && !strcmp(ctl->procname,KERNEL_DEBUG))
113  {
114     gossip_debug_mask=PVFS_proc_kmod_eventlog_to_mask((const char *)ctl->data);
115     ret=PVFS_proc_kmod_mask_to_eventlog(gossip_debug_mask,(char *)ctl->data);
116
117     gossip_debug(GOSSIP_PROC_DEBUG,"%s: kernel debug mask: %lu\n"
118                                   ,"pvfs2_proc_debug_mask_handler"
119                                   ,(unsigned long)gossip_debug_mask);
120     gossip_debug(GOSSIP_PROC_DEBUG,"New kernel debug string is %s.\n"
121                                   ,kernel_debug_string);
122     printk("PVFS: kernel debug mask has been modified to \"%s\" (0x%08llx).\n"
123           ,kernel_debug_string, llu(gossip_debug_mask));
124  }
125  else if (write && !strcmp(ctl->procname,CLIENT_DEBUG))
126  {
127     new_op = op_alloc(PVFS2_VFS_OP_PARAM);
128     if (!new_op)
129        return (-ENOMEM);
130     strcpy(new_op->upcall.req.param.s_value,ctl->data);
131     new_op->upcall.req.param.type = PVFS2_PARAM_REQUEST_SET;
132     new_op->upcall.req.param.op = PVFS2_PARAM_REQUEST_OP_CLIENT_DEBUG;
133
134     ret=service_operation(new_op,"pvfs2_param",PVFS2_OP_INTERRUPTIBLE);
135     
136     if (ret==0)
137     {
138        gossip_debug(GOSSIP_PROC_DEBUG,"Downcall:\treturn status:%d\treturn "
139                                       "value:%x\n"
140                                      ,(int)new_op->downcall.status
141                                      ,(int)new_op->downcall.resp.param.value);
142
143        ret=PVFS_proc_mask_to_eventlog(new_op->downcall.resp.param.value
144                                      ,client_debug_string);
145        gossip_debug(GOSSIP_PROC_DEBUG,"New client debug string is %s\n"
146                                      ,client_debug_string);
147     }
148     op_release(new_op);
149     printk("PVFS: client debug mask has been modified to \"%s\" (0x%08llx).\n"
150           ,client_debug_string, llu(new_op->downcall.resp.param.value));
151  }
152  else if (write && !strcmp(ctl->procname,DEBUG_HELP))
153  {
154    /*do nothing...the user can only READ the debug help*/
155    return (0);
156  }
157
158  return (0);
159}/*end pvfs2_proc_debug_mask_handler*/
160
161/* pvfs2_param_proc_handler()
162 *
163 * generic proc file handler for getting and setting various tunable
164 * pvfs2-client parameters
165 */
166#if defined(HAVE_PROC_HANDLER_FILE_ARG)
167static int pvfs2_param_proc_handler(
168    ctl_table       *ctl,
169    int             write,
170    struct file     *filp,
171    void            *buffer,
172    size_t          *lenp,
173    loff_t          *ppos)
174#elif defined(HAVE_PROC_HANDLER_PPOS_ARG)
175static int pvfs2_param_proc_handler(
176    ctl_table       *ctl,
177    int             write,
178    void            *buffer,
179    size_t          *lenp,
180    loff_t          *ppos)
181#else
182static int pvfs2_param_proc_handler(
183    ctl_table       *ctl,
184    int             write,
185    struct file     *filp,
186    void            *buffer,
187    size_t          *lenp)
188#endif
189{       
190    pvfs2_kernel_op_t *new_op = NULL;
191    struct pvfs2_param_extra* extra = ctl->extra1;
192    int val = 0;
193    int ret = 0;
194    ctl_table tmp_ctl = *ctl;
195
196    /* override fields in control structure for call to generic proc handler */
197    tmp_ctl.data = &val;
198    tmp_ctl.extra1 = &extra->min;
199    tmp_ctl.extra2 = &extra->max;
200
201    /* build an op structure to send request to pvfs2-client */
202    new_op = op_alloc(PVFS2_VFS_OP_PARAM);
203    if (!new_op)
204    {
205        return -ENOMEM;
206    }
207
208    if(write)
209    {
210        /* use generic proc handling function to retrive value to set */
211#if defined(HAVE_PROC_HANDLER_FILE_ARG)
212        ret = proc_dointvec_minmax(&tmp_ctl, write, filp, buffer, lenp, ppos);
213#elif defined(HAVE_PROC_HANDLER_PPOS_ARG)
214        ret = proc_dointvec_minmax(&tmp_ctl, write, buffer, lenp, ppos);
215#else
216        ret = proc_dointvec_minmax(&tmp_ctl, write, filp, buffer, lenp);
217#endif
218        if(ret != 0)
219        {
220            op_release(new_op);
221            return(ret);
222        }
223        gossip_debug(GOSSIP_PROC_DEBUG, "pvfs2: proc write %d\n", val);
224        new_op->upcall.req.param.value = val;
225        new_op->upcall.req.param.type = PVFS2_PARAM_REQUEST_SET;
226    }
227    else
228    {
229        /* get parameter from client, we will output afterwards */
230        new_op->upcall.req.param.type = PVFS2_PARAM_REQUEST_GET;
231    }
232
233    new_op->upcall.req.param.op = extra->op;
234
235    /* perform operation (get or set) */
236    ret = service_operation(new_op, "pvfs2_param", 
237        PVFS2_OP_INTERRUPTIBLE);
238   
239    if(ret == 0 && !write)
240    {
241        /* use generic proc handling function to output value */
242        val = (int)new_op->downcall.resp.param.value;
243        gossip_debug(GOSSIP_PROC_DEBUG, "pvfs2: proc read %d\n", val);
244#if defined(HAVE_PROC_HANDLER_FILE_ARG)
245        ret = proc_dointvec_minmax(&tmp_ctl, write, filp, buffer, lenp, ppos);
246#elif defined(HAVE_PROC_HANDLER_PPOS_ARG)
247        ret = proc_dointvec_minmax(&tmp_ctl, write, buffer, lenp, ppos);
248#else
249        ret = proc_dointvec_minmax(&tmp_ctl, write, filp, buffer, lenp);
250#endif
251    }
252
253    op_release(new_op);
254    return(ret);
255}
256
257#if defined(HAVE_PROC_HANDLER_FILE_ARG)
258static int pvfs2_pc_proc_handler(
259    ctl_table       *ctl,
260    int             write,
261    struct file     *filp,
262    void            *buffer,
263    size_t          *lenp,
264    loff_t          *ppos)
265#elif defined(HAVE_PROC_HANDLER_PPOS_ARG)
266static int pvfs2_pc_proc_handler(
267    ctl_table       *ctl,
268    int             write,
269    void            *buffer,
270    size_t          *lenp,
271    loff_t          *ppos)
272#else
273static int pvfs2_pc_proc_handler(
274    ctl_table       *ctl,
275    int             write,
276    struct file     *filp,
277    void            *buffer,
278    size_t          *lenp)
279#endif
280{
281    pvfs2_kernel_op_t *new_op = NULL;
282    int ret;
283    int pos = 0;
284    int to_copy = 0;
285    int* pc_type = ctl->extra1;
286#if defined(HAVE_PROC_HANDLER_PPOS_ARG) || defined(HAVE_PROC_HANDLER_FILE_ARG)
287    loff_t *offset = ppos;
288#else
289    loff_t *offset = &filp->f_pos;
290#endif
291
292    if(write)
293    {
294        /* don't allow writes to this file */
295        *lenp = 0;
296        return(-EPERM);
297    }
298
299    /* build an op structure to send request to pvfs2-client */
300    new_op = op_alloc(PVFS2_VFS_OP_PERF_COUNT);
301    if (!new_op)
302    {
303        return -ENOMEM;
304    }
305    new_op->upcall.req.perf_count.type = *pc_type;
306
307    /* retrieve performance counters */
308    ret = service_operation(new_op, "pvfs2_perf_count",
309         PVFS2_OP_INTERRUPTIBLE);
310
311    if(ret == 0)
312    {
313        /* figure out how many bytes we will copy out */
314        pos = strlen(new_op->downcall.resp.perf_count.buffer);
315        to_copy = pos - *offset;
316        if(to_copy < 0)
317        {
318            to_copy = 0;
319        }
320        if(to_copy > *lenp)
321        {
322            to_copy = *lenp;
323        }
324
325        if(to_copy)
326        {
327            /* copy correct portion of the string buffer */
328            if(copy_to_user(buffer,
329                (new_op->downcall.resp.perf_count.buffer+(*offset)), to_copy))
330            {
331                ret = -EFAULT;
332            }
333            else
334            {
335                /* update offsets etc. if successful */
336                *lenp = to_copy;
337                *offset += to_copy;
338                ret = to_copy;
339            }
340        }
341        else
342        {
343            *lenp = 0;
344            ret = 0;
345        }
346    }
347
348    op_release(new_op);
349
350    return(ret);
351}
352
353static struct ctl_table_header *fs_table_header = NULL;
354
355static struct pvfs2_param_extra acache_timeout_extra = {
356    .op = PVFS2_PARAM_REQUEST_OP_ACACHE_TIMEOUT_MSECS,
357    .min = 0,
358    .max = INT_MAX,
359};
360static struct pvfs2_param_extra acache_hard_extra = {
361    .op = PVFS2_PARAM_REQUEST_OP_ACACHE_HARD_LIMIT,
362    .min = 0,
363    .max = INT_MAX,
364};
365static struct pvfs2_param_extra acache_soft_extra = {
366    .op = PVFS2_PARAM_REQUEST_OP_ACACHE_SOFT_LIMIT,
367    .min = 0,
368    .max = INT_MAX,
369};
370static struct pvfs2_param_extra acache_rec_extra = {
371    .op = PVFS2_PARAM_REQUEST_OP_ACACHE_RECLAIM_PERCENTAGE,
372    .min = 0,
373    .max = 100,
374};
375static struct pvfs2_param_extra static_acache_timeout_extra = {
376    .op = PVFS2_PARAM_REQUEST_OP_STATIC_ACACHE_TIMEOUT_MSECS,
377    .min = 0,
378    .max = INT_MAX,
379};
380static struct pvfs2_param_extra static_acache_hard_extra = {
381    .op = PVFS2_PARAM_REQUEST_OP_STATIC_ACACHE_HARD_LIMIT,
382    .min = 0,
383    .max = INT_MAX,
384};
385static struct pvfs2_param_extra static_acache_soft_extra = {
386    .op = PVFS2_PARAM_REQUEST_OP_STATIC_ACACHE_SOFT_LIMIT,
387    .min = 0,
388    .max = INT_MAX,
389};
390static struct pvfs2_param_extra static_acache_rec_extra = {
391    .op = PVFS2_PARAM_REQUEST_OP_STATIC_ACACHE_RECLAIM_PERCENTAGE,
392    .min = 0,
393    .max = 100,
394};
395static struct pvfs2_param_extra ncache_timeout_extra = {
396    .op = PVFS2_PARAM_REQUEST_OP_NCACHE_TIMEOUT_MSECS,
397    .min = 0,
398    .max = INT_MAX,
399};
400static struct pvfs2_param_extra ncache_hard_extra = {
401    .op = PVFS2_PARAM_REQUEST_OP_NCACHE_HARD_LIMIT,
402    .min = 0,
403    .max = INT_MAX,
404};
405static struct pvfs2_param_extra ncache_soft_extra = {
406    .op = PVFS2_PARAM_REQUEST_OP_NCACHE_SOFT_LIMIT,
407    .min = 0,
408    .max = INT_MAX,
409};
410static struct pvfs2_param_extra ncache_rec_extra = {
411    .op = PVFS2_PARAM_REQUEST_OP_NCACHE_RECLAIM_PERCENTAGE,
412    .min = 0,
413    .max = 100,
414};
415static struct pvfs2_param_extra perf_time_interval_extra = {
416    .op = PVFS2_PARAM_REQUEST_OP_PERF_TIME_INTERVAL_SECS,
417    .min = 0,
418    .max = INT_MAX,
419};
420static struct pvfs2_param_extra perf_history_size_extra = {
421    .op = PVFS2_PARAM_REQUEST_OP_PERF_HISTORY_SIZE,
422    .min = 1,
423    .max = INT_MAX,
424};
425static struct pvfs2_param_extra perf_reset_extra = {
426    .op = PVFS2_PARAM_REQUEST_OP_PERF_RESET,
427    .min = 0,
428    .max = 1,
429};
430
431static int min_op_timeout_secs[] = {0}, max_op_timeout_secs[] = {INT_MAX};
432static int min_slot_timeout_secs[] = {0}, max_slot_timeout_secs[] = {INT_MAX};
433
434/*
435 * Modern kernels (up to 2.6.33) prefer to number the controls themselves.
436 */
437#ifdef CTL_UNNUMBERED
438#define UNNUMBERED_OR_VAL(x) ((x==CTL_NONE) ? CTL_NONE : CTL_UNNUMBERED)
439#else
440#define UNNUMBERED_OR_VAL(x) x
441#endif
442
443/*
444 * API change in 2.6.33 removes .ctl_name and .strategy from ctl_table
445 */
446#ifdef HAVE_CTL_NAME
447#define CTL_NAME(c_name)        .ctl_name = UNNUMBERED_OR_VAL(c_name),
448#else
449#define CTL_NAME(c_name)
450#endif /* HAVE_CTL_NAME */
451
452#ifdef HAVE_CTL_STRATEGY
453#define CTL_STATEGY(c_strategy) .strategy = (c_strategy),
454#else
455#define CTL_STRATEGY(strat)     
456#endif /* HAVE_CTL_STRATEGY */
457
458static ctl_table pvfs2_acache_table[] = {
459    /* controls acache timeout */
460    {
461        CTL_NAME(1)
462        .procname = "timeout-msecs",
463        .maxlen = sizeof(int),
464        .mode = 0644,
465        .proc_handler = &pvfs2_param_proc_handler,
466        .extra1 = &acache_timeout_extra
467    },
468    /* controls acache hard limit */
469    {
470        CTL_NAME(2)
471        .procname = "hard-limit",
472        .maxlen = sizeof(int),
473        .mode = 0644,
474        .proc_handler = &pvfs2_param_proc_handler,
475        .extra1 = &acache_hard_extra
476    },
477    /* controls acache soft limit */
478    {
479        CTL_NAME(3)
480        .procname = "soft-limit",
481        .maxlen = sizeof(int),
482        .mode = 0644,
483        .proc_handler = &pvfs2_param_proc_handler,
484        .extra1 = &acache_soft_extra
485    },
486    /* controls acache reclaim percentage */
487    {
488        CTL_NAME(4)
489        .procname = "reclaim-percentage",
490        .maxlen = sizeof(int),
491        .mode = 0644,
492        .proc_handler = &pvfs2_param_proc_handler,
493        .extra1 = &acache_rec_extra,
494    },
495    { CTL_NAME(CTL_NONE) }
496};
497static ctl_table pvfs2_static_acache_table[] = {
498    /* controls static acache timeout */
499    {
500        CTL_NAME(1)
501        .procname = "timeout-msecs",
502        .maxlen = sizeof(int),
503        .mode = 0644,
504        .proc_handler = &pvfs2_param_proc_handler,
505        .extra1 = &static_acache_timeout_extra
506    },
507    /* controls static acache hard limit */
508    {
509        CTL_NAME(2)
510        .procname = "hard-limit",
511        .maxlen = sizeof(int),
512        .mode = 0644,
513        .proc_handler = &pvfs2_param_proc_handler,
514        .extra1 = &static_acache_hard_extra
515    },
516    /* controls static acache soft limit */
517    {
518        CTL_NAME(3)
519        .procname = "soft-limit",
520        .maxlen = sizeof(int),
521        .mode = 0644,
522        .proc_handler = &pvfs2_param_proc_handler,
523        .extra1 = &static_acache_soft_extra
524    },
525    /* controls static acache reclaim percentage */
526    {
527        CTL_NAME(4)
528        .procname = "reclaim-percentage",
529        .maxlen = sizeof(int),
530        .mode = 0644,
531        .proc_handler = &pvfs2_param_proc_handler,
532        .extra1 = &static_acache_rec_extra,
533    },
534    { CTL_NAME(CTL_NONE) }
535};
536
537static ctl_table pvfs2_ncache_table[] = {
538    /* controls ncache timeout */
539    {
540        CTL_NAME(1)
541        .procname = "timeout-msecs",
542        .maxlen = sizeof(int),
543        .mode = 0644,
544        .proc_handler = &pvfs2_param_proc_handler,
545        .extra1 = &ncache_timeout_extra
546    },
547    /* controls ncache hard limit */
548    {
549        CTL_NAME(2)
550        .procname = "hard-limit",
551        .maxlen = sizeof(int),
552        .mode = 0644,
553        .proc_handler = &pvfs2_param_proc_handler,
554        .extra1 = &ncache_hard_extra
555    },
556    /* controls ncache soft limit */
557    {
558        CTL_NAME(3)
559        .procname = "soft-limit",
560        .maxlen = sizeof(int),
561        .mode = 0644,
562        .proc_handler = &pvfs2_param_proc_handler,
563        .extra1 = &ncache_soft_extra
564    },
565    /* controls ncache reclaim percentage */
566    {
567        CTL_NAME(4)
568        .procname = "reclaim-percentage",
569        .maxlen = sizeof(int),
570        .mode = 0644,
571        .proc_handler = &pvfs2_param_proc_handler,
572        .extra1 = &ncache_rec_extra
573    },
574    { CTL_NAME(CTL_NONE) }
575};
576static int acache_perf_count = PVFS2_PERF_COUNT_REQUEST_ACACHE;
577static int static_acache_perf_count = PVFS2_PERF_COUNT_REQUEST_STATIC_ACACHE;
578static int ncache_perf_count = PVFS2_PERF_COUNT_REQUEST_NCACHE;
579static ctl_table pvfs2_pc_table[] = {
580    {
581        CTL_NAME(1)
582        .procname = "acache",
583        .maxlen = 4096,
584        .mode = 0444,
585        .proc_handler = pvfs2_pc_proc_handler,
586        .extra1 = &acache_perf_count,
587    },
588    {
589        CTL_NAME(1)
590        .procname = "static-acache",
591        .maxlen = 4096,
592        .mode = 0444,
593        .proc_handler = pvfs2_pc_proc_handler,
594        .extra1 = &static_acache_perf_count,
595    },
596    {
597        CTL_NAME(2)
598        .procname = "ncache",
599        .maxlen = 4096,
600        .mode = 0444,
601        .proc_handler = pvfs2_pc_proc_handler,
602        .extra1 = &ncache_perf_count
603    },
604    { CTL_NAME(CTL_NONE) }
605};
606
607pvfs2_stats g_pvfs2_stats;
608
609static ctl_table pvfs2_stats_table[] = {
610    /* shows number of hits in cache */
611    {
612        CTL_NAME(1)
613        .procname = "hits",
614        .data     = &g_pvfs2_stats.cache_hits,
615        .maxlen   = sizeof(unsigned long),
616        .mode     = 0444,
617        .proc_handler = &proc_dointvec,
618    },
619    {
620        CTL_NAME(2)
621        .procname = "misses",
622        .data     = &g_pvfs2_stats.cache_misses,
623        .maxlen   = sizeof(unsigned long),
624        .mode     = 0444,
625        .proc_handler = &proc_dointvec,
626    },
627    {
628        .procname = "reads",
629        .data     = &g_pvfs2_stats.reads,
630        .maxlen   = sizeof(unsigned long),
631        .mode     = 0444,
632        .proc_handler = &proc_dointvec,
633    },
634    {
635        CTL_NAME(4)
636        .procname = "writes",
637        .data     = &g_pvfs2_stats.writes,
638        .maxlen   = sizeof(unsigned long),
639        .mode     = 0444,
640        .proc_handler = &proc_dointvec,
641    },
642    { CTL_NAME(CTL_NONE) }
643};
644
645
646
647static ctl_table pvfs2_table[] = {
648    /* outputs the available debugging keywords */
649    {
650        CTL_NAME(14)
651        .procname = DEBUG_HELP,
652        .data = &debug_help_string,
653        .maxlen = PVFS2_MAX_DEBUG_STRING_LEN,
654        .mode = 0444,
655        .proc_handler = &pvfs2_proc_debug_mask_handler
656    },
657    /* controls client-core debugging level */
658    {
659        CTL_NAME(1)
660        .procname = CLIENT_DEBUG,
661        .data = &client_debug_string,
662        .maxlen = PVFS2_MAX_DEBUG_STRING_LEN, 
663        .mode = 0644,
664        .proc_handler = &pvfs2_proc_debug_mask_handler
665    },
666    /* controls kernel debugging level using string input */
667    {
668        CTL_NAME(2)
669       .procname = KERNEL_DEBUG,
670       .data = &kernel_debug_string,
671       .maxlen = PVFS2_MAX_DEBUG_STRING_LEN,
672       .mode = 0644,
673       .proc_handler = &pvfs2_proc_debug_mask_handler
674    },
675    /* operation timeout */
676    {
677        CTL_NAME(3)
678        .procname = "op-timeout-secs",
679        .data = &op_timeout_secs,
680        .maxlen = sizeof(int),
681        .mode = 0644,
682        .proc_handler = &proc_dointvec_minmax,
683        CTL_STRATEGY(&sysctl_intvec)
684        .extra1 = &min_op_timeout_secs,
685        .extra2 = &max_op_timeout_secs
686    },
687    /* slot timeout */
688    {
689        CTL_NAME(4)
690        .procname = "slot-timeout-secs",
691        .data = &slot_timeout_secs,
692        .maxlen = sizeof(int),
693        .mode = 0644,
694        .proc_handler = &proc_dointvec_minmax,
695        CTL_STRATEGY(&sysctl_intvec)
696        .extra1 = &min_slot_timeout_secs,
697        .extra2 = &max_slot_timeout_secs
698    },
699    /* time interval for client side performance counters */
700    {
701        CTL_NAME(5)
702        .procname = "perf-time-interval-secs",
703        .maxlen = sizeof(int),
704        .mode = 0644,
705        .proc_handler = &pvfs2_param_proc_handler,
706        .extra1 = &perf_time_interval_extra
707    },
708    /* time interval for client side performance counters */
709    {
710        CTL_NAME(6)
711        .procname = "perf-history-size",
712        .maxlen = sizeof(int),
713        .mode = 0644,
714        .proc_handler = &pvfs2_param_proc_handler,
715        .extra1 = &perf_history_size_extra
716    },
717    /* reset performance counters */
718    {
719        CTL_NAME(7)
720        .procname = "perf-counter-reset",
721        .maxlen = sizeof(int),
722        .mode = 0644,
723        .proc_handler = &pvfs2_param_proc_handler,
724        .extra1 = &perf_reset_extra,
725    },
726    /* subdir for acache control */
727    {
728        CTL_NAME(8)
729        .procname = "acache",
730        .maxlen = 0,
731        .mode = 0555,
732        .child = pvfs2_acache_table
733    },
734    /* subdir for static acache control */
735    {
736        CTL_NAME(9)
737        .procname = "static-acache",
738        .maxlen = 0,
739        .mode = 0555,
740        .child = pvfs2_static_acache_table
741    },
742    {
743        CTL_NAME(10)
744        .procname = "perf-counters",
745        .maxlen = 0,
746        .mode = 0555,
747        .child = pvfs2_pc_table
748    },
749    /* subdir for ncache control */
750    {
751        CTL_NAME(11)
752        .procname = "ncache",
753        .maxlen = 0,
754        .mode = 0555,
755        .child = pvfs2_ncache_table
756    },
757    /* statistics maintained by the kernel module (output only below this) */
758    {
759        CTL_NAME(12)
760        .procname = "stats",
761        .maxlen = 0,
762        .mode = 0555,
763        .child = pvfs2_stats_table
764    },
765    { CTL_NAME(CTL_NONE) }
766};
767static ctl_table fs_table[] = {
768    {
769        CTL_NAME(13)
770        .procname = "pvfs2",
771        .mode = 0555,
772        .child = pvfs2_table
773    },
774    { CTL_NAME(CTL_NONE) }
775};
776#endif
777
778void pvfs2_proc_initialize(void)
779{
780#ifdef CONFIG_SYSCTL
781    if (!fs_table_header)
782    {
783#ifdef HAVE_TWO_ARG_REGISTER_SYSCTL_TABLE
784        fs_table_header = register_sysctl_table(fs_table, 0);
785#else
786        fs_table_header = register_sysctl_table(fs_table);
787#endif
788    }
789#endif
790
791    return;
792}
793
794void pvfs2_proc_finalize(void)
795{
796#ifdef CONFIG_SYSCTL
797    if(fs_table_header)
798    {
799        unregister_sysctl_table(fs_table_header);
800        fs_table_header = NULL;
801    }
802#endif
803    return;
804}
805
806/*
807 * Local variables:
808 *  c-indent-level: 4
809 *  c-basic-offset: 4
810 * End:
811 *
812 * vim: ts=8 sts=4 sw=4 expandtab
813 */
Note: See TracBrowser for help on using the browser.