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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2016, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 #define DEBUG_SUBSYSTEM S_CLASS
34 #include <linux/version.h>
35 #include <asm/statfs.h>
36 #include <obd_cksum.h>
37 #include <obd_class.h>
38 #include <lprocfs_status.h>
39 #include <linux/seq_file.h>
40 #include "osc_internal.h"
43 static int osc_active_seq_show(struct seq_file *m, void *v)
45 struct obd_device *dev = m->private;
47 LPROCFS_CLIMP_CHECK(dev);
48 seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
49 LPROCFS_CLIMP_EXIT(dev);
53 static ssize_t osc_active_seq_write(struct file *file,
54 const char __user *buffer,
55 size_t count, loff_t *off)
57 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
61 rc = lprocfs_str_to_s64(buffer, count, &val);
64 if (val < 0 || val > 1)
68 if (dev->u.cli.cl_import->imp_deactive == val)
69 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
71 CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n",
76 LPROC_SEQ_FOPS(osc_active);
78 static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
80 struct obd_device *dev = m->private;
81 struct client_obd *cli = &dev->u.cli;
83 spin_lock(&cli->cl_loi_list_lock);
84 seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
85 spin_unlock(&cli->cl_loi_list_lock);
89 static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
90 const char __user *buffer,
91 size_t count, loff_t *off)
93 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
94 struct client_obd *cli = &dev->u.cli;
96 int adding, added, req_count;
99 rc = lprocfs_str_to_s64(buffer, count, &val);
102 if (val < 1 || val > OSC_MAX_RIF_MAX)
105 LPROCFS_CLIMP_CHECK(dev);
107 adding = (int)val - cli->cl_max_rpcs_in_flight;
108 req_count = atomic_read(&osc_pool_req_count);
109 if (adding > 0 && req_count < osc_reqpool_maxreqcount) {
111 * There might be some race which will cause over-limit
112 * allocation, but it is fine.
114 if (req_count + adding > osc_reqpool_maxreqcount)
115 adding = osc_reqpool_maxreqcount - req_count;
117 added = osc_rq_pool->prp_populate(osc_rq_pool, adding);
118 atomic_add(added, &osc_pool_req_count);
121 spin_lock(&cli->cl_loi_list_lock);
122 cli->cl_max_rpcs_in_flight = val;
123 client_adjust_max_dirty(cli);
124 spin_unlock(&cli->cl_loi_list_lock);
126 LPROCFS_CLIMP_EXIT(dev);
129 LPROC_SEQ_FOPS(osc_max_rpcs_in_flight);
131 static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
133 struct obd_device *dev = m->private;
134 struct client_obd *cli = &dev->u.cli;
138 spin_lock(&cli->cl_loi_list_lock);
139 val = cli->cl_dirty_max_pages;
140 spin_unlock(&cli->cl_loi_list_lock);
142 mult = 1 << (20 - PAGE_SHIFT);
143 return lprocfs_seq_read_frac_helper(m, val, mult);
146 static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
147 const char __user *buffer,
148 size_t count, loff_t *off)
150 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
151 struct client_obd *cli = &dev->u.cli;
155 rc = lprocfs_str_with_units_to_s64(buffer, count, &pages_number, 'M');
159 pages_number >>= PAGE_SHIFT;
161 if (pages_number <= 0 ||
162 pages_number >= OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_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_SHIFT;
181 seq_printf(m, "used_mb: %ld\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;
203 if (count >= sizeof(kernbuf))
206 if (copy_from_user(kernbuf, buffer, count))
210 buffer += lprocfs_find_named_value(kernbuf, "used_mb:", &count) -
212 rc = lprocfs_str_with_units_to_s64(buffer, count, &pages_number, 'M');
216 pages_number >>= PAGE_SHIFT;
218 if (pages_number < 0)
221 rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
226 env = cl_env_get(&refcheck);
228 (void)osc_lru_shrink(env, cli, rc, true);
229 cl_env_put(env, &refcheck);
235 LPROC_SEQ_FOPS(osc_cached_mb);
237 static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v)
239 struct obd_device *dev = m->private;
240 struct client_obd *cli = &dev->u.cli;
242 spin_lock(&cli->cl_loi_list_lock);
243 seq_printf(m, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT);
244 spin_unlock(&cli->cl_loi_list_lock);
247 LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes);
249 static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
251 struct obd_device *dev = m->private;
252 struct client_obd *cli = &dev->u.cli;
254 spin_lock(&cli->cl_loi_list_lock);
255 seq_printf(m, "%lu\n", cli->cl_avail_grant);
256 spin_unlock(&cli->cl_loi_list_lock);
260 static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
261 const char __user *buffer,
262 size_t count, loff_t *off)
264 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
265 struct client_obd *cli = &obd->u.cli;
272 rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
278 /* this is only for shrinking grant */
279 spin_lock(&cli->cl_loi_list_lock);
280 if (val >= cli->cl_avail_grant) {
281 spin_unlock(&cli->cl_loi_list_lock);
285 spin_unlock(&cli->cl_loi_list_lock);
287 LPROCFS_CLIMP_CHECK(obd);
288 if (cli->cl_import->imp_state == LUSTRE_IMP_FULL)
289 rc = osc_shrink_grant_to_target(cli, val);
290 LPROCFS_CLIMP_EXIT(obd);
295 LPROC_SEQ_FOPS(osc_cur_grant_bytes);
297 static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v)
299 struct obd_device *dev = m->private;
300 struct client_obd *cli = &dev->u.cli;
302 spin_lock(&cli->cl_loi_list_lock);
303 seq_printf(m, "%lu\n", cli->cl_lost_grant);
304 spin_unlock(&cli->cl_loi_list_lock);
307 LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes);
309 static int osc_cur_dirty_grant_bytes_seq_show(struct seq_file *m, void *v)
311 struct obd_device *dev = m->private;
312 struct client_obd *cli = &dev->u.cli;
314 spin_lock(&cli->cl_loi_list_lock);
315 seq_printf(m, "%lu\n", cli->cl_dirty_grant);
316 spin_unlock(&cli->cl_loi_list_lock);
319 LPROC_SEQ_FOPS_RO(osc_cur_dirty_grant_bytes);
321 static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
323 struct obd_device *obd = m->private;
327 seq_printf(m, "%d\n",
328 obd->u.cli.cl_grant_shrink_interval);
332 static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
333 const char __user *buffer,
334 size_t count, loff_t *off)
336 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
343 rc = lprocfs_str_to_s64(buffer, count, &val);
347 if (val <= 0 || val > INT_MAX)
350 obd->u.cli.cl_grant_shrink_interval = val;
354 LPROC_SEQ_FOPS(osc_grant_shrink_interval);
356 static int osc_checksum_seq_show(struct seq_file *m, void *v)
358 struct obd_device *obd = m->private;
363 seq_printf(m, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
367 static ssize_t osc_checksum_seq_write(struct file *file,
368 const char __user *buffer,
369 size_t count, loff_t *off)
371 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
378 rc = lprocfs_str_to_s64(buffer, count, &val);
382 obd->u.cli.cl_checksum = !!val;
386 LPROC_SEQ_FOPS(osc_checksum);
388 static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
390 struct obd_device *obd = m->private;
397 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
398 if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
400 if (obd->u.cli.cl_cksum_type == (1 << i))
401 seq_printf(m, "[%s] ", cksum_name[i]);
403 seq_printf(m, "%s ", cksum_name[i]);
409 static ssize_t osc_checksum_type_seq_write(struct file *file,
410 const char __user *buffer,
411 size_t count, loff_t *off)
413 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
421 if (count > sizeof(kernbuf) - 1)
423 if (copy_from_user(kernbuf, buffer, count))
425 if (count > 0 && kernbuf[count - 1] == '\n')
426 kernbuf[count - 1] = '\0';
428 kernbuf[count] = '\0';
430 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
431 if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
433 if (!strcmp(kernbuf, cksum_name[i])) {
434 obd->u.cli.cl_cksum_type = 1 << i;
440 LPROC_SEQ_FOPS(osc_checksum_type);
442 static int osc_resend_count_seq_show(struct seq_file *m, void *v)
444 struct obd_device *obd = m->private;
446 seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
450 static ssize_t osc_resend_count_seq_write(struct file *file,
451 const char __user *buffer,
452 size_t count, loff_t *off)
454 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
458 rc = lprocfs_str_to_s64(buffer, count, &val);
462 if (val < 0 || val > INT_MAX)
465 atomic_set(&obd->u.cli.cl_resends, val);
469 LPROC_SEQ_FOPS(osc_resend_count);
471 static int osc_checksum_dump_seq_show(struct seq_file *m, void *v)
473 struct obd_device *obd = m->private;
478 seq_printf(m, "%d\n", obd->u.cli.cl_checksum_dump ? 1 : 0);
482 static ssize_t osc_checksum_dump_seq_write(struct file *file,
483 const char __user *buffer,
484 size_t count, loff_t *off)
486 struct obd_device *obd;
490 obd = ((struct seq_file *)file->private_data)->private;
494 rc = lprocfs_str_to_s64(buffer, count, &val);
498 obd->u.cli.cl_checksum_dump = (val ? 1 : 0);
502 LPROC_SEQ_FOPS(osc_checksum_dump);
504 static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
506 struct obd_device *obd = m->private;
507 struct osc_device *od = obd2osc_dev(obd);
509 seq_printf(m, "%u\n", od->od_contention_time);
513 static ssize_t osc_contention_seconds_seq_write(struct file *file,
514 const char __user *buffer,
515 size_t count, loff_t *off)
517 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
518 struct osc_device *od = obd2osc_dev(obd);
522 rc = lprocfs_str_to_s64(buffer, count, &val);
525 if (val < 0 || val > INT_MAX)
528 od->od_contention_time = val;
532 LPROC_SEQ_FOPS(osc_contention_seconds);
534 static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
536 struct obd_device *obd = m->private;
537 struct osc_device *od = obd2osc_dev(obd);
539 seq_printf(m, "%u\n", od->od_lockless_truncate);
543 static ssize_t osc_lockless_truncate_seq_write(struct file *file,
544 const char __user *buffer,
545 size_t count, loff_t *off)
547 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
548 struct osc_device *od = obd2osc_dev(obd);
552 rc = lprocfs_str_to_s64(buffer, count, &val);
558 od->od_lockless_truncate = !!val;
562 LPROC_SEQ_FOPS(osc_lockless_truncate);
564 static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v)
566 struct obd_device *obd = m->private;
567 seq_printf(m, "%u\n",
568 atomic_read(&obd->u.cli.cl_destroy_in_flight));
571 LPROC_SEQ_FOPS_RO(osc_destroys_in_flight);
573 LPROC_SEQ_FOPS_RW_TYPE(osc, obd_max_pages_per_rpc);
575 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
577 struct obd_device *dev = m->private;
578 struct client_obd *cli = &dev->u.cli;
582 pages = atomic_long_read(&cli->cl_unstable_count);
583 mb = (pages * PAGE_SIZE) >> 20;
585 seq_printf(m, "unstable_pages: %20ld\n"
586 "unstable_mb: %10d\n",
590 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
592 LPROC_SEQ_FOPS_RO_TYPE(osc, uuid);
593 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
594 LPROC_SEQ_FOPS_RO_TYPE(osc, blksize);
595 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal);
596 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree);
597 LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail);
598 LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal);
599 LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree);
600 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
601 LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid);
602 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
603 LPROC_SEQ_FOPS_RO_TYPE(osc, state);
605 LPROC_SEQ_FOPS_WO_TYPE(osc, ping);
607 LPROC_SEQ_FOPS_RW_TYPE(osc, import);
608 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
610 struct lprocfs_vars lprocfs_osc_obd_vars[] = {
612 .fops = &osc_uuid_fops },
614 .fops = &osc_ping_fops,
616 { .name = "connect_flags",
617 .fops = &osc_connect_flags_fops },
618 { .name = "blocksize",
619 .fops = &osc_blksize_fops },
620 { .name = "kbytestotal",
621 .fops = &osc_kbytestotal_fops },
622 { .name = "kbytesfree",
623 .fops = &osc_kbytesfree_fops },
624 { .name = "kbytesavail",
625 .fops = &osc_kbytesavail_fops },
626 { .name = "filestotal",
627 .fops = &osc_filestotal_fops },
628 { .name = "filesfree",
629 .fops = &osc_filesfree_fops },
630 { .name = "ost_server_uuid",
631 .fops = &osc_server_uuid_fops },
632 { .name = "ost_conn_uuid",
633 .fops = &osc_conn_uuid_fops },
635 .fops = &osc_active_fops },
636 { .name = "max_pages_per_rpc",
637 .fops = &osc_obd_max_pages_per_rpc_fops },
638 { .name = "max_rpcs_in_flight",
639 .fops = &osc_max_rpcs_in_flight_fops },
640 { .name = "destroys_in_flight",
641 .fops = &osc_destroys_in_flight_fops },
642 { .name = "max_dirty_mb",
643 .fops = &osc_max_dirty_mb_fops },
644 { .name = "osc_cached_mb",
645 .fops = &osc_cached_mb_fops },
646 { .name = "cur_dirty_bytes",
647 .fops = &osc_cur_dirty_bytes_fops },
648 { .name = "cur_grant_bytes",
649 .fops = &osc_cur_grant_bytes_fops },
650 { .name = "cur_lost_grant_bytes",
651 .fops = &osc_cur_lost_grant_bytes_fops },
652 { .name = "cur_dirty_grant_bytes",
653 .fops = &osc_cur_dirty_grant_bytes_fops },
654 { .name = "grant_shrink_interval",
655 .fops = &osc_grant_shrink_interval_fops },
656 { .name = "checksums",
657 .fops = &osc_checksum_fops },
658 { .name = "checksum_type",
659 .fops = &osc_checksum_type_fops },
660 { .name = "checksum_dump",
661 .fops = &osc_checksum_dump_fops },
662 { .name = "resend_count",
663 .fops = &osc_resend_count_fops },
664 { .name = "timeouts",
665 .fops = &osc_timeouts_fops },
666 { .name = "contention_seconds",
667 .fops = &osc_contention_seconds_fops },
668 { .name = "lockless_truncate",
669 .fops = &osc_lockless_truncate_fops },
671 .fops = &osc_import_fops },
673 .fops = &osc_state_fops },
674 { .name = "pinger_recov",
675 .fops = &osc_pinger_recov_fops },
676 { .name = "unstable_stats",
677 .fops = &osc_unstable_stats_fops },
681 #define pct(a,b) (b ? a * 100 / b : 0)
683 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
685 struct timespec64 now;
686 struct obd_device *dev = seq->private;
687 struct client_obd *cli = &dev->u.cli;
688 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
691 ktime_get_real_ts64(&now);
693 spin_lock(&cli->cl_loi_list_lock);
695 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
696 (s64)now.tv_sec, now.tv_nsec);
697 seq_printf(seq, "read RPCs in flight: %d\n",
698 cli->cl_r_in_flight);
699 seq_printf(seq, "write RPCs in flight: %d\n",
700 cli->cl_w_in_flight);
701 seq_printf(seq, "pending write pages: %d\n",
702 atomic_read(&cli->cl_pending_w_pages));
703 seq_printf(seq, "pending read pages: %d\n",
704 atomic_read(&cli->cl_pending_r_pages));
706 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
707 seq_printf(seq, "pages per rpc rpcs %% cum %% |");
708 seq_printf(seq, " rpcs %% cum %%\n");
710 read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
711 write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
715 for (i = 0; i < OBD_HIST_MAX; i++) {
716 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
717 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
721 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
722 1 << i, r, pct(r, read_tot),
723 pct(read_cum, read_tot), w,
725 pct(write_cum, write_tot));
726 if (read_cum == read_tot && write_cum == write_tot)
730 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
731 seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
732 seq_printf(seq, " rpcs %% cum %%\n");
734 read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
735 write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
739 for (i = 0; i < OBD_HIST_MAX; i++) {
740 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
741 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
744 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
745 i, r, pct(r, read_tot),
746 pct(read_cum, read_tot), w,
748 pct(write_cum, write_tot));
749 if (read_cum == read_tot && write_cum == write_tot)
753 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
754 seq_printf(seq, "offset rpcs %% cum %% |");
755 seq_printf(seq, " rpcs %% cum %%\n");
757 read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
758 write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
762 for (i = 0; i < OBD_HIST_MAX; i++) {
763 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
764 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
767 seq_printf(seq, "%d:\t\t%10lu %3lu %3lu | %10lu %3lu %3lu\n",
768 (i == 0) ? 0 : 1 << (i - 1),
769 r, pct(r, read_tot), pct(read_cum, read_tot),
770 w, pct(w, write_tot), pct(write_cum, write_tot));
771 if (read_cum == read_tot && write_cum == write_tot)
775 spin_unlock(&cli->cl_loi_list_lock);
781 static ssize_t osc_rpc_stats_seq_write(struct file *file,
782 const char __user *buf,
783 size_t len, loff_t *off)
785 struct seq_file *seq = file->private_data;
786 struct obd_device *dev = seq->private;
787 struct client_obd *cli = &dev->u.cli;
789 lprocfs_oh_clear(&cli->cl_read_rpc_hist);
790 lprocfs_oh_clear(&cli->cl_write_rpc_hist);
791 lprocfs_oh_clear(&cli->cl_read_page_hist);
792 lprocfs_oh_clear(&cli->cl_write_page_hist);
793 lprocfs_oh_clear(&cli->cl_read_offset_hist);
794 lprocfs_oh_clear(&cli->cl_write_offset_hist);
798 LPROC_SEQ_FOPS(osc_rpc_stats);
800 static int osc_stats_seq_show(struct seq_file *seq, void *v)
802 struct timespec64 now;
803 struct obd_device *dev = seq->private;
804 struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
806 ktime_get_real_ts64(&now);
808 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
809 (s64)now.tv_sec, now.tv_nsec);
810 seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
811 stats->os_lockless_writes);
812 seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
813 stats->os_lockless_reads);
814 seq_printf(seq, "lockless_truncate\t\t%llu\n",
815 stats->os_lockless_truncates);
819 static ssize_t osc_stats_seq_write(struct file *file,
820 const char __user *buf,
821 size_t len, loff_t *off)
823 struct seq_file *seq = file->private_data;
824 struct obd_device *dev = seq->private;
825 struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
827 memset(stats, 0, sizeof(*stats));
831 LPROC_SEQ_FOPS(osc_stats);
833 int lproc_osc_attach_seqstat(struct obd_device *dev)
837 rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644,
838 &osc_stats_fops, dev);
840 rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644,
841 &osc_rpc_stats_fops, dev);
845 #endif /* CONFIG_PROC_FS */