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/
31 * lustre/include/lprocfs_status.h
33 * Top level header file for LProc
35 * Author: Hariharan Thantry thantry@users.sourceforge.net
37 #ifndef _LPROCFS_STATUS_H
38 #define _LPROCFS_STATUS_H
41 #include <linux/proc_fs.h>
42 #include <linux/debugfs.h>
43 #include <linux/rwsem.h>
44 #include <linux/spinlock.h>
45 #include <linux/string_helpers.h>
46 #include <linux/seq_file.h>
48 #include <libcfs/libcfs.h>
49 #include <uapi/linux/lustre/lustre_idl.h>
52 * Liuux 5.6 introduces proc_ops with v5.5-8862-gd56c0d45f0e2
53 * Now that proc and debugfs use separate operation vector types
54 * separate containers are also needed.
58 const struct file_operations *fops;
60 /** /proc file mode. */
64 /** Provide a debugfs container */
65 struct ldebugfs_vars {
67 const struct file_operations *fops;
69 /** debugfs file mode. */
73 static inline unsigned int pct(unsigned long a, unsigned long b)
75 return b ? a * 100 / b : 0;
78 #define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
79 #define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
82 * Append a space separated list of current set flags to str.
84 #define flag2str(port, flag) \
86 if ((port)->port##_##flag) { \
87 seq_printf(m, "%s" #flag, first ? "" : ", "); \
92 void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, __u64 flags2,
94 void obd_connect_data_seqprint(struct seq_file *m,
95 struct obd_connect_data *ocd);
97 /* if we find more consumers this could be generalized */
98 #define OBD_HIST_MAX 32
99 struct obd_histogram {
101 unsigned long oh_buckets[OBD_HIST_MAX];
113 BRW_R_DISCONT_BLOCKS,
114 BRW_W_DISCONT_BLOCKS,
123 struct obd_histogram hist[BRW_LAST];
127 RENAME_SAMEDIR_SIZE = 0,
128 RENAME_CROSSDIR_SRC_SIZE,
129 RENAME_CROSSDIR_TGT_SIZE,
133 struct rename_stats {
134 struct obd_histogram hist[RENAME_LAST];
137 /* An lprocfs counter can be configured using the enum bit masks below.
139 * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
140 * protects this counter from concurrent updates. If not specified,
141 * lprocfs an internal per-counter lock variable. External locks are
142 * not used to protect counter increments, but are used to protect
143 * counter readout and resets.
145 * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
146 * (i.e. counter can be incremented by more than "1"). When specified,
147 * the counter maintains min, max and sum in addition to a simple
148 * invocation count. This allows averages to be be computed.
149 * If not specified, the counter is an increment-by-1 counter.
150 * min, max, sum, etc. are not maintained.
152 * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
153 * squares (for multi-valued counter samples only). This allows
154 * external computation of standard deviation, but involves a 64-bit
155 * multiply per counter increment.
159 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
160 LPROCFS_CNTR_AVGMINMAX = 0x0002,
161 LPROCFS_CNTR_STDDEV = 0x0004,
163 /* counter data type */
164 LPROCFS_TYPE_REQS = 0x0100,
165 LPROCFS_TYPE_BYTES = 0x0200,
166 LPROCFS_TYPE_PAGES = 0x0400,
167 LPROCFS_TYPE_USEC = 0x0800,
169 LPROCFS_TYPE_LATENCY = LPROCFS_TYPE_USEC |
170 LPROCFS_CNTR_AVGMINMAX |
172 LPROCFS_TYPE_BYTES_FULL = LPROCFS_TYPE_BYTES |
173 LPROCFS_CNTR_AVGMINMAX |
176 #define LC_MIN_INIT ((~(__u64)0) >> 1)
178 struct lprocfs_counter_header {
179 unsigned int lc_config;
180 const char *lc_name; /* must be static */
181 const char *lc_units; /* must be static */
184 struct lprocfs_counter {
190 * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
191 * for irq context counter, i.e. stats with
192 * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
195 __s64 lc_array_sum[1];
197 #define lc_sum lc_array_sum[0]
198 #define lc_sum_irq lc_array_sum[1]
200 struct lprocfs_percpu {
201 struct lprocfs_counter lp_cntr[0];
204 enum lprocfs_stats_lock_ops {
205 LPROCFS_GET_NUM_CPU = 0x0001, /* number allocated per-CPU stats */
206 LPROCFS_GET_SMP_ID = 0x0002, /* current stat to be updated */
209 enum lprocfs_stats_flags {
210 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
211 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
212 * area and need locking */
213 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
216 enum lprocfs_fields_flags {
217 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
218 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
219 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
220 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
221 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
222 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
223 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
226 struct lprocfs_stats {
228 unsigned short ls_num;
229 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
230 unsigned short ls_biggest_alloc_num;
231 enum lprocfs_stats_flags ls_flags;
232 /* Lock used when there are no percpu stats areas; For percpu stats,
233 * it is used to protect ls_biggest_alloc_num change */
236 /* has ls_num of counter headers */
237 struct lprocfs_counter_header *ls_cnt_header;
238 struct lprocfs_percpu *ls_percpu[0];
241 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
243 /* Pack all opcodes down into a single monotonically increasing index */
244 static inline int opcode_offset(__u32 opc) {
245 if (opc < OST_LAST_OPC) {
247 return (opc - OST_FIRST_OPC);
248 } else if (opc < MDS_LAST_OPC) {
250 return (opc - MDS_FIRST_OPC +
252 } else if (opc < LDLM_LAST_OPC) {
254 return (opc - LDLM_FIRST_OPC +
257 } else if (opc < MGS_LAST_OPC) {
259 return (opc - MGS_FIRST_OPC +
263 } else if (opc < OBD_LAST_OPC) {
265 return (opc - OBD_FIRST_OPC +
270 } else if (opc < LLOG_LAST_OPC) {
272 return (opc - LLOG_FIRST_OPC +
278 } else if (opc < QUOTA_LAST_OPC) {
280 return (opc - QUOTA_FIRST_OPC +
287 } else if (opc < SEQ_LAST_OPC) {
289 return (opc - SEQ_FIRST_OPC +
297 } else if (opc < SEC_LAST_OPC) {
299 return (opc - SEC_FIRST_OPC +
308 } else if (opc < FLD_LAST_OPC) {
310 return (opc - FLD_FIRST_OPC +
320 } else if (opc < OUT_UPDATE_LAST_OPC) {
322 return (opc - OUT_UPDATE_FIRST_OPC +
333 } else if (opc < LFSCK_LAST_OPC) {
335 return (opc - LFSCK_FIRST_OPC +
336 OPC_RANGE(OUT_UPDATE) +
354 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
364 OPC_RANGE(OUT_UPDATE) + \
367 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
371 PTLRPC_REQWAIT_CNTR = 0,
372 PTLRPC_REQQDEPTH_CNTR,
373 PTLRPC_REQACTIVE_CNTR,
375 PTLRPC_REQBUF_AVAIL_CNTR,
379 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
381 enum lprocfs_extra_opc {
382 LDLM_GLIMPSE_ENQUEUE = 0,
400 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
402 extern struct proc_dir_entry *proc_lustre_root;
403 extern struct dentry *debugfs_lustre_root;
404 extern struct kset *lustre_kset;
407 struct obd_histogram;
409 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
410 #define JOBSTATS_DISABLE "disable"
411 #define JOBSTATS_PROCNAME_UID "procname_uid"
412 #define JOBSTATS_NODELOCAL "nodelocal"
413 #define JOBSTATS_SESSION "session"
415 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats,
416 unsigned int offset);
418 struct obd_job_stats {
419 struct cfs_hash *ojs_hash; /* hash of jobids */
420 struct list_head ojs_list; /* list of job_stat structs */
421 rwlock_t ojs_lock; /* protect ojs_list/js_list */
422 unsigned int ojs_cleanup_interval;/* seconds before expiry */
423 time64_t ojs_last_cleanup; /* previous cleanup time */
424 cntr_init_callback ojs_cntr_init_fn;/* lprocfs_stats initializer */
425 unsigned short ojs_cntr_num; /* number of stats in struct */
426 bool ojs_cleaning; /* currently expiring stats */
429 #ifdef CONFIG_PROC_FS
431 int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
433 int lprocfs_stats_lock(struct lprocfs_stats *stats,
434 enum lprocfs_stats_lock_ops opc,
435 unsigned long *flags);
436 void lprocfs_stats_unlock(struct lprocfs_stats *stats,
437 enum lprocfs_stats_lock_ops opc,
438 unsigned long *flags);
440 static inline unsigned int
441 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
443 unsigned int percpusize;
445 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
447 /* irq safe stats need lc_array_sum[1] */
448 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
449 percpusize += stats->ls_num * sizeof(__s64);
451 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
452 percpusize = L1_CACHE_ALIGN(percpusize);
457 static inline struct lprocfs_counter *
458 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
461 struct lprocfs_counter *cntr;
463 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
465 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
466 cntr = (void *)cntr + index * sizeof(__s64);
471 /* Two optimized LPROCFS counter increment functions are provided:
472 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
473 * lprocfs_counter_add(cntr) - use for multi-valued counters
474 * Counter data layout allows config flag, counter lock and the
475 * count itself to reside within a single cache line.
478 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
480 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
483 #define lprocfs_counter_incr(stats, idx) \
484 lprocfs_counter_add(stats, idx, 1)
485 #define lprocfs_counter_decr(stats, idx) \
486 lprocfs_counter_sub(stats, idx, 1)
488 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
489 struct lprocfs_counter_header *header,
490 enum lprocfs_stats_flags flags,
491 enum lprocfs_fields_flags field);
492 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
493 enum lprocfs_fields_flags field);
495 extern struct lprocfs_stats *
496 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
497 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
498 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
499 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
500 extern int lprocfs_alloc_obd_stats(struct obd_device *obd,
501 unsigned int num_stats);
502 extern int lprocfs_alloc_md_stats(struct obd_device *obd,
503 unsigned int num_private_stats);
504 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
505 unsigned conf, const char *name,
507 extern void lprocfs_free_obd_stats(struct obd_device *obd);
508 extern void lprocfs_free_md_stats(struct obd_device *obd);
511 extern int lprocfs_add_clear_entry(struct obd_device *obd,
512 struct proc_dir_entry *entry);
513 #ifdef HAVE_SERVER_SUPPORT
514 extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid);
515 extern int lprocfs_exp_cleanup(struct obd_export *exp);
516 struct dentry *ldebugfs_add_symlink(const char *name, const char *target,
517 const char *format, ...);
519 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
522 extern struct proc_dir_entry *
523 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
524 void *data, const struct file_operations *fops);
525 extern struct proc_dir_entry *
526 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
527 const char *format, ...);
528 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
529 #ifdef HAVE_SERVER_SUPPORT
531 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
532 size_t count, loff_t *off);
533 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
535 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
536 struct lprocfs_stats *stats);
537 extern const struct file_operations ldebugfs_stats_seq_fops;
539 /* lprocfs_status.c */
540 extern void ldebugfs_add_vars(struct dentry *parent, struct ldebugfs_vars *var,
542 extern struct dentry *ldebugfs_register(const char *name,
543 struct dentry *parent,
544 struct ldebugfs_vars *list,
546 extern int lprocfs_add_vars(struct proc_dir_entry *root,
547 struct lprocfs_vars *var, void *data);
549 extern struct proc_dir_entry *
550 lprocfs_register(const char *name, struct proc_dir_entry *parent,
551 struct lprocfs_vars *list, void *data);
553 extern void lprocfs_remove(struct proc_dir_entry **root);
554 extern void lprocfs_remove_proc_entry(const char *name,
555 struct proc_dir_entry *parent);
556 extern int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only);
557 extern int lprocfs_obd_cleanup(struct obd_device *obd);
559 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
561 const struct file_operations *seq_fops,
563 extern int lprocfs_obd_seq_create(struct obd_device *obd, const char *name,
565 const struct file_operations *seq_fops,
568 /* Generic callbacks */
569 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
570 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
571 ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf);
572 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
573 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
574 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
575 #ifdef HAVE_SERVER_SUPPORT
576 ssize_t num_exports_show(struct kobject *kobj, struct attribute *attr,
579 struct adaptive_timeout;
580 extern int lprocfs_at_hist_helper(struct seq_file *m,
581 struct adaptive_timeout *at);
582 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
584 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
585 size_t count, loff_t *off);
586 #ifdef HAVE_SERVER_SUPPORT
588 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
589 size_t count, loff_t *off);
591 ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
592 const char *buffer, size_t count);
593 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
597 ldebugfs_import_seq_write(struct file *file, const char __user *buffer,
598 size_t count, loff_t *off);
599 static inline ssize_t
600 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
601 size_t count, loff_t *off)
603 return ldebugfs_import_seq_write(file, buffer, count, off);
606 extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data);
608 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
609 size_t count, loff_t *off);
611 int string_to_size(u64 *size, const char *buffer, size_t count);
612 int sysfs_memparse(const char *buffer, size_t count, u64 *val,
613 const char *defunit);
614 char *lprocfs_strnstr(const char *s1, const char *s2, size_t len);
615 char *lprocfs_find_named_value(const char *buffer, const char *name,
617 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
618 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
619 void lprocfs_oh_clear(struct obd_histogram *oh);
620 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
622 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
623 struct lprocfs_counter *cnt);
625 #ifdef HAVE_SERVER_SUPPORT
626 /* lprocfs_status.c: recovery status */
627 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
629 /* lprocfs_status.c: hash statistics */
630 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
632 /* lprocfs_status.c: IR factor */
633 ssize_t ir_factor_show(struct kobject *kobj, struct attribute *attr,
635 ssize_t ir_factor_store(struct kobject *kobj, struct attribute *attr,
636 const char *buffer, size_t count);
639 /* lprocfs_status.c: dump pages on cksum error */
640 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data);
642 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
643 size_t count, loff_t *off);
645 extern int lprocfs_single_release(struct inode *, struct file *);
646 extern int lprocfs_seq_release(struct inode *, struct file *);
648 /* You must use these macros when you want to refer to
649 * the import in a client obd_device for a lprocfs entry
650 * Note that it is not safe to 'goto', 'return' or 'break'
651 * out of the body of this statement. It *IS* safe to
652 * 'goto' the a label inside the statement, or to 'continue'
653 * to get out of the statement.
656 #define with_imp_locked_nested(__obd, __imp, __rc, __nest) \
657 for (down_read_nested(&(__obd)->u.cli.cl_sem, __nest), \
658 __imp = (__obd)->u.cli.cl_import, \
659 __rc = __imp ? 0 : -ENODEV; \
660 __imp ? 1 : (up_read(&(__obd)->u.cli.cl_sem), 0); \
663 #define with_imp_locked(__obd, __imp, __rc) \
664 with_imp_locked_nested(__obd, __imp, __rc, 0)
666 /* write the name##_seq_show function, call LDEBUGFS_SEQ_FOPS_RO for read-only
667 * debugfs entries; otherwise, you will define name##_seq_write function also
668 * for a read-write debugfs entry, and then call LDEBUGFS_SEQ_FOPS instead.
669 * Finally, call debugfs_create_file(filename, 0444, obd, data, &name#_fops);
671 #define __LDEBUGFS_SEQ_FOPS(name, custom_seq_write) \
672 static int name##_single_open(struct inode *inode, struct file *file) \
674 return single_open(file, name##_seq_show, inode->i_private); \
676 static const struct file_operations name##_fops = { \
677 .owner = THIS_MODULE, \
678 .open = name##_single_open, \
680 .write = custom_seq_write, \
681 .llseek = seq_lseek, \
682 .release = single_release, \
685 #define LDEBUGFS_SEQ_FOPS_RO(name) __LDEBUGFS_SEQ_FOPS(name, NULL)
686 #define LDEBUGFS_SEQ_FOPS(name) __LDEBUGFS_SEQ_FOPS(name, \
689 #define LDEBUGFS_SEQ_FOPS_RO_TYPE(name, type) \
690 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
694 return lprocfs_##type##_seq_show(m, m->private); \
696 LDEBUGFS_SEQ_FOPS_RO(name##_##type)
698 #define LDEBUGFS_SEQ_FOPS_RW_TYPE(name, type) \
699 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
703 return lprocfs_##type##_seq_show(m, m->private); \
705 static ssize_t name##_##type##_seq_write(struct file *file, \
706 const char __user *buffer, size_t count, \
709 struct seq_file *seq = file->private_data; \
713 return ldebugfs_##type##_seq_write(file, buffer, count, \
716 LDEBUGFS_SEQ_FOPS(name##_##type);
718 #define LDEBUGFS_FOPS_WR_ONLY(name, type) \
719 static ssize_t name##_##type##_write(struct file *file, \
720 const char __user *buffer, size_t count, \
723 return ldebugfs_##type##_seq_write(file, buffer, count, \
726 static int name##_##type##_open(struct inode *inode, \
729 return single_open(file, NULL, inode->i_private); \
731 static const struct file_operations name##_##type##_fops = { \
732 .open = name##_##type##_open, \
733 .write = name##_##type##_write, \
734 .release = single_release, \
737 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
738 * proc entries; otherwise, you will define name##_seq_write function also for
739 * a read-write proc entry, and then call LPROC_SEQ_FOPS instead. Finally,
740 * call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data);
742 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
743 static int name##_single_open(struct inode *inode, struct file *file) \
745 return single_open(file, name##_seq_show, \
746 inode->i_private ? inode->i_private : \
749 static const struct file_operations name##_fops = { \
750 .owner = THIS_MODULE, \
751 .open = name##_single_open, \
753 .write = custom_seq_write, \
754 .llseek = seq_lseek, \
755 .release = lprocfs_single_release, \
758 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
759 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
761 #define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
762 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
764 return lprocfs_##type##_seq_show(m, m->private); \
766 LPROC_SEQ_FOPS_RO(name##_##type)
768 #define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
769 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
771 return lprocfs_##type##_seq_show(m, m->private); \
773 static ssize_t name##_##type##_seq_write(struct file *file, \
774 const char __user *buffer, size_t count, \
777 struct seq_file *seq = file->private_data; \
778 return lprocfs_##type##_seq_write(file, buffer, \
779 count, seq->private); \
781 LPROC_SEQ_FOPS(name##_##type);
783 #define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
784 static ssize_t name##_##type##_write(struct file *file, \
785 const char __user *buffer, size_t count, \
788 return lprocfs_##type##_seq_write(file, buffer, count, off);\
790 static int name##_##type##_open(struct inode *inode, struct file *file)\
792 return single_open(file, NULL, \
793 inode->i_private ? inode->i_private : \
796 static const struct file_operations name##_##type##_fops = { \
797 .open = name##_##type##_open, \
798 .write = name##_##type##_write, \
799 .release = lprocfs_single_release, \
803 struct attribute attr;
804 ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
806 ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
807 const char *buf, size_t len);
810 #define LUSTRE_ATTR(name, mode, show, store) \
811 static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
813 #define LUSTRE_WO_ATTR(name) LUSTRE_ATTR(name, 0200, NULL, name##_store)
814 #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
815 #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
817 ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr,
819 ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
820 const char *buf, size_t len);
822 extern const struct sysfs_ops lustre_sysfs_ops;
825 struct ptlrpc_request;
826 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
828 #ifdef HAVE_SERVER_SUPPORT
829 /* lprocfs_jobstats.c */
830 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
831 int event, long amount);
832 void lprocfs_job_stats_fini(struct obd_device *obd);
833 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
834 cntr_init_callback fn);
835 ssize_t job_cleanup_interval_show(struct kobject *kobj, struct attribute *attr,
837 ssize_t job_cleanup_interval_store(struct kobject *kobj,
838 struct attribute *attr,
839 const char *buffer, size_t count);
840 /* lproc_status_server.c */
841 ssize_t recovery_time_soft_show(struct kobject *kobj, struct attribute *attr,
843 ssize_t recovery_time_soft_store(struct kobject *kobj,
844 struct attribute *attr,
845 const char *buffer, size_t count);
846 ssize_t recovery_time_hard_show(struct kobject *kobj, struct attribute *attr,
848 ssize_t recovery_time_hard_store(struct kobject *kobj,
849 struct attribute *attr,
850 const char *buffer, size_t count);
851 ssize_t instance_show(struct kobject *kobj, struct attribute *attr,
855 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
856 ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
857 const char __user *buffer,
858 size_t count, loff_t *off);
859 int lprocfs_obd_short_io_bytes_seq_show(struct seq_file *m, void *data);
860 ssize_t lprocfs_obd_short_io_bytes_seq_write(struct file *file,
861 const char __user *buffer,
862 size_t count, loff_t *off);
863 ssize_t short_io_bytes_show(struct kobject *kobj, struct attribute *attr,
865 ssize_t short_io_bytes_store(struct kobject *kobj, struct attribute *attr,
866 const char *buffer, size_t count);
868 struct root_squash_info;
869 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
870 struct root_squash_info *squash, char *name);
871 int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
872 struct root_squash_info *squash, char *name);
874 #else /* !CONFIG_PROC_FS */
876 #define proc_lustre_root NULL
878 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
879 int index, long amount)
881 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
884 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
885 int index, long amount)
887 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
890 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
891 int index, unsigned conf,
892 const char *name, const char *units)
895 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
896 enum lprocfs_fields_flags field)
899 /* NB: we return !NULL to satisfy error checker */
900 static inline struct lprocfs_stats *
901 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
902 { return (struct lprocfs_stats *)1; }
903 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
905 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
907 static inline int lprocfs_register_stats(struct proc_dir_entry *root,
909 struct lprocfs_stats *stats)
911 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
913 static inline int lprocfs_alloc_obd_stats(struct obd_device *obd,
914 unsigned int num_stats)
916 static inline int lprocfs_alloc_md_stats(struct obd_device *obd,
917 unsigned int num_private_stats)
919 static inline void lprocfs_free_obd_stats(struct obd_device *obd)
921 static inline void lprocfs_free_md_stats(struct obd_device *obd)
925 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
927 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
929 #ifdef HAVE_SERVER_SUPPORT
931 ssize_t lprocfs_nid_stats_seq_write(struct file *file,
932 const char __user *buffer,
933 size_t count, loff_t *off)
936 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
938 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid)
941 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
943 static inline struct proc_dir_entry *
944 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
945 void *data, const struct file_operations *fops)
947 static inline struct proc_dir_entry *
948 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
949 const char *format, ...)
951 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
952 struct lprocfs_vars *var, void *data)
954 static inline struct proc_dir_entry *
955 lprocfs_register(const char *name, struct proc_dir_entry *parent,
956 struct lprocfs_vars *list, void *data)
958 static inline void lprocfs_remove(struct proc_dir_entry **root)
960 static inline void lprocfs_remove_proc_entry(const char *name,
961 struct proc_dir_entry *parent)
963 static inline int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only)
965 static inline int lprocfs_obd_cleanup(struct obd_device *obd)
967 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
969 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
971 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
973 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
975 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
977 #ifdef HAVE_SERVER_SUPPORT
978 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
981 struct adaptive_timeout;
982 static inline int lprocfs_at_hist_helper(struct seq_file *m,
983 struct adaptive_timeout *at)
985 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
987 static inline ssize_t
988 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
989 size_t count, loff_t *off)
991 #ifdef HAVE_SERVER_SUPPORT
992 static inline ssize_t
993 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
994 size_t count, loff_t *off)
997 static inline ssize_t
998 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
999 size_t count, loff_t *off)
1001 static inline ssize_t
1002 ldebugfs_import_seq_write(struct file *file, const char __user *buffer,
1003 size_t count, loff_t *off)
1005 static inline ssize_t
1006 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
1007 size_t count, loff_t *off)
1010 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
1012 static inline ssize_t
1013 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
1014 size_t count, loff_t *off)
1017 /* Statfs helpers */
1019 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
1022 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
1025 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
1028 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
1031 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
1034 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
1037 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1040 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1043 void lprocfs_oh_clear(struct obd_histogram *oh)
1046 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1049 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1050 struct lprocfs_counter *cnt)
1053 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1054 enum lprocfs_fields_flags field)
1055 { return (__u64)0; }
1057 #define LPROC_SEQ_FOPS_RO(name)
1058 #define LPROC_SEQ_FOPS(name)
1059 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
1060 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
1061 #define LPROC_SEQ_FOPS_WR_ONLY(name, type)
1063 /* lprocfs_jobstats.c */
1065 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1069 void lprocfs_job_stats_fini(struct obd_device *obd)
1072 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1073 cntr_init_callback fn)
1077 /* lproc_ptlrpc.c */
1078 #define target_print_req NULL
1080 #endif /* CONFIG_PROC_FS */
1082 #endif /* LPROCFS_STATUS_H */