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.sun.com/software/products/lustre/docs/GPLv2.pdf
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
27 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2014, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 #define DEBUG_SUBSYSTEM S_CLASS
38 #include <linux/version.h>
39 #include <asm/statfs.h>
40 #include <obd_cksum.h>
41 #include <obd_class.h>
42 #include <lprocfs_status.h>
43 #include <linux/seq_file.h>
44 #include "osc_internal.h"
47 static int osc_active_seq_show(struct seq_file *m, void *v)
49 struct obd_device *dev = m->private;
52 LPROCFS_CLIMP_CHECK(dev);
53 rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
54 LPROCFS_CLIMP_EXIT(dev);
58 static ssize_t osc_active_seq_write(struct file *file,
59 const char __user *buffer,
60 size_t count, loff_t *off)
62 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
65 rc = lprocfs_write_helper(buffer, count, &val);
68 if (val < 0 || val > 1)
72 if (dev->u.cli.cl_import->imp_deactive == val)
73 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
75 CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val);
79 LPROC_SEQ_FOPS(osc_active);
81 static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
83 struct obd_device *dev = m->private;
84 struct client_obd *cli = &dev->u.cli;
87 spin_lock(&cli->cl_loi_list_lock);
88 rc = seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
89 spin_unlock(&cli->cl_loi_list_lock);
93 static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
94 const char __user *buffer,
95 size_t count, loff_t *off)
97 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
98 struct client_obd *cli = &dev->u.cli;
99 struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool;
102 rc = lprocfs_write_helper(buffer, count, &val);
106 if (val < 1 || val > OSC_MAX_RIF_MAX)
109 LPROCFS_CLIMP_CHECK(dev);
110 if (pool && val > cli->cl_max_rpcs_in_flight)
111 pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight);
113 spin_lock(&cli->cl_loi_list_lock);
114 cli->cl_max_rpcs_in_flight = val;
115 client_adjust_max_dirty(cli);
116 spin_unlock(&cli->cl_loi_list_lock);
118 LPROCFS_CLIMP_EXIT(dev);
121 LPROC_SEQ_FOPS(osc_max_rpcs_in_flight);
123 static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
125 struct obd_device *dev = m->private;
126 struct client_obd *cli = &dev->u.cli;
130 spin_lock(&cli->cl_loi_list_lock);
131 val = cli->cl_dirty_max_pages;
132 spin_unlock(&cli->cl_loi_list_lock);
134 mult = 1 << (20 - PAGE_CACHE_SHIFT);
135 return lprocfs_seq_read_frac_helper(m, val, mult);
138 static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
139 const char __user *buffer,
140 size_t count, loff_t *off)
142 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
143 struct client_obd *cli = &dev->u.cli;
144 int pages_number, mult, rc;
146 mult = 1 << (20 - PAGE_CACHE_SHIFT);
147 rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
151 if (pages_number <= 0 ||
152 pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) ||
153 pages_number > totalram_pages / 4) /* 1/4 of RAM */
156 spin_lock(&cli->cl_loi_list_lock);
157 cli->cl_dirty_max_pages = pages_number;
158 osc_wake_cache_waiters(cli);
159 spin_unlock(&cli->cl_loi_list_lock);
163 LPROC_SEQ_FOPS(osc_max_dirty_mb);
165 static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
167 struct obd_device *dev = m->private;
168 struct client_obd *cli = &dev->u.cli;
169 int shift = 20 - PAGE_CACHE_SHIFT;
175 (atomic_long_read(&cli->cl_lru_in_list) +
176 atomic_long_read(&cli->cl_lru_busy)) >> shift,
177 atomic_long_read(&cli->cl_lru_busy));
182 /* shrink the number of caching pages to a specific number */
184 osc_cached_mb_seq_write(struct file *file, const char __user *buffer,
185 size_t count, loff_t *off)
187 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
188 struct client_obd *cli = &dev->u.cli;
195 if (count >= sizeof(kernbuf))
198 if (copy_from_user(kernbuf, buffer, count))
202 mult = 1 << (20 - PAGE_CACHE_SHIFT);
203 buffer += lprocfs_find_named_value(kernbuf, "used_mb:", &count) -
205 rc = lprocfs_write_frac_u64_helper(buffer, count, &val, mult);
212 pages_number = (long)val;
214 if (pages_number < 0)
217 rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
222 env = cl_env_get(&refcheck);
224 (void)osc_lru_shrink(env, cli, rc, true);
225 cl_env_put(env, &refcheck);
231 LPROC_SEQ_FOPS(osc_cached_mb);
233 static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v)
235 struct obd_device *dev = m->private;
236 struct client_obd *cli = &dev->u.cli;
239 spin_lock(&cli->cl_loi_list_lock);
240 rc = seq_printf(m, "%lu\n", cli->cl_dirty_pages << PAGE_CACHE_SHIFT);
241 spin_unlock(&cli->cl_loi_list_lock);
244 LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes);
246 static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
248 struct obd_device *dev = m->private;
249 struct client_obd *cli = &dev->u.cli;
252 spin_lock(&cli->cl_loi_list_lock);
253 rc = seq_printf(m, "%lu\n", cli->cl_avail_grant);
254 spin_unlock(&cli->cl_loi_list_lock);
258 static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
259 const char __user *buffer,
260 size_t count, loff_t *off)
262 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
263 struct client_obd *cli = &obd->u.cli;
270 rc = lprocfs_write_u64_helper(buffer, count, &val);
274 /* this is only for shrinking grant */
275 spin_lock(&cli->cl_loi_list_lock);
276 if (val >= cli->cl_avail_grant) {
277 spin_unlock(&cli->cl_loi_list_lock);
281 spin_unlock(&cli->cl_loi_list_lock);
283 LPROCFS_CLIMP_CHECK(obd);
284 if (cli->cl_import->imp_state == LUSTRE_IMP_FULL)
285 rc = osc_shrink_grant_to_target(cli, val);
286 LPROCFS_CLIMP_EXIT(obd);
291 LPROC_SEQ_FOPS(osc_cur_grant_bytes);
293 static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v)
295 struct obd_device *dev = m->private;
296 struct client_obd *cli = &dev->u.cli;
299 spin_lock(&cli->cl_loi_list_lock);
300 rc = seq_printf(m, "%lu\n", cli->cl_lost_grant);
301 spin_unlock(&cli->cl_loi_list_lock);
304 LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes);
306 static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
308 struct obd_device *obd = m->private;
312 return seq_printf(m, "%d\n",
313 obd->u.cli.cl_grant_shrink_interval);
316 static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
317 const char __user *buffer,
318 size_t count, loff_t *off)
320 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
326 rc = lprocfs_write_helper(buffer, count, &val);
333 obd->u.cli.cl_grant_shrink_interval = val;
337 LPROC_SEQ_FOPS(osc_grant_shrink_interval);
339 static int osc_checksum_seq_show(struct seq_file *m, void *v)
341 struct obd_device *obd = m->private;
346 return seq_printf(m, "%d\n",
347 obd->u.cli.cl_checksum ? 1 : 0);
350 static ssize_t osc_checksum_seq_write(struct file *file,
351 const char __user *buffer,
352 size_t count, loff_t *off)
354 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
360 rc = lprocfs_write_helper(buffer, count, &val);
364 obd->u.cli.cl_checksum = (val ? 1 : 0);
368 LPROC_SEQ_FOPS(osc_checksum);
370 static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
372 struct obd_device *obd = m->private;
379 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
380 if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
382 if (obd->u.cli.cl_cksum_type == (1 << i))
383 seq_printf(m, "[%s] ", cksum_name[i]);
385 seq_printf(m, "%s ", cksum_name[i]);
391 static ssize_t osc_checksum_type_seq_write(struct file *file,
392 const char __user *buffer,
393 size_t count, loff_t *off)
395 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
403 if (count > sizeof(kernbuf) - 1)
405 if (copy_from_user(kernbuf, buffer, count))
407 if (count > 0 && kernbuf[count - 1] == '\n')
408 kernbuf[count - 1] = '\0';
410 kernbuf[count] = '\0';
412 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
413 if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
415 if (!strcmp(kernbuf, cksum_name[i])) {
416 obd->u.cli.cl_cksum_type = 1 << i;
422 LPROC_SEQ_FOPS(osc_checksum_type);
424 static int osc_resend_count_seq_show(struct seq_file *m, void *v)
426 struct obd_device *obd = m->private;
428 return seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
431 static ssize_t osc_resend_count_seq_write(struct file *file,
432 const char __user *buffer,
433 size_t count, loff_t *off)
435 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
438 rc = lprocfs_write_helper(buffer, count, &val);
445 atomic_set(&obd->u.cli.cl_resends, val);
449 LPROC_SEQ_FOPS(osc_resend_count);
451 static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
453 struct obd_device *obd = m->private;
454 struct osc_device *od = obd2osc_dev(obd);
456 return seq_printf(m, "%u\n", od->od_contention_time);
459 static ssize_t osc_contention_seconds_seq_write(struct file *file,
460 const char __user *buffer,
461 size_t count, loff_t *off)
463 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
464 struct osc_device *od = obd2osc_dev(obd);
466 return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?: count;
468 LPROC_SEQ_FOPS(osc_contention_seconds);
470 static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
472 struct obd_device *obd = m->private;
473 struct osc_device *od = obd2osc_dev(obd);
475 return seq_printf(m, "%u\n", od->od_lockless_truncate);
478 static ssize_t osc_lockless_truncate_seq_write(struct file *file,
479 const char __user *buffer,
480 size_t count, loff_t *off)
482 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
483 struct osc_device *od = obd2osc_dev(obd);
485 return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?:
488 LPROC_SEQ_FOPS(osc_lockless_truncate);
490 static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v)
492 struct obd_device *obd = m->private;
493 return seq_printf(m, "%u\n",
494 atomic_read(&obd->u.cli.cl_destroy_in_flight));
496 LPROC_SEQ_FOPS_RO(osc_destroys_in_flight);
498 static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
500 return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
503 static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
504 const char __user *buffer,
505 size_t count, loff_t *off)
507 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
508 struct client_obd *cli = &dev->u.cli;
509 struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
513 rc = lprocfs_write_u64_helper(buffer, count, &val);
517 /* if the max_pages is specified in bytes, convert to pages */
518 if (val >= ONE_MB_BRW_SIZE)
519 val >>= PAGE_CACHE_SHIFT;
521 LPROCFS_CLIMP_CHECK(dev);
523 chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1);
524 /* max_pages_per_rpc must be chunk aligned */
525 val = (val + ~chunk_mask) & chunk_mask;
526 if (val == 0 || (ocd->ocd_brw_size != 0 &&
527 val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT)) {
528 LPROCFS_CLIMP_EXIT(dev);
531 spin_lock(&cli->cl_loi_list_lock);
532 cli->cl_max_pages_per_rpc = val;
533 client_adjust_max_dirty(cli);
534 spin_unlock(&cli->cl_loi_list_lock);
536 LPROCFS_CLIMP_EXIT(dev);
539 LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc);
541 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
543 struct obd_device *dev = m->private;
544 struct client_obd *cli = &dev->u.cli;
548 pages = atomic_long_read(&cli->cl_unstable_count);
549 mb = (pages * PAGE_CACHE_SIZE) >> 20;
551 return seq_printf(m, "unstable_pages: %20ld\n"
552 "unstable_mb: %10d\n",
555 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
557 LPROC_SEQ_FOPS_RO_TYPE(osc, uuid);
558 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
559 LPROC_SEQ_FOPS_RO_TYPE(osc, blksize);
560 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal);
561 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree);
562 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail);
563 LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal);
564 LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree);
565 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
566 LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid);
567 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
568 LPROC_SEQ_FOPS_RO_TYPE(osc, state);
570 LPROC_SEQ_FOPS_WO_TYPE(osc, ping);
572 LPROC_SEQ_FOPS_RW_TYPE(osc, import);
573 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
575 struct lprocfs_vars lprocfs_osc_obd_vars[] = {
577 .fops = &osc_uuid_fops },
579 .fops = &osc_ping_fops,
581 { .name = "connect_flags",
582 .fops = &osc_connect_flags_fops },
583 { .name = "blocksize",
584 .fops = &osc_blksize_fops },
585 { .name = "kbytestotal",
586 .fops = &osc_kbytestotal_fops },
587 { .name = "kbytesfree",
588 .fops = &osc_kbytesfree_fops },
589 { .name = "kbytesavail",
590 .fops = &osc_kbytesavail_fops },
591 { .name = "filestotal",
592 .fops = &osc_filestotal_fops },
593 { .name = "filesfree",
594 .fops = &osc_filesfree_fops },
595 { .name = "ost_server_uuid",
596 .fops = &osc_server_uuid_fops },
597 { .name = "ost_conn_uuid",
598 .fops = &osc_conn_uuid_fops },
600 .fops = &osc_active_fops },
601 { .name = "max_pages_per_rpc",
602 .fops = &osc_obd_max_pages_per_rpc_fops },
603 { .name = "max_rpcs_in_flight",
604 .fops = &osc_max_rpcs_in_flight_fops },
605 { .name = "destroys_in_flight",
606 .fops = &osc_destroys_in_flight_fops },
607 { .name = "max_dirty_mb",
608 .fops = &osc_max_dirty_mb_fops },
609 { .name = "osc_cached_mb",
610 .fops = &osc_cached_mb_fops },
611 { .name = "cur_dirty_bytes",
612 .fops = &osc_cur_dirty_bytes_fops },
613 { .name = "cur_grant_bytes",
614 .fops = &osc_cur_grant_bytes_fops },
615 { .name = "cur_lost_grant_bytes",
616 .fops = &osc_cur_lost_grant_bytes_fops },
617 { .name = "grant_shrink_interval",
618 .fops = &osc_grant_shrink_interval_fops },
619 { .name = "checksums",
620 .fops = &osc_checksum_fops },
621 { .name = "checksum_type",
622 .fops = &osc_checksum_type_fops },
623 { .name = "resend_count",
624 .fops = &osc_resend_count_fops },
625 { .name = "timeouts",
626 .fops = &osc_timeouts_fops },
627 { .name = "contention_seconds",
628 .fops = &osc_contention_seconds_fops },
629 { .name = "lockless_truncate",
630 .fops = &osc_lockless_truncate_fops },
632 .fops = &osc_import_fops },
634 .fops = &osc_state_fops },
635 { .name = "pinger_recov",
636 .fops = &osc_pinger_recov_fops },
637 { .name = "unstable_stats",
638 .fops = &osc_unstable_stats_fops },
642 #define pct(a,b) (b ? a * 100 / b : 0)
644 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
647 struct obd_device *dev = seq->private;
648 struct client_obd *cli = &dev->u.cli;
649 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
652 do_gettimeofday(&now);
654 spin_lock(&cli->cl_loi_list_lock);
656 seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
657 now.tv_sec, now.tv_usec);
658 seq_printf(seq, "read RPCs in flight: %d\n",
659 cli->cl_r_in_flight);
660 seq_printf(seq, "write RPCs in flight: %d\n",
661 cli->cl_w_in_flight);
662 seq_printf(seq, "pending write pages: %d\n",
663 atomic_read(&cli->cl_pending_w_pages));
664 seq_printf(seq, "pending read pages: %d\n",
665 atomic_read(&cli->cl_pending_r_pages));
667 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
668 seq_printf(seq, "pages per rpc rpcs %% cum %% |");
669 seq_printf(seq, " rpcs %% cum %%\n");
671 read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
672 write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
676 for (i = 0; i < OBD_HIST_MAX; i++) {
677 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
678 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
682 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
683 1 << i, r, pct(r, read_tot),
684 pct(read_cum, read_tot), w,
686 pct(write_cum, write_tot));
687 if (read_cum == read_tot && write_cum == write_tot)
691 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
692 seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
693 seq_printf(seq, " rpcs %% cum %%\n");
695 read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
696 write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
700 for (i = 0; i < OBD_HIST_MAX; i++) {
701 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
702 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
705 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
706 i, r, pct(r, read_tot),
707 pct(read_cum, read_tot), w,
709 pct(write_cum, write_tot));
710 if (read_cum == read_tot && write_cum == write_tot)
714 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
715 seq_printf(seq, "offset rpcs %% cum %% |");
716 seq_printf(seq, " rpcs %% cum %%\n");
718 read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
719 write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
723 for (i = 0; i < OBD_HIST_MAX; i++) {
724 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
725 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
728 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
729 (i == 0) ? 0 : 1 << (i - 1),
730 r, pct(r, read_tot), pct(read_cum, read_tot),
731 w, pct(w, write_tot), pct(write_cum, write_tot));
732 if (read_cum == read_tot && write_cum == write_tot)
736 spin_unlock(&cli->cl_loi_list_lock);
742 static ssize_t osc_rpc_stats_seq_write(struct file *file,
743 const char __user *buf,
744 size_t len, loff_t *off)
746 struct seq_file *seq = file->private_data;
747 struct obd_device *dev = seq->private;
748 struct client_obd *cli = &dev->u.cli;
750 lprocfs_oh_clear(&cli->cl_read_rpc_hist);
751 lprocfs_oh_clear(&cli->cl_write_rpc_hist);
752 lprocfs_oh_clear(&cli->cl_read_page_hist);
753 lprocfs_oh_clear(&cli->cl_write_page_hist);
754 lprocfs_oh_clear(&cli->cl_read_offset_hist);
755 lprocfs_oh_clear(&cli->cl_write_offset_hist);
759 LPROC_SEQ_FOPS(osc_rpc_stats);
761 static int osc_stats_seq_show(struct seq_file *seq, void *v)
764 struct obd_device *dev = seq->private;
765 struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
767 do_gettimeofday(&now);
769 seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
770 now.tv_sec, now.tv_usec);
771 seq_printf(seq, "lockless_write_bytes\t\t"LPU64"\n",
772 stats->os_lockless_writes);
773 seq_printf(seq, "lockless_read_bytes\t\t"LPU64"\n",
774 stats->os_lockless_reads);
775 seq_printf(seq, "lockless_truncate\t\t"LPU64"\n",
776 stats->os_lockless_truncates);
780 static ssize_t osc_stats_seq_write(struct file *file,
781 const char __user *buf,
782 size_t len, loff_t *off)
784 struct seq_file *seq = file->private_data;
785 struct obd_device *dev = seq->private;
786 struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
788 memset(stats, 0, sizeof(*stats));
792 LPROC_SEQ_FOPS(osc_stats);
794 int lproc_osc_attach_seqstat(struct obd_device *dev)
798 rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644,
799 &osc_stats_fops, dev);
801 rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644,
802 &osc_rpc_stats_fops, dev);
806 #endif /* CONFIG_PROC_FS */