4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/include/lprocfs_status.h
38 * Top level header file for LProc SNMP
40 * Author: Hariharan Thantry thantry@users.sourceforge.net
42 #ifndef _LPROCFS_SNMP_H
43 #define _LPROCFS_SNMP_H
45 #if defined(__linux__)
46 #include <linux/lprocfs_status.h>
47 #elif defined(__APPLE__)
48 #include <darwin/lprocfs_status.h>
49 #elif defined(__WINNT__)
50 #include <winnt/lprocfs_status.h>
52 #error Unsupported operating system.
54 #include <lustre/lustre_idl.h>
55 #include <libcfs/params_tree.h>
59 cfs_read_proc_t *read_fptr;
60 cfs_write_proc_t *write_fptr;
62 struct file_operations *fops;
69 struct lprocfs_static_vars {
70 struct lprocfs_vars *module_vars;
71 struct lprocfs_vars *obd_vars;
74 /* if we find more consumers this could be generalized */
75 #define OBD_HIST_MAX 32
76 struct obd_histogram {
78 unsigned long oh_buckets[OBD_HIST_MAX];
100 struct obd_histogram hist[BRW_LAST];
104 RENAME_SAMEDIR_SIZE = 0,
105 RENAME_CROSSDIR_SRC_SIZE,
106 RENAME_CROSSDIR_TGT_SIZE,
110 struct rename_stats {
111 struct obd_histogram hist[RENAME_LAST];
114 /* An lprocfs counter can be configured using the enum bit masks below.
116 * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
117 * protects this counter from concurrent updates. If not specified,
118 * lprocfs an internal per-counter lock variable. External locks are
119 * not used to protect counter increments, but are used to protect
120 * counter readout and resets.
122 * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
123 * (i.e. counter can be incremented by more than "1"). When specified,
124 * the counter maintains min, max and sum in addition to a simple
125 * invocation count. This allows averages to be be computed.
126 * If not specified, the counter is an increment-by-1 counter.
127 * min, max, sum, etc. are not maintained.
129 * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
130 * squares (for multi-valued counter samples only). This allows
131 * external computation of standard deviation, but involves a 64-bit
132 * multiply per counter increment.
136 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
137 LPROCFS_CNTR_AVGMINMAX = 0x0002,
138 LPROCFS_CNTR_STDDEV = 0x0004,
140 /* counter data type */
141 LPROCFS_TYPE_REGS = 0x0100,
142 LPROCFS_TYPE_BYTES = 0x0200,
143 LPROCFS_TYPE_PAGES = 0x0400,
144 LPROCFS_TYPE_CYCLE = 0x0800,
147 #define LC_MIN_INIT ((~(__u64)0) >> 1)
149 struct lprocfs_counter_header {
150 unsigned int lc_config;
151 const char *lc_name; /* must be static */
152 const char *lc_units; /* must be static */
155 struct lprocfs_counter {
161 * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
162 * for irq context counter, i.e. stats with
163 * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
166 __s64 lc_array_sum[1];
168 #define lc_sum lc_array_sum[0]
169 #define lc_sum_irq lc_array_sum[1]
171 struct lprocfs_percpu {
175 struct lprocfs_counter lp_cntr[0];
178 #define LPROCFS_GET_NUM_CPU 0x0001
179 #define LPROCFS_GET_SMP_ID 0x0002
181 enum lprocfs_stats_flags {
182 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
183 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
184 * area and need locking */
185 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
188 enum lprocfs_fields_flags {
189 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
190 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
191 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
192 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
193 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
194 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
195 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
198 struct lprocfs_stats {
200 unsigned short ls_num;
201 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
202 unsigned short ls_biggest_alloc_num;
203 enum lprocfs_stats_flags ls_flags;
204 /* Lock used when there are no percpu stats areas; For percpu stats,
205 * it is used to protect ls_biggest_alloc_num change */
208 /* has ls_num of counter headers */
209 struct lprocfs_counter_header *ls_cnt_header;
210 struct lprocfs_percpu *ls_percpu[0];
213 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
215 /* Pack all opcodes down into a single monotonically increasing index */
216 static inline int opcode_offset(__u32 opc) {
217 if (opc < OST_LAST_OPC) {
219 return (opc - OST_FIRST_OPC);
220 } else if (opc < MDS_LAST_OPC) {
222 return (opc - MDS_FIRST_OPC +
224 } else if (opc < LDLM_LAST_OPC) {
226 return (opc - LDLM_FIRST_OPC +
229 } else if (opc < MGS_LAST_OPC) {
231 return (opc - MGS_FIRST_OPC +
235 } else if (opc < OBD_LAST_OPC) {
237 return (opc - OBD_FIRST_OPC +
242 } else if (opc < LLOG_LAST_OPC) {
244 return (opc - LLOG_FIRST_OPC +
250 } else if (opc < QUOTA_LAST_OPC) {
252 return (opc - QUOTA_FIRST_OPC +
259 } else if (opc < SEQ_LAST_OPC) {
261 return (opc - SEQ_FIRST_OPC +
269 } else if (opc < SEC_LAST_OPC) {
271 return (opc - SEC_FIRST_OPC +
280 } else if (opc < FLD_LAST_OPC) {
282 return (opc - FLD_FIRST_OPC +
299 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
310 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
314 PTLRPC_REQWAIT_CNTR = 0,
315 PTLRPC_REQQDEPTH_CNTR,
316 PTLRPC_REQACTIVE_CNTR,
318 PTLRPC_REQBUF_AVAIL_CNTR,
322 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
325 LDLM_GLIMPSE_ENQUEUE = 0,
342 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
344 extern cfs_proc_dir_entry_t *proc_lustre_root;
347 struct obd_histogram;
349 /* Days / hours / mins / seconds format */
353 static inline void s2dhms(struct dhms *ts, time_t secs)
355 ts->d = secs / 86400;
362 #define DHMS_FMT "%dd%dh%02dm%02ds"
363 #define DHMS_VARS(x) (x)->d, (x)->h, (x)->m, (x)->s
365 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
366 #define JOBSTATS_DISABLE "disable"
367 #define JOBSTATS_PROCNAME_UID "procname_uid"
369 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
371 struct obd_job_stats {
372 cfs_hash_t *ojs_hash;
374 rwlock_t ojs_lock; /* protect the obj_list */
375 cntr_init_callback ojs_cntr_init_fn;
377 int ojs_cleanup_interval;
378 time_t ojs_last_cleanup;
383 extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
387 * < 0 : on error (only possible for opc as LPROCFS_GET_SMP_ID)
389 static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc,
390 unsigned long *flags)
398 case LPROCFS_GET_SMP_ID:
399 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
400 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
401 spin_lock_irqsave(&stats->ls_lock, *flags);
403 spin_lock(&stats->ls_lock);
406 unsigned int cpuid = cfs_get_cpu();
408 if (unlikely(stats->ls_percpu[cpuid] == NULL)) {
409 rc = lprocfs_stats_alloc_one(stats, cpuid);
418 case LPROCFS_GET_NUM_CPU:
419 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
420 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
421 spin_lock_irqsave(&stats->ls_lock, *flags);
423 spin_lock(&stats->ls_lock);
426 return stats->ls_biggest_alloc_num;
431 static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats, int opc,
432 unsigned long *flags)
438 case LPROCFS_GET_SMP_ID:
439 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
440 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
441 spin_unlock_irqrestore(&stats->ls_lock,
444 spin_unlock(&stats->ls_lock);
451 case LPROCFS_GET_NUM_CPU:
452 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
453 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
454 spin_unlock_irqrestore(&stats->ls_lock,
457 spin_unlock(&stats->ls_lock);
464 static inline unsigned int
465 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
467 unsigned int percpusize;
469 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
471 /* irq safe stats need lc_array_sum[1] */
472 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
473 percpusize += stats->ls_num * sizeof(__s64);
475 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
476 percpusize = CFS_L1_CACHE_ALIGN(percpusize);
481 static inline struct lprocfs_counter *
482 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
485 struct lprocfs_counter *cntr;
487 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
489 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
490 cntr = (void *)cntr + index * sizeof(__s64);
495 /* Two optimized LPROCFS counter increment functions are provided:
496 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
497 * lprocfs_counter_add(cntr) - use for multi-valued counters
498 * Counter data layout allows config flag, counter lock and the
499 * count itself to reside within a single cache line.
502 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
504 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
507 #define lprocfs_counter_incr(stats, idx) \
508 lprocfs_counter_add(stats, idx, 1)
509 #define lprocfs_counter_decr(stats, idx) \
510 lprocfs_counter_sub(stats, idx, 1)
512 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
513 struct lprocfs_counter_header *header,
514 enum lprocfs_stats_flags flags,
515 enum lprocfs_fields_flags field);
516 static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats,
518 enum lprocfs_fields_flags field)
521 unsigned int num_cpu;
522 unsigned long flags = 0;
525 LASSERT(stats != NULL);
527 num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
528 for (i = 0; i < num_cpu; i++) {
529 if (stats->ls_percpu[i] == NULL)
531 ret += lprocfs_read_helper(
532 lprocfs_stats_counter_get(stats, i, idx),
533 &stats->ls_cnt_header[idx], stats->ls_flags,
536 lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
540 extern struct lprocfs_stats *
541 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
542 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
543 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
544 extern void lprocfs_init_ops_stats(int num_private_stats,
545 struct lprocfs_stats *stats);
546 extern void lprocfs_init_mps_stats(int num_private_stats,
547 struct lprocfs_stats *stats);
548 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
549 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
550 unsigned int num_private_stats);
551 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
552 unsigned int num_private_stats);
553 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
554 unsigned conf, const char *name,
556 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
557 extern void lprocfs_free_md_stats(struct obd_device *obddev);
560 extern int lprocfs_add_clear_entry(struct obd_device * obd,
561 cfs_proc_dir_entry_t *entry);
562 extern int lprocfs_exp_setup(struct obd_export *exp,
563 lnet_nid_t *peer_nid, int *newnid);
564 extern int lprocfs_exp_cleanup(struct obd_export *exp);
565 extern cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
567 cfs_read_proc_t *read_proc,
568 cfs_write_proc_t *write_proc,
570 struct file_operations *fops);
571 extern struct proc_dir_entry *
572 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
573 const char *format, ...);
574 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
576 lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
577 unsigned long count, void *data);
578 extern int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off,
579 int count, int *eof, void *data);
581 extern int lprocfs_register_stats(cfs_proc_dir_entry_t *root, const char *name,
582 struct lprocfs_stats *stats);
584 /* lprocfs_status.c */
585 extern int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
586 struct lprocfs_vars *var,
589 extern cfs_proc_dir_entry_t *lprocfs_register(const char *name,
590 cfs_proc_dir_entry_t *parent,
591 struct lprocfs_vars *list,
594 extern void lprocfs_remove(cfs_proc_dir_entry_t **root);
595 extern void lprocfs_remove_proc_entry(const char *name,
596 struct proc_dir_entry *parent);
597 extern void lprocfs_try_remove_proc_entry(const char *name,
598 struct proc_dir_entry *parent);
600 extern cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *root,
603 extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
604 extern int lprocfs_obd_cleanup(struct obd_device *obd);
605 extern struct file_operations lprocfs_evict_client_fops;
607 extern int lprocfs_seq_create(cfs_proc_dir_entry_t *parent, const char *name,
609 const struct file_operations *seq_fops,
611 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
613 const struct file_operations *seq_fops,
616 /* Generic callbacks */
618 extern int lprocfs_rd_u64(char *page, char **start, off_t off,
619 int count, int *eof, void *data);
620 extern int lprocfs_rd_atomic(char *page, char **start, off_t off,
621 int count, int *eof, void *data);
622 extern int lprocfs_wr_atomic(struct file *file, const char *buffer,
623 unsigned long count, void *data);
624 extern int lprocfs_rd_uint(char *page, char **start, off_t off,
625 int count, int *eof, void *data);
626 extern int lprocfs_wr_uint(struct file *file, const char *buffer,
627 unsigned long count, void *data);
628 extern int lprocfs_rd_uuid(char *page, char **start, off_t off,
629 int count, int *eof, void *data);
630 extern int lprocfs_rd_name(char *page, char **start, off_t off,
631 int count, int *eof, void *data);
632 extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
633 int count, int *eof, void *data);
634 extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
635 int count, int *eof, void *data);
636 extern int lprocfs_rd_import(char *page, char **start, off_t off, int count,
637 int *eof, void *data);
638 extern int lprocfs_rd_state(char *page, char **start, off_t off, int count,
639 int *eof, void *data);
640 extern int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
641 int count, int *eof, void *data);
642 extern int lprocfs_rd_num_exports(char *page, char **start, off_t off,
643 int count, int *eof, void *data);
644 extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
645 int count, int *eof, void *data);
646 struct adaptive_timeout;
647 extern int lprocfs_at_hist_helper(char *page, int count, int rc,
648 struct adaptive_timeout *at);
649 extern int lprocfs_rd_timeouts(char *page, char **start, off_t off,
650 int count, int *eof, void *data);
651 extern int lprocfs_wr_timeouts(struct file *file, const char *buffer,
652 unsigned long count, void *data);
653 extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
654 unsigned long count, void *data);
655 extern int lprocfs_wr_ping(struct file *file, const char *buffer,
656 unsigned long count, void *data);
657 extern int lprocfs_wr_import(struct file *file, const char *buffer,
658 unsigned long count, void *data);
659 extern int lprocfs_rd_pinger_recov(char *page, char **start, off_t off,
660 int count, int *eof, void *data);
661 extern int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
662 unsigned long count, void *data);
665 extern int lprocfs_rd_blksize(char *page, char **start, off_t off,
666 int count, int *eof, void *data);
667 extern int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
668 int count, int *eof, void *data);
669 extern int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
670 int count, int *eof, void *data);
671 extern int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
672 int count, int *eof, void *data);
673 extern int lprocfs_rd_filestotal(char *page, char **start, off_t off,
674 int count, int *eof, void *data);
675 extern int lprocfs_rd_filesfree(char *page, char **start, off_t off,
676 int count, int *eof, void *data);
677 extern int lprocfs_rd_filegroups(char *page, char **start, off_t off,
678 int count, int *eof, void *data);
679 extern int lprocfs_osd_rd_blksize(char *page, char **start, off_t off,
680 int count, int *eof, void *data);
681 extern int lprocfs_osd_rd_kbytesfree(char *page, char **start, off_t off,
682 int count, int *eof, void *data);
683 extern int lprocfs_osd_rd_kbytesavail(char *page, char **start, off_t off,
684 int count, int *eof, void *data);
685 extern int lprocfs_osd_rd_filestotal(char *page, char **start, off_t off,
686 int count, int *eof, void *data);
687 extern int lprocfs_osd_rd_filesfree(char *page, char **start, off_t off,
688 int count, int *eof, void *data);
689 extern int lprocfs_osd_rd_kbytestotal(char *page, char **start, off_t off,
690 int count, int *eof, void *data);
693 extern int lprocfs_write_helper(const char *buffer, unsigned long count,
695 extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
697 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
699 extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
701 extern int lprocfs_write_frac_u64_helper(const char *buffer,
703 __u64 *val, int mult);
704 char *lprocfs_find_named_value(const char *buffer, const char *name,
705 unsigned long *count);
706 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
707 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
708 void lprocfs_oh_clear(struct obd_histogram *oh);
709 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
711 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
712 struct lprocfs_counter *cnt);
714 /* lprocfs_status.c: recovery status */
715 int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
716 int count, int *eof, void *data);
718 /* lprocfs_statuc.c: hash statistics */
719 int lprocfs_obd_rd_hash(char *page, char **start, off_t off,
720 int count, int *eof, void *data);
722 /* lprocfs_status.c: IR factor */
723 int lprocfs_obd_rd_ir_factor(char *page, char **start, off_t off,
724 int count, int *eof, void *data);
725 int lprocfs_obd_wr_ir_factor(struct file *file, const char *buffer,
726 unsigned long count, void *data);
728 extern int lprocfs_single_release(cfs_inode_t *, struct file *);
729 extern int lprocfs_seq_release(cfs_inode_t *, struct file *);
731 /* You must use these macros when you want to refer to
732 * the import in a client obd_device for a lprocfs entry */
733 #define LPROCFS_CLIMP_CHECK(obd) do { \
734 typecheck(struct obd_device *, obd); \
735 down_read(&(obd)->u.cli.cl_sem); \
736 if ((obd)->u.cli.cl_import == NULL) { \
737 up_read(&(obd)->u.cli.cl_sem); \
741 #define LPROCFS_CLIMP_EXIT(obd) \
742 up_read(&(obd)->u.cli.cl_sem);
745 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
746 proc entries; otherwise, you will define name##_seq_write function also for
747 a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
748 call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
749 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
750 static int name##_single_open(cfs_inode_t *inode, struct file *file) { \
751 struct proc_dir_entry *dp = PDE(inode); \
753 LPROCFS_ENTRY_AND_CHECK(dp); \
754 rc = single_open(file, name##_seq_show, dp->data); \
761 struct file_operations name##_fops = { \
762 .owner = THIS_MODULE, \
763 .open = name##_single_open, \
765 .write = custom_seq_write, \
766 .llseek = seq_lseek, \
767 .release = lprocfs_single_release, \
770 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
771 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
773 /* lprocfs_jobstats.c */
774 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
775 int event, long amount);
776 void lprocfs_job_stats_fini(struct obd_device *obd);
777 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
778 cntr_init_callback fn);
779 int lprocfs_rd_job_interval(char *page, char **start, off_t off,
780 int count, int *eof, void *data);
781 int lprocfs_wr_job_interval(struct file *file, const char *buffer,
782 unsigned long count, void *data);
785 struct ptlrpc_request;
786 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
789 int lprocfs_obd_rd_recovery_time_soft(char *page, char **start, off_t off,
790 int count, int *eof, void *data);
791 int lprocfs_obd_wr_recovery_time_soft(struct file *file,
793 unsigned long count, void *data);
794 int lprocfs_obd_rd_recovery_time_hard(char *page, char **start, off_t off,
795 int count, int *eof, void *data);
796 int lprocfs_obd_wr_recovery_time_hard(struct file *file,
798 unsigned long count, void *data);
799 int lprocfs_obd_rd_mntdev(char *page, char **start, off_t off,
800 int count, int *eof, void *data);
801 int lprocfs_obd_rd_max_pages_per_rpc(char *page, char **start, off_t off,
802 int count, int *eof, void *data);
803 int lprocfs_obd_wr_max_pages_per_rpc(struct file *file, const char *buffer,
804 unsigned long count, void *data);
805 int lprocfs_target_rd_instance(char *page, char **start, off_t off,
806 int count, int *eof, void *data);
808 /* all quota proc functions */
809 extern int lprocfs_quota_rd_bunit(char *page, char **start,
810 off_t off, int count,
811 int *eof, void *data);
812 extern int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
813 unsigned long count, void *data);
814 extern int lprocfs_quota_rd_btune(char *page, char **start,
815 off_t off, int count,
816 int *eof, void *data);
817 extern int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
818 unsigned long count, void *data);
819 extern int lprocfs_quota_rd_iunit(char *page, char **start,
820 off_t off, int count,
821 int *eof, void *data);
822 extern int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
823 unsigned long count, void *data);
824 extern int lprocfs_quota_rd_itune(char *page, char **start,
825 off_t off, int count,
826 int *eof, void *data);
827 extern int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
828 unsigned long count, void *data);
829 extern int lprocfs_quota_rd_type(char *page, char **start, off_t off, int count,
830 int *eof, void *data);
831 extern int lprocfs_quota_wr_type(struct file *file, const char *buffer,
832 unsigned long count, void *data);
833 extern int lprocfs_quota_rd_switch_seconds(char *page, char **start, off_t off,
834 int count, int *eof, void *data);
835 extern int lprocfs_quota_wr_switch_seconds(struct file *file,
837 unsigned long count, void *data);
838 extern int lprocfs_quota_rd_sync_blk(char *page, char **start, off_t off,
839 int count, int *eof, void *data);
840 extern int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
841 unsigned long count, void *data);
842 extern int lprocfs_quota_rd_switch_qs(char *page, char **start, off_t off,
843 int count, int *eof, void *data);
844 extern int lprocfs_quota_wr_switch_qs(struct file *file,
846 unsigned long count, void *data);
847 extern int lprocfs_quota_rd_boundary_factor(char *page, char **start, off_t off,
848 int count, int *eof, void *data);
849 extern int lprocfs_quota_wr_boundary_factor(struct file *file,
851 unsigned long count, void *data);
852 extern int lprocfs_quota_rd_least_bunit(char *page, char **start, off_t off,
853 int count, int *eof, void *data);
854 extern int lprocfs_quota_wr_least_bunit(struct file *file,
856 unsigned long count, void *data);
857 extern int lprocfs_quota_rd_least_iunit(char *page, char **start, off_t off,
858 int count, int *eof, void *data);
859 extern int lprocfs_quota_wr_least_iunit(struct file *file,
861 unsigned long count, void *data);
862 extern int lprocfs_quota_rd_qs_factor(char *page, char **start, off_t off,
863 int count, int *eof, void *data);
864 extern int lprocfs_quota_wr_qs_factor(struct file *file,
866 unsigned long count, void *data);
871 /* LPROCFS is not defined */
873 #define proc_lustre_root NULL
875 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
876 int index, long amount)
878 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
881 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
882 int index, long amount)
884 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
887 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
888 int index, unsigned conf,
889 const char *name, const char *units)
892 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
893 enum lprocfs_fields_flags field)
896 /* NB: we return !NULL to satisfy error checker */
897 static inline struct lprocfs_stats *
898 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
899 { return (struct lprocfs_stats *)1; }
900 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
902 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
904 static inline int lprocfs_register_stats(cfs_proc_dir_entry_t *root,
906 struct lprocfs_stats *stats)
908 static inline void lprocfs_init_ops_stats(int num_private_stats,
909 struct lprocfs_stats *stats)
911 static inline void lprocfs_init_mps_stats(int num_private_stats,
912 struct lprocfs_stats *stats)
914 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
916 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
917 unsigned int num_private_stats)
919 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
920 unsigned int num_private_stats)
922 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
924 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
928 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
930 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid,
933 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
935 static inline cfs_proc_dir_entry_t *
936 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
937 cfs_read_proc_t *read_proc, cfs_write_proc_t *write_proc,
938 void *data, struct file_operations *fops)
940 static inline struct proc_dir_entry *
941 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
942 const char *format, ...)
944 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
947 int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
948 unsigned long count, void *data)
951 int lprocfs_nid_stats_clear_read(char *page, char **start, off_t off,
952 int count, int *eof, void *data)
955 static inline cfs_proc_dir_entry_t *
956 lprocfs_register(const char *name, cfs_proc_dir_entry_t *parent,
957 struct lprocfs_vars *list, void *data)
959 static inline int lprocfs_add_vars(cfs_proc_dir_entry_t *root,
960 struct lprocfs_vars *var,
963 static inline void lprocfs_remove(cfs_proc_dir_entry_t **root)
965 static inline void lprocfs_remove_proc_entry(const char *name,
966 struct proc_dir_entry *parent)
968 static inline void lprocfs_try_remove_proc_entry(const char *name,
969 struct proc_dir_entry *parent)
971 static inline cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *head,
974 static inline int lprocfs_obd_setup(struct obd_device *dev,
975 struct lprocfs_vars *list)
977 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
979 static inline int lprocfs_rd_u64(char *page, char **start, off_t off,
980 int count, int *eof, void *data)
982 static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
983 int count, int *eof, void *data)
985 static inline int lprocfs_rd_name(char *page, char **start, off_t off,
986 int count, int *eof, void *data)
988 static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
989 int count, int *eof, void *data)
991 static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
992 int count, int *eof, void *data)
994 static inline int lprocfs_rd_import(char *page, char **start, off_t off,
995 int count, int *eof, void *data)
997 static inline int lprocfs_rd_pinger_recov(char *page, char **start, off_t off,
998 int count, int *eof, void *data)
1000 static inline int lprocfs_rd_state(char *page, char **start, off_t off,
1001 int count, int *eof, void *data)
1003 static inline int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
1004 int count, int *eof, void *data)
1006 static inline int lprocfs_rd_num_exports(char *page, char **start, off_t off,
1007 int count, int *eof, void *data)
1009 static inline int lprocfs_rd_numrefs(char *page, char **start, off_t off,
1010 int count, int *eof, void *data)
1012 struct adaptive_timeout;
1013 static inline int lprocfs_at_hist_helper(char *page, int count, int rc,
1014 struct adaptive_timeout *at)
1016 static inline int lprocfs_rd_timeouts(char *page, char **start, off_t off,
1017 int count, int *eof, void *data)
1019 static inline int lprocfs_wr_timeouts(struct file *file,
1021 unsigned long count, void *data)
1023 static inline int lprocfs_wr_evict_client(struct file *file,
1025 unsigned long count, void *data)
1027 static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
1028 unsigned long count, void *data)
1030 static inline int lprocfs_wr_import(struct file *file, const char *buffer,
1031 unsigned long count, void *data)
1033 static inline int lprocfs_wr_pinger_recov(struct file *file, const char *buffer,
1034 unsigned long count, void *data)
1037 /* Statfs helpers */
1039 int lprocfs_rd_blksize(char *page, char **start, off_t off,
1040 int count, int *eof, void *data)
1043 int lprocfs_rd_kbytestotal(char *page, char **start, off_t off,
1044 int count, int *eof, void *data)
1047 int lprocfs_rd_kbytesfree(char *page, char **start, off_t off,
1048 int count, int *eof, void *data)
1051 int lprocfs_rd_kbytesavail(char *page, char **start, off_t off,
1052 int count, int *eof, void *data)
1055 int lprocfs_rd_filestotal(char *page, char **start, off_t off,
1056 int count, int *eof, void *data)
1059 int lprocfs_rd_filesfree(char *page, char **start, off_t off,
1060 int count, int *eof, void *data)
1063 int lprocfs_rd_filegroups(char *page, char **start, off_t off,
1064 int count, int *eof, void *data)
1067 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1070 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1073 void lprocfs_oh_clear(struct obd_histogram *oh)
1076 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1079 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1080 struct lprocfs_counter *cnt)
1083 __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1084 enum lprocfs_fields_flags field)
1085 { return (__u64)0; }
1087 #define LPROC_SEQ_FOPS_RO(name)
1088 #define LPROC_SEQ_FOPS(name)
1090 /* lprocfs_jobstats.c */
1092 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1096 void lprocfs_job_stats_fini(struct obd_device *obd)
1099 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1100 cntr_init_callback fn)
1104 /* lproc_ptlrpc.c */
1105 #define target_print_req NULL
1107 #endif /* LPROCFS */
1109 #endif /* LPROCFS_SNMP_H */