Whamcloud - gitweb
98e386887523f486e2b2f8beca9e75910d10c2ee
[fs/lustre-release.git] / lustre / include / lprocfs_status.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2013, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/include/lprocfs_status.h
37  *
38  * Top level header file for LProc SNMP
39  *
40  * Author: Hariharan Thantry thantry@users.sourceforge.net
41  */
42 #ifndef _LPROCFS_SNMP_H
43 #define _LPROCFS_SNMP_H
44
45 #include <lustre/lustre_idl.h>
46 #include <libcfs/params_tree.h>
47
48 #ifndef HAVE_ONLY_PROCFS_SEQ
49 struct lprocfs_vars {
50         const char                      *name;
51         read_proc_t                     *read_fptr;
52         write_proc_t                    *write_fptr;
53         void                            *data;
54         const struct file_operations    *fops;
55         /**
56          * /proc file mode.
57          */
58         mode_t                          proc_mode;
59 };
60
61 struct lprocfs_static_vars {
62         struct lprocfs_vars *module_vars;
63         struct lprocfs_vars *obd_vars;
64 };
65
66 #endif
67
68 struct lprocfs_seq_vars {
69         const char                      *name;
70         const struct file_operations    *fops;
71         void                            *data;
72         /**
73          * /proc file mode.
74          */
75         mode_t                           proc_mode;
76 };
77
78 /* if we find more consumers this could be generalized */
79 #define OBD_HIST_MAX 32
80 struct obd_histogram {
81         spinlock_t      oh_lock;
82         unsigned long   oh_buckets[OBD_HIST_MAX];
83 };
84
85 enum {
86         BRW_R_PAGES = 0,
87         BRW_W_PAGES,
88         BRW_R_RPC_HIST,
89         BRW_W_RPC_HIST,
90         BRW_R_IO_TIME,
91         BRW_W_IO_TIME,
92         BRW_R_DISCONT_PAGES,
93         BRW_W_DISCONT_PAGES,
94         BRW_R_DISCONT_BLOCKS,
95         BRW_W_DISCONT_BLOCKS,
96         BRW_R_DISK_IOSIZE,
97         BRW_W_DISK_IOSIZE,
98         BRW_R_DIO_FRAGS,
99         BRW_W_DIO_FRAGS,
100         BRW_LAST,
101 };
102
103 struct brw_stats {
104         struct obd_histogram hist[BRW_LAST];
105 };
106
107 enum {
108         RENAME_SAMEDIR_SIZE = 0,
109         RENAME_CROSSDIR_SRC_SIZE,
110         RENAME_CROSSDIR_TGT_SIZE,
111         RENAME_LAST,
112 };
113
114 struct rename_stats {
115         struct obd_histogram hist[RENAME_LAST];
116 };
117
118 /* An lprocfs counter can be configured using the enum bit masks below.
119  *
120  * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
121  * protects this counter from concurrent updates. If not specified,
122  * lprocfs an internal per-counter lock variable. External locks are
123  * not used to protect counter increments, but are used to protect
124  * counter readout and resets.
125  *
126  * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
127  * (i.e. counter can be incremented by more than "1"). When specified,
128  * the counter maintains min, max and sum in addition to a simple
129  * invocation count. This allows averages to be be computed.
130  * If not specified, the counter is an increment-by-1 counter.
131  * min, max, sum, etc. are not maintained.
132  *
133  * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
134  * squares (for multi-valued counter samples only). This allows
135  * external computation of standard deviation, but involves a 64-bit
136  * multiply per counter increment.
137  */
138
139 enum {
140         LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
141         LPROCFS_CNTR_AVGMINMAX    = 0x0002,
142         LPROCFS_CNTR_STDDEV       = 0x0004,
143
144         /* counter data type */
145         LPROCFS_TYPE_REGS         = 0x0100,
146         LPROCFS_TYPE_BYTES        = 0x0200,
147         LPROCFS_TYPE_PAGES        = 0x0400,
148         LPROCFS_TYPE_CYCLE        = 0x0800,
149 };
150
151 #define LC_MIN_INIT ((~(__u64)0) >> 1)
152
153 struct lprocfs_counter_header {
154         unsigned int            lc_config;
155         const char              *lc_name;   /* must be static */
156         const char              *lc_units;  /* must be static */
157 };
158
159 struct lprocfs_counter {
160         __s64   lc_count;
161         __s64   lc_min;
162         __s64   lc_max;
163         __s64   lc_sumsquare;
164         /*
165          * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
166          * for irq context counter, i.e. stats with
167          * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
168          * lc_array_sum[1]
169          */
170         __s64   lc_array_sum[1];
171 };
172 #define lc_sum          lc_array_sum[0]
173 #define lc_sum_irq      lc_array_sum[1]
174
175 struct lprocfs_percpu {
176         struct lprocfs_counter lp_cntr[0];
177 };
178
179 #define LPROCFS_GET_NUM_CPU 0x0001
180 #define LPROCFS_GET_SMP_ID  0x0002
181
182 enum lprocfs_stats_flags {
183         LPROCFS_STATS_FLAG_NONE     = 0x0000, /* per cpu counter */
184         LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
185                                                * area and need locking */
186         LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
187 };
188
189 enum lprocfs_fields_flags {
190         LPROCFS_FIELDS_FLAGS_CONFIG     = 0x0001,
191         LPROCFS_FIELDS_FLAGS_SUM        = 0x0002,
192         LPROCFS_FIELDS_FLAGS_MIN        = 0x0003,
193         LPROCFS_FIELDS_FLAGS_MAX        = 0x0004,
194         LPROCFS_FIELDS_FLAGS_AVG        = 0x0005,
195         LPROCFS_FIELDS_FLAGS_SUMSQUARE  = 0x0006,
196         LPROCFS_FIELDS_FLAGS_COUNT      = 0x0007,
197 };
198
199 struct lprocfs_stats {
200         /* # of counters */
201         unsigned short                  ls_num;
202         /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
203         unsigned short                  ls_biggest_alloc_num;
204         enum lprocfs_stats_flags        ls_flags;
205         /* Lock used when there are no percpu stats areas; For percpu stats,
206          * it is used to protect ls_biggest_alloc_num change */
207         spinlock_t                      ls_lock;
208
209         /* has ls_num of counter headers */
210         struct lprocfs_counter_header   *ls_cnt_header;
211         struct lprocfs_percpu           *ls_percpu[0];
212 };
213
214 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
215
216 /* Pack all opcodes down into a single monotonically increasing index */
217 static inline int opcode_offset(__u32 opc) {
218         if (opc < OST_LAST_OPC) {
219                  /* OST opcode */
220                 return (opc - OST_FIRST_OPC);
221         } else if (opc < MDS_LAST_OPC) {
222                 /* MDS opcode */
223                 return (opc - MDS_FIRST_OPC +
224                         OPC_RANGE(OST));
225         } else if (opc < LDLM_LAST_OPC) {
226                 /* LDLM Opcode */
227                 return (opc - LDLM_FIRST_OPC +
228                         OPC_RANGE(MDS) +
229                         OPC_RANGE(OST));
230         } else if (opc < MGS_LAST_OPC) {
231                 /* MGS Opcode */
232                 return (opc - MGS_FIRST_OPC +
233                         OPC_RANGE(LDLM) +
234                         OPC_RANGE(MDS) +
235                         OPC_RANGE(OST));
236         } else if (opc < OBD_LAST_OPC) {
237                 /* OBD Ping */
238                 return (opc - OBD_FIRST_OPC +
239                         OPC_RANGE(MGS) +
240                         OPC_RANGE(LDLM) +
241                         OPC_RANGE(MDS) +
242                         OPC_RANGE(OST));
243         } else if (opc < LLOG_LAST_OPC) {
244                 /* LLOG Opcode */
245                 return (opc - LLOG_FIRST_OPC +
246                         OPC_RANGE(OBD) +
247                         OPC_RANGE(MGS) +
248                         OPC_RANGE(LDLM) +
249                         OPC_RANGE(MDS) +
250                         OPC_RANGE(OST));
251         } else if (opc < QUOTA_LAST_OPC) {
252                 /* LQUOTA Opcode */
253                 return (opc - QUOTA_FIRST_OPC +
254                         OPC_RANGE(LLOG) +
255                         OPC_RANGE(OBD) +
256                         OPC_RANGE(MGS) +
257                         OPC_RANGE(LDLM) +
258                         OPC_RANGE(MDS) +
259                         OPC_RANGE(OST));
260         } else if (opc < SEQ_LAST_OPC) {
261                 /* SEQ opcode */
262                 return (opc - SEQ_FIRST_OPC +
263                         OPC_RANGE(QUOTA) +
264                         OPC_RANGE(LLOG) +
265                         OPC_RANGE(OBD) +
266                         OPC_RANGE(MGS) +
267                         OPC_RANGE(LDLM) +
268                         OPC_RANGE(MDS) +
269                         OPC_RANGE(OST));
270         } else if (opc < SEC_LAST_OPC) {
271                 /* SEC opcode */
272                 return (opc - SEC_FIRST_OPC +
273                         OPC_RANGE(SEQ) +
274                         OPC_RANGE(QUOTA) +
275                         OPC_RANGE(LLOG) +
276                         OPC_RANGE(OBD) +
277                         OPC_RANGE(MGS) +
278                         OPC_RANGE(LDLM) +
279                         OPC_RANGE(MDS) +
280                         OPC_RANGE(OST));
281         } else if (opc < FLD_LAST_OPC) {
282                 /* FLD opcode */
283                  return (opc - FLD_FIRST_OPC +
284                         OPC_RANGE(SEC) +
285                         OPC_RANGE(SEQ) +
286                         OPC_RANGE(QUOTA) +
287                         OPC_RANGE(LLOG) +
288                         OPC_RANGE(OBD) +
289                         OPC_RANGE(MGS) +
290                         OPC_RANGE(LDLM) +
291                         OPC_RANGE(MDS) +
292                         OPC_RANGE(OST));
293         } else if (opc < OUT_UPDATE_LAST_OPC) {
294                 /* update opcode */
295                 return (opc - OUT_UPDATE_FIRST_OPC +
296                         OPC_RANGE(FLD) +
297                         OPC_RANGE(SEC) +
298                         OPC_RANGE(SEQ) +
299                         OPC_RANGE(QUOTA) +
300                         OPC_RANGE(LLOG) +
301                         OPC_RANGE(OBD) +
302                         OPC_RANGE(MGS) +
303                         OPC_RANGE(LDLM) +
304                         OPC_RANGE(MDS) +
305                         OPC_RANGE(OST));
306         } else if (opc < LFSCK_LAST_OPC) {
307                 /* LFSCK opcode */
308                 return (opc - LFSCK_FIRST_OPC +
309                         OPC_RANGE(OUT_UPDATE) +
310                         OPC_RANGE(FLD) +
311                         OPC_RANGE(SEC) +
312                         OPC_RANGE(SEQ) +
313                         OPC_RANGE(QUOTA) +
314                         OPC_RANGE(LLOG) +
315                         OPC_RANGE(OBD) +
316                         OPC_RANGE(MGS) +
317                         OPC_RANGE(LDLM) +
318                         OPC_RANGE(MDS) +
319                         OPC_RANGE(OST));
320         } else {
321                 /* Unknown Opcode */
322                 return -1;
323         }
324 }
325
326
327 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST)  + \
328                             OPC_RANGE(MDS)  + \
329                             OPC_RANGE(LDLM) + \
330                             OPC_RANGE(MGS)  + \
331                             OPC_RANGE(OBD)  + \
332                             OPC_RANGE(LLOG) + \
333                             OPC_RANGE(SEC)  + \
334                             OPC_RANGE(SEQ)  + \
335                             OPC_RANGE(SEC)  + \
336                             OPC_RANGE(FLD)  + \
337                             OPC_RANGE(OUT_UPDATE) + \
338                             OPC_RANGE(LFSCK))
339
340 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR)  + \
341                             OPC_RANGE(EXTRA))
342
343 enum {
344         PTLRPC_REQWAIT_CNTR = 0,
345         PTLRPC_REQQDEPTH_CNTR,
346         PTLRPC_REQACTIVE_CNTR,
347         PTLRPC_TIMEOUT,
348         PTLRPC_REQBUF_AVAIL_CNTR,
349         PTLRPC_LAST_CNTR
350 };
351
352 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
353
354 enum {
355         LDLM_GLIMPSE_ENQUEUE = 0,
356         LDLM_PLAIN_ENQUEUE,
357         LDLM_EXTENT_ENQUEUE,
358         LDLM_FLOCK_ENQUEUE,
359         LDLM_IBITS_ENQUEUE,
360         MDS_REINT_SETATTR,
361         MDS_REINT_CREATE,
362         MDS_REINT_LINK,
363         MDS_REINT_UNLINK,
364         MDS_REINT_RENAME,
365         MDS_REINT_OPEN,
366         MDS_REINT_SETXATTR,
367         BRW_READ_BYTES,
368         BRW_WRITE_BYTES,
369         EXTRA_LAST_OPC
370 };
371
372 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
373 /* class_obd.c */
374 extern cfs_proc_dir_entry_t *proc_lustre_root;
375
376 struct obd_device;
377 struct obd_histogram;
378
379 /* Days / hours / mins / seconds format */
380 struct dhms {
381         int d,h,m,s;
382 };
383 static inline void s2dhms(struct dhms *ts, time_t secs)
384 {
385         ts->d = secs / 86400;
386         secs = secs % 86400;
387         ts->h = secs / 3600;
388         secs = secs % 3600;
389         ts->m = secs / 60;
390         ts->s = secs % 60;
391 }
392 #define DHMS_FMT "%dd%dh%02dm%02ds"
393 #define DHMS_VARS(x) (x)->d, (x)->h, (x)->m, (x)->s
394
395 #define JOBSTATS_JOBID_VAR_MAX_LEN      20
396 #define JOBSTATS_DISABLE                "disable"
397 #define JOBSTATS_PROCNAME_UID           "procname_uid"
398
399 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
400
401 struct obd_job_stats {
402         cfs_hash_t             *ojs_hash;
403         struct list_head        ojs_list;
404         rwlock_t                ojs_lock; /* protect the obj_list */
405         cntr_init_callback      ojs_cntr_init_fn;
406         int                     ojs_cntr_num;
407         int                     ojs_cleanup_interval;
408         time_t                  ojs_last_cleanup;
409 };
410
411 #ifdef LPROCFS
412
413 extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
414                                    unsigned int cpuid);
415 /*
416  * \return value
417  *      < 0     : on error (only possible for opc as LPROCFS_GET_SMP_ID)
418  */
419 static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc,
420                                      unsigned long *flags)
421 {
422         int             rc = 0;
423
424         switch (opc) {
425         default:
426                 LBUG();
427
428         case LPROCFS_GET_SMP_ID:
429                 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
430                         if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
431                                 spin_lock_irqsave(&stats->ls_lock, *flags);
432                         else
433                                 spin_lock(&stats->ls_lock);
434                         return 0;
435                 } else {
436                         unsigned int cpuid = get_cpu();
437
438                         if (unlikely(stats->ls_percpu[cpuid] == NULL)) {
439                                 rc = lprocfs_stats_alloc_one(stats, cpuid);
440                                 if (rc < 0) {
441                                         put_cpu();
442                                         return rc;
443                                 }
444                         }
445                         return cpuid;
446                 }
447
448         case LPROCFS_GET_NUM_CPU:
449                 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
450                         if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
451                                 spin_lock_irqsave(&stats->ls_lock, *flags);
452                         else
453                                 spin_lock(&stats->ls_lock);
454                         return 1;
455                 } else {
456                         return stats->ls_biggest_alloc_num;
457                 }
458         }
459 }
460
461 static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats, int opc,
462                                         unsigned long *flags)
463 {
464         switch (opc) {
465         default:
466                 LBUG();
467
468         case LPROCFS_GET_SMP_ID:
469                 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
470                         if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
471                                 spin_unlock_irqrestore(&stats->ls_lock,
472                                                            *flags);
473                         } else {
474                                 spin_unlock(&stats->ls_lock);
475                         }
476                 } else {
477                         put_cpu();
478                 }
479                 return;
480
481         case LPROCFS_GET_NUM_CPU:
482                 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
483                         if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
484                                 spin_unlock_irqrestore(&stats->ls_lock,
485                                                            *flags);
486                         } else {
487                                 spin_unlock(&stats->ls_lock);
488                         }
489                 }
490                 return;
491         }
492 }
493
494 static inline unsigned int
495 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
496 {
497         unsigned int percpusize;
498
499         percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
500
501         /* irq safe stats need lc_array_sum[1] */
502         if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
503                 percpusize += stats->ls_num * sizeof(__s64);
504
505         if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
506                 percpusize = L1_CACHE_ALIGN(percpusize);
507
508         return percpusize;
509 }
510
511 static inline struct lprocfs_counter *
512 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
513                           int index)
514 {
515         struct lprocfs_counter *cntr;
516
517         cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
518
519         if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
520                 cntr = (void *)cntr + index * sizeof(__s64);
521
522         return cntr;
523 }
524
525 /* Two optimized LPROCFS counter increment functions are provided:
526  *     lprocfs_counter_incr(cntr, value) - optimized for by-one counters
527  *     lprocfs_counter_add(cntr) - use for multi-valued counters
528  * Counter data layout allows config flag, counter lock and the
529  * count itself to reside within a single cache line.
530  */
531
532 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
533                                 long amount);
534 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
535                                 long amount);
536
537 #define lprocfs_counter_incr(stats, idx) \
538         lprocfs_counter_add(stats, idx, 1)
539 #define lprocfs_counter_decr(stats, idx) \
540         lprocfs_counter_sub(stats, idx, 1)
541
542 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
543                                  struct lprocfs_counter_header *header,
544                                  enum lprocfs_stats_flags flags,
545                                  enum lprocfs_fields_flags field);
546 static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats,
547                                             int idx,
548                                             enum lprocfs_fields_flags field)
549 {
550         unsigned int  i;
551         unsigned int  num_cpu;
552         unsigned long flags     = 0;
553         __u64         ret       = 0;
554
555         LASSERT(stats != NULL);
556
557         num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
558         for (i = 0; i < num_cpu; i++) {
559                 if (stats->ls_percpu[i] == NULL)
560                         continue;
561                 ret += lprocfs_read_helper(
562                                 lprocfs_stats_counter_get(stats, i, idx),
563                                 &stats->ls_cnt_header[idx], stats->ls_flags,
564                                 field);
565         }
566         lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
567         return ret;
568 }
569
570 extern struct lprocfs_stats *
571 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
572 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
573 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
574 extern void lprocfs_init_ops_stats(int num_private_stats,
575                                    struct lprocfs_stats *stats);
576 extern void lprocfs_init_mps_stats(int num_private_stats,
577                                    struct lprocfs_stats *stats);
578 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
579 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
580                                    unsigned int num_private_stats);
581 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
582                                   unsigned int num_private_stats);
583 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
584                                  unsigned conf, const char *name,
585                                  const char *units);
586 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
587 extern void lprocfs_free_md_stats(struct obd_device *obddev);
588 struct obd_export;
589 struct nid_stat;
590 extern int lprocfs_add_clear_entry(struct obd_device * obd,
591                                    cfs_proc_dir_entry_t *entry);
592 #ifdef HAVE_SERVER_SUPPORT
593 extern int lprocfs_exp_setup(struct obd_export *exp,
594                              lnet_nid_t *peer_nid, int *newnid);
595 extern int lprocfs_exp_cleanup(struct obd_export *exp);
596 #else
597 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
598 { return 0; }
599 #endif
600 extern struct proc_dir_entry *
601 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
602 #ifndef HAVE_ONLY_PROCFS_SEQ
603                    read_proc_t *read_proc, write_proc_t *write_proc,
604 #endif
605                    void *data, const struct file_operations *fops);
606 extern struct proc_dir_entry *
607 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
608                     const char *format, ...);
609 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
610 #ifdef HAVE_SERVER_SUPPORT
611 #ifndef HAVE_ONLY_PROCFS_SEQ
612 extern int
613 lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
614                               unsigned long count, void *data);
615 extern int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off,
616                                         int count, int *eof,  void *data);
617 #endif
618 extern ssize_t
619 lprocfs_nid_stats_clear_seq_write(struct file *file, const char *buffer,
620                                         size_t count, loff_t *off);
621 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
622 #endif
623 extern int lprocfs_register_stats(cfs_proc_dir_entry_t *root, const char *name,
624                                   struct lprocfs_stats *stats);
625
626 /* lprocfs_status.c */
627 #ifndef HAVE_ONLY_PROCFS_SEQ
628 extern int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
629                             struct lprocfs_vars *var,
630                             void *data);
631
632 extern cfs_proc_dir_entry_t *lprocfs_register(const char *name,
633                                               cfs_proc_dir_entry_t *parent,
634                                               struct lprocfs_vars *list,
635                                               void *data);
636 #endif
637 extern int lprocfs_seq_add_vars(cfs_proc_dir_entry_t *root,
638                                 struct lprocfs_seq_vars *var,
639                                 void *data);
640
641 extern cfs_proc_dir_entry_t *
642 lprocfs_seq_register(const char *name, cfs_proc_dir_entry_t *parent,
643                      struct lprocfs_seq_vars *list, void *data);
644 extern void lprocfs_remove(cfs_proc_dir_entry_t **root);
645 extern void lprocfs_remove_proc_entry(const char *name,
646                                       struct proc_dir_entry *parent);
647 #ifndef HAVE_ONLY_PROCFS_SEQ
648 extern void lprocfs_try_remove_proc_entry(const char *name,
649                                           struct proc_dir_entry *parent);
650
651 extern cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *root,
652                                           const char *name);
653 extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
654 #endif
655 extern int lprocfs_seq_obd_setup(struct obd_device *dev);
656 extern int lprocfs_obd_cleanup(struct obd_device *obd);
657 #ifdef HAVE_SERVER_SUPPORT
658 extern const struct file_operations lprocfs_evict_client_fops;
659 #endif
660 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
661                               mode_t mode,
662                               const struct file_operations *seq_fops,
663                               void *data);
664 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
665                                   mode_t mode,
666                                   const struct file_operations *seq_fops,
667                                   void *data);
668
669 /* Generic callbacks */
670 #ifndef HAVE_ONLY_PROCFS_SEQ
671 extern int lprocfs_rd_u64(char *page, char **start, off_t off,
672                           int count, int *eof, void *data);
673 extern int lprocfs_rd_atomic(char *page, char **start, off_t off,
674                              int count, int *eof, void *data);
675 extern int lprocfs_wr_atomic(struct file *file, const char *buffer,
676                              unsigned long count, void *data);
677 extern int lprocfs_rd_uint(char *page, char **start, off_t off,
678                            int count, int *eof, void *data);
679 extern int lprocfs_rd_uuid(char *page, char **start, off_t off,
680                            int count, int *eof, void *data);
681 extern int lprocfs_rd_name(char *page, char **start, off_t off,
682                            int count, int *eof, void *data);
683 extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
684                                   int count, int *eof, void *data);
685 extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
686                                 int count, int *eof, void *data);
687 extern int lprocfs_rd_import(char *page, char **start, off_t off, int count,
688                              int *eof, void *data);
689 extern int lprocfs_rd_state(char *page, char **start, off_t off, int count,
690                             int *eof, void *data);
691 extern int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
692                                     int count, int *eof, void *data);
693 extern int lprocfs_rd_num_exports(char *page, char **start, off_t off,
694                                   int count, int *eof, void *data);
695 extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
696                               int count, int *eof, void *data);
697 #endif
698 extern int lprocfs_u64_seq_show(struct seq_file *m, void *data);
699 extern int lprocfs_atomic_seq_show(struct seq_file *m, void *data);
700 extern ssize_t lprocfs_atomic_seq_write(struct file *file, const char *buffer,
701                                         size_t count, loff_t *off);
702 extern int lprocfs_uint_seq_show(struct seq_file *m, void *data);
703 extern ssize_t lprocfs_uint_seq_write(struct file *file, const char *buffer,
704                                       size_t count, loff_t *off);
705 extern int lprocfs_wr_uint(struct file *file, const char *buffer,
706                            unsigned long count, void *data);
707 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
708 extern int lprocfs_name_seq_show(struct seq_file *m, void *data);
709 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
710 extern int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data);
711 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
712 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
713 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
714 #ifdef HAVE_SERVER_SUPPORT
715 extern int lprocfs_num_exports_seq_show(struct seq_file *m, void *data);
716 #endif
717 struct adaptive_timeout;
718 #ifndef HAVE_ONLY_PROCFS_SEQ
719 extern int lprocfs_at_hist_helper(char *page, int count, int rc,
720                                   struct adaptive_timeout *at);
721 extern int lprocfs_rd_timeouts(char *page, char **start, off_t off,
722                                int count, int *eof, void *data);
723 extern int lprocfs_wr_timeouts(struct file *file, const char *buffer,
724                                unsigned long count, void *data);
725 #endif
726 extern int lprocfs_seq_at_hist_helper(struct seq_file *m,
727                                       struct adaptive_timeout *at);
728 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
729 extern ssize_t
730 lprocfs_timeouts_seq_write(struct file *file, const char *buffer,
731                            size_t count, loff_t *off);
732 #ifndef HAVE_ONLY_PROCFS_SEQ
733 #ifdef HAVE_SERVER_SUPPORT
734 extern ssize_t lprocfs_fops_read(struct file *f, char __user *buf,
735                                  size_t size, loff_t *ppos);
736 extern ssize_t lprocfs_fops_write(struct file *f, const char __user *buf,
737                                   size_t size, loff_t *ppos);
738 extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
739                                    unsigned long count, void *data);
740 #endif
741 extern int lprocfs_wr_ping(struct file *file, const char *buffer,
742                            unsigned long count, void *data);
743 extern int lprocfs_wr_import(struct file *file, const char *buffer,
744                              unsigned long count, void *data);
745 extern int lprocfs_rd_pinger_recov(char *page, char **start, off_t off,
746                                    int count, int *eof, void *data);
747 extern int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
748                                    unsigned long count, void *data);
749 #endif
750 #ifdef HAVE_SERVER_SUPPORT
751 extern ssize_t
752 lprocfs_evict_client_seq_write(struct file *file, const char *buffer,
753                                 size_t count, loff_t *off);
754 #endif
755 extern ssize_t
756 lprocfs_ping_seq_write(struct file *file, const char *buffer,
757                        size_t count, loff_t *off);
758 extern ssize_t
759 lprocfs_import_seq_write(struct file *file, const char *buffer,
760                          size_t count, loff_t *off);
761 extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data);
762 extern ssize_t
763 lprocfs_pinger_recov_seq_write(struct file *file, const char *buffer,
764                                size_t count, loff_t *off);
765
766 /* Statfs helpers */
767 #ifndef HAVE_ONLY_PROCFS_SEQ
768 extern int lprocfs_rd_blksize(char *page, char **start, off_t off,
769                               int count, int *eof, void *data);
770 extern int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
771                                   int count, int *eof, void *data);
772 extern int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
773                                  int count, int *eof, void *data);
774 extern int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
775                                  int count, int *eof, void *data);
776 extern int lprocfs_rd_filestotal(char *page, char **start, off_t off,
777                                  int count, int *eof, void *data);
778 extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
779                                 int count, int *eof, void *data);
780 extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
781                                  int count, int *eof, void *data);
782 #endif
783 extern int lprocfs_blksize_seq_show(struct seq_file *m, void *data);
784 extern int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data);
785 extern int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data);
786 extern int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data);
787 extern int lprocfs_filestotal_seq_show(struct seq_file *m, void *data);
788 extern int lprocfs_filesfree_seq_show(struct seq_file *m, void *data);
789
790 extern int lprocfs_write_helper(const char *buffer, unsigned long count,
791                                 int *val);
792 extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
793                                      int *val, int mult);
794 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
795 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
796                                     long val, int mult);
797 extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
798                                     __u64 *val);
799 extern int lprocfs_write_frac_u64_helper(const char *buffer,
800                                          unsigned long count,
801                                          __u64 *val, int mult);
802 char *lprocfs_find_named_value(const char *buffer, const char *name,
803                                 size_t *count);
804 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
805 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
806 void lprocfs_oh_clear(struct obd_histogram *oh);
807 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
808
809 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
810                            struct lprocfs_counter *cnt);
811
812 #ifdef HAVE_SERVER_SUPPORT
813 #ifndef HAVE_ONLY_PROCFS_SEQ
814 /* lprocfs_status.c: recovery status */
815 int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
816                                    int count, int *eof, void *data);
817 /* lprocfs_statuc.c: hash statistics */
818 int lprocfs_obd_rd_hash(char *page, char **start, off_t off,
819                         int count, int *eof, void *data);
820
821 /* lprocfs_status.c: IR factor */
822 int lprocfs_obd_rd_ir_factor(char *page, char **start, off_t off,
823                              int count, int *eof, void *data);
824 int lprocfs_obd_wr_ir_factor(struct file *file, const char *buffer,
825                              unsigned long count, void *data);
826 #endif
827 /* lprocfs_status.c: recovery status */
828 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
829
830 /* lprocfs_status.c: hash statistics */
831 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
832
833 /* lprocfs_status.c: IR factor */
834 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data);
835 ssize_t
836 lprocfs_ir_factor_seq_write(struct file *file, const char *buffer,
837                                 size_t count, loff_t *off);
838 #endif
839 extern int lprocfs_single_release(cfs_inode_t *, struct file *);
840 extern int lprocfs_seq_release(cfs_inode_t *, struct file *);
841
842 /* You must use these macros when you want to refer to
843  * the import in a client obd_device for a lprocfs entry */
844 #define LPROCFS_CLIMP_CHECK(obd) do {           \
845         typecheck(struct obd_device *, obd);    \
846         down_read(&(obd)->u.cli.cl_sem);    \
847         if ((obd)->u.cli.cl_import == NULL) {   \
848              up_read(&(obd)->u.cli.cl_sem); \
849              return -ENODEV;                    \
850         }                                       \
851 } while(0)
852 #define LPROCFS_CLIMP_EXIT(obd)                 \
853         up_read(&(obd)->u.cli.cl_sem);
854
855 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
856   proc entries; otherwise, you will define name##_seq_write function also for
857   a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
858   call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
859 #define __LPROC_SEQ_FOPS(name, custom_seq_write)                        \
860 static int name##_single_open(cfs_inode_t *inode, struct file *file)    \
861 {                                                                       \
862         LPROCFS_ENTRY_CHECK(PDE(inode));                                \
863         return single_open(file, name##_seq_show, PDE_DATA(inode));     \
864 }                                                                       \
865 struct file_operations name##_fops = {                                  \
866         .owner   = THIS_MODULE,                                         \
867         .open    = name##_single_open,                                  \
868         .read    = seq_read,                                            \
869         .write   = custom_seq_write,                                    \
870         .llseek  = seq_lseek,                                           \
871         .release = lprocfs_single_release,                              \
872 }
873
874 #define LPROC_SEQ_FOPS_RO(name)         __LPROC_SEQ_FOPS(name, NULL)
875 #define LPROC_SEQ_FOPS(name)            __LPROC_SEQ_FOPS(name, name##_seq_write)
876
877 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)                              \
878         static int name##_##type##_seq_show(struct seq_file *m, void *v)\
879         {                                                               \
880                 return lprocfs_##type##_seq_show(m, m->private);        \
881         }                                                               \
882         LPROC_SEQ_FOPS_RO(name##_##type)
883
884 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)                              \
885         static int name##_##type##_seq_show(struct seq_file *m, void *v)\
886         {                                                               \
887                 return lprocfs_##type##_seq_show(m, m->private);        \
888         }                                                               \
889         static ssize_t name##_##type##_seq_write(struct file *file,     \
890                         const char *buffer, size_t count, loff_t *off)  \
891         {                                                               \
892                 struct seq_file *seq = file->private_data;              \
893                 return lprocfs_##type##_seq_write(file, buffer,         \
894                                                 count, seq->private);   \
895         }                                                               \
896         LPROC_SEQ_FOPS(name##_##type);
897
898 #define LPROC_SEQ_FOPS_WO_TYPE(name, type)                              \
899         static ssize_t name##_##type##_write(struct file *file,         \
900                         const char *buffer, size_t count, loff_t *off)  \
901         {                                                               \
902                 return lprocfs_##type##_seq_write(file, buffer, count, off);    \
903         }                                                               \
904         static int name##_##type##_open(cfs_inode_t *inode, struct file *file)  \
905         {                                                               \
906                 return single_open(file, NULL, PDE_DATA(inode));        \
907         }                                                               \
908         struct file_operations name##_##type##_fops = {                 \
909                 .open    = name##_##type##_open,                        \
910                 .write   = name##_##type##_write,                       \
911                 .release = lprocfs_single_release,                      \
912         };
913
914 /* lproc_ptlrpc.c */
915 struct ptlrpc_request;
916 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
917
918 #ifdef HAVE_SERVER_SUPPORT
919 /* lprocfs_jobstats.c */
920 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
921                           int event, long amount);
922 void lprocfs_job_stats_fini(struct obd_device *obd);
923 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
924                            cntr_init_callback fn);
925 #ifndef HAVE_ONLY_PROCFS_SEQ
926 int lprocfs_rd_job_interval(char *page, char **start, off_t off,
927                             int count, int *eof, void *data);
928 int lprocfs_wr_job_interval(struct file *file, const char *buffer,
929                             unsigned long count, void *data);
930
931 /* lproc_status.c */
932 int lprocfs_obd_rd_recovery_time_soft(char *page, char **start, off_t off,
933                                       int count, int *eof, void *data);
934 int lprocfs_obd_wr_recovery_time_soft(struct file *file,
935                                       const char *buffer,
936                                       unsigned long count, void *data);
937 int lprocfs_obd_rd_recovery_time_hard(char *page, char **start, off_t off,
938                                       int count, int *eof, void *data);
939 int lprocfs_obd_wr_recovery_time_hard(struct file *file,
940                                       const char *buffer,
941                                       unsigned long count, void *data);
942 int lprocfs_target_rd_instance(char *page, char **start, off_t off,
943                                int count, int *eof, void *data);
944 #endif
945 int lprocfs_job_interval_seq_show(struct seq_file *m, void *data);
946 ssize_t
947 lprocfs_job_interval_seq_write(struct file *file, const char *buffer,
948                                 size_t count, loff_t *off);
949 /* lproc_status.c */
950 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data);
951 ssize_t lprocfs_recovery_time_soft_seq_write(struct file *file,
952                                                 const char *buffer,
953                                                 size_t count, loff_t *off);
954 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data);
955 ssize_t
956 lprocfs_recovery_time_hard_seq_write(struct file *file, const char *buffer,
957                                         size_t count, loff_t *off);
958 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data);
959 #endif
960 #ifndef HAVE_ONLY_PROCFS_SEQ
961 int lprocfs_obd_rd_max_pages_per_rpc(char *page, char **start, off_t off,
962                                      int count, int *eof, void *data);
963 int lprocfs_obd_wr_max_pages_per_rpc(struct file *file, const char *buffer,
964                                      unsigned long count, void *data);
965 #endif
966 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
967 ssize_t
968 lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file, const char *buffer,
969                                        size_t count, loff_t *off);
970
971 struct root_squash_info;
972 int lprocfs_wr_root_squash(const char *buffer, unsigned long count,
973                            struct root_squash_info *squash, char *name);
974 int lprocfs_wr_nosquash_nids(const char *buffer, unsigned long count,
975                              struct root_squash_info *squash, char *name);
976
977 /* all quota proc functions */
978 extern int lprocfs_quota_rd_bunit(char *page, char **start,
979                                   off_t off, int count,
980                                   int *eof, void *data);
981 extern int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
982                                   unsigned long count, void *data);
983 extern int lprocfs_quota_rd_btune(char *page, char **start,
984                                   off_t off, int count,
985                                   int *eof, void *data);
986 extern int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
987                                   unsigned long count, void *data);
988 extern int lprocfs_quota_rd_iunit(char *page, char **start,
989                                   off_t off, int count,
990                                   int *eof, void *data);
991 extern int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
992                                   unsigned long count, void *data);
993 extern int lprocfs_quota_rd_itune(char *page, char **start,
994                                   off_t off, int count,
995                                   int *eof, void *data);
996 extern int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
997                                   unsigned long count, void *data);
998 extern int lprocfs_quota_rd_type(char *page, char **start, off_t off, int count,
999                                  int *eof, void *data);
1000 extern int lprocfs_quota_wr_type(struct file *file, const char *buffer,
1001                                  unsigned long count, void *data);
1002 extern int lprocfs_quota_rd_switch_seconds(char *page, char **start, off_t off,
1003                                            int count, int *eof, void *data);
1004 extern int lprocfs_quota_wr_switch_seconds(struct file *file,
1005                                            const char *buffer,
1006                                            unsigned long count, void *data);
1007 extern int lprocfs_quota_rd_sync_blk(char *page, char **start, off_t off,
1008                                      int count, int *eof, void *data);
1009 extern int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
1010                                      unsigned long count, void *data);
1011 extern int lprocfs_quota_rd_switch_qs(char *page, char **start, off_t off,
1012                                       int count, int *eof, void *data);
1013 extern int lprocfs_quota_wr_switch_qs(struct file *file,
1014                                       const char *buffer,
1015                                       unsigned long count, void *data);
1016 extern int lprocfs_quota_rd_boundary_factor(char *page, char **start, off_t off,
1017                                             int count, int *eof, void *data);
1018 extern int lprocfs_quota_wr_boundary_factor(struct file *file,
1019                                             const char *buffer,
1020                                             unsigned long count, void *data);
1021 extern int lprocfs_quota_rd_least_bunit(char *page, char **start, off_t off,
1022                                         int count, int *eof, void *data);
1023 extern int lprocfs_quota_wr_least_bunit(struct file *file,
1024                                         const char *buffer,
1025                                         unsigned long count, void *data);
1026 extern int lprocfs_quota_rd_least_iunit(char *page, char **start, off_t off,
1027                                         int count, int *eof, void *data);
1028 extern int lprocfs_quota_wr_least_iunit(struct file *file,
1029                                         const char *buffer,
1030                                         unsigned long count, void *data);
1031 extern int lprocfs_quota_rd_qs_factor(char *page, char **start, off_t off,
1032                                       int count, int *eof, void *data);
1033 extern int lprocfs_quota_wr_qs_factor(struct file *file,
1034                                       const char *buffer,
1035                                       unsigned long count, void *data);
1036 #else
1037 /* LPROCFS is not defined */
1038
1039 #define proc_lustre_root NULL
1040
1041 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
1042                                        int index, long amount)
1043 { return; }
1044 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
1045                                         int index)
1046 { return; }
1047 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
1048                                        int index, long amount)
1049 { return; }
1050 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
1051                                         int index)
1052 { return; }
1053 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
1054                                         int index, unsigned conf,
1055                                         const char *name, const char *units)
1056 { return; }
1057
1058 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
1059                                    enum lprocfs_fields_flags field)
1060 { return 0; }
1061
1062 /* NB: we return !NULL to satisfy error checker */
1063 static inline struct lprocfs_stats *
1064 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
1065 { return (struct lprocfs_stats *)1; }
1066 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
1067 { return; }
1068 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
1069 { return; }
1070 static inline int lprocfs_register_stats(cfs_proc_dir_entry_t *root,
1071                                          const char *name,
1072                                          struct lprocfs_stats *stats)
1073 { return 0; }
1074 static inline void lprocfs_init_ops_stats(int num_private_stats,
1075                                           struct lprocfs_stats *stats)
1076 { return; }
1077 static inline void lprocfs_init_mps_stats(int num_private_stats,
1078                                           struct lprocfs_stats *stats)
1079 { return; }
1080 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
1081 { return; }
1082 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
1083                                           unsigned int num_private_stats)
1084 { return 0; }
1085 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
1086                                          unsigned int num_private_stats)
1087 { return 0; }
1088 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
1089 { return; }
1090 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
1091 { return; }
1092
1093 struct obd_export;
1094 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
1095 { return 0; }
1096 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
1097 { return; }
1098 #ifdef HAVE_SERVER_SUPPORT
1099 #ifndef HAVE_ONLY_PROCFS_SEQ
1100 static inline
1101 int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
1102                                   unsigned long count, void *data)
1103 {return count;}
1104 static inline
1105 int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off,
1106                                  int count, int *eof,  void *data)
1107 {return count;}
1108 #endif
1109 static inline
1110 ssize_t lprocfs_nid_stats_seq_write(struct file *file, const char *buffer,
1111                                         size_t count, loff_t *off)
1112 {return 0;}
1113 static inline
1114 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
1115 {return 0;}
1116 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid,
1117                                     int *newnid)
1118 { return 0; }
1119 #endif
1120 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
1121 { return 0; }
1122 static inline struct proc_dir_entry *
1123 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
1124 #ifndef HAVE_ONLY_PROCFS_SEQ
1125                    read_proc_t *read_proc, write_proc_t *write_proc,
1126 #endif
1127                    void *data, const struct file_operations *fops)
1128 {return 0; }
1129 static inline struct proc_dir_entry *
1130 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
1131                     const char *format, ...)
1132 {return NULL; }
1133 #ifndef HAVE_ONLY_PROCFS_SEQ
1134 static inline cfs_proc_dir_entry_t *
1135 lprocfs_register(const char *name, cfs_proc_dir_entry_t *parent,
1136                  struct lprocfs_vars *list, void *data)
1137 { return NULL; }
1138 static inline int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
1139                                    struct lprocfs_vars *var,
1140                                    void *data)
1141 { return 0; }
1142 #endif
1143 static inline int lprocfs_seq_add_vars(cfs_proc_dir_entry_t *root,
1144                                        struct lprocfs_seq_vars *var,
1145                                        void *data)
1146 { return 0; }
1147 static inline cfs_proc_dir_entry_t *
1148 lprocfs_seq_register(const char *name, cfs_proc_dir_entry_t *parent,
1149                      struct lprocfs_seq_vars *list, void *data)
1150 { return NULL; }
1151 static inline void lprocfs_remove(cfs_proc_dir_entry_t **root)
1152 { return; }
1153 static inline void lprocfs_remove_proc_entry(const char *name,
1154                                              struct proc_dir_entry *parent)
1155 { return; }
1156 #ifndef HAVE_ONLY_PROCFS_SEQ
1157 static inline void lprocfs_try_remove_proc_entry(const char *name,
1158                                                  struct proc_dir_entry *parent)
1159 { return; }
1160 static inline cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *head,
1161                                                  const char *name)
1162 { return 0; }
1163 static inline int lprocfs_obd_setup(struct obd_device *dev,
1164                                     struct lprocfs_vars *list)
1165 { return 0; }
1166 #endif
1167 static inline int lprocfs_seq_obd_setup(struct obd_device *dev)
1168 { return 0; }
1169 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
1170 { return 0; }
1171 static inline int lprocfs_rd_u64(char *page, char **start, off_t off,
1172                                  int count, int *eof, void *data)
1173 { return 0; }
1174 #ifndef HAVE_ONLY_PROCFS_SEQ
1175 static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
1176                                   int count, int *eof, void *data)
1177 { return 0; }
1178 static inline int lprocfs_rd_name(char *page, char **start, off_t off,
1179                                   int count, int *eof, void *data)
1180 { return 0; }
1181 static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
1182                                          int count, int *eof, void *data)
1183 { return 0; }
1184 static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
1185                                        int count, int *eof, void *data)
1186 { return 0; }
1187 static inline int lprocfs_rd_import(char *page, char **start, off_t off,
1188                                     int count, int *eof, void *data)
1189 { return 0; }
1190 static inline int lprocfs_rd_pinger_recov(char *page, char **start, off_t off,
1191                                           int count, int *eof, void *data)
1192 { return 0; }
1193 static inline int lprocfs_rd_state(char *page, char **start, off_t off,
1194                                    int count, int *eof, void *data)
1195 { return 0; }
1196 static inline int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
1197                                            int count, int *eof, void *data)
1198 { return 0; }
1199 static inline int lprocfs_rd_num_exports(char *page, char **start, off_t off,
1200                                          int count, int *eof, void *data)
1201 { return 0; }
1202 static inline int lprocfs_rd_numrefs(struct seq_file *m, void *data)
1203 { return 0; }
1204 struct adaptive_timeout;
1205 static inline int lprocfs_at_hist_helper(char *page, int count, int rc,
1206                                          struct adaptive_timeout *at)
1207 { return 0; }
1208 static inline int lprocfs_rd_timeouts(char *page, char **start, off_t off,
1209                                       int count, int *eof, void *data)
1210 { return 0; }
1211 static inline int lprocfs_wr_timeouts(struct file *file,
1212                                       const char *buffer,
1213                                       unsigned long count, void *data)
1214 { return 0; }
1215 #ifdef HAVE_SERVER_SUPPORT
1216 static inline int lprocfs_wr_evict_client(struct file *file,
1217                                           const char *buffer,
1218                                           unsigned long count, void *data)
1219 { return 0; }
1220 #endif
1221 static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
1222                                   unsigned long count, void *data)
1223 { return 0; }
1224 static inline int lprocfs_wr_import(struct file *file, const char *buffer,
1225                                     unsigned long count, void *data)
1226 { return 0; }
1227 static inline int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
1228                                     unsigned long count, void *data)
1229 { return 0; }
1230 #endif
1231 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
1232 { return 0; }
1233 static inline int lprocfs_name_seq_show(struct seq_file *m, void *data)
1234 { return 0; }
1235 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
1236 { return 0; }
1237 static inline int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data)
1238 { return 0; }
1239 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
1240 { return 0; }
1241 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
1242 { return 0; }
1243 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
1244 { return 0; }
1245 #ifdef HAVE_SERVER_SUPPORT
1246 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
1247 { return 0; }
1248 #endif
1249 struct adaptive_timeout;
1250 static inline int lprocfs_seq_at_hist_helper(struct seq_file *m,
1251                                              struct adaptive_timeout *at)
1252 { return 0; }
1253 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
1254 { return 0; }
1255 static inline ssize_t
1256 lprocfs_timeouts_seq_write(struct file *file, const char *buffer,
1257                            size_t count, loff_t *off)
1258 { return 0; }
1259 #ifdef HAVE_SERVER_SUPPORT
1260 static inline ssize_t
1261 lprocfs_evict_client_seq_write(struct file *file, const char *buffer,
1262                                size_t count, loff_t *off)
1263 { return 0; }
1264 #endif
1265 static inline ssize_t
1266 lprocfs_ping_seq_write(struct file *file, const char *buffer,
1267                        size_t count, loff_t *off)
1268 { return 0; }
1269 static inline ssize_t
1270 lprocfs_import_seq_write(struct file *file, const char *buffer,
1271                          size_t count, loff_t *off)
1272 { return 0; }
1273 static inline int
1274 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
1275 { return 0; }
1276 static inline ssize_t
1277 lprocfs_pinger_recov_seq_write(struct file *file, const char *buffer,
1278                                size_t count, loff_t *off)
1279 { return 0; }
1280
1281 /* Statfs helpers */
1282 #ifndef HAVE_ONLY_PROCFS_SEQ
1283 static inline
1284 int lprocfs_rd_blksize(char *page, char **start, off_t off,
1285                        int count, int *eof, void *data)
1286 { return 0; }
1287 static inline
1288 int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
1289                            int count, int *eof, void *data)
1290 { return 0; }
1291 static inline
1292 int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
1293                           int count, int *eof, void *data)
1294 { return 0; }
1295 static inline
1296 int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
1297                            int count, int *eof, void *data)
1298 { return 0; }
1299 static inline
1300 int lprocfs_rd_filestotal(char *page, char **start, off_t off,
1301                           int count, int *eof, void *data)
1302 { return 0; }
1303 static inline
1304 int lprocfs_rd_filesfree(char *page, char **start, off_t off,
1305                          int count, int *eof, void *data)
1306 { return 0; }
1307 #endif
1308 static inline
1309 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
1310 { return 0; }
1311 static inline
1312 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
1313 { return 0; }
1314 static inline
1315 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
1316 { return 0; }
1317 static inline
1318 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
1319 { return 0; }
1320 static inline
1321 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
1322 { return 0; }
1323 static inline
1324 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
1325 { return 0; }
1326 static inline
1327 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1328 { return; }
1329 static inline
1330 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1331 { return; }
1332 static inline
1333 void lprocfs_oh_clear(struct obd_histogram *oh)
1334 { return; }
1335 static inline
1336 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1337 { return 0; }
1338 static inline
1339 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1340                            struct lprocfs_counter *cnt)
1341 { return; }
1342 static inline
1343 __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1344                                enum lprocfs_fields_flags field)
1345 { return (__u64)0; }
1346
1347 #define LPROC_SEQ_FOPS_RO(name)
1348 #define LPROC_SEQ_FOPS(name)
1349 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
1350 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
1351 #define LPROC_SEQ_FOPS_WO_TYPE(name, type)
1352
1353 /* lprocfs_jobstats.c */
1354 static inline
1355 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1356                           long amount)
1357 { return 0; }
1358 static inline
1359 void lprocfs_job_stats_fini(struct obd_device *obd)
1360 { return; }
1361 static inline
1362 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1363                            cntr_init_callback fn)
1364 { return 0; }
1365
1366
1367 /* lproc_ptlrpc.c */
1368 #define target_print_req NULL
1369
1370 #endif /* LPROCFS */
1371
1372 #endif /* LPROCFS_SNMP_H */