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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/include/lprocfs_status.h
34 * Top level header file for LProc
36 * Author: Hariharan Thantry thantry@users.sourceforge.net
38 #ifndef _LPROCFS_STATUS_H
39 #define _LPROCFS_STATUS_H
42 #include <linux/proc_fs.h>
43 #include <linux/debugfs.h>
44 #include <linux/rwsem.h>
45 #include <linux/spinlock.h>
46 #include <linux/string_helpers.h>
47 #include <linux/seq_file.h>
49 #include <libcfs/libcfs.h>
50 #include <uapi/linux/lustre/lustre_idl.h>
54 const struct file_operations *fops;
62 static inline unsigned int pct(unsigned long a, unsigned long b)
64 return b ? a * 100 / b : 0;
67 #define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
68 #define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
71 * Append a space separated list of current set flags to str.
73 #define flag2str(port, flag) \
75 if ((port)->port##_##flag) { \
76 seq_printf(m, "%s" #flag, first ? "" : ", "); \
81 void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, __u64 flags2,
83 void obd_connect_data_seqprint(struct seq_file *m,
84 struct obd_connect_data *ocd);
86 /* if we find more consumers this could be generalized */
87 #define OBD_HIST_MAX 32
88 struct obd_histogram {
90 unsigned long oh_buckets[OBD_HIST_MAX];
102 BRW_R_DISCONT_BLOCKS,
103 BRW_W_DISCONT_BLOCKS,
112 struct obd_histogram hist[BRW_LAST];
116 RENAME_SAMEDIR_SIZE = 0,
117 RENAME_CROSSDIR_SRC_SIZE,
118 RENAME_CROSSDIR_TGT_SIZE,
122 struct rename_stats {
123 struct obd_histogram hist[RENAME_LAST];
126 /* An lprocfs counter can be configured using the enum bit masks below.
128 * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
129 * protects this counter from concurrent updates. If not specified,
130 * lprocfs an internal per-counter lock variable. External locks are
131 * not used to protect counter increments, but are used to protect
132 * counter readout and resets.
134 * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
135 * (i.e. counter can be incremented by more than "1"). When specified,
136 * the counter maintains min, max and sum in addition to a simple
137 * invocation count. This allows averages to be be computed.
138 * If not specified, the counter is an increment-by-1 counter.
139 * min, max, sum, etc. are not maintained.
141 * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
142 * squares (for multi-valued counter samples only). This allows
143 * external computation of standard deviation, but involves a 64-bit
144 * multiply per counter increment.
148 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
149 LPROCFS_CNTR_AVGMINMAX = 0x0002,
150 LPROCFS_CNTR_STDDEV = 0x0004,
152 /* counter data type */
153 LPROCFS_TYPE_REQS = 0x0100,
154 LPROCFS_TYPE_BYTES = 0x0200,
155 LPROCFS_TYPE_PAGES = 0x0400,
156 LPROCFS_TYPE_USEC = 0x0800,
158 LPROCFS_TYPE_LATENCY = LPROCFS_TYPE_USEC |
159 LPROCFS_CNTR_AVGMINMAX |
161 LPROCFS_TYPE_BYTES_FULL = LPROCFS_TYPE_BYTES |
162 LPROCFS_CNTR_AVGMINMAX |
165 #define LC_MIN_INIT ((~(__u64)0) >> 1)
167 struct lprocfs_counter_header {
168 unsigned int lc_config;
169 const char *lc_name; /* must be static */
170 const char *lc_units; /* must be static */
173 struct lprocfs_counter {
179 * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
180 * for irq context counter, i.e. stats with
181 * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
184 __s64 lc_array_sum[1];
186 #define lc_sum lc_array_sum[0]
187 #define lc_sum_irq lc_array_sum[1]
189 struct lprocfs_percpu {
190 struct lprocfs_counter lp_cntr[0];
193 enum lprocfs_stats_lock_ops {
194 LPROCFS_GET_NUM_CPU = 0x0001, /* number allocated per-CPU stats */
195 LPROCFS_GET_SMP_ID = 0x0002, /* current stat to be updated */
198 enum lprocfs_stats_flags {
199 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
200 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
201 * area and need locking */
202 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
205 enum lprocfs_fields_flags {
206 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
207 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
208 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
209 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
210 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
211 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
212 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
215 struct lprocfs_stats {
217 unsigned short ls_num;
218 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
219 unsigned short ls_biggest_alloc_num;
220 enum lprocfs_stats_flags ls_flags;
221 /* Lock used when there are no percpu stats areas; For percpu stats,
222 * it is used to protect ls_biggest_alloc_num change */
225 /* has ls_num of counter headers */
226 struct lprocfs_counter_header *ls_cnt_header;
227 struct lprocfs_percpu *ls_percpu[0];
230 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
232 /* Pack all opcodes down into a single monotonically increasing index */
233 static inline int opcode_offset(__u32 opc) {
234 if (opc < OST_LAST_OPC) {
236 return (opc - OST_FIRST_OPC);
237 } else if (opc < MDS_LAST_OPC) {
239 return (opc - MDS_FIRST_OPC +
241 } else if (opc < LDLM_LAST_OPC) {
243 return (opc - LDLM_FIRST_OPC +
246 } else if (opc < MGS_LAST_OPC) {
248 return (opc - MGS_FIRST_OPC +
252 } else if (opc < OBD_LAST_OPC) {
254 return (opc - OBD_FIRST_OPC +
259 } else if (opc < LLOG_LAST_OPC) {
261 return (opc - LLOG_FIRST_OPC +
267 } else if (opc < QUOTA_LAST_OPC) {
269 return (opc - QUOTA_FIRST_OPC +
276 } else if (opc < SEQ_LAST_OPC) {
278 return (opc - SEQ_FIRST_OPC +
286 } else if (opc < SEC_LAST_OPC) {
288 return (opc - SEC_FIRST_OPC +
297 } else if (opc < FLD_LAST_OPC) {
299 return (opc - FLD_FIRST_OPC +
309 } else if (opc < OUT_UPDATE_LAST_OPC) {
311 return (opc - OUT_UPDATE_FIRST_OPC +
322 } else if (opc < LFSCK_LAST_OPC) {
324 return (opc - LFSCK_FIRST_OPC +
325 OPC_RANGE(OUT_UPDATE) +
343 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
353 OPC_RANGE(OUT_UPDATE) + \
356 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
360 PTLRPC_REQWAIT_CNTR = 0,
361 PTLRPC_REQQDEPTH_CNTR,
362 PTLRPC_REQACTIVE_CNTR,
364 PTLRPC_REQBUF_AVAIL_CNTR,
368 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
370 enum lprocfs_extra_opc {
371 LDLM_GLIMPSE_ENQUEUE = 0,
389 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
391 extern struct proc_dir_entry *proc_lustre_root;
392 extern struct dentry *debugfs_lustre_root;
393 extern struct kset *lustre_kset;
396 struct obd_histogram;
398 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
399 #define JOBSTATS_DISABLE "disable"
400 #define JOBSTATS_PROCNAME_UID "procname_uid"
401 #define JOBSTATS_NODELOCAL "nodelocal"
402 #define JOBSTATS_SESSION "session"
404 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats,
405 unsigned int offset);
407 struct obd_job_stats {
408 struct cfs_hash *ojs_hash; /* hash of jobids */
409 struct list_head ojs_list; /* list of job_stat structs */
410 rwlock_t ojs_lock; /* protect ojs_list/js_list */
411 unsigned int ojs_cleanup_interval;/* seconds before expiry */
412 time64_t ojs_last_cleanup; /* previous cleanup time */
413 cntr_init_callback ojs_cntr_init_fn;/* lprocfs_stats initializer */
414 unsigned short ojs_cntr_num; /* number of stats in struct */
415 bool ojs_cleaning; /* currently expiring stats */
418 #ifdef CONFIG_PROC_FS
420 int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
422 int lprocfs_stats_lock(struct lprocfs_stats *stats,
423 enum lprocfs_stats_lock_ops opc,
424 unsigned long *flags);
425 void lprocfs_stats_unlock(struct lprocfs_stats *stats,
426 enum lprocfs_stats_lock_ops opc,
427 unsigned long *flags);
429 static inline unsigned int
430 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
432 unsigned int percpusize;
434 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
436 /* irq safe stats need lc_array_sum[1] */
437 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
438 percpusize += stats->ls_num * sizeof(__s64);
440 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
441 percpusize = L1_CACHE_ALIGN(percpusize);
446 static inline struct lprocfs_counter *
447 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
450 struct lprocfs_counter *cntr;
452 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
454 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
455 cntr = (void *)cntr + index * sizeof(__s64);
460 /* Two optimized LPROCFS counter increment functions are provided:
461 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
462 * lprocfs_counter_add(cntr) - use for multi-valued counters
463 * Counter data layout allows config flag, counter lock and the
464 * count itself to reside within a single cache line.
467 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
469 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
472 #define lprocfs_counter_incr(stats, idx) \
473 lprocfs_counter_add(stats, idx, 1)
474 #define lprocfs_counter_decr(stats, idx) \
475 lprocfs_counter_sub(stats, idx, 1)
477 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
478 struct lprocfs_counter_header *header,
479 enum lprocfs_stats_flags flags,
480 enum lprocfs_fields_flags field);
481 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
482 enum lprocfs_fields_flags field);
484 extern struct lprocfs_stats *
485 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
486 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
487 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
488 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
489 extern int lprocfs_alloc_obd_stats(struct obd_device *obd,
490 unsigned int num_stats);
491 extern int lprocfs_alloc_md_stats(struct obd_device *obd,
492 unsigned int num_private_stats);
493 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
494 unsigned conf, const char *name,
496 extern void lprocfs_free_obd_stats(struct obd_device *obd);
497 extern void lprocfs_free_md_stats(struct obd_device *obd);
500 extern int lprocfs_add_clear_entry(struct obd_device *obd,
501 struct proc_dir_entry *entry);
502 #ifdef HAVE_SERVER_SUPPORT
503 extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid);
504 extern int lprocfs_exp_cleanup(struct obd_export *exp);
505 struct dentry *ldebugfs_add_symlink(const char *name, const char *target,
506 const char *format, ...);
508 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
511 extern struct proc_dir_entry *
512 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
513 void *data, const struct file_operations *fops);
514 extern struct proc_dir_entry *
515 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
516 const char *format, ...);
517 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
518 #ifdef HAVE_SERVER_SUPPORT
520 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
521 size_t count, loff_t *off);
522 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
524 extern const struct file_operations lprocfs_stats_seq_fops;
525 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
526 struct lprocfs_stats *stats);
528 /* lprocfs_status.c */
529 extern void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var,
531 extern int lprocfs_add_vars(struct proc_dir_entry *root,
532 struct lprocfs_vars *var, void *data);
534 extern struct proc_dir_entry *
535 lprocfs_register(const char *name, struct proc_dir_entry *parent,
536 struct lprocfs_vars *list, void *data);
538 extern void lprocfs_remove(struct proc_dir_entry **root);
539 extern void lprocfs_remove_proc_entry(const char *name,
540 struct proc_dir_entry *parent);
541 extern int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only);
542 extern int lprocfs_obd_cleanup(struct obd_device *obd);
543 #ifdef HAVE_SERVER_SUPPORT
544 extern const struct file_operations lprocfs_evict_client_fops;
547 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
549 const struct file_operations *seq_fops,
551 extern int lprocfs_obd_seq_create(struct obd_device *obd, const char *name,
553 const struct file_operations *seq_fops,
556 /* Generic callbacks */
557 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
558 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
559 ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf);
560 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
561 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
562 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
563 #ifdef HAVE_SERVER_SUPPORT
564 ssize_t num_exports_show(struct kobject *kobj, struct attribute *attr,
567 struct adaptive_timeout;
568 extern int lprocfs_at_hist_helper(struct seq_file *m,
569 struct adaptive_timeout *at);
570 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
572 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
573 size_t count, loff_t *off);
574 #ifdef HAVE_SERVER_SUPPORT
576 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
577 size_t count, loff_t *off);
579 ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
580 const char *buffer, size_t count);
581 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
585 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
586 size_t count, loff_t *off);
587 extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data);
589 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
590 size_t count, loff_t *off);
592 int string_to_size(u64 *size, const char *buffer, size_t count);
593 int sysfs_memparse(const char *buffer, size_t count, u64 *val,
594 const char *defunit);
595 char *lprocfs_strnstr(const char *s1, const char *s2, size_t len);
596 char *lprocfs_find_named_value(const char *buffer, const char *name,
598 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
599 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
600 void lprocfs_oh_clear(struct obd_histogram *oh);
601 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
603 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
604 struct lprocfs_counter *cnt);
606 #ifdef HAVE_SERVER_SUPPORT
607 /* lprocfs_status.c: recovery status */
608 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
610 /* lprocfs_status.c: hash statistics */
611 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
613 /* lprocfs_status.c: IR factor */
614 ssize_t ir_factor_show(struct kobject *kobj, struct attribute *attr,
616 ssize_t ir_factor_store(struct kobject *kobj, struct attribute *attr,
617 const char *buffer, size_t count);
620 /* lprocfs_status.c: dump pages on cksum error */
621 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data);
623 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
624 size_t count, loff_t *off);
626 extern int lprocfs_single_release(struct inode *, struct file *);
627 extern int lprocfs_seq_release(struct inode *, struct file *);
629 /* You must use these macros when you want to refer to
630 * the import in a client obd_device for a lprocfs entry
632 #define with_imp_locked(__obd, __imp, __rc) \
633 for (down_read(&(__obd)->u.cli.cl_sem), \
634 __imp = (__obd)->u.cli.cl_import, \
635 __rc = __imp ? 0 : -ENODEV; \
636 __imp ? 1 : (up_read(&(__obd)->u.cli.cl_sem), 0); \
639 /* write the name##_seq_show function, call LDEBUGFS_SEQ_FOPS_RO for read-only
640 * debugfs entries; otherwise, you will define name##_seq_write function also
641 * for a read-write debugfs entry, and then call LDEBUGFS_SEQ_FOPS instead.
642 * Finally, call debugfs_create_file(filename, 0444, obd, data, &name#_fops);
644 #define __LDEBUGFS_SEQ_FOPS(name, custom_seq_write) \
645 static int name##_single_open(struct inode *inode, struct file *file) \
647 return single_open(file, name##_seq_show, inode->i_private); \
649 static const struct file_operations name##_fops = { \
650 .owner = THIS_MODULE, \
651 .open = name##_single_open, \
653 .write = custom_seq_write, \
654 .llseek = seq_lseek, \
655 .release = single_release, \
658 #define LDEBUGFS_SEQ_FOPS_RO(name) __LDEBUGFS_SEQ_FOPS(name, NULL)
659 #define LDEBUGFS_SEQ_FOPS(name) __LDEBUGFS_SEQ_FOPS(name, \
662 #define LDEBUGFS_SEQ_FOPS_RO_TYPE(name, type) \
663 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
667 return lprocfs_##type##_seq_show(m, m->private); \
669 LDEBUGFS_SEQ_FOPS_RO(name##_##type)
671 #define LDEBUGFS_SEQ_FOPS_RW_TYPE(name, type) \
672 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
676 return lprocfs_##type##_seq_show(m, m->private); \
678 static ssize_t name##_##type##_seq_write(struct file *file, \
679 const char __user *buffer, size_t count, \
682 struct seq_file *seq = file->private_data; \
686 return ldebugfs_##type##_seq_write(file, buffer, count, \
689 LDEBUGFS_SEQ_FOPS(name##_##type);
691 #define LDEBUGFS_FOPS_WR_ONLY(name, type) \
692 static ssize_t name##_##type##_write(struct file *file, \
693 const char __user *buffer, size_t count, \
696 return ldebugfs_##type##_seq_write(file, buffer, count, \
699 static int name##_##type##_open(struct inode *inode, \
702 return single_open(file, NULL, inode->i_private); \
704 static const struct file_operations name##_##type##_fops = { \
705 .open = name##_##type##_open, \
706 .write = name##_##type##_write, \
707 .release = single_release, \
710 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
711 * proc entries; otherwise, you will define name##_seq_write function also for
712 * a read-write proc entry, and then call LPROC_SEQ_FOPS instead. Finally,
713 * call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data);
715 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
716 static int name##_single_open(struct inode *inode, struct file *file) \
718 return single_open(file, name##_seq_show, \
719 inode->i_private ? inode->i_private : \
722 static const struct file_operations name##_fops = { \
723 .owner = THIS_MODULE, \
724 .open = name##_single_open, \
726 .write = custom_seq_write, \
727 .llseek = seq_lseek, \
728 .release = lprocfs_single_release, \
731 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
732 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
734 #define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
735 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
737 return lprocfs_##type##_seq_show(m, m->private); \
739 LPROC_SEQ_FOPS_RO(name##_##type)
741 #define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
742 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
744 return lprocfs_##type##_seq_show(m, m->private); \
746 static ssize_t name##_##type##_seq_write(struct file *file, \
747 const char __user *buffer, size_t count, \
750 struct seq_file *seq = file->private_data; \
751 return lprocfs_##type##_seq_write(file, buffer, \
752 count, seq->private); \
754 LPROC_SEQ_FOPS(name##_##type);
756 #define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
757 static ssize_t name##_##type##_write(struct file *file, \
758 const char __user *buffer, size_t count, \
761 return lprocfs_##type##_seq_write(file, buffer, count, off);\
763 static int name##_##type##_open(struct inode *inode, struct file *file)\
765 return single_open(file, NULL, \
766 inode->i_private ? inode->i_private : \
769 static const struct file_operations name##_##type##_fops = { \
770 .open = name##_##type##_open, \
771 .write = name##_##type##_write, \
772 .release = lprocfs_single_release, \
776 struct attribute attr;
777 ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
779 ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
780 const char *buf, size_t len);
783 #define LUSTRE_ATTR(name, mode, show, store) \
784 static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
786 #define LUSTRE_WO_ATTR(name) LUSTRE_ATTR(name, 0200, NULL, name##_store)
787 #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
788 #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
790 ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr,
792 ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
793 const char *buf, size_t len);
795 extern const struct sysfs_ops lustre_sysfs_ops;
798 struct ptlrpc_request;
799 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
801 #ifdef HAVE_SERVER_SUPPORT
802 /* lprocfs_jobstats.c */
803 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
804 int event, long amount);
805 void lprocfs_job_stats_fini(struct obd_device *obd);
806 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
807 cntr_init_callback fn);
808 ssize_t job_cleanup_interval_show(struct kobject *kobj, struct attribute *attr,
810 ssize_t job_cleanup_interval_store(struct kobject *kobj,
811 struct attribute *attr,
812 const char *buffer, size_t count);
813 /* lproc_status_server.c */
814 ssize_t recovery_time_soft_show(struct kobject *kobj, struct attribute *attr,
816 ssize_t recovery_time_soft_store(struct kobject *kobj,
817 struct attribute *attr,
818 const char *buffer, size_t count);
819 ssize_t recovery_time_hard_show(struct kobject *kobj, struct attribute *attr,
821 ssize_t recovery_time_hard_store(struct kobject *kobj,
822 struct attribute *attr,
823 const char *buffer, size_t count);
824 ssize_t instance_show(struct kobject *kobj, struct attribute *attr,
828 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
829 ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
830 const char __user *buffer,
831 size_t count, loff_t *off);
832 int lprocfs_obd_short_io_bytes_seq_show(struct seq_file *m, void *data);
833 ssize_t lprocfs_obd_short_io_bytes_seq_write(struct file *file,
834 const char __user *buffer,
835 size_t count, loff_t *off);
836 ssize_t short_io_bytes_show(struct kobject *kobj, struct attribute *attr,
838 ssize_t short_io_bytes_store(struct kobject *kobj, struct attribute *attr,
839 const char *buffer, size_t count);
841 struct root_squash_info;
842 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
843 struct root_squash_info *squash, char *name);
844 int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
845 struct root_squash_info *squash, char *name);
847 #else /* !CONFIG_PROC_FS */
849 #define proc_lustre_root NULL
851 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
852 int index, long amount)
854 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
857 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
858 int index, long amount)
860 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
863 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
864 int index, unsigned conf,
865 const char *name, const char *units)
868 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
869 enum lprocfs_fields_flags field)
872 /* NB: we return !NULL to satisfy error checker */
873 static inline struct lprocfs_stats *
874 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
875 { return (struct lprocfs_stats *)1; }
876 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
878 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
880 static inline int lprocfs_register_stats(struct proc_dir_entry *root,
882 struct lprocfs_stats *stats)
884 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
886 static inline int lprocfs_alloc_obd_stats(struct obd_device *obd,
887 unsigned int num_stats)
889 static inline int lprocfs_alloc_md_stats(struct obd_device *obd,
890 unsigned int num_private_stats)
892 static inline void lprocfs_free_obd_stats(struct obd_device *obd)
894 static inline void lprocfs_free_md_stats(struct obd_device *obd)
898 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
900 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
902 #ifdef HAVE_SERVER_SUPPORT
904 ssize_t lprocfs_nid_stats_seq_write(struct file *file,
905 const char __user *buffer,
906 size_t count, loff_t *off)
909 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
911 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid)
914 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
916 static inline struct proc_dir_entry *
917 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
918 void *data, const struct file_operations *fops)
920 static inline struct proc_dir_entry *
921 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
922 const char *format, ...)
924 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
925 struct lprocfs_vars *var, void *data)
927 static inline struct proc_dir_entry *
928 lprocfs_register(const char *name, struct proc_dir_entry *parent,
929 struct lprocfs_vars *list, void *data)
931 static inline void lprocfs_remove(struct proc_dir_entry **root)
933 static inline void lprocfs_remove_proc_entry(const char *name,
934 struct proc_dir_entry *parent)
936 static inline int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only)
938 static inline int lprocfs_obd_cleanup(struct obd_device *obd)
940 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
942 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
944 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
946 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
948 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
950 #ifdef HAVE_SERVER_SUPPORT
951 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
954 struct adaptive_timeout;
955 static inline int lprocfs_at_hist_helper(struct seq_file *m,
956 struct adaptive_timeout *at)
958 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
960 static inline ssize_t
961 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
962 size_t count, loff_t *off)
964 #ifdef HAVE_SERVER_SUPPORT
965 static inline ssize_t
966 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
967 size_t count, loff_t *off)
970 static inline ssize_t
971 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
972 size_t count, loff_t *off)
974 static inline ssize_t
975 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
976 size_t count, loff_t *off)
979 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
981 static inline ssize_t
982 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
983 size_t count, loff_t *off)
988 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
991 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
994 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
997 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
1000 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
1003 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
1006 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1009 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1012 void lprocfs_oh_clear(struct obd_histogram *oh)
1015 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1018 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1019 struct lprocfs_counter *cnt)
1022 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1023 enum lprocfs_fields_flags field)
1024 { return (__u64)0; }
1026 #define LPROC_SEQ_FOPS_RO(name)
1027 #define LPROC_SEQ_FOPS(name)
1028 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
1029 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
1030 #define LPROC_SEQ_FOPS_WR_ONLY(name, type)
1032 /* lprocfs_jobstats.c */
1034 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1038 void lprocfs_job_stats_fini(struct obd_device *obd)
1041 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1042 cntr_init_callback fn)
1046 /* lproc_ptlrpc.c */
1047 #define target_print_req NULL
1049 #endif /* CONFIG_PROC_FS */
1051 #endif /* LPROCFS_STATUS_H */