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_time.h>
49 #include <libcfs/linux/linux-misc.h>
50 #include <uapi/linux/lustre/lustre_idl.h>
54 const struct file_operations *fops;
63 * Append a space separated list of current set flags to str.
65 #define flag2str(port, flag) \
67 if ((port)->port##_##flag) { \
68 seq_printf(m, "%s" #flag, first ? "" : ", "); \
73 void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, __u64 flags2,
75 void obd_connect_data_seqprint(struct seq_file *m,
76 struct obd_connect_data *ocd);
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 enum lprocfs_stats_lock_ops {
180 LPROCFS_GET_NUM_CPU = 0x0001, /* number allocated per-CPU stats */
181 LPROCFS_GET_SMP_ID = 0x0002, /* current stat to be updated */
184 enum lprocfs_stats_flags {
185 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
186 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
187 * area and need locking */
188 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
191 enum lprocfs_fields_flags {
192 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
193 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
194 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
195 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
196 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
197 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
198 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
201 struct lprocfs_stats {
203 unsigned short ls_num;
204 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
205 unsigned short ls_biggest_alloc_num;
206 enum lprocfs_stats_flags ls_flags;
207 /* Lock used when there are no percpu stats areas; For percpu stats,
208 * it is used to protect ls_biggest_alloc_num change */
211 /* has ls_num of counter headers */
212 struct lprocfs_counter_header *ls_cnt_header;
213 struct lprocfs_percpu *ls_percpu[0];
216 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
218 /* Pack all opcodes down into a single monotonically increasing index */
219 static inline int opcode_offset(__u32 opc) {
220 if (opc < OST_LAST_OPC) {
222 return (opc - OST_FIRST_OPC);
223 } else if (opc < MDS_LAST_OPC) {
225 return (opc - MDS_FIRST_OPC +
227 } else if (opc < LDLM_LAST_OPC) {
229 return (opc - LDLM_FIRST_OPC +
232 } else if (opc < MGS_LAST_OPC) {
234 return (opc - MGS_FIRST_OPC +
238 } else if (opc < OBD_LAST_OPC) {
240 return (opc - OBD_FIRST_OPC +
245 } else if (opc < LLOG_LAST_OPC) {
247 return (opc - LLOG_FIRST_OPC +
253 } else if (opc < QUOTA_LAST_OPC) {
255 return (opc - QUOTA_FIRST_OPC +
262 } else if (opc < SEQ_LAST_OPC) {
264 return (opc - SEQ_FIRST_OPC +
272 } else if (opc < SEC_LAST_OPC) {
274 return (opc - SEC_FIRST_OPC +
283 } else if (opc < FLD_LAST_OPC) {
285 return (opc - FLD_FIRST_OPC +
295 } else if (opc < OUT_UPDATE_LAST_OPC) {
297 return (opc - OUT_UPDATE_FIRST_OPC +
308 } else if (opc < LFSCK_LAST_OPC) {
310 return (opc - LFSCK_FIRST_OPC +
311 OPC_RANGE(OUT_UPDATE) +
329 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
339 OPC_RANGE(OUT_UPDATE) + \
342 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
346 PTLRPC_REQWAIT_CNTR = 0,
347 PTLRPC_REQQDEPTH_CNTR,
348 PTLRPC_REQACTIVE_CNTR,
350 PTLRPC_REQBUF_AVAIL_CNTR,
354 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
356 enum lprocfs_extra_opc {
357 LDLM_GLIMPSE_ENQUEUE = 0,
375 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
377 extern struct proc_dir_entry *proc_lustre_root;
378 extern struct dentry *debugfs_lustre_root;
379 extern struct kset *lustre_kset;
382 struct obd_histogram;
384 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
385 #define JOBSTATS_DISABLE "disable"
386 #define JOBSTATS_PROCNAME_UID "procname_uid"
387 #define JOBSTATS_NODELOCAL "nodelocal"
389 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
391 struct obd_job_stats {
392 struct cfs_hash *ojs_hash; /* hash of jobids */
393 struct list_head ojs_list; /* list of job_stat structs */
394 rwlock_t ojs_lock; /* protect ojs_list/js_list */
395 unsigned int ojs_cleanup_interval;/* seconds before expiry */
396 time64_t ojs_last_cleanup; /* previous cleanup time */
397 cntr_init_callback ojs_cntr_init_fn;/* lprocfs_stats initializer */
398 unsigned short ojs_cntr_num; /* number of stats in struct */
399 bool ojs_cleaning; /* currently expiring stats */
402 #ifdef CONFIG_PROC_FS
404 int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
406 int lprocfs_stats_lock(struct lprocfs_stats *stats,
407 enum lprocfs_stats_lock_ops opc,
408 unsigned long *flags);
409 void lprocfs_stats_unlock(struct lprocfs_stats *stats,
410 enum lprocfs_stats_lock_ops opc,
411 unsigned long *flags);
413 static inline unsigned int
414 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
416 unsigned int percpusize;
418 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
420 /* irq safe stats need lc_array_sum[1] */
421 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
422 percpusize += stats->ls_num * sizeof(__s64);
424 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
425 percpusize = L1_CACHE_ALIGN(percpusize);
430 static inline struct lprocfs_counter *
431 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
434 struct lprocfs_counter *cntr;
436 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
438 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
439 cntr = (void *)cntr + index * sizeof(__s64);
444 /* Two optimized LPROCFS counter increment functions are provided:
445 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
446 * lprocfs_counter_add(cntr) - use for multi-valued counters
447 * Counter data layout allows config flag, counter lock and the
448 * count itself to reside within a single cache line.
451 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
453 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
456 #define lprocfs_counter_incr(stats, idx) \
457 lprocfs_counter_add(stats, idx, 1)
458 #define lprocfs_counter_decr(stats, idx) \
459 lprocfs_counter_sub(stats, idx, 1)
461 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
462 struct lprocfs_counter_header *header,
463 enum lprocfs_stats_flags flags,
464 enum lprocfs_fields_flags field);
465 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
466 enum lprocfs_fields_flags field);
468 extern struct lprocfs_stats *
469 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
470 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
471 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
472 extern void lprocfs_init_ops_stats(int num_private_stats,
473 struct lprocfs_stats *stats);
474 extern void lprocfs_init_mps_stats(int num_private_stats,
475 struct lprocfs_stats *stats);
476 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
477 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
478 unsigned int num_private_stats);
479 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
480 unsigned int num_private_stats);
481 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
482 unsigned conf, const char *name,
484 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
485 extern void lprocfs_free_md_stats(struct obd_device *obddev);
488 extern int lprocfs_add_clear_entry(struct obd_device * obd,
489 struct proc_dir_entry *entry);
490 #ifdef HAVE_SERVER_SUPPORT
491 extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid);
492 extern int lprocfs_exp_cleanup(struct obd_export *exp);
493 struct dentry *ldebugfs_add_symlink(const char *name, const char *target,
494 const char *format, ...);
496 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
499 struct dentry *ldebugfs_add_simple(struct dentry *root, char *name, void *data,
500 const struct file_operations *fops);
501 extern struct proc_dir_entry *
502 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
503 void *data, const struct file_operations *fops);
504 extern struct proc_dir_entry *
505 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
506 const char *format, ...);
507 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
508 #ifdef HAVE_SERVER_SUPPORT
510 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
511 size_t count, loff_t *off);
512 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
514 extern int ldebugfs_register_stats(struct dentry *parent, const char *name,
515 struct lprocfs_stats *stats);
516 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
517 struct lprocfs_stats *stats);
519 /* lprocfs_status.c */
520 extern int ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var,
522 extern int lprocfs_add_vars(struct proc_dir_entry *root,
523 struct lprocfs_vars *var, void *data);
525 extern struct dentry *ldebugfs_register(const char *name,
526 struct dentry *parent,
527 struct lprocfs_vars *list,
529 extern struct proc_dir_entry *
530 lprocfs_register(const char *name, struct proc_dir_entry *parent,
531 struct lprocfs_vars *list, void *data);
533 extern void ldebugfs_remove(struct dentry **entryp);
534 extern void lprocfs_remove(struct proc_dir_entry **root);
535 extern void lprocfs_remove_proc_entry(const char *name,
536 struct proc_dir_entry *parent);
537 #ifndef HAVE_REMOVE_PROC_SUBTREE
538 extern int remove_proc_subtree(const char *name,
539 struct proc_dir_entry *parent);
540 #define PDE_DATA(inode) (PDE(inode)->data)
542 static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
544 struct proc_dir_entry *dp = PDE(inode);
547 spin_lock(&(dp)->pde_unload_lock);
548 if (dp->proc_fops == NULL)
550 spin_unlock(&(dp)->pde_unload_lock);
556 static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
560 extern int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only);
561 extern int lprocfs_obd_cleanup(struct obd_device *obd);
562 #ifdef HAVE_SERVER_SUPPORT
563 extern const struct file_operations lprocfs_evict_client_fops;
566 int ldebugfs_seq_create(struct dentry *parent, const char *name, umode_t mode,
567 const struct file_operations *seq_fops, void *data);
568 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
570 const struct file_operations *seq_fops,
572 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
574 const struct file_operations *seq_fops,
577 /* Generic callbacks */
578 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
579 extern int lprocfs_name_seq_show(struct seq_file *m, void *data);
580 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
581 extern int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data);
582 ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf);
583 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
584 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
585 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
586 #ifdef HAVE_SERVER_SUPPORT
587 extern int lprocfs_num_exports_seq_show(struct seq_file *m, void *data);
589 struct adaptive_timeout;
590 extern int lprocfs_at_hist_helper(struct seq_file *m,
591 struct adaptive_timeout *at);
592 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
594 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
595 size_t count, loff_t *off);
596 #ifdef HAVE_SERVER_SUPPORT
598 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
599 size_t count, loff_t *off);
601 ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
602 const char *buffer, size_t count);
604 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
605 size_t count, loff_t *off);
607 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
608 size_t count, loff_t *off);
609 extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data);
611 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
612 size_t count, loff_t *off);
614 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
615 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
617 extern int lprocfs_str_with_units_to_s64(const char __user *buffer,
618 unsigned long count, __s64 *val,
621 char *lprocfs_strnstr(const char *s1, const char *s2, size_t len);
622 char *lprocfs_find_named_value(const char *buffer, const char *name,
624 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
625 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
626 void lprocfs_oh_clear(struct obd_histogram *oh);
627 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
629 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
630 struct lprocfs_counter *cnt);
632 #ifdef HAVE_SERVER_SUPPORT
633 /* lprocfs_status.c: recovery status */
634 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
636 /* lprocfs_status.c: hash statistics */
637 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
639 /* lprocfs_status.c: IR factor */
640 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data);
642 lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
643 size_t count, loff_t *off);
646 /* lprocfs_status.c: dump pages on cksum error */
647 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data);
649 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
650 size_t count, loff_t *off);
652 extern int lprocfs_single_release(struct inode *, struct file *);
653 extern int lprocfs_seq_release(struct inode *, struct file *);
655 /* You must use these macros when you want to refer to
656 * the import in a client obd_device for a lprocfs entry */
657 #define LPROCFS_CLIMP_CHECK(obd) do { \
658 typecheck(struct obd_device *, obd); \
659 down_read(&(obd)->u.cli.cl_sem); \
660 if ((obd)->u.cli.cl_import == NULL) { \
661 up_read(&(obd)->u.cli.cl_sem); \
665 #define LPROCFS_CLIMP_EXIT(obd) \
666 up_read(&(obd)->u.cli.cl_sem);
668 /* write the name##_seq_show function, call LDEBUGFS_SEQ_FOPS_RO for read-only
669 * debugfs entries; otherwise, you will define name##_seq_write function also
670 * for a read-write debugfs entry, and then call LDEBUGFS_SEQ_FOPS instead.
671 * Finally, call ldebugfs_seq_create(obd, filename, 0444, &name#_fops, data);
673 #define __LDEBUGFS_SEQ_FOPS(name, custom_seq_write) \
674 static int name##_single_open(struct inode *inode, struct file *file) \
676 return single_open(file, name##_seq_show, inode->i_private); \
678 static const struct file_operations name##_fops = { \
679 .owner = THIS_MODULE, \
680 .open = name##_single_open, \
682 .write = custom_seq_write, \
683 .llseek = seq_lseek, \
684 .release = single_release, \
687 #define LDEBUGFS_SEQ_FOPS_RO(name) __LDEBUGFS_SEQ_FOPS(name, NULL)
688 #define LDEBUGFS_SEQ_FOPS(name) __LDEBUGFS_SEQ_FOPS(name, \
691 #define LDEBUGFS_SEQ_FOPS_RO_TYPE(name, type) \
692 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)\
701 return lprocfs_##type##_seq_show(m, m->private); \
703 static ssize_t name##_##type##_seq_write(struct file *file, \
704 const char __user *buffer, size_t count, \
707 struct seq_file *seq = file->private_data; \
708 return ldebugfs_##type##_seq_write(file, buffer, count, \
711 LDEBUGFS_SEQ_FOPS(name##_##type);
713 #define LDEBUGFS_FOPS_WR_ONLY(name, type) \
714 static ssize_t name##_##type##_write(struct file *file, \
715 const char __user *buffer, size_t count, \
718 return ldebugfs_##type##_seq_write(file, buffer, count, \
721 static int name##_##type##_open(struct inode *inode, \
724 return single_open(file, NULL, inode->i_private); \
726 static const struct file_operations name##_##type##_fops = { \
727 .open = name##_##type##_open, \
728 .write = name##_##type##_write, \
729 .release = single_release, \
732 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
733 * proc entries; otherwise, you will define name##_seq_write function also for
734 * a read-write proc entry, and then call LPROC_SEQ_FOPS instead. Finally,
735 * call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data);
737 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
738 static int name##_single_open(struct inode *inode, struct file *file) \
742 rc = LPROCFS_ENTRY_CHECK(inode); \
746 return single_open(file, name##_seq_show, \
747 inode->i_private ? inode->i_private : \
750 static const struct file_operations name##_fops = { \
751 .owner = THIS_MODULE, \
752 .open = name##_single_open, \
754 .write = custom_seq_write, \
755 .llseek = seq_lseek, \
756 .release = lprocfs_single_release, \
759 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
760 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
762 #define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
763 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
765 return lprocfs_##type##_seq_show(m, m->private); \
767 LPROC_SEQ_FOPS_RO(name##_##type)
769 #define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
770 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
772 return lprocfs_##type##_seq_show(m, m->private); \
774 static ssize_t name##_##type##_seq_write(struct file *file, \
775 const char __user *buffer, size_t count, \
778 struct seq_file *seq = file->private_data; \
779 return lprocfs_##type##_seq_write(file, buffer, \
780 count, seq->private); \
782 LPROC_SEQ_FOPS(name##_##type);
784 #define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
785 static ssize_t name##_##type##_write(struct file *file, \
786 const char __user *buffer, size_t count, \
789 return lprocfs_##type##_seq_write(file, buffer, count, off);\
791 static int name##_##type##_open(struct inode *inode, struct file *file)\
793 return single_open(file, NULL, \
794 inode->i_private ? inode->i_private : \
797 static const struct file_operations name##_##type##_fops = { \
798 .open = name##_##type##_open, \
799 .write = name##_##type##_write, \
800 .release = lprocfs_single_release, \
804 struct attribute attr;
805 ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
807 ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
808 const char *buf, size_t len);
811 #define LUSTRE_ATTR(name, mode, show, store) \
812 static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
814 #define LUSTRE_WO_ATTR(name) LUSTRE_ATTR(name, 0200, NULL, name##_store)
815 #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
816 #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
818 ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr,
820 ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
821 const char *buf, size_t len);
823 extern const struct sysfs_ops lustre_sysfs_ops;
826 struct ptlrpc_request;
827 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
829 #ifdef HAVE_SERVER_SUPPORT
830 /* lprocfs_jobstats.c */
831 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
832 int event, long amount);
833 void lprocfs_job_stats_fini(struct obd_device *obd);
834 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
835 cntr_init_callback fn);
836 int lprocfs_job_interval_seq_show(struct seq_file *m, void *data);
838 lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer,
839 size_t count, loff_t *off);
841 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data);
842 ssize_t lprocfs_recovery_time_soft_seq_write(struct file *file,
843 const char __user *buffer,
844 size_t count, loff_t *off);
845 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data);
847 lprocfs_recovery_time_hard_seq_write(struct file *file,
848 const char __user *buffer,
849 size_t count, loff_t *off);
850 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data);
852 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
853 ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
854 const char __user *buffer,
855 size_t count, loff_t *off);
856 int lprocfs_obd_short_io_bytes_seq_show(struct seq_file *m, void *data);
857 ssize_t lprocfs_obd_short_io_bytes_seq_write(struct file *file,
858 const char __user *buffer,
859 size_t count, loff_t *off);
861 struct root_squash_info;
862 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
863 struct root_squash_info *squash, char *name);
864 int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
865 struct root_squash_info *squash, char *name);
867 #else /* !CONFIG_PROC_FS */
869 #define proc_lustre_root NULL
871 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
872 int index, long amount)
874 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
877 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
878 int index, long amount)
880 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
883 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
884 int index, unsigned conf,
885 const char *name, const char *units)
888 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
889 enum lprocfs_fields_flags field)
892 /* NB: we return !NULL to satisfy error checker */
893 static inline struct lprocfs_stats *
894 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
895 { return (struct lprocfs_stats *)1; }
896 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
898 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
900 static inline int lprocfs_register_stats(struct proc_dir_entry *root,
902 struct lprocfs_stats *stats)
904 static inline void lprocfs_init_ops_stats(int num_private_stats,
905 struct lprocfs_stats *stats)
907 static inline void lprocfs_init_mps_stats(int num_private_stats,
908 struct lprocfs_stats *stats)
910 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
912 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
913 unsigned int num_private_stats)
915 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
916 unsigned int num_private_stats)
918 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
920 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
924 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
926 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
928 #ifdef HAVE_SERVER_SUPPORT
930 ssize_t lprocfs_nid_stats_seq_write(struct file *file,
931 const char __user *buffer,
932 size_t count, loff_t *off)
935 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
937 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid)
940 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
942 static inline struct proc_dir_entry *
943 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
944 void *data, const struct file_operations *fops)
946 static inline struct proc_dir_entry *
947 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
948 const char *format, ...)
950 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
951 struct lprocfs_vars *var, void *data)
953 static inline struct proc_dir_entry *
954 lprocfs_register(const char *name, struct proc_dir_entry *parent,
955 struct lprocfs_vars *list, void *data)
957 static inline void lprocfs_remove(struct proc_dir_entry **root)
959 static inline void lprocfs_remove_proc_entry(const char *name,
960 struct proc_dir_entry *parent)
962 static inline int lprocfs_obd_setup(struct obd_device *dev, bool uuid_only)
964 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
966 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
968 static inline int lprocfs_name_seq_show(struct seq_file *m, void *data)
970 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
972 static inline int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data)
974 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
976 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
978 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
980 #ifdef HAVE_SERVER_SUPPORT
981 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
984 struct adaptive_timeout;
985 static inline int lprocfs_at_hist_helper(struct seq_file *m,
986 struct adaptive_timeout *at)
988 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
990 static inline ssize_t
991 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
992 size_t count, loff_t *off)
994 #ifdef HAVE_SERVER_SUPPORT
995 static inline ssize_t
996 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
997 size_t count, loff_t *off)
1000 static inline ssize_t
1001 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
1002 size_t count, loff_t *off)
1004 static inline ssize_t
1005 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
1006 size_t count, loff_t *off)
1009 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
1011 static inline ssize_t
1012 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
1013 size_t count, loff_t *off)
1016 /* Statfs helpers */
1018 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
1021 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
1024 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
1027 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
1030 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
1033 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
1036 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1039 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1042 void lprocfs_oh_clear(struct obd_histogram *oh)
1045 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1048 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1049 struct lprocfs_counter *cnt)
1052 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1053 enum lprocfs_fields_flags field)
1054 { return (__u64)0; }
1056 #define LPROC_SEQ_FOPS_RO(name)
1057 #define LPROC_SEQ_FOPS(name)
1058 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
1059 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
1060 #define LPROC_SEQ_FOPS_WR_ONLY(name, type)
1062 /* lprocfs_jobstats.c */
1064 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1068 void lprocfs_job_stats_fini(struct obd_device *obd)
1071 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1072 cntr_init_callback fn)
1076 /* lproc_ptlrpc.c */
1077 #define target_print_req NULL
1079 #endif /* CONFIG_PROC_FS */
1081 #endif /* LPROCFS_STATUS_H */