staging: lustre: remove top level ccflags variable
[deliverable/linux.git] / drivers / staging / lustre / 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, 2012, Intel Corporation.
31 */
32 /*
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
35 *
36 * lustre/include/lprocfs_status.h
37 *
38 * Top level header file for LProc SNMP
39 *
40 * Author: Hariharan Thantry thantry@users.sourceforge.net
41 */
42 #ifndef _LPROCFS_SNMP_H
43 #define _LPROCFS_SNMP_H
44
45 #include <linux/lprocfs_status.h>
46 #include <lustre/lustre_idl.h>
47 #include "../../include/linux/libcfs/params_tree.h"
48
49 struct lprocfs_vars {
50 const char *name;
51 struct file_operations *fops;
52 void *data;
53 /**
54 * /proc file mode.
55 */
56 umode_t proc_mode;
57 };
58
59 struct lprocfs_static_vars {
60 struct lprocfs_vars *module_vars;
61 struct lprocfs_vars *obd_vars;
62 };
63
64 /* if we find more consumers this could be generalized */
65 #define OBD_HIST_MAX 32
66 struct obd_histogram {
67 spinlock_t oh_lock;
68 unsigned long oh_buckets[OBD_HIST_MAX];
69 };
70
71 enum {
72 BRW_R_PAGES = 0,
73 BRW_W_PAGES,
74 BRW_R_RPC_HIST,
75 BRW_W_RPC_HIST,
76 BRW_R_IO_TIME,
77 BRW_W_IO_TIME,
78 BRW_R_DISCONT_PAGES,
79 BRW_W_DISCONT_PAGES,
80 BRW_R_DISCONT_BLOCKS,
81 BRW_W_DISCONT_BLOCKS,
82 BRW_R_DISK_IOSIZE,
83 BRW_W_DISK_IOSIZE,
84 BRW_R_DIO_FRAGS,
85 BRW_W_DIO_FRAGS,
86 BRW_LAST,
87 };
88
89 struct brw_stats {
90 struct obd_histogram hist[BRW_LAST];
91 };
92
93 enum {
94 RENAME_SAMEDIR_SIZE = 0,
95 RENAME_CROSSDIR_SRC_SIZE,
96 RENAME_CROSSDIR_TGT_SIZE,
97 RENAME_LAST,
98 };
99
100 struct rename_stats {
101 struct obd_histogram hist[RENAME_LAST];
102 };
103
104 /* An lprocfs counter can be configured using the enum bit masks below.
105 *
106 * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
107 * protects this counter from concurrent updates. If not specified,
108 * lprocfs an internal per-counter lock variable. External locks are
109 * not used to protect counter increments, but are used to protect
110 * counter readout and resets.
111 *
112 * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
113 * (i.e. counter can be incremented by more than "1"). When specified,
114 * the counter maintains min, max and sum in addition to a simple
115 * invocation count. This allows averages to be be computed.
116 * If not specified, the counter is an increment-by-1 counter.
117 * min, max, sum, etc. are not maintained.
118 *
119 * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
120 * squares (for multi-valued counter samples only). This allows
121 * external computation of standard deviation, but involves a 64-bit
122 * multiply per counter increment.
123 */
124
125 enum {
126 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
127 LPROCFS_CNTR_AVGMINMAX = 0x0002,
128 LPROCFS_CNTR_STDDEV = 0x0004,
129
130 /* counter data type */
131 LPROCFS_TYPE_REGS = 0x0100,
132 LPROCFS_TYPE_BYTES = 0x0200,
133 LPROCFS_TYPE_PAGES = 0x0400,
134 LPROCFS_TYPE_CYCLE = 0x0800,
135 };
136
137 #define LC_MIN_INIT ((~(__u64)0) >> 1)
138
139 struct lprocfs_counter_header {
140 unsigned int lc_config;
141 const char *lc_name; /* must be static */
142 const char *lc_units; /* must be static */
143 };
144
145 struct lprocfs_counter {
146 __s64 lc_count;
147 __s64 lc_min;
148 __s64 lc_max;
149 __s64 lc_sumsquare;
150 /*
151 * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
152 * for irq context counter, i.e. stats with
153 * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
154 * lc_array_sum[1]
155 */
156 __s64 lc_array_sum[1];
157 };
158 #define lc_sum lc_array_sum[0]
159 #define lc_sum_irq lc_array_sum[1]
160
161 struct lprocfs_percpu {
162 #ifndef __GNUC__
163 __s64 pad;
164 #endif
165 struct lprocfs_counter lp_cntr[0];
166 };
167
168 #define LPROCFS_GET_NUM_CPU 0x0001
169 #define LPROCFS_GET_SMP_ID 0x0002
170
171 enum lprocfs_stats_flags {
172 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
173 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
174 * area and need locking */
175 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
176 };
177
178 enum lprocfs_fields_flags {
179 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
180 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
181 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
182 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
183 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
184 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
185 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
186 };
187
188 struct lprocfs_stats {
189 /* # of counters */
190 unsigned short ls_num;
191 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
192 unsigned short ls_biggest_alloc_num;
193 enum lprocfs_stats_flags ls_flags;
194 /* Lock used when there are no percpu stats areas; For percpu stats,
195 * it is used to protect ls_biggest_alloc_num change */
196 spinlock_t ls_lock;
197
198 /* has ls_num of counter headers */
199 struct lprocfs_counter_header *ls_cnt_header;
200 struct lprocfs_percpu *ls_percpu[0];
201 };
202
203 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
204
205 /* Pack all opcodes down into a single monotonically increasing index */
206 static inline int opcode_offset(__u32 opc) {
207 if (opc < OST_LAST_OPC) {
208 /* OST opcode */
209 return (opc - OST_FIRST_OPC);
210 } else if (opc < MDS_LAST_OPC) {
211 /* MDS opcode */
212 return (opc - MDS_FIRST_OPC +
213 OPC_RANGE(OST));
214 } else if (opc < LDLM_LAST_OPC) {
215 /* LDLM Opcode */
216 return (opc - LDLM_FIRST_OPC +
217 OPC_RANGE(MDS) +
218 OPC_RANGE(OST));
219 } else if (opc < MGS_LAST_OPC) {
220 /* MGS Opcode */
221 return (opc - MGS_FIRST_OPC +
222 OPC_RANGE(LDLM) +
223 OPC_RANGE(MDS) +
224 OPC_RANGE(OST));
225 } else if (opc < OBD_LAST_OPC) {
226 /* OBD Ping */
227 return (opc - OBD_FIRST_OPC +
228 OPC_RANGE(MGS) +
229 OPC_RANGE(LDLM) +
230 OPC_RANGE(MDS) +
231 OPC_RANGE(OST));
232 } else if (opc < LLOG_LAST_OPC) {
233 /* LLOG Opcode */
234 return (opc - LLOG_FIRST_OPC +
235 OPC_RANGE(OBD) +
236 OPC_RANGE(MGS) +
237 OPC_RANGE(LDLM) +
238 OPC_RANGE(MDS) +
239 OPC_RANGE(OST));
240 } else if (opc < QUOTA_LAST_OPC) {
241 /* LQUOTA Opcode */
242 return (opc - QUOTA_FIRST_OPC +
243 OPC_RANGE(LLOG) +
244 OPC_RANGE(OBD) +
245 OPC_RANGE(MGS) +
246 OPC_RANGE(LDLM) +
247 OPC_RANGE(MDS) +
248 OPC_RANGE(OST));
249 } else if (opc < SEQ_LAST_OPC) {
250 /* SEQ opcode */
251 return (opc - SEQ_FIRST_OPC +
252 OPC_RANGE(QUOTA) +
253 OPC_RANGE(LLOG) +
254 OPC_RANGE(OBD) +
255 OPC_RANGE(MGS) +
256 OPC_RANGE(LDLM) +
257 OPC_RANGE(MDS) +
258 OPC_RANGE(OST));
259 } else if (opc < SEC_LAST_OPC) {
260 /* SEC opcode */
261 return (opc - SEC_FIRST_OPC +
262 OPC_RANGE(SEQ) +
263 OPC_RANGE(QUOTA) +
264 OPC_RANGE(LLOG) +
265 OPC_RANGE(OBD) +
266 OPC_RANGE(MGS) +
267 OPC_RANGE(LDLM) +
268 OPC_RANGE(MDS) +
269 OPC_RANGE(OST));
270 } else if (opc < FLD_LAST_OPC) {
271 /* FLD opcode */
272 return (opc - FLD_FIRST_OPC +
273 OPC_RANGE(SEC) +
274 OPC_RANGE(SEQ) +
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 < UPDATE_LAST_OPC) {
283 /* update opcode */
284 return (opc - UPDATE_FIRST_OPC +
285 OPC_RANGE(FLD) +
286 OPC_RANGE(SEC) +
287 OPC_RANGE(SEQ) +
288 OPC_RANGE(QUOTA) +
289 OPC_RANGE(LLOG) +
290 OPC_RANGE(OBD) +
291 OPC_RANGE(MGS) +
292 OPC_RANGE(LDLM) +
293 OPC_RANGE(MDS) +
294 OPC_RANGE(OST));
295 } else {
296 /* Unknown Opcode */
297 return -1;
298 }
299 }
300
301
302 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
303 OPC_RANGE(MDS) + \
304 OPC_RANGE(LDLM) + \
305 OPC_RANGE(MGS) + \
306 OPC_RANGE(OBD) + \
307 OPC_RANGE(LLOG) + \
308 OPC_RANGE(SEC) + \
309 OPC_RANGE(SEQ) + \
310 OPC_RANGE(SEC) + \
311 OPC_RANGE(FLD) + \
312 OPC_RANGE(UPDATE))
313
314 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
315 OPC_RANGE(EXTRA))
316
317 enum {
318 PTLRPC_REQWAIT_CNTR = 0,
319 PTLRPC_REQQDEPTH_CNTR,
320 PTLRPC_REQACTIVE_CNTR,
321 PTLRPC_TIMEOUT,
322 PTLRPC_REQBUF_AVAIL_CNTR,
323 PTLRPC_LAST_CNTR
324 };
325
326 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
327
328 enum {
329 LDLM_GLIMPSE_ENQUEUE = 0,
330 LDLM_PLAIN_ENQUEUE,
331 LDLM_EXTENT_ENQUEUE,
332 LDLM_FLOCK_ENQUEUE,
333 LDLM_IBITS_ENQUEUE,
334 MDS_REINT_SETATTR,
335 MDS_REINT_CREATE,
336 MDS_REINT_LINK,
337 MDS_REINT_UNLINK,
338 MDS_REINT_RENAME,
339 MDS_REINT_OPEN,
340 MDS_REINT_SETXATTR,
341 BRW_READ_BYTES,
342 BRW_WRITE_BYTES,
343 EXTRA_LAST_OPC
344 };
345
346 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
347 /* class_obd.c */
348 extern struct proc_dir_entry *proc_lustre_root;
349
350 struct obd_device;
351 struct obd_histogram;
352
353 /* Days / hours / mins / seconds format */
354 struct dhms {
355 int d,h,m,s;
356 };
357 static inline void s2dhms(struct dhms *ts, time_t secs)
358 {
359 ts->d = secs / 86400;
360 secs = secs % 86400;
361 ts->h = secs / 3600;
362 secs = secs % 3600;
363 ts->m = secs / 60;
364 ts->s = secs % 60;
365 }
366 #define DHMS_FMT "%dd%dh%02dm%02ds"
367 #define DHMS_VARS(x) (x)->d, (x)->h, (x)->m, (x)->s
368
369 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
370 #define JOBSTATS_DISABLE "disable"
371 #define JOBSTATS_PROCNAME_UID "procname_uid"
372 #define JOBSTATS_NODELOCAL "nodelocal"
373
374 extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
375 int *val, int mult);
376 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
377 long val, int mult);
378 #ifdef LPROCFS
379
380 extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
381 unsigned int cpuid);
382 /*
383 * \return value
384 * < 0 : on error (only possible for opc as LPROCFS_GET_SMP_ID)
385 */
386 static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc,
387 unsigned long *flags)
388 {
389 int rc = 0;
390
391 switch (opc) {
392 default:
393 LBUG();
394
395 case LPROCFS_GET_SMP_ID:
396 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
397 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
398 spin_lock_irqsave(&stats->ls_lock, *flags);
399 else
400 spin_lock(&stats->ls_lock);
401 return 0;
402 } else {
403 unsigned int cpuid = get_cpu();
404
405 if (unlikely(stats->ls_percpu[cpuid] == NULL)) {
406 rc = lprocfs_stats_alloc_one(stats, cpuid);
407 if (rc < 0) {
408 put_cpu();
409 return rc;
410 }
411 }
412 return cpuid;
413 }
414
415 case LPROCFS_GET_NUM_CPU:
416 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
417 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
418 spin_lock_irqsave(&stats->ls_lock, *flags);
419 else
420 spin_lock(&stats->ls_lock);
421 return 1;
422 } else {
423 return stats->ls_biggest_alloc_num;
424 }
425 }
426 }
427
428 static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats, int opc,
429 unsigned long *flags)
430 {
431 switch (opc) {
432 default:
433 LBUG();
434
435 case LPROCFS_GET_SMP_ID:
436 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
437 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
438 spin_unlock_irqrestore(&stats->ls_lock,
439 *flags);
440 } else {
441 spin_unlock(&stats->ls_lock);
442 }
443 } else {
444 put_cpu();
445 }
446 return;
447
448 case LPROCFS_GET_NUM_CPU:
449 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
450 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
451 spin_unlock_irqrestore(&stats->ls_lock,
452 *flags);
453 } else {
454 spin_unlock(&stats->ls_lock);
455 }
456 }
457 return;
458 }
459 }
460
461 static inline unsigned int
462 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
463 {
464 unsigned int percpusize;
465
466 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
467
468 /* irq safe stats need lc_array_sum[1] */
469 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
470 percpusize += stats->ls_num * sizeof(__s64);
471
472 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
473 percpusize = L1_CACHE_ALIGN(percpusize);
474
475 return percpusize;
476 }
477
478 static inline struct lprocfs_counter *
479 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
480 int index)
481 {
482 struct lprocfs_counter *cntr;
483
484 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
485
486 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
487 cntr = (void *)cntr + index * sizeof(__s64);
488
489 return cntr;
490 }
491
492 /* Two optimized LPROCFS counter increment functions are provided:
493 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
494 * lprocfs_counter_add(cntr) - use for multi-valued counters
495 * Counter data layout allows config flag, counter lock and the
496 * count itself to reside within a single cache line.
497 */
498
499 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
500 long amount);
501 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
502 long amount);
503
504 #define lprocfs_counter_incr(stats, idx) \
505 lprocfs_counter_add(stats, idx, 1)
506 #define lprocfs_counter_decr(stats, idx) \
507 lprocfs_counter_sub(stats, idx, 1)
508
509 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
510 struct lprocfs_counter_header *header,
511 enum lprocfs_stats_flags flags,
512 enum lprocfs_fields_flags field);
513 static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats,
514 int idx,
515 enum lprocfs_fields_flags field)
516 {
517 int i;
518 unsigned int num_cpu;
519 unsigned long flags = 0;
520 __u64 ret = 0;
521
522 LASSERT(stats != NULL);
523
524 num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
525 for (i = 0; i < num_cpu; i++) {
526 if (stats->ls_percpu[i] == NULL)
527 continue;
528 ret += lprocfs_read_helper(
529 lprocfs_stats_counter_get(stats, i, idx),
530 &stats->ls_cnt_header[idx], stats->ls_flags,
531 field);
532 }
533 lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
534 return ret;
535 }
536
537 extern struct lprocfs_stats *
538 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
539 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
540 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
541 extern void lprocfs_init_ops_stats(int num_private_stats,
542 struct lprocfs_stats *stats);
543 extern void lprocfs_init_mps_stats(int num_private_stats,
544 struct lprocfs_stats *stats);
545 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
546 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
547 unsigned int num_private_stats);
548 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
549 unsigned int num_private_stats);
550 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
551 unsigned conf, const char *name,
552 const char *units);
553 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
554 extern void lprocfs_free_md_stats(struct obd_device *obddev);
555 struct obd_export;
556 struct nid_stat;
557 extern int lprocfs_add_clear_entry(struct obd_device * obd,
558 struct proc_dir_entry *entry);
559 extern int lprocfs_exp_setup(struct obd_export *exp,
560 lnet_nid_t *peer_nid, int *newnid);
561 extern int lprocfs_exp_cleanup(struct obd_export *exp);
562 extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root,
563 char *name,
564 void *data,
565 struct file_operations *fops);
566 extern struct proc_dir_entry *
567 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
568 const char *format, ...);
569 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
570 extern int
571 lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
572 unsigned long count, void *data);
573 extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data);
574
575 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
576 struct lprocfs_stats *stats);
577
578 /* lprocfs_status.c */
579 extern int lprocfs_add_vars(struct proc_dir_entry *root,
580 struct lprocfs_vars *var,
581 void *data);
582
583 extern struct proc_dir_entry *lprocfs_register(const char *name,
584 struct proc_dir_entry *parent,
585 struct lprocfs_vars *list,
586 void *data);
587
588 extern void lprocfs_remove(struct proc_dir_entry **root);
589 extern void lprocfs_remove_proc_entry(const char *name,
590 struct proc_dir_entry *parent);
591
592 extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
593 extern int lprocfs_obd_cleanup(struct obd_device *obd);
594
595 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
596 umode_t mode,
597 const struct file_operations *seq_fops,
598 void *data);
599 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
600 umode_t mode,
601 const struct file_operations *seq_fops,
602 void *data);
603
604 /* Generic callbacks */
605
606 extern int lprocfs_rd_u64(struct seq_file *m, void *data);
607 extern int lprocfs_rd_atomic(struct seq_file *m, void *data);
608 extern int lprocfs_wr_atomic(struct file *file, const char *buffer,
609 unsigned long count, void *data);
610 extern int lprocfs_rd_uint(struct seq_file *m, void *data);
611 extern int lprocfs_wr_uint(struct file *file, const char *buffer,
612 unsigned long count, void *data);
613 extern int lprocfs_rd_uuid(struct seq_file *m, void *data);
614 extern int lprocfs_rd_name(struct seq_file *m, void *data);
615 extern int lprocfs_rd_server_uuid(struct seq_file *m, void *data);
616 extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data);
617 extern int lprocfs_rd_import(struct seq_file *m, void *data);
618 extern int lprocfs_rd_state(struct seq_file *m, void *data);
619 extern int lprocfs_rd_connect_flags(struct seq_file *m, void *data);
620 extern int lprocfs_rd_num_exports(struct seq_file *m, void *data);
621 extern int lprocfs_rd_numrefs(struct seq_file *m, void *data);
622
623 struct adaptive_timeout;
624 extern int lprocfs_at_hist_helper(struct seq_file *m,
625 struct adaptive_timeout *at);
626 extern int lprocfs_rd_timeouts(struct seq_file *m, void *data);
627 extern int lprocfs_wr_timeouts(struct file *file, const char *buffer,
628 unsigned long count, void *data);
629 extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
630 size_t count, loff_t *off);
631 extern int lprocfs_wr_ping(struct file *file, const char *buffer,
632 size_t count, loff_t *off);
633 extern int lprocfs_wr_import(struct file *file, const char *buffer,
634 size_t count, loff_t *off);
635 extern int lprocfs_rd_pinger_recov(struct seq_file *m, void *n);
636 extern int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
637 size_t count, loff_t *off);
638
639 /* Statfs helpers */
640 extern int lprocfs_rd_blksize(struct seq_file *m, void *data);
641 extern int lprocfs_rd_kbytestotal(struct seq_file *m, void *data);
642 extern int lprocfs_rd_kbytesfree(struct seq_file *m, void *data);
643 extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data);
644 extern int lprocfs_rd_filestotal(struct seq_file *m, void *data);
645 extern int lprocfs_rd_filesfree(struct seq_file *m, void *data);
646
647 extern int lprocfs_write_helper(const char *buffer, unsigned long count,
648 int *val);
649 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
650 extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
651 __u64 *val);
652 extern int lprocfs_write_frac_u64_helper(const char *buffer,
653 unsigned long count,
654 __u64 *val, int mult);
655 extern char *lprocfs_find_named_value(const char *buffer, const char *name,
656 size_t *count);
657 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
658 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
659 void lprocfs_oh_clear(struct obd_histogram *oh);
660 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
661
662 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
663 struct lprocfs_counter *cnt);
664
665 extern int lprocfs_single_release(cfs_inode_t *, struct file *);
666 extern int lprocfs_seq_release(cfs_inode_t *, struct file *);
667
668 /* You must use these macros when you want to refer to
669 * the import in a client obd_device for a lprocfs entry */
670 #define LPROCFS_CLIMP_CHECK(obd) do { \
671 typecheck(struct obd_device *, obd); \
672 down_read(&(obd)->u.cli.cl_sem); \
673 if ((obd)->u.cli.cl_import == NULL) { \
674 up_read(&(obd)->u.cli.cl_sem); \
675 return -ENODEV; \
676 } \
677 } while(0)
678 #define LPROCFS_CLIMP_EXIT(obd) \
679 up_read(&(obd)->u.cli.cl_sem);
680
681
682 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
683 proc entries; otherwise, you will define name##_seq_write function also for
684 a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
685 call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
686 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
687 static int name##_single_open(cfs_inode_t *inode, struct file *file) \
688 { \
689 return single_open(file, name##_seq_show, PDE_DATA(inode)); \
690 } \
691 static struct file_operations name##_fops = { \
692 .owner = THIS_MODULE, \
693 .open = name##_single_open, \
694 .read = seq_read, \
695 .write = custom_seq_write, \
696 .llseek = seq_lseek, \
697 .release = lprocfs_single_release, \
698 }
699
700 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
701 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
702
703 #define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
704 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
705 { \
706 return lprocfs_rd_##type(m, m->private); \
707 } \
708 LPROC_SEQ_FOPS_RO(name##_##type)
709
710 #define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
711 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
712 { \
713 return lprocfs_rd_##type(m, m->private); \
714 } \
715 static ssize_t name##_##type##_seq_write(struct file *file, \
716 const char *buffer, size_t count, loff_t *off) \
717 { \
718 struct seq_file *seq = file->private_data; \
719 return lprocfs_wr_##type(file, buffer, \
720 count, seq->private); \
721 } \
722 LPROC_SEQ_FOPS(name##_##type);
723
724 #define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
725 static ssize_t name##_##type##_write(struct file *file, \
726 const char *buffer, size_t count, loff_t *off) \
727 { \
728 return lprocfs_wr_##type(file, buffer, count, off); \
729 } \
730 static int name##_##type##_open(cfs_inode_t *inode, struct file *file) \
731 { \
732 return single_open(file, NULL, PDE_DATA(inode)); \
733 } \
734 static struct file_operations name##_##type##_fops = { \
735 .open = name##_##type##_open, \
736 .write = name##_##type##_write, \
737 .release = lprocfs_single_release, \
738 };
739
740 /* lproc_ptlrpc.c */
741 struct ptlrpc_request;
742 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
743
744 /* lproc_status.c */
745 int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data);
746 int lprocfs_obd_wr_max_pages_per_rpc(struct file *file, const char *buffer,
747 size_t count, loff_t *off);
748
749 /* all quota proc functions */
750 extern int lprocfs_quota_rd_bunit(char *page, char **start,
751 loff_t off, int count,
752 int *eof, void *data);
753 extern int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
754 unsigned long count, void *data);
755 extern int lprocfs_quota_rd_btune(char *page, char **start,
756 loff_t off, int count,
757 int *eof, void *data);
758 extern int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
759 unsigned long count, void *data);
760 extern int lprocfs_quota_rd_iunit(char *page, char **start,
761 loff_t off, int count,
762 int *eof, void *data);
763 extern int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
764 unsigned long count, void *data);
765 extern int lprocfs_quota_rd_itune(char *page, char **start,
766 loff_t off, int count,
767 int *eof, void *data);
768 extern int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
769 unsigned long count, void *data);
770 extern int lprocfs_quota_rd_type(char *page, char **start, loff_t off, int count,
771 int *eof, void *data);
772 extern int lprocfs_quota_wr_type(struct file *file, const char *buffer,
773 unsigned long count, void *data);
774 extern int lprocfs_quota_rd_switch_seconds(char *page, char **start, loff_t off,
775 int count, int *eof, void *data);
776 extern int lprocfs_quota_wr_switch_seconds(struct file *file,
777 const char *buffer,
778 unsigned long count, void *data);
779 extern int lprocfs_quota_rd_sync_blk(char *page, char **start, loff_t off,
780 int count, int *eof, void *data);
781 extern int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
782 unsigned long count, void *data);
783 extern int lprocfs_quota_rd_switch_qs(char *page, char **start, loff_t off,
784 int count, int *eof, void *data);
785 extern int lprocfs_quota_wr_switch_qs(struct file *file,
786 const char *buffer,
787 unsigned long count, void *data);
788 extern int lprocfs_quota_rd_boundary_factor(char *page, char **start, loff_t off,
789 int count, int *eof, void *data);
790 extern int lprocfs_quota_wr_boundary_factor(struct file *file,
791 const char *buffer,
792 unsigned long count, void *data);
793 extern int lprocfs_quota_rd_least_bunit(char *page, char **start, loff_t off,
794 int count, int *eof, void *data);
795 extern int lprocfs_quota_wr_least_bunit(struct file *file,
796 const char *buffer,
797 unsigned long count, void *data);
798 extern int lprocfs_quota_rd_least_iunit(char *page, char **start, loff_t off,
799 int count, int *eof, void *data);
800 extern int lprocfs_quota_wr_least_iunit(struct file *file,
801 const char *buffer,
802 unsigned long count, void *data);
803 extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off,
804 int count, int *eof, void *data);
805 extern int lprocfs_quota_wr_qs_factor(struct file *file,
806 const char *buffer,
807 unsigned long count, void *data);
808 #else
809 /* LPROCFS is not defined */
810
811 #define proc_lustre_root NULL
812
813 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
814 int index, long amount)
815 { return; }
816 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
817 int index)
818 { return; }
819 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
820 int index, long amount)
821 { return; }
822 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
823 int index)
824 { return; }
825 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
826 int index, unsigned conf,
827 const char *name, const char *units)
828 { return; }
829
830 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
831 enum lprocfs_fields_flags field)
832 { return 0; }
833
834 /* NB: we return !NULL to satisfy error checker */
835 static inline struct lprocfs_stats *
836 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
837 { return (struct lprocfs_stats *)1; }
838 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
839 { return; }
840 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
841 { return; }
842 static inline int lprocfs_register_stats(struct proc_dir_entry *root,
843 const char *name,
844 struct lprocfs_stats *stats)
845 { return 0; }
846 static inline void lprocfs_init_ops_stats(int num_private_stats,
847 struct lprocfs_stats *stats)
848 { return; }
849 static inline void lprocfs_init_mps_stats(int num_private_stats,
850 struct lprocfs_stats *stats)
851 { return; }
852 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
853 { return; }
854 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
855 unsigned int num_private_stats)
856 { return 0; }
857 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
858 unsigned int num_private_stats)
859 { return 0; }
860 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
861 { return; }
862 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
863 { return; }
864
865 struct obd_export;
866 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
867 { return 0; }
868 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid,
869 int *newnid)
870 { return 0; }
871 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
872 { return 0; }
873 static inline struct proc_dir_entry *
874 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
875 void *data, struct file_operations *fops)
876 {return 0; }
877 static inline struct proc_dir_entry *
878 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
879 const char *format, ...)
880 {return NULL; }
881 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
882 { return; }
883 static inline
884 int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
885 unsigned long count, void *data)
886 {return count;}
887 static inline
888 int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
889 { return 0; }
890
891 static inline struct proc_dir_entry *
892 lprocfs_register(const char *name, struct proc_dir_entry *parent,
893 struct lprocfs_vars *list, void *data)
894 { return NULL; }
895 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
896 struct lprocfs_vars *var,
897 void *data)
898 { return 0; }
899 static inline void lprocfs_remove(struct proc_dir_entry **root)
900 { return; }
901 static inline void lprocfs_remove_proc_entry(const char *name,
902 struct proc_dir_entry *parent)
903 { return; }
904 static inline int lprocfs_obd_setup(struct obd_device *dev,
905 struct lprocfs_vars *list)
906 { return 0; }
907 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
908 { return 0; }
909 static inline int lprocfs_rd_u64(struct seq_file *m, void *data)
910 { return 0; }
911 static inline int lprocfs_rd_uuid(struct seq_file *m, void *data)
912 { return 0; }
913 static inline int lprocfs_rd_name(struct seq_file *m, void *data)
914 { return 0; }
915 static inline int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
916 { return 0; }
917 static inline int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
918 { return 0; }
919 static inline int lprocfs_rd_import(struct seq_file *m, void *data)
920 { return 0; }
921 static inline int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
922 { return 0; }
923 static inline int lprocfs_rd_state(struct seq_file *m, void *data)
924 { return 0; }
925 static inline int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
926 { return 0; }
927 static inline int lprocfs_rd_num_exports(struct seq_file *m, void *data)
928 { return 0; }
929 extern inline int lprocfs_rd_numrefs(struct seq_file *m, void *data)
930 { return 0; }
931 struct adaptive_timeout;
932 static inline int lprocfs_at_hist_helper(struct seq_file *m,
933 struct adaptive_timeout *at)
934 { return 0; }
935 static inline int lprocfs_rd_timeouts(struct seq_file *m, void *data)
936 { return 0; }
937 static inline int lprocfs_wr_timeouts(struct file *file,
938 const char *buffer,
939 unsigned long count, void *data)
940 { return 0; }
941 static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer,
942 size_t count, loff_t *off)
943 { return 0; }
944 static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
945 size_t count, loff_t *off)
946 { return 0; }
947 static inline int lprocfs_wr_import(struct file *file, const char *buffer,
948 size_t count, loff_t *off)
949 { return 0; }
950 static inline int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
951 size_t count, loff_t *off)
952 { return 0; }
953
954 /* Statfs helpers */
955 static inline
956 int lprocfs_rd_blksize(struct seq_file *m, void *data)
957 { return 0; }
958 static inline
959 int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
960 { return 0; }
961 static inline
962 int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
963 { return 0; }
964 static inline
965 int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
966 { return 0; }
967 static inline
968 int lprocfs_rd_filestotal(struct seq_file *m, void *data)
969 { return 0; }
970 static inline
971 int lprocfs_rd_filesfree(struct seq_file *m, void *data)
972 { return 0; }
973 static inline
974 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
975 { return; }
976 static inline
977 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
978 { return; }
979 static inline
980 void lprocfs_oh_clear(struct obd_histogram *oh)
981 { return; }
982 static inline
983 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
984 { return 0; }
985 static inline
986 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
987 struct lprocfs_counter *cnt)
988 { return; }
989 static inline
990 __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
991 enum lprocfs_fields_flags field)
992 { return (__u64)0; }
993
994 #define LPROC_SEQ_FOPS_RO(name)
995 #define LPROC_SEQ_FOPS(name)
996 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
997 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
998 #define LPROC_SEQ_FOPS_WR_ONLY(name, type)
999
1000 /* lproc_ptlrpc.c */
1001 #define target_print_req NULL
1002
1003 #endif /* LPROCFS */
1004
1005 #endif /* LPROCFS_SNMP_H */
This page took 0.072417 seconds and 5 git commands to generate.