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 sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
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);
391 static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
393 struct obd_device *obd = m->private;
400 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
401 if ((BIT(i) & obd->u.cli.cl_supp_cksum_types) == 0)
403 if (obd->u.cli.cl_cksum_type == BIT(i))
404 seq_printf(m, "[%s] ", cksum_name[i]);
406 seq_printf(m, "%s ", cksum_name[i]);
412 static ssize_t osc_checksum_type_seq_write(struct file *file,
413 const char __user *buffer,
414 size_t count, loff_t *off)
416 struct seq_file *m = file->private_data;
417 struct obd_device *obd = m->private;
426 if (count > sizeof(kernbuf) - 1)
428 if (copy_from_user(kernbuf, buffer, count))
431 if (count > 0 && kernbuf[count - 1] == '\n')
432 kernbuf[count - 1] = '\0';
434 kernbuf[count] = '\0';
436 for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
437 if (strcmp(kernbuf, cksum_name[i]) == 0) {
438 obd->u.cli.cl_preferred_cksum_type = BIT(i);
439 if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
440 obd->u.cli.cl_cksum_type = BIT(i);
450 LPROC_SEQ_FOPS(osc_checksum_type);
452 static ssize_t resend_count_show(struct kobject *kobj,
453 struct attribute *attr,
456 struct obd_device *obd = container_of(kobj, struct obd_device,
459 return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends));
462 static ssize_t resend_count_store(struct kobject *kobj,
463 struct attribute *attr,
467 struct obd_device *obd = container_of(kobj, struct obd_device,
472 rc = kstrtouint(buffer, 10, &val);
476 atomic_set(&obd->u.cli.cl_resends, val);
480 LUSTRE_RW_ATTR(resend_count);
482 static ssize_t checksum_dump_show(struct kobject *kobj,
483 struct attribute *attr,
486 struct obd_device *obd = container_of(kobj, struct obd_device,
489 return sprintf(buf, "%d\n", obd->u.cli.cl_checksum_dump ? 1 : 0);
492 static ssize_t checksum_dump_store(struct kobject *kobj,
493 struct attribute *attr,
497 struct obd_device *obd = container_of(kobj, struct obd_device,
502 rc = kstrtobool(buffer, &val);
506 obd->u.cli.cl_checksum_dump = val;
510 LUSTRE_RW_ATTR(checksum_dump);
512 static ssize_t contention_seconds_show(struct kobject *kobj,
513 struct attribute *attr,
516 struct obd_device *obd = container_of(kobj, struct obd_device,
518 struct osc_device *od = obd2osc_dev(obd);
520 return sprintf(buf, "%lld\n", od->od_contention_time);
523 static ssize_t contention_seconds_store(struct kobject *kobj,
524 struct attribute *attr,
528 struct obd_device *obd = container_of(kobj, struct obd_device,
530 struct osc_device *od = obd2osc_dev(obd);
534 rc = kstrtouint(buffer, 0, &val);
538 od->od_contention_time = val;
542 LUSTRE_RW_ATTR(contention_seconds);
544 static ssize_t lockless_truncate_show(struct kobject *kobj,
545 struct attribute *attr,
548 struct obd_device *obd = container_of(kobj, struct obd_device,
550 struct osc_device *od = obd2osc_dev(obd);
552 return sprintf(buf, "%u\n", od->od_lockless_truncate);
555 static ssize_t lockless_truncate_store(struct kobject *kobj,
556 struct attribute *attr,
560 struct obd_device *obd = container_of(kobj, struct obd_device,
562 struct osc_device *od = obd2osc_dev(obd);
566 rc = kstrtobool(buffer, &val);
570 od->od_lockless_truncate = val;
574 LUSTRE_RW_ATTR(lockless_truncate);
576 static ssize_t destroys_in_flight_show(struct kobject *kobj,
577 struct attribute *attr,
580 struct obd_device *obd = container_of(kobj, struct obd_device,
583 return sprintf(buf, "%u\n",
584 atomic_read(&obd->u.cli.cl_destroy_in_flight));
586 LUSTRE_RO_ATTR(destroys_in_flight);
588 LPROC_SEQ_FOPS_RW_TYPE(osc, obd_max_pages_per_rpc);
590 LUSTRE_RW_ATTR(short_io_bytes);
592 #ifdef CONFIG_PROC_FS
593 static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
595 struct obd_device *obd = m->private;
596 struct client_obd *cli = &obd->u.cli;
600 pages = atomic_long_read(&cli->cl_unstable_count);
601 mb = (pages * PAGE_SIZE) >> 20;
603 seq_printf(m, "unstable_pages: %20ld\n"
604 "unstable_mb: %10d\n",
608 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
610 static ssize_t idle_timeout_show(struct kobject *kobj, struct attribute *attr,
613 struct obd_device *obd = container_of(kobj, struct obd_device,
615 struct obd_import *imp;
618 with_imp_locked(obd, imp, ret)
619 ret = sprintf(buf, "%u\n", imp->imp_idle_timeout);
624 static ssize_t idle_timeout_store(struct kobject *kobj, struct attribute *attr,
625 const char *buffer, size_t count)
627 struct obd_device *obd = container_of(kobj, struct obd_device,
629 struct obd_import *imp;
630 struct ptlrpc_request *req;
631 unsigned int idle_debug = 0;
635 if (strncmp(buffer, "debug", 5) == 0) {
636 idle_debug = D_CONSOLE;
637 } else if (strncmp(buffer, "nodebug", 6) == 0) {
640 rc = kstrtouint(buffer, 10, &val);
644 if (val > CONNECTION_SWITCH_MAX)
648 with_imp_locked(obd, imp, rc) {
650 imp->imp_idle_debug = idle_debug;
653 /* initiate the connection if it's in IDLE state */
654 req = ptlrpc_request_alloc(imp,
657 ptlrpc_req_finished(req);
659 imp->imp_idle_timeout = val;
665 LUSTRE_RW_ATTR(idle_timeout);
667 static ssize_t idle_connect_store(struct kobject *kobj, struct attribute *attr,
668 const char *buffer, size_t count)
670 struct obd_device *obd = container_of(kobj, struct obd_device,
672 struct obd_import *imp;
673 struct ptlrpc_request *req;
676 with_imp_locked(obd, imp, rc) {
677 /* to initiate the connection if it's in IDLE state */
678 req = ptlrpc_request_alloc(imp, &RQF_OST_STATFS);
680 ptlrpc_req_finished(req);
681 ptlrpc_pinger_force(imp);
686 LUSTRE_WO_ATTR(idle_connect);
688 static ssize_t grant_shrink_show(struct kobject *kobj, struct attribute *attr,
691 struct obd_device *obd = container_of(kobj, struct obd_device,
693 struct obd_import *imp;
696 with_imp_locked(obd, imp, len)
697 len = scnprintf(buf, PAGE_SIZE, "%d\n",
698 !imp->imp_grant_shrink_disabled &&
699 OCD_HAS_FLAG(&imp->imp_connect_data,
705 static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
706 const char *buffer, size_t count)
708 struct obd_device *obd = container_of(kobj, struct obd_device,
710 struct obd_import *imp;
717 rc = kstrtobool(buffer, &val);
721 with_imp_locked(obd, imp, rc) {
722 spin_lock(&imp->imp_lock);
723 imp->imp_grant_shrink_disabled = !val;
724 spin_unlock(&imp->imp_lock);
729 LUSTRE_RW_ATTR(grant_shrink);
731 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
732 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
733 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
734 LPROC_SEQ_FOPS_RO_TYPE(osc, state);
736 LPROC_SEQ_FOPS_RW_TYPE(osc, import);
737 LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
739 struct lprocfs_vars lprocfs_osc_obd_vars[] = {
740 { .name = "connect_flags",
741 .fops = &osc_connect_flags_fops },
742 { .name = "ost_server_uuid",
743 .fops = &osc_server_uuid_fops },
744 { .name = "max_pages_per_rpc",
745 .fops = &osc_obd_max_pages_per_rpc_fops },
746 { .name = "osc_cached_mb",
747 .fops = &osc_cached_mb_fops },
748 { .name = "cur_grant_bytes",
749 .fops = &osc_cur_grant_bytes_fops },
750 { .name = "checksum_type",
751 .fops = &osc_checksum_type_fops },
752 { .name = "timeouts",
753 .fops = &osc_timeouts_fops },
755 .fops = &osc_import_fops },
757 .fops = &osc_state_fops },
758 { .name = "pinger_recov",
759 .fops = &osc_pinger_recov_fops },
760 { .name = "unstable_stats",
761 .fops = &osc_unstable_stats_fops },
765 static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
767 struct timespec64 now;
768 struct obd_device *obd = seq->private;
769 struct client_obd *cli = &obd->u.cli;
770 unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
773 ktime_get_real_ts64(&now);
775 spin_lock(&cli->cl_loi_list_lock);
777 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
778 (s64)now.tv_sec, now.tv_nsec);
779 seq_printf(seq, "read RPCs in flight: %d\n",
780 cli->cl_r_in_flight);
781 seq_printf(seq, "write RPCs in flight: %d\n",
782 cli->cl_w_in_flight);
783 seq_printf(seq, "pending write pages: %d\n",
784 atomic_read(&cli->cl_pending_w_pages));
785 seq_printf(seq, "pending read pages: %d\n",
786 atomic_read(&cli->cl_pending_r_pages));
788 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
789 seq_printf(seq, "pages per rpc rpcs %% cum %% |");
790 seq_printf(seq, " rpcs %% cum %%\n");
792 read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
793 write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
797 for (i = 0; i < OBD_HIST_MAX; i++) {
798 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
799 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
803 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
804 1 << i, r, pct(r, read_tot),
805 pct(read_cum, read_tot), w,
807 pct(write_cum, write_tot));
808 if (read_cum == read_tot && write_cum == write_tot)
812 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
813 seq_printf(seq, "rpcs in flight rpcs %% cum %% |");
814 seq_printf(seq, " rpcs %% cum %%\n");
816 read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
817 write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
821 for (i = 0; i < OBD_HIST_MAX; i++) {
822 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
823 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
826 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
827 i, r, pct(r, read_tot),
828 pct(read_cum, read_tot), w,
830 pct(write_cum, write_tot));
831 if (read_cum == read_tot && write_cum == write_tot)
835 seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
836 seq_printf(seq, "offset rpcs %% cum %% |");
837 seq_printf(seq, " rpcs %% cum %%\n");
839 read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
840 write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
844 for (i = 0; i < OBD_HIST_MAX; i++) {
845 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
846 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
849 seq_printf(seq, "%d:\t\t%10lu %3u %3u | %10lu %3u %3u\n",
850 (i == 0) ? 0 : 1 << (i - 1),
851 r, pct(r, read_tot), pct(read_cum, read_tot),
852 w, pct(w, write_tot), pct(write_cum, write_tot));
853 if (read_cum == read_tot && write_cum == write_tot)
857 spin_unlock(&cli->cl_loi_list_lock);
862 static ssize_t osc_rpc_stats_seq_write(struct file *file,
863 const char __user *buf,
864 size_t len, loff_t *off)
866 struct seq_file *seq = file->private_data;
867 struct obd_device *obd = seq->private;
868 struct client_obd *cli = &obd->u.cli;
870 lprocfs_oh_clear(&cli->cl_read_rpc_hist);
871 lprocfs_oh_clear(&cli->cl_write_rpc_hist);
872 lprocfs_oh_clear(&cli->cl_read_page_hist);
873 lprocfs_oh_clear(&cli->cl_write_page_hist);
874 lprocfs_oh_clear(&cli->cl_read_offset_hist);
875 lprocfs_oh_clear(&cli->cl_write_offset_hist);
879 LPROC_SEQ_FOPS(osc_rpc_stats);
881 static int osc_stats_seq_show(struct seq_file *seq, void *v)
883 struct timespec64 now;
884 struct obd_device *obd = seq->private;
885 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
887 ktime_get_real_ts64(&now);
889 seq_printf(seq, "snapshot_time: %lld.%09lu (secs.nsecs)\n",
890 (s64)now.tv_sec, now.tv_nsec);
891 seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
892 stats->os_lockless_writes);
893 seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
894 stats->os_lockless_reads);
895 seq_printf(seq, "lockless_truncate\t\t%llu\n",
896 stats->os_lockless_truncates);
900 static ssize_t osc_stats_seq_write(struct file *file,
901 const char __user *buf,
902 size_t len, loff_t *off)
904 struct seq_file *seq = file->private_data;
905 struct obd_device *obd = seq->private;
906 struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
908 memset(stats, 0, sizeof(*stats));
912 LPROC_SEQ_FOPS(osc_stats);
914 int lprocfs_osc_attach_seqstat(struct obd_device *obd)
918 rc = lprocfs_seq_create(obd->obd_proc_entry, "osc_stats", 0644,
919 &osc_stats_fops, obd);
921 rc = lprocfs_obd_seq_create(obd, "rpc_stats", 0644,
922 &osc_rpc_stats_fops, obd);
926 #endif /* CONFIG_PROC_FS */
928 static struct attribute *osc_attrs[] = {
929 &lustre_attr_active.attr,
930 &lustre_attr_checksums.attr,
931 &lustre_attr_checksum_dump.attr,
932 &lustre_attr_contention_seconds.attr,
933 &lustre_attr_cur_dirty_bytes.attr,
934 &lustre_attr_cur_lost_grant_bytes.attr,
935 &lustre_attr_cur_dirty_grant_bytes.attr,
936 &lustre_attr_destroys_in_flight.attr,
937 &lustre_attr_grant_shrink_interval.attr,
938 &lustre_attr_lockless_truncate.attr,
939 &lustre_attr_max_dirty_mb.attr,
940 &lustre_attr_max_rpcs_in_flight.attr,
941 &lustre_attr_short_io_bytes.attr,
942 &lustre_attr_resend_count.attr,
943 &lustre_attr_ost_conn_uuid.attr,
944 &lustre_attr_conn_uuid.attr,
945 &lustre_attr_ping.attr,
946 &lustre_attr_idle_timeout.attr,
947 &lustre_attr_idle_connect.attr,
948 &lustre_attr_grant_shrink.attr,
952 int osc_tunables_init(struct obd_device *obd)
956 obd->obd_vars = lprocfs_osc_obd_vars;
957 obd->obd_ktype.default_attrs = osc_attrs;
958 rc = lprocfs_obd_setup(obd, false);
961 #ifdef CONFIG_PROC_FS
962 /* If the basic OSC proc tree construction succeeded then
965 rc = lprocfs_osc_attach_seqstat(obd);
969 #endif /* CONFIG_PROC_FS */
970 rc = sptlrpc_lprocfs_cliobd_attach(obd);
974 ptlrpc_lprocfs_register_obd(obd);
977 lprocfs_obd_cleanup(obd);