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;
62 * Append a space separated list of current set flags to str.
64 #define flag2str(port, flag) \
66 if ((port)->port##_##flag) { \
67 seq_printf(m, "%s" #flag, first ? "" : ", "); \
72 void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, __u64 flags2,
74 void obd_connect_data_seqprint(struct seq_file *m,
75 struct obd_connect_data *ocd);
77 /* if we find more consumers this could be generalized */
78 #define OBD_HIST_MAX 32
79 struct obd_histogram {
81 unsigned long oh_buckets[OBD_HIST_MAX];
103 struct obd_histogram hist[BRW_LAST];
107 RENAME_SAMEDIR_SIZE = 0,
108 RENAME_CROSSDIR_SRC_SIZE,
109 RENAME_CROSSDIR_TGT_SIZE,
113 struct rename_stats {
114 struct obd_histogram hist[RENAME_LAST];
117 /* An lprocfs counter can be configured using the enum bit masks below.
119 * LPROCFS_CNTR_EXTERNALLOCK indicates that an external lock already
120 * protects this counter from concurrent updates. If not specified,
121 * lprocfs an internal per-counter lock variable. External locks are
122 * not used to protect counter increments, but are used to protect
123 * counter readout and resets.
125 * LPROCFS_CNTR_AVGMINMAX indicates a multi-valued counter samples,
126 * (i.e. counter can be incremented by more than "1"). When specified,
127 * the counter maintains min, max and sum in addition to a simple
128 * invocation count. This allows averages to be be computed.
129 * If not specified, the counter is an increment-by-1 counter.
130 * min, max, sum, etc. are not maintained.
132 * LPROCFS_CNTR_STDDEV indicates that the counter should track sum of
133 * squares (for multi-valued counter samples only). This allows
134 * external computation of standard deviation, but involves a 64-bit
135 * multiply per counter increment.
139 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
140 LPROCFS_CNTR_AVGMINMAX = 0x0002,
141 LPROCFS_CNTR_STDDEV = 0x0004,
143 /* counter data type */
144 LPROCFS_TYPE_REGS = 0x0100,
145 LPROCFS_TYPE_BYTES = 0x0200,
146 LPROCFS_TYPE_PAGES = 0x0400,
147 LPROCFS_TYPE_CYCLE = 0x0800,
150 #define LC_MIN_INIT ((~(__u64)0) >> 1)
152 struct lprocfs_counter_header {
153 unsigned int lc_config;
154 const char *lc_name; /* must be static */
155 const char *lc_units; /* must be static */
158 struct lprocfs_counter {
164 * Every counter has lc_array_sum[0], while lc_array_sum[1] is only
165 * for irq context counter, i.e. stats with
166 * LPROCFS_STATS_FLAG_IRQ_SAFE flag, its counter need
169 __s64 lc_array_sum[1];
171 #define lc_sum lc_array_sum[0]
172 #define lc_sum_irq lc_array_sum[1]
174 struct lprocfs_percpu {
175 struct lprocfs_counter lp_cntr[0];
178 enum lprocfs_stats_lock_ops {
179 LPROCFS_GET_NUM_CPU = 0x0001, /* number allocated per-CPU stats */
180 LPROCFS_GET_SMP_ID = 0x0002, /* current stat to be updated */
183 enum lprocfs_stats_flags {
184 LPROCFS_STATS_FLAG_NONE = 0x0000, /* per cpu counter */
185 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
186 * area and need locking */
187 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002, /* alloc need irq safe */
190 enum lprocfs_fields_flags {
191 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
192 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
193 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
194 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
195 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
196 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
197 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
200 struct lprocfs_stats {
202 unsigned short ls_num;
203 /* 1 + the biggest cpu # whose ls_percpu slot has been allocated */
204 unsigned short ls_biggest_alloc_num;
205 enum lprocfs_stats_flags ls_flags;
206 /* Lock used when there are no percpu stats areas; For percpu stats,
207 * it is used to protect ls_biggest_alloc_num change */
210 /* has ls_num of counter headers */
211 struct lprocfs_counter_header *ls_cnt_header;
212 struct lprocfs_percpu *ls_percpu[0];
215 #define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
217 /* Pack all opcodes down into a single monotonically increasing index */
218 static inline int opcode_offset(__u32 opc) {
219 if (opc < OST_LAST_OPC) {
221 return (opc - OST_FIRST_OPC);
222 } else if (opc < MDS_LAST_OPC) {
224 return (opc - MDS_FIRST_OPC +
226 } else if (opc < LDLM_LAST_OPC) {
228 return (opc - LDLM_FIRST_OPC +
231 } else if (opc < MGS_LAST_OPC) {
233 return (opc - MGS_FIRST_OPC +
237 } else if (opc < OBD_LAST_OPC) {
239 return (opc - OBD_FIRST_OPC +
244 } else if (opc < LLOG_LAST_OPC) {
246 return (opc - LLOG_FIRST_OPC +
252 } else if (opc < QUOTA_LAST_OPC) {
254 return (opc - QUOTA_FIRST_OPC +
261 } else if (opc < SEQ_LAST_OPC) {
263 return (opc - SEQ_FIRST_OPC +
271 } else if (opc < SEC_LAST_OPC) {
273 return (opc - SEC_FIRST_OPC +
282 } else if (opc < FLD_LAST_OPC) {
284 return (opc - FLD_FIRST_OPC +
294 } else if (opc < OUT_UPDATE_LAST_OPC) {
296 return (opc - OUT_UPDATE_FIRST_OPC +
307 } else if (opc < LFSCK_LAST_OPC) {
309 return (opc - LFSCK_FIRST_OPC +
310 OPC_RANGE(OUT_UPDATE) +
328 #define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
338 OPC_RANGE(OUT_UPDATE) + \
341 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
345 PTLRPC_REQWAIT_CNTR = 0,
346 PTLRPC_REQQDEPTH_CNTR,
347 PTLRPC_REQACTIVE_CNTR,
349 PTLRPC_REQBUF_AVAIL_CNTR,
353 #define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
355 enum lprocfs_extra_opc {
356 LDLM_GLIMPSE_ENQUEUE = 0,
374 #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
376 extern struct proc_dir_entry *proc_lustre_root;
377 extern struct dentry *debugfs_lustre_root;
378 extern struct kset *lustre_kset;
381 struct obd_histogram;
383 #define JOBSTATS_JOBID_VAR_MAX_LEN 20
384 #define JOBSTATS_DISABLE "disable"
385 #define JOBSTATS_PROCNAME_UID "procname_uid"
386 #define JOBSTATS_NODELOCAL "nodelocal"
388 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
390 struct obd_job_stats {
391 struct cfs_hash *ojs_hash; /* hash of jobids */
392 struct list_head ojs_list; /* list of job_stat structs */
393 rwlock_t ojs_lock; /* protect ojs_list/js_list */
394 unsigned int ojs_cleanup_interval;/* seconds before expiry */
395 time64_t ojs_last_cleanup; /* previous cleanup time */
396 cntr_init_callback ojs_cntr_init_fn;/* lprocfs_stats initializer */
397 unsigned short ojs_cntr_num; /* number of stats in struct */
398 bool ojs_cleaning; /* currently expiring stats */
401 #ifdef CONFIG_PROC_FS
403 int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
405 int lprocfs_stats_lock(struct lprocfs_stats *stats,
406 enum lprocfs_stats_lock_ops opc,
407 unsigned long *flags);
408 void lprocfs_stats_unlock(struct lprocfs_stats *stats,
409 enum lprocfs_stats_lock_ops opc,
410 unsigned long *flags);
412 static inline unsigned int
413 lprocfs_stats_counter_size(struct lprocfs_stats *stats)
415 unsigned int percpusize;
417 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
419 /* irq safe stats need lc_array_sum[1] */
420 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
421 percpusize += stats->ls_num * sizeof(__s64);
423 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
424 percpusize = L1_CACHE_ALIGN(percpusize);
429 static inline struct lprocfs_counter *
430 lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
433 struct lprocfs_counter *cntr;
435 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
437 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
438 cntr = (void *)cntr + index * sizeof(__s64);
443 /* Two optimized LPROCFS counter increment functions are provided:
444 * lprocfs_counter_incr(cntr, value) - optimized for by-one counters
445 * lprocfs_counter_add(cntr) - use for multi-valued counters
446 * Counter data layout allows config flag, counter lock and the
447 * count itself to reside within a single cache line.
450 extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
452 extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
455 #define lprocfs_counter_incr(stats, idx) \
456 lprocfs_counter_add(stats, idx, 1)
457 #define lprocfs_counter_decr(stats, idx) \
458 lprocfs_counter_sub(stats, idx, 1)
460 extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
461 struct lprocfs_counter_header *header,
462 enum lprocfs_stats_flags flags,
463 enum lprocfs_fields_flags field);
464 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
465 enum lprocfs_fields_flags field);
467 extern struct lprocfs_stats *
468 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
469 extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
470 extern void lprocfs_free_stats(struct lprocfs_stats **stats);
471 extern void lprocfs_init_mps_stats(int num_private_stats,
472 struct lprocfs_stats *stats);
473 extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
474 extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
475 unsigned int num_stats);
476 extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
477 unsigned int num_private_stats);
478 extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
479 unsigned conf, const char *name,
481 extern void lprocfs_free_obd_stats(struct obd_device *obddev);
482 extern void lprocfs_free_md_stats(struct obd_device *obddev);
485 extern int lprocfs_add_clear_entry(struct obd_device * obd,
486 struct proc_dir_entry *entry);
487 #ifdef HAVE_SERVER_SUPPORT
488 extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid);
489 extern int lprocfs_exp_cleanup(struct obd_export *exp);
490 struct dentry *ldebugfs_add_symlink(const char *name, const char *target,
491 const char *format, ...);
493 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
496 struct dentry *ldebugfs_add_simple(struct dentry *root, char *name, void *data,
497 const struct file_operations *fops);
498 extern struct proc_dir_entry *
499 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
500 void *data, const struct file_operations *fops);
501 extern struct proc_dir_entry *
502 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
503 const char *format, ...);
504 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
505 #ifdef HAVE_SERVER_SUPPORT
507 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
508 size_t count, loff_t *off);
509 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
511 extern int ldebugfs_register_stats(struct dentry *parent, const char *name,
512 struct lprocfs_stats *stats);
513 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
514 struct lprocfs_stats *stats);
516 /* lprocfs_status.c */
517 extern int ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var,
519 extern int lprocfs_add_vars(struct proc_dir_entry *root,
520 struct lprocfs_vars *var, void *data);
522 extern struct dentry *ldebugfs_register(const char *name,
523 struct dentry *parent,
524 struct lprocfs_vars *list,
526 extern struct proc_dir_entry *
527 lprocfs_register(const char *name, struct proc_dir_entry *parent,
528 struct lprocfs_vars *list, void *data);
530 extern void ldebugfs_remove(struct dentry **entryp);
531 extern void lprocfs_remove(struct proc_dir_entry **root);
532 extern void lprocfs_remove_proc_entry(const char *name,
533 struct proc_dir_entry *parent);
534 #ifndef HAVE_REMOVE_PROC_SUBTREE
535 extern int remove_proc_subtree(const char *name,
536 struct proc_dir_entry *parent);
537 #define PDE_DATA(inode) (PDE(inode)->data)
539 static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
541 struct proc_dir_entry *dp = PDE(inode);
544 spin_lock(&(dp)->pde_unload_lock);
545 if (dp->proc_fops == NULL)
547 spin_unlock(&(dp)->pde_unload_lock);
553 static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
557 extern int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only);
558 extern int lprocfs_obd_cleanup(struct obd_device *obd);
559 #ifdef HAVE_SERVER_SUPPORT
560 extern const struct file_operations lprocfs_evict_client_fops;
563 int ldebugfs_seq_create(struct dentry *parent, const char *name, umode_t mode,
564 const struct file_operations *seq_fops, void *data);
565 extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
567 const struct file_operations *seq_fops,
569 extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
571 const struct file_operations *seq_fops,
574 /* Generic callbacks */
575 extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
576 extern int lprocfs_name_seq_show(struct seq_file *m, void *data);
577 extern int lprocfs_server_uuid_seq_show(struct seq_file *m, void *data);
578 extern int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data);
579 ssize_t conn_uuid_show(struct kobject *kobj, struct attribute *attr, char *buf);
580 extern int lprocfs_import_seq_show(struct seq_file *m, void *data);
581 extern int lprocfs_state_seq_show(struct seq_file *m, void *data);
582 extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
583 #ifdef HAVE_SERVER_SUPPORT
584 extern int lprocfs_num_exports_seq_show(struct seq_file *m, void *data);
586 struct adaptive_timeout;
587 extern int lprocfs_at_hist_helper(struct seq_file *m,
588 struct adaptive_timeout *at);
589 extern int lprocfs_timeouts_seq_show(struct seq_file *m, void *data);
591 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
592 size_t count, loff_t *off);
593 #ifdef HAVE_SERVER_SUPPORT
595 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
596 size_t count, loff_t *off);
598 ssize_t ping_store(struct kobject *kobj, struct attribute *attr,
599 const char *buffer, size_t count);
601 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
602 size_t count, loff_t *off);
604 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
605 size_t count, loff_t *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 extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
612 extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
614 extern int lprocfs_str_with_units_to_s64(const char __user *buffer,
615 unsigned long count, __s64 *val,
618 char *lprocfs_strnstr(const char *s1, const char *s2, size_t len);
619 char *lprocfs_find_named_value(const char *buffer, const char *name,
621 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
622 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
623 void lprocfs_oh_clear(struct obd_histogram *oh);
624 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
626 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
627 struct lprocfs_counter *cnt);
629 #ifdef HAVE_SERVER_SUPPORT
630 /* lprocfs_status.c: recovery status */
631 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data);
633 /* lprocfs_status.c: hash statistics */
634 int lprocfs_hash_seq_show(struct seq_file *m, void *data);
636 /* lprocfs_status.c: IR factor */
637 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data);
639 lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
640 size_t count, loff_t *off);
643 /* lprocfs_status.c: dump pages on cksum error */
644 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data);
646 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
647 size_t count, loff_t *off);
649 extern int lprocfs_single_release(struct inode *, struct file *);
650 extern int lprocfs_seq_release(struct inode *, struct file *);
652 /* You must use these macros when you want to refer to
653 * the import in a client obd_device for a lprocfs entry */
654 #define LPROCFS_CLIMP_CHECK(obd) do { \
655 typecheck(struct obd_device *, obd); \
656 down_read(&(obd)->u.cli.cl_sem); \
657 if ((obd)->u.cli.cl_import == NULL) { \
658 up_read(&(obd)->u.cli.cl_sem); \
662 #define LPROCFS_CLIMP_EXIT(obd) \
663 up_read(&(obd)->u.cli.cl_sem);
665 /* write the name##_seq_show function, call LDEBUGFS_SEQ_FOPS_RO for read-only
666 * debugfs entries; otherwise, you will define name##_seq_write function also
667 * for a read-write debugfs entry, and then call LDEBUGFS_SEQ_FOPS instead.
668 * Finally, call ldebugfs_seq_create(obd, filename, 0444, &name#_fops, data);
670 #define __LDEBUGFS_SEQ_FOPS(name, custom_seq_write) \
671 static int name##_single_open(struct inode *inode, struct file *file) \
673 return single_open(file, name##_seq_show, inode->i_private); \
675 static const struct file_operations name##_fops = { \
676 .owner = THIS_MODULE, \
677 .open = name##_single_open, \
679 .write = custom_seq_write, \
680 .llseek = seq_lseek, \
681 .release = single_release, \
684 #define LDEBUGFS_SEQ_FOPS_RO(name) __LDEBUGFS_SEQ_FOPS(name, NULL)
685 #define LDEBUGFS_SEQ_FOPS(name) __LDEBUGFS_SEQ_FOPS(name, \
688 #define LDEBUGFS_SEQ_FOPS_RO_TYPE(name, type) \
689 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
691 return lprocfs_##type##_seq_show(m, m->private); \
693 LDEBUGFS_SEQ_FOPS_RO(name##_##type)
695 #define LDEBUGFS_SEQ_FOPS_RW_TYPE(name, type) \
696 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
698 return lprocfs_##type##_seq_show(m, m->private); \
700 static ssize_t name##_##type##_seq_write(struct file *file, \
701 const char __user *buffer, size_t count, \
704 struct seq_file *seq = file->private_data; \
705 return ldebugfs_##type##_seq_write(file, buffer, count, \
708 LDEBUGFS_SEQ_FOPS(name##_##type);
710 #define LDEBUGFS_FOPS_WR_ONLY(name, type) \
711 static ssize_t name##_##type##_write(struct file *file, \
712 const char __user *buffer, size_t count, \
715 return ldebugfs_##type##_seq_write(file, buffer, count, \
718 static int name##_##type##_open(struct inode *inode, \
721 return single_open(file, NULL, inode->i_private); \
723 static const struct file_operations name##_##type##_fops = { \
724 .open = name##_##type##_open, \
725 .write = name##_##type##_write, \
726 .release = single_release, \
729 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
730 * proc entries; otherwise, you will define name##_seq_write function also for
731 * a read-write proc entry, and then call LPROC_SEQ_FOPS instead. Finally,
732 * call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data);
734 #define __LPROC_SEQ_FOPS(name, custom_seq_write) \
735 static int name##_single_open(struct inode *inode, struct file *file) \
739 rc = LPROCFS_ENTRY_CHECK(inode); \
743 return single_open(file, name##_seq_show, \
744 inode->i_private ? inode->i_private : \
747 static const struct file_operations name##_fops = { \
748 .owner = THIS_MODULE, \
749 .open = name##_single_open, \
751 .write = custom_seq_write, \
752 .llseek = seq_lseek, \
753 .release = lprocfs_single_release, \
756 #define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
757 #define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
759 #define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
760 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
762 return lprocfs_##type##_seq_show(m, m->private); \
764 LPROC_SEQ_FOPS_RO(name##_##type)
766 #define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
767 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
769 return lprocfs_##type##_seq_show(m, m->private); \
771 static ssize_t name##_##type##_seq_write(struct file *file, \
772 const char __user *buffer, size_t count, \
775 struct seq_file *seq = file->private_data; \
776 return lprocfs_##type##_seq_write(file, buffer, \
777 count, seq->private); \
779 LPROC_SEQ_FOPS(name##_##type);
781 #define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
782 static ssize_t name##_##type##_write(struct file *file, \
783 const char __user *buffer, size_t count, \
786 return lprocfs_##type##_seq_write(file, buffer, count, off);\
788 static int name##_##type##_open(struct inode *inode, struct file *file)\
790 return single_open(file, NULL, \
791 inode->i_private ? inode->i_private : \
794 static const struct file_operations name##_##type##_fops = { \
795 .open = name##_##type##_open, \
796 .write = name##_##type##_write, \
797 .release = lprocfs_single_release, \
801 struct attribute attr;
802 ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
804 ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
805 const char *buf, size_t len);
808 #define LUSTRE_ATTR(name, mode, show, store) \
809 static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
811 #define LUSTRE_WO_ATTR(name) LUSTRE_ATTR(name, 0200, NULL, name##_store)
812 #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
813 #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
815 ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr,
817 ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
818 const char *buf, size_t len);
820 extern const struct sysfs_ops lustre_sysfs_ops;
823 struct ptlrpc_request;
824 extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
826 #ifdef HAVE_SERVER_SUPPORT
827 /* lprocfs_jobstats.c */
828 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
829 int event, long amount);
830 void lprocfs_job_stats_fini(struct obd_device *obd);
831 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
832 cntr_init_callback fn);
833 int lprocfs_job_interval_seq_show(struct seq_file *m, void *data);
835 lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer,
836 size_t count, loff_t *off);
838 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data);
839 ssize_t lprocfs_recovery_time_soft_seq_write(struct file *file,
840 const char __user *buffer,
841 size_t count, loff_t *off);
842 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data);
844 lprocfs_recovery_time_hard_seq_write(struct file *file,
845 const char __user *buffer,
846 size_t count, loff_t *off);
847 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data);
849 int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data);
850 ssize_t lprocfs_obd_max_pages_per_rpc_seq_write(struct file *file,
851 const char __user *buffer,
852 size_t count, loff_t *off);
853 int lprocfs_obd_short_io_bytes_seq_show(struct seq_file *m, void *data);
854 ssize_t lprocfs_obd_short_io_bytes_seq_write(struct file *file,
855 const char __user *buffer,
856 size_t count, loff_t *off);
857 ssize_t short_io_bytes_show(struct kobject *kobj, struct attribute *attr,
859 ssize_t short_io_bytes_store(struct kobject *kobj, struct attribute *attr,
860 const char *buffer, size_t count);
862 struct root_squash_info;
863 int lprocfs_wr_root_squash(const char __user *buffer, unsigned long count,
864 struct root_squash_info *squash, char *name);
865 int lprocfs_wr_nosquash_nids(const char __user *buffer, unsigned long count,
866 struct root_squash_info *squash, char *name);
868 #else /* !CONFIG_PROC_FS */
870 #define proc_lustre_root NULL
872 static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
873 int index, long amount)
875 static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
878 static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
879 int index, long amount)
881 static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
884 static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
885 int index, unsigned conf,
886 const char *name, const char *units)
889 static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
890 enum lprocfs_fields_flags field)
893 /* NB: we return !NULL to satisfy error checker */
894 static inline struct lprocfs_stats *
895 lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
896 { return (struct lprocfs_stats *)1; }
897 static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
899 static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
901 static inline int lprocfs_register_stats(struct proc_dir_entry *root,
903 struct lprocfs_stats *stats)
905 static inline void lprocfs_init_mps_stats(int num_private_stats,
906 struct lprocfs_stats *stats)
908 static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
910 static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
911 unsigned int num_stats)
913 static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
914 unsigned int num_private_stats)
916 static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
918 static inline void lprocfs_free_md_stats(struct obd_device *obddev)
922 static inline int lprocfs_add_clear_entry(struct obd_export *exp)
924 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
926 #ifdef HAVE_SERVER_SUPPORT
928 ssize_t lprocfs_nid_stats_seq_write(struct file *file,
929 const char __user *buffer,
930 size_t count, loff_t *off)
933 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
935 static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid)
938 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
940 static inline struct proc_dir_entry *
941 lprocfs_add_simple(struct proc_dir_entry *root, char *name,
942 void *data, const struct file_operations *fops)
944 static inline struct proc_dir_entry *
945 lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
946 const char *format, ...)
948 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
949 struct lprocfs_vars *var, void *data)
951 static inline struct proc_dir_entry *
952 lprocfs_register(const char *name, struct proc_dir_entry *parent,
953 struct lprocfs_vars *list, void *data)
955 static inline void lprocfs_remove(struct proc_dir_entry **root)
957 static inline void lprocfs_remove_proc_entry(const char *name,
958 struct proc_dir_entry *parent)
960 static inline int lprocfs_obd_setup(struct obd_device *dev, bool uuid_only)
962 static inline int lprocfs_obd_cleanup(struct obd_device *dev)
964 static inline int lprocfs_uuid_seq_show(struct seq_file *m, void *data)
966 static inline int lprocfs_name_seq_show(struct seq_file *m, void *data)
968 static inline int lprocfs_server_seq_show(struct seq_file *m, void *data)
970 static inline int lprocfs_conn_uuid_seq_show(struct seq_file *m, void *data)
972 static inline int lprocfs_import_seq_show(struct seq_file *m, void *data)
974 static inline int lprocfs_state_seq_show(struct seq_file *m, void *data)
976 static inline int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data)
978 #ifdef HAVE_SERVER_SUPPORT
979 static inline int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
982 struct adaptive_timeout;
983 static inline int lprocfs_at_hist_helper(struct seq_file *m,
984 struct adaptive_timeout *at)
986 static inline int lprocfs_timeouts_seq_show(struct seq_file *m, void *data)
988 static inline ssize_t
989 lprocfs_timeouts_seq_write(struct file *file, const char __user *buffer,
990 size_t count, loff_t *off)
992 #ifdef HAVE_SERVER_SUPPORT
993 static inline ssize_t
994 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
995 size_t count, loff_t *off)
998 static inline ssize_t
999 lprocfs_ping_seq_write(struct file *file, const char __user *buffer,
1000 size_t count, loff_t *off)
1002 static inline ssize_t
1003 lprocfs_import_seq_write(struct file *file, const char __user *buffer,
1004 size_t count, loff_t *off)
1007 lprocfs_pinger_recov_seq_show(struct seq_file *m, void *data)
1009 static inline ssize_t
1010 lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer,
1011 size_t count, loff_t *off)
1014 /* Statfs helpers */
1016 int lprocfs_blksize_seq_show(struct seq_file *m, void *data)
1019 int lprocfs_kbytestotal_seq_show(struct seq_file *m, void *data)
1022 int lprocfs_kbytesfree_seq_show(struct seq_file *m, void *data)
1025 int lprocfs_kbytesavail_seq_show(struct seq_file *m, void *data)
1028 int lprocfs_filestotal_seq_show(struct seq_file *m, void *data)
1031 int lprocfs_filesfree_seq_show(struct seq_file *m, void *data)
1034 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
1037 void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
1040 void lprocfs_oh_clear(struct obd_histogram *oh)
1043 unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
1046 void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
1047 struct lprocfs_counter *cnt)
1050 u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
1051 enum lprocfs_fields_flags field)
1052 { return (__u64)0; }
1054 #define LPROC_SEQ_FOPS_RO(name)
1055 #define LPROC_SEQ_FOPS(name)
1056 #define LPROC_SEQ_FOPS_RO_TYPE(name, type)
1057 #define LPROC_SEQ_FOPS_RW_TYPE(name, type)
1058 #define LPROC_SEQ_FOPS_WR_ONLY(name, type)
1060 /* lprocfs_jobstats.c */
1062 int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event,
1066 void lprocfs_job_stats_fini(struct obd_device *obd)
1069 int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
1070 cntr_init_callback fn)
1074 /* lproc_ptlrpc.c */
1075 #define target_print_req NULL
1077 #endif /* CONFIG_PROC_FS */
1079 #endif /* LPROCFS_STATUS_H */