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,
66 rc = kstrtobool(buffer, &val);
71 if (obd->u.cli.cl_import->imp_deactive == val)
72 rc = ptlrpc_set_import_active(obd->u.cli.cl_import, val);
74 CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
79 LUSTRE_RW_ATTR(active);
81 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
82 struct attribute *attr,
85 struct obd_device *obd = container_of(kobj, struct obd_device,
87 struct client_obd *cli = &obd->u.cli;
90 spin_lock(&cli->cl_loi_list_lock);
91 len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight);
92 spin_unlock(&cli->cl_loi_list_lock);
96 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
97 struct attribute *attr,
101 struct obd_device *obd = container_of(kobj, struct obd_device,
103 struct client_obd *cli = &obd->u.cli;
104 int adding, added, req_count;
108 rc = kstrtouint(buffer, 0, &val);
112 if (val == 0 || val > OSC_MAX_RIF_MAX)
115 adding = (int)val - cli->cl_max_rpcs_in_flight;
116 req_count = atomic_read(&osc_pool_req_count);
117 if (adding > 0 && req_count < osc_reqpool_maxreqcount) {
119 * There might be some race which will cause over-limit
120 * allocation, but it is fine.
122 if (req_count + adding > osc_reqpool_maxreqcount)
123 adding = osc_reqpool_maxreqcount - req_count;
125 added = osc_rq_pool->prp_populate(osc_rq_pool, adding);
126 atomic_add(added, &osc_pool_req_count);
129 spin_lock(&cli->cl_loi_list_lock);
130 cli->cl_max_rpcs_in_flight = val;
131 client_adjust_max_dirty(cli);
132 spin_unlock(&cli->cl_loi_list_lock);
136 LUSTRE_RW_ATTR(max_rpcs_in_flight);
138 static ssize_t max_dirty_mb_show(struct kobject *kobj,
139 struct attribute *attr,
142 struct obd_device *obd = container_of(kobj, struct obd_device,
144 struct client_obd *cli = &obd->u.cli;
147 spin_lock(&cli->cl_loi_list_lock);
148 val = PAGES_TO_MiB(cli->cl_dirty_max_pages);
149 spin_unlock(&cli->cl_loi_list_lock);
151 return sprintf(buf, "%lu\n", val);
154 static ssize_t max_dirty_mb_store(struct kobject *kobj,
155 struct attribute *attr,
159 struct obd_device *obd = container_of(kobj, struct obd_device,
161 struct client_obd *cli = &obd->u.cli;
162 unsigned long pages_number, max_dirty_mb;
165 rc = kstrtoul(buffer, 10, &max_dirty_mb);
169 pages_number = MiB_TO_PAGES(max_dirty_mb);
171 if (pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) ||
172 pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */
175 spin_lock(&cli->cl_loi_list_lock);
176 cli->cl_dirty_max_pages = pages_number;
177 osc_wake_cache_waiters(cli);
178 spin_unlock(&cli->cl_loi_list_lock);
182 LUSTRE_RW_ATTR(max_dirty_mb);
184 LUSTRE_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL);
185 LUSTRE_RO_ATTR(conn_uuid);
187 LUSTRE_RW_ATTR(ping);
189 static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
191 struct obd_device *obd = m->private;
192 struct client_obd *cli = &obd->u.cli;
193 int shift = 20 - PAGE_SHIFT;
195 seq_printf(m, "used_mb: %ld\n"
198 (atomic_long_read(&cli->cl_lru_in_list) +
199 atomic_long_read(&cli->cl_lru_busy)) >> shift,
200 atomic_long_read(&cli->cl_lru_busy),
201 cli->cl_lru_reclaim);
206 /* shrink the number of caching pages to a specific number */
207 static ssize_t osc_cached_mb_seq_write(struct file *file,
208 const char __user *buffer,
209 size_t count, loff_t *off)
211 struct seq_file *m = file->private_data;
212 struct obd_device *obd = m->private;
213 struct client_obd *cli = &obd->u.cli;
219 if (count >= sizeof(kernbuf))
222 if (copy_from_user(kernbuf, buffer, count))
226 tmp = lprocfs_find_named_value(kernbuf, "used_mb:", &count);
227 rc = sysfs_memparse(tmp, count, &pages_number, "MiB");
231 pages_number >>= PAGE_SHIFT;
233 rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
238 env = cl_env_get(&refcheck);
240 (void)osc_lru_shrink(env, cli, rc, true);
241 cl_env_put(env, &refcheck);
248 LPROC_SEQ_FOPS(osc_cached_mb);
250 static ssize_t cur_dirty_bytes_show(struct kobject *kobj,
251 struct attribute *attr,
254 struct obd_device *obd = container_of(kobj, struct obd_device,
256 struct client_obd *cli = &obd->u.cli;
259 spin_lock(&cli->cl_loi_list_lock);
260 len = sprintf(buf, "%lu\n", cli->cl_dirty_pages << PAGE_SHIFT);
261 spin_unlock(&cli->cl_loi_list_lock);
265 LUSTRE_RO_ATTR(cur_dirty_bytes);
267 static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
269 struct obd_device *obd = m->private;
270 struct client_obd *cli = &obd->u.cli;
272 spin_lock(&cli->cl_loi_list_lock);
273 seq_printf(m, "%lu\n", cli->cl_avail_grant);
274 spin_unlock(&cli->cl_loi_list_lock);
278 static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
279 const char __user *buffer,
280 size_t count, loff_t *off)
282 struct seq_file *m = file->private_data;
283 struct obd_device *obd = m->private;
284 struct client_obd *cli = &obd->u.cli;
285 struct obd_import *imp;
286 char kernbuf[22] = "";
293 if (count >= sizeof(kernbuf))
296 if (copy_from_user(kernbuf, buffer, count))
300 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
304 /* this is only for shrinking grant */
305 spin_lock(&cli->cl_loi_list_lock);
306 if (val >= cli->cl_avail_grant) {
307 spin_unlock(&cli->cl_loi_list_lock);
311 spin_unlock(&cli->cl_loi_list_lock);
313 with_imp_locked(obd, imp, rc)
314 if (imp->imp_state == LUSTRE_IMP_FULL)
315 rc = osc_shrink_grant_to_target(cli, val);
317 return rc ? rc : count;
319 LPROC_SEQ_FOPS(osc_cur_grant_bytes);
321 static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj,
322 struct attribute *attr,
325 struct obd_device *obd = container_of(kobj, struct obd_device,
327 struct client_obd *cli = &obd->u.cli;
330 spin_lock(&cli->cl_loi_list_lock);
331 len = sprintf(buf, "%lu\n", cli->cl_lost_grant);
332 spin_unlock(&cli->cl_loi_list_lock);
335 LUSTRE_RO_ATTR(cur_lost_grant_bytes);
337 static ssize_t grant_shrink_interval_show(struct kobject *kobj,
338 struct attribute *attr,
341 struct obd_device *obd = container_of(kobj, struct obd_device,
344 return sprintf(buf, "%lld\n", obd->u.cli.cl_grant_shrink_interval);
347 static ssize_t grant_shrink_interval_store(struct kobject *kobj,
348 struct attribute *attr,
352 struct obd_device *obd = container_of(kobj, struct obd_device,
357 rc = kstrtouint(buffer, 0, &val);
364 obd->u.cli.cl_grant_shrink_interval = val;
365 osc_update_next_shrink(&obd->u.cli);
366 osc_schedule_grant_work();
370 LUSTRE_RW_ATTR(grant_shrink_interval);
372 static ssize_t checksums_show(struct kobject *kobj,
373 struct attribute *attr,
376 struct obd_device *obd = container_of(kobj, struct obd_device,
379 return sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
382 static ssize_t checksums_store(struct kobject *kobj,
383 struct attribute *attr,
387 struct obd_device *obd = container_of(kobj, struct obd_device,
392 rc = kstrtobool(buffer, &val);
396 obd->u.cli.cl_checksum = val;
400 LUSTRE_RW_ATTR(checksums);
402 static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
404 struct obd_device *obd = m->private;
411 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
412 if (((1 << i) & obd->u.cli.cl_supp_cksum_types) == 0)
414 if (obd->u.cli.cl_cksum_type == (1 << i))
415 seq_printf(m, "[%s] ", cksum_name[i]);
417 seq_printf(m, "%s ", cksum_name[i]);
423 static ssize_t osc_checksum_type_seq_write(struct file *file,
424 const char __user *buffer,
425 size_t count, loff_t *off)
427 struct seq_file *m = file->private_data;
428 struct obd_device *obd = m->private;
437 if (count > sizeof(kernbuf) - 1)
439 if (copy_from_user(kernbuf, buffer, count))
442 if (count > 0 && kernbuf[count - 1] == '\n')
443 kernbuf[count - 1] = '\0';
445 kernbuf[count] = '\0';
447 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
448 if (strcmp(kernbuf, cksum_name[i]) == 0) {
449 obd->u.cli.cl_preferred_cksum_type = BIT(i);
450 if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
451 obd->u.cli.cl_cksum_type = BIT(i);
461 LPROC_SEQ_FOPS(osc_checksum_type);
463 static ssize_t resend_count_show(struct kobject *kobj,
464 struct attribute *attr,
467 struct obd_device *obd = container_of(kobj, struct obd_device,
470 return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends));
473 static ssize_t resend_count_store(struct kobject *kobj,
474 struct attribute *attr,
478 struct obd_device *obd = container_of(kobj, struct obd_device,
483 rc = kstrtouint(buffer, 10, &val);
487 atomic_set(&obd->u.cli.cl_resends, val);
491 LUSTRE_RW_ATTR(resend_count);
493 static ssize_t checksum_dump_show(struct kobject *kobj,
494 struct attribute *attr,
497 struct obd_device *obd = container_of(kobj, struct obd_device,
500 return sprintf(buf, "%d\n", obd->u.cli.cl_checksum_dump ? 1 : 0);
503 static ssize_t checksum_dump_store(struct kobject *kobj,
504 struct attribute *attr,
508 struct obd_device *obd = container_of(kobj, struct obd_device,
513 rc = kstrtobool(buffer, &val);
517 obd->u.cli.cl_checksum_dump = val;
521 LUSTRE_RW_ATTR(checksum_dump);
523 static ssize_t contention_seconds_show(struct kobject *kobj,
524 struct attribute *attr,
527 struct obd_device *obd = container_of(kobj, struct obd_device,
529 struct osc_device *od = obd2osc_dev(obd);
531 return sprintf(buf, "%lld\n", od->od_contention_time);
534 static ssize_t contention_seconds_store(struct kobject *kobj,
535 struct attribute *attr,
539 struct obd_device *obd = container_of(kobj, struct obd_device,
541 struct osc_device *od = obd2osc_dev(obd);
545 rc = kstrtouint(buffer, 0, &val);
549 od->od_contention_time = val;
553 LUSTRE_RW_ATTR(contention_seconds);
555 static ssize_t lockless_truncate_show(struct kobject *kobj,
556 struct attribute *attr,
559 struct obd_device *obd = container_of(kobj, struct obd_device,
561 struct osc_device *od = obd2osc_dev(obd);
563 return sprintf(buf, "%u\n", od->od_lockless_truncate);
566 static ssize_t lockless_truncate_store(struct kobject *kobj,
567 struct attribute *attr,
571 struct obd_device *obd = container_of(kobj, struct obd_device,
573 struct osc_device *od = obd2osc_dev(obd);
577 rc = kstrtobool(buffer, &val);
581 od->od_lockless_truncate = val;
585 LUSTRE_RW_ATTR(lockless_truncate);
587 static ssize_t destroys_in_flight_show(struct kobject *kobj,
588 struct attribute *attr,
591 struct obd_device *obd = container_of(kobj, struct obd_device,
594 return sprintf(buf, "%u\n",
595 atomic_read(&obd->u.cli.cl_destroy_in_flight));
597 LUSTRE_RO_ATTR(destroys_in_flight);
599 LPROC_SEQ_FOPS_RW_TYPE(osc, obd_max_pages_per_rpc);
601 LUSTRE_RW_ATTR(short_io_bytes);
603 #ifdef CONFIG_PROC_FS
604 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
606 struct obd_device *obd = m->private;
607 struct client_obd *cli = &obd->u.cli;
611 pages = atomic_long_read(&cli->cl_unstable_count);
612 mb = (pages * PAGE_SIZE) >> 20;
614 seq_printf(m, "unstable_pages: %20ld\n"
615 "unstable_mb: %10d\n",
619 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
621 static ssize_t idle_timeout_show(struct kobject *kobj, struct attribute *attr,
624 struct obd_device *obd = container_of(kobj, struct obd_device,
626 struct obd_import *imp;
629 with_imp_locked(obd, imp, ret)
630 ret = sprintf(buf, "%u\n", imp->imp_idle_timeout);
635 static ssize_t idle_timeout_store(struct kobject *kobj, struct attribute *attr,
636 const char *buffer, size_t count)
638 struct obd_device *obd = container_of(kobj, struct obd_device,
640 struct obd_import *imp;
641 struct ptlrpc_request *req;
642 unsigned int idle_debug = 0;
646 if (strncmp(buffer, "debug", 5) == 0) {
647 idle_debug = D_CONSOLE;
648 } else if (strncmp(buffer, "nodebug", 6) == 0) {
651 rc = kstrtouint(buffer, 10, &val);
655 if (val > CONNECTION_SWITCH_MAX)
659 with_imp_locked(obd, imp, rc) {
661 imp->imp_idle_debug = idle_debug;
664 /* initiate the connection if it's in IDLE state */
665 req = ptlrpc_request_alloc(imp,
668 ptlrpc_req_finished(req);
670 imp->imp_idle_timeout = val;
676 LUSTRE_RW_ATTR(idle_timeout);
678 static ssize_t idle_connect_store(struct kobject *kobj, struct attribute *attr,
679 const char *buffer, size_t count)
681 struct obd_device *obd = container_of(kobj, struct obd_device,
683 struct obd_import *imp;
684 struct ptlrpc_request *req;
687 with_imp_locked(obd, imp, rc) {
688 /* to initiate the connection if it's in IDLE state */
689 req = ptlrpc_request_alloc(imp, &RQF_OST_STATFS);
691 ptlrpc_req_finished(req);
692 ptlrpc_pinger_force(imp);
697 LUSTRE_WO_ATTR(idle_connect);
699 static ssize_t grant_shrink_show(struct kobject *kobj, struct attribute *attr,
702 struct obd_device *obd = container_of(kobj, struct obd_device,
704 struct obd_import *imp;
707 with_imp_locked(obd, imp, len)
708 len = scnprintf(buf, PAGE_SIZE, "%d\n",
709 !imp->imp_grant_shrink_disabled &&
710 OCD_HAS_FLAG(&imp->imp_connect_data,
716 static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
717 const char *buffer, size_t count)
719 struct obd_device *obd = container_of(kobj, struct obd_device,
721 struct obd_import *imp;
728 rc = kstrtobool(buffer, &val);
732 with_imp_locked(obd, imp, rc) {
733 spin_lock(&imp->imp_lock);
734 imp->imp_grant_shrink_disabled = !val;
735 spin_unlock(&imp->imp_lock);
740 LUSTRE_RW_ATTR(grant_shrink);
742 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
743 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
744 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
745 LPROC_SEQ_FOPS_RO_TYPE(osc, state);
747 LPROC_SEQ_FOPS_RW_TYPE(osc, import);
748 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
750 struct lprocfs_vars lprocfs_osc_obd_vars[] = {
751 { .name = "connect_flags",
752 .fops = &osc_connect_flags_fops },
753 { .name = "ost_server_uuid",
754 .fops = &osc_server_uuid_fops },
755 { .name = "max_pages_per_rpc",
756 .fops = &osc_obd_max_pages_per_rpc_fops },
757 { .name = "osc_cached_mb",
758 .fops = &osc_cached_mb_fops },
759 { .name = "cur_grant_bytes",
760 .fops = &osc_cur_grant_bytes_fops },
761 { .name = "checksum_type",
762 .fops = &osc_checksum_type_fops },
763 { .name = "timeouts",
764 .fops = &osc_timeouts_fops },
766 .fops = &osc_import_fops },
768 .fops = &osc_state_fops },
769 { .name = "pinger_recov",
770 .fops = &osc_pinger_recov_fops },
771 { .name = "unstable_stats",
772 .fops = &osc_unstable_stats_fops },
776 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
778 struct timespec64 now;
779 struct obd_device *obd = seq->private;
780 struct client_obd *cli = &obd->u.cli;
781 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
784 ktime_get_real_ts64(&now);
786 spin_lock(&cli->cl_loi_list_lock);
788 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
789 (s64)now.tv_sec, now.tv_nsec);
790 seq_printf(seq, "read RPCs in flight: %d\n",
791 cli->cl_r_in_flight);
792 seq_printf(seq, "write RPCs in flight: %d\n",
793 cli->cl_w_in_flight);
794 seq_printf(seq, "pending write pages: %d\n",
795 atomic_read(&cli->cl_pending_w_pages));
796 seq_printf(seq, "pending read pages: %d\n",
797 atomic_read(&cli->cl_pending_r_pages));
799 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
800 seq_printf(seq, "pages per rpc rpcs %% cum %% |");
801 seq_printf(seq, " rpcs %% cum %%\n");
803 read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
804 write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
808 for (i = 0; i < OBD_HIST_MAX; i++) {
809 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
810 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
814 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
815 1 << i, r, pct(r, read_tot),
816 pct(read_cum, read_tot), w,
818 pct(write_cum, write_tot));
819 if (read_cum == read_tot && write_cum == write_tot)
823 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
824 seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
825 seq_printf(seq, " rpcs %% cum %%\n");
827 read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
828 write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
832 for (i = 0; i < OBD_HIST_MAX; i++) {
833 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
834 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
837 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
838 i, r, pct(r, read_tot),
839 pct(read_cum, read_tot), w,
841 pct(write_cum, write_tot));
842 if (read_cum == read_tot && write_cum == write_tot)
846 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
847 seq_printf(seq, "offset rpcs %% cum %% |");
848 seq_printf(seq, " rpcs %% cum %%\n");
850 read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
851 write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
855 for (i = 0; i < OBD_HIST_MAX; i++) {
856 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
857 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
860 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
861 (i == 0) ? 0 : 1 << (i - 1),
862 r, pct(r, read_tot), pct(read_cum, read_tot),
863 w, pct(w, write_tot), pct(write_cum, write_tot));
864 if (read_cum == read_tot && write_cum == write_tot)
868 spin_unlock(&cli->cl_loi_list_lock);
873 static ssize_t osc_rpc_stats_seq_write(struct file *file,
874 const char __user *buf,
875 size_t len, loff_t *off)
877 struct seq_file *seq = file->private_data;
878 struct obd_device *obd = seq->private;
879 struct client_obd *cli = &obd->u.cli;
881 lprocfs_oh_clear(&cli->cl_read_rpc_hist);
882 lprocfs_oh_clear(&cli->cl_write_rpc_hist);
883 lprocfs_oh_clear(&cli->cl_read_page_hist);
884 lprocfs_oh_clear(&cli->cl_write_page_hist);
885 lprocfs_oh_clear(&cli->cl_read_offset_hist);
886 lprocfs_oh_clear(&cli->cl_write_offset_hist);
890 LPROC_SEQ_FOPS(osc_rpc_stats);
892 static int osc_stats_seq_show(struct seq_file *seq, void *v)
894 struct timespec64 now;
895 struct obd_device *obd = seq->private;
896 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
898 ktime_get_real_ts64(&now);
900 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
901 (s64)now.tv_sec, now.tv_nsec);
902 seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
903 stats->os_lockless_writes);
904 seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
905 stats->os_lockless_reads);
906 seq_printf(seq, "lockless_truncate\t\t%llu\n",
907 stats->os_lockless_truncates);
911 static ssize_t osc_stats_seq_write(struct file *file,
912 const char __user *buf,
913 size_t len, loff_t *off)
915 struct seq_file *seq = file->private_data;
916 struct obd_device *obd = seq->private;
917 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
919 memset(stats, 0, sizeof(*stats));
923 LPROC_SEQ_FOPS(osc_stats);
925 int lprocfs_osc_attach_seqstat(struct obd_device *obd)
929 rc = lprocfs_seq_create(obd->obd_proc_entry, "osc_stats", 0644,
930 &osc_stats_fops, obd);
932 rc = lprocfs_obd_seq_create(obd, "rpc_stats", 0644,
933 &osc_rpc_stats_fops, obd);
937 #endif /* CONFIG_PROC_FS */
939 static struct attribute *osc_attrs[] = {
940 &lustre_attr_active.attr,
941 &lustre_attr_checksums.attr,
942 &lustre_attr_checksum_dump.attr,
943 &lustre_attr_contention_seconds.attr,
944 &lustre_attr_cur_dirty_bytes.attr,
945 &lustre_attr_cur_lost_grant_bytes.attr,
946 &lustre_attr_destroys_in_flight.attr,
947 &lustre_attr_grant_shrink_interval.attr,
948 &lustre_attr_lockless_truncate.attr,
949 &lustre_attr_max_dirty_mb.attr,
950 &lustre_attr_max_rpcs_in_flight.attr,
951 &lustre_attr_short_io_bytes.attr,
952 &lustre_attr_resend_count.attr,
953 &lustre_attr_ost_conn_uuid.attr,
954 &lustre_attr_conn_uuid.attr,
955 &lustre_attr_ping.attr,
956 &lustre_attr_idle_timeout.attr,
957 &lustre_attr_idle_connect.attr,
958 &lustre_attr_grant_shrink.attr,
962 int osc_tunables_init(struct obd_device *obd)
966 obd->obd_vars = lprocfs_osc_obd_vars;
967 obd->obd_ktype.default_attrs = osc_attrs;
968 rc = lprocfs_obd_setup(obd, false);
971 #ifdef CONFIG_PROC_FS
972 /* If the basic OSC proc tree construction succeeded then
975 rc = lprocfs_osc_attach_seqstat(obd);
979 #endif /* CONFIG_PROC_FS */
980 rc = sptlrpc_lprocfs_cliobd_attach(obd);
984 ptlrpc_lprocfs_register_obd(obd);
987 lprocfs_obd_cleanup(obd);