Whamcloud - gitweb
LU-4563 Fix unsafe userspace access in many proc files
[fs/lustre-release.git] / lustre / ofd / lproc_ofd.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2012, 2013, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/ofd/lproc_ofd.c
37  */
38
39 #define DEBUG_SUBSYSTEM S_CLASS
40
41 #include <obd.h>
42 #include <lprocfs_status.h>
43 #include <linux/seq_file.h>
44 #include <lustre_lfsck.h>
45
46 #include "ofd_internal.h"
47
48 #ifdef LPROCFS
49
50 static int lprocfs_ofd_rd_seqs(char *page, char **start, off_t off,
51                                 int count, int *eof, void *data)
52 {
53         struct obd_device *obd = (struct obd_device *)data;
54         struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
55
56         *eof = 1;
57         return snprintf(page, count, "%u\n", ofd->ofd_seq_count);
58 }
59
60 static int lprocfs_ofd_rd_tot_dirty(char *page, char **start, off_t off,
61                                     int count, int *eof, void *data)
62 {
63         struct obd_device *obd = (struct obd_device *)data;
64         struct ofd_device *ofd;
65
66         LASSERT(obd != NULL);
67         ofd = ofd_dev(obd->obd_lu_dev);
68         *eof = 1;
69         return snprintf(page, count, LPU64"\n", ofd->ofd_tot_dirty);
70 }
71
72 static int lprocfs_ofd_rd_tot_granted(char *page, char **start, off_t off,
73                                       int count, int *eof, void *data)
74 {
75         struct obd_device *obd = (struct obd_device *)data;
76         struct ofd_device *ofd;
77
78         LASSERT(obd != NULL);
79         ofd = ofd_dev(obd->obd_lu_dev);
80         *eof = 1;
81         return snprintf(page, count, LPU64"\n", ofd->ofd_tot_granted);
82 }
83
84 static int lprocfs_ofd_rd_tot_pending(char *page, char **start, off_t off,
85                                       int count, int *eof, void *data)
86 {
87         struct obd_device *obd = (struct obd_device *)data;
88         struct ofd_device *ofd;
89
90         LASSERT(obd != NULL);
91         ofd = ofd_dev(obd->obd_lu_dev);
92         *eof = 1;
93         return snprintf(page, count, LPU64"\n", ofd->ofd_tot_pending);
94 }
95
96 static int lprocfs_ofd_rd_grant_precreate(char *page, char **start, off_t off,
97                                           int count, int *eof, void *data)
98 {
99         struct obd_device *obd = (struct obd_device *)data;
100
101         LASSERT(obd != NULL);
102         *eof = 1;
103         return snprintf(page, count, "%ld\n",
104                         obd->obd_self_export->exp_filter_data.fed_grant);
105 }
106
107 static int lprocfs_ofd_rd_grant_ratio(char *page, char **start, off_t off,
108                                       int count, int *eof, void *data)
109 {
110         struct obd_device *obd = (struct obd_device *)data;
111         struct ofd_device *ofd;
112
113         LASSERT(obd != NULL);
114         ofd = ofd_dev(obd->obd_lu_dev);
115         *eof = 1;
116         return snprintf(page, count, "%d%%\n",
117                         (int) ofd_grant_reserved(ofd, 100));
118 }
119
120 static int lprocfs_ofd_wr_grant_ratio(struct file *file,
121                                       const char __user *buffer,
122                                       unsigned long count, void *data)
123 {
124         struct obd_device       *obd = (struct obd_device *)data;
125         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
126         int                      val;
127         int                      rc;
128
129         rc = lprocfs_write_helper(buffer, count, &val);
130         if (rc)
131                 return rc;
132
133         if (val > 100 || val < 0)
134                 return -EINVAL;
135
136         if (val == 0)
137                 CWARN("%s: disabling grant error margin\n", obd->obd_name);
138         if (val > 50)
139                 CWARN("%s: setting grant error margin >50%%, be warned that "
140                       "a huge part of the free space is now reserved for "
141                       "grants\n", obd->obd_name);
142
143         spin_lock(&ofd->ofd_grant_lock);
144         ofd->ofd_grant_ratio = ofd_grant_ratio_conv(val);
145         spin_unlock(&ofd->ofd_grant_lock);
146         return count;
147 }
148
149 static int lprocfs_ofd_rd_precreate_batch(char *page, char **start, off_t off,
150                                           int count, int *eof, void *data)
151 {
152         struct obd_device *obd = (struct obd_device *)data;
153         struct ofd_device *ofd;
154
155         LASSERT(obd != NULL);
156         ofd = ofd_dev(obd->obd_lu_dev);
157         *eof = 1;
158         return snprintf(page, count, "%d\n", ofd->ofd_precreate_batch);
159 }
160
161 static int lprocfs_ofd_wr_precreate_batch(struct file *file,
162                                           const char __user *buffer,
163                                           unsigned long count, void *data)
164 {
165         struct obd_device *obd = (struct obd_device *)data;
166         struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
167         int val;
168         int rc;
169
170         rc = lprocfs_write_helper(buffer, count, &val);
171         if (rc)
172                 return rc;
173
174         if (val < 1)
175                 return -EINVAL;
176
177         spin_lock(&ofd->ofd_batch_lock);
178         ofd->ofd_precreate_batch = val;
179         spin_unlock(&ofd->ofd_batch_lock);
180         return count;
181 }
182
183 static int lprocfs_ofd_rd_last_id(char *page, char **start, off_t off,
184                                   int count, int *eof, void *data)
185 {
186         struct obd_device       *obd = data;
187         struct ofd_device       *ofd;
188         struct ofd_seq          *oseq = NULL;
189         int                     retval = 0, rc;
190
191         if (obd == NULL)
192                 return 0;
193
194         ofd = ofd_dev(obd->obd_lu_dev);
195
196         read_lock(&ofd->ofd_seq_list_lock);
197         cfs_list_for_each_entry(oseq, &ofd->ofd_seq_list, os_list) {
198                 __u64 seq;
199
200                 seq = ostid_seq(&oseq->os_oi) == 0 ?
201                       fid_idif_seq(ostid_id(&oseq->os_oi),
202                                    ofd->ofd_lut.lut_lsd.lsd_osd_index) :
203                       ostid_seq(&oseq->os_oi);
204                 rc = snprintf(page, count, DOSTID"\n", seq,
205                               ostid_id(&oseq->os_oi));
206                 if (rc < 0) {
207                         retval = rc;
208                         break;
209                 }
210                 page += rc;
211                 count -= rc;
212                 retval += rc;
213         }
214         read_unlock(&ofd->ofd_seq_list_lock);
215         return retval;
216 }
217
218 int lprocfs_ofd_rd_fmd_max_num(char *page, char **start, off_t off,
219                                int count, int *eof, void *data)
220 {
221         struct obd_device       *obd = data;
222         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
223         int                      rc;
224
225         rc = snprintf(page, count, "%u\n", ofd->ofd_fmd_max_num);
226         return rc;
227 }
228
229 int lprocfs_ofd_wr_fmd_max_num(struct file *file, const char __user *buffer,
230                                unsigned long count, void *data)
231 {
232         struct obd_device       *obd = data;
233         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
234         int                      val;
235         int                      rc;
236
237         rc = lprocfs_write_helper(buffer, count, &val);
238         if (rc)
239                 return rc;
240
241         if (val > 65536 || val < 1)
242                 return -EINVAL;
243
244         ofd->ofd_fmd_max_num = val;
245         return count;
246 }
247
248 int lprocfs_ofd_rd_fmd_max_age(char *page, char **start, off_t off,
249                                int count, int *eof, void *data)
250 {
251         struct obd_device       *obd = data;
252         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
253         int                      rc;
254
255         rc = snprintf(page, count, "%ld\n", ofd->ofd_fmd_max_age / HZ);
256         return rc;
257 }
258
259 int lprocfs_ofd_wr_fmd_max_age(struct file *file, const char __user *buffer,
260                                unsigned long count, void *data)
261 {
262         struct obd_device       *obd = data;
263         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
264         int                      val;
265         int                      rc;
266
267         rc = lprocfs_write_helper(buffer, count, &val);
268         if (rc)
269                 return rc;
270
271         if (val > 65536 || val < 1)
272                 return -EINVAL;
273
274         ofd->ofd_fmd_max_age = val * HZ;
275         return count;
276 }
277
278 static int lprocfs_ofd_rd_capa(char *page, char **start, off_t off,
279                                int count, int *eof, void *data)
280 {
281         struct obd_device       *obd = data;
282         int                      rc;
283
284         rc = snprintf(page, count, "capability on: %s\n",
285                       obd->u.filter.fo_fl_oss_capa ? "oss" : "");
286         return rc;
287 }
288
289 static int lprocfs_ofd_wr_capa(struct file *file, const char __user *buffer,
290                                unsigned long count, void *data)
291 {
292         struct obd_device       *obd = data;
293         int                      val, rc;
294
295         rc = lprocfs_write_helper(buffer, count, &val);
296         if (rc)
297                 return rc;
298
299         if (val & ~0x1) {
300                 CERROR("invalid capability mode, only 0/1 are accepted.\n"
301                        " 1: enable oss fid capability\n"
302                        " 0: disable oss fid capability\n");
303                 return -EINVAL;
304         }
305
306         obd->u.filter.fo_fl_oss_capa = val;
307         LCONSOLE_INFO("OSS %s %s fid capability.\n", obd->obd_name,
308                       val ? "enabled" : "disabled");
309         return count;
310 }
311
312 static int lprocfs_ofd_rd_capa_count(char *page, char **start, off_t off,
313                                      int count, int *eof, void *data)
314 {
315         return snprintf(page, count, "%d %d\n",
316                         capa_count[CAPA_SITE_CLIENT],
317                         capa_count[CAPA_SITE_SERVER]);
318 }
319
320 int lprocfs_ofd_rd_degraded(char *page, char **start, off_t off,
321                             int count, int *eof, void *data)
322 {
323         struct obd_device *obd = data;
324         struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
325
326         return snprintf(page, count, "%u\n", ofd->ofd_raid_degraded);
327 }
328
329 int lprocfs_ofd_wr_degraded(struct file *file, const char __user *buffer,
330                             unsigned long count, void *data)
331 {
332         struct obd_device       *obd = data;
333         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
334         int                      val, rc;
335
336         rc = lprocfs_write_helper(buffer, count, &val);
337         if (rc)
338                 return rc;
339
340         spin_lock(&ofd->ofd_flags_lock);
341         ofd->ofd_raid_degraded = !!val;
342         spin_unlock(&ofd->ofd_flags_lock);
343
344         return count;
345 }
346
347 int lprocfs_ofd_rd_fstype(char *page, char **start, off_t off, int count,
348                           int *eof, void *data)
349 {
350         struct obd_device *obd = data;
351         struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
352         struct lu_device  *d;
353
354         LASSERT(ofd->ofd_osd);
355         d = &ofd->ofd_osd->dd_lu_dev;
356         LASSERT(d->ld_type);
357         return snprintf(page, count, "%s\n", d->ld_type->ldt_name);
358 }
359
360 int lprocfs_ofd_rd_syncjournal(char *page, char **start, off_t off,
361                                int count, int *eof, void *data)
362 {
363         struct obd_device       *obd = data;
364         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
365         int                      rc;
366
367         rc = snprintf(page, count, "%u\n", ofd->ofd_syncjournal);
368         return rc;
369 }
370
371 int lprocfs_ofd_wr_syncjournal(struct file *file, const char __user *buffer,
372                                unsigned long count, void *data)
373 {
374         struct obd_device       *obd = data;
375         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
376         int                      val;
377         int                      rc;
378
379         rc = lprocfs_write_helper(buffer, count, &val);
380         if (rc)
381                 return rc;
382
383         if (val < 0)
384                 return -EINVAL;
385
386         spin_lock(&ofd->ofd_flags_lock);
387         ofd->ofd_syncjournal = !!val;
388         ofd_slc_set(ofd);
389         spin_unlock(&ofd->ofd_flags_lock);
390
391         return count;
392 }
393
394 /* This must be longer than the longest string below */
395 #define SYNC_STATES_MAXLEN 16
396 static char *sync_on_cancel_states[] = {"never",
397                                         "blocking",
398                                         "always" };
399
400 int lprocfs_ofd_rd_sync_lock_cancel(char *page, char **start, off_t off,
401                                     int count, int *eof, void *data)
402 {
403         struct obd_device       *obd = data;
404         struct lu_target        *tgt = obd->u.obt.obt_lut;
405         int                      rc;
406
407         rc = snprintf(page, count, "%s\n",
408                       sync_on_cancel_states[tgt->lut_sync_lock_cancel]);
409         return rc;
410 }
411
412 int lprocfs_ofd_wr_sync_lock_cancel(struct file *file,
413                                     const char __user *buffer,
414                                     unsigned long count, void *data)
415 {
416         struct obd_device       *obd = data;
417         struct lu_target        *tgt = obd->u.obt.obt_lut;
418         char                     kernbuf[SYNC_STATES_MAXLEN];
419         int                      val = -1;
420         int                      i;
421
422         if (count == 0 || count >= sizeof(kernbuf))
423                 return -EINVAL;
424
425         if (copy_from_user(kernbuf, buffer, count))
426                 return -EFAULT;
427         kernbuf[count] = 0;
428
429         if (kernbuf[count - 1] == '\n')
430                 kernbuf[count - 1] = 0;
431
432         for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) {
433                 if (strcmp(kernbuf, sync_on_cancel_states[i]) == 0) {
434                         val = i;
435                         break;
436                 }
437         }
438
439         /* Legacy numeric codes */
440         if (val == -1) {
441                 int rc;
442
443                 /* Safe to use userspace buffer as lprocfs_write_helper will
444                  * use copy from user for parsing */
445                 rc = lprocfs_write_helper(buffer, count, &val);
446                 if (rc)
447                         return rc;
448         }
449
450         if (val < 0 || val > 2)
451                 return -EINVAL;
452
453         spin_lock(&tgt->lut_flags_lock);
454         tgt->lut_sync_lock_cancel = val;
455         spin_unlock(&tgt->lut_flags_lock);
456         return count;
457 }
458
459 int lprocfs_ofd_rd_grant_compat_disable(char *page, char **start, off_t off,
460                                         int count, int *eof, void *data)
461 {
462         struct obd_device       *obd = data;
463         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
464         int                      rc;
465
466         rc = snprintf(page, count, "%u\n", ofd->ofd_grant_compat_disable);
467         return rc;
468 }
469
470 int lprocfs_ofd_wr_grant_compat_disable(struct file *file,
471                                         const char __user *buffer,
472                                         unsigned long count, void *data)
473 {
474         struct obd_device       *obd = data;
475         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
476         int                      val;
477         int                      rc;
478
479         rc = lprocfs_write_helper(buffer, count, &val);
480         if (rc)
481                 return rc;
482
483         if (val < 0)
484                 return -EINVAL;
485
486         spin_lock(&ofd->ofd_flags_lock);
487         ofd->ofd_grant_compat_disable = !!val;
488         spin_unlock(&ofd->ofd_flags_lock);
489
490         return count;
491 }
492
493 int lprocfs_ofd_rd_soft_sync_limit(char *page, char **start, off_t off,
494                                    int count, int *eof, void *data)
495 {
496         struct obd_device       *obd = data;
497         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
498
499         return lprocfs_rd_uint(page, start, off, count, eof,
500                                &ofd->ofd_soft_sync_limit);
501 }
502
503 int lprocfs_ofd_wr_soft_sync_limit(struct file *file, const char __user *buffer,
504                                    unsigned long count, void *data)
505 {
506         struct obd_device       *obd = data;
507         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
508
509         return lprocfs_wr_uint(file, buffer, count, &ofd->ofd_soft_sync_limit);
510 }
511
512 static int lprocfs_rd_lfsck_speed_limit(char *page, char **start, off_t off,
513                                         int count, int *eof, void *data)
514 {
515         struct obd_device       *obd = data;
516         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
517
518         *eof = 1;
519
520         return lfsck_get_speed(ofd->ofd_osd, page, count);
521 }
522
523 static int lprocfs_wr_lfsck_speed_limit(struct file *file,
524                                         const char __user *buffer,
525                                         unsigned long count, void *data)
526 {
527         struct obd_device       *obd = data;
528         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
529         __u32                    val;
530         int                      rc;
531
532         rc = lprocfs_write_helper(buffer, count, &val);
533         if (rc != 0)
534                 return rc;
535
536         rc = lfsck_set_speed(ofd->ofd_osd, val);
537
538         return rc != 0 ? rc : count;
539 }
540
541 static int lprocfs_rd_lfsck_layout(char *page, char **start, off_t off,
542                                    int count, int *eof, void *data)
543 {
544         struct obd_device       *obd = data;
545         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
546
547         *eof = 1;
548
549         return lfsck_dump(ofd->ofd_osd, page, count, LT_LAYOUT);
550 }
551
552 static int lprocfs_rd_lfsck_verify_pfid(char *page, char **start, off_t off,
553                                         int count, int *eof, void *data)
554 {
555         struct obd_device       *obd = data;
556         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
557
558         *eof = 1;
559
560         return snprintf(page, count,
561                         "switch: %s\ndetected: "LPU64"\nrepaired: "LPU64"\n",
562                         ofd->ofd_lfsck_verify_pfid ? "on" : "off",
563                         ofd->ofd_inconsistency_self_detected,
564                         ofd->ofd_inconsistency_self_repaired);
565 }
566
567 static int lprocfs_wr_lfsck_verify_pfid(struct file *file,
568                                         const char __user *buffer,
569                                         unsigned long count, void *data)
570 {
571         struct obd_device       *obd = data;
572         struct ofd_device       *ofd = ofd_dev(obd->obd_lu_dev);
573         __u32                    val;
574         int                      rc;
575
576         rc = lprocfs_write_helper(buffer, count, &val);
577         if (rc != 0)
578                 return rc;
579
580         ofd->ofd_lfsck_verify_pfid = !!val;
581
582         return count;
583 }
584
585 static struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
586         { "uuid",                lprocfs_rd_uuid, 0, 0 },
587         { "blocksize",           lprocfs_rd_blksize, 0, 0 },
588         { "kbytestotal",         lprocfs_rd_kbytestotal, 0, 0 },
589         { "kbytesfree",          lprocfs_rd_kbytesfree, 0, 0 },
590         { "kbytesavail",         lprocfs_rd_kbytesavail, 0, 0 },
591         { "filestotal",          lprocfs_rd_filestotal, 0, 0 },
592         { "filesfree",           lprocfs_rd_filesfree, 0, 0 },
593         { "seqs_allocated",      lprocfs_ofd_rd_seqs, 0, 0 },
594         { "fstype",              lprocfs_ofd_rd_fstype, 0, 0 },
595         { "last_id",             lprocfs_ofd_rd_last_id, 0, 0 },
596         { "tot_dirty",           lprocfs_ofd_rd_tot_dirty,   0, 0 },
597         { "tot_pending",         lprocfs_ofd_rd_tot_pending, 0, 0 },
598         { "tot_granted",         lprocfs_ofd_rd_tot_granted, 0, 0 },
599         { "grant_precreate",     lprocfs_ofd_rd_grant_precreate, 0, 0 },
600         { "grant_ratio",         lprocfs_ofd_rd_grant_ratio,
601                                  lprocfs_ofd_wr_grant_ratio, 0, 0 },
602         { "precreate_batch",     lprocfs_ofd_rd_precreate_batch,
603                                  lprocfs_ofd_wr_precreate_batch, 0 },
604         { "recovery_status",     lprocfs_obd_rd_recovery_status, 0, 0 },
605         { "recovery_time_soft",  lprocfs_obd_rd_recovery_time_soft,
606                                  lprocfs_obd_wr_recovery_time_soft, 0},
607         { "recovery_time_hard",  lprocfs_obd_rd_recovery_time_hard,
608                                  lprocfs_obd_wr_recovery_time_hard, 0},
609         { "evict_client",        0, lprocfs_wr_evict_client, 0,
610                                  &lprocfs_evict_client_fops},
611         { "num_exports",         lprocfs_rd_num_exports,   0, 0 },
612         { "degraded",            lprocfs_ofd_rd_degraded,
613                                  lprocfs_ofd_wr_degraded, 0},
614         { "sync_journal",        lprocfs_ofd_rd_syncjournal,
615                                  lprocfs_ofd_wr_syncjournal, 0 },
616         { "sync_on_lock_cancel", lprocfs_ofd_rd_sync_lock_cancel,
617                                  lprocfs_ofd_wr_sync_lock_cancel, 0 },
618         { "instance",            lprocfs_target_rd_instance, 0 },
619         { "ir_factor",           lprocfs_obd_rd_ir_factor,
620                                  lprocfs_obd_wr_ir_factor, 0},
621         { "grant_compat_disable", lprocfs_ofd_rd_grant_compat_disable,
622                                   lprocfs_ofd_wr_grant_compat_disable, 0 },
623         { "client_cache_count",  lprocfs_ofd_rd_fmd_max_num,
624                                  lprocfs_ofd_wr_fmd_max_num, 0 },
625         { "client_cache_seconds", lprocfs_ofd_rd_fmd_max_age,
626                                   lprocfs_ofd_wr_fmd_max_age, 0 },
627         { "capa",                lprocfs_ofd_rd_capa,
628                                  lprocfs_ofd_wr_capa, 0 },
629         { "capa_count",          lprocfs_ofd_rd_capa_count, 0, 0 },
630         { "job_cleanup_interval", lprocfs_rd_job_interval,
631                                   lprocfs_wr_job_interval, 0},
632         { "soft_sync_limit",     lprocfs_ofd_rd_soft_sync_limit,
633                                  lprocfs_ofd_wr_soft_sync_limit, 0},
634         { "lfsck_speed_limit",  lprocfs_rd_lfsck_speed_limit,
635                                 lprocfs_wr_lfsck_speed_limit, 0 },
636         { "lfsck_layout",       lprocfs_rd_lfsck_layout, 0, 0 },
637         { "lfsck_verify_pfid",  lprocfs_rd_lfsck_verify_pfid,
638                                 lprocfs_wr_lfsck_verify_pfid, 0 },
639         { 0 }
640 };
641
642 static struct lprocfs_vars lprocfs_ofd_module_vars[] = {
643         { "num_refs",     lprocfs_rd_numrefs,   0, 0 },
644         { 0 }
645 };
646
647 void lprocfs_ofd_init_vars(struct lprocfs_static_vars *lvars)
648 {
649         lvars->module_vars  = lprocfs_ofd_module_vars;
650         lvars->obd_vars     = lprocfs_ofd_obd_vars;
651 }
652
653 void ofd_stats_counter_init(struct lprocfs_stats *stats)
654 {
655         LASSERT(stats && stats->ls_num >= LPROC_OFD_STATS_LAST);
656
657         lprocfs_counter_init(stats, LPROC_OFD_STATS_READ,
658                              LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
659         lprocfs_counter_init(stats, LPROC_OFD_STATS_WRITE,
660                              LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
661         lprocfs_counter_init(stats, LPROC_OFD_STATS_GETATTR,
662                              0, "getattr", "reqs");
663         lprocfs_counter_init(stats, LPROC_OFD_STATS_SETATTR,
664                              0, "setattr", "reqs");
665         lprocfs_counter_init(stats, LPROC_OFD_STATS_PUNCH,
666                              0, "punch", "reqs");
667         lprocfs_counter_init(stats, LPROC_OFD_STATS_SYNC,
668                              0, "sync", "reqs");
669         lprocfs_counter_init(stats, LPROC_OFD_STATS_DESTROY,
670                              0, "destroy", "reqs");
671         lprocfs_counter_init(stats, LPROC_OFD_STATS_CREATE,
672                              0, "create", "reqs");
673         lprocfs_counter_init(stats, LPROC_OFD_STATS_STATFS,
674                              0, "statfs", "reqs");
675         lprocfs_counter_init(stats, LPROC_OFD_STATS_GET_INFO,
676                              0, "get_info", "reqs");
677         lprocfs_counter_init(stats, LPROC_OFD_STATS_SET_INFO,
678                              0, "set_info", "reqs");
679         lprocfs_counter_init(stats, LPROC_OFD_STATS_QUOTACTL,
680                              0, "quotactl", "reqs");
681 }
682
683 #endif /* LPROCFS */