Whamcloud - gitweb
b=14687
[fs/lustre-release.git] / lustre / include / lprocfs_status.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  *   Top level header file for LProc SNMP
22  *   Author: Hariharan Thantry thantry@users.sourceforge.net
23  */
24 #ifndef _LPROCFS_SNMP_H
25 #define _LPROCFS_SNMP_H
26
27 #include <lustre/lustre_idl.h>
28 #if defined(__linux__)
29 #include <linux/lprocfs_status.h>
30 #elif defined(__APPLE__)
31 #include <darwin/lprocfs_status.h>
32 #elif defined(__WINNT__)
33 #include <winnt/lprocfs_status.h>
34 #else
35 #error Unsupported operating system.
36 #endif
37
38 #undef LPROCFS
39 #if (defined(__KERNEL__) && defined(CONFIG_PROC_FS))
40 # define LPROCFS
41 #endif
42
43 struct lprocfs_vars {
44         const char   *name;
45         cfs_read_proc_t *read_fptr;
46         cfs_write_proc_t *write_fptr;
47         void *data;
48         struct file_operations *fops;
49 };
50
51 struct lprocfs_static_vars {
52         struct lprocfs_vars *module_vars;
53         struct lprocfs_vars *obd_vars;
54 };
55
56 /* if we find more consumers this could be generalized */
57 #define OBD_HIST_MAX 32
58 struct obd_histogram {
59         spinlock_t      oh_lock;
60         unsigned long   oh_buckets[OBD_HIST_MAX];
61 };
62
63 enum {
64         BRW_R_PAGES = 0,
65         BRW_W_PAGES,
66         BRW_R_RPC_HIST,
67         BRW_W_RPC_HIST,
68         BRW_R_IO_TIME,
69         BRW_W_IO_TIME,
70         BRW_R_DISCONT_PAGES,
71         BRW_W_DISCONT_PAGES,
72         BRW_R_DISCONT_BLOCKS,
73         BRW_W_DISCONT_BLOCKS,
74         BRW_R_DISK_IOSIZE,
75         BRW_W_DISK_IOSIZE,
76         BRW_R_DIO_FRAGS,
77         BRW_W_DIO_FRAGS,
78         BRW_LAST,
79 };
80
81 struct brw_stats {
82         struct obd_histogram hist[BRW_LAST];
83 };
84
85
86 /* An lprocfs counter can be configured using the enum bit masks below.
87  *
88  * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
89  * protects this counter from concurrent updates. If not specified,
90  * lprocfs an internal per-counter lock variable. External locks are
91  * not used to protect counter increments, but are used to protect
92  * counter readout and resets.
93  *
94  * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
95  * (i.e. counter can be incremented by more than "1"). When specified,
96  * the counter maintains min, max and sum in addition to a simple
97  * invocation count. This allows averages to be be computed.
98  * If not specified, the counter is an increment-by-1 counter.
99  * min, max, sum, etc. are not maintained.
100  *
101  * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
102  * squares (for multi-valued counter samples only). This allows
103  * external computation of standard deviation, but involves a 64-bit
104  * multiply per counter increment.
105  */
106
107 enum {
108         LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
109         LPROCFS_CNTR_AVGMINMAX    = 0x0002,
110         LPROCFS_CNTR_STDDEV       = 0x0004,
111
112         /* counter data type */
113         LPROCFS_TYPE_REGS         = 0x0100,
114         LPROCFS_TYPE_BYTES        = 0x0200,
115         LPROCFS_TYPE_PAGES        = 0x0400,
116         LPROCFS_TYPE_CYCLE        = 0x0800,
117 };
118
119 struct lprocfs_atomic {
120         atomic_t               la_entry;
121         atomic_t               la_exit;
122 };
123
124 struct lprocfs_counter {
125         struct lprocfs_atomic  lc_cntl;  /* may need to move to per set */
126         unsigned int           lc_config;
127         __s64                  lc_count;
128         __s64                  lc_sum;
129         __s64                  lc_min;
130         __s64                  lc_max;
131         __s64                  lc_sumsquare;
132         const char            *lc_name;   /* must be static */
133         const char            *lc_units;  /* must be static */
134 };
135
136 struct lprocfs_percpu {
137         struct lprocfs_counter lp_cntr[0];
138 };
139
140 #define LPROCFS_GET_NUM_CPU 0x0001
141 #define LPROCFS_GET_SMP_ID  0x0002
142
143 enum lprocfs_stats_flags {
144         LPROCFS_STATS_FLAG_PERCPU   = 0x0000, /* per cpu counter */
145         LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
146                                                * area and need locking */
147 };
148
149 enum lprocfs_fields_flags {
150         LPROCFS_FIELDS_FLAGS_CONFIG     = 0x0001,
151         LPROCFS_FIELDS_FLAGS_SUM        = 0x0002,
152         LPROCFS_FIELDS_FLAGS_MIN        = 0x0003,
153         LPROCFS_FIELDS_FLAGS_MAX        = 0x0004,
154         LPROCFS_FIELDS_FLAGS_AVG        = 0x0005,
155         LPROCFS_FIELDS_FLAGS_SUMSQUARE  = 0x0006,
156         LPROCFS_FIELDS_FLAGS_COUNT      = 0x0007,
157 };
158
159 struct lprocfs_stats {
160         unsigned int           ls_num;     /* # of counters */
161         unsigned int           ls_percpu_size;
162         int                    ls_flags; /* See LPROCFS_STATS_FLAG_* */
163         spinlock_t             ls_lock;  /* Lock used only when there are
164                                           * no percpu stats areas */
165         struct lprocfs_percpu *ls_percpu[0];
166 };
167
168 static inline int opcode_offset(__u32 opc) {
169         if (opc < OST_LAST_OPC) {
170                  /* OST opcode */
171                 return (opc - OST_FIRST_OPC);
172         } else if (opc < MDS_LAST_OPC) {
173                 /* MDS opcode */
174                 return (opc - MDS_FIRST_OPC +
175                         (OST_LAST_OPC - OST_FIRST_OPC));
176         } else if (opc < LDLM_LAST_OPC) {
177                 /* LDLM Opcode */
178                 return (opc - LDLM_FIRST_OPC +
179                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
180                         (OST_LAST_OPC - OST_FIRST_OPC));
181         } else if (opc < MGS_LAST_OPC) {
182                 /* MGS Opcode */
183                 return (opc - MGS_FIRST_OPC +
184                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
185                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
186                         (OST_LAST_OPC - OST_FIRST_OPC));
187         } else if (opc < OBD_LAST_OPC) {
188                 /* OBD Ping */
189                 return (opc - OBD_FIRST_OPC +
190                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
191                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
192                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
193                         (OST_LAST_OPC - OST_FIRST_OPC));
194         } else if (opc < LLOG_LAST_OPC) {
195                 /* LLOG Opcode */
196                 return (opc - LLOG_FIRST_OPC +
197                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
198                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
199                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
200                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
201                         (OST_LAST_OPC - OST_FIRST_OPC));
202 } else if (opc < FLD_LAST_OPC) {
203                 /* FLD opcode */
204                 return (opc - FLD_FIRST_OPC +
205                         (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
206                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
207                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
208                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
209                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
210                         (OST_LAST_OPC - OST_FIRST_OPC));
211         } else if (opc < SEQ_LAST_OPC) {
212                 /* SEQ opcode */
213                 return (opc - SEQ_FIRST_OPC +
214                         (FLD_LAST_OPC - FLD_FIRST_OPC) +
215                         (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
216                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
217                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
218                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
219                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
220                         (OST_LAST_OPC - OST_FIRST_OPC));
221         } else if (opc < SEC_LAST_OPC) {
222                 /* SEC opcode */
223                 return (opc - SEC_FIRST_OPC +
224                         (SEQ_LAST_OPC - SEQ_FIRST_OPC) +
225                         (FLD_LAST_OPC - FLD_FIRST_OPC) +
226                         (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
227                         (OBD_LAST_OPC - OBD_FIRST_OPC) +
228                         (MGS_LAST_OPC - MGS_FIRST_OPC) +
229                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
230                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
231                         (OST_LAST_OPC - OST_FIRST_OPC));
232         } else {
233                 /* Unknown Opcode */
234                 return -1;
235         }
236 }
237
238 #define LUSTRE_MAX_OPCODES ((LDLM_LAST_OPC - LDLM_FIRST_OPC)   + \
239                             (MDS_LAST_OPC - MDS_FIRST_OPC)     + \
240                             (OST_LAST_OPC - OST_FIRST_OPC)     + \
241                             (OBD_LAST_OPC - OBD_FIRST_OPC)     + \
242                             (FLD_LAST_OPC - FLD_FIRST_OPC)     + \
243                             (SEQ_LAST_OPC - SEQ_FIRST_OPC)     + \
244                             (MGS_LAST_OPC - MGS_FIRST_OPC)     + \
245                             (LLOG_LAST_OPC - LLOG_FIRST_OPC)   + \
246                             (SEC_LAST_OPC - SEC_FIRST_OPC))
247
248 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR)  + \
249                            (EXTRA_LAST_OPC - EXTRA_FIRST_OPC))
250
251 enum {
252         PTLRPC_REQWAIT_CNTR = 0,
253         PTLRPC_REQQDEPTH_CNTR,
254         PTLRPC_REQACTIVE_CNTR,
255         PTLRPC_TIMEOUT,
256         PTLRPC_REQBUF_AVAIL_CNTR,
257         PTLRPC_LAST_CNTR
258 };
259
260 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
261
262 enum {
263         LDLM_GLIMPSE_ENQUEUE = 0,
264         LDLM_PLAIN_ENQUEUE,
265         LDLM_EXTENT_ENQUEUE,
266         LDLM_FLOCK_ENQUEUE,
267         LDLM_IBITS_ENQUEUE,
268         MDS_REINT_CREATE,
269         MDS_REINT_LINK,
270         MDS_REINT_OPEN,
271         MDS_REINT_SETATTR,
272         MDS_REINT_RENAME,
273         MDS_REINT_UNLINK,
274         EXTRA_LAST_OPC
275 };
276
277 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
278 /* class_obd.c */
279 extern cfs_proc_dir_entry_t *proc_lustre_root;
280
281 struct obd_device;
282 struct file;
283 struct obd_histogram;
284
285 #ifdef LPROCFS
286
287 static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int type)
288 {
289         int rc = 0;
290
291         if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
292                 if (type & LPROCFS_GET_NUM_CPU)
293                         rc = 1;
294                 if (type & LPROCFS_GET_SMP_ID)
295                         rc = 0;
296                 spin_lock(&stats->ls_lock);
297         } else {
298                 if (type & LPROCFS_GET_NUM_CPU)
299                         rc = num_possible_cpus();
300                 if (type & LPROCFS_GET_SMP_ID)
301                         rc = smp_processor_id();
302         }
303         return rc;
304 }
305
306 static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats)
307 {
308         if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU)
309                 spin_unlock(&stats->ls_lock);
310 }
311
312 /* Two optimized LPROCFS counter increment functions are provided:
313  *     lprocfs_counter_incr(cntr, value) - optimized for by-one counters
314  *     lprocfs_counter_add(cntr) - use for multi-valued counters
315  * Counter data layout allows config flag, counter lock and the
316  * count itself to reside within a single cache line.
317  */
318
319 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
320                                 long amount);
321 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
322                                 long amount);
323
324 #define lprocfs_counter_incr(stats, idx) \
325         lprocfs_counter_add(stats, idx, 1)
326 #define lprocfs_counter_decr(stats, idx) \
327         lprocfs_counter_sub(stats, idx, 1)
328
329 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc, 
330                                  enum lprocfs_fields_flags field);
331 static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, 
332                                             int idx, 
333                                             enum lprocfs_fields_flags field)
334 {
335         __u64 ret = 0;
336         int i;
337
338         LASSERT(stats != NULL);
339         for (i = 0; i < num_possible_cpus(); i++)
340                 ret += lprocfs_read_helper(&(stats->ls_percpu[i]->lp_cntr[idx]),
341                                            field);
342         return ret;
343 }
344
345 extern struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num,
346                                                  enum lprocfs_stats_flags flags);
347 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
348 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
349 extern void lprocfs_init_ops_stats(int num_private_stats, 
350                                    struct lprocfs_stats *stats);
351 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
352                                    unsigned int num_private_stats);
353 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
354                                  unsigned conf, const char *name,
355                                  const char *units);
356 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
357 struct obd_export;
358 struct nid_stat;
359 extern int lprocfs_add_clear_entry(struct obd_device * obd,
360                                    cfs_proc_dir_entry_t *entry);
361 extern int lprocfs_exp_setup(struct obd_export *exp,
362                              lnet_nid_t *peer_nid, int *newnid);
363 extern int lprocfs_exp_cleanup(struct obd_export *exp);
364 extern int lprocfs_add_simple(struct proc_dir_entry *root,
365                               char *name, read_proc_t *read_proc,
366                               write_proc_t *write_proc, void *data);
367 extern struct proc_dir_entry *lprocfs_add_symlink(const char *name,
368                         struct proc_dir_entry *parent, const char *dest);
369 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
370 extern int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
371                                          unsigned long count, void *data);
372 extern int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off,
373                                         int count, int *eof,  void *data);
374
375 extern int lprocfs_register_stats(cfs_proc_dir_entry_t *root, const char *name,
376                                   struct lprocfs_stats *stats);
377
378 /* lprocfs_status.c */
379 extern int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
380                             struct lprocfs_vars *var,
381                             void *data);
382
383 extern cfs_proc_dir_entry_t *lprocfs_register(const char *name,
384                                                cfs_proc_dir_entry_t *parent,
385                                                struct lprocfs_vars *list,
386                                                void *data);
387
388 extern void lprocfs_remove(cfs_proc_dir_entry_t **root);
389 extern void lprocfs_remove_proc_entry(const char *name,
390                                       struct proc_dir_entry *parent);
391
392 extern cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *root,
393                                            const char *name);
394
395 extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
396 extern int lprocfs_obd_cleanup(struct obd_device *obd);
397 extern int lprocfs_add_simple(struct proc_dir_entry *root, char *name,
398                               read_proc_t *read_proc, write_proc_t *write_proc,
399                               void *data);
400 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
401 extern struct file_operations lprocfs_evict_client_fops;
402
403 extern int lprocfs_seq_create(cfs_proc_dir_entry_t *parent, char *name, 
404                               mode_t mode, struct file_operations *seq_fops,
405                               void *data);
406 extern int lprocfs_obd_seq_create(struct obd_device *dev, char *name,
407                                   mode_t mode, struct file_operations *seq_fops,
408                                   void *data);
409
410 /* Generic callbacks */
411
412 extern int lprocfs_rd_u64(char *page, char **start, off_t off,
413                           int count, int *eof, void *data);
414 extern int lprocfs_rd_atomic(char *page, char **start, off_t off,
415                              int count, int *eof, void *data);
416 extern int lprocfs_wr_atomic(struct file *file, const char *buffer,
417                              unsigned long count, void *data);
418 extern int lprocfs_rd_uint(char *page, char **start, off_t off,
419                            int count, int *eof, void *data);
420 extern int lprocfs_wr_uint(struct file *file, const char *buffer,
421                            unsigned long count, void *data);
422 extern int lprocfs_rd_uuid(char *page, char **start, off_t off,
423                            int count, int *eof, void *data);
424 extern int lprocfs_rd_name(char *page, char **start, off_t off,
425                            int count, int *eof, void *data);
426 extern int lprocfs_rd_fstype(char *page, char **start, off_t off,
427                              int count, int *eof, void *data);
428 extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
429                                   int count, int *eof, void *data);
430 extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
431                                 int count, int *eof, void *data);
432 extern int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
433                                     int count, int *eof, void *data);
434 extern int lprocfs_rd_num_exports(char *page, char **start, off_t off,
435                                   int count, int *eof, void *data);
436 extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
437                               int count, int *eof, void *data);
438 extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
439                                    unsigned long count, void *data);
440 extern int lprocfs_wr_ping(struct file *file, const char *buffer,
441                            unsigned long count, void *data);
442
443 /* Statfs helpers */
444 extern int lprocfs_rd_blksize(char *page, char **start, off_t off,
445                               int count, int *eof, void *data);
446 extern int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
447                                   int count, int *eof, void *data);
448 extern int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
449                                  int count, int *eof, void *data);
450 extern int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
451                                  int count, int *eof, void *data);
452 extern int lprocfs_rd_filestotal(char *page, char **start, off_t off,
453                                  int count, int *eof, void *data);
454 extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
455                                 int count, int *eof, void *data);
456 extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
457                                  int count, int *eof, void *data);
458
459 extern int lprocfs_write_helper(const char *buffer, unsigned long count,
460                                 int *val);
461 extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
462                                      int *val, int mult);
463 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count, 
464                                     long val, int mult);
465 extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
466                                     __u64 *val);
467 extern int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
468                                          __u64 *val, int mult);
469 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
470 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
471 void lprocfs_oh_clear(struct obd_histogram *oh);
472 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
473
474 /* lprocfs_status.c: counter read/write functions */
475 extern int lprocfs_counter_read(char *page, char **start, off_t off,
476                                 int count, int *eof, void *data);
477 extern int lprocfs_counter_write(struct file *file, const char *buffer,
478                                  unsigned long count, void *data);
479
480 /* lprocfs_status.c: recovery status */
481 int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
482                                    int count, int *eof, void *data);
483
484 extern int lprocfs_seq_release(struct inode *, struct file *);
485
486 /* in lprocfs_stat.c, to protect the private data for proc entries */
487 extern struct rw_semaphore _lprocfs_lock;
488 #define LPROCFS_ENTRY()           do {  \
489         down_read(&_lprocfs_lock);      \
490 } while(0)
491 #define LPROCFS_EXIT()            do {  \
492         up_read(&_lprocfs_lock);        \
493 } while(0)
494 #define LPROCFS_ENTRY_AND_CHECK(dp) do {        \
495         typecheck(struct proc_dir_entry *, dp); \
496         LPROCFS_ENTRY();                        \
497         if ((dp)->deleted) {                    \
498                 LPROCFS_EXIT();                 \
499                 return -ENODEV;                 \
500         }                                       \
501 } while(0)
502
503 /* You must use these macros when you want to refer to 
504  * the import in a client obd_device for a lprocfs entry */
505 #define LPROCFS_CLIMP_CHECK(obd) do {           \
506         typecheck(struct obd_device *, obd);    \
507         mutex_down(&(obd)->u.cli.cl_sem);       \
508         if ((obd)->u.cli.cl_import == NULL) {   \
509              mutex_up(&(obd)->u.cli.cl_sem);    \
510              return -ENODEV;                    \
511         }                                       \
512 } while(0)
513 #define LPROCFS_CLIMP_EXIT(obd)                 \
514         mutex_up(&(obd)->u.cli.cl_sem);
515
516
517 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only 
518   proc entries; otherwise, you will define name##_seq_write function also for 
519   a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
520   call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
521 #define __LPROC_SEQ_FOPS(name, custom_seq_write)                           \
522 static int name##_seq_open(struct inode *inode, struct file *file) {       \
523         struct proc_dir_entry *dp = PDE(inode);                            \
524         int rc;                                                            \
525         LPROCFS_ENTRY_AND_CHECK(dp);                                       \
526         rc = single_open(file, name##_seq_show, dp->data);                 \
527         if (rc) {                                                          \
528                 LPROCFS_EXIT();                                            \
529                 return rc;                                                 \
530         }                                                                  \
531         return 0;                                                          \
532 }                                                                          \
533 struct file_operations name##_fops = {                                     \
534         .owner   = THIS_MODULE,                                            \
535         .open    = name##_seq_open,                                        \
536         .read    = seq_read,                                               \
537         .write   = custom_seq_write,                                       \
538         .llseek  = seq_lseek,                                              \
539         .release = lprocfs_seq_release,                                    \
540 }
541
542 #define LPROC_SEQ_FOPS_RO(name)         __LPROC_SEQ_FOPS(name, NULL)
543 #define LPROC_SEQ_FOPS(name)            __LPROC_SEQ_FOPS(name, name##_seq_write)
544
545 /* lprocfs_status.c: read recovery max time bz13079 */
546 int lprocfs_obd_rd_recovery_maxtime(char *page, char **start, off_t off,
547                                     int count, int *eof, void *data);
548
549 /* lprocfs_status.c: write recovery max time bz13079 */
550 int lprocfs_obd_wr_recovery_maxtime(struct file *file, const char *buffer,
551                                     unsigned long count, void *data);
552 #else
553 /* LPROCFS is not defined */
554 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
555                                        int index, long amount) { return; }
556 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
557                                         int index) { return; }
558 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
559                                        int index, long amount) { return; }
560 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
561                                         int index, unsigned conf,
562                                         const char *name, const char *units)
563 { return; }
564
565 static inline __u64 lc_read_helper(struct lprocfs_counter *lc, 
566                                    enum lprocfs_fields_flags field) 
567 { return 0; }
568
569 static inline struct lprocfs_stats* lprocfs_alloc_stats(unsigned int num,
570                                                         enum lprocfs_stats_flags flags)
571 { return NULL; }
572 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
573 { return; }
574 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
575 { return; }
576 static inline int lprocfs_register_stats(cfs_proc_dir_entry_t *root,
577                                             const char *name,
578                                             struct lprocfs_stats *stats)
579 { return 0; }
580 static inline void lprocfs_init_ops_stats(int num_private_stats, 
581                                           struct lprocfs_stats *stats)
582 { return; }
583 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
584                                              unsigned int num_private_stats)
585 { return 0; }
586 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
587 { return; }
588
589 struct obd_export;
590 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
591 { return 0; }
592 static inline int lprocfs_exp_setup(struct obd_export *exp,
593                                     lnet_nid_t *peer_nid, int *newnid)
594 { return 0; }
595 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
596 { return 0; }
597 static inline int lprocfs_add_simple(struct proc_dir_entry *root,
598                                      char *name,
599                                      read_proc_t *read_proc,
600                                      write_proc_t *write_proc,
601                                      void *data)
602 {return 0; }
603 static inline struct proc_dir_entry *lprocfs_add_symlink(const char *name,
604                         struct proc_dir_entry *parent, const char *dest)
605 {return NULL; }
606 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
607 {}
608 static inline
609 int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
610                                   unsigned long count, void *data)
611 {return count;}
612 static inline
613 int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off,
614                                  int count, int *eof,  void *data)
615 {return count;}
616
617 static inline cfs_proc_dir_entry_t *
618 lprocfs_register(const char *name, cfs_proc_dir_entry_t *parent,
619                  struct lprocfs_vars *list, void *data) { return NULL; }
620 static inline int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
621                                    struct lprocfs_vars *var,
622                                    void *data) { return 0; }
623 static inline void lprocfs_remove(cfs_proc_dir_entry_t **root) {};
624 static inline void lprocfs_remove_proc_entry(const char *name,
625                                              struct proc_dir_entry *parent) {};
626 static inline cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *head,
627                                     const char *name) {return 0;}
628 static inline int lprocfs_obd_setup(struct obd_device *dev,
629                                     struct lprocfs_vars *list) { return 0; }
630 static inline int lprocfs_obd_cleanup(struct obd_device *dev)  { return 0; }
631 static inline int lprocfs_rd_u64(char *page, char **start, off_t off,
632                                  int count, int *eof, void *data) { return 0; }
633 static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
634                                   int count, int *eof, void *data) { return 0; }
635 static inline int lprocfs_rd_name(char *page, char **start, off_t off,
636                                   int count, int *eof, void *data) { return 0; }
637 static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
638                                          int count, int *eof, void *data)
639 { return 0; }
640 static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
641                                        int count, int *eof, void *data)
642 { return 0; }
643 static inline int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
644                                            int count, int *eof, void *data)
645 { return 0; }
646 static inline int lprocfs_rd_num_exports(char *page, char **start, off_t off,
647                                          int count, int *eof, void *data)
648 { return 0; }
649 static inline int lprocfs_rd_numrefs(char *page, char **start, off_t off,
650                                      int count, int *eof, void *data)
651 { return 0; }
652 static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer,
653                                           unsigned long count, void *data)
654 { return 0; }
655 static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
656                                   unsigned long count, void *data)
657 { return 0; }
658
659
660 /* Statfs helpers */
661 static inline
662 int lprocfs_rd_blksize(char *page, char **start, off_t off,
663                        int count, int *eof, void *data) { return 0; }
664 static inline
665 int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
666                            int count, int *eof, void *data) { return 0; }
667 static inline
668 int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
669                           int count, int *eof, void *data) { return 0; }
670 static inline
671 int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
672                            int count, int *eof, void *data) { return 0; }
673 static inline
674 int lprocfs_rd_filestotal(char *page, char **start, off_t off,
675                           int count, int *eof, void *data) { return 0; }
676 static inline
677 int lprocfs_rd_filesfree(char *page, char **start, off_t off,
678                          int count, int *eof, void *data)  { return 0; }
679 static inline
680 int lprocfs_rd_filegroups(char *page, char **start, off_t off,
681                           int count, int *eof, void *data) { return 0; }
682 static inline
683 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value) {}
684 static inline
685 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value) {}
686 static inline
687 void lprocfs_oh_clear(struct obd_histogram *oh) {}
688 static inline
689 unsigned long lprocfs_oh_sum(struct obd_histogram *oh) { return 0; }
690 static inline
691 int lprocfs_counter_read(char *page, char **start, off_t off,
692                          int count, int *eof, void *data) { return 0; }
693 static inline
694 int lprocfs_counter_write(struct file *file, const char *buffer,
695                           unsigned long count, void *data) { return 0; }
696
697 static inline
698 __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, 
699                                enum lprocfs_fields_flags field)
700 { return (__u64)0; }
701
702 #define LPROCFS_ENTRY()
703 #define LPROCFS_EXIT()
704 #define LPROCFS_ENTRY_AND_CHECK(dp)
705 #define LPROC_SEQ_FOPS_RO(name)
706 #define LPROC_SEQ_FOPS(name)
707
708 #endif /* LPROCFS */
709
710 #endif /* LPROCFS_SNMP_H */