Whamcloud - gitweb
LU-1146 build: batch update copyright messages
[fs/lustre-release.git] / lustre / obdfilter / lproc_obdfilter.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  *
32  * Copyright (c) 2011, Whamcloud, Inc.
33  */
34 /*
35  * This file is part of Lustre, http://www.lustre.org/
36  * Lustre is a trademark of Sun Microsystems, Inc.
37  */
38 #define DEBUG_SUBSYSTEM S_CLASS
39
40 #include <linux/version.h>
41 #include <lprocfs_status.h>
42 #include <obd.h>
43 #include <linux/seq_file.h>
44 #include <linux/version.h>
45
46 #include "filter_internal.h"
47
48 #ifdef LPROCFS
49 static int lprocfs_filter_rd_groups(char *page, char **start, off_t off,
50                                     int count, int *eof, void *data)
51 {
52         struct obd_device *obd = (struct obd_device *)data;
53         *eof = 1;
54         return snprintf(page, count, "%u\n", obd->u.filter.fo_group_count);
55 }
56
57 static int lprocfs_filter_rd_tot_dirty(char *page, char **start, off_t off,
58                                        int count, int *eof, void *data)
59 {
60         struct obd_device *obd = (struct obd_device *)data;
61
62         LASSERT(obd != NULL);
63         *eof = 1;
64         return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_dirty);
65 }
66
67 static int lprocfs_filter_rd_tot_granted(char *page, char **start, off_t off,
68                                          int count, int *eof, void *data)
69 {
70         struct obd_device *obd = (struct obd_device *)data;
71
72         LASSERT(obd != NULL);
73         *eof = 1;
74         return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_granted);
75 }
76
77 static int lprocfs_filter_rd_tot_pending(char *page, char **start, off_t off,
78                                          int count, int *eof, void *data)
79 {
80         struct obd_device *obd = (struct obd_device *)data;
81
82         LASSERT(obd != NULL);
83         *eof = 1;
84         return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_pending);
85 }
86
87 static int lprocfs_filter_rd_last_id(char *page, char **start, off_t off,
88                                      int count, int *eof, void *data)
89 {
90         struct obd_device *obd = data;
91         struct filter_obd *filter = &obd->u.filter;
92         int retval = 0, rc, i;
93
94         if (obd == NULL || !obd->obd_set_up || obd->obd_stopping)
95                 return 0;
96         rc = snprintf(page, count, LPU64"\n",filter_last_id(filter, 0));
97         if (rc < 0)
98                 return rc;
99         page += rc;
100         count -= rc;
101         retval += rc;
102
103         for (i = FID_SEQ_OST_MDT1; i < filter->fo_group_count; i++) {
104                 rc = snprintf(page, count, LPU64"\n",filter_last_id(filter, i));
105                 if (rc < 0) {
106                         retval = rc;
107                         break;
108                 }
109                 page += rc;
110                 count -= rc;
111                 retval += rc;
112         }
113         return retval;
114 }
115
116 int lprocfs_filter_rd_readcache(char *page, char **start, off_t off, int count,
117                                 int *eof, void *data)
118 {
119         struct obd_device *obd = data;
120         int rc;
121
122         rc = snprintf(page, count, LPU64"\n",
123                       obd->u.filter.fo_readcache_max_filesize);
124         return rc;
125 }
126
127 int lprocfs_filter_wr_readcache(struct file *file, const char *buffer,
128                                 unsigned long count, void *data)
129 {
130         struct obd_device *obd = data;
131         __u64 val;
132         int rc;
133
134         rc = lprocfs_write_u64_helper(buffer, count, &val);
135         if (rc)
136                 return rc;
137
138         obd->u.filter.fo_readcache_max_filesize = val;
139         return count;
140 }
141
142 int lprocfs_filter_rd_fmd_max_num(char *page, char **start, off_t off,
143                                   int count, int *eof, void *data)
144 {
145         struct obd_device *obd = data;
146         int rc;
147
148         rc = snprintf(page, count, "%u\n", obd->u.filter.fo_fmd_max_num);
149         return rc;
150 }
151
152 int lprocfs_filter_wr_fmd_max_num(struct file *file, const char *buffer,
153                                   unsigned long count, void *data)
154 {
155         struct obd_device *obd = data;
156         int val;
157         int rc;
158
159         rc = lprocfs_write_helper(buffer, count, &val);
160         if (rc)
161                 return rc;
162
163         if (val > 65536 || val < 1)
164                 return -EINVAL;
165
166         obd->u.filter.fo_fmd_max_num = val;
167         return count;
168 }
169
170 int lprocfs_filter_rd_fmd_max_age(char *page, char **start, off_t off,
171                                   int count, int *eof, void *data)
172 {
173         struct obd_device *obd = data;
174         int rc;
175
176         rc = snprintf(page, count, "%u\n",
177                       obd->u.filter.fo_fmd_max_age / CFS_HZ);
178         return rc;
179 }
180
181 int lprocfs_filter_wr_fmd_max_age(struct file *file, const char *buffer,
182                                   unsigned long count, void *data)
183 {
184         struct obd_device *obd = data;
185         int val;
186         int rc;
187
188         rc = lprocfs_write_helper(buffer, count, &val);
189         if (rc)
190                 return rc;
191
192         if (val > 65536 || val < 1)
193                 return -EINVAL;
194
195         obd->u.filter.fo_fmd_max_age = val * CFS_HZ;
196         return count;
197 }
198
199 static int lprocfs_filter_rd_capa(char *page, char **start, off_t off,
200                                   int count, int *eof, void *data)
201 {
202         struct obd_device *obd = data;
203         int rc;
204
205         rc = snprintf(page, count, "capability on: %s\n",
206                       obd->u.filter.fo_fl_oss_capa ? "oss" : "");
207         return rc;
208 }
209
210 static int lprocfs_filter_wr_capa(struct file *file, const char *buffer,
211                                   unsigned long count, void *data)
212 {
213         struct obd_device *obd = data;
214         int val, rc;
215
216         rc = lprocfs_write_helper(buffer, count, &val);
217         if (rc)
218                 return rc;
219
220         if (val & ~0x1) {
221                 CERROR("invalid capability mode, only 0/1 are accepted.\n"
222                        " 1: enable oss fid capability\n"
223                        " 0: disable oss fid capability\n");
224                 return -EINVAL;
225         }
226
227         obd->u.filter.fo_fl_oss_capa = val;
228         LCONSOLE_INFO("OSS %s %s fid capability.\n", obd->obd_name,
229                       val ? "enabled" : "disabled");
230         return count;
231 }
232
233 static int lprocfs_filter_rd_capa_count(char *page, char **start, off_t off,
234                                         int count, int *eof, void *data)
235 {
236         return snprintf(page, count, "%d %d\n",
237                         capa_count[CAPA_SITE_CLIENT],
238                         capa_count[CAPA_SITE_SERVER]);
239 }
240
241 static int lprocfs_rd_sec_level(char *page, char **start, off_t off,
242                                 int count, int *eof, void *data)
243 {
244         struct obd_device *obd = data;
245
246         return snprintf(page, count, "%d\n", obd->u.filter.fo_sec_level);
247 }
248
249 static int lprocfs_wr_sec_level(struct file *file, const char *buffer,
250                                 unsigned long count, void *data)
251 {
252         struct obd_device *obd = data;
253         int val, rc;
254
255         rc = lprocfs_write_helper(buffer, count, &val);
256         if (rc)
257                 return rc;
258
259         if (val > LUSTRE_SEC_ALL || val < LUSTRE_SEC_NONE)
260                 return -EINVAL;
261
262         if (val == LUSTRE_SEC_SPECIFY) {
263                 CWARN("security level %d will be supported in future.\n",
264                       LUSTRE_SEC_SPECIFY);
265                 return -EINVAL;
266         }
267
268         obd->u.filter.fo_sec_level = val;
269         return count;
270 }
271
272 static int lprocfs_filter_rd_cache(char *page, char **start, off_t off,
273                                    int count, int *eof, void *data)
274 {
275         struct obd_device *obd = (struct obd_device *)data;
276         LASSERT(obd != NULL);
277
278         return snprintf(page, count, "%u\n", obd->u.filter.fo_read_cache);
279 }
280
281 static int lprocfs_filter_wr_cache(struct file *file, const char *buffer,
282                      unsigned long count, void *data)
283 {
284         struct obd_device *obd = (struct obd_device *)data;
285         int val, rc;
286         LASSERT(obd != NULL);
287
288         rc = lprocfs_write_helper(buffer, count, &val);
289
290         if (rc)
291                 return rc;
292
293         cfs_spin_lock_bh(&obd->u.filter.fo_flags_lock);
294         obd->u.filter.fo_read_cache = !!val;
295         cfs_spin_unlock_bh(&obd->u.filter.fo_flags_lock);
296         return count;
297 }
298
299 static int lprocfs_filter_rd_wcache(char *page, char **start, off_t off,
300                                    int count, int *eof, void *data)
301 {
302         struct obd_device *obd = (struct obd_device *)data;
303         LASSERT(obd != NULL);
304
305         return snprintf(page, count, "%u\n", obd->u.filter.fo_writethrough_cache);
306 }
307
308 static int lprocfs_filter_wr_wcache(struct file *file, const char *buffer,
309                      unsigned long count, void *data)
310 {
311         struct obd_device *obd = (struct obd_device *)data;
312         int val, rc;
313         LASSERT(obd != NULL);
314
315         rc = lprocfs_write_helper(buffer, count, &val);
316
317         if (rc)
318                 return rc;
319
320         cfs_spin_lock(&obd->u.filter.fo_flags_lock);
321         obd->u.filter.fo_writethrough_cache = !!val;
322         cfs_spin_unlock(&obd->u.filter.fo_flags_lock);
323         return count;
324 }
325
326 static int lprocfs_filter_rd_mds_sync(char *page, char **start, off_t off,
327                                       int count, int *eof, void *data)
328 {
329         struct obd_device *obd = (struct obd_device *)data;
330         LASSERT(obd != NULL);
331
332         return snprintf(page, count, "%u\n", obd->u.filter.fo_mds_ost_sync);
333 }
334
335 int lprocfs_filter_rd_degraded(char *page, char **start, off_t off,
336                                int count, int *eof, void *data)
337 {
338         struct obd_device *obd = data;
339
340         return snprintf(page, count, "%u\n", obd->u.filter.fo_raid_degraded);
341 }
342
343 int lprocfs_filter_wr_degraded(struct file *file, const char *buffer,
344                                unsigned long count, void *data)
345 {
346         struct obd_device *obd = data;
347         int val, rc;
348
349         rc = lprocfs_write_helper(buffer, count, &val);
350         if (rc)
351                 return rc;
352
353         cfs_spin_lock(&obd->u.filter.fo_flags_lock);
354         obd->u.filter.fo_raid_degraded = !!val;
355         cfs_spin_unlock(&obd->u.filter.fo_flags_lock);
356         return count;
357 }
358
359 int lprocfs_filter_rd_syncjournal(char *page, char **start, off_t off,
360                                   int count, int *eof, void *data)
361 {
362         struct obd_device *obd = data;
363         int rc;
364
365         rc = snprintf(page, count, "%u\n", obd->u.filter.fo_syncjournal);
366         return rc;
367 }
368
369 int lprocfs_filter_wr_syncjournal(struct file *file, const char *buffer,
370                                   unsigned long count, void *data)
371 {
372         struct obd_device *obd = data;
373         int val;
374         int rc;
375
376         rc = lprocfs_write_helper(buffer, count, &val);
377         if (rc)
378                 return rc;
379
380         if (val < 0)
381                 return -EINVAL;
382
383         obd->u.filter.fo_syncjournal = !!val;
384         filter_slc_set(&obd->u.filter);
385
386         return count;
387 }
388
389 static char *sync_on_cancel_states[] = {"never",
390                                         "blocking",
391                                         "always" };
392
393 int lprocfs_filter_rd_sync_lock_cancel(char *page, char **start, off_t off,
394                                        int count, int *eof, void *data)
395 {
396         struct obd_device *obd = data;
397         int rc;
398
399         rc = snprintf(page, count, "%s\n",
400                       sync_on_cancel_states[obd->u.filter.fo_sync_lock_cancel]);
401         return rc;
402 }
403
404 int lprocfs_filter_wr_sync_lock_cancel(struct file *file, const char *buffer,
405                                           unsigned long count, void *data)
406 {
407         struct obd_device *obd = data;
408         int val = -1;
409         int i;
410
411         for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) {
412                 if (memcmp(buffer, sync_on_cancel_states[i],
413                     strlen(sync_on_cancel_states[i])) == 0) {
414                         val = i;
415                         break;
416                 }
417         }
418         if (val == -1) {
419                 int rc;
420                 rc = lprocfs_write_helper(buffer, count, &val);
421                 if (rc)
422                         return rc;
423         }
424
425         if (val < 0 || val > 2)
426                 return -EINVAL;
427
428         obd->u.filter.fo_sync_lock_cancel = val;
429         return count;
430 }
431
432 static struct lprocfs_vars lprocfs_filter_obd_vars[] = {
433         { "uuid",         lprocfs_rd_uuid,          0, 0 },
434         { "blocksize",    lprocfs_rd_blksize,       0, 0 },
435         { "kbytestotal",  lprocfs_rd_kbytestotal,   0, 0 },
436         { "kbytesfree",   lprocfs_rd_kbytesfree,    0, 0 },
437         { "kbytesavail",  lprocfs_rd_kbytesavail,   0, 0 },
438         { "filestotal",   lprocfs_rd_filestotal,    0, 0 },
439         { "filesfree",    lprocfs_rd_filesfree,     0, 0 },
440         { "filegroups",   lprocfs_filter_rd_groups, 0, 0 },
441         { "fstype",       lprocfs_rd_fstype,        0, 0 },
442         { "mntdev",       lprocfs_obd_rd_mntdev,    0, 0 },
443         { "last_id",      lprocfs_filter_rd_last_id,0, 0 },
444         { "tot_dirty",    lprocfs_filter_rd_tot_dirty,   0, 0 },
445         { "tot_pending",  lprocfs_filter_rd_tot_pending, 0, 0 },
446         { "tot_granted",  lprocfs_filter_rd_tot_granted, 0, 0 },
447         { "hash_stats",   lprocfs_obd_rd_hash,      0, 0 },
448         { "recovery_status",    lprocfs_obd_rd_recovery_status, 0, 0 },
449         { "recovery_time_soft", lprocfs_obd_rd_recovery_time_soft,
450                                 lprocfs_obd_wr_recovery_time_soft, 0},
451         { "recovery_time_hard", lprocfs_obd_rd_recovery_time_hard,
452                                 lprocfs_obd_wr_recovery_time_hard, 0},
453         { "evict_client", 0, lprocfs_wr_evict_client, 0,
454                                 &lprocfs_evict_client_fops},
455         { "num_exports",  lprocfs_rd_num_exports,   0, 0 },
456         { "readcache_max_filesize",
457                           lprocfs_filter_rd_readcache,
458                           lprocfs_filter_wr_readcache, 0 },
459 #ifdef HAVE_QUOTA_SUPPORT
460         { "quota_type",     lprocfs_quota_rd_type,
461                             lprocfs_quota_wr_type, 0},
462 #endif
463         { "client_cache_count", lprocfs_filter_rd_fmd_max_num,
464                           lprocfs_filter_wr_fmd_max_num, 0 },
465         { "client_cache_seconds", lprocfs_filter_rd_fmd_max_age,
466                           lprocfs_filter_wr_fmd_max_age, 0 },
467         { "capa",         lprocfs_filter_rd_capa,
468                           lprocfs_filter_wr_capa, 0 },
469         { "capa_count",   lprocfs_filter_rd_capa_count, 0, 0 },
470         { "sec_level",    lprocfs_rd_sec_level,
471                           lprocfs_wr_sec_level,            0 },
472         { "read_cache_enable", lprocfs_filter_rd_cache, lprocfs_filter_wr_cache, 0},
473         { "writethrough_cache_enable", lprocfs_filter_rd_wcache,
474                           lprocfs_filter_wr_wcache, 0},
475         { "mds_sync",     lprocfs_filter_rd_mds_sync, 0, 0},
476         { "degraded",     lprocfs_filter_rd_degraded,
477                           lprocfs_filter_wr_degraded, 0 },
478         { "sync_journal", lprocfs_filter_rd_syncjournal,
479                           lprocfs_filter_wr_syncjournal, 0 },
480         { "sync_on_lock_cancel", lprocfs_filter_rd_sync_lock_cancel,
481                                  lprocfs_filter_wr_sync_lock_cancel, 0 },
482         { "instance",     lprocfs_target_rd_instance, 0 },
483         { "ir_factor",    lprocfs_obd_rd_ir_factor,
484                           lprocfs_obd_wr_ir_factor, 0},
485         { 0 }
486 };
487
488 static struct lprocfs_vars lprocfs_filter_module_vars[] = {
489         { "num_refs",     lprocfs_rd_numrefs,       0, 0 },
490         { 0 }
491 };
492
493 void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages,
494                   unsigned long *blocks, int blocks_per_page, int wr)
495 {
496         struct filter_obd *filter = &exp->exp_obd->u.filter;
497         struct page *last_page = NULL;
498         unsigned long *last_block = NULL;
499         unsigned long discont_pages = 0;
500         unsigned long discont_blocks = 0;
501         int i;
502
503         if (nr_pages == 0)
504                 return;
505
506         lprocfs_oh_tally_log2(&filter->fo_filter_stats.hist[BRW_R_PAGES + wr],
507                               nr_pages);
508         if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats)
509                 lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats->
510                                         hist[BRW_R_PAGES + wr], nr_pages);
511
512         while (nr_pages-- > 0) {
513                 if (last_page && (*pages)->index != (last_page->index + 1))
514                         discont_pages++;
515                 last_page = *pages;
516                 pages++;
517                 for (i = 0; i < blocks_per_page; i++) {
518                         if (last_block && *blocks != (*last_block + 1))
519                                 discont_blocks++;
520                         last_block = blocks++;
521                 }
522         }
523
524         lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_R_DISCONT_PAGES +wr],
525                          discont_pages);
526         lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_R_DISCONT_BLOCKS+wr],
527                          discont_blocks);
528
529         if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats) {
530                 lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats->
531                                         hist[BRW_R_DISCONT_PAGES + wr],
532                                       discont_pages);
533                 lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats->
534                                         hist[BRW_R_DISCONT_BLOCKS + wr],
535                                       discont_blocks);
536         }
537 }
538
539 #define pct(a,b) (b ? a * 100 / b : 0)
540
541 static void display_brw_stats(struct seq_file *seq, char *name, char *units,
542         struct obd_histogram *read, struct obd_histogram *write, int log2)
543 {
544         unsigned long read_tot, write_tot, r, w, read_cum = 0, write_cum = 0;
545         int i;
546
547         seq_printf(seq, "\n%26s read      |     write\n", " ");
548         seq_printf(seq, "%-22s %-5s %% cum %% |  %-5s %% cum %%\n",
549                    name, units, units);
550
551         read_tot = lprocfs_oh_sum(read);
552         write_tot = lprocfs_oh_sum(write);
553         for (i = 0; i < OBD_HIST_MAX; i++) {
554                 r = read->oh_buckets[i];
555                 w = write->oh_buckets[i];
556                 read_cum += r;
557                 write_cum += w;
558                 if (read_cum == 0 && write_cum == 0)
559                         continue;
560
561                 if (!log2)
562                         seq_printf(seq, "%u", i);
563                 else if (i < 10)
564                         seq_printf(seq, "%u", 1<<i);
565                 else if (i < 20)
566                         seq_printf(seq, "%uK", 1<<(i-10));
567                 else
568                         seq_printf(seq, "%uM", 1<<(i-20));
569
570                 seq_printf(seq, ":\t\t%10lu %3lu %3lu   | %4lu %3lu %3lu\n",
571                            r, pct(r, read_tot), pct(read_cum, read_tot),
572                            w, pct(w, write_tot), pct(write_cum, write_tot));
573
574                 if (read_cum == read_tot && write_cum == write_tot)
575                         break;
576         }
577 }
578
579 static void brw_stats_show(struct seq_file *seq, struct brw_stats *brw_stats)
580 {
581         struct timeval now;
582
583         /* this sampling races with updates */
584         cfs_gettimeofday(&now);
585         seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n",
586                    now.tv_sec, now.tv_usec);
587
588         display_brw_stats(seq, "pages per bulk r/w", "rpcs",
589                           &brw_stats->hist[BRW_R_PAGES],
590                           &brw_stats->hist[BRW_W_PAGES], 1);
591
592         display_brw_stats(seq, "discontiguous pages", "rpcs",
593                           &brw_stats->hist[BRW_R_DISCONT_PAGES],
594                           &brw_stats->hist[BRW_W_DISCONT_PAGES], 0);
595
596         display_brw_stats(seq, "discontiguous blocks", "rpcs",
597                           &brw_stats->hist[BRW_R_DISCONT_BLOCKS],
598                           &brw_stats->hist[BRW_W_DISCONT_BLOCKS], 0);
599
600         display_brw_stats(seq, "disk fragmented I/Os", "ios",
601                           &brw_stats->hist[BRW_R_DIO_FRAGS],
602                           &brw_stats->hist[BRW_W_DIO_FRAGS], 0);
603
604         display_brw_stats(seq, "disk I/Os in flight", "ios",
605                           &brw_stats->hist[BRW_R_RPC_HIST],
606                           &brw_stats->hist[BRW_W_RPC_HIST], 0);
607
608         {
609                 char title[24];
610                 sprintf(title, "I/O time (1/%ds)", CFS_HZ);
611                 display_brw_stats(seq, title, "ios",
612                                   &brw_stats->hist[BRW_R_IO_TIME],
613                                   &brw_stats->hist[BRW_W_IO_TIME], 1);
614         }
615
616         display_brw_stats(seq, "disk I/O size", "ios",
617                           &brw_stats->hist[BRW_R_DISK_IOSIZE],
618                           &brw_stats->hist[BRW_W_DISK_IOSIZE], 1);
619 }
620
621 #undef pct
622
623 static int filter_brw_stats_seq_show(struct seq_file *seq, void *v)
624 {
625         struct obd_device *dev = seq->private;
626         struct filter_obd *filter = &dev->u.filter;
627
628         brw_stats_show(seq, &filter->fo_filter_stats);
629
630         return 0;
631 }
632
633 static ssize_t filter_brw_stats_seq_write(struct file *file, const char *buf,
634                                        size_t len, loff_t *off)
635 {
636         struct seq_file *seq = file->private_data;
637         struct obd_device *dev = seq->private;
638         struct filter_obd *filter = &dev->u.filter;
639         int i;
640
641         for (i = 0; i < BRW_LAST; i++)
642                 lprocfs_oh_clear(&filter->fo_filter_stats.hist[i]);
643
644         return len;
645 }
646
647 LPROC_SEQ_FOPS(filter_brw_stats);
648
649 int lproc_filter_attach_seqstat(struct obd_device *dev)
650 {
651         return lprocfs_obd_seq_create(dev, "brw_stats", 0444,
652                                       &filter_brw_stats_fops, dev);
653 }
654
655 void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars)
656 {
657     lvars->module_vars  = lprocfs_filter_module_vars;
658     lvars->obd_vars     = lprocfs_filter_obd_vars;
659 }
660
661 static int filter_per_nid_stats_seq_show(struct seq_file *seq, void *v)
662 {
663         nid_stat_t * stat = seq->private;
664
665         if (stat->nid_brw_stats)
666                 brw_stats_show(seq, stat->nid_brw_stats);
667
668         return 0;
669 }
670
671 static ssize_t filter_per_nid_stats_seq_write(struct file *file,
672                                               const char *buf, size_t len,
673                                               loff_t *off)
674 {
675         struct seq_file *seq  = file->private_data;
676         nid_stat_t      *stat = seq->private;
677         int i;
678
679         if (stat->nid_brw_stats)
680                 for (i = 0; i < BRW_LAST; i++)
681                         lprocfs_oh_clear(&stat->nid_brw_stats->hist[i]);
682
683         return len;
684 }
685
686 LPROC_SEQ_FOPS(filter_per_nid_stats);
687 #endif /* LPROCFS */