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, 2016, 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 <lustre/lustre_idl.h>
53 const struct file_operations *fops;
61 /* if we find more consumers this could be generalized */
62 #define OBD_HIST_MAX 32
63 struct obd_histogram {
65 unsigned long oh_buckets[OBD_HIST_MAX];
87 struct obd_histogram hist[BRW_LAST];
91 RENAME_SAMEDIR_SIZE = 0,
92 RENAME_CROSSDIR_SRC_SIZE,
93 RENAME_CROSSDIR_TGT_SIZE,
98 struct obd_histogram hist[RENAME_LAST];
101 /* An lprocfs counter can be configured using the enum bit masks below.
103 * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
104 * protects this counter from concurrent updates. If not specified,
105 * lprocfs an internal per-counter lock variable. External locks are
106 * not used to protect counter increments, but are used to protect
107 * counter readout and resets.
109 * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
110 * (i.e. counter can be incremented by more than "1"). When specified,
111 * the counter maintains min, max and sum in addition to a simple
112 * invocation count. This allows averages to be be computed.
113 * If not specified, the counter is an increment-by-1 counter.
114 * min, max, sum, etc. are not maintained.
116 * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
117 * squares (for multi-valued counter samples only). This allows
118 * external computation of standard deviation, but involves a 64-bit
119 * multiply per counter increment.
123 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
124 LPROCFS_CNTR_AVGMINMAX = 0x0002,
125 LPROCFS_CNTR_STDDEV = 0x0004,
127 /* counter data type */
128 LPROCFS_TYPE_REGS = 0x0100,
129 LPROCFS_TYPE_BYTES = 0x0200,
130 LPROCFS_TYPE_PAGES = 0x0400,
131 LPROCFS_TYPE_CYCLE = 0x0800,
134 #define LC_MIN_INIT ((~(__u64)0) >> 1)
136 struct lprocfs_counter_header {
137 unsigned int lc_config;
138 const char *lc_name; /* must be static */
139 const char *lc_units; /* must be static */
142 struct lprocfs_counter {
148 * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
149 * for irq context counter, i.e. stats with
150 * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
153 __s64 lc_array_sum[1];
155 #define lc_sum lc_array_sum[0]
156 #define lc_sum_irq lc_array_sum[1]
158 struct lprocfs_percpu {
159 struct lprocfs_counter lp_cntr[0];
162 enum lprocfs_stats_lock_ops {
163 LPROCFS_GET_NUM_CPU = 0x0001, /* number allocated per-CPU stats */
164 LPROCFS_GET_SMP_ID = 0x0002, /* current stat to be updated */
167 enum lprocfs_stats_flags {
168 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
169 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
170 * area and need locking */
171 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
174 enum lprocfs_fields_flags {
175 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
176 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
177 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
178 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
179 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
180 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
181 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
184 struct lprocfs_stats {
186 unsigned short ls_num;
187 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
188 unsigned short ls_biggest_alloc_num;
189 enum lprocfs_stats_flags ls_flags;
190 /* Lock used when there are no percpu stats areas; For percpu stats,
191 * it is used to protect ls_biggest_alloc_num change */
194 /* has ls_num of counter headers */
195 struct lprocfs_counter_header *ls_cnt_header;
196 struct lprocfs_percpu *ls_percpu[0];
199 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
201 /* Pack all opcodes down into a single monotonically increasing index */
202 static inline int opcode_offset(__u32 opc) {
203 if (opc < OST_LAST_OPC) {
205 return (opc - OST_FIRST_OPC);
206 } else if (opc < MDS_LAST_OPC) {
208 return (opc - MDS_FIRST_OPC +
210 } else if (opc < LDLM_LAST_OPC) {
212 return (opc - LDLM_FIRST_OPC +
215 } else if (opc < MGS_LAST_OPC) {
217 return (opc - MGS_FIRST_OPC +
221 } else if (opc < OBD_LAST_OPC) {
223 return (opc - OBD_FIRST_OPC +
228 } else if (opc < LLOG_LAST_OPC) {
230 return (opc - LLOG_FIRST_OPC +
236 } else if (opc < QUOTA_LAST_OPC) {
238 return (opc - QUOTA_FIRST_OPC +
245 } else if (opc < SEQ_LAST_OPC) {
247 return (opc - SEQ_FIRST_OPC +
255 } else if (opc < SEC_LAST_OPC) {
257 return (opc - SEC_FIRST_OPC +
266 } else if (opc < FLD_LAST_OPC) {
268 return (opc - FLD_FIRST_OPC +
278 } else if (opc < OUT_UPDATE_LAST_OPC) {
280 return (opc - OUT_UPDATE_FIRST_OPC +
291 } else if (opc < LFSCK_LAST_OPC) {
293 return (opc - LFSCK_FIRST_OPC +
294 OPC_RANGE(OUT_UPDATE) +
312 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
322 OPC_RANGE(OUT_UPDATE) + \
325 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
329 PTLRPC_REQWAIT_CNTR = 0,
330 PTLRPC_REQQDEPTH_CNTR,
331 PTLRPC_REQACTIVE_CNTR,
333 PTLRPC_REQBUF_AVAIL_CNTR,
337 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
339 enum lprocfs_extra_opc {
340 LDLM_GLIMPSE_ENQUEUE = 0,
357 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
359 extern struct proc_dir_entry *proc_lustre_root;
360 extern struct dentry *debugfs_lustre_root;
361 extern struct kobject *lustre_kobj;
364 struct obd_histogram;
366 /* Days / hours / mins / seconds format */
370 static inline void s2dhms(struct dhms *ts, time_t secs)
372 ts->d = secs / 86400;
379 #define DHMS_FMT "%dd%dh%02dm%02ds"
380 #define DHMS_VARS(x) (x)->d, (x)->h, (x)->m, (x)->s
382 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
383 #define JOBSTATS_DISABLE "disable"
384 #define JOBSTATS_PROCNAME_UID "procname_uid"
385 #define JOBSTATS_NODELOCAL "nodelocal"
387 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
389 struct obd_job_stats {
390 struct cfs_hash *ojs_hash; /* hash of jobids */
391 struct list_head ojs_list; /* list of job_stat structs */
392 rwlock_t ojs_lock; /* protect ojs_list/js_list */
393 unsigned int ojs_cleanup_interval;/* seconds before expiry */
394 time_t ojs_last_cleanup; /* previous cleanup time */
395 cntr_init_callback ojs_cntr_init_fn;/* lprocfs_stats initializer */
396 unsigned short ojs_cntr_num; /* number of stats in struct */
397 bool ojs_cleaning; /* currently expiring stats */
400 #ifdef CONFIG_PROC_FS
402 int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
404 int lprocfs_stats_lock(struct lprocfs_stats *stats,
405 enum lprocfs_stats_lock_ops opc,
406 unsigned long *flags);
407 void lprocfs_stats_unlock(struct lprocfs_stats *stats,
408 enum lprocfs_stats_lock_ops opc,
409 unsigned long *flags);
411 static inline unsigned int
412 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
414 unsigned int percpusize;
416 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
418 /* irq safe stats need lc_array_sum[1] */
419 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
420 percpusize += stats->ls_num * sizeof(__s64);
422 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
423 percpusize = L1_CACHE_ALIGN(percpusize);
428 static inline struct lprocfs_counter *
429 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
432 struct lprocfs_counter *cntr;
434 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
436 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
437 cntr = (void *)cntr + index * sizeof(__s64);
442 /* Two optimized LPROCFS counter increment functions are provided:
443 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
444 * lprocfs_counter_add(cntr) - use for multi-valued counters
445 * Counter data layout allows config flag, counter lock and the
446 * count itself to reside within a single cache line.
449 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
451 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
454 #define lprocfs_counter_incr(stats, idx) \
455 lprocfs_counter_add(stats, idx, 1)
456 #define lprocfs_counter_decr(stats, idx) \
457 lprocfs_counter_sub(stats, idx, 1)
459 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
460 struct lprocfs_counter_header *header,
461 enum lprocfs_stats_flags flags,
462 enum lprocfs_fields_flags field);
463 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
464 enum lprocfs_fields_flags field);
466 extern struct lprocfs_stats *
467 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
468 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
469 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
470 extern void lprocfs_init_ops_stats(int num_private_stats,
471 struct lprocfs_stats *stats);
472 extern void lprocfs_init_mps_stats(int num_private_stats,
473 struct lprocfs_stats *stats);
474 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
475 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
476 unsigned int num_private_stats);
477 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
478 unsigned int num_private_stats);
479 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
480 unsigned conf, const char *name,
482 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
483 extern void lprocfs_free_md_stats(struct obd_device *obddev);
486 extern int lprocfs_add_clear_entry(struct obd_device * obd,
487 struct proc_dir_entry *entry);
488 #ifdef HAVE_SERVER_SUPPORT
489 extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid);
490 extern int lprocfs_exp_cleanup(struct obd_export *exp);
492 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
495 extern struct proc_dir_entry *
496 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
497 void *data, const struct file_operations *fops);
498 extern struct proc_dir_entry *
499 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
500 const char *format, ...);
501 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
502 #ifdef HAVE_SERVER_SUPPORT
504 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
505 size_t count, loff_t *off);
506 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
508 extern int ldebugfs_register_stats(struct dentry *parent, const char *name,
509 struct lprocfs_stats *stats);
510 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
511 struct lprocfs_stats *stats);
513 /* lprocfs_status.c */
514 extern int ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var,
516 extern int lprocfs_add_vars(struct proc_dir_entry *root,
517 struct lprocfs_vars *var, void *data);
519 extern struct dentry *ldebugfs_register(const char *name,
520 struct dentry *parent,
521 struct lprocfs_vars *list,
523 extern struct proc_dir_entry *
524 lprocfs_register(const char *name, struct proc_dir_entry *parent,
525 struct lprocfs_vars *list, void *data);
527 extern void ldebugfs_remove(struct dentry **entryp);
528 extern void lprocfs_remove(struct proc_dir_entry **root);
529 extern void lprocfs_remove_proc_entry(const char *name,
530 struct proc_dir_entry *parent);
531 #ifndef HAVE_REMOVE_PROC_SUBTREE
532 extern int remove_proc_subtree(const char *name,
533 struct proc_dir_entry *parent);
534 #define PDE_DATA(inode) (PDE(inode)->data)
536 static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
538 struct proc_dir_entry *dp = PDE(inode);
541 spin_lock(&(dp)->pde_unload_lock);
542 if (dp->proc_fops == NULL)
544 spin_unlock(&(dp)->pde_unload_lock);
550 static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
553 extern int lprocfs_obd_setup(struct obd_device *dev);
554 extern int lprocfs_obd_cleanup(struct obd_device *obd);
555 #ifdef HAVE_SERVER_SUPPORT
556 extern const struct file_operations lprocfs_evict_client_fops;
559 extern int ldebugfs_seq_create(struct dentry *parent, const char *name,
561 const struct file_operations *seq_fops,
563 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
565 const struct file_operations *seq_fops,
567 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
569 const struct file_operations *seq_fops,
572 /* Generic callbacks */
573 extern int lprocfs_u64_seq_show(struct seq_file *m, void *data);
574 extern int lprocfs_atomic_seq_show(struct seq_file *m, void *data);
575 extern ssize_t lprocfs_atomic_seq_write(struct file *file,
576 const char __user *buffer,
577 size_t count, loff_t *off);
578 extern int lprocfs_uint_seq_show(struct seq_file *m, void *data);
579 extern ssize_t lprocfs_uint_seq_write(struct file *file,
580 const char __user *buffer,
581 size_t count, loff_t *off);
582 extern int lprocfs_wr_uint(struct file *file, const char __user *buffer,
583 unsigned long count, void *data);
584 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
585 extern int lprocfs_name_seq_show(struct seq_file *m, void *data);
586 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
587 extern int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data);
588 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
589 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
590 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
591 #ifdef HAVE_SERVER_SUPPORT
592 extern int lprocfs_num_exports_seq_show(struct seq_file *m, void *data);
594 struct adaptive_timeout;
595 extern int lprocfs_at_hist_helper(struct seq_file *m,
596 struct adaptive_timeout *at);
597 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
599 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
600 size_t count, loff_t *off);
601 #ifdef HAVE_SERVER_SUPPORT
603 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
604 size_t count, loff_t *off);
607 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
608 size_t count, loff_t *off);
610 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
611 size_t count, loff_t *off);
612 extern int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data);
614 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
615 size_t count, loff_t *off);
618 extern int lprocfs_blksize_seq_show(struct seq_file *m, void *data);
619 extern int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data);
620 extern int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data);
621 extern int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data);
622 extern int lprocfs_filestotal_seq_show(struct seq_file *m, void *data);
623 extern int lprocfs_filesfree_seq_show(struct seq_file *m, void *data);
625 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
626 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
628 extern int lprocfs_str_to_s64(const char __user *buffer, unsigned long count,
630 extern int lprocfs_str_with_units_to_s64(const char __user *buffer,
631 unsigned long count, __s64 *val,
633 char *lprocfs_find_named_value(const char *buffer, const char *name,
635 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
636 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
637 void lprocfs_oh_clear(struct obd_histogram *oh);
638 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
640 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
641 struct lprocfs_counter *cnt);
643 #ifdef HAVE_SERVER_SUPPORT
644 /* lprocfs_status.c: recovery status */
645 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
647 /* lprocfs_status.c: hash statistics */
648 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
650 /* lprocfs_status.c: IR factor */
651 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data);
653 lprocfs_ir_factor_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 LPROC_SEQ_FOPS_RO for read-only
673 proc entries; otherwise, you will define name##_seq_write function also for
674 a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
675 call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
676 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
677 static int name##_single_open(struct inode *inode, struct file *file) \
681 rc = LPROCFS_ENTRY_CHECK(inode); \
685 return single_open(file, name##_seq_show, \
686 inode->i_private ? : PDE_DATA(inode)); \
688 static const struct file_operations name##_fops = { \
689 .owner = THIS_MODULE, \
690 .open = name##_single_open, \
692 .write = custom_seq_write, \
693 .llseek = seq_lseek, \
694 .release = lprocfs_single_release, \
697 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
698 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
700 #define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
701 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
703 return lprocfs_##type##_seq_show(m, m->private); \
705 LPROC_SEQ_FOPS_RO(name##_##type)
707 #define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
708 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
710 return lprocfs_##type##_seq_show(m, m->private); \
712 static ssize_t name##_##type##_seq_write(struct file *file, \
713 const char __user *buffer, size_t count, \
716 struct seq_file *seq = file->private_data; \
717 return lprocfs_##type##_seq_write(file, buffer, \
718 count, seq->private); \
720 LPROC_SEQ_FOPS(name##_##type);
722 #define LPROC_SEQ_FOPS_WO_TYPE(name, type) \
723 static ssize_t name##_##type##_write(struct file *file, \
724 const char __user *buffer, size_t count, \
727 return lprocfs_##type##_seq_write(file, buffer, count, off);\
729 static int name##_##type##_open(struct inode *inode, struct file *file)\
731 return single_open(file, NULL, \
732 inode->i_private ? : PDE_DATA(inode));\
734 static const struct file_operations name##_##type##_fops = { \
735 .open = name##_##type##_open, \
736 .write = name##_##type##_write, \
737 .release = lprocfs_single_release, \
741 struct attribute attr;
742 ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
744 ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
745 const char *buf, size_t len);
748 #define LUSTRE_ATTR(name, mode, show, store) \
749 static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
751 #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
752 #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
754 ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr,
756 ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
757 const char *buf, size_t len);
759 extern const struct sysfs_ops lustre_sysfs_ops;
762 struct ptlrpc_request;
763 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
765 #ifdef HAVE_SERVER_SUPPORT
766 /* lprocfs_jobstats.c */
767 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
768 int event, long amount);
769 void lprocfs_job_stats_fini(struct obd_device *obd);
770 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
771 cntr_init_callback fn);
772 int lprocfs_job_interval_seq_show(struct seq_file *m, void *data);
774 lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer,
775 size_t count, loff_t *off);
777 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data);
778 ssize_t lprocfs_recovery_time_soft_seq_write(struct file *file,
779 const char __user *buffer,
780 size_t count, loff_t *off);
781 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data);
783 lprocfs_recovery_time_hard_seq_write(struct file *file,
784 const char __user *buffer,
785 size_t count, loff_t *off);
786 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data);
788 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
790 lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
791 const char __user *buffer,
792 size_t count, loff_t *off);
794 struct root_squash_info;
795 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
796 struct root_squash_info *squash, char *name);
797 int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
798 struct root_squash_info *squash, char *name);
800 #else /* !CONFIG_PROC_FS */
802 #define proc_lustre_root NULL
804 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
805 int index, long amount)
807 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
810 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
811 int index, long amount)
813 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
816 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
817 int index, unsigned conf,
818 const char *name, const char *units)
821 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
822 enum lprocfs_fields_flags field)
825 /* NB: we return !NULL to satisfy error checker */
826 static inline struct lprocfs_stats *
827 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
828 { return (struct lprocfs_stats *)1; }
829 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
831 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
833 static inline int lprocfs_register_stats(struct proc_dir_entry *root,
835 struct lprocfs_stats *stats)
837 static inline void lprocfs_init_ops_stats(int num_private_stats,
838 struct lprocfs_stats *stats)
840 static inline void lprocfs_init_mps_stats(int num_private_stats,
841 struct lprocfs_stats *stats)
843 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
845 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
846 unsigned int num_private_stats)
848 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
849 unsigned int num_private_stats)
851 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
853 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
857 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
859 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
861 #ifdef HAVE_SERVER_SUPPORT
863 ssize_t lprocfs_nid_stats_seq_write(struct file *file,
864 const char __user *buffer,
865 size_t count, loff_t *off)
868 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
870 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid)
873 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
875 static inline struct proc_dir_entry *
876 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
877 void *data, const struct file_operations *fops)
879 static inline struct proc_dir_entry *
880 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
881 const char *format, ...)
883 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
884 struct lprocfs_vars *var, void *data)
886 static inline struct proc_dir_entry *
887 lprocfs_register(const char *name, struct proc_dir_entry *parent,
888 struct lprocfs_vars *list, void *data)
890 static inline void lprocfs_remove(struct proc_dir_entry **root)
892 static inline void lprocfs_remove_proc_entry(const char *name,
893 struct proc_dir_entry *parent)
895 static inline int lprocfs_obd_setup(struct obd_device *dev)
897 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
899 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
901 static inline int lprocfs_name_seq_show(struct seq_file *m, void *data)
903 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
905 static inline int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data)
907 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
909 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
911 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
913 #ifdef HAVE_SERVER_SUPPORT
914 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
917 struct adaptive_timeout;
918 static inline int lprocfs_at_hist_helper(struct seq_file *m,
919 struct adaptive_timeout *at)
921 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
923 static inline ssize_t
924 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
925 size_t count, loff_t *off)
927 #ifdef HAVE_SERVER_SUPPORT
928 static inline ssize_t
929 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
930 size_t count, loff_t *off)
933 static inline ssize_t
934 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
935 size_t count, loff_t *off)
937 static inline ssize_t
938 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
939 size_t count, loff_t *off)
942 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
944 static inline ssize_t
945 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
946 size_t count, loff_t *off)
951 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
954 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
957 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
960 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
963 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
966 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
969 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
972 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
975 void lprocfs_oh_clear(struct obd_histogram *oh)
978 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
981 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
982 struct lprocfs_counter *cnt)
985 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
986 enum lprocfs_fields_flags field)
989 #define LPROC_SEQ_FOPS_RO(name)
990 #define LPROC_SEQ_FOPS(name)
991 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
992 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
993 #define LPROC_SEQ_FOPS_WO_TYPE(name, type)
995 /* lprocfs_jobstats.c */
997 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1001 void lprocfs_job_stats_fini(struct obd_device *obd)
1004 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1005 cntr_init_callback fn)
1009 /* lproc_ptlrpc.c */
1010 #define target_print_req NULL
1012 #endif /* CONFIG_PROC_FS */
1014 #endif /* LPROCFS_STATUS_H */