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, 2017, 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 <lustre_osc.h>
42 #include "osc_internal.h"
44 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
47 struct obd_device *obd = container_of(kobj, struct obd_device,
49 struct obd_import *imp;
52 with_imp_locked(obd, imp, rc)
53 rc = sprintf(buf, "%d\n", !imp->imp_deactive);
58 static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
59 const char *buffer, size_t count)
61 struct obd_device *obd = container_of(kobj, struct obd_device,
63 struct obd_import *imp, *imp0;
67 rc = kstrtobool(buffer, &val);
71 with_imp_locked(obd, imp0, rc)
72 imp = class_import_get(imp0);
76 if (imp->imp_deactive == val)
77 rc = ptlrpc_set_import_active(imp, val);
79 CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
81 class_import_put(imp);
85 LUSTRE_RW_ATTR(active);
87 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
88 struct attribute *attr,
91 struct obd_device *obd = container_of(kobj, struct obd_device,
93 struct client_obd *cli = &obd->u.cli;
95 return scnprintf(buf, PAGE_SIZE, "%u\n", cli->cl_max_rpcs_in_flight);
98 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
99 struct attribute *attr,
103 struct obd_device *obd = container_of(kobj, struct obd_device,
105 struct client_obd *cli = &obd->u.cli;
106 int adding, added, req_count;
110 rc = kstrtouint(buffer, 0, &val);
114 if (val == 0 || val > OSC_MAX_RIF_MAX)
117 adding = (int)val - cli->cl_max_rpcs_in_flight;
118 req_count = atomic_read(&osc_pool_req_count);
119 if (adding > 0 && req_count < osc_reqpool_maxreqcount) {
121 * There might be some race which will cause over-limit
122 * allocation, but it is fine.
124 if (req_count + adding > osc_reqpool_maxreqcount)
125 adding = osc_reqpool_maxreqcount - req_count;
127 added = osc_rq_pool->prp_populate(osc_rq_pool, adding);
128 atomic_add(added, &osc_pool_req_count);
131 spin_lock(&cli->cl_loi_list_lock);
132 cli->cl_max_rpcs_in_flight = val;
133 client_adjust_max_dirty(cli);
134 spin_unlock(&cli->cl_loi_list_lock);
138 LUSTRE_RW_ATTR(max_rpcs_in_flight);
140 static ssize_t max_dirty_mb_show(struct kobject *kobj,
141 struct attribute *attr,
144 struct obd_device *obd = container_of(kobj, struct obd_device,
146 struct client_obd *cli = &obd->u.cli;
148 return scnprintf(buf, PAGE_SIZE, "%lu\n",
149 PAGES_TO_MiB(cli->cl_dirty_max_pages));
152 static ssize_t max_dirty_mb_store(struct kobject *kobj,
153 struct attribute *attr,
157 struct obd_device *obd = container_of(kobj, struct obd_device,
159 struct client_obd *cli = &obd->u.cli;
160 unsigned long pages_number, max_dirty_mb;
163 rc = kstrtoul(buffer, 10, &max_dirty_mb);
167 pages_number = MiB_TO_PAGES(max_dirty_mb);
169 if (pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) ||
170 pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */
173 spin_lock(&cli->cl_loi_list_lock);
174 cli->cl_dirty_max_pages = pages_number;
175 osc_wake_cache_waiters(cli);
176 spin_unlock(&cli->cl_loi_list_lock);
180 LUSTRE_RW_ATTR(max_dirty_mb);
182 LUSTRE_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL);
183 LUSTRE_RO_ATTR(conn_uuid);
185 LUSTRE_RW_ATTR(ping);
187 static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
189 struct obd_device *obd = m->private;
190 struct client_obd *cli = &obd->u.cli;
191 int shift = 20 - PAGE_SHIFT;
193 seq_printf(m, "used_mb: %ld\n"
196 (atomic_long_read(&cli->cl_lru_in_list) +
197 atomic_long_read(&cli->cl_lru_busy)) >> shift,
198 atomic_long_read(&cli->cl_lru_busy),
199 cli->cl_lru_reclaim);
204 /* shrink the number of caching pages to a specific number */
205 static ssize_t osc_cached_mb_seq_write(struct file *file,
206 const char __user *buffer,
207 size_t count, loff_t *off)
209 struct seq_file *m = file->private_data;
210 struct obd_device *obd = m->private;
211 struct client_obd *cli = &obd->u.cli;
217 if (count >= sizeof(kernbuf))
220 if (copy_from_user(kernbuf, buffer, count))
224 tmp = lprocfs_find_named_value(kernbuf, "used_mb:", &count);
225 rc = sysfs_memparse(tmp, count, &pages_number, "MiB");
229 pages_number >>= PAGE_SHIFT;
231 rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
236 env = cl_env_get(&refcheck);
238 (void)osc_lru_shrink(env, cli, rc, true);
239 cl_env_put(env, &refcheck);
246 LPROC_SEQ_FOPS(osc_cached_mb);
248 static ssize_t cur_dirty_bytes_show(struct kobject *kobj,
249 struct attribute *attr,
252 struct obd_device *obd = container_of(kobj, struct obd_device,
254 struct client_obd *cli = &obd->u.cli;
256 return scnprintf(buf, PAGE_SIZE, "%lu\n",
257 cli->cl_dirty_pages << PAGE_SHIFT);
259 LUSTRE_RO_ATTR(cur_dirty_bytes);
261 static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
263 struct obd_device *obd = m->private;
264 struct client_obd *cli = &obd->u.cli;
266 seq_printf(m, "%lu\n", cli->cl_avail_grant);
270 static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
271 const char __user *buffer,
272 size_t count, loff_t *off)
274 struct seq_file *m = file->private_data;
275 struct obd_device *obd = m->private;
276 struct client_obd *cli = &obd->u.cli;
277 struct obd_import *imp;
278 char kernbuf[22] = "";
285 if (count >= sizeof(kernbuf))
288 if (copy_from_user(kernbuf, buffer, count))
292 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
296 /* this is only for shrinking grant */
297 if (val >= cli->cl_avail_grant)
300 with_imp_locked(obd, imp, rc)
301 if (imp->imp_state == LUSTRE_IMP_FULL)
302 rc = osc_shrink_grant_to_target(cli, val);
304 return rc ? rc : count;
306 LPROC_SEQ_FOPS(osc_cur_grant_bytes);
308 static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj,
309 struct attribute *attr,
312 struct obd_device *obd = container_of(kobj, struct obd_device,
314 struct client_obd *cli = &obd->u.cli;
316 return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_lost_grant);
318 LUSTRE_RO_ATTR(cur_lost_grant_bytes);
320 static ssize_t cur_dirty_grant_bytes_show(struct kobject *kobj,
321 struct attribute *attr,
324 struct obd_device *obd = container_of(kobj, struct obd_device,
326 struct client_obd *cli = &obd->u.cli;
328 return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_dirty_grant);
330 LUSTRE_RO_ATTR(cur_dirty_grant_bytes);
332 static ssize_t grant_shrink_interval_show(struct kobject *kobj,
333 struct attribute *attr,
336 struct obd_device *obd = container_of(kobj, struct obd_device,
339 return sprintf(buf, "%lld\n", obd->u.cli.cl_grant_shrink_interval);
342 static ssize_t grant_shrink_interval_store(struct kobject *kobj,
343 struct attribute *attr,
347 struct obd_device *obd = container_of(kobj, struct obd_device,
352 rc = kstrtouint(buffer, 0, &val);
359 obd->u.cli.cl_grant_shrink_interval = val;
360 osc_update_next_shrink(&obd->u.cli);
361 osc_schedule_grant_work();
365 LUSTRE_RW_ATTR(grant_shrink_interval);
367 static ssize_t checksums_show(struct kobject *kobj,
368 struct attribute *attr,
371 struct obd_device *obd = container_of(kobj, struct obd_device,
374 return scnprintf(buf, PAGE_SIZE, "%d\n", !!obd->u.cli.cl_checksum);
377 static ssize_t checksums_store(struct kobject *kobj,
378 struct attribute *attr,
382 struct obd_device *obd = container_of(kobj, struct obd_device,
387 rc = kstrtobool(buffer, &val);
391 obd->u.cli.cl_checksum = val;
395 LUSTRE_RW_ATTR(checksums);
399 static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
401 struct obd_device *obd = m->private;
407 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
408 if ((BIT(i) & obd->u.cli.cl_supp_cksum_types) == 0)
410 if (obd->u.cli.cl_cksum_type == BIT(i))
411 seq_printf(m, "[%s] ", cksum_name[i]);
413 seq_printf(m, "%s ", cksum_name[i]);
420 static ssize_t osc_checksum_type_seq_write(struct file *file,
421 const char __user *buffer,
422 size_t count, loff_t *off)
424 struct seq_file *m = file->private_data;
425 struct obd_device *obd = m->private;
433 if (count > sizeof(kernbuf) - 1)
435 if (copy_from_user(kernbuf, buffer, count))
438 if (count > 0 && kernbuf[count - 1] == '\n')
439 kernbuf[count - 1] = '\0';
441 kernbuf[count] = '\0';
443 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
444 if (strcmp(kernbuf, cksum_name[i]) == 0) {
445 obd->u.cli.cl_preferred_cksum_type = BIT(i);
446 if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
447 obd->u.cli.cl_cksum_type = BIT(i);
457 LPROC_SEQ_FOPS(osc_checksum_type);
459 static ssize_t resend_count_show(struct kobject *kobj,
460 struct attribute *attr,
463 struct obd_device *obd = container_of(kobj, struct obd_device,
466 return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends));
469 static ssize_t resend_count_store(struct kobject *kobj,
470 struct attribute *attr,
474 struct obd_device *obd = container_of(kobj, struct obd_device,
479 rc = kstrtouint(buffer, 10, &val);
483 atomic_set(&obd->u.cli.cl_resends, val);
487 LUSTRE_RW_ATTR(resend_count);
489 static ssize_t checksum_dump_show(struct kobject *kobj,
490 struct attribute *attr,
493 struct obd_device *obd = container_of(kobj, struct obd_device,
496 return scnprintf(buf, PAGE_SIZE, "%d\n", !!obd->u.cli.cl_checksum_dump);
499 static ssize_t checksum_dump_store(struct kobject *kobj,
500 struct attribute *attr,
504 struct obd_device *obd = container_of(kobj, struct obd_device,
509 rc = kstrtobool(buffer, &val);
513 obd->u.cli.cl_checksum_dump = val;
517 LUSTRE_RW_ATTR(checksum_dump);
519 static ssize_t contention_seconds_show(struct kobject *kobj,
520 struct attribute *attr,
523 struct obd_device *obd = container_of(kobj, struct obd_device,
525 struct osc_device *od = obd2osc_dev(obd);
527 return sprintf(buf, "%lld\n", od->od_contention_time);
530 static ssize_t contention_seconds_store(struct kobject *kobj,
531 struct attribute *attr,
535 struct obd_device *obd = container_of(kobj, struct obd_device,
537 struct osc_device *od = obd2osc_dev(obd);
541 rc = kstrtouint(buffer, 0, &val);
545 od->od_contention_time = val;
549 LUSTRE_RW_ATTR(contention_seconds);
551 static ssize_t lockless_truncate_show(struct kobject *kobj,
552 struct attribute *attr,
555 struct obd_device *obd = container_of(kobj, struct obd_device,
557 struct osc_device *od = obd2osc_dev(obd);
559 return sprintf(buf, "%u\n", od->od_lockless_truncate);
562 static ssize_t lockless_truncate_store(struct kobject *kobj,
563 struct attribute *attr,
567 struct obd_device *obd = container_of(kobj, struct obd_device,
569 struct osc_device *od = obd2osc_dev(obd);
573 rc = kstrtobool(buffer, &val);
577 od->od_lockless_truncate = val;
581 LUSTRE_RW_ATTR(lockless_truncate);
583 static ssize_t destroys_in_flight_show(struct kobject *kobj,
584 struct attribute *attr,
587 struct obd_device *obd = container_of(kobj, struct obd_device,
590 return sprintf(buf, "%u\n",
591 atomic_read(&obd->u.cli.cl_destroy_in_flight));
593 LUSTRE_RO_ATTR(destroys_in_flight);
595 LPROC_SEQ_FOPS_RW_TYPE(osc, obd_max_pages_per_rpc);
597 LUSTRE_RW_ATTR(short_io_bytes);
599 #ifdef CONFIG_PROC_FS
600 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
602 struct obd_device *obd = m->private;
603 struct client_obd *cli = &obd->u.cli;
607 pages = atomic_long_read(&cli->cl_unstable_count);
608 mb = (pages * PAGE_SIZE) >> 20;
610 seq_printf(m, "unstable_pages: %20ld\n"
611 "unstable_mb: %10d\n",
615 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
617 static ssize_t idle_timeout_show(struct kobject *kobj, struct attribute *attr,
620 struct obd_device *obd = container_of(kobj, struct obd_device,
622 struct obd_import *imp;
625 with_imp_locked(obd, imp, ret)
626 ret = sprintf(buf, "%u\n", imp->imp_idle_timeout);
631 static ssize_t idle_timeout_store(struct kobject *kobj, struct attribute *attr,
632 const char *buffer, size_t count)
634 struct obd_device *obd = container_of(kobj, struct obd_device,
636 struct obd_import *imp;
637 struct ptlrpc_request *req;
638 unsigned int idle_debug = 0;
642 if (strncmp(buffer, "debug", 5) == 0) {
643 idle_debug = D_CONSOLE;
644 } else if (strncmp(buffer, "nodebug", 6) == 0) {
647 rc = kstrtouint(buffer, 10, &val);
651 if (val > CONNECTION_SWITCH_MAX)
655 with_imp_locked(obd, imp, rc) {
657 imp->imp_idle_debug = idle_debug;
660 /* initiate the connection if it's in IDLE state */
661 req = ptlrpc_request_alloc(imp,
664 ptlrpc_req_finished(req);
666 imp->imp_idle_timeout = val;
672 LUSTRE_RW_ATTR(idle_timeout);
674 static ssize_t idle_connect_store(struct kobject *kobj, struct attribute *attr,
675 const char *buffer, size_t count)
677 struct obd_device *obd = container_of(kobj, struct obd_device,
679 struct obd_import *imp;
680 struct ptlrpc_request *req;
683 with_imp_locked(obd, imp, rc) {
684 /* to initiate the connection if it's in IDLE state */
685 req = ptlrpc_request_alloc(imp, &RQF_OST_STATFS);
687 ptlrpc_req_finished(req);
688 ptlrpc_pinger_force(imp);
693 LUSTRE_WO_ATTR(idle_connect);
695 static ssize_t grant_shrink_show(struct kobject *kobj, struct attribute *attr,
698 struct obd_device *obd = container_of(kobj, struct obd_device,
700 struct obd_import *imp;
703 with_imp_locked(obd, imp, len)
704 len = scnprintf(buf, PAGE_SIZE, "%d\n",
705 !imp->imp_grant_shrink_disabled &&
706 OCD_HAS_FLAG(&imp->imp_connect_data,
712 static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
713 const char *buffer, size_t count)
715 struct obd_device *obd = container_of(kobj, struct obd_device,
717 struct obd_import *imp;
724 rc = kstrtobool(buffer, &val);
728 with_imp_locked(obd, imp, rc) {
729 spin_lock(&imp->imp_lock);
730 imp->imp_grant_shrink_disabled = !val;
731 spin_unlock(&imp->imp_lock);
736 LUSTRE_RW_ATTR(grant_shrink);
738 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
739 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
740 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
741 LPROC_SEQ_FOPS_RO_TYPE(osc, state);
743 LPROC_SEQ_FOPS_RW_TYPE(osc, import);
744 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
746 struct lprocfs_vars lprocfs_osc_obd_vars[] = {
747 { .name = "connect_flags",
748 .fops = &osc_connect_flags_fops },
749 { .name = "ost_server_uuid",
750 .fops = &osc_server_uuid_fops },
751 { .name = "max_pages_per_rpc",
752 .fops = &osc_obd_max_pages_per_rpc_fops },
753 { .name = "osc_cached_mb",
754 .fops = &osc_cached_mb_fops },
755 { .name = "cur_grant_bytes",
756 .fops = &osc_cur_grant_bytes_fops },
757 { .name = "checksum_type",
758 .fops = &osc_checksum_type_fops },
759 { .name = "timeouts",
760 .fops = &osc_timeouts_fops },
762 .fops = &osc_import_fops },
764 .fops = &osc_state_fops },
765 { .name = "pinger_recov",
766 .fops = &osc_pinger_recov_fops },
767 { .name = "unstable_stats",
768 .fops = &osc_unstable_stats_fops },
772 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
774 struct timespec64 now;
775 struct obd_device *obd = seq->private;
776 struct client_obd *cli = &obd->u.cli;
777 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
780 ktime_get_real_ts64(&now);
782 spin_lock(&cli->cl_loi_list_lock);
784 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
785 (s64)now.tv_sec, now.tv_nsec);
786 seq_printf(seq, "read RPCs in flight: %d\n",
787 cli->cl_r_in_flight);
788 seq_printf(seq, "write RPCs in flight: %d\n",
789 cli->cl_w_in_flight);
790 seq_printf(seq, "pending write pages: %d\n",
791 atomic_read(&cli->cl_pending_w_pages));
792 seq_printf(seq, "pending read pages: %d\n",
793 atomic_read(&cli->cl_pending_r_pages));
795 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
796 seq_printf(seq, "pages per rpc rpcs %% cum %% |");
797 seq_printf(seq, " rpcs %% cum %%\n");
799 read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
800 write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
804 for (i = 0; i < OBD_HIST_MAX; i++) {
805 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
806 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
810 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
811 1 << i, r, pct(r, read_tot),
812 pct(read_cum, read_tot), w,
814 pct(write_cum, write_tot));
815 if (read_cum == read_tot && write_cum == write_tot)
819 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
820 seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
821 seq_printf(seq, " rpcs %% cum %%\n");
823 read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
824 write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
828 for (i = 1; i < OBD_HIST_MAX; i++) {
829 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
830 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
833 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
834 i, r, pct(r, read_tot),
835 pct(read_cum, read_tot), w,
837 pct(write_cum, write_tot));
838 if (read_cum == read_tot && write_cum == write_tot)
842 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
843 seq_printf(seq, "offset rpcs %% cum %% |");
844 seq_printf(seq, " rpcs %% cum %%\n");
846 read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
847 write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
851 for (i = 0; i < OBD_HIST_MAX; i++) {
852 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
853 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
856 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
857 (i == 0) ? 0 : 1 << (i - 1),
858 r, pct(r, read_tot), pct(read_cum, read_tot),
859 w, pct(w, write_tot), pct(write_cum, write_tot));
860 if (read_cum == read_tot && write_cum == write_tot)
864 spin_unlock(&cli->cl_loi_list_lock);
869 static ssize_t osc_rpc_stats_seq_write(struct file *file,
870 const char __user *buf,
871 size_t len, loff_t *off)
873 struct seq_file *seq = file->private_data;
874 struct obd_device *obd = seq->private;
875 struct client_obd *cli = &obd->u.cli;
877 lprocfs_oh_clear(&cli->cl_read_rpc_hist);
878 lprocfs_oh_clear(&cli->cl_write_rpc_hist);
879 lprocfs_oh_clear(&cli->cl_read_page_hist);
880 lprocfs_oh_clear(&cli->cl_write_page_hist);
881 lprocfs_oh_clear(&cli->cl_read_offset_hist);
882 lprocfs_oh_clear(&cli->cl_write_offset_hist);
886 LPROC_SEQ_FOPS(osc_rpc_stats);
888 static int osc_stats_seq_show(struct seq_file *seq, void *v)
890 struct timespec64 now;
891 struct obd_device *obd = seq->private;
892 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
894 ktime_get_real_ts64(&now);
896 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
897 (s64)now.tv_sec, now.tv_nsec);
898 seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
899 stats->os_lockless_writes);
900 seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
901 stats->os_lockless_reads);
902 seq_printf(seq, "lockless_truncate\t\t%llu\n",
903 stats->os_lockless_truncates);
907 static ssize_t osc_stats_seq_write(struct file *file,
908 const char __user *buf,
909 size_t len, loff_t *off)
911 struct seq_file *seq = file->private_data;
912 struct obd_device *obd = seq->private;
913 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
915 memset(stats, 0, sizeof(*stats));
919 LPROC_SEQ_FOPS(osc_stats);
921 int lprocfs_osc_attach_seqstat(struct obd_device *obd)
925 rc = lprocfs_seq_create(obd->obd_proc_entry, "osc_stats", 0644,
926 &osc_stats_fops, obd);
928 rc = lprocfs_obd_seq_create(obd, "rpc_stats", 0644,
929 &osc_rpc_stats_fops, obd);
933 #endif /* CONFIG_PROC_FS */
935 static struct attribute *osc_attrs[] = {
936 &lustre_attr_active.attr,
937 &lustre_attr_checksums.attr,
938 &lustre_attr_checksum_dump.attr,
939 &lustre_attr_contention_seconds.attr,
940 &lustre_attr_cur_dirty_bytes.attr,
941 &lustre_attr_cur_lost_grant_bytes.attr,
942 &lustre_attr_cur_dirty_grant_bytes.attr,
943 &lustre_attr_destroys_in_flight.attr,
944 &lustre_attr_grant_shrink_interval.attr,
945 &lustre_attr_lockless_truncate.attr,
946 &lustre_attr_max_dirty_mb.attr,
947 &lustre_attr_max_rpcs_in_flight.attr,
948 &lustre_attr_short_io_bytes.attr,
949 &lustre_attr_resend_count.attr,
950 &lustre_attr_ost_conn_uuid.attr,
951 &lustre_attr_conn_uuid.attr,
952 &lustre_attr_ping.attr,
953 &lustre_attr_idle_timeout.attr,
954 &lustre_attr_idle_connect.attr,
955 &lustre_attr_grant_shrink.attr,
959 int osc_tunables_init(struct obd_device *obd)
963 obd->obd_vars = lprocfs_osc_obd_vars;
964 obd->obd_ktype.default_attrs = osc_attrs;
965 rc = lprocfs_obd_setup(obd, false);
968 #ifdef CONFIG_PROC_FS
969 /* If the basic OSC proc tree construction succeeded then
972 rc = lprocfs_osc_attach_seqstat(obd);
976 #endif /* CONFIG_PROC_FS */
977 rc = sptlrpc_lprocfs_cliobd_attach(obd);
981 ptlrpc_lprocfs_register_obd(obd);
984 lprocfs_obd_cleanup(obd);