Whamcloud - gitweb
LU-5331 obdclass: serialize lu_site purge
[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 < OUT_UPDATE_LAST_OPC) {
306                 /* update opcode */
307                 return (opc - OUT_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 if (opc < LFSCK_LAST_OPC) {
319                 /* LFSCK opcode */
320                 return (opc - LFSCK_FIRST_OPC +
321                         OPC_RANGE(OUT_UPDATE) +
322                         OPC_RANGE(FLD) +
323                         OPC_RANGE(SEC) +
324                         OPC_RANGE(SEQ) +
325                         OPC_RANGE(QUOTA) +
326                         OPC_RANGE(LLOG) +
327                         OPC_RANGE(OBD) +
328                         OPC_RANGE(MGS) +
329                         OPC_RANGE(LDLM) +
330                         OPC_RANGE(MDS) +
331                         OPC_RANGE(OST));
332         } else {
333                 /* Unknown Opcode */
334                 return -1;
335         }
336 }
337
338
339 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST)  + \
340                             OPC_RANGE(MDS)  + \
341                             OPC_RANGE(LDLM) + \
342                             OPC_RANGE(MGS)  + \
343                             OPC_RANGE(OBD)  + \
344                             OPC_RANGE(LLOG) + \
345                             OPC_RANGE(SEC)  + \
346                             OPC_RANGE(SEQ)  + \
347                             OPC_RANGE(SEC)  + \
348                             OPC_RANGE(FLD)  + \
349                             OPC_RANGE(OUT_UPDATE) + \
350                             OPC_RANGE(LFSCK))
351
352 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR)  + \
353                             OPC_RANGE(EXTRA))
354
355 enum {
356         PTLRPC_REQWAIT_CNTR = 0,
357         PTLRPC_REQQDEPTH_CNTR,
358         PTLRPC_REQACTIVE_CNTR,
359         PTLRPC_TIMEOUT,
360         PTLRPC_REQBUF_AVAIL_CNTR,
361         PTLRPC_LAST_CNTR
362 };
363
364 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
365
366 enum {
367         LDLM_GLIMPSE_ENQUEUE = 0,
368         LDLM_PLAIN_ENQUEUE,
369         LDLM_EXTENT_ENQUEUE,
370         LDLM_FLOCK_ENQUEUE,
371         LDLM_IBITS_ENQUEUE,
372         MDS_REINT_SETATTR,
373         MDS_REINT_CREATE,
374         MDS_REINT_LINK,
375         MDS_REINT_UNLINK,
376         MDS_REINT_RENAME,
377         MDS_REINT_OPEN,
378         MDS_REINT_SETXATTR,
379         BRW_READ_BYTES,
380         BRW_WRITE_BYTES,
381         EXTRA_LAST_OPC
382 };
383
384 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
385 /* class_obd.c */
386 extern cfs_proc_dir_entry_t *proc_lustre_root;
387
388 struct obd_device;
389 struct obd_histogram;
390
391 /* Days / hours / mins / seconds format */
392 struct dhms {
393         int d,h,m,s;
394 };
395 static inline void s2dhms(struct dhms *ts, time_t secs)
396 {
397         ts->d = secs / 86400;
398         secs = secs % 86400;
399         ts->h = secs / 3600;
400         secs = secs % 3600;
401         ts->m = secs / 60;
402         ts->s = secs % 60;
403 }
404 #define DHMS_FMT "%dd%dh%02dm%02ds"
405 #define DHMS_VARS(x) (x)->d, (x)->h, (x)->m, (x)->s
406
407 #define JOBSTATS_JOBID_VAR_MAX_LEN      20
408 #define JOBSTATS_DISABLE                "disable"
409 #define JOBSTATS_PROCNAME_UID           "procname_uid"
410
411 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
412
413 struct obd_job_stats {
414         cfs_hash_t        *ojs_hash;
415         cfs_list_t         ojs_list;
416         rwlock_t       ojs_lock; /* protect the obj_list */
417         cntr_init_callback ojs_cntr_init_fn;
418         int                ojs_cntr_num;
419         int                ojs_cleanup_interval;
420         time_t             ojs_last_cleanup;
421 };
422
423 #ifdef LPROCFS
424
425 extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
426                                    unsigned int cpuid);
427 /*
428  * \return value
429  *      < 0     : on error (only possible for opc as LPROCFS_GET_SMP_ID)
430  */
431 static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc,
432                                      unsigned long *flags)
433 {
434         int             rc = 0;
435
436         switch (opc) {
437         default:
438                 LBUG();
439
440         case LPROCFS_GET_SMP_ID:
441                 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
442                         if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
443                                 spin_lock_irqsave(&stats->ls_lock, *flags);
444                         else
445                                 spin_lock(&stats->ls_lock);
446                         return 0;
447                 } else {
448                         unsigned int cpuid = get_cpu();
449
450                         if (unlikely(stats->ls_percpu[cpuid] == NULL)) {
451                                 rc = lprocfs_stats_alloc_one(stats, cpuid);
452                                 if (rc < 0) {
453                                         put_cpu();
454                                         return rc;
455                                 }
456                         }
457                         return cpuid;
458                 }
459
460         case LPROCFS_GET_NUM_CPU:
461                 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
462                         if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
463                                 spin_lock_irqsave(&stats->ls_lock, *flags);
464                         else
465                                 spin_lock(&stats->ls_lock);
466                         return 1;
467                 } else {
468                         return stats->ls_biggest_alloc_num;
469                 }
470         }
471 }
472
473 static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats, int opc,
474                                         unsigned long *flags)
475 {
476         switch (opc) {
477         default:
478                 LBUG();
479
480         case LPROCFS_GET_SMP_ID:
481                 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
482                         if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
483                                 spin_unlock_irqrestore(&stats->ls_lock,
484                                                            *flags);
485                         } else {
486                                 spin_unlock(&stats->ls_lock);
487                         }
488                 } else {
489                         put_cpu();
490                 }
491                 return;
492
493         case LPROCFS_GET_NUM_CPU:
494                 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
495                         if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
496                                 spin_unlock_irqrestore(&stats->ls_lock,
497                                                            *flags);
498                         } else {
499                                 spin_unlock(&stats->ls_lock);
500                         }
501                 }
502                 return;
503         }
504 }
505
506 static inline unsigned int
507 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
508 {
509         unsigned int percpusize;
510
511         percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
512
513         /* irq safe stats need lc_array_sum[1] */
514         if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
515                 percpusize += stats->ls_num * sizeof(__s64);
516
517         if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
518                 percpusize = L1_CACHE_ALIGN(percpusize);
519
520         return percpusize;
521 }
522
523 static inline struct lprocfs_counter *
524 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
525                           int index)
526 {
527         struct lprocfs_counter *cntr;
528
529         cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
530
531         if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
532                 cntr = (void *)cntr + index * sizeof(__s64);
533
534         return cntr;
535 }
536
537 /* Two optimized LPROCFS counter increment functions are provided:
538  *     lprocfs_counter_incr(cntr, value) - optimized for by-one counters
539  *     lprocfs_counter_add(cntr) - use for multi-valued counters
540  * Counter data layout allows config flag, counter lock and the
541  * count itself to reside within a single cache line.
542  */
543
544 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
545                                 long amount);
546 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
547                                 long amount);
548
549 #define lprocfs_counter_incr(stats, idx) \
550         lprocfs_counter_add(stats, idx, 1)
551 #define lprocfs_counter_decr(stats, idx) \
552         lprocfs_counter_sub(stats, idx, 1)
553
554 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
555                                  struct lprocfs_counter_header *header,
556                                  enum lprocfs_stats_flags flags,
557                                  enum lprocfs_fields_flags field);
558 static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats,
559                                             int idx,
560                                             enum lprocfs_fields_flags field)
561 {
562         int           i;
563         unsigned int  num_cpu;
564         unsigned long flags     = 0;
565         __u64         ret       = 0;
566
567         LASSERT(stats != NULL);
568
569         num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
570         for (i = 0; i < num_cpu; i++) {
571                 if (stats->ls_percpu[i] == NULL)
572                         continue;
573                 ret += lprocfs_read_helper(
574                                 lprocfs_stats_counter_get(stats, i, idx),
575                                 &stats->ls_cnt_header[idx], stats->ls_flags,
576                                 field);
577         }
578         lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
579         return ret;
580 }
581
582 extern struct lprocfs_stats *
583 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
584 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
585 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
586 extern void lprocfs_init_ops_stats(int num_private_stats,
587                                    struct lprocfs_stats *stats);
588 extern void lprocfs_init_mps_stats(int num_private_stats,
589                                    struct lprocfs_stats *stats);
590 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
591 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
592                                    unsigned int num_private_stats);
593 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
594                                   unsigned int num_private_stats);
595 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
596                                  unsigned conf, const char *name,
597                                  const char *units);
598 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
599 extern void lprocfs_free_md_stats(struct obd_device *obddev);
600 struct obd_export;
601 struct nid_stat;
602 extern int lprocfs_add_clear_entry(struct obd_device * obd,
603                                    cfs_proc_dir_entry_t *entry);
604 #ifdef HAVE_SERVER_SUPPORT
605 extern int lprocfs_exp_setup(struct obd_export *exp,
606                              lnet_nid_t *peer_nid, int *newnid);
607 extern int lprocfs_exp_cleanup(struct obd_export *exp);
608 #else
609 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
610 { return 0; }
611 #endif
612 extern struct proc_dir_entry *
613 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
614 #ifndef HAVE_ONLY_PROCFS_SEQ
615                    read_proc_t *read_proc, write_proc_t *write_proc,
616 #endif
617                    void *data, const struct file_operations *fops);
618 extern struct proc_dir_entry *
619 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
620                     const char *format, ...);
621 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
622 #ifdef HAVE_SERVER_SUPPORT
623 #ifndef HAVE_ONLY_PROCFS_SEQ
624 extern int
625 lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
626                               unsigned long count, void *data);
627 extern int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off,
628                                         int count, int *eof,  void *data);
629 #endif
630 extern ssize_t
631 lprocfs_nid_stats_clear_seq_write(struct file *file, const char *buffer,
632                                         size_t count, loff_t *off);
633 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
634 #endif
635 extern int lprocfs_register_stats(cfs_proc_dir_entry_t *root, const char *name,
636                                   struct lprocfs_stats *stats);
637
638 /* lprocfs_status.c */
639 #ifndef HAVE_ONLY_PROCFS_SEQ
640 extern int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
641                             struct lprocfs_vars *var,
642                             void *data);
643
644 extern cfs_proc_dir_entry_t *lprocfs_register(const char *name,
645                                               cfs_proc_dir_entry_t *parent,
646                                               struct lprocfs_vars *list,
647                                               void *data);
648 #endif
649 extern int lprocfs_seq_add_vars(cfs_proc_dir_entry_t *root,
650                                 struct lprocfs_seq_vars *var,
651                                 void *data);
652
653 extern cfs_proc_dir_entry_t *
654 lprocfs_seq_register(const char *name, cfs_proc_dir_entry_t *parent,
655                      struct lprocfs_seq_vars *list, void *data);
656 extern void lprocfs_remove(cfs_proc_dir_entry_t **root);
657 extern void lprocfs_remove_proc_entry(const char *name,
658                                       struct proc_dir_entry *parent);
659 #ifndef HAVE_ONLY_PROCFS_SEQ
660 extern void lprocfs_try_remove_proc_entry(const char *name,
661                                           struct proc_dir_entry *parent);
662
663 extern cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *root,
664                                           const char *name);
665 extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
666 #endif
667 extern int lprocfs_seq_obd_setup(struct obd_device *dev);
668 extern int lprocfs_obd_cleanup(struct obd_device *obd);
669 #ifdef HAVE_SERVER_SUPPORT
670 extern const struct file_operations lprocfs_evict_client_fops;
671 #endif
672 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
673                               mode_t mode,
674                               const struct file_operations *seq_fops,
675                               void *data);
676 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
677                                   mode_t mode,
678                                   const struct file_operations *seq_fops,
679                                   void *data);
680
681 /* Generic callbacks */
682 #ifndef HAVE_ONLY_PROCFS_SEQ
683 extern int lprocfs_rd_u64(char *page, char **start, off_t off,
684                           int count, int *eof, void *data);
685 extern int lprocfs_rd_atomic(char *page, char **start, off_t off,
686                              int count, int *eof, void *data);
687 extern int lprocfs_wr_atomic(struct file *file, const char *buffer,
688                              unsigned long count, void *data);
689 extern int lprocfs_rd_uint(char *page, char **start, off_t off,
690                            int count, int *eof, void *data);
691 extern int lprocfs_rd_uuid(char *page, char **start, off_t off,
692                            int count, int *eof, void *data);
693 extern int lprocfs_rd_name(char *page, char **start, off_t off,
694                            int count, int *eof, void *data);
695 extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
696                                   int count, int *eof, void *data);
697 extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
698                                 int count, int *eof, void *data);
699 extern int lprocfs_rd_import(char *page, char **start, off_t off, int count,
700                              int *eof, void *data);
701 extern int lprocfs_rd_state(char *page, char **start, off_t off, int count,
702                             int *eof, void *data);
703 extern int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
704                                     int count, int *eof, void *data);
705 extern int lprocfs_rd_num_exports(char *page, char **start, off_t off,
706                                   int count, int *eof, void *data);
707 extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
708                               int count, int *eof, void *data);
709 #endif
710 extern int lprocfs_u64_seq_show(struct seq_file *m, void *data);
711 extern int lprocfs_atomic_seq_show(struct seq_file *m, void *data);
712 extern ssize_t lprocfs_atomic_seq_write(struct file *file, const char *buffer,
713                                         size_t count, loff_t *off);
714 extern int lprocfs_uint_seq_show(struct seq_file *m, void *data);
715 extern ssize_t lprocfs_uint_seq_write(struct file *file, const char *buffer,
716                                       size_t count, loff_t *off);
717 extern int lprocfs_wr_uint(struct file *file, const char *buffer,
718                            unsigned long count, void *data);
719 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
720 extern int lprocfs_name_seq_show(struct seq_file *m, void *data);
721 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
722 extern int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data);
723 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
724 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
725 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
726 #ifdef HAVE_SERVER_SUPPORT
727 extern int lprocfs_num_exports_seq_show(struct seq_file *m, void *data);
728 #endif
729 struct adaptive_timeout;
730 #ifndef HAVE_ONLY_PROCFS_SEQ
731 extern int lprocfs_at_hist_helper(char *page, int count, int rc,
732                                   struct adaptive_timeout *at);
733 extern int lprocfs_rd_timeouts(char *page, char **start, off_t off,
734                                int count, int *eof, void *data);
735 extern int lprocfs_wr_timeouts(struct file *file, const char *buffer,
736                                unsigned long count, void *data);
737 #endif
738 extern int lprocfs_seq_at_hist_helper(struct seq_file *m,
739                                       struct adaptive_timeout *at);
740 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
741 extern ssize_t
742 lprocfs_timeouts_seq_write(struct file *file, const char *buffer,
743                            size_t count, loff_t *off);
744 #ifndef HAVE_ONLY_PROCFS_SEQ
745 #ifdef HAVE_SERVER_SUPPORT
746 extern ssize_t lprocfs_fops_read(struct file *f, char __user *buf,
747                                  size_t size, loff_t *ppos);
748 extern ssize_t lprocfs_fops_write(struct file *f, const char __user *buf,
749                                   size_t size, loff_t *ppos);
750 extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
751                                    unsigned long count, void *data);
752 #endif
753 extern int lprocfs_wr_ping(struct file *file, const char *buffer,
754                            unsigned long count, void *data);
755 extern int lprocfs_wr_import(struct file *file, const char *buffer,
756                              unsigned long count, void *data);
757 extern int lprocfs_rd_pinger_recov(char *page, char **start, off_t off,
758                                    int count, int *eof, void *data);
759 extern int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
760                                    unsigned long count, void *data);
761 #endif
762 #ifdef HAVE_SERVER_SUPPORT
763 extern ssize_t
764 lprocfs_evict_client_seq_write(struct file *file, const char *buffer,
765                                 size_t count, loff_t *off);
766 #endif
767 extern ssize_t
768 lprocfs_ping_seq_write(struct file *file, const char *buffer,
769                        size_t count, loff_t *off);
770 extern ssize_t
771 lprocfs_import_seq_write(struct file *file, const char *buffer,
772                          size_t count, loff_t *off);
773 extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data);
774 extern ssize_t
775 lprocfs_pinger_recov_seq_write(struct file *file, const char *buffer,
776                                size_t count, loff_t *off);
777
778 /* Statfs helpers */
779 #ifndef HAVE_ONLY_PROCFS_SEQ
780 extern int lprocfs_rd_blksize(char *page, char **start, off_t off,
781                               int count, int *eof, void *data);
782 extern int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
783                                   int count, int *eof, void *data);
784 extern int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
785                                  int count, int *eof, void *data);
786 extern int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
787                                  int count, int *eof, void *data);
788 extern int lprocfs_rd_filestotal(char *page, char **start, off_t off,
789                                  int count, int *eof, void *data);
790 extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
791                                 int count, int *eof, void *data);
792 extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
793                                  int count, int *eof, void *data);
794 #endif
795 extern int lprocfs_blksize_seq_show(struct seq_file *m, void *data);
796 extern int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data);
797 extern int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data);
798 extern int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data);
799 extern int lprocfs_filestotal_seq_show(struct seq_file *m, void *data);
800 extern int lprocfs_filesfree_seq_show(struct seq_file *m, void *data);
801
802 extern int lprocfs_write_helper(const char *buffer, unsigned long count,
803                                 int *val);
804 extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
805                                      int *val, int mult);
806 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
807 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
808                                     long val, int mult);
809 extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
810                                     __u64 *val);
811 extern int lprocfs_write_frac_u64_helper(const char *buffer,
812                                          unsigned long count,
813                                          __u64 *val, int mult);
814 char *lprocfs_find_named_value(const char *buffer, const char *name,
815                                 size_t *count);
816 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
817 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
818 void lprocfs_oh_clear(struct obd_histogram *oh);
819 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
820
821 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
822                            struct lprocfs_counter *cnt);
823
824 #ifdef HAVE_SERVER_SUPPORT
825 #ifndef HAVE_ONLY_PROCFS_SEQ
826 /* lprocfs_status.c: recovery status */
827 int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
828                                    int count, int *eof, void *data);
829 /* lprocfs_statuc.c: hash statistics */
830 int lprocfs_obd_rd_hash(char *page, char **start, off_t off,
831                         int count, int *eof, void *data);
832
833 /* lprocfs_status.c: IR factor */
834 int lprocfs_obd_rd_ir_factor(char *page, char **start, off_t off,
835                              int count, int *eof, void *data);
836 int lprocfs_obd_wr_ir_factor(struct file *file, const char *buffer,
837                              unsigned long count, void *data);
838 #endif
839 /* lprocfs_status.c: recovery status */
840 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
841
842 /* lprocfs_status.c: hash statistics */
843 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
844
845 /* lprocfs_status.c: IR factor */
846 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data);
847 ssize_t
848 lprocfs_ir_factor_seq_write(struct file *file, const char *buffer,
849                                 size_t count, loff_t *off);
850 #endif
851 extern int lprocfs_single_release(cfs_inode_t *, struct file *);
852 extern int lprocfs_seq_release(cfs_inode_t *, struct file *);
853
854 /* You must use these macros when you want to refer to
855  * the import in a client obd_device for a lprocfs entry */
856 #define LPROCFS_CLIMP_CHECK(obd) do {           \
857         typecheck(struct obd_device *, obd);    \
858         down_read(&(obd)->u.cli.cl_sem);    \
859         if ((obd)->u.cli.cl_import == NULL) {   \
860              up_read(&(obd)->u.cli.cl_sem); \
861              return -ENODEV;                    \
862         }                                       \
863 } while(0)
864 #define LPROCFS_CLIMP_EXIT(obd)                 \
865         up_read(&(obd)->u.cli.cl_sem);
866
867 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
868   proc entries; otherwise, you will define name##_seq_write function also for
869   a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
870   call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
871 #define __LPROC_SEQ_FOPS(name, custom_seq_write)                        \
872 static int name##_single_open(cfs_inode_t *inode, struct file *file)    \
873 {                                                                       \
874         LPROCFS_ENTRY_CHECK(PDE(inode));                                \
875         return single_open(file, name##_seq_show, PDE_DATA(inode));     \
876 }                                                                       \
877 struct file_operations name##_fops = {                                  \
878         .owner   = THIS_MODULE,                                         \
879         .open    = name##_single_open,                                  \
880         .read    = seq_read,                                            \
881         .write   = custom_seq_write,                                    \
882         .llseek  = seq_lseek,                                           \
883         .release = lprocfs_single_release,                              \
884 }
885
886 #define LPROC_SEQ_FOPS_RO(name)         __LPROC_SEQ_FOPS(name, NULL)
887 #define LPROC_SEQ_FOPS(name)            __LPROC_SEQ_FOPS(name, name##_seq_write)
888
889 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)                              \
890         static int name##_##type##_seq_show(struct seq_file *m, void *v)\
891         {                                                               \
892                 return lprocfs_##type##_seq_show(m, m->private);        \
893         }                                                               \
894         LPROC_SEQ_FOPS_RO(name##_##type)
895
896 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)                              \
897         static int name##_##type##_seq_show(struct seq_file *m, void *v)\
898         {                                                               \
899                 return lprocfs_##type##_seq_show(m, m->private);        \
900         }                                                               \
901         static ssize_t name##_##type##_seq_write(struct file *file,     \
902                         const char *buffer, size_t count, loff_t *off)  \
903         {                                                               \
904                 struct seq_file *seq = file->private_data;              \
905                 return lprocfs_##type##_seq_write(file, buffer,         \
906                                                 count, seq->private);   \
907         }                                                               \
908         LPROC_SEQ_FOPS(name##_##type);
909
910 #define LPROC_SEQ_FOPS_WO_TYPE(name, type)                              \
911         static ssize_t name##_##type##_write(struct file *file,         \
912                         const char *buffer, size_t count, loff_t *off)  \
913         {                                                               \
914                 return lprocfs_##type##_seq_write(file, buffer, count, off);    \
915         }                                                               \
916         static int name##_##type##_open(cfs_inode_t *inode, struct file *file)  \
917         {                                                               \
918                 return single_open(file, NULL, PDE_DATA(inode));        \
919         }                                                               \
920         struct file_operations name##_##type##_fops = {                 \
921                 .open    = name##_##type##_open,                        \
922                 .write   = name##_##type##_write,                       \
923                 .release = lprocfs_single_release,                      \
924         };
925
926 /* lproc_ptlrpc.c */
927 struct ptlrpc_request;
928 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
929
930 #ifdef HAVE_SERVER_SUPPORT
931 /* lprocfs_jobstats.c */
932 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
933                           int event, long amount);
934 void lprocfs_job_stats_fini(struct obd_device *obd);
935 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
936                            cntr_init_callback fn);
937 #ifndef HAVE_ONLY_PROCFS_SEQ
938 int lprocfs_rd_job_interval(char *page, char **start, off_t off,
939                             int count, int *eof, void *data);
940 int lprocfs_wr_job_interval(struct file *file, const char *buffer,
941                             unsigned long count, void *data);
942
943 /* lproc_status.c */
944 int lprocfs_obd_rd_recovery_time_soft(char *page, char **start, off_t off,
945                                       int count, int *eof, void *data);
946 int lprocfs_obd_wr_recovery_time_soft(struct file *file,
947                                       const char *buffer,
948                                       unsigned long count, void *data);
949 int lprocfs_obd_rd_recovery_time_hard(char *page, char **start, off_t off,
950                                       int count, int *eof, void *data);
951 int lprocfs_obd_wr_recovery_time_hard(struct file *file,
952                                       const char *buffer,
953                                       unsigned long count, void *data);
954 int lprocfs_target_rd_instance(char *page, char **start, off_t off,
955                                int count, int *eof, void *data);
956 #endif
957 int lprocfs_job_interval_seq_show(struct seq_file *m, void *data);
958 ssize_t
959 lprocfs_job_interval_seq_write(struct file *file, const char *buffer,
960                                 size_t count, loff_t *off);
961 /* lproc_status.c */
962 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data);
963 ssize_t lprocfs_recovery_time_soft_seq_write(struct file *file,
964                                                 const char *buffer,
965                                                 size_t count, loff_t *off);
966 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data);
967 ssize_t
968 lprocfs_recovery_time_hard_seq_write(struct file *file, const char *buffer,
969                                         size_t count, loff_t *off);
970 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data);
971 #endif
972 #ifndef HAVE_ONLY_PROCFS_SEQ
973 int lprocfs_obd_rd_max_pages_per_rpc(char *page, char **start, off_t off,
974                                      int count, int *eof, void *data);
975 int lprocfs_obd_wr_max_pages_per_rpc(struct file *file, const char *buffer,
976                                      unsigned long count, void *data);
977 #endif
978 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
979 ssize_t
980 lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file, const char *buffer,
981                                        size_t count, loff_t *off);
982
983 struct root_squash_info;
984 int lprocfs_wr_root_squash(const char *buffer, unsigned long count,
985                            struct root_squash_info *squash, char *name);
986 int lprocfs_wr_nosquash_nids(const char *buffer, unsigned long count,
987                              struct root_squash_info *squash, char *name);
988
989 /* all quota proc functions */
990 extern int lprocfs_quota_rd_bunit(char *page, char **start,
991                                   off_t off, int count,
992                                   int *eof, void *data);
993 extern int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
994                                   unsigned long count, void *data);
995 extern int lprocfs_quota_rd_btune(char *page, char **start,
996                                   off_t off, int count,
997                                   int *eof, void *data);
998 extern int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
999                                   unsigned long count, void *data);
1000 extern int lprocfs_quota_rd_iunit(char *page, char **start,
1001                                   off_t off, int count,
1002                                   int *eof, void *data);
1003 extern int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
1004                                   unsigned long count, void *data);
1005 extern int lprocfs_quota_rd_itune(char *page, char **start,
1006                                   off_t off, int count,
1007                                   int *eof, void *data);
1008 extern int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
1009                                   unsigned long count, void *data);
1010 extern int lprocfs_quota_rd_type(char *page, char **start, off_t off, int count,
1011                                  int *eof, void *data);
1012 extern int lprocfs_quota_wr_type(struct file *file, const char *buffer,
1013                                  unsigned long count, void *data);
1014 extern int lprocfs_quota_rd_switch_seconds(char *page, char **start, off_t off,
1015                                            int count, int *eof, void *data);
1016 extern int lprocfs_quota_wr_switch_seconds(struct file *file,
1017                                            const char *buffer,
1018                                            unsigned long count, void *data);
1019 extern int lprocfs_quota_rd_sync_blk(char *page, char **start, off_t off,
1020                                      int count, int *eof, void *data);
1021 extern int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
1022                                      unsigned long count, void *data);
1023 extern int lprocfs_quota_rd_switch_qs(char *page, char **start, off_t off,
1024                                       int count, int *eof, void *data);
1025 extern int lprocfs_quota_wr_switch_qs(struct file *file,
1026                                       const char *buffer,
1027                                       unsigned long count, void *data);
1028 extern int lprocfs_quota_rd_boundary_factor(char *page, char **start, off_t off,
1029                                             int count, int *eof, void *data);
1030 extern int lprocfs_quota_wr_boundary_factor(struct file *file,
1031                                             const char *buffer,
1032                                             unsigned long count, void *data);
1033 extern int lprocfs_quota_rd_least_bunit(char *page, char **start, off_t off,
1034                                         int count, int *eof, void *data);
1035 extern int lprocfs_quota_wr_least_bunit(struct file *file,
1036                                         const char *buffer,
1037                                         unsigned long count, void *data);
1038 extern int lprocfs_quota_rd_least_iunit(char *page, char **start, off_t off,
1039                                         int count, int *eof, void *data);
1040 extern int lprocfs_quota_wr_least_iunit(struct file *file,
1041                                         const char *buffer,
1042                                         unsigned long count, void *data);
1043 extern int lprocfs_quota_rd_qs_factor(char *page, char **start, off_t off,
1044                                       int count, int *eof, void *data);
1045 extern int lprocfs_quota_wr_qs_factor(struct file *file,
1046                                       const char *buffer,
1047                                       unsigned long count, void *data);
1048 #else
1049 /* LPROCFS is not defined */
1050
1051 #define proc_lustre_root NULL
1052
1053 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
1054                                        int index, long amount)
1055 { return; }
1056 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
1057                                         int index)
1058 { return; }
1059 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
1060                                        int index, long amount)
1061 { return; }
1062 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
1063                                         int index)
1064 { return; }
1065 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
1066                                         int index, unsigned conf,
1067                                         const char *name, const char *units)
1068 { return; }
1069
1070 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
1071                                    enum lprocfs_fields_flags field)
1072 { return 0; }
1073
1074 /* NB: we return !NULL to satisfy error checker */
1075 static inline struct lprocfs_stats *
1076 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
1077 { return (struct lprocfs_stats *)1; }
1078 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
1079 { return; }
1080 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
1081 { return; }
1082 static inline int lprocfs_register_stats(cfs_proc_dir_entry_t *root,
1083                                          const char *name,
1084                                          struct lprocfs_stats *stats)
1085 { return 0; }
1086 static inline void lprocfs_init_ops_stats(int num_private_stats,
1087                                           struct lprocfs_stats *stats)
1088 { return; }
1089 static inline void lprocfs_init_mps_stats(int num_private_stats,
1090                                           struct lprocfs_stats *stats)
1091 { return; }
1092 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
1093 { return; }
1094 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
1095                                           unsigned int num_private_stats)
1096 { return 0; }
1097 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
1098                                          unsigned int num_private_stats)
1099 { return 0; }
1100 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
1101 { return; }
1102 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
1103 { return; }
1104
1105 struct obd_export;
1106 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
1107 { return 0; }
1108 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
1109 { return; }
1110 #ifdef HAVE_SERVER_SUPPORT
1111 #ifndef HAVE_ONLY_PROCFS_SEQ
1112 static inline
1113 int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
1114                                   unsigned long count, void *data)
1115 {return count;}
1116 static inline
1117 int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off,
1118                                  int count, int *eof,  void *data)
1119 {return count;}
1120 #endif
1121 static inline
1122 ssize_t lprocfs_nid_stats_seq_write(struct file *file, const char *buffer,
1123                                         size_t count, loff_t *off)
1124 {return 0;}
1125 static inline
1126 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
1127 {return 0;}
1128 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid,
1129                                     int *newnid)
1130 { return 0; }
1131 #endif
1132 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
1133 { return 0; }
1134 static inline struct proc_dir_entry *
1135 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
1136 #ifndef HAVE_ONLY_PROCFS_SEQ
1137                    read_proc_t *read_proc, write_proc_t *write_proc,
1138 #endif
1139                    void *data, const struct file_operations *fops)
1140 {return 0; }
1141 static inline struct proc_dir_entry *
1142 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
1143                     const char *format, ...)
1144 {return NULL; }
1145 #ifndef HAVE_ONLY_PROCFS_SEQ
1146 static inline cfs_proc_dir_entry_t *
1147 lprocfs_register(const char *name, cfs_proc_dir_entry_t *parent,
1148                  struct lprocfs_vars *list, void *data)
1149 { return NULL; }
1150 static inline int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
1151                                    struct lprocfs_vars *var,
1152                                    void *data)
1153 { return 0; }
1154 #endif
1155 static inline int lprocfs_seq_add_vars(cfs_proc_dir_entry_t *root,
1156                                        struct lprocfs_seq_vars *var,
1157                                        void *data)
1158 { return 0; }
1159 static inline cfs_proc_dir_entry_t *
1160 lprocfs_seq_register(const char *name, cfs_proc_dir_entry_t *parent,
1161                      struct lprocfs_seq_vars *list, void *data)
1162 { return NULL; }
1163 static inline void lprocfs_remove(cfs_proc_dir_entry_t **root)
1164 { return; }
1165 static inline void lprocfs_remove_proc_entry(const char *name,
1166                                              struct proc_dir_entry *parent)
1167 { return; }
1168 #ifndef HAVE_ONLY_PROCFS_SEQ
1169 static inline void lprocfs_try_remove_proc_entry(const char *name,
1170                                                  struct proc_dir_entry *parent)
1171 { return; }
1172 static inline cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *head,
1173                                                  const char *name)
1174 { return 0; }
1175 static inline int lprocfs_obd_setup(struct obd_device *dev,
1176                                     struct lprocfs_vars *list)
1177 { return 0; }
1178 #endif
1179 static inline int lprocfs_seq_obd_setup(struct obd_device *dev)
1180 { return 0; }
1181 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
1182 { return 0; }
1183 static inline int lprocfs_rd_u64(char *page, char **start, off_t off,
1184                                  int count, int *eof, void *data)
1185 { return 0; }
1186 #ifndef HAVE_ONLY_PROCFS_SEQ
1187 static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
1188                                   int count, int *eof, void *data)
1189 { return 0; }
1190 static inline int lprocfs_rd_name(char *page, char **start, off_t off,
1191                                   int count, int *eof, void *data)
1192 { return 0; }
1193 static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
1194                                          int count, int *eof, void *data)
1195 { return 0; }
1196 static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
1197                                        int count, int *eof, void *data)
1198 { return 0; }
1199 static inline int lprocfs_rd_import(char *page, char **start, off_t off,
1200                                     int count, int *eof, void *data)
1201 { return 0; }
1202 static inline int lprocfs_rd_pinger_recov(char *page, char **start, off_t off,
1203                                           int count, int *eof, void *data)
1204 { return 0; }
1205 static inline int lprocfs_rd_state(char *page, char **start, off_t off,
1206                                    int count, int *eof, void *data)
1207 { return 0; }
1208 static inline int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
1209                                            int count, int *eof, void *data)
1210 { return 0; }
1211 static inline int lprocfs_rd_num_exports(char *page, char **start, off_t off,
1212                                          int count, int *eof, void *data)
1213 { return 0; }
1214 static inline int lprocfs_rd_numrefs(struct seq_file *m, void *data)
1215 { return 0; }
1216 struct adaptive_timeout;
1217 static inline int lprocfs_at_hist_helper(char *page, int count, int rc,
1218                                          struct adaptive_timeout *at)
1219 { return 0; }
1220 static inline int lprocfs_rd_timeouts(char *page, char **start, off_t off,
1221                                       int count, int *eof, void *data)
1222 { return 0; }
1223 static inline int lprocfs_wr_timeouts(struct file *file,
1224                                       const char *buffer,
1225                                       unsigned long count, void *data)
1226 { return 0; }
1227 #ifdef HAVE_SERVER_SUPPORT
1228 static inline int lprocfs_wr_evict_client(struct file *file,
1229                                           const char *buffer,
1230                                           unsigned long count, void *data)
1231 { return 0; }
1232 #endif
1233 static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
1234                                   unsigned long count, void *data)
1235 { return 0; }
1236 static inline int lprocfs_wr_import(struct file *file, const char *buffer,
1237                                     unsigned long count, void *data)
1238 { return 0; }
1239 static inline int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
1240                                     unsigned long count, void *data)
1241 { return 0; }
1242 #endif
1243 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
1244 { return 0; }
1245 static inline int lprocfs_name_seq_show(struct seq_file *m, void *data)
1246 { return 0; }
1247 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
1248 { return 0; }
1249 static inline int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data)
1250 { return 0; }
1251 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
1252 { return 0; }
1253 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
1254 { return 0; }
1255 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
1256 { return 0; }
1257 #ifdef HAVE_SERVER_SUPPORT
1258 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
1259 { return 0; }
1260 #endif
1261 struct adaptive_timeout;
1262 static inline int lprocfs_seq_at_hist_helper(struct seq_file *m,
1263                                              struct adaptive_timeout *at)
1264 { return 0; }
1265 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
1266 { return 0; }
1267 static inline ssize_t
1268 lprocfs_timeouts_seq_write(struct file *file, const char *buffer,
1269                            size_t count, loff_t *off)
1270 { return 0; }
1271 #ifdef HAVE_SERVER_SUPPORT
1272 static inline ssize_t
1273 lprocfs_evict_client_seq_write(struct file *file, const char *buffer,
1274                                size_t count, loff_t *off)
1275 { return 0; }
1276 #endif
1277 static inline ssize_t
1278 lprocfs_ping_seq_write(struct file *file, const char *buffer,
1279                        size_t count, loff_t *off)
1280 { return 0; }
1281 static inline ssize_t
1282 lprocfs_import_seq_write(struct file *file, const char *buffer,
1283                          size_t count, loff_t *off)
1284 { return 0; }
1285 static inline int
1286 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
1287 { return 0; }
1288 static inline ssize_t
1289 lprocfs_pinger_recov_seq_write(struct file *file, const char *buffer,
1290                                size_t count, loff_t *off)
1291 { return 0; }
1292
1293 /* Statfs helpers */
1294 #ifndef HAVE_ONLY_PROCFS_SEQ
1295 static inline
1296 int lprocfs_rd_blksize(char *page, char **start, off_t off,
1297                        int count, int *eof, void *data)
1298 { return 0; }
1299 static inline
1300 int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
1301                            int count, int *eof, void *data)
1302 { return 0; }
1303 static inline
1304 int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
1305                           int count, int *eof, void *data)
1306 { return 0; }
1307 static inline
1308 int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
1309                            int count, int *eof, void *data)
1310 { return 0; }
1311 static inline
1312 int lprocfs_rd_filestotal(char *page, char **start, off_t off,
1313                           int count, int *eof, void *data)
1314 { return 0; }
1315 static inline
1316 int lprocfs_rd_filesfree(char *page, char **start, off_t off,
1317                          int count, int *eof, void *data)
1318 { return 0; }
1319 #endif
1320 static inline
1321 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
1322 { return 0; }
1323 static inline
1324 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
1325 { return 0; }
1326 static inline
1327 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
1328 { return 0; }
1329 static inline
1330 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
1331 { return 0; }
1332 static inline
1333 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
1334 { return 0; }
1335 static inline
1336 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
1337 { return 0; }
1338 static inline
1339 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1340 { return; }
1341 static inline
1342 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1343 { return; }
1344 static inline
1345 void lprocfs_oh_clear(struct obd_histogram *oh)
1346 { return; }
1347 static inline
1348 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1349 { return 0; }
1350 static inline
1351 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1352                            struct lprocfs_counter *cnt)
1353 { return; }
1354 static inline
1355 __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1356                                enum lprocfs_fields_flags field)
1357 { return (__u64)0; }
1358
1359 #define LPROC_SEQ_FOPS_RO(name)
1360 #define LPROC_SEQ_FOPS(name)
1361 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
1362 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
1363 #define LPROC_SEQ_FOPS_WO_TYPE(name, type)
1364
1365 /* lprocfs_jobstats.c */
1366 static inline
1367 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1368                           long amount)
1369 { return 0; }
1370 static inline
1371 void lprocfs_job_stats_fini(struct obd_device *obd)
1372 { return; }
1373 static inline
1374 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1375                            cntr_init_callback fn)
1376 { return 0; }
1377
1378
1379 /* lproc_ptlrpc.c */
1380 #define target_print_req NULL
1381
1382 #endif /* LPROCFS */
1383
1384 #endif /* LPROCFS_SNMP_H */