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