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