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, 2014, 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 #include <lustre/lustre_idl.h>
46 #include <libcfs/params_tree.h>
48 #ifndef HAVE_ONLY_PROCFS_SEQ
51 read_proc_t *read_fptr;
52 write_proc_t *write_fptr;
54 const struct file_operations *fops;
61 struct lprocfs_static_vars {
62 struct lprocfs_vars *module_vars;
63 struct lprocfs_vars *obd_vars;
68 struct lprocfs_seq_vars {
70 const struct file_operations *fops;
78 /* if we find more consumers this could be generalized */
79 #define OBD_HIST_MAX 32
80 struct obd_histogram {
82 unsigned long oh_buckets[OBD_HIST_MAX];
104 struct obd_histogram hist[BRW_LAST];
108 RENAME_SAMEDIR_SIZE = 0,
109 RENAME_CROSSDIR_SRC_SIZE,
110 RENAME_CROSSDIR_TGT_SIZE,
114 struct rename_stats {
115 struct obd_histogram hist[RENAME_LAST];
118 /* An lprocfs counter can be configured using the enum bit masks below.
120 * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
121 * protects this counter from concurrent updates. If not specified,
122 * lprocfs an internal per-counter lock variable. External locks are
123 * not used to protect counter increments, but are used to protect
124 * counter readout and resets.
126 * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
127 * (i.e. counter can be incremented by more than "1"). When specified,
128 * the counter maintains min, max and sum in addition to a simple
129 * invocation count. This allows averages to be be computed.
130 * If not specified, the counter is an increment-by-1 counter.
131 * min, max, sum, etc. are not maintained.
133 * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
134 * squares (for multi-valued counter samples only). This allows
135 * external computation of standard deviation, but involves a 64-bit
136 * multiply per counter increment.
140 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
141 LPROCFS_CNTR_AVGMINMAX = 0x0002,
142 LPROCFS_CNTR_STDDEV = 0x0004,
144 /* counter data type */
145 LPROCFS_TYPE_REGS = 0x0100,
146 LPROCFS_TYPE_BYTES = 0x0200,
147 LPROCFS_TYPE_PAGES = 0x0400,
148 LPROCFS_TYPE_CYCLE = 0x0800,
151 #define LC_MIN_INIT ((~(__u64)0) >> 1)
153 struct lprocfs_counter_header {
154 unsigned int lc_config;
155 const char *lc_name; /* must be static */
156 const char *lc_units; /* must be static */
159 struct lprocfs_counter {
165 * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
166 * for irq context counter, i.e. stats with
167 * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
170 __s64 lc_array_sum[1];
172 #define lc_sum lc_array_sum[0]
173 #define lc_sum_irq lc_array_sum[1]
175 struct lprocfs_percpu {
176 struct lprocfs_counter lp_cntr[0];
179 #define LPROCFS_GET_NUM_CPU 0x0001
180 #define LPROCFS_GET_SMP_ID 0x0002
182 enum lprocfs_stats_flags {
183 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
184 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
185 * area and need locking */
186 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
189 enum lprocfs_fields_flags {
190 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
191 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
192 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
193 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
194 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
195 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
196 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
199 struct lprocfs_stats {
201 unsigned short ls_num;
202 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
203 unsigned short ls_biggest_alloc_num;
204 enum lprocfs_stats_flags ls_flags;
205 /* Lock used when there are no percpu stats areas; For percpu stats,
206 * it is used to protect ls_biggest_alloc_num change */
209 /* has ls_num of counter headers */
210 struct lprocfs_counter_header *ls_cnt_header;
211 struct lprocfs_percpu *ls_percpu[0];
214 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
216 /* Pack all opcodes down into a single monotonically increasing index */
217 static inline int opcode_offset(__u32 opc) {
218 if (opc < OST_LAST_OPC) {
220 return (opc - OST_FIRST_OPC);
221 } else if (opc < MDS_LAST_OPC) {
223 return (opc - MDS_FIRST_OPC +
225 } else if (opc < LDLM_LAST_OPC) {
227 return (opc - LDLM_FIRST_OPC +
230 } else if (opc < MGS_LAST_OPC) {
232 return (opc - MGS_FIRST_OPC +
236 } else if (opc < OBD_LAST_OPC) {
238 return (opc - OBD_FIRST_OPC +
243 } else if (opc < LLOG_LAST_OPC) {
245 return (opc - LLOG_FIRST_OPC +
251 } else if (opc < QUOTA_LAST_OPC) {
253 return (opc - QUOTA_FIRST_OPC +
260 } else if (opc < SEQ_LAST_OPC) {
262 return (opc - SEQ_FIRST_OPC +
270 } else if (opc < SEC_LAST_OPC) {
272 return (opc - SEC_FIRST_OPC +
281 } else if (opc < FLD_LAST_OPC) {
283 return (opc - FLD_FIRST_OPC +
293 } else if (opc < OUT_UPDATE_LAST_OPC) {
295 return (opc - OUT_UPDATE_FIRST_OPC +
306 } else if (opc < LFSCK_LAST_OPC) {
308 return (opc - LFSCK_FIRST_OPC +
309 OPC_RANGE(OUT_UPDATE) +
327 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
337 OPC_RANGE(OUT_UPDATE) + \
340 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
344 PTLRPC_REQWAIT_CNTR = 0,
345 PTLRPC_REQQDEPTH_CNTR,
346 PTLRPC_REQACTIVE_CNTR,
348 PTLRPC_REQBUF_AVAIL_CNTR,
352 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
354 enum lprocfs_extra_opc {
355 LDLM_GLIMPSE_ENQUEUE = 0,
372 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
374 extern struct proc_dir_entry *proc_lustre_root;
377 struct obd_histogram;
379 /* Days / hours / mins / seconds format */
383 static inline void s2dhms(struct dhms *ts, time_t secs)
385 ts->d = secs / 86400;
392 #define DHMS_FMT "%dd%dh%02dm%02ds"
393 #define DHMS_VARS(x) (x)->d, (x)->h, (x)->m, (x)->s
395 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
396 #define JOBSTATS_DISABLE "disable"
397 #define JOBSTATS_PROCNAME_UID "procname_uid"
399 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
401 struct obd_job_stats {
402 cfs_hash_t *ojs_hash;
403 struct list_head ojs_list;
404 rwlock_t ojs_lock; /* protect the obj_list */
405 cntr_init_callback ojs_cntr_init_fn;
407 int ojs_cleanup_interval;
408 time_t ojs_last_cleanup;
413 extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
417 * < 0 : on error (only possible for opc as LPROCFS_GET_SMP_ID)
419 static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc,
420 unsigned long *flags)
428 case LPROCFS_GET_SMP_ID:
429 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
430 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
431 spin_lock_irqsave(&stats->ls_lock, *flags);
433 spin_lock(&stats->ls_lock);
436 unsigned int cpuid = get_cpu();
438 if (unlikely(stats->ls_percpu[cpuid] == NULL)) {
439 rc = lprocfs_stats_alloc_one(stats, cpuid);
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_lock_irqsave(&stats->ls_lock, *flags);
453 spin_lock(&stats->ls_lock);
456 return stats->ls_biggest_alloc_num;
461 static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats, int opc,
462 unsigned long *flags)
468 case LPROCFS_GET_SMP_ID:
469 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
470 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
471 spin_unlock_irqrestore(&stats->ls_lock,
474 spin_unlock(&stats->ls_lock);
481 case LPROCFS_GET_NUM_CPU:
482 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
483 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
484 spin_unlock_irqrestore(&stats->ls_lock,
487 spin_unlock(&stats->ls_lock);
494 static inline unsigned int
495 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
497 unsigned int percpusize;
499 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
501 /* irq safe stats need lc_array_sum[1] */
502 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
503 percpusize += stats->ls_num * sizeof(__s64);
505 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
506 percpusize = L1_CACHE_ALIGN(percpusize);
511 static inline struct lprocfs_counter *
512 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
515 struct lprocfs_counter *cntr;
517 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
519 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
520 cntr = (void *)cntr + index * sizeof(__s64);
525 /* Two optimized LPROCFS counter increment functions are provided:
526 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
527 * lprocfs_counter_add(cntr) - use for multi-valued counters
528 * Counter data layout allows config flag, counter lock and the
529 * count itself to reside within a single cache line.
532 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
534 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
537 #define lprocfs_counter_incr(stats, idx) \
538 lprocfs_counter_add(stats, idx, 1)
539 #define lprocfs_counter_decr(stats, idx) \
540 lprocfs_counter_sub(stats, idx, 1)
542 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
543 struct lprocfs_counter_header *header,
544 enum lprocfs_stats_flags flags,
545 enum lprocfs_fields_flags field);
546 static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats,
548 enum lprocfs_fields_flags field)
551 unsigned int num_cpu;
552 unsigned long flags = 0;
555 LASSERT(stats != NULL);
557 num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
558 for (i = 0; i < num_cpu; i++) {
559 if (stats->ls_percpu[i] == NULL)
561 ret += lprocfs_read_helper(
562 lprocfs_stats_counter_get(stats, i, idx),
563 &stats->ls_cnt_header[idx], stats->ls_flags,
566 lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
570 extern struct lprocfs_stats *
571 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
572 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
573 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
574 extern void lprocfs_init_ops_stats(int num_private_stats,
575 struct lprocfs_stats *stats);
576 extern void lprocfs_init_mps_stats(int num_private_stats,
577 struct lprocfs_stats *stats);
578 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
579 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
580 unsigned int num_private_stats);
581 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
582 unsigned int num_private_stats);
583 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
584 unsigned conf, const char *name,
586 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
587 extern void lprocfs_free_md_stats(struct obd_device *obddev);
590 extern int lprocfs_add_clear_entry(struct obd_device * obd,
591 struct proc_dir_entry *entry);
592 #ifdef HAVE_SERVER_SUPPORT
593 extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid);
594 extern int lprocfs_exp_cleanup(struct obd_export *exp);
596 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
599 extern struct proc_dir_entry *
600 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
601 void *data, const struct file_operations *fops);
602 extern struct proc_dir_entry *
603 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
604 const char *format, ...);
605 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
606 #ifdef HAVE_SERVER_SUPPORT
608 lprocfs_nid_stats_clear_seq_write(struct file *file, const char *buffer,
609 size_t count, loff_t *off);
610 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
612 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
613 struct lprocfs_stats *stats);
615 /* lprocfs_status.c */
616 #ifndef HAVE_ONLY_PROCFS_SEQ
617 extern int lprocfs_add_vars(struct proc_dir_entry *root,
618 struct lprocfs_vars *var,
621 extern struct proc_dir_entry *lprocfs_register(const char *name,
622 struct proc_dir_entry *parent,
623 struct lprocfs_vars *list,
626 extern int lprocfs_seq_add_vars(struct proc_dir_entry *root,
627 struct lprocfs_seq_vars *var,
630 extern struct proc_dir_entry *
631 lprocfs_seq_register(const char *name, struct proc_dir_entry *parent,
632 struct lprocfs_seq_vars *list, void *data);
633 extern void lprocfs_remove(struct proc_dir_entry **root);
634 extern void lprocfs_remove_proc_entry(const char *name,
635 struct proc_dir_entry *parent);
636 #ifndef HAVE_ONLY_PROCFS_SEQ
637 extern void lprocfs_try_remove_proc_entry(const char *name,
638 struct proc_dir_entry *parent);
640 extern struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *root,
643 extern int lprocfs_obd_setup(struct obd_device *dev);
644 extern int lprocfs_obd_cleanup(struct obd_device *obd);
645 #ifdef HAVE_SERVER_SUPPORT
646 extern const struct file_operations lprocfs_evict_client_fops;
648 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
650 const struct file_operations *seq_fops,
652 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
654 const struct file_operations *seq_fops,
657 /* Generic callbacks */
658 extern int lprocfs_u64_seq_show(struct seq_file *m, void *data);
659 extern int lprocfs_atomic_seq_show(struct seq_file *m, void *data);
660 extern ssize_t lprocfs_atomic_seq_write(struct file *file,
661 const char __user *buffer,
662 size_t count, loff_t *off);
663 extern int lprocfs_uint_seq_show(struct seq_file *m, void *data);
664 extern ssize_t lprocfs_uint_seq_write(struct file *file,
665 const char __user *buffer,
666 size_t count, loff_t *off);
667 extern int lprocfs_wr_uint(struct file *file, const char __user *buffer,
668 unsigned long count, void *data);
669 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
670 extern int lprocfs_name_seq_show(struct seq_file *m, void *data);
671 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
672 extern int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data);
673 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
674 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
675 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
676 #ifdef HAVE_SERVER_SUPPORT
677 extern int lprocfs_num_exports_seq_show(struct seq_file *m, void *data);
679 struct adaptive_timeout;
680 extern int lprocfs_seq_at_hist_helper(struct seq_file *m,
681 struct adaptive_timeout *at);
682 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
684 lprocfs_timeouts_seq_write(struct file *file, const char *buffer,
685 size_t count, loff_t *off);
686 #ifdef HAVE_SERVER_SUPPORT
687 #ifndef HAVE_ONLY_PROCFS_SEQ
688 extern ssize_t lprocfs_fops_read(struct file *f, char __user *buf,
689 size_t size, loff_t *ppos);
690 extern ssize_t lprocfs_fops_write(struct file *f, const char __user *buf,
691 size_t size, loff_t *ppos);
694 lprocfs_evict_client_seq_write(struct file *file, const char *buffer,
695 size_t count, loff_t *off);
698 lprocfs_ping_seq_write(struct file *file, const char *buffer,
699 size_t count, loff_t *off);
701 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
702 size_t count, loff_t *off);
703 extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data);
705 lprocfs_pinger_recov_seq_write(struct file *file, const char *buffer,
706 size_t count, loff_t *off);
709 extern int lprocfs_blksize_seq_show(struct seq_file *m, void *data);
710 extern int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data);
711 extern int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data);
712 extern int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data);
713 extern int lprocfs_filestotal_seq_show(struct seq_file *m, void *data);
714 extern int lprocfs_filesfree_seq_show(struct seq_file *m, void *data);
716 extern int lprocfs_write_helper(const char __user *buffer, unsigned long count,
718 extern int lprocfs_write_frac_helper(const char __user *buffer,
721 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
722 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
724 extern int lprocfs_write_u64_helper(const char __user *buffer,
725 unsigned long count, __u64 *val);
726 extern int lprocfs_write_frac_u64_helper(const char __user *buffer,
728 __u64 *val, int mult);
729 char *lprocfs_find_named_value(const char *buffer, const char *name,
731 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
732 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
733 void lprocfs_oh_clear(struct obd_histogram *oh);
734 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
736 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
737 struct lprocfs_counter *cnt);
739 #ifdef HAVE_SERVER_SUPPORT
740 /* lprocfs_status.c: recovery status */
741 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
743 /* lprocfs_status.c: hash statistics */
744 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
746 /* lprocfs_status.c: IR factor */
747 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data);
749 lprocfs_ir_factor_seq_write(struct file *file, const char *buffer,
750 size_t count, loff_t *off);
752 extern int lprocfs_single_release(struct inode *, struct file *);
753 extern int lprocfs_seq_release(struct inode *, struct file *);
755 /* You must use these macros when you want to refer to
756 * the import in a client obd_device for a lprocfs entry */
757 #define LPROCFS_CLIMP_CHECK(obd) do { \
758 typecheck(struct obd_device *, obd); \
759 down_read(&(obd)->u.cli.cl_sem); \
760 if ((obd)->u.cli.cl_import == NULL) { \
761 up_read(&(obd)->u.cli.cl_sem); \
765 #define LPROCFS_CLIMP_EXIT(obd) \
766 up_read(&(obd)->u.cli.cl_sem);
768 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
769 proc entries; otherwise, you will define name##_seq_write function also for
770 a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
771 call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
772 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
773 static int name##_single_open(struct inode *inode, struct file *file) \
775 LPROCFS_ENTRY_CHECK(PDE(inode)); \
776 return single_open(file, name##_seq_show, PDE_DATA(inode)); \
778 static const struct file_operations name##_fops = { \
779 .owner = THIS_MODULE, \
780 .open = name##_single_open, \
782 .write = custom_seq_write, \
783 .llseek = seq_lseek, \
784 .release = lprocfs_single_release, \
787 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
788 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
790 #define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
791 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
793 return lprocfs_##type##_seq_show(m, m->private); \
795 LPROC_SEQ_FOPS_RO(name##_##type)
797 #define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
798 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
800 return lprocfs_##type##_seq_show(m, m->private); \
802 static ssize_t name##_##type##_seq_write(struct file *file, \
803 const char __user *buffer, size_t count, \
806 struct seq_file *seq = file->private_data; \
807 return lprocfs_##type##_seq_write(file, buffer, \
808 count, seq->private); \
810 LPROC_SEQ_FOPS(name##_##type);
812 #define LPROC_SEQ_FOPS_WO_TYPE(name, type) \
813 static ssize_t name##_##type##_write(struct file *file, \
814 const char __user *buffer, size_t count, \
817 return lprocfs_##type##_seq_write(file, buffer, count, off);\
819 static int name##_##type##_open(struct inode *inode, struct file *file)\
821 return single_open(file, NULL, PDE_DATA(inode)); \
823 static const struct file_operations name##_##type##_fops = { \
824 .open = name##_##type##_open, \
825 .write = name##_##type##_write, \
826 .release = lprocfs_single_release, \
830 struct ptlrpc_request;
831 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
833 #ifdef HAVE_SERVER_SUPPORT
834 /* lprocfs_jobstats.c */
835 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
836 int event, long amount);
837 void lprocfs_job_stats_fini(struct obd_device *obd);
838 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
839 cntr_init_callback fn);
840 int lprocfs_job_interval_seq_show(struct seq_file *m, void *data);
842 lprocfs_job_interval_seq_write(struct file *file, const char *buffer,
843 size_t count, loff_t *off);
845 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data);
846 ssize_t lprocfs_recovery_time_soft_seq_write(struct file *file,
848 size_t count, loff_t *off);
849 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data);
851 lprocfs_recovery_time_hard_seq_write(struct file *file, const char *buffer,
852 size_t count, loff_t *off);
853 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data);
855 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
857 lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file, const char *buffer,
858 size_t count, loff_t *off);
860 struct root_squash_info;
861 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
862 struct root_squash_info *squash, char *name);
863 int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
864 struct root_squash_info *squash, char *name);
866 /* all quota proc functions */
867 extern int lprocfs_quota_rd_bunit(char *page, char **start,
868 off_t off, int count,
869 int *eof, void *data);
870 extern int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
871 unsigned long count, void *data);
872 extern int lprocfs_quota_rd_btune(char *page, char **start,
873 off_t off, int count,
874 int *eof, void *data);
875 extern int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
876 unsigned long count, void *data);
877 extern int lprocfs_quota_rd_iunit(char *page, char **start,
878 off_t off, int count,
879 int *eof, void *data);
880 extern int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
881 unsigned long count, void *data);
882 extern int lprocfs_quota_rd_itune(char *page, char **start,
883 off_t off, int count,
884 int *eof, void *data);
885 extern int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
886 unsigned long count, void *data);
887 extern int lprocfs_quota_rd_type(char *page, char **start, off_t off, int count,
888 int *eof, void *data);
889 extern int lprocfs_quota_wr_type(struct file *file, const char *buffer,
890 unsigned long count, void *data);
891 extern int lprocfs_quota_rd_switch_seconds(char *page, char **start, off_t off,
892 int count, int *eof, void *data);
893 extern int lprocfs_quota_wr_switch_seconds(struct file *file,
895 unsigned long count, void *data);
896 extern int lprocfs_quota_rd_sync_blk(char *page, char **start, off_t off,
897 int count, int *eof, void *data);
898 extern int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
899 unsigned long count, void *data);
900 extern int lprocfs_quota_rd_switch_qs(char *page, char **start, off_t off,
901 int count, int *eof, void *data);
902 extern int lprocfs_quota_wr_switch_qs(struct file *file,
904 unsigned long count, void *data);
905 extern int lprocfs_quota_rd_boundary_factor(char *page, char **start, off_t off,
906 int count, int *eof, void *data);
907 extern int lprocfs_quota_wr_boundary_factor(struct file *file,
909 unsigned long count, void *data);
910 extern int lprocfs_quota_rd_least_bunit(char *page, char **start, off_t off,
911 int count, int *eof, void *data);
912 extern int lprocfs_quota_wr_least_bunit(struct file *file,
914 unsigned long count, void *data);
915 extern int lprocfs_quota_rd_least_iunit(char *page, char **start, off_t off,
916 int count, int *eof, void *data);
917 extern int lprocfs_quota_wr_least_iunit(struct file *file,
919 unsigned long count, void *data);
920 extern int lprocfs_quota_rd_qs_factor(char *page, char **start, off_t off,
921 int count, int *eof, void *data);
922 extern int lprocfs_quota_wr_qs_factor(struct file *file,
924 unsigned long count, void *data);
926 /* LPROCFS is not defined */
928 #define proc_lustre_root NULL
930 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
931 int index, long amount)
933 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
936 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
937 int index, long amount)
939 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
942 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
943 int index, unsigned conf,
944 const char *name, const char *units)
947 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
948 enum lprocfs_fields_flags field)
951 /* NB: we return !NULL to satisfy error checker */
952 static inline struct lprocfs_stats *
953 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
954 { return (struct lprocfs_stats *)1; }
955 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
957 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
959 static inline int lprocfs_register_stats(struct proc_dir_entry *root,
961 struct lprocfs_stats *stats)
963 static inline void lprocfs_init_ops_stats(int num_private_stats,
964 struct lprocfs_stats *stats)
966 static inline void lprocfs_init_mps_stats(int num_private_stats,
967 struct lprocfs_stats *stats)
969 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
971 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
972 unsigned int num_private_stats)
974 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
975 unsigned int num_private_stats)
977 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
979 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
983 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
985 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
987 #ifdef HAVE_SERVER_SUPPORT
989 ssize_t lprocfs_nid_stats_seq_write(struct file *file, const char *buffer,
990 size_t count, loff_t *off)
993 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
995 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid)
998 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
1000 static inline struct proc_dir_entry *
1001 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
1002 void *data, const struct file_operations *fops)
1004 static inline struct proc_dir_entry *
1005 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
1006 const char *format, ...)
1008 #ifndef HAVE_ONLY_PROCFS_SEQ
1009 static inline struct proc_dir_entry *
1010 lprocfs_register(const char *name, struct proc_dir_entry *parent,
1011 struct lprocfs_vars *list, void *data)
1013 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
1014 struct lprocfs_vars *var,
1018 static inline int lprocfs_seq_add_vars(struct proc_dir_entry *root,
1019 struct lprocfs_seq_vars *var,
1022 static inline struct proc_dir_entry *
1023 lprocfs_seq_register(const char *name, struct proc_dir_entry *parent,
1024 struct lprocfs_seq_vars *list, void *data)
1026 static inline void lprocfs_remove(struct proc_dir_entry **root)
1028 static inline void lprocfs_remove_proc_entry(const char *name,
1029 struct proc_dir_entry *parent)
1031 #ifndef HAVE_ONLY_PROCFS_SEQ
1032 static inline void lprocfs_try_remove_proc_entry(const char *name,
1033 struct proc_dir_entry *parent)
1035 static inline struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
1039 static inline int lprocfs_obd_setup(struct obd_device *dev)
1041 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
1043 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
1045 static inline int lprocfs_name_seq_show(struct seq_file *m, void *data)
1047 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
1049 static inline int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data)
1051 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
1053 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
1055 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
1057 #ifdef HAVE_SERVER_SUPPORT
1058 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
1061 struct adaptive_timeout;
1062 static inline int lprocfs_seq_at_hist_helper(struct seq_file *m,
1063 struct adaptive_timeout *at)
1065 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
1067 static inline ssize_t
1068 lprocfs_timeouts_seq_write(struct file *file, const char *buffer,
1069 size_t count, loff_t *off)
1071 #ifdef HAVE_SERVER_SUPPORT
1072 static inline ssize_t
1073 lprocfs_evict_client_seq_write(struct file *file, const char *buffer,
1074 size_t count, loff_t *off)
1077 static inline ssize_t
1078 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
1079 size_t count, loff_t *off)
1081 static inline ssize_t
1082 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
1083 size_t count, loff_t *off)
1086 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
1088 static inline ssize_t
1089 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
1090 size_t count, loff_t *off)
1093 /* Statfs helpers */
1095 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
1098 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
1101 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
1104 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
1107 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
1110 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
1113 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1116 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1119 void lprocfs_oh_clear(struct obd_histogram *oh)
1122 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1125 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1126 struct lprocfs_counter *cnt)
1129 __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1130 enum lprocfs_fields_flags field)
1131 { return (__u64)0; }
1133 #define LPROC_SEQ_FOPS_RO(name)
1134 #define LPROC_SEQ_FOPS(name)
1135 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
1136 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
1137 #define LPROC_SEQ_FOPS_WO_TYPE(name, type)
1139 /* lprocfs_jobstats.c */
1141 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1145 void lprocfs_job_stats_fini(struct obd_device *obd)
1148 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1149 cntr_init_callback fn)
1153 /* lproc_ptlrpc.c */
1154 #define target_print_req NULL
1156 #endif /* LPROCFS */
1158 #endif /* LPROCFS_SNMP_H */