staging: lustre: remove top level ccflags variable
[deliverable/linux.git] / drivers / staging / lustre / lustre / include / lprocfs_status.h
CommitLineData
d7e09d03
PT
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>
9fdaf8c0 47#include "../../include/linux/libcfs/params_tree.h"
d7e09d03
PT
48
49struct lprocfs_vars {
73bb1da6
PT
50 const char *name;
51 struct file_operations *fops;
52 void *data;
d7e09d03
PT
53 /**
54 * /proc file mode.
55 */
3de91f92 56 umode_t proc_mode;
d7e09d03
PT
57};
58
59struct 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
66struct obd_histogram {
67 spinlock_t oh_lock;
68 unsigned long oh_buckets[OBD_HIST_MAX];
69};
70
71enum {
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
89struct brw_stats {
90 struct obd_histogram hist[BRW_LAST];
91};
92
93enum {
94 RENAME_SAMEDIR_SIZE = 0,
95 RENAME_CROSSDIR_SRC_SIZE,
96 RENAME_CROSSDIR_TGT_SIZE,
97 RENAME_LAST,
98};
99
100struct 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
125enum {
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
139struct 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
145struct 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
161struct 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
171enum 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
178enum 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
188struct 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 */
206static 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
317enum {
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
328enum {
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 */
b59fe845 348extern struct proc_dir_entry *proc_lustre_root;
d7e09d03
PT
349
350struct obd_device;
351struct obd_histogram;
352
353/* Days / hours / mins / seconds format */
354struct dhms {
355 int d,h,m,s;
356};
357static 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"
76133e66 372#define JOBSTATS_NODELOCAL "nodelocal"
d7e09d03 373
2c185ffa
PT
374extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
375 int *val, int mult);
376extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
377 long val, int mult);
d7e09d03
PT
378#ifdef LPROCFS
379
380extern 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 */
386static 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
428static 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
461static inline unsigned int
462lprocfs_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
478static inline struct lprocfs_counter *
479lprocfs_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
499extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
500 long amount);
501extern 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
509extern __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);
513static 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
537extern struct lprocfs_stats *
538lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
539extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
540extern void lprocfs_free_stats(struct lprocfs_stats **stats);
541extern void lprocfs_init_ops_stats(int num_private_stats,
542 struct lprocfs_stats *stats);
543extern void lprocfs_init_mps_stats(int num_private_stats,
544 struct lprocfs_stats *stats);
545extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
546extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
547 unsigned int num_private_stats);
548extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
549 unsigned int num_private_stats);
550extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
551 unsigned conf, const char *name,
552 const char *units);
553extern void lprocfs_free_obd_stats(struct obd_device *obddev);
554extern void lprocfs_free_md_stats(struct obd_device *obddev);
555struct obd_export;
556struct nid_stat;
557extern int lprocfs_add_clear_entry(struct obd_device * obd,
b59fe845 558 struct proc_dir_entry *entry);
d7e09d03
PT
559extern int lprocfs_exp_setup(struct obd_export *exp,
560 lnet_nid_t *peer_nid, int *newnid);
561extern int lprocfs_exp_cleanup(struct obd_export *exp);
b59fe845 562extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root,
d7e09d03 563 char *name,
d7e09d03
PT
564 void *data,
565 struct file_operations *fops);
566extern struct proc_dir_entry *
567lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
568 const char *format, ...);
569extern void lprocfs_free_per_client_stats(struct obd_device *obd);
570extern int
571lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
572 unsigned long count, void *data);
73bb1da6 573extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data);
d7e09d03 574
b59fe845 575extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
d7e09d03
PT
576 struct lprocfs_stats *stats);
577
578/* lprocfs_status.c */
b59fe845 579extern int lprocfs_add_vars(struct proc_dir_entry *root,
d7e09d03
PT
580 struct lprocfs_vars *var,
581 void *data);
582
b59fe845
GKH
583extern struct proc_dir_entry *lprocfs_register(const char *name,
584 struct proc_dir_entry *parent,
d7e09d03
PT
585 struct lprocfs_vars *list,
586 void *data);
587
b59fe845 588extern void lprocfs_remove(struct proc_dir_entry **root);
d7e09d03
PT
589extern void lprocfs_remove_proc_entry(const char *name,
590 struct proc_dir_entry *parent);
d7e09d03
PT
591
592extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
593extern int lprocfs_obd_cleanup(struct obd_device *obd);
d7e09d03 594
b59fe845 595extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
3de91f92 596 umode_t mode,
d7e09d03
PT
597 const struct file_operations *seq_fops,
598 void *data);
599extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
3de91f92 600 umode_t mode,
d7e09d03
PT
601 const struct file_operations *seq_fops,
602 void *data);
603
604/* Generic callbacks */
605
73bb1da6
PT
606extern int lprocfs_rd_u64(struct seq_file *m, void *data);
607extern int lprocfs_rd_atomic(struct seq_file *m, void *data);
d7e09d03
PT
608extern int lprocfs_wr_atomic(struct file *file, const char *buffer,
609 unsigned long count, void *data);
73bb1da6 610extern int lprocfs_rd_uint(struct seq_file *m, void *data);
d7e09d03
PT
611extern int lprocfs_wr_uint(struct file *file, const char *buffer,
612 unsigned long count, void *data);
73bb1da6
PT
613extern int lprocfs_rd_uuid(struct seq_file *m, void *data);
614extern int lprocfs_rd_name(struct seq_file *m, void *data);
615extern int lprocfs_rd_server_uuid(struct seq_file *m, void *data);
616extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data);
617extern int lprocfs_rd_import(struct seq_file *m, void *data);
618extern int lprocfs_rd_state(struct seq_file *m, void *data);
619extern int lprocfs_rd_connect_flags(struct seq_file *m, void *data);
620extern int lprocfs_rd_num_exports(struct seq_file *m, void *data);
621extern int lprocfs_rd_numrefs(struct seq_file *m, void *data);
622
d7e09d03 623struct adaptive_timeout;
73bb1da6 624extern int lprocfs_at_hist_helper(struct seq_file *m,
d7e09d03 625 struct adaptive_timeout *at);
73bb1da6 626extern int lprocfs_rd_timeouts(struct seq_file *m, void *data);
d7e09d03
PT
627extern int lprocfs_wr_timeouts(struct file *file, const char *buffer,
628 unsigned long count, void *data);
629extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
73bb1da6 630 size_t count, loff_t *off);
d7e09d03 631extern int lprocfs_wr_ping(struct file *file, const char *buffer,
73bb1da6 632 size_t count, loff_t *off);
d7e09d03 633extern int lprocfs_wr_import(struct file *file, const char *buffer,
73bb1da6
PT
634 size_t count, loff_t *off);
635extern int lprocfs_rd_pinger_recov(struct seq_file *m, void *n);
d7e09d03 636extern int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
73bb1da6 637 size_t count, loff_t *off);
d7e09d03
PT
638
639/* Statfs helpers */
73bb1da6
PT
640extern int lprocfs_rd_blksize(struct seq_file *m, void *data);
641extern int lprocfs_rd_kbytestotal(struct seq_file *m, void *data);
642extern int lprocfs_rd_kbytesfree(struct seq_file *m, void *data);
643extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data);
644extern int lprocfs_rd_filestotal(struct seq_file *m, void *data);
645extern int lprocfs_rd_filesfree(struct seq_file *m, void *data);
d7e09d03
PT
646
647extern int lprocfs_write_helper(const char *buffer, unsigned long count,
648 int *val);
73bb1da6 649extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
d7e09d03
PT
650extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
651 __u64 *val);
652extern int lprocfs_write_frac_u64_helper(const char *buffer,
653 unsigned long count,
654 __u64 *val, int mult);
b69835a2
PT
655extern char *lprocfs_find_named_value(const char *buffer, const char *name,
656 size_t *count);
d7e09d03
PT
657void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
658void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
659void lprocfs_oh_clear(struct obd_histogram *oh);
660unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
661
662void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
663 struct lprocfs_counter *cnt);
664
d7e09d03
PT
665extern int lprocfs_single_release(cfs_inode_t *, struct file *);
666extern 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); */
73bb1da6
PT
686#define __LPROC_SEQ_FOPS(name, custom_seq_write) \
687static int name##_single_open(cfs_inode_t *inode, struct file *file) \
688{ \
689 return single_open(file, name##_seq_show, PDE_DATA(inode)); \
690} \
b9c98cfa 691static struct file_operations name##_fops = { \
d7e09d03
PT
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
73bb1da6
PT
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 } \
b9c98cfa 734 static struct file_operations name##_##type##_fops = { \
73bb1da6
PT
735 .open = name##_##type##_open, \
736 .write = name##_##type##_write, \
737 .release = lprocfs_single_release, \
738 };
739
d7e09d03
PT
740/* lproc_ptlrpc.c */
741struct ptlrpc_request;
742extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
743
744/* lproc_status.c */
73bb1da6 745int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data);
d7e09d03 746int lprocfs_obd_wr_max_pages_per_rpc(struct file *file, const char *buffer,
73bb1da6 747 size_t count, loff_t *off);
d7e09d03
PT
748
749/* all quota proc functions */
750extern int lprocfs_quota_rd_bunit(char *page, char **start,
73bb1da6 751 loff_t off, int count,
d7e09d03
PT
752 int *eof, void *data);
753extern int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
754 unsigned long count, void *data);
755extern int lprocfs_quota_rd_btune(char *page, char **start,
73bb1da6 756 loff_t off, int count,
d7e09d03
PT
757 int *eof, void *data);
758extern int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
759 unsigned long count, void *data);
760extern int lprocfs_quota_rd_iunit(char *page, char **start,
73bb1da6 761 loff_t off, int count,
d7e09d03
PT
762 int *eof, void *data);
763extern int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
764 unsigned long count, void *data);
765extern int lprocfs_quota_rd_itune(char *page, char **start,
73bb1da6 766 loff_t off, int count,
d7e09d03
PT
767 int *eof, void *data);
768extern int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
769 unsigned long count, void *data);
73bb1da6 770extern int lprocfs_quota_rd_type(char *page, char **start, loff_t off, int count,
d7e09d03
PT
771 int *eof, void *data);
772extern int lprocfs_quota_wr_type(struct file *file, const char *buffer,
773 unsigned long count, void *data);
73bb1da6 774extern int lprocfs_quota_rd_switch_seconds(char *page, char **start, loff_t off,
d7e09d03
PT
775 int count, int *eof, void *data);
776extern int lprocfs_quota_wr_switch_seconds(struct file *file,
777 const char *buffer,
778 unsigned long count, void *data);
73bb1da6 779extern int lprocfs_quota_rd_sync_blk(char *page, char **start, loff_t off,
d7e09d03
PT
780 int count, int *eof, void *data);
781extern int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
782 unsigned long count, void *data);
73bb1da6 783extern int lprocfs_quota_rd_switch_qs(char *page, char **start, loff_t off,
d7e09d03
PT
784 int count, int *eof, void *data);
785extern int lprocfs_quota_wr_switch_qs(struct file *file,
786 const char *buffer,
787 unsigned long count, void *data);
73bb1da6 788extern int lprocfs_quota_rd_boundary_factor(char *page, char **start, loff_t off,
d7e09d03
PT
789 int count, int *eof, void *data);
790extern int lprocfs_quota_wr_boundary_factor(struct file *file,
791 const char *buffer,
792 unsigned long count, void *data);
73bb1da6 793extern int lprocfs_quota_rd_least_bunit(char *page, char **start, loff_t off,
d7e09d03
PT
794 int count, int *eof, void *data);
795extern int lprocfs_quota_wr_least_bunit(struct file *file,
796 const char *buffer,
797 unsigned long count, void *data);
73bb1da6 798extern int lprocfs_quota_rd_least_iunit(char *page, char **start, loff_t off,
d7e09d03
PT
799 int count, int *eof, void *data);
800extern int lprocfs_quota_wr_least_iunit(struct file *file,
801 const char *buffer,
802 unsigned long count, void *data);
73bb1da6 803extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off,
d7e09d03
PT
804 int count, int *eof, void *data);
805extern int lprocfs_quota_wr_qs_factor(struct file *file,
806 const char *buffer,
807 unsigned long count, void *data);
d7e09d03
PT
808#else
809/* LPROCFS is not defined */
810
811#define proc_lustre_root NULL
812
813static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
814 int index, long amount)
815{ return; }
816static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
817 int index)
818{ return; }
819static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
820 int index, long amount)
821{ return; }
822static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
823 int index)
824{ return; }
825static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
826 int index, unsigned conf,
827 const char *name, const char *units)
828{ return; }
829
830static 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 */
835static inline struct lprocfs_stats *
836lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
837{ return (struct lprocfs_stats *)1; }
838static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
839{ return; }
840static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
841{ return; }
b59fe845 842static inline int lprocfs_register_stats(struct proc_dir_entry *root,
d7e09d03
PT
843 const char *name,
844 struct lprocfs_stats *stats)
845{ return 0; }
846static inline void lprocfs_init_ops_stats(int num_private_stats,
847 struct lprocfs_stats *stats)
848{ return; }
849static inline void lprocfs_init_mps_stats(int num_private_stats,
850 struct lprocfs_stats *stats)
851{ return; }
852static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
853{ return; }
854static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
855 unsigned int num_private_stats)
856{ return 0; }
857static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
858 unsigned int num_private_stats)
859{ return 0; }
860static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
861{ return; }
862static inline void lprocfs_free_md_stats(struct obd_device *obddev)
863{ return; }
864
865struct obd_export;
866static inline int lprocfs_add_clear_entry(struct obd_export *exp)
867{ return 0; }
868static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid,
869 int *newnid)
870{ return 0; }
871static inline int lprocfs_exp_cleanup(struct obd_export *exp)
872{ return 0; }
b59fe845 873static inline struct proc_dir_entry *
d7e09d03 874lprocfs_add_simple(struct proc_dir_entry *root, char *name,
d7e09d03
PT
875 void *data, struct file_operations *fops)
876{return 0; }
877static inline struct proc_dir_entry *
878lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
879 const char *format, ...)
880{return NULL; }
881static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
882{ return; }
883static inline
884int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
885 unsigned long count, void *data)
886{return count;}
887static inline
73bb1da6
PT
888int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
889{ return 0; }
d7e09d03 890
b59fe845
GKH
891static inline struct proc_dir_entry *
892lprocfs_register(const char *name, struct proc_dir_entry *parent,
d7e09d03
PT
893 struct lprocfs_vars *list, void *data)
894{ return NULL; }
b59fe845 895static inline int lprocfs_add_vars(struct proc_dir_entry *root,
d7e09d03
PT
896 struct lprocfs_vars *var,
897 void *data)
898{ return 0; }
b59fe845 899static inline void lprocfs_remove(struct proc_dir_entry **root)
d7e09d03
PT
900{ return; }
901static inline void lprocfs_remove_proc_entry(const char *name,
902 struct proc_dir_entry *parent)
903{ return; }
d7e09d03
PT
904static inline int lprocfs_obd_setup(struct obd_device *dev,
905 struct lprocfs_vars *list)
906{ return 0; }
907static inline int lprocfs_obd_cleanup(struct obd_device *dev)
908{ return 0; }
73bb1da6 909static inline int lprocfs_rd_u64(struct seq_file *m, void *data)
d7e09d03 910{ return 0; }
73bb1da6 911static inline int lprocfs_rd_uuid(struct seq_file *m, void *data)
d7e09d03 912{ return 0; }
73bb1da6 913static inline int lprocfs_rd_name(struct seq_file *m, void *data)
d7e09d03 914{ return 0; }
73bb1da6 915static inline int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
d7e09d03 916{ return 0; }
73bb1da6 917static inline int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
d7e09d03 918{ return 0; }
73bb1da6 919static inline int lprocfs_rd_import(struct seq_file *m, void *data)
d7e09d03 920{ return 0; }
73bb1da6 921static inline int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
d7e09d03 922{ return 0; }
73bb1da6 923static inline int lprocfs_rd_state(struct seq_file *m, void *data)
d7e09d03 924{ return 0; }
73bb1da6 925static inline int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
d7e09d03 926{ return 0; }
73bb1da6 927static inline int lprocfs_rd_num_exports(struct seq_file *m, void *data)
d7e09d03 928{ return 0; }
73bb1da6 929extern inline int lprocfs_rd_numrefs(struct seq_file *m, void *data)
d7e09d03
PT
930{ return 0; }
931struct adaptive_timeout;
73bb1da6 932static inline int lprocfs_at_hist_helper(struct seq_file *m,
d7e09d03
PT
933 struct adaptive_timeout *at)
934{ return 0; }
73bb1da6 935static inline int lprocfs_rd_timeouts(struct seq_file *m, void *data)
d7e09d03
PT
936{ return 0; }
937static inline int lprocfs_wr_timeouts(struct file *file,
938 const char *buffer,
939 unsigned long count, void *data)
940{ return 0; }
73bb1da6
PT
941static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer,
942 size_t count, loff_t *off)
d7e09d03
PT
943{ return 0; }
944static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
73bb1da6 945 size_t count, loff_t *off)
d7e09d03
PT
946{ return 0; }
947static inline int lprocfs_wr_import(struct file *file, const char *buffer,
73bb1da6 948 size_t count, loff_t *off)
d7e09d03
PT
949{ return 0; }
950static inline int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
73bb1da6 951 size_t count, loff_t *off)
d7e09d03
PT
952{ return 0; }
953
954/* Statfs helpers */
955static inline
73bb1da6 956int lprocfs_rd_blksize(struct seq_file *m, void *data)
d7e09d03
PT
957{ return 0; }
958static inline
73bb1da6 959int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
d7e09d03
PT
960{ return 0; }
961static inline
73bb1da6 962int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
d7e09d03
PT
963{ return 0; }
964static inline
73bb1da6 965int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
d7e09d03
PT
966{ return 0; }
967static inline
73bb1da6 968int lprocfs_rd_filestotal(struct seq_file *m, void *data)
d7e09d03
PT
969{ return 0; }
970static inline
73bb1da6 971int lprocfs_rd_filesfree(struct seq_file *m, void *data)
d7e09d03
PT
972{ return 0; }
973static inline
974void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
975{ return; }
976static inline
977void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
978{ return; }
979static inline
980void lprocfs_oh_clear(struct obd_histogram *oh)
981{ return; }
982static inline
983unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
984{ return 0; }
985static inline
986void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
987 struct lprocfs_counter *cnt)
988{ return; }
989static 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)
73bb1da6
PT
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)
d7e09d03 999
d7e09d03
PT
1000/* lproc_ptlrpc.c */
1001#define target_print_req NULL
1002
1003#endif /* LPROCFS */
1004
1005#endif /* LPROCFS_SNMP_H */
This page took 0.238941 seconds and 5 git commands to generate.