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/seq_file.h>
48 #include <libcfs/libcfs.h>
49 #include <uapi/linux/lustre/lustre_idl.h>
53 const struct file_operations *fops;
61 static inline unsigned int pct(unsigned long a, unsigned long b)
63 return b ? a * 100 / b : 0;
66 #define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
67 #define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
70 * Append a space separated list of current set flags to str.
72 #define flag2str(port, flag) \
74 if ((port)->port##_##flag) { \
75 seq_printf(m, "%s" #flag, first ? "" : ", "); \
80 void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, __u64 flags2,
82 void obd_connect_data_seqprint(struct seq_file *m,
83 struct obd_connect_data *ocd);
85 /* if we find more consumers this could be generalized */
86 #define OBD_HIST_MAX 32
87 struct obd_histogram {
89 unsigned long oh_buckets[OBD_HIST_MAX];
101 BRW_R_DISCONT_BLOCKS,
102 BRW_W_DISCONT_BLOCKS,
111 struct obd_histogram hist[BRW_LAST];
115 RENAME_SAMEDIR_SIZE = 0,
116 RENAME_CROSSDIR_SRC_SIZE,
117 RENAME_CROSSDIR_TGT_SIZE,
121 struct rename_stats {
122 struct obd_histogram hist[RENAME_LAST];
125 /* An lprocfs counter can be configured using the enum bit masks below.
127 * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
128 * protects this counter from concurrent updates. If not specified,
129 * lprocfs an internal per-counter lock variable. External locks are
130 * not used to protect counter increments, but are used to protect
131 * counter readout and resets.
133 * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
134 * (i.e. counter can be incremented by more than "1"). When specified,
135 * the counter maintains min, max and sum in addition to a simple
136 * invocation count. This allows averages to be be computed.
137 * If not specified, the counter is an increment-by-1 counter.
138 * min, max, sum, etc. are not maintained.
140 * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
141 * squares (for multi-valued counter samples only). This allows
142 * external computation of standard deviation, but involves a 64-bit
143 * multiply per counter increment.
147 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
148 LPROCFS_CNTR_AVGMINMAX = 0x0002,
149 LPROCFS_CNTR_STDDEV = 0x0004,
151 /* counter data type */
152 LPROCFS_TYPE_REQS = 0x0100,
153 LPROCFS_TYPE_BYTES = 0x0200,
154 LPROCFS_TYPE_PAGES = 0x0400,
155 LPROCFS_TYPE_USEC = 0x0800,
158 #define LC_MIN_INIT ((~(__u64)0) >> 1)
160 struct lprocfs_counter_header {
161 unsigned int lc_config;
162 const char *lc_name; /* must be static */
163 const char *lc_units; /* must be static */
166 struct lprocfs_counter {
172 * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
173 * for irq context counter, i.e. stats with
174 * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
177 __s64 lc_array_sum[1];
179 #define lc_sum lc_array_sum[0]
180 #define lc_sum_irq lc_array_sum[1]
182 struct lprocfs_percpu {
183 struct lprocfs_counter lp_cntr[0];
186 enum lprocfs_stats_lock_ops {
187 LPROCFS_GET_NUM_CPU = 0x0001, /* number allocated per-CPU stats */
188 LPROCFS_GET_SMP_ID = 0x0002, /* current stat to be updated */
191 enum lprocfs_stats_flags {
192 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
193 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
194 * area and need locking */
195 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
198 enum lprocfs_fields_flags {
199 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
200 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
201 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
202 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
203 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
204 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
205 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
208 struct lprocfs_stats {
210 unsigned short ls_num;
211 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
212 unsigned short ls_biggest_alloc_num;
213 enum lprocfs_stats_flags ls_flags;
214 /* Lock used when there are no percpu stats areas; For percpu stats,
215 * it is used to protect ls_biggest_alloc_num change */
218 /* has ls_num of counter headers */
219 struct lprocfs_counter_header *ls_cnt_header;
220 struct lprocfs_percpu *ls_percpu[0];
223 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
225 /* Pack all opcodes down into a single monotonically increasing index */
226 static inline int opcode_offset(__u32 opc) {
227 if (opc < OST_LAST_OPC) {
229 return (opc - OST_FIRST_OPC);
230 } else if (opc < MDS_LAST_OPC) {
232 return (opc - MDS_FIRST_OPC +
234 } else if (opc < LDLM_LAST_OPC) {
236 return (opc - LDLM_FIRST_OPC +
239 } else if (opc < MGS_LAST_OPC) {
241 return (opc - MGS_FIRST_OPC +
245 } else if (opc < OBD_LAST_OPC) {
247 return (opc - OBD_FIRST_OPC +
252 } else if (opc < LLOG_LAST_OPC) {
254 return (opc - LLOG_FIRST_OPC +
260 } else if (opc < QUOTA_LAST_OPC) {
262 return (opc - QUOTA_FIRST_OPC +
269 } else if (opc < SEQ_LAST_OPC) {
271 return (opc - SEQ_FIRST_OPC +
279 } else if (opc < SEC_LAST_OPC) {
281 return (opc - SEC_FIRST_OPC +
290 } else if (opc < FLD_LAST_OPC) {
292 return (opc - FLD_FIRST_OPC +
302 } else if (opc < OUT_UPDATE_LAST_OPC) {
304 return (opc - OUT_UPDATE_FIRST_OPC +
315 } else if (opc < LFSCK_LAST_OPC) {
317 return (opc - LFSCK_FIRST_OPC +
318 OPC_RANGE(OUT_UPDATE) +
336 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
346 OPC_RANGE(OUT_UPDATE) + \
349 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
353 PTLRPC_REQWAIT_CNTR = 0,
354 PTLRPC_REQQDEPTH_CNTR,
355 PTLRPC_REQACTIVE_CNTR,
357 PTLRPC_REQBUF_AVAIL_CNTR,
361 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
363 enum lprocfs_extra_opc {
364 LDLM_GLIMPSE_ENQUEUE = 0,
382 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
384 extern struct proc_dir_entry *proc_lustre_root;
385 extern struct dentry *debugfs_lustre_root;
386 extern struct kset *lustre_kset;
389 struct obd_histogram;
391 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
392 #define JOBSTATS_DISABLE "disable"
393 #define JOBSTATS_PROCNAME_UID "procname_uid"
394 #define JOBSTATS_NODELOCAL "nodelocal"
395 #define JOBSTATS_SESSION "session"
397 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
399 struct obd_job_stats {
400 struct cfs_hash *ojs_hash; /* hash of jobids */
401 struct list_head ojs_list; /* list of job_stat structs */
402 rwlock_t ojs_lock; /* protect ojs_list/js_list */
403 unsigned int ojs_cleanup_interval;/* seconds before expiry */
404 time64_t ojs_last_cleanup; /* previous cleanup time */
405 cntr_init_callback ojs_cntr_init_fn;/* lprocfs_stats initializer */
406 unsigned short ojs_cntr_num; /* number of stats in struct */
407 bool ojs_cleaning; /* currently expiring stats */
410 #ifdef CONFIG_PROC_FS
412 int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
414 int lprocfs_stats_lock(struct lprocfs_stats *stats,
415 enum lprocfs_stats_lock_ops opc,
416 unsigned long *flags);
417 void lprocfs_stats_unlock(struct lprocfs_stats *stats,
418 enum lprocfs_stats_lock_ops opc,
419 unsigned long *flags);
421 static inline unsigned int
422 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
424 unsigned int percpusize;
426 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
428 /* irq safe stats need lc_array_sum[1] */
429 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
430 percpusize += stats->ls_num * sizeof(__s64);
432 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
433 percpusize = L1_CACHE_ALIGN(percpusize);
438 static inline struct lprocfs_counter *
439 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
442 struct lprocfs_counter *cntr;
444 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
446 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
447 cntr = (void *)cntr + index * sizeof(__s64);
452 /* Two optimized LPROCFS counter increment functions are provided:
453 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
454 * lprocfs_counter_add(cntr) - use for multi-valued counters
455 * Counter data layout allows config flag, counter lock and the
456 * count itself to reside within a single cache line.
459 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
461 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
464 #define lprocfs_counter_incr(stats, idx) \
465 lprocfs_counter_add(stats, idx, 1)
466 #define lprocfs_counter_decr(stats, idx) \
467 lprocfs_counter_sub(stats, idx, 1)
469 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
470 struct lprocfs_counter_header *header,
471 enum lprocfs_stats_flags flags,
472 enum lprocfs_fields_flags field);
473 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
474 enum lprocfs_fields_flags field);
476 extern struct lprocfs_stats *
477 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
478 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
479 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
480 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
481 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
482 unsigned int num_stats);
483 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
484 unsigned int num_private_stats);
485 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
486 unsigned conf, const char *name,
488 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
489 extern void lprocfs_free_md_stats(struct obd_device *obddev);
492 extern int lprocfs_add_clear_entry(struct obd_device * obd,
493 struct proc_dir_entry *entry);
494 #ifdef HAVE_SERVER_SUPPORT
495 extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid);
496 extern int lprocfs_exp_cleanup(struct obd_export *exp);
497 struct dentry *ldebugfs_add_symlink(const char *name, const char *target,
498 const char *format, ...);
500 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
503 struct dentry *ldebugfs_add_simple(struct dentry *root, char *name, void *data,
504 const struct file_operations *fops);
505 extern struct proc_dir_entry *
506 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
507 void *data, const struct file_operations *fops);
508 extern struct proc_dir_entry *
509 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
510 const char *format, ...);
511 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
512 #ifdef HAVE_SERVER_SUPPORT
514 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
515 size_t count, loff_t *off);
516 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
518 extern int ldebugfs_register_stats(struct dentry *parent, const char *name,
519 struct lprocfs_stats *stats);
520 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
521 struct lprocfs_stats *stats);
523 /* lprocfs_status.c */
524 extern int ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var,
526 extern int lprocfs_add_vars(struct proc_dir_entry *root,
527 struct lprocfs_vars *var, void *data);
529 extern struct dentry *ldebugfs_register(const char *name,
530 struct dentry *parent,
531 struct lprocfs_vars *list,
533 extern struct proc_dir_entry *
534 lprocfs_register(const char *name, struct proc_dir_entry *parent,
535 struct lprocfs_vars *list, void *data);
537 extern void lprocfs_remove(struct proc_dir_entry **root);
538 extern void lprocfs_remove_proc_entry(const char *name,
539 struct proc_dir_entry *parent);
540 #ifndef HAVE_REMOVE_PROC_SUBTREE
541 extern int remove_proc_subtree(const char *name,
542 struct proc_dir_entry *parent);
543 #define PDE_DATA(inode) (PDE(inode)->data)
545 static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
547 struct proc_dir_entry *dp = PDE(inode);
550 spin_lock(&(dp)->pde_unload_lock);
551 if (dp->proc_fops == NULL)
553 spin_unlock(&(dp)->pde_unload_lock);
559 static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
563 extern int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only);
564 extern int lprocfs_obd_cleanup(struct obd_device *obd);
565 #ifdef HAVE_SERVER_SUPPORT
566 extern const struct file_operations lprocfs_evict_client_fops;
569 int ldebugfs_seq_create(struct dentry *parent, const char *name, umode_t mode,
570 const struct file_operations *seq_fops, void *data);
571 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
573 const struct file_operations *seq_fops,
575 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
577 const struct file_operations *seq_fops,
580 /* Generic callbacks */
581 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
582 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
583 ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf);
584 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
585 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
586 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
587 #ifdef HAVE_SERVER_SUPPORT
588 ssize_t num_exports_show(struct kobject *kobj, struct attribute *attr,
591 struct adaptive_timeout;
592 extern int lprocfs_at_hist_helper(struct seq_file *m,
593 struct adaptive_timeout *at);
594 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
596 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
597 size_t count, loff_t *off);
598 #ifdef HAVE_SERVER_SUPPORT
600 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
601 size_t count, loff_t *off);
603 ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
604 const char *buffer, size_t count);
605 ssize_t ping_show(struct kobject *kobj, struct attribute *attr,
609 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
610 size_t count, loff_t *off);
611 extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data);
613 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
614 size_t count, loff_t *off);
616 int lu_str_to_s64(char *buffer, unsigned long count, __s64 *val, char defunit);
617 extern int lprocfs_str_with_units_to_s64(const char __user *buffer,
618 unsigned long count, __s64 *val,
621 extern int lprocfs_str_with_units_to_u64(const char __user *buffer,
622 unsigned long count, __u64 *val,
625 char *lprocfs_strnstr(const char *s1, const char *s2, size_t len);
626 char *lprocfs_find_named_value(const char *buffer, const char *name,
628 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
629 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
630 void lprocfs_oh_clear(struct obd_histogram *oh);
631 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
633 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
634 struct lprocfs_counter *cnt);
636 #ifdef HAVE_SERVER_SUPPORT
637 /* lprocfs_status.c: recovery status */
638 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
640 /* lprocfs_status.c: hash statistics */
641 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
643 /* lprocfs_status.c: IR factor */
644 ssize_t ir_factor_show(struct kobject *kobj, struct attribute *attr,
646 ssize_t ir_factor_store(struct kobject *kobj, struct attribute *attr,
647 const char *buffer, size_t count);
650 /* lprocfs_status.c: dump pages on cksum error */
651 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data);
653 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
654 size_t count, loff_t *off);
656 extern int lprocfs_single_release(struct inode *, struct file *);
657 extern int lprocfs_seq_release(struct inode *, struct file *);
659 /* You must use these macros when you want to refer to
660 * the import in a client obd_device for a lprocfs entry */
661 #define LPROCFS_CLIMP_CHECK(obd) do { \
662 typecheck(struct obd_device *, obd); \
663 down_read(&(obd)->u.cli.cl_sem); \
664 if ((obd)->u.cli.cl_import == NULL) { \
665 up_read(&(obd)->u.cli.cl_sem); \
669 #define LPROCFS_CLIMP_EXIT(obd) \
670 up_read(&(obd)->u.cli.cl_sem);
672 /* write the name##_seq_show function, call LDEBUGFS_SEQ_FOPS_RO for read-only
673 * debugfs entries; otherwise, you will define name##_seq_write function also
674 * for a read-write debugfs entry, and then call LDEBUGFS_SEQ_FOPS instead.
675 * Finally, call ldebugfs_seq_create(obd, filename, 0444, &name#_fops, data);
677 #define __LDEBUGFS_SEQ_FOPS(name, custom_seq_write) \
678 static int name##_single_open(struct inode *inode, struct file *file) \
680 return single_open(file, name##_seq_show, inode->i_private); \
682 static const struct file_operations name##_fops = { \
683 .owner = THIS_MODULE, \
684 .open = name##_single_open, \
686 .write = custom_seq_write, \
687 .llseek = seq_lseek, \
688 .release = single_release, \
691 #define LDEBUGFS_SEQ_FOPS_RO(name) __LDEBUGFS_SEQ_FOPS(name, NULL)
692 #define LDEBUGFS_SEQ_FOPS(name) __LDEBUGFS_SEQ_FOPS(name, \
695 #define LDEBUGFS_SEQ_FOPS_RO_TYPE(name, type) \
696 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
700 return lprocfs_##type##_seq_show(m, m->private); \
702 LDEBUGFS_SEQ_FOPS_RO(name##_##type)
704 #define LDEBUGFS_SEQ_FOPS_RW_TYPE(name, type) \
705 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
709 return lprocfs_##type##_seq_show(m, m->private); \
711 static ssize_t name##_##type##_seq_write(struct file *file, \
712 const char __user *buffer, size_t count, \
715 struct seq_file *seq = file->private_data; \
719 return ldebugfs_##type##_seq_write(file, buffer, count, \
722 LDEBUGFS_SEQ_FOPS(name##_##type);
724 #define LDEBUGFS_FOPS_WR_ONLY(name, type) \
725 static ssize_t name##_##type##_write(struct file *file, \
726 const char __user *buffer, size_t count, \
729 return ldebugfs_##type##_seq_write(file, buffer, count, \
732 static int name##_##type##_open(struct inode *inode, \
735 return single_open(file, NULL, inode->i_private); \
737 static const struct file_operations name##_##type##_fops = { \
738 .open = name##_##type##_open, \
739 .write = name##_##type##_write, \
740 .release = single_release, \
743 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
744 * proc entries; otherwise, you will define name##_seq_write function also for
745 * a read-write proc entry, and then call LPROC_SEQ_FOPS instead. Finally,
746 * call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data);
748 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
749 static int name##_single_open(struct inode *inode, struct file *file) \
753 rc = LPROCFS_ENTRY_CHECK(inode); \
757 return single_open(file, name##_seq_show, \
758 inode->i_private ? inode->i_private : \
761 static const struct file_operations name##_fops = { \
762 .owner = THIS_MODULE, \
763 .open = name##_single_open, \
765 .write = custom_seq_write, \
766 .llseek = seq_lseek, \
767 .release = lprocfs_single_release, \
770 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
771 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
773 #define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
774 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
776 return lprocfs_##type##_seq_show(m, m->private); \
778 LPROC_SEQ_FOPS_RO(name##_##type)
780 #define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
781 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
783 return lprocfs_##type##_seq_show(m, m->private); \
785 static ssize_t name##_##type##_seq_write(struct file *file, \
786 const char __user *buffer, size_t count, \
789 struct seq_file *seq = file->private_data; \
790 return lprocfs_##type##_seq_write(file, buffer, \
791 count, seq->private); \
793 LPROC_SEQ_FOPS(name##_##type);
795 #define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
796 static ssize_t name##_##type##_write(struct file *file, \
797 const char __user *buffer, size_t count, \
800 return lprocfs_##type##_seq_write(file, buffer, count, off);\
802 static int name##_##type##_open(struct inode *inode, struct file *file)\
804 return single_open(file, NULL, \
805 inode->i_private ? inode->i_private : \
808 static const struct file_operations name##_##type##_fops = { \
809 .open = name##_##type##_open, \
810 .write = name##_##type##_write, \
811 .release = lprocfs_single_release, \
815 struct attribute attr;
816 ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
818 ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
819 const char *buf, size_t len);
822 #define LUSTRE_ATTR(name, mode, show, store) \
823 static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
825 #define LUSTRE_WO_ATTR(name) LUSTRE_ATTR(name, 0200, NULL, name##_store)
826 #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
827 #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
829 ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr,
831 ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
832 const char *buf, size_t len);
834 extern const struct sysfs_ops lustre_sysfs_ops;
837 struct ptlrpc_request;
838 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
840 #ifdef HAVE_SERVER_SUPPORT
841 /* lprocfs_jobstats.c */
842 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
843 int event, long amount);
844 void lprocfs_job_stats_fini(struct obd_device *obd);
845 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
846 cntr_init_callback fn);
847 ssize_t job_cleanup_interval_show(struct kobject *kobj, struct attribute *attr,
849 ssize_t job_cleanup_interval_store(struct kobject *kobj,
850 struct attribute *attr,
851 const char *buffer, size_t count);
852 /* lproc_status_server.c */
853 ssize_t recovery_time_soft_show(struct kobject *kobj, struct attribute *attr,
855 ssize_t recovery_time_soft_store(struct kobject *kobj,
856 struct attribute *attr,
857 const char *buffer, size_t count);
858 ssize_t recovery_time_hard_show(struct kobject *kobj, struct attribute *attr,
860 ssize_t recovery_time_hard_store(struct kobject *kobj,
861 struct attribute *attr,
862 const char *buffer, size_t count);
863 ssize_t instance_show(struct kobject *kobj, struct attribute *attr,
867 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
868 ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
869 const char __user *buffer,
870 size_t count, loff_t *off);
871 int lprocfs_obd_short_io_bytes_seq_show(struct seq_file *m, void *data);
872 ssize_t lprocfs_obd_short_io_bytes_seq_write(struct file *file,
873 const char __user *buffer,
874 size_t count, loff_t *off);
875 ssize_t short_io_bytes_show(struct kobject *kobj, struct attribute *attr,
877 ssize_t short_io_bytes_store(struct kobject *kobj, struct attribute *attr,
878 const char *buffer, size_t count);
880 struct root_squash_info;
881 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
882 struct root_squash_info *squash, char *name);
883 int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
884 struct root_squash_info *squash, char *name);
886 #else /* !CONFIG_PROC_FS */
888 #define proc_lustre_root NULL
890 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
891 int index, long amount)
893 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
896 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
897 int index, long amount)
899 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
902 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
903 int index, unsigned conf,
904 const char *name, const char *units)
907 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
908 enum lprocfs_fields_flags field)
911 /* NB: we return !NULL to satisfy error checker */
912 static inline struct lprocfs_stats *
913 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
914 { return (struct lprocfs_stats *)1; }
915 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
917 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
919 static inline int lprocfs_register_stats(struct proc_dir_entry *root,
921 struct lprocfs_stats *stats)
923 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
925 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
926 unsigned int num_stats)
928 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
929 unsigned int num_private_stats)
931 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
933 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
937 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
939 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
941 #ifdef HAVE_SERVER_SUPPORT
943 ssize_t lprocfs_nid_stats_seq_write(struct file *file,
944 const char __user *buffer,
945 size_t count, loff_t *off)
948 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
950 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid)
953 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
955 static inline struct proc_dir_entry *
956 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
957 void *data, const struct file_operations *fops)
959 static inline struct proc_dir_entry *
960 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
961 const char *format, ...)
963 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
964 struct lprocfs_vars *var, void *data)
966 static inline struct proc_dir_entry *
967 lprocfs_register(const char *name, struct proc_dir_entry *parent,
968 struct lprocfs_vars *list, void *data)
970 static inline void lprocfs_remove(struct proc_dir_entry **root)
972 static inline void lprocfs_remove_proc_entry(const char *name,
973 struct proc_dir_entry *parent)
975 static inline int lprocfs_obd_setup(struct obd_device *dev, bool uuid_only)
977 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
979 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
981 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
983 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
985 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
987 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
989 #ifdef HAVE_SERVER_SUPPORT
990 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
993 struct adaptive_timeout;
994 static inline int lprocfs_at_hist_helper(struct seq_file *m,
995 struct adaptive_timeout *at)
997 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
999 static inline ssize_t
1000 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
1001 size_t count, loff_t *off)
1003 #ifdef HAVE_SERVER_SUPPORT
1004 static inline ssize_t
1005 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
1006 size_t count, loff_t *off)
1009 static inline ssize_t
1010 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
1011 size_t count, loff_t *off)
1013 static inline ssize_t
1014 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
1015 size_t count, loff_t *off)
1018 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
1020 static inline ssize_t
1021 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
1022 size_t count, loff_t *off)
1025 /* Statfs helpers */
1027 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
1030 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
1033 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
1036 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
1039 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
1042 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
1045 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1048 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1051 void lprocfs_oh_clear(struct obd_histogram *oh)
1054 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1057 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1058 struct lprocfs_counter *cnt)
1061 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1062 enum lprocfs_fields_flags field)
1063 { return (__u64)0; }
1065 #define LPROC_SEQ_FOPS_RO(name)
1066 #define LPROC_SEQ_FOPS(name)
1067 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
1068 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
1069 #define LPROC_SEQ_FOPS_WR_ONLY(name, type)
1071 /* lprocfs_jobstats.c */
1073 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1077 void lprocfs_job_stats_fini(struct obd_device *obd)
1080 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1081 cntr_init_callback fn)
1085 /* lproc_ptlrpc.c */
1086 #define target_print_req NULL
1088 #endif /* CONFIG_PROC_FS */
1090 #endif /* LPROCFS_STATUS_H */