1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42#ifndef _LPROCFS_SNMP_H
43#define _LPROCFS_SNMP_H
44
45#include <linux/debugfs.h>
46#include <linux/seq_file.h>
47#include <linux/spinlock.h>
48#include <linux/types.h>
49
50#include "lustre/lustre_idl.h"
51
52struct lprocfs_vars {
53 const char *name;
54 struct file_operations *fops;
55 void *data;
56
57
58
59 umode_t proc_mode;
60};
61
62struct lprocfs_static_vars {
63 struct lprocfs_vars *obd_vars;
64 struct attribute_group *sysfs_vars;
65};
66
67
68#define OBD_HIST_MAX 32
69struct obd_histogram {
70 spinlock_t oh_lock;
71 unsigned long oh_buckets[OBD_HIST_MAX];
72};
73
74enum {
75 BRW_R_PAGES = 0,
76 BRW_W_PAGES,
77 BRW_R_RPC_HIST,
78 BRW_W_RPC_HIST,
79 BRW_R_IO_TIME,
80 BRW_W_IO_TIME,
81 BRW_R_DISCONT_PAGES,
82 BRW_W_DISCONT_PAGES,
83 BRW_R_DISCONT_BLOCKS,
84 BRW_W_DISCONT_BLOCKS,
85 BRW_R_DISK_IOSIZE,
86 BRW_W_DISK_IOSIZE,
87 BRW_R_DIO_FRAGS,
88 BRW_W_DIO_FRAGS,
89 BRW_LAST,
90};
91
92struct brw_stats {
93 struct obd_histogram hist[BRW_LAST];
94};
95
96enum {
97 RENAME_SAMEDIR_SIZE = 0,
98 RENAME_CROSSDIR_SRC_SIZE,
99 RENAME_CROSSDIR_TGT_SIZE,
100 RENAME_LAST,
101};
102
103struct rename_stats {
104 struct obd_histogram hist[RENAME_LAST];
105};
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128enum {
129 LPROCFS_CNTR_EXTERNALLOCK = 0x0001,
130 LPROCFS_CNTR_AVGMINMAX = 0x0002,
131 LPROCFS_CNTR_STDDEV = 0x0004,
132
133
134 LPROCFS_TYPE_REGS = 0x0100,
135 LPROCFS_TYPE_BYTES = 0x0200,
136 LPROCFS_TYPE_PAGES = 0x0400,
137 LPROCFS_TYPE_CYCLE = 0x0800,
138};
139
140#define LC_MIN_INIT ((~(__u64)0) >> 1)
141
142struct lprocfs_counter_header {
143 unsigned int lc_config;
144 const char *lc_name;
145 const char *lc_units;
146};
147
148struct lprocfs_counter {
149 __s64 lc_count;
150 __s64 lc_min;
151 __s64 lc_max;
152 __s64 lc_sumsquare;
153
154
155
156
157
158
159 __s64 lc_array_sum[1];
160};
161#define lc_sum lc_array_sum[0]
162#define lc_sum_irq lc_array_sum[1]
163
164struct lprocfs_percpu {
165#ifndef __GNUC__
166 __s64 pad;
167#endif
168 struct lprocfs_counter lp_cntr[0];
169};
170
171#define LPROCFS_GET_NUM_CPU 0x0001
172#define LPROCFS_GET_SMP_ID 0x0002
173
174enum lprocfs_stats_flags {
175 LPROCFS_STATS_FLAG_NONE = 0x0000,
176 LPROCFS_STATS_FLAG_NOPERCPU = 0x0001,
177
178 LPROCFS_STATS_FLAG_IRQ_SAFE = 0x0002,
179};
180
181enum lprocfs_fields_flags {
182 LPROCFS_FIELDS_FLAGS_CONFIG = 0x0001,
183 LPROCFS_FIELDS_FLAGS_SUM = 0x0002,
184 LPROCFS_FIELDS_FLAGS_MIN = 0x0003,
185 LPROCFS_FIELDS_FLAGS_MAX = 0x0004,
186 LPROCFS_FIELDS_FLAGS_AVG = 0x0005,
187 LPROCFS_FIELDS_FLAGS_SUMSQUARE = 0x0006,
188 LPROCFS_FIELDS_FLAGS_COUNT = 0x0007,
189};
190
191struct lprocfs_stats {
192
193 unsigned short ls_num;
194
195 unsigned short ls_biggest_alloc_num;
196 enum lprocfs_stats_flags ls_flags;
197
198
199 spinlock_t ls_lock;
200
201
202 struct lprocfs_counter_header *ls_cnt_header;
203 struct lprocfs_percpu *ls_percpu[0];
204};
205
206#define OPC_RANGE(seg) (seg ## _LAST_OPC - seg ## _FIRST_OPC)
207
208
209static inline int opcode_offset(__u32 opc) {
210 if (opc < OST_LAST_OPC) {
211
212 return (opc - OST_FIRST_OPC);
213 } else if (opc < MDS_LAST_OPC) {
214
215 return (opc - MDS_FIRST_OPC +
216 OPC_RANGE(OST));
217 } else if (opc < LDLM_LAST_OPC) {
218
219 return (opc - LDLM_FIRST_OPC +
220 OPC_RANGE(MDS) +
221 OPC_RANGE(OST));
222 } else if (opc < MGS_LAST_OPC) {
223
224 return (opc - MGS_FIRST_OPC +
225 OPC_RANGE(LDLM) +
226 OPC_RANGE(MDS) +
227 OPC_RANGE(OST));
228 } else if (opc < OBD_LAST_OPC) {
229
230 return (opc - OBD_FIRST_OPC +
231 OPC_RANGE(MGS) +
232 OPC_RANGE(LDLM) +
233 OPC_RANGE(MDS) +
234 OPC_RANGE(OST));
235 } else if (opc < LLOG_LAST_OPC) {
236
237 return (opc - LLOG_FIRST_OPC +
238 OPC_RANGE(OBD) +
239 OPC_RANGE(MGS) +
240 OPC_RANGE(LDLM) +
241 OPC_RANGE(MDS) +
242 OPC_RANGE(OST));
243 } else if (opc < QUOTA_LAST_OPC) {
244
245 return (opc - QUOTA_FIRST_OPC +
246 OPC_RANGE(LLOG) +
247 OPC_RANGE(OBD) +
248 OPC_RANGE(MGS) +
249 OPC_RANGE(LDLM) +
250 OPC_RANGE(MDS) +
251 OPC_RANGE(OST));
252 } else if (opc < SEQ_LAST_OPC) {
253
254 return (opc - SEQ_FIRST_OPC +
255 OPC_RANGE(QUOTA) +
256 OPC_RANGE(LLOG) +
257 OPC_RANGE(OBD) +
258 OPC_RANGE(MGS) +
259 OPC_RANGE(LDLM) +
260 OPC_RANGE(MDS) +
261 OPC_RANGE(OST));
262 } else if (opc < SEC_LAST_OPC) {
263
264 return (opc - SEC_FIRST_OPC +
265 OPC_RANGE(SEQ) +
266 OPC_RANGE(QUOTA) +
267 OPC_RANGE(LLOG) +
268 OPC_RANGE(OBD) +
269 OPC_RANGE(MGS) +
270 OPC_RANGE(LDLM) +
271 OPC_RANGE(MDS) +
272 OPC_RANGE(OST));
273 } else if (opc < FLD_LAST_OPC) {
274
275 return (opc - FLD_FIRST_OPC +
276 OPC_RANGE(SEC) +
277 OPC_RANGE(SEQ) +
278 OPC_RANGE(QUOTA) +
279 OPC_RANGE(LLOG) +
280 OPC_RANGE(OBD) +
281 OPC_RANGE(MGS) +
282 OPC_RANGE(LDLM) +
283 OPC_RANGE(MDS) +
284 OPC_RANGE(OST));
285 } else if (opc < UPDATE_LAST_OPC) {
286
287 return (opc - UPDATE_FIRST_OPC +
288 OPC_RANGE(FLD) +
289 OPC_RANGE(SEC) +
290 OPC_RANGE(SEQ) +
291 OPC_RANGE(QUOTA) +
292 OPC_RANGE(LLOG) +
293 OPC_RANGE(OBD) +
294 OPC_RANGE(MGS) +
295 OPC_RANGE(LDLM) +
296 OPC_RANGE(MDS) +
297 OPC_RANGE(OST));
298 } else {
299
300 return -1;
301 }
302}
303
304
305#define LUSTRE_MAX_OPCODES (OPC_RANGE(OST) + \
306 OPC_RANGE(MDS) + \
307 OPC_RANGE(LDLM) + \
308 OPC_RANGE(MGS) + \
309 OPC_RANGE(OBD) + \
310 OPC_RANGE(LLOG) + \
311 OPC_RANGE(SEC) + \
312 OPC_RANGE(SEQ) + \
313 OPC_RANGE(SEC) + \
314 OPC_RANGE(FLD) + \
315 OPC_RANGE(UPDATE))
316
317#define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \
318 OPC_RANGE(EXTRA))
319
320enum {
321 PTLRPC_REQWAIT_CNTR = 0,
322 PTLRPC_REQQDEPTH_CNTR,
323 PTLRPC_REQACTIVE_CNTR,
324 PTLRPC_TIMEOUT,
325 PTLRPC_REQBUF_AVAIL_CNTR,
326 PTLRPC_LAST_CNTR
327};
328
329#define PTLRPC_FIRST_CNTR PTLRPC_REQWAIT_CNTR
330
331enum {
332 LDLM_GLIMPSE_ENQUEUE = 0,
333 LDLM_PLAIN_ENQUEUE,
334 LDLM_EXTENT_ENQUEUE,
335 LDLM_FLOCK_ENQUEUE,
336 LDLM_IBITS_ENQUEUE,
337 MDS_REINT_SETATTR,
338 MDS_REINT_CREATE,
339 MDS_REINT_LINK,
340 MDS_REINT_UNLINK,
341 MDS_REINT_RENAME,
342 MDS_REINT_OPEN,
343 MDS_REINT_SETXATTR,
344 BRW_READ_BYTES,
345 BRW_WRITE_BYTES,
346 EXTRA_LAST_OPC
347};
348
349#define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
350
351extern struct dentry *debugfs_lustre_root;
352extern struct kobject *lustre_kobj;
353
354struct obd_device;
355struct obd_histogram;
356
357
358struct dhms {
359 int d, h, m, s;
360};
361static inline void s2dhms(struct dhms *ts, time_t secs)
362{
363 ts->d = secs / 86400;
364 secs = secs % 86400;
365 ts->h = secs / 3600;
366 secs = secs % 3600;
367 ts->m = secs / 60;
368 ts->s = secs % 60;
369}
370#define DHMS_FMT "%dd%dh%02dm%02ds"
371#define DHMS_VARS(x) (x)->d, (x)->h, (x)->m, (x)->s
372
373#define JOBSTATS_JOBID_VAR_MAX_LEN 20
374#define JOBSTATS_DISABLE "disable"
375#define JOBSTATS_PROCNAME_UID "procname_uid"
376#define JOBSTATS_NODELOCAL "nodelocal"
377
378extern int lprocfs_write_frac_helper(const char __user *buffer,
379 unsigned long count, int *val, int mult);
380extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
381 long val, int mult);
382extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
383 unsigned int cpuid);
384
385
386
387
388static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int opc,
389 unsigned long *flags)
390{
391 int rc = 0;
392
393 switch (opc) {
394 default:
395 LBUG();
396
397 case LPROCFS_GET_SMP_ID:
398 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
399 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
400 spin_lock_irqsave(&stats->ls_lock, *flags);
401 else
402 spin_lock(&stats->ls_lock);
403 return 0;
404 } else {
405 unsigned int cpuid = get_cpu();
406
407 if (unlikely(stats->ls_percpu[cpuid] == NULL)) {
408 rc = lprocfs_stats_alloc_one(stats, cpuid);
409 if (rc < 0) {
410 put_cpu();
411 return rc;
412 }
413 }
414 return cpuid;
415 }
416
417 case LPROCFS_GET_NUM_CPU:
418 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
419 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
420 spin_lock_irqsave(&stats->ls_lock, *flags);
421 else
422 spin_lock(&stats->ls_lock);
423 return 1;
424 }
425 return stats->ls_biggest_alloc_num;
426 }
427}
428
429static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats, int opc,
430 unsigned long *flags)
431{
432 switch (opc) {
433 default:
434 LBUG();
435
436 case LPROCFS_GET_SMP_ID:
437 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
438 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
439 spin_unlock_irqrestore(&stats->ls_lock,
440 *flags);
441 } else {
442 spin_unlock(&stats->ls_lock);
443 }
444 } else {
445 put_cpu();
446 }
447 return;
448
449 case LPROCFS_GET_NUM_CPU:
450 if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) {
451 if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) {
452 spin_unlock_irqrestore(&stats->ls_lock,
453 *flags);
454 } else {
455 spin_unlock(&stats->ls_lock);
456 }
457 }
458 return;
459 }
460}
461
462static inline unsigned int
463lprocfs_stats_counter_size(struct lprocfs_stats *stats)
464{
465 unsigned int percpusize;
466
467 percpusize = offsetof(struct lprocfs_percpu, lp_cntr[stats->ls_num]);
468
469
470 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
471 percpusize += stats->ls_num * sizeof(__s64);
472
473 if ((stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) == 0)
474 percpusize = L1_CACHE_ALIGN(percpusize);
475
476 return percpusize;
477}
478
479static inline struct lprocfs_counter *
480lprocfs_stats_counter_get(struct lprocfs_stats *stats, unsigned int cpuid,
481 int index)
482{
483 struct lprocfs_counter *cntr;
484
485 cntr = &stats->ls_percpu[cpuid]->lp_cntr[index];
486
487 if ((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0)
488 cntr = (void *)cntr + index * sizeof(__s64);
489
490 return cntr;
491}
492
493
494
495
496
497
498
499
500extern void lprocfs_counter_add(struct lprocfs_stats *stats, int idx,
501 long amount);
502extern void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx,
503 long amount);
504
505#define lprocfs_counter_incr(stats, idx) \
506 lprocfs_counter_add(stats, idx, 1)
507#define lprocfs_counter_decr(stats, idx) \
508 lprocfs_counter_sub(stats, idx, 1)
509
510extern __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
511 struct lprocfs_counter_header *header,
512 enum lprocfs_stats_flags flags,
513 enum lprocfs_fields_flags field);
514static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats,
515 int idx,
516 enum lprocfs_fields_flags field)
517{
518 int i;
519 unsigned int num_cpu;
520 unsigned long flags = 0;
521 __u64 ret = 0;
522
523 LASSERT(stats != NULL);
524
525 num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
526 for (i = 0; i < num_cpu; i++) {
527 if (stats->ls_percpu[i] == NULL)
528 continue;
529 ret += lprocfs_read_helper(
530 lprocfs_stats_counter_get(stats, i, idx),
531 &stats->ls_cnt_header[idx], stats->ls_flags,
532 field);
533 }
534 lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
535 return ret;
536}
537
538extern struct lprocfs_stats *
539lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);
540extern void lprocfs_clear_stats(struct lprocfs_stats *stats);
541extern void lprocfs_free_stats(struct lprocfs_stats **stats);
542extern void lprocfs_init_ops_stats(int num_private_stats,
543 struct lprocfs_stats *stats);
544extern void lprocfs_init_mps_stats(int num_private_stats,
545 struct lprocfs_stats *stats);
546extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats);
547extern int lprocfs_alloc_obd_stats(struct obd_device *obddev,
548 unsigned int num_private_stats);
549extern int lprocfs_alloc_md_stats(struct obd_device *obddev,
550 unsigned int num_private_stats);
551extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
552 unsigned conf, const char *name,
553 const char *units);
554extern void lprocfs_free_obd_stats(struct obd_device *obddev);
555extern void lprocfs_free_md_stats(struct obd_device *obddev);
556struct obd_export;
557extern int lprocfs_exp_cleanup(struct obd_export *exp);
558extern struct dentry *ldebugfs_add_simple(struct dentry *root,
559 char *name,
560 void *data,
561 struct file_operations *fops);
562extern struct dentry *
563ldebugfs_add_symlink(const char *name, struct dentry *parent,
564 const char *format, ...);
565
566extern int ldebugfs_register_stats(struct dentry *parent,
567 const char *name,
568 struct lprocfs_stats *stats);
569
570
571extern int ldebugfs_add_vars(struct dentry *parent,
572 struct lprocfs_vars *var,
573 void *data);
574
575extern struct dentry *ldebugfs_register(const char *name,
576 struct dentry *parent,
577 struct lprocfs_vars *list,
578 void *data);
579
580extern void ldebugfs_remove(struct dentry **entryp);
581
582extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
583 struct attribute_group *attrs);
584extern int lprocfs_obd_cleanup(struct obd_device *obd);
585
586extern int ldebugfs_seq_create(struct dentry *parent,
587 const char *name,
588 umode_t mode,
589 const struct file_operations *seq_fops,
590 void *data);
591extern int ldebugfs_obd_seq_create(struct obd_device *dev,
592 const char *name,
593 umode_t mode,
594 const struct file_operations *seq_fops,
595 void *data);
596
597
598
599extern int lprocfs_rd_u64(struct seq_file *m, void *data);
600extern int lprocfs_rd_atomic(struct seq_file *m, void *data);
601extern int lprocfs_wr_atomic(struct file *file, const char __user *buffer,
602 unsigned long count, void *data);
603extern int lprocfs_rd_uint(struct seq_file *m, void *data);
604extern int lprocfs_wr_uint(struct file *file, const char __user *buffer,
605 unsigned long count, void *data);
606extern int lprocfs_rd_name(struct seq_file *m, void *data);
607extern int lprocfs_rd_server_uuid(struct seq_file *m, void *data);
608extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data);
609extern int lprocfs_rd_import(struct seq_file *m, void *data);
610extern int lprocfs_rd_state(struct seq_file *m, void *data);
611extern int lprocfs_rd_connect_flags(struct seq_file *m, void *data);
612
613struct adaptive_timeout;
614extern int lprocfs_at_hist_helper(struct seq_file *m,
615 struct adaptive_timeout *at);
616extern int lprocfs_rd_timeouts(struct seq_file *m, void *data);
617extern int lprocfs_wr_timeouts(struct file *file, const char __user *buffer,
618 unsigned long count, void *data);
619extern int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
620 size_t count, loff_t *off);
621extern int lprocfs_wr_ping(struct file *file, const char __user *buffer,
622 size_t count, loff_t *off);
623extern int lprocfs_wr_import(struct file *file, const char __user *buffer,
624 size_t count, loff_t *off);
625extern int lprocfs_rd_pinger_recov(struct seq_file *m, void *n);
626extern int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
627 size_t count, loff_t *off);
628
629
630
631extern int lprocfs_write_helper(const char __user *buffer, unsigned long count,
632 int *val);
633extern int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult);
634extern int lprocfs_write_u64_helper(const char __user *buffer,
635 unsigned long count, __u64 *val);
636extern int lprocfs_write_frac_u64_helper(const char *buffer,
637 unsigned long count,
638 __u64 *val, int mult);
639extern char *lprocfs_find_named_value(const char *buffer, const char *name,
640 size_t *count);
641void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value);
642void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
643void lprocfs_oh_clear(struct obd_histogram *oh);
644unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
645
646void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
647 struct lprocfs_counter *cnt);
648
649extern int lprocfs_single_release(struct inode *, struct file *);
650extern int lprocfs_seq_release(struct inode *, struct file *);
651
652
653
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); \
659 return -ENODEV; \
660 } \
661} while (0)
662#define LPROCFS_CLIMP_EXIT(obd) \
663 up_read(&(obd)->u.cli.cl_sem)
664
665
666
667
668
669
670#define __LPROC_SEQ_FOPS(name, custom_seq_write) \
671static int name##_single_open(struct inode *inode, struct file *file) \
672{ \
673 return single_open(file, name##_seq_show, inode->i_private); \
674} \
675static struct file_operations name##_fops = { \
676 .owner = THIS_MODULE, \
677 .open = name##_single_open, \
678 .read = seq_read, \
679 .write = custom_seq_write, \
680 .llseek = seq_lseek, \
681 .release = lprocfs_single_release, \
682}
683
684#define LPROC_SEQ_FOPS_RO(name) __LPROC_SEQ_FOPS(name, NULL)
685#define LPROC_SEQ_FOPS(name) __LPROC_SEQ_FOPS(name, name##_seq_write)
686
687#define LPROC_SEQ_FOPS_RO_TYPE(name, type) \
688 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
689 { \
690 return lprocfs_rd_##type(m, m->private); \
691 } \
692 LPROC_SEQ_FOPS_RO(name##_##type)
693
694#define LPROC_SEQ_FOPS_RW_TYPE(name, type) \
695 static int name##_##type##_seq_show(struct seq_file *m, void *v)\
696 { \
697 return lprocfs_rd_##type(m, m->private); \
698 } \
699 static ssize_t name##_##type##_seq_write(struct file *file, \
700 const char __user *buffer, size_t count, \
701 loff_t *off) \
702 { \
703 struct seq_file *seq = file->private_data; \
704 return lprocfs_wr_##type(file, buffer, \
705 count, seq->private); \
706 } \
707 LPROC_SEQ_FOPS(name##_##type)
708
709#define LPROC_SEQ_FOPS_WR_ONLY(name, type) \
710 static ssize_t name##_##type##_write(struct file *file, \
711 const char __user *buffer, size_t count, \
712 loff_t *off) \
713 { \
714 return lprocfs_wr_##type(file, buffer, count, off); \
715 } \
716 static int name##_##type##_open(struct inode *inode, struct file *file) \
717 { \
718 return single_open(file, NULL, inode->i_private); \
719 } \
720 static struct file_operations name##_##type##_fops = { \
721 .open = name##_##type##_open, \
722 .write = name##_##type##_write, \
723 .release = lprocfs_single_release, \
724 }
725
726struct lustre_attr {
727 struct attribute attr;
728 ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
729 char *buf);
730 ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
731 const char *buf, size_t len);
732};
733
734#define LUSTRE_ATTR(name, mode, show, store) \
735static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
736
737#define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
738#define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
739
740ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr,
741 char *buf);
742ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
743 const char *buf, size_t len);
744
745extern const struct sysfs_ops lustre_sysfs_ops;
746
747
748struct ptlrpc_request;
749extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
750
751
752int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data);
753int lprocfs_obd_wr_max_pages_per_rpc(struct file *file, const char *buffer,
754 size_t count, loff_t *off);
755
756
757extern int lprocfs_quota_rd_bunit(char *page, char **start,
758 loff_t off, int count,
759 int *eof, void *data);
760extern int lprocfs_quota_wr_bunit(struct file *file, const char *buffer,
761 unsigned long count, void *data);
762extern int lprocfs_quota_rd_btune(char *page, char **start,
763 loff_t off, int count,
764 int *eof, void *data);
765extern int lprocfs_quota_wr_btune(struct file *file, const char *buffer,
766 unsigned long count, void *data);
767extern int lprocfs_quota_rd_iunit(char *page, char **start,
768 loff_t off, int count,
769 int *eof, void *data);
770extern int lprocfs_quota_wr_iunit(struct file *file, const char *buffer,
771 unsigned long count, void *data);
772extern int lprocfs_quota_rd_itune(char *page, char **start,
773 loff_t off, int count,
774 int *eof, void *data);
775extern int lprocfs_quota_wr_itune(struct file *file, const char *buffer,
776 unsigned long count, void *data);
777extern int lprocfs_quota_rd_type(char *page, char **start, loff_t off, int count,
778 int *eof, void *data);
779extern int lprocfs_quota_wr_type(struct file *file, const char *buffer,
780 unsigned long count, void *data);
781extern int lprocfs_quota_rd_switch_seconds(char *page, char **start, loff_t off,
782 int count, int *eof, void *data);
783extern int lprocfs_quota_wr_switch_seconds(struct file *file,
784 const char *buffer,
785 unsigned long count, void *data);
786extern int lprocfs_quota_rd_sync_blk(char *page, char **start, loff_t off,
787 int count, int *eof, void *data);
788extern int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
789 unsigned long count, void *data);
790extern int lprocfs_quota_rd_switch_qs(char *page, char **start, loff_t off,
791 int count, int *eof, void *data);
792extern int lprocfs_quota_wr_switch_qs(struct file *file,
793 const char *buffer,
794 unsigned long count, void *data);
795extern int lprocfs_quota_rd_boundary_factor(char *page, char **start, loff_t off,
796 int count, int *eof, void *data);
797extern int lprocfs_quota_wr_boundary_factor(struct file *file,
798 const char *buffer,
799 unsigned long count, void *data);
800extern int lprocfs_quota_rd_least_bunit(char *page, char **start, loff_t off,
801 int count, int *eof, void *data);
802extern int lprocfs_quota_wr_least_bunit(struct file *file,
803 const char *buffer,
804 unsigned long count, void *data);
805extern int lprocfs_quota_rd_least_iunit(char *page, char **start, loff_t off,
806 int count, int *eof, void *data);
807extern int lprocfs_quota_wr_least_iunit(struct file *file,
808 const char *buffer,
809 unsigned long count, void *data);
810extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off,
811 int count, int *eof, void *data);
812extern int lprocfs_quota_wr_qs_factor(struct file *file,
813 const char *buffer,
814 unsigned long count, void *data);
815#endif
816