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, 2015, 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;
51 LPROCFS_CLIMP_CHECK(dev);
52 seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
53 LPROCFS_CLIMP_EXIT(dev);
57 static ssize_t osc_active_seq_write(struct file *file,
58 const char __user *buffer,
59 size_t count, loff_t *off)
61 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
64 rc = lprocfs_write_helper(buffer, count, &val);
67 if (val < 0 || val > 1)
71 if (dev->u.cli.cl_import->imp_deactive == val)
72 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
74 CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val);
78 LPROC_SEQ_FOPS(osc_active);
80 static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
82 struct obd_device *dev = m->private;
83 struct client_obd *cli = &dev->u.cli;
85 spin_lock(&cli->cl_loi_list_lock);
86 seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
87 spin_unlock(&cli->cl_loi_list_lock);
91 static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
92 const char __user *buffer,
93 size_t count, loff_t *off)
95 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
96 struct client_obd *cli = &dev->u.cli;
98 int adding, added, req_count;
100 rc = lprocfs_write_helper(buffer, count, &val);
104 if (val < 1 || val > OSC_MAX_RIF_MAX)
107 LPROCFS_CLIMP_CHECK(dev);
109 adding = val - cli->cl_max_rpcs_in_flight;
110 req_count = atomic_read(&osc_pool_req_count);
111 if (adding > 0 && req_count < osc_reqpool_maxreqcount) {
113 * There might be some race which will cause over-limit
114 * allocation, but it is fine.
116 if (req_count + adding > osc_reqpool_maxreqcount)
117 adding = osc_reqpool_maxreqcount - req_count;
119 added = osc_rq_pool->prp_populate(osc_rq_pool, adding);
120 atomic_add(added, &osc_pool_req_count);
123 spin_lock(&cli->cl_loi_list_lock);
124 cli->cl_max_rpcs_in_flight = val;
125 client_adjust_max_dirty(cli);
126 spin_unlock(&cli->cl_loi_list_lock);
128 LPROCFS_CLIMP_EXIT(dev);
131 LPROC_SEQ_FOPS(osc_max_rpcs_in_flight);
133 static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
135 struct obd_device *dev = m->private;
136 struct client_obd *cli = &dev->u.cli;
140 spin_lock(&cli->cl_loi_list_lock);
141 val = cli->cl_dirty_max_pages;
142 spin_unlock(&cli->cl_loi_list_lock);
144 mult = 1 << (20 - PAGE_CACHE_SHIFT);
145 return lprocfs_seq_read_frac_helper(m, val, mult);
148 static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
149 const char __user *buffer,
150 size_t count, loff_t *off)
152 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
153 struct client_obd *cli = &dev->u.cli;
154 int pages_number, mult, rc;
156 mult = 1 << (20 - PAGE_CACHE_SHIFT);
157 rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
161 if (pages_number <= 0 ||
162 pages_number >= OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) ||
163 pages_number > totalram_pages / 4) /* 1/4 of RAM */
166 spin_lock(&cli->cl_loi_list_lock);
167 cli->cl_dirty_max_pages = pages_number;
168 osc_wake_cache_waiters(cli);
169 spin_unlock(&cli->cl_loi_list_lock);
173 LPROC_SEQ_FOPS(osc_max_dirty_mb);
175 static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
177 struct obd_device *dev = m->private;
178 struct client_obd *cli = &dev->u.cli;
179 int shift = 20 - PAGE_CACHE_SHIFT;
181 seq_printf(m, "used_mb: %ld\n"
183 "reclaim: "LPU64"\n",
184 (atomic_long_read(&cli->cl_lru_in_list) +
185 atomic_long_read(&cli->cl_lru_busy)) >> shift,
186 atomic_long_read(&cli->cl_lru_busy),
187 cli->cl_lru_reclaim);
192 /* shrink the number of caching pages to a specific number */
194 osc_cached_mb_seq_write(struct file *file, const char __user *buffer,
195 size_t count, loff_t *off)
197 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
198 struct client_obd *cli = &dev->u.cli;
205 if (count >= sizeof(kernbuf))
208 if (copy_from_user(kernbuf, buffer, count))
212 mult = 1 << (20 - PAGE_CACHE_SHIFT);
213 buffer += lprocfs_find_named_value(kernbuf, "used_mb:", &count) -
215 rc = lprocfs_write_frac_u64_helper(buffer, count, &val, mult);
222 pages_number = (long)val;
224 if (pages_number < 0)
227 rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
232 env = cl_env_get(&refcheck);
234 (void)osc_lru_shrink(env, cli, rc, true);
235 cl_env_put(env, &refcheck);
241 LPROC_SEQ_FOPS(osc_cached_mb);
243 static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v)
245 struct obd_device *dev = m->private;
246 struct client_obd *cli = &dev->u.cli;
248 spin_lock(&cli->cl_loi_list_lock);
249 seq_printf(m, "%lu\n", cli->cl_dirty_pages << PAGE_CACHE_SHIFT);
250 spin_unlock(&cli->cl_loi_list_lock);
253 LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes);
255 static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
257 struct obd_device *dev = m->private;
258 struct client_obd *cli = &dev->u.cli;
260 spin_lock(&cli->cl_loi_list_lock);
261 seq_printf(m, "%lu\n", cli->cl_avail_grant);
262 spin_unlock(&cli->cl_loi_list_lock);
266 static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
267 const char __user *buffer,
268 size_t count, loff_t *off)
270 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
271 struct client_obd *cli = &obd->u.cli;
278 rc = lprocfs_write_u64_helper(buffer, count, &val);
282 /* this is only for shrinking grant */
283 spin_lock(&cli->cl_loi_list_lock);
284 if (val >= cli->cl_avail_grant) {
285 spin_unlock(&cli->cl_loi_list_lock);
289 spin_unlock(&cli->cl_loi_list_lock);
291 LPROCFS_CLIMP_CHECK(obd);
292 if (cli->cl_import->imp_state == LUSTRE_IMP_FULL)
293 rc = osc_shrink_grant_to_target(cli, val);
294 LPROCFS_CLIMP_EXIT(obd);
299 LPROC_SEQ_FOPS(osc_cur_grant_bytes);
301 static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v)
303 struct obd_device *dev = m->private;
304 struct client_obd *cli = &dev->u.cli;
306 spin_lock(&cli->cl_loi_list_lock);
307 seq_printf(m, "%lu\n", cli->cl_lost_grant);
308 spin_unlock(&cli->cl_loi_list_lock);
311 LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes);
313 static int osc_cur_dirty_grant_bytes_seq_show(struct seq_file *m, void *v)
315 struct obd_device *dev = m->private;
316 struct client_obd *cli = &dev->u.cli;
318 spin_lock(&cli->cl_loi_list_lock);
319 seq_printf(m, "%lu\n", cli->cl_dirty_grant);
320 spin_unlock(&cli->cl_loi_list_lock);
323 LPROC_SEQ_FOPS_RO(osc_cur_dirty_grant_bytes);
325 static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
327 struct obd_device *obd = m->private;
331 seq_printf(m, "%d\n",
332 obd->u.cli.cl_grant_shrink_interval);
336 static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
337 const char __user *buffer,
338 size_t count, loff_t *off)
340 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
346 rc = lprocfs_write_helper(buffer, count, &val);
353 obd->u.cli.cl_grant_shrink_interval = val;
357 LPROC_SEQ_FOPS(osc_grant_shrink_interval);
359 static int osc_checksum_seq_show(struct seq_file *m, void *v)
361 struct obd_device *obd = m->private;
366 seq_printf(m, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
370 static ssize_t osc_checksum_seq_write(struct file *file,
371 const char __user *buffer,
372 size_t count, loff_t *off)
374 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
380 rc = lprocfs_write_helper(buffer, count, &val);
384 obd->u.cli.cl_checksum = (val ? 1 : 0);
388 LPROC_SEQ_FOPS(osc_checksum);
390 static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
392 struct obd_device *obd = m->private;
399 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
400 if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
402 if (obd->u.cli.cl_cksum_type == (1 << i))
403 seq_printf(m, "[%s] ", cksum_name[i]);
405 seq_printf(m, "%s ", cksum_name[i]);
411 static ssize_t osc_checksum_type_seq_write(struct file *file,
412 const char __user *buffer,
413 size_t count, loff_t *off)
415 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
423 if (count > sizeof(kernbuf) - 1)
425 if (copy_from_user(kernbuf, buffer, count))
427 if (count > 0 && kernbuf[count - 1] == '\n')
428 kernbuf[count - 1] = '\0';
430 kernbuf[count] = '\0';
432 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
433 if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
435 if (!strcmp(kernbuf, cksum_name[i])) {
436 obd->u.cli.cl_cksum_type = 1 << i;
442 LPROC_SEQ_FOPS(osc_checksum_type);
444 static int osc_resend_count_seq_show(struct seq_file *m, void *v)
446 struct obd_device *obd = m->private;
448 seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
452 static ssize_t osc_resend_count_seq_write(struct file *file,
453 const char __user *buffer,
454 size_t count, loff_t *off)
456 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
459 rc = lprocfs_write_helper(buffer, count, &val);
466 atomic_set(&obd->u.cli.cl_resends, val);
470 LPROC_SEQ_FOPS(osc_resend_count);
472 static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
474 struct obd_device *obd = m->private;
475 struct osc_device *od = obd2osc_dev(obd);
477 seq_printf(m, "%u\n", od->od_contention_time);
481 static ssize_t osc_contention_seconds_seq_write(struct file *file,
482 const char __user *buffer,
483 size_t count, loff_t *off)
485 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
486 struct osc_device *od = obd2osc_dev(obd);
488 return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?: count;
490 LPROC_SEQ_FOPS(osc_contention_seconds);
492 static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
494 struct obd_device *obd = m->private;
495 struct osc_device *od = obd2osc_dev(obd);
497 seq_printf(m, "%u\n", od->od_lockless_truncate);
501 static ssize_t osc_lockless_truncate_seq_write(struct file *file,
502 const char __user *buffer,
503 size_t count, loff_t *off)
505 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
506 struct osc_device *od = obd2osc_dev(obd);
508 return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?:
511 LPROC_SEQ_FOPS(osc_lockless_truncate);
513 static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v)
515 struct obd_device *obd = m->private;
516 seq_printf(m, "%u\n",
517 atomic_read(&obd->u.cli.cl_destroy_in_flight));
520 LPROC_SEQ_FOPS_RO(osc_destroys_in_flight);
522 static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
524 return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
527 static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
528 const char __user *buffer,
529 size_t count, loff_t *off)
531 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
532 struct client_obd *cli = &dev->u.cli;
533 struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
537 rc = lprocfs_write_u64_helper(buffer, count, &val);
541 /* if the max_pages is specified in bytes, convert to pages */
542 if (val >= ONE_MB_BRW_SIZE)
543 val >>= PAGE_CACHE_SHIFT;
545 LPROCFS_CLIMP_CHECK(dev);
547 chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1);
548 /* max_pages_per_rpc must be chunk aligned */
549 val = (val + ~chunk_mask) & chunk_mask;
550 if (val == 0 || (ocd->ocd_brw_size != 0 &&
551 val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT)) {
552 LPROCFS_CLIMP_EXIT(dev);
555 spin_lock(&cli->cl_loi_list_lock);
556 cli->cl_max_pages_per_rpc = val;
557 client_adjust_max_dirty(cli);
558 spin_unlock(&cli->cl_loi_list_lock);
560 LPROCFS_CLIMP_EXIT(dev);
563 LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc);
565 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
567 struct obd_device *dev = m->private;
568 struct client_obd *cli = &dev->u.cli;
572 pages = atomic_long_read(&cli->cl_unstable_count);
573 mb = (pages * PAGE_CACHE_SIZE) >> 20;
575 seq_printf(m, "unstable_pages: %20ld\n"
576 "unstable_mb: %10d\n",
580 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
582 LPROC_SEQ_FOPS_RO_TYPE(osc, uuid);
583 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
584 LPROC_SEQ_FOPS_RO_TYPE(osc, blksize);
585 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal);
586 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree);
587 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail);
588 LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal);
589 LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree);
590 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
591 LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid);
592 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
593 LPROC_SEQ_FOPS_RO_TYPE(osc, state);
595 LPROC_SEQ_FOPS_WO_TYPE(osc, ping);
597 LPROC_SEQ_FOPS_RW_TYPE(osc, import);
598 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
600 struct lprocfs_vars lprocfs_osc_obd_vars[] = {
602 .fops = &osc_uuid_fops },
604 .fops = &osc_ping_fops,
606 { .name = "connect_flags",
607 .fops = &osc_connect_flags_fops },
608 { .name = "blocksize",
609 .fops = &osc_blksize_fops },
610 { .name = "kbytestotal",
611 .fops = &osc_kbytestotal_fops },
612 { .name = "kbytesfree",
613 .fops = &osc_kbytesfree_fops },
614 { .name = "kbytesavail",
615 .fops = &osc_kbytesavail_fops },
616 { .name = "filestotal",
617 .fops = &osc_filestotal_fops },
618 { .name = "filesfree",
619 .fops = &osc_filesfree_fops },
620 { .name = "ost_server_uuid",
621 .fops = &osc_server_uuid_fops },
622 { .name = "ost_conn_uuid",
623 .fops = &osc_conn_uuid_fops },
625 .fops = &osc_active_fops },
626 { .name = "max_pages_per_rpc",
627 .fops = &osc_obd_max_pages_per_rpc_fops },
628 { .name = "max_rpcs_in_flight",
629 .fops = &osc_max_rpcs_in_flight_fops },
630 { .name = "destroys_in_flight",
631 .fops = &osc_destroys_in_flight_fops },
632 { .name = "max_dirty_mb",
633 .fops = &osc_max_dirty_mb_fops },
634 { .name = "osc_cached_mb",
635 .fops = &osc_cached_mb_fops },
636 { .name = "cur_dirty_bytes",
637 .fops = &osc_cur_dirty_bytes_fops },
638 { .name = "cur_grant_bytes",
639 .fops = &osc_cur_grant_bytes_fops },
640 { .name = "cur_lost_grant_bytes",
641 .fops = &osc_cur_lost_grant_bytes_fops },
642 { .name = "cur_dirty_grant_bytes",
643 .fops = &osc_cur_dirty_grant_bytes_fops },
644 { .name = "grant_shrink_interval",
645 .fops = &osc_grant_shrink_interval_fops },
646 { .name = "checksums",
647 .fops = &osc_checksum_fops },
648 { .name = "checksum_type",
649 .fops = &osc_checksum_type_fops },
650 { .name = "resend_count",
651 .fops = &osc_resend_count_fops },
652 { .name = "timeouts",
653 .fops = &osc_timeouts_fops },
654 { .name = "contention_seconds",
655 .fops = &osc_contention_seconds_fops },
656 { .name = "lockless_truncate",
657 .fops = &osc_lockless_truncate_fops },
659 .fops = &osc_import_fops },
661 .fops = &osc_state_fops },
662 { .name = "pinger_recov",
663 .fops = &osc_pinger_recov_fops },
664 { .name = "unstable_stats",
665 .fops = &osc_unstable_stats_fops },
669 #define pct(a,b) (b ? a * 100 / b : 0)
671 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
674 struct obd_device *dev = seq->private;
675 struct client_obd *cli = &dev->u.cli;
676 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
679 do_gettimeofday(&now);
681 spin_lock(&cli->cl_loi_list_lock);
683 seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
684 now.tv_sec, now.tv_usec);
685 seq_printf(seq, "read RPCs in flight: %d\n",
686 cli->cl_r_in_flight);
687 seq_printf(seq, "write RPCs in flight: %d\n",
688 cli->cl_w_in_flight);
689 seq_printf(seq, "pending write pages: %d\n",
690 atomic_read(&cli->cl_pending_w_pages));
691 seq_printf(seq, "pending read pages: %d\n",
692 atomic_read(&cli->cl_pending_r_pages));
694 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
695 seq_printf(seq, "pages per rpc rpcs %% cum %% |");
696 seq_printf(seq, " rpcs %% cum %%\n");
698 read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
699 write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
703 for (i = 0; i < OBD_HIST_MAX; i++) {
704 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
705 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
709 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
710 1 << i, r, pct(r, read_tot),
711 pct(read_cum, read_tot), w,
713 pct(write_cum, write_tot));
714 if (read_cum == read_tot && write_cum == write_tot)
718 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
719 seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
720 seq_printf(seq, " rpcs %% cum %%\n");
722 read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
723 write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
727 for (i = 0; i < OBD_HIST_MAX; i++) {
728 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
729 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
732 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
733 i, r, pct(r, read_tot),
734 pct(read_cum, read_tot), w,
736 pct(write_cum, write_tot));
737 if (read_cum == read_tot && write_cum == write_tot)
741 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
742 seq_printf(seq, "offset rpcs %% cum %% |");
743 seq_printf(seq, " rpcs %% cum %%\n");
745 read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
746 write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
750 for (i = 0; i < OBD_HIST_MAX; i++) {
751 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
752 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
755 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
756 (i == 0) ? 0 : 1 << (i - 1),
757 r, pct(r, read_tot), pct(read_cum, read_tot),
758 w, pct(w, write_tot), pct(write_cum, write_tot));
759 if (read_cum == read_tot && write_cum == write_tot)
763 spin_unlock(&cli->cl_loi_list_lock);
769 static ssize_t osc_rpc_stats_seq_write(struct file *file,
770 const char __user *buf,
771 size_t len, loff_t *off)
773 struct seq_file *seq = file->private_data;
774 struct obd_device *dev = seq->private;
775 struct client_obd *cli = &dev->u.cli;
777 lprocfs_oh_clear(&cli->cl_read_rpc_hist);
778 lprocfs_oh_clear(&cli->cl_write_rpc_hist);
779 lprocfs_oh_clear(&cli->cl_read_page_hist);
780 lprocfs_oh_clear(&cli->cl_write_page_hist);
781 lprocfs_oh_clear(&cli->cl_read_offset_hist);
782 lprocfs_oh_clear(&cli->cl_write_offset_hist);
786 LPROC_SEQ_FOPS(osc_rpc_stats);
788 static int osc_stats_seq_show(struct seq_file *seq, void *v)
791 struct obd_device *dev = seq->private;
792 struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
794 do_gettimeofday(&now);
796 seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n",
797 now.tv_sec, now.tv_usec);
798 seq_printf(seq, "lockless_write_bytes\t\t"LPU64"\n",
799 stats->os_lockless_writes);
800 seq_printf(seq, "lockless_read_bytes\t\t"LPU64"\n",
801 stats->os_lockless_reads);
802 seq_printf(seq, "lockless_truncate\t\t"LPU64"\n",
803 stats->os_lockless_truncates);
807 static ssize_t osc_stats_seq_write(struct file *file,
808 const char __user *buf,
809 size_t len, loff_t *off)
811 struct seq_file *seq = file->private_data;
812 struct obd_device *dev = seq->private;
813 struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
815 memset(stats, 0, sizeof(*stats));
819 LPROC_SEQ_FOPS(osc_stats);
821 int lproc_osc_attach_seqstat(struct obd_device *dev)
825 rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644,
826 &osc_stats_fops, dev);
828 rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644,
829 &osc_rpc_stats_fops, dev);
833 #endif /* CONFIG_PROC_FS */