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;
89 return scnprintf(buf, PAGE_SIZE, "%u\n", cli->cl_max_rpcs_in_flight);
92 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
93 struct attribute *attr,
97 struct obd_device *obd = container_of(kobj, struct obd_device,
99 struct client_obd *cli = &obd->u.cli;
100 int adding, added, req_count;
104 rc = kstrtouint(buffer, 0, &val);
108 if (val == 0 || val > OSC_MAX_RIF_MAX)
111 adding = (int)val - cli->cl_max_rpcs_in_flight;
112 req_count = atomic_read(&osc_pool_req_count);
113 if (adding > 0 && req_count < osc_reqpool_maxreqcount) {
115 * There might be some race which will cause over-limit
116 * allocation, but it is fine.
118 if (req_count + adding > osc_reqpool_maxreqcount)
119 adding = osc_reqpool_maxreqcount - req_count;
121 added = osc_rq_pool->prp_populate(osc_rq_pool, adding);
122 atomic_add(added, &osc_pool_req_count);
125 spin_lock(&cli->cl_loi_list_lock);
126 cli->cl_max_rpcs_in_flight = val;
127 client_adjust_max_dirty(cli);
128 spin_unlock(&cli->cl_loi_list_lock);
132 LUSTRE_RW_ATTR(max_rpcs_in_flight);
134 static ssize_t max_dirty_mb_show(struct kobject *kobj,
135 struct attribute *attr,
138 struct obd_device *obd = container_of(kobj, struct obd_device,
140 struct client_obd *cli = &obd->u.cli;
142 return scnprintf(buf, PAGE_SIZE, "%lu\n",
143 PAGES_TO_MiB(cli->cl_dirty_max_pages));
146 static ssize_t max_dirty_mb_store(struct kobject *kobj,
147 struct attribute *attr,
151 struct obd_device *obd = container_of(kobj, struct obd_device,
153 struct client_obd *cli = &obd->u.cli;
154 unsigned long pages_number, max_dirty_mb;
157 rc = kstrtoul(buffer, 10, &max_dirty_mb);
161 pages_number = MiB_TO_PAGES(max_dirty_mb);
163 if (pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) ||
164 pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */
167 spin_lock(&cli->cl_loi_list_lock);
168 cli->cl_dirty_max_pages = pages_number;
169 osc_wake_cache_waiters(cli);
170 spin_unlock(&cli->cl_loi_list_lock);
174 LUSTRE_RW_ATTR(max_dirty_mb);
176 LUSTRE_ATTR(ost_conn_uuid, 0444, conn_uuid_show, NULL);
177 LUSTRE_RO_ATTR(conn_uuid);
179 LUSTRE_RW_ATTR(ping);
181 static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
183 struct obd_device *obd = m->private;
184 struct client_obd *cli = &obd->u.cli;
185 int shift = 20 - PAGE_SHIFT;
187 seq_printf(m, "used_mb: %ld\n"
190 (atomic_long_read(&cli->cl_lru_in_list) +
191 atomic_long_read(&cli->cl_lru_busy)) >> shift,
192 atomic_long_read(&cli->cl_lru_busy),
193 cli->cl_lru_reclaim);
198 /* shrink the number of caching pages to a specific number */
199 static ssize_t osc_cached_mb_seq_write(struct file *file,
200 const char __user *buffer,
201 size_t count, loff_t *off)
203 struct seq_file *m = file->private_data;
204 struct obd_device *obd = m->private;
205 struct client_obd *cli = &obd->u.cli;
211 if (count >= sizeof(kernbuf))
214 if (copy_from_user(kernbuf, buffer, count))
218 tmp = lprocfs_find_named_value(kernbuf, "used_mb:", &count);
219 rc = sysfs_memparse(tmp, count, &pages_number, "MiB");
223 pages_number >>= PAGE_SHIFT;
225 rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
230 env = cl_env_get(&refcheck);
232 (void)osc_lru_shrink(env, cli, rc, true);
233 cl_env_put(env, &refcheck);
240 LPROC_SEQ_FOPS(osc_cached_mb);
242 static ssize_t cur_dirty_bytes_show(struct kobject *kobj,
243 struct attribute *attr,
246 struct obd_device *obd = container_of(kobj, struct obd_device,
248 struct client_obd *cli = &obd->u.cli;
250 return scnprintf(buf, PAGE_SIZE, "%lu\n",
251 cli->cl_dirty_pages << PAGE_SHIFT);
253 LUSTRE_RO_ATTR(cur_dirty_bytes);
255 static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
257 struct obd_device *obd = m->private;
258 struct client_obd *cli = &obd->u.cli;
260 seq_printf(m, "%lu\n", cli->cl_avail_grant);
264 static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
265 const char __user *buffer,
266 size_t count, loff_t *off)
268 struct seq_file *m = file->private_data;
269 struct obd_device *obd = m->private;
270 struct client_obd *cli = &obd->u.cli;
271 struct obd_import *imp;
272 char kernbuf[22] = "";
279 if (count >= sizeof(kernbuf))
282 if (copy_from_user(kernbuf, buffer, count))
286 rc = sysfs_memparse(kernbuf, count, &val, "MiB");
290 /* this is only for shrinking grant */
291 if (val >= cli->cl_avail_grant)
294 with_imp_locked(obd, imp, rc)
295 if (imp->imp_state == LUSTRE_IMP_FULL)
296 rc = osc_shrink_grant_to_target(cli, val);
298 return rc ? rc : count;
300 LPROC_SEQ_FOPS(osc_cur_grant_bytes);
302 static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj,
303 struct attribute *attr,
306 struct obd_device *obd = container_of(kobj, struct obd_device,
308 struct client_obd *cli = &obd->u.cli;
310 return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_lost_grant);
312 LUSTRE_RO_ATTR(cur_lost_grant_bytes);
314 static ssize_t cur_dirty_grant_bytes_show(struct kobject *kobj,
315 struct attribute *attr,
318 struct obd_device *obd = container_of(kobj, struct obd_device,
320 struct client_obd *cli = &obd->u.cli;
322 return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_dirty_grant);
324 LUSTRE_RO_ATTR(cur_dirty_grant_bytes);
326 static ssize_t grant_shrink_interval_show(struct kobject *kobj,
327 struct attribute *attr,
330 struct obd_device *obd = container_of(kobj, struct obd_device,
333 return sprintf(buf, "%lld\n", obd->u.cli.cl_grant_shrink_interval);
336 static ssize_t grant_shrink_interval_store(struct kobject *kobj,
337 struct attribute *attr,
341 struct obd_device *obd = container_of(kobj, struct obd_device,
346 rc = kstrtouint(buffer, 0, &val);
353 obd->u.cli.cl_grant_shrink_interval = val;
354 osc_update_next_shrink(&obd->u.cli);
355 osc_schedule_grant_work();
359 LUSTRE_RW_ATTR(grant_shrink_interval);
361 static ssize_t checksums_show(struct kobject *kobj,
362 struct attribute *attr,
365 struct obd_device *obd = container_of(kobj, struct obd_device,
368 return scnprintf(buf, PAGE_SIZE, "%d\n", !!obd->u.cli.cl_checksum);
371 static ssize_t checksums_store(struct kobject *kobj,
372 struct attribute *attr,
376 struct obd_device *obd = container_of(kobj, struct obd_device,
381 rc = kstrtobool(buffer, &val);
385 obd->u.cli.cl_checksum = val;
389 LUSTRE_RW_ATTR(checksums);
393 static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
395 struct obd_device *obd = m->private;
401 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
402 if ((BIT(i) & obd->u.cli.cl_supp_cksum_types) == 0)
404 if (obd->u.cli.cl_cksum_type == BIT(i))
405 seq_printf(m, "[%s] ", cksum_name[i]);
407 seq_printf(m, "%s ", cksum_name[i]);
414 static ssize_t osc_checksum_type_seq_write(struct file *file,
415 const char __user *buffer,
416 size_t count, loff_t *off)
418 struct seq_file *m = file->private_data;
419 struct obd_device *obd = m->private;
427 if (count > sizeof(kernbuf) - 1)
429 if (copy_from_user(kernbuf, buffer, count))
432 if (count > 0 && kernbuf[count - 1] == '\n')
433 kernbuf[count - 1] = '\0';
435 kernbuf[count] = '\0';
437 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
438 if (strcmp(kernbuf, cksum_name[i]) == 0) {
439 obd->u.cli.cl_preferred_cksum_type = BIT(i);
440 if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
441 obd->u.cli.cl_cksum_type = BIT(i);
451 LPROC_SEQ_FOPS(osc_checksum_type);
453 static ssize_t resend_count_show(struct kobject *kobj,
454 struct attribute *attr,
457 struct obd_device *obd = container_of(kobj, struct obd_device,
460 return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends));
463 static ssize_t resend_count_store(struct kobject *kobj,
464 struct attribute *attr,
468 struct obd_device *obd = container_of(kobj, struct obd_device,
473 rc = kstrtouint(buffer, 10, &val);
477 atomic_set(&obd->u.cli.cl_resends, val);
481 LUSTRE_RW_ATTR(resend_count);
483 static ssize_t checksum_dump_show(struct kobject *kobj,
484 struct attribute *attr,
487 struct obd_device *obd = container_of(kobj, struct obd_device,
490 return scnprintf(buf, PAGE_SIZE, "%d\n", !!obd->u.cli.cl_checksum_dump);
493 static ssize_t checksum_dump_store(struct kobject *kobj,
494 struct attribute *attr,
498 struct obd_device *obd = container_of(kobj, struct obd_device,
503 rc = kstrtobool(buffer, &val);
507 obd->u.cli.cl_checksum_dump = val;
511 LUSTRE_RW_ATTR(checksum_dump);
513 static ssize_t contention_seconds_show(struct kobject *kobj,
514 struct attribute *attr,
517 struct obd_device *obd = container_of(kobj, struct obd_device,
519 struct osc_device *od = obd2osc_dev(obd);
521 return sprintf(buf, "%lld\n", od->od_contention_time);
524 static ssize_t contention_seconds_store(struct kobject *kobj,
525 struct attribute *attr,
529 struct obd_device *obd = container_of(kobj, struct obd_device,
531 struct osc_device *od = obd2osc_dev(obd);
535 rc = kstrtouint(buffer, 0, &val);
539 od->od_contention_time = val;
543 LUSTRE_RW_ATTR(contention_seconds);
545 static ssize_t lockless_truncate_show(struct kobject *kobj,
546 struct attribute *attr,
549 struct obd_device *obd = container_of(kobj, struct obd_device,
551 struct osc_device *od = obd2osc_dev(obd);
553 return sprintf(buf, "%u\n", od->od_lockless_truncate);
556 static ssize_t lockless_truncate_store(struct kobject *kobj,
557 struct attribute *attr,
561 struct obd_device *obd = container_of(kobj, struct obd_device,
563 struct osc_device *od = obd2osc_dev(obd);
567 rc = kstrtobool(buffer, &val);
571 od->od_lockless_truncate = val;
575 LUSTRE_RW_ATTR(lockless_truncate);
577 static ssize_t destroys_in_flight_show(struct kobject *kobj,
578 struct attribute *attr,
581 struct obd_device *obd = container_of(kobj, struct obd_device,
584 return sprintf(buf, "%u\n",
585 atomic_read(&obd->u.cli.cl_destroy_in_flight));
587 LUSTRE_RO_ATTR(destroys_in_flight);
589 LPROC_SEQ_FOPS_RW_TYPE(osc, obd_max_pages_per_rpc);
591 LUSTRE_RW_ATTR(short_io_bytes);
593 #ifdef CONFIG_PROC_FS
594 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
596 struct obd_device *obd = m->private;
597 struct client_obd *cli = &obd->u.cli;
601 pages = atomic_long_read(&cli->cl_unstable_count);
602 mb = (pages * PAGE_SIZE) >> 20;
604 seq_printf(m, "unstable_pages: %20ld\n"
605 "unstable_mb: %10d\n",
609 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
611 static ssize_t idle_timeout_show(struct kobject *kobj, struct attribute *attr,
614 struct obd_device *obd = container_of(kobj, struct obd_device,
616 struct obd_import *imp;
619 with_imp_locked(obd, imp, ret)
620 ret = sprintf(buf, "%u\n", imp->imp_idle_timeout);
625 static ssize_t idle_timeout_store(struct kobject *kobj, struct attribute *attr,
626 const char *buffer, size_t count)
628 struct obd_device *obd = container_of(kobj, struct obd_device,
630 struct obd_import *imp;
631 struct ptlrpc_request *req;
632 unsigned int idle_debug = 0;
636 if (strncmp(buffer, "debug", 5) == 0) {
637 idle_debug = D_CONSOLE;
638 } else if (strncmp(buffer, "nodebug", 6) == 0) {
641 rc = kstrtouint(buffer, 10, &val);
645 if (val > CONNECTION_SWITCH_MAX)
649 with_imp_locked(obd, imp, rc) {
651 imp->imp_idle_debug = idle_debug;
654 /* initiate the connection if it's in IDLE state */
655 req = ptlrpc_request_alloc(imp,
658 ptlrpc_req_finished(req);
660 imp->imp_idle_timeout = val;
666 LUSTRE_RW_ATTR(idle_timeout);
668 static ssize_t idle_connect_store(struct kobject *kobj, struct attribute *attr,
669 const char *buffer, size_t count)
671 struct obd_device *obd = container_of(kobj, struct obd_device,
673 struct obd_import *imp;
674 struct ptlrpc_request *req;
677 with_imp_locked(obd, imp, rc) {
678 /* to initiate the connection if it's in IDLE state */
679 req = ptlrpc_request_alloc(imp, &RQF_OST_STATFS);
681 ptlrpc_req_finished(req);
682 ptlrpc_pinger_force(imp);
687 LUSTRE_WO_ATTR(idle_connect);
689 static ssize_t grant_shrink_show(struct kobject *kobj, struct attribute *attr,
692 struct obd_device *obd = container_of(kobj, struct obd_device,
694 struct obd_import *imp;
697 with_imp_locked(obd, imp, len)
698 len = scnprintf(buf, PAGE_SIZE, "%d\n",
699 !imp->imp_grant_shrink_disabled &&
700 OCD_HAS_FLAG(&imp->imp_connect_data,
706 static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
707 const char *buffer, size_t count)
709 struct obd_device *obd = container_of(kobj, struct obd_device,
711 struct obd_import *imp;
718 rc = kstrtobool(buffer, &val);
722 with_imp_locked(obd, imp, rc) {
723 spin_lock(&imp->imp_lock);
724 imp->imp_grant_shrink_disabled = !val;
725 spin_unlock(&imp->imp_lock);
730 LUSTRE_RW_ATTR(grant_shrink);
732 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
733 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
734 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
735 LPROC_SEQ_FOPS_RO_TYPE(osc, state);
737 LPROC_SEQ_FOPS_RW_TYPE(osc, import);
738 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
740 struct lprocfs_vars lprocfs_osc_obd_vars[] = {
741 { .name = "connect_flags",
742 .fops = &osc_connect_flags_fops },
743 { .name = "ost_server_uuid",
744 .fops = &osc_server_uuid_fops },
745 { .name = "max_pages_per_rpc",
746 .fops = &osc_obd_max_pages_per_rpc_fops },
747 { .name = "osc_cached_mb",
748 .fops = &osc_cached_mb_fops },
749 { .name = "cur_grant_bytes",
750 .fops = &osc_cur_grant_bytes_fops },
751 { .name = "checksum_type",
752 .fops = &osc_checksum_type_fops },
753 { .name = "timeouts",
754 .fops = &osc_timeouts_fops },
756 .fops = &osc_import_fops },
758 .fops = &osc_state_fops },
759 { .name = "pinger_recov",
760 .fops = &osc_pinger_recov_fops },
761 { .name = "unstable_stats",
762 .fops = &osc_unstable_stats_fops },
766 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
768 struct timespec64 now;
769 struct obd_device *obd = seq->private;
770 struct client_obd *cli = &obd->u.cli;
771 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
774 ktime_get_real_ts64(&now);
776 spin_lock(&cli->cl_loi_list_lock);
778 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
779 (s64)now.tv_sec, now.tv_nsec);
780 seq_printf(seq, "read RPCs in flight: %d\n",
781 cli->cl_r_in_flight);
782 seq_printf(seq, "write RPCs in flight: %d\n",
783 cli->cl_w_in_flight);
784 seq_printf(seq, "pending write pages: %d\n",
785 atomic_read(&cli->cl_pending_w_pages));
786 seq_printf(seq, "pending read pages: %d\n",
787 atomic_read(&cli->cl_pending_r_pages));
789 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
790 seq_printf(seq, "pages per rpc rpcs %% cum %% |");
791 seq_printf(seq, " rpcs %% cum %%\n");
793 read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
794 write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
798 for (i = 0; i < OBD_HIST_MAX; i++) {
799 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
800 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
804 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
805 1 << i, r, pct(r, read_tot),
806 pct(read_cum, read_tot), w,
808 pct(write_cum, write_tot));
809 if (read_cum == read_tot && write_cum == write_tot)
813 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
814 seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
815 seq_printf(seq, " rpcs %% cum %%\n");
817 read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
818 write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
822 for (i = 1; i < OBD_HIST_MAX; i++) {
823 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
824 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
827 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
828 i, r, pct(r, read_tot),
829 pct(read_cum, read_tot), w,
831 pct(write_cum, write_tot));
832 if (read_cum == read_tot && write_cum == write_tot)
836 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
837 seq_printf(seq, "offset rpcs %% cum %% |");
838 seq_printf(seq, " rpcs %% cum %%\n");
840 read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
841 write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
845 for (i = 0; i < OBD_HIST_MAX; i++) {
846 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
847 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
850 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
851 (i == 0) ? 0 : 1 << (i - 1),
852 r, pct(r, read_tot), pct(read_cum, read_tot),
853 w, pct(w, write_tot), pct(write_cum, write_tot));
854 if (read_cum == read_tot && write_cum == write_tot)
858 spin_unlock(&cli->cl_loi_list_lock);
863 static ssize_t osc_rpc_stats_seq_write(struct file *file,
864 const char __user *buf,
865 size_t len, loff_t *off)
867 struct seq_file *seq = file->private_data;
868 struct obd_device *obd = seq->private;
869 struct client_obd *cli = &obd->u.cli;
871 lprocfs_oh_clear(&cli->cl_read_rpc_hist);
872 lprocfs_oh_clear(&cli->cl_write_rpc_hist);
873 lprocfs_oh_clear(&cli->cl_read_page_hist);
874 lprocfs_oh_clear(&cli->cl_write_page_hist);
875 lprocfs_oh_clear(&cli->cl_read_offset_hist);
876 lprocfs_oh_clear(&cli->cl_write_offset_hist);
880 LPROC_SEQ_FOPS(osc_rpc_stats);
882 static int osc_stats_seq_show(struct seq_file *seq, void *v)
884 struct timespec64 now;
885 struct obd_device *obd = seq->private;
886 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
888 ktime_get_real_ts64(&now);
890 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
891 (s64)now.tv_sec, now.tv_nsec);
892 seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
893 stats->os_lockless_writes);
894 seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
895 stats->os_lockless_reads);
896 seq_printf(seq, "lockless_truncate\t\t%llu\n",
897 stats->os_lockless_truncates);
901 static ssize_t osc_stats_seq_write(struct file *file,
902 const char __user *buf,
903 size_t len, loff_t *off)
905 struct seq_file *seq = file->private_data;
906 struct obd_device *obd = seq->private;
907 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
909 memset(stats, 0, sizeof(*stats));
913 LPROC_SEQ_FOPS(osc_stats);
915 int lprocfs_osc_attach_seqstat(struct obd_device *obd)
919 rc = lprocfs_seq_create(obd->obd_proc_entry, "osc_stats", 0644,
920 &osc_stats_fops, obd);
922 rc = lprocfs_obd_seq_create(obd, "rpc_stats", 0644,
923 &osc_rpc_stats_fops, obd);
927 #endif /* CONFIG_PROC_FS */
929 static struct attribute *osc_attrs[] = {
930 &lustre_attr_active.attr,
931 &lustre_attr_checksums.attr,
932 &lustre_attr_checksum_dump.attr,
933 &lustre_attr_contention_seconds.attr,
934 &lustre_attr_cur_dirty_bytes.attr,
935 &lustre_attr_cur_lost_grant_bytes.attr,
936 &lustre_attr_cur_dirty_grant_bytes.attr,
937 &lustre_attr_destroys_in_flight.attr,
938 &lustre_attr_grant_shrink_interval.attr,
939 &lustre_attr_lockless_truncate.attr,
940 &lustre_attr_max_dirty_mb.attr,
941 &lustre_attr_max_rpcs_in_flight.attr,
942 &lustre_attr_short_io_bytes.attr,
943 &lustre_attr_resend_count.attr,
944 &lustre_attr_ost_conn_uuid.attr,
945 &lustre_attr_conn_uuid.attr,
946 &lustre_attr_ping.attr,
947 &lustre_attr_idle_timeout.attr,
948 &lustre_attr_idle_connect.attr,
949 &lustre_attr_grant_shrink.attr,
953 int osc_tunables_init(struct obd_device *obd)
957 obd->obd_vars = lprocfs_osc_obd_vars;
958 obd->obd_ktype.default_attrs = osc_attrs;
959 rc = lprocfs_obd_setup(obd, false);
962 #ifdef CONFIG_PROC_FS
963 /* If the basic OSC proc tree construction succeeded then
966 rc = lprocfs_osc_attach_seqstat(obd);
970 #endif /* CONFIG_PROC_FS */
971 rc = sptlrpc_lprocfs_cliobd_attach(obd);
975 ptlrpc_lprocfs_register_obd(obd);
978 lprocfs_obd_cleanup(obd);