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/
31 #define DEBUG_SUBSYSTEM S_CLASS
33 #include <linux/version.h>
34 #include <asm/statfs.h>
35 #include <obd_cksum.h>
36 #include <obd_class.h>
37 #include <lprocfs_status.h>
38 #include <linux/seq_file.h>
39 #include <lustre_osc.h>
41 #include "osc_internal.h"
43 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
46 struct obd_device *obd = container_of(kobj, struct obd_device,
48 struct obd_import *imp;
51 with_imp_locked(obd, imp, rc)
52 rc = sprintf(buf, "%d\n", !imp->imp_deactive);
57 static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
58 const char *buffer, size_t count)
60 struct obd_device *obd = container_of(kobj, struct obd_device,
62 struct obd_import *imp, *imp0;
66 rc = kstrtobool(buffer, &val);
70 with_imp_locked(obd, imp0, rc)
71 imp = class_import_get(imp0);
75 if (imp->imp_deactive == val)
76 rc = ptlrpc_set_import_active(imp, val);
78 CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
80 class_import_put(imp);
84 LUSTRE_RW_ATTR(active);
86 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
87 struct attribute *attr,
90 struct obd_device *obd = container_of(kobj, struct obd_device,
92 struct client_obd *cli = &obd->u.cli;
94 return scnprintf(buf, PAGE_SIZE, "%u\n", cli->cl_max_rpcs_in_flight);
97 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
98 struct attribute *attr,
102 struct obd_device *obd = container_of(kobj, struct obd_device,
104 struct client_obd *cli = &obd->u.cli;
105 int adding, added, req_count;
109 rc = kstrtouint(buffer, 0, &val);
113 if (val == 0 || val > OSC_MAX_RIF_MAX)
116 adding = (int)val - cli->cl_max_rpcs_in_flight;
117 req_count = atomic_read(&osc_pool_req_count);
118 if (adding > 0 && req_count < osc_reqpool_maxreqcount) {
120 * There might be some race which will cause over-limit
121 * allocation, but it is fine.
123 if (req_count + adding > osc_reqpool_maxreqcount)
124 adding = osc_reqpool_maxreqcount - req_count;
126 added = osc_rq_pool->prp_populate(osc_rq_pool, adding);
127 atomic_add(added, &osc_pool_req_count);
130 spin_lock(&cli->cl_loi_list_lock);
131 cli->cl_max_rpcs_in_flight = val;
132 client_adjust_max_dirty(cli);
133 spin_unlock(&cli->cl_loi_list_lock);
137 LUSTRE_RW_ATTR(max_rpcs_in_flight);
139 static ssize_t max_dirty_mb_show(struct kobject *kobj,
140 struct attribute *attr,
143 struct obd_device *obd = container_of(kobj, struct obd_device,
145 struct client_obd *cli = &obd->u.cli;
147 return scnprintf(buf, PAGE_SIZE, "%lu\n",
148 PAGES_TO_MiB(cli->cl_dirty_max_pages));
151 static ssize_t max_dirty_mb_store(struct kobject *kobj,
152 struct attribute *attr,
156 struct obd_device *obd = container_of(kobj, struct obd_device,
158 struct client_obd *cli = &obd->u.cli;
159 unsigned long pages_number, max_dirty_mb;
162 rc = kstrtoul(buffer, 10, &max_dirty_mb);
166 pages_number = MiB_TO_PAGES(max_dirty_mb);
168 if (pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) ||
169 pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */
172 spin_lock(&cli->cl_loi_list_lock);
173 cli->cl_dirty_max_pages = pages_number;
174 osc_wake_cache_waiters(cli);
175 spin_unlock(&cli->cl_loi_list_lock);
179 LUSTRE_RW_ATTR(max_dirty_mb);
181 LUSTRE_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL);
182 LUSTRE_RO_ATTR(conn_uuid);
184 LUSTRE_RW_ATTR(ping);
186 static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
188 struct obd_device *obd = m->private;
189 struct client_obd *cli = &obd->u.cli;
190 int shift = 20 - PAGE_SHIFT;
192 seq_printf(m, "used_mb: %ld\n"
195 (atomic_long_read(&cli->cl_lru_in_list) +
196 atomic_long_read(&cli->cl_lru_busy)) >> shift,
197 atomic_long_read(&cli->cl_lru_busy),
198 cli->cl_lru_reclaim);
203 /* shrink the number of caching pages to a specific number */
204 static ssize_t osc_cached_mb_seq_write(struct file *file,
205 const char __user *buffer,
206 size_t count, loff_t *off)
208 struct seq_file *m = file->private_data;
209 struct obd_device *obd = m->private;
210 struct client_obd *cli = &obd->u.cli;
216 if (count >= sizeof(kernbuf))
219 if (copy_from_user(kernbuf, buffer, count))
223 tmp = lprocfs_find_named_value(kernbuf, "used_mb:", &count);
224 rc = sysfs_memparse(tmp, count, &pages_number, "MiB");
228 pages_number >>= PAGE_SHIFT;
230 rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
235 env = cl_env_get(&refcheck);
237 (void)osc_lru_shrink(env, cli, rc, true);
238 cl_env_put(env, &refcheck);
245 LPROC_SEQ_FOPS(osc_cached_mb);
247 static ssize_t cur_dirty_bytes_show(struct kobject *kobj,
248 struct attribute *attr,
251 struct obd_device *obd = container_of(kobj, struct obd_device,
253 struct client_obd *cli = &obd->u.cli;
255 return scnprintf(buf, PAGE_SIZE, "%lu\n",
256 cli->cl_dirty_pages << PAGE_SHIFT);
258 LUSTRE_RO_ATTR(cur_dirty_bytes);
260 static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
262 struct obd_device *obd = m->private;
263 struct client_obd *cli = &obd->u.cli;
265 seq_printf(m, "%lu\n", cli->cl_avail_grant);
269 static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
270 const char __user *buffer,
271 size_t count, loff_t *off)
273 struct seq_file *m = file->private_data;
274 struct obd_device *obd = m->private;
275 struct client_obd *cli = &obd->u.cli;
276 struct obd_import *imp;
277 char kernbuf[22] = "";
284 if (count >= sizeof(kernbuf))
287 if (copy_from_user(kernbuf, buffer, count))
291 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
295 /* this is only for shrinking grant */
296 if (val >= cli->cl_avail_grant)
299 with_imp_locked(obd, imp, rc)
300 if (imp->imp_state == LUSTRE_IMP_FULL)
301 rc = osc_shrink_grant_to_target(cli, val);
303 return rc ? rc : count;
305 LPROC_SEQ_FOPS(osc_cur_grant_bytes);
307 static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj,
308 struct attribute *attr,
311 struct obd_device *obd = container_of(kobj, struct obd_device,
313 struct client_obd *cli = &obd->u.cli;
315 return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_lost_grant);
317 LUSTRE_RO_ATTR(cur_lost_grant_bytes);
319 static ssize_t cur_dirty_grant_bytes_show(struct kobject *kobj,
320 struct attribute *attr,
323 struct obd_device *obd = container_of(kobj, struct obd_device,
325 struct client_obd *cli = &obd->u.cli;
327 return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_dirty_grant);
329 LUSTRE_RO_ATTR(cur_dirty_grant_bytes);
331 static ssize_t grant_shrink_interval_show(struct kobject *kobj,
332 struct attribute *attr,
335 struct obd_device *obd = container_of(kobj, struct obd_device,
338 return sprintf(buf, "%lld\n", obd->u.cli.cl_grant_shrink_interval);
341 static ssize_t grant_shrink_interval_store(struct kobject *kobj,
342 struct attribute *attr,
346 struct obd_device *obd = container_of(kobj, struct obd_device,
351 rc = kstrtouint(buffer, 0, &val);
358 obd->u.cli.cl_grant_shrink_interval = val;
359 osc_update_next_shrink(&obd->u.cli);
360 osc_schedule_grant_work();
364 LUSTRE_RW_ATTR(grant_shrink_interval);
366 static ssize_t checksums_show(struct kobject *kobj,
367 struct attribute *attr,
370 struct obd_device *obd = container_of(kobj, struct obd_device,
373 return scnprintf(buf, PAGE_SIZE, "%d\n", !!obd->u.cli.cl_checksum);
376 static ssize_t checksums_store(struct kobject *kobj,
377 struct attribute *attr,
381 struct obd_device *obd = container_of(kobj, struct obd_device,
386 rc = kstrtobool(buffer, &val);
390 obd->u.cli.cl_checksum = val;
394 LUSTRE_RW_ATTR(checksums);
398 static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
400 struct obd_device *obd = m->private;
406 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
407 if ((BIT(i) & obd->u.cli.cl_supp_cksum_types) == 0)
409 if (obd->u.cli.cl_cksum_type == BIT(i))
410 seq_printf(m, "[%s] ", cksum_name[i]);
412 seq_printf(m, "%s ", cksum_name[i]);
419 static ssize_t osc_checksum_type_seq_write(struct file *file,
420 const char __user *buffer,
421 size_t count, loff_t *off)
423 struct seq_file *m = file->private_data;
424 struct obd_device *obd = m->private;
432 if (count > sizeof(kernbuf) - 1)
434 if (copy_from_user(kernbuf, buffer, count))
437 if (count > 0 && kernbuf[count - 1] == '\n')
438 kernbuf[count - 1] = '\0';
440 kernbuf[count] = '\0';
442 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
443 if (strcmp(kernbuf, cksum_name[i]) == 0) {
444 obd->u.cli.cl_preferred_cksum_type = BIT(i);
445 if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
446 obd->u.cli.cl_cksum_type = BIT(i);
456 LPROC_SEQ_FOPS(osc_checksum_type);
458 static ssize_t resend_count_show(struct kobject *kobj,
459 struct attribute *attr,
462 struct obd_device *obd = container_of(kobj, struct obd_device,
465 return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends));
468 static ssize_t resend_count_store(struct kobject *kobj,
469 struct attribute *attr,
473 struct obd_device *obd = container_of(kobj, struct obd_device,
478 rc = kstrtouint(buffer, 10, &val);
482 atomic_set(&obd->u.cli.cl_resends, val);
486 LUSTRE_RW_ATTR(resend_count);
488 static ssize_t checksum_dump_show(struct kobject *kobj,
489 struct attribute *attr,
492 struct obd_device *obd = container_of(kobj, struct obd_device,
495 return scnprintf(buf, PAGE_SIZE, "%d\n", !!obd->u.cli.cl_checksum_dump);
498 static ssize_t checksum_dump_store(struct kobject *kobj,
499 struct attribute *attr,
503 struct obd_device *obd = container_of(kobj, struct obd_device,
508 rc = kstrtobool(buffer, &val);
512 obd->u.cli.cl_checksum_dump = val;
516 LUSTRE_RW_ATTR(checksum_dump);
518 static ssize_t contention_seconds_show(struct kobject *kobj,
519 struct attribute *attr,
522 struct obd_device *obd = container_of(kobj, struct obd_device,
524 struct osc_device *od = obd2osc_dev(obd);
526 return sprintf(buf, "%lld\n", od->od_contention_time);
529 static ssize_t contention_seconds_store(struct kobject *kobj,
530 struct attribute *attr,
534 struct obd_device *obd = container_of(kobj, struct obd_device,
536 struct osc_device *od = obd2osc_dev(obd);
540 rc = kstrtouint(buffer, 0, &val);
544 od->od_contention_time = val;
548 LUSTRE_RW_ATTR(contention_seconds);
550 static ssize_t lockless_truncate_show(struct kobject *kobj,
551 struct attribute *attr,
554 struct obd_device *obd = container_of(kobj, struct obd_device,
556 struct osc_device *od = obd2osc_dev(obd);
558 return sprintf(buf, "%u\n", od->od_lockless_truncate);
561 static ssize_t lockless_truncate_store(struct kobject *kobj,
562 struct attribute *attr,
566 struct obd_device *obd = container_of(kobj, struct obd_device,
568 struct osc_device *od = obd2osc_dev(obd);
572 rc = kstrtobool(buffer, &val);
576 od->od_lockless_truncate = val;
580 LUSTRE_RW_ATTR(lockless_truncate);
582 static ssize_t destroys_in_flight_show(struct kobject *kobj,
583 struct attribute *attr,
586 struct obd_device *obd = container_of(kobj, struct obd_device,
589 return sprintf(buf, "%u\n",
590 atomic_read(&obd->u.cli.cl_destroy_in_flight));
592 LUSTRE_RO_ATTR(destroys_in_flight);
594 LPROC_SEQ_FOPS_RW_TYPE(osc, obd_max_pages_per_rpc);
596 LUSTRE_RW_ATTR(short_io_bytes);
598 #ifdef CONFIG_PROC_FS
599 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
601 struct obd_device *obd = m->private;
602 struct client_obd *cli = &obd->u.cli;
606 pages = atomic_long_read(&cli->cl_unstable_count);
607 mb = (pages * PAGE_SIZE) >> 20;
609 seq_printf(m, "unstable_pages: %20ld\n"
610 "unstable_mb: %10d\n",
614 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
616 static ssize_t idle_timeout_show(struct kobject *kobj, struct attribute *attr,
619 struct obd_device *obd = container_of(kobj, struct obd_device,
621 struct obd_import *imp;
624 with_imp_locked(obd, imp, ret)
625 ret = sprintf(buf, "%u\n", imp->imp_idle_timeout);
630 static ssize_t idle_timeout_store(struct kobject *kobj, struct attribute *attr,
631 const char *buffer, size_t count)
633 struct obd_device *obd = container_of(kobj, struct obd_device,
635 struct obd_import *imp;
636 struct ptlrpc_request *req;
637 unsigned int idle_debug = 0;
641 if (strncmp(buffer, "debug", 5) == 0) {
642 idle_debug = D_CONSOLE;
643 } else if (strncmp(buffer, "nodebug", 6) == 0) {
646 rc = kstrtouint(buffer, 10, &val);
650 if (val > CONNECTION_SWITCH_MAX)
654 with_imp_locked(obd, imp, rc) {
656 imp->imp_idle_debug = idle_debug;
659 /* initiate the connection if it's in IDLE state */
660 req = ptlrpc_request_alloc(imp,
663 ptlrpc_req_finished(req);
665 imp->imp_idle_timeout = val;
671 LUSTRE_RW_ATTR(idle_timeout);
673 static ssize_t idle_connect_store(struct kobject *kobj, struct attribute *attr,
674 const char *buffer, size_t count)
676 struct obd_device *obd = container_of(kobj, struct obd_device,
678 struct obd_import *imp;
679 struct ptlrpc_request *req;
682 with_imp_locked(obd, imp, rc) {
683 /* to initiate the connection if it's in IDLE state */
684 req = ptlrpc_request_alloc(imp, &RQF_OST_STATFS);
686 ptlrpc_req_finished(req);
687 ptlrpc_pinger_force(imp);
692 LUSTRE_WO_ATTR(idle_connect);
694 static ssize_t grant_shrink_show(struct kobject *kobj, struct attribute *attr,
697 struct obd_device *obd = container_of(kobj, struct obd_device,
699 struct obd_import *imp;
702 with_imp_locked(obd, imp, len)
703 len = scnprintf(buf, PAGE_SIZE, "%d\n",
704 !imp->imp_grant_shrink_disabled &&
705 OCD_HAS_FLAG(&imp->imp_connect_data,
711 static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
712 const char *buffer, size_t count)
714 struct obd_device *obd = container_of(kobj, struct obd_device,
716 struct obd_import *imp;
723 rc = kstrtobool(buffer, &val);
727 with_imp_locked(obd, imp, rc) {
728 spin_lock(&imp->imp_lock);
729 imp->imp_grant_shrink_disabled = !val;
730 spin_unlock(&imp->imp_lock);
735 LUSTRE_RW_ATTR(grant_shrink);
737 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
738 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
739 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
740 LPROC_SEQ_FOPS_RO_TYPE(osc, state);
742 LPROC_SEQ_FOPS_RW_TYPE(osc, import);
743 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
745 struct lprocfs_vars lprocfs_osc_obd_vars[] = {
746 { .name = "connect_flags",
747 .fops = &osc_connect_flags_fops },
748 { .name = "ost_server_uuid",
749 .fops = &osc_server_uuid_fops },
750 { .name = "max_pages_per_rpc",
751 .fops = &osc_obd_max_pages_per_rpc_fops },
752 { .name = "osc_cached_mb",
753 .fops = &osc_cached_mb_fops },
754 { .name = "cur_grant_bytes",
755 .fops = &osc_cur_grant_bytes_fops },
756 { .name = "checksum_type",
757 .fops = &osc_checksum_type_fops },
758 { .name = "timeouts",
759 .fops = &osc_timeouts_fops },
761 .fops = &osc_import_fops },
763 .fops = &osc_state_fops },
764 { .name = "pinger_recov",
765 .fops = &osc_pinger_recov_fops },
766 { .name = "unstable_stats",
767 .fops = &osc_unstable_stats_fops },
771 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
773 struct timespec64 now;
774 struct obd_device *obd = seq->private;
775 struct client_obd *cli = &obd->u.cli;
776 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
779 ktime_get_real_ts64(&now);
781 spin_lock(&cli->cl_loi_list_lock);
783 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
784 (s64)now.tv_sec, now.tv_nsec);
785 seq_printf(seq, "read RPCs in flight: %d\n",
786 cli->cl_r_in_flight);
787 seq_printf(seq, "write RPCs in flight: %d\n",
788 cli->cl_w_in_flight);
789 seq_printf(seq, "pending write pages: %d\n",
790 atomic_read(&cli->cl_pending_w_pages));
791 seq_printf(seq, "pending read pages: %d\n",
792 atomic_read(&cli->cl_pending_r_pages));
794 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
795 seq_printf(seq, "pages per rpc rpcs %% cum %% |");
796 seq_printf(seq, " rpcs %% cum %%\n");
798 read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
799 write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
803 for (i = 0; i < OBD_HIST_MAX; i++) {
804 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
805 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
809 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
810 1 << i, r, pct(r, read_tot),
811 pct(read_cum, read_tot), w,
813 pct(write_cum, write_tot));
814 if (read_cum == read_tot && write_cum == write_tot)
818 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
819 seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
820 seq_printf(seq, " rpcs %% cum %%\n");
822 read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
823 write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
827 for (i = 1; i < OBD_HIST_MAX; i++) {
828 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
829 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
832 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
833 i, r, pct(r, read_tot),
834 pct(read_cum, read_tot), w,
836 pct(write_cum, write_tot));
837 if (read_cum == read_tot && write_cum == write_tot)
841 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
842 seq_printf(seq, "offset rpcs %% cum %% |");
843 seq_printf(seq, " rpcs %% cum %%\n");
845 read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
846 write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
850 for (i = 0; i < OBD_HIST_MAX; i++) {
851 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
852 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
855 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
856 (i == 0) ? 0 : 1 << (i - 1),
857 r, pct(r, read_tot), pct(read_cum, read_tot),
858 w, pct(w, write_tot), pct(write_cum, write_tot));
859 if (read_cum == read_tot && write_cum == write_tot)
863 spin_unlock(&cli->cl_loi_list_lock);
868 static ssize_t osc_rpc_stats_seq_write(struct file *file,
869 const char __user *buf,
870 size_t len, loff_t *off)
872 struct seq_file *seq = file->private_data;
873 struct obd_device *obd = seq->private;
874 struct client_obd *cli = &obd->u.cli;
876 lprocfs_oh_clear(&cli->cl_read_rpc_hist);
877 lprocfs_oh_clear(&cli->cl_write_rpc_hist);
878 lprocfs_oh_clear(&cli->cl_read_page_hist);
879 lprocfs_oh_clear(&cli->cl_write_page_hist);
880 lprocfs_oh_clear(&cli->cl_read_offset_hist);
881 lprocfs_oh_clear(&cli->cl_write_offset_hist);
885 LPROC_SEQ_FOPS(osc_rpc_stats);
887 static int osc_stats_seq_show(struct seq_file *seq, void *v)
889 struct timespec64 now;
890 struct obd_device *obd = seq->private;
891 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
893 ktime_get_real_ts64(&now);
895 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
896 (s64)now.tv_sec, now.tv_nsec);
897 seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
898 stats->os_lockless_writes);
899 seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
900 stats->os_lockless_reads);
901 seq_printf(seq, "lockless_truncate\t\t%llu\n",
902 stats->os_lockless_truncates);
906 static ssize_t osc_stats_seq_write(struct file *file,
907 const char __user *buf,
908 size_t len, loff_t *off)
910 struct seq_file *seq = file->private_data;
911 struct obd_device *obd = seq->private;
912 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
914 memset(stats, 0, sizeof(*stats));
918 LPROC_SEQ_FOPS(osc_stats);
920 int lprocfs_osc_attach_seqstat(struct obd_device *obd)
924 rc = lprocfs_seq_create(obd->obd_proc_entry, "osc_stats", 0644,
925 &osc_stats_fops, obd);
927 rc = lprocfs_obd_seq_create(obd, "rpc_stats", 0644,
928 &osc_rpc_stats_fops, obd);
932 #endif /* CONFIG_PROC_FS */
934 static struct attribute *osc_attrs[] = {
935 &lustre_attr_active.attr,
936 &lustre_attr_checksums.attr,
937 &lustre_attr_checksum_dump.attr,
938 &lustre_attr_contention_seconds.attr,
939 &lustre_attr_cur_dirty_bytes.attr,
940 &lustre_attr_cur_lost_grant_bytes.attr,
941 &lustre_attr_cur_dirty_grant_bytes.attr,
942 &lustre_attr_destroys_in_flight.attr,
943 &lustre_attr_grant_shrink_interval.attr,
944 &lustre_attr_lockless_truncate.attr,
945 &lustre_attr_max_dirty_mb.attr,
946 &lustre_attr_max_rpcs_in_flight.attr,
947 &lustre_attr_short_io_bytes.attr,
948 &lustre_attr_resend_count.attr,
949 &lustre_attr_ost_conn_uuid.attr,
950 &lustre_attr_conn_uuid.attr,
951 &lustre_attr_ping.attr,
952 &lustre_attr_idle_timeout.attr,
953 &lustre_attr_idle_connect.attr,
954 &lustre_attr_grant_shrink.attr,
958 int osc_tunables_init(struct obd_device *obd)
962 obd->obd_vars = lprocfs_osc_obd_vars;
963 obd->obd_ktype.default_attrs = osc_attrs;
964 rc = lprocfs_obd_setup(obd, false);
967 #ifdef CONFIG_PROC_FS
968 /* If the basic OSC proc tree construction succeeded then
971 rc = lprocfs_osc_attach_seqstat(obd);
975 #endif /* CONFIG_PROC_FS */
976 rc = sptlrpc_lprocfs_cliobd_attach(obd);
980 ptlrpc_lprocfs_register_obd(obd);
983 lprocfs_obd_cleanup(obd);