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) 2014, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
31 * lustre/obdclass/lprocfs_status_server.c
34 #define DEBUG_SUBSYSTEM S_CLASS
36 #include <linux/kobject.h>
37 #include <linux/sysfs.h>
39 #include <obd_class.h>
40 #include <lprocfs_status.h>
41 #include <lustre_nodemap.h>
43 #define MAX_STRING_SIZE 128
45 struct dentry *ldebugfs_add_symlink(const char *name, const char *target,
46 const char *format, ...)
48 struct dentry *entry = NULL;
49 struct dentry *parent;
54 if (!target || !format)
58 dname.len = strlen(dname.name);
59 dname.hash = ll_full_name_hash(debugfs_lustre_root,
60 dname.name, dname.len);
61 parent = d_lookup(debugfs_lustre_root, &dname);
65 OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1);
70 vsnprintf(dest, MAX_STRING_SIZE, format, ap);
73 entry = debugfs_create_symlink(name, parent, dest);
75 OBD_FREE(dest, MAX_STRING_SIZE + 1);
80 EXPORT_SYMBOL(ldebugfs_add_symlink);
84 int lprocfs_evict_client_open(struct inode *inode, struct file *f)
86 struct obd_device *obd = PDE_DATA(file_inode(f));
88 atomic_inc(&obd->obd_evict_inprogress);
92 int lprocfs_evict_client_release(struct inode *inode, struct file *f)
94 struct obd_device *obd = PDE_DATA(file_inode(f));
96 atomic_dec(&obd->obd_evict_inprogress);
97 wake_up(&obd->obd_evict_inprogress_waitq);
102 #define BUFLEN (UUID_MAX + 5)
105 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
106 size_t count, loff_t *off)
108 struct seq_file *m = file->private_data;
109 struct obd_device *obd = m->private;
112 OBD_ALLOC(kbuf, BUFLEN);
117 * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
118 * bytes into kbuf, to ensure that the string is NUL-terminated.
119 * UUID_MAX should include a trailing NUL already.
121 if (copy_from_user(kbuf, buffer,
122 min_t(unsigned long, BUFLEN - 1, count))) {
126 tmpbuf = skip_spaces(kbuf);
127 tmpbuf = strsep(&tmpbuf, " \t\n\f\v\r");
128 class_incref(obd, __func__, current);
130 if (strncmp(tmpbuf, "nid:", 4) == 0)
131 obd_export_evict_by_nid(obd, tmpbuf + 4);
132 else if (strncmp(tmpbuf, "uuid:", 5) == 0)
133 obd_export_evict_by_uuid(obd, tmpbuf + 5);
135 obd_export_evict_by_uuid(obd, tmpbuf);
137 class_decref(obd, __func__, current);
140 OBD_FREE(kbuf, BUFLEN);
143 EXPORT_SYMBOL(lprocfs_evict_client_seq_write);
147 ssize_t num_exports_show(struct kobject *kobj, struct attribute *attr,
150 struct obd_device *obd = container_of(kobj, struct obd_device,
153 return scnprintf(buf, PAGE_SIZE, "%u\n", obd->obd_num_exports);
155 EXPORT_SYMBOL(num_exports_show);
157 ssize_t grant_check_threshold_show(struct kobject *kobj, struct attribute *attr,
160 struct obd_device *obd = container_of(kobj, struct obd_device,
163 return scnprintf(buf, PAGE_SIZE, "%d\n",
164 obd->obd_grant_check_threshold);
166 EXPORT_SYMBOL(grant_check_threshold_show);
168 ssize_t grant_check_threshold_store(struct kobject *kobj,
169 struct attribute *attr,
170 const char *buffer, size_t count)
172 struct obd_device *obd = container_of(kobj, struct obd_device,
177 rc = kstrtoint(buffer, 10, &val);
183 obd->obd_grant_check_threshold = val;
186 EXPORT_SYMBOL(grant_check_threshold_store);
188 static int obd_export_flags2str(struct obd_export *exp, struct seq_file *m)
192 flag2str(exp, failed);
193 flag2str(exp, in_recovery);
194 flag2str(exp, disconnected);
195 flag2str(exp, connecting);
196 flag2str(exp, no_recovery);
202 lprocfs_exp_print_export_seq(struct obd_export *exp, void *cb_data)
204 struct seq_file *m = cb_data;
205 struct obd_device *obd;
206 struct obd_connect_data *ocd;
208 LASSERT(exp != NULL);
209 if (exp->exp_nid_stats == NULL)
212 ocd = &exp->exp_connect_data;
214 seq_printf(m, "%s:\n"
217 " connect_flags: [ ",
218 obd_uuid2str(&exp->exp_client_uuid),
220 obd_export_nid2str(exp));
221 obd_connect_seq_flags2str(m, ocd->ocd_connect_flags,
222 ocd->ocd_connect_flags2, ", ");
223 seq_printf(m, " ]\n");
224 obd_connect_data_seqprint(m, ocd);
225 seq_printf(m, " export_flags: [ ");
226 obd_export_flags2str(exp, m);
227 seq_printf(m, " ]\n");
230 strcmp(obd->obd_type->typ_name, "obdfilter") == 0) {
231 struct filter_export_data *fed = &exp->exp_filter_data;
233 seq_printf(m, " grant:\n");
234 seq_printf(m, " granted: %ld\n",
235 fed->fed_ted.ted_grant);
236 seq_printf(m, " dirty: %ld\n",
237 fed->fed_ted.ted_dirty);
238 seq_printf(m, " pending: %ld\n",
239 fed->fed_ted.ted_pending);
247 * RPC connections are composed of an import and an export. Using the
248 * lctl utility we can extract important information about the state.
249 * The lprocfs_exp_export_seq_show routine displays the state information
252 * \param[in] m seq file
253 * \param[in] data unused
255 * \retval 0 on success
257 * The format of the export state information is like:
258 * a793e354-49c0-aa11-8c4f-a4f2b1a1a92b:
260 * client: 10.211.55.10@tcp
261 * connect_flags: [ version, barrier, adaptive_timeouts, ... ]
263 * flags: 0x2000011005002020
265 * target_version: 2.10.51.0
266 * export_flags: [ ... ]
269 static int lprocfs_exp_export_seq_show(struct seq_file *m, void *data)
271 struct nid_stat *stats = m->private;
273 return obd_nid_export_for_each(stats->nid_obd, stats->nid,
274 lprocfs_exp_print_export_seq, m);
276 LPROC_SEQ_FOPS_RO(lprocfs_exp_export);
278 static void lprocfs_free_client_stats(struct nid_stat *client_stat)
280 CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat,
281 client_stat->nid_proc, client_stat->nid_stats);
283 LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
284 "nid %s:count %d\n", libcfs_nid2str(client_stat->nid),
285 atomic_read(&client_stat->nid_exp_ref_count));
287 if (client_stat->nid_proc)
288 lprocfs_remove(&client_stat->nid_proc);
290 if (client_stat->nid_stats)
291 lprocfs_free_stats(&client_stat->nid_stats);
293 if (client_stat->nid_ldlm_stats)
294 lprocfs_free_stats(&client_stat->nid_ldlm_stats);
296 OBD_FREE_PTR(client_stat);
299 void lprocfs_free_per_client_stats(struct obd_device *obd)
301 struct cfs_hash *hash = obd->obd_nid_stats_hash;
302 struct nid_stat *stat;
305 /* we need extra list - because hash_exit called to early */
306 /* not need locking because all clients is died */
307 while (!list_empty(&obd->obd_nid_stats)) {
308 stat = list_entry(obd->obd_nid_stats.next,
309 struct nid_stat, nid_list);
310 list_del_init(&stat->nid_list);
311 cfs_hash_del(hash, &stat->nid, &stat->nid_hash);
312 lprocfs_free_client_stats(stat);
316 EXPORT_SYMBOL(lprocfs_free_per_client_stats);
319 lprocfs_exp_print_nodemap_seq(struct obd_export *exp, void *cb_data)
321 struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
322 struct seq_file *m = cb_data;
325 seq_printf(m, "%s\n", nodemap->nm_name);
330 lprocfs_exp_nodemap_seq_show(struct seq_file *m, void *data)
332 struct nid_stat *stats = m->private;
334 return obd_nid_export_for_each(stats->nid_obd, stats->nid,
335 lprocfs_exp_print_nodemap_seq, m);
337 LPROC_SEQ_FOPS_RO(lprocfs_exp_nodemap);
340 lprocfs_exp_print_uuid_seq(struct obd_export *exp, void *cb_data)
342 struct seq_file *m = cb_data;
344 if (exp->exp_nid_stats)
345 seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid));
349 static int lprocfs_exp_uuid_seq_show(struct seq_file *m, void *data)
351 struct nid_stat *stats = m->private;
353 return obd_nid_export_for_each(stats->nid_obd, stats->nid,
354 lprocfs_exp_print_uuid_seq, m);
356 LPROC_SEQ_FOPS_RO(lprocfs_exp_uuid);
358 #define HASH_NAME_LEN 16
360 static void ldebugfs_rhash_seq_show(const char *name, struct rhashtable *ht,
363 unsigned int max_size = ht->p.max_size ? ht->p.max_size : UINT_MAX;
364 struct bucket_table *tbl;
365 int dist[8] = { 0, };
370 tbl = rht_dereference(ht->tbl, ht);
371 for (i = 0; i < tbl->size; i++) {
372 struct rhash_head *pos;
375 rht_for_each(pos, tbl, i)
379 maxdep = max(maxdep, count);
381 dist[min(fls(count), 7)]++;
384 seq_printf(m, "%-*s %5d %5d %10u %d.%03d 0.300 0.750 0x%03x %7d %7d %7d ",
385 HASH_NAME_LEN, name, tbl->size, ht->p.min_size, max_size,
386 atomic_read(&ht->nelems) / tbl->size,
387 atomic_read(&ht->nelems) * 1000 / tbl->size,
388 ht->p.automatic_shrinking, 0,
389 atomic_read(&ht->nelems), maxdep);
392 for (i = 0; i < 8; i++)
393 seq_printf(m, "%d%c", dist[i], (i == 7) ? '\n' : '/');
397 lprocfs_exp_print_hash_seq(struct obd_export *exp, void *cb_data)
400 struct obd_device *obd = exp->exp_obd;
401 struct seq_file *m = cb_data;
403 if (exp->exp_lock_hash != NULL) {
404 seq_printf(m, "%-*s cur min max theta t-min t-max flags rehash count distribution\n",
405 HASH_NAME_LEN, "name");
406 ldebugfs_rhash_seq_show("NID_HASH", &obd->obd_nid_hash.ht, m);
411 static int lprocfs_exp_hash_seq_show(struct seq_file *m, void *data)
413 struct nid_stat *stats = m->private;
415 return obd_nid_export_for_each(stats->nid_obd, stats->nid,
416 lprocfs_exp_print_hash_seq, m);
418 LPROC_SEQ_FOPS_RO(lprocfs_exp_hash);
420 int lprocfs_exp_print_replydata_seq(struct obd_export *exp, void *cb_data)
423 struct seq_file *m = cb_data;
424 struct tg_export_data *ted = &exp->exp_target_data;
426 seq_printf(m, "reply_cnt: %d\n"
428 "reply_released_by_xid: %d\n"
429 "reply_released_by_tag: %d\n\n",
432 ted->ted_release_xid,
433 ted->ted_release_tag);
437 int lprocfs_exp_replydata_seq_show(struct seq_file *m, void *data)
439 struct nid_stat *stats = m->private;
441 return obd_nid_export_for_each(stats->nid_obd, stats->nid,
442 lprocfs_exp_print_replydata_seq, m);
444 LPROC_SEQ_FOPS_RO(lprocfs_exp_replydata);
446 int lprocfs_exp_print_fmd_count_seq(struct obd_export *exp, void *cb_data)
448 struct seq_file *m = cb_data;
449 struct tg_export_data *ted = &exp->exp_target_data;
451 seq_printf(m, "%d\n", ted->ted_fmd_count);
456 int lprocfs_exp_fmd_count_seq_show(struct seq_file *m, void *data)
458 struct nid_stat *stats = m->private;
460 return obd_nid_export_for_each(stats->nid_obd, stats->nid,
461 lprocfs_exp_print_fmd_count_seq, m);
463 LPROC_SEQ_FOPS_RO(lprocfs_exp_fmd_count);
465 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
467 seq_puts(m, "Write into this file to clear all nid stats and stale nid entries\n");
470 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_show);
472 static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
474 struct nid_stat *stat = obj;
477 CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count));
478 if (atomic_read(&stat->nid_exp_ref_count) == 1) {
479 /* object has only hash references. */
480 spin_lock(&stat->nid_obd->obd_nid_lock);
481 list_move(&stat->nid_list, data);
482 spin_unlock(&stat->nid_obd->obd_nid_lock);
485 /* we has reference to object - only clear data*/
487 lprocfs_clear_stats(stat->nid_stats);
493 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
494 size_t count, loff_t *off)
496 struct seq_file *m = file->private_data;
497 struct obd_device *obd = m->private;
498 struct nid_stat *client_stat;
499 LIST_HEAD(free_list);
501 cfs_hash_cond_del(obd->obd_nid_stats_hash,
502 lprocfs_nid_stats_clear_write_cb, &free_list);
504 while (!list_empty(&free_list)) {
505 client_stat = list_entry(free_list.next, struct nid_stat,
507 list_del_init(&client_stat->nid_list);
508 lprocfs_free_client_stats(client_stat);
512 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_write);
514 int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid)
516 struct nid_stat *new_stat, *old_stat;
517 struct obd_device *obd = NULL;
518 struct proc_dir_entry *entry;
519 char nidstr[LNET_NIDSTR_SIZE];
523 if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry ||
524 !exp->exp_obd->obd_nid_stats_hash)
527 /* not test against zero because eric say:
528 * You may only test nid against another nid, or LNET_NID_ANY.
529 * Anything else is nonsense.*/
530 if (nid == NULL || *nid == LNET_NID_ANY)
533 libcfs_nid2str_r(*nid, nidstr, sizeof(nidstr));
535 spin_lock(&exp->exp_lock);
536 if (exp->exp_nid_stats != NULL) {
537 spin_unlock(&exp->exp_lock);
540 spin_unlock(&exp->exp_lock);
544 CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
546 OBD_ALLOC_PTR(new_stat);
547 if (new_stat == NULL)
550 new_stat->nid = *nid;
551 new_stat->nid_obd = exp->exp_obd;
552 /* we need set default refcount to 1 to balance obd_disconnect */
553 atomic_set(&new_stat->nid_exp_ref_count, 1);
555 old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash,
556 nid, &new_stat->nid_hash);
557 CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
558 old_stat, nidstr, atomic_read(&old_stat->nid_exp_ref_count));
560 /* Return -EALREADY here so that we know that the /proc
561 * entry already has been created */
562 if (old_stat != new_stat) {
563 spin_lock(&exp->exp_lock);
564 if (exp->exp_nid_stats) {
565 LASSERT(exp->exp_nid_stats == old_stat);
566 nidstat_putref(exp->exp_nid_stats);
568 exp->exp_nid_stats = old_stat;
569 spin_unlock(&exp->exp_lock);
570 GOTO(destroy_new, rc = -EALREADY);
572 /* not found - create */
573 new_stat->nid_proc = lprocfs_register(nidstr,
574 obd->obd_proc_exports_entry,
577 if (IS_ERR(new_stat->nid_proc)) {
578 rc = PTR_ERR(new_stat->nid_proc);
579 new_stat->nid_proc = NULL;
580 CERROR("%s: cannot create proc entry for export %s: rc = %d\n",
581 obd->obd_name, nidstr, rc);
582 GOTO(destroy_new_ns, rc);
585 entry = lprocfs_add_simple(new_stat->nid_proc, "nodemap", new_stat,
586 &lprocfs_exp_nodemap_fops);
589 CWARN("%s: error adding the nodemap file: rc = %d\n",
591 GOTO(destroy_new_ns, rc);
594 entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", new_stat,
595 &lprocfs_exp_uuid_fops);
598 CWARN("%s: error adding the NID stats file: rc = %d\n",
600 GOTO(destroy_new_ns, rc);
603 entry = lprocfs_add_simple(new_stat->nid_proc, "hash", new_stat,
604 &lprocfs_exp_hash_fops);
607 CWARN("%s: error adding the hash file: rc = %d\n",
609 GOTO(destroy_new_ns, rc);
612 entry = lprocfs_add_simple(new_stat->nid_proc, "export",
613 new_stat, &lprocfs_exp_export_fops);
616 CWARN("%s: error adding the export file: rc = %d\n",
618 GOTO(destroy_new_ns, rc);
621 entry = lprocfs_add_simple(new_stat->nid_proc, "reply_data", new_stat,
622 &lprocfs_exp_replydata_fops);
625 CWARN("%s: error adding the reply_data file: rc = %d\n",
627 GOTO(destroy_new_ns, rc);
630 entry = lprocfs_add_simple(new_stat->nid_proc, "fmd_count", new_stat,
631 &lprocfs_exp_fmd_count_fops);
634 CWARN("%s: error adding the fmd_count file: rc = %d\n",
636 GOTO(destroy_new_ns, rc);
639 spin_lock(&exp->exp_lock);
640 exp->exp_nid_stats = new_stat;
641 spin_unlock(&exp->exp_lock);
643 /* protect competitive add to list, not need locking on destroy */
644 spin_lock(&obd->obd_nid_lock);
645 list_add(&new_stat->nid_list, &obd->obd_nid_stats);
646 spin_unlock(&obd->obd_nid_lock);
651 if (new_stat->nid_proc != NULL)
652 lprocfs_remove(&new_stat->nid_proc);
653 cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
656 nidstat_putref(new_stat);
657 OBD_FREE_PTR(new_stat);
660 EXPORT_SYMBOL(lprocfs_exp_setup);
662 int lprocfs_exp_cleanup(struct obd_export *exp)
664 struct nid_stat *stat = exp->exp_nid_stats;
666 if (!stat || !exp->exp_obd)
669 nidstat_putref(exp->exp_nid_stats);
670 exp->exp_nid_stats = NULL;
675 int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned int num_stats)
677 struct lprocfs_stats *stats;
680 LASSERT(obd->obd_stats == NULL);
681 LASSERT(obd->obd_proc_entry != NULL);
683 stats = lprocfs_alloc_stats(num_stats, 0);
687 rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats);
689 lprocfs_free_stats(&stats);
691 obd->obd_stats = stats;
695 EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
697 void lprocfs_free_obd_stats(struct obd_device *obd)
700 lprocfs_free_stats(&obd->obd_stats);
702 EXPORT_SYMBOL(lprocfs_free_obd_stats);
704 static void display_brw_stats(struct seq_file *seq, const char *name,
705 const char *units, struct obd_histogram *read,
706 struct obd_histogram *write, bool scale)
708 unsigned long read_tot, write_tot, r, w, read_cum = 0, write_cum = 0;
711 seq_printf(seq, "\n%26s read | write\n", " ");
712 seq_printf(seq, "%-22s %-5s %% cum %% | %-11s %% cum %%\n",
715 read_tot = lprocfs_oh_sum(read);
716 write_tot = lprocfs_oh_sum(write);
718 if (!read_tot && !write_tot)
721 for (i = 0; i < OBD_HIST_MAX; i++) {
722 r = read->oh_buckets[i];
723 w = write->oh_buckets[i];
726 if (read_cum == 0 && write_cum == 0)
730 seq_printf(seq, "%u", i);
732 seq_printf(seq, "%lu", BIT(i));
734 seq_printf(seq, "%luK", BIT(i - 10));
736 seq_printf(seq, "%luM", BIT(i - 20));
738 seq_printf(seq, ":\t\t%10lu %3u %3u | %4lu %3u %3u\n",
739 r, pct(r, read_tot), pct(read_cum, read_tot),
740 w, pct(w, write_tot), pct(write_cum, write_tot));
742 if (read_cum == read_tot && write_cum == write_tot)
747 static const struct brw_stats_props brw_props[] = {
748 { .bsp_name = "pages per bulk r/w",
751 { .bsp_name = "discontiguous pages",
753 .bsp_scale = false },
754 { .bsp_name = "discontiguous blocks",
756 .bsp_scale = false },
757 { .bsp_name = "disk fragmented I/Os",
759 .bsp_scale = false },
760 { .bsp_name = "disk I/Os in flight",
762 .bsp_scale = false },
763 { .bsp_name = "I/O time (1/1000s)",
766 { .bsp_name = "disk I/O size",
771 static int brw_stats_seq_show(struct seq_file *seq, void *v)
773 struct brw_stats *brw_stats = seq->private;
776 /* this sampling races with updates */
777 lprocfs_stats_header(seq, ktime_get(), brw_stats->bs_init, 25, ":", 1);
779 for (i = 0; i < ARRAY_SIZE(brw_stats->bs_props); i++) {
780 if (!brw_stats->bs_props[i].bsp_name)
783 display_brw_stats(seq, brw_stats->bs_props[i].bsp_name,
784 brw_stats->bs_props[i].bsp_units,
785 &brw_stats->bs_hist[i * 2],
786 &brw_stats->bs_hist[i * 2 + 1],
787 brw_stats->bs_props[i].bsp_scale);
793 static ssize_t brw_stats_seq_write(struct file *file,
794 const char __user *buf,
795 size_t len, loff_t *off)
797 struct seq_file *seq = file->private_data;
798 struct brw_stats *brw_stats = seq->private;
801 for (i = 0; i < BRW_RW_STATS_NUM; i++)
802 lprocfs_oh_clear(&brw_stats->bs_hist[i]);
807 LDEBUGFS_SEQ_FOPS(brw_stats);
809 void lprocfs_init_brw_stats(struct brw_stats *brw_stats)
813 for (i = 0; i < BRW_RW_STATS_NUM; i++)
814 spin_lock_init(&brw_stats->bs_hist[i].oh_lock);
816 EXPORT_SYMBOL(lprocfs_init_brw_stats);
818 void ldebugfs_register_osd_stats(struct dentry *parent,
819 struct brw_stats *brw_stats,
820 struct lprocfs_stats *stats)
825 brw_stats->bs_init = ktime_get();
826 for (i = 0; i < BRW_RW_STATS_NUM; i++) {
827 struct brw_stats_props *props = brw_stats->bs_props;
830 props[i / 2].bsp_name = brw_props[i / 2].bsp_name;
831 props[i / 2].bsp_units = brw_props[i / 2].bsp_units;
832 props[i / 2].bsp_scale = brw_props[i / 2].bsp_scale;
839 debugfs_create_file("brw_stats", 0644, parent, brw_stats,
843 debugfs_create_file("stats", 0644, parent, stats,
844 &ldebugfs_stats_seq_fops);
846 EXPORT_SYMBOL(ldebugfs_register_osd_stats);
848 int lprocfs_hash_seq_show(struct seq_file *m, void *data)
850 struct obd_device *obd = m->private;
855 /* header for rhashtable state */
856 seq_printf(m, "%-*s cur min max theta t-min t-max flags rehash count maxdep distribution\n",
857 HASH_NAME_LEN, "name");
858 ldebugfs_rhash_seq_show("UUID_HASH", &obd->obd_uuid_hash, m);
859 ldebugfs_rhash_seq_show("NID_HASH", &obd->obd_nid_hash.ht, m);
861 cfs_hash_debug_header(m);
862 cfs_hash_debug_str(obd->obd_nid_stats_hash, m);
865 EXPORT_SYMBOL(lprocfs_hash_seq_show);
867 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data)
869 struct obd_device *obd = m->private;
870 struct target_distribute_txn_data *tdtd;
872 LASSERT(obd != NULL);
874 seq_printf(m, "status: ");
875 if (atomic_read(&obd->obd_max_recoverable_clients) == 0) {
876 seq_printf(m, "INACTIVE\n");
880 /* There is gap between client data read from storage and setting
881 * obd_recovering so check obd_recovery_end as well to make sure
882 * recovery is really finished
884 if (obd->obd_recovery_end > 0 && !obd->obd_recovering) {
885 seq_printf(m, "COMPLETE\n");
886 seq_printf(m, "recovery_start: %lld\n",
887 (s64)ktime_get_real_seconds() -
888 (ktime_get_seconds() - obd->obd_recovery_start));
889 seq_printf(m, "recovery_duration: %lld\n",
890 obd->obd_recovery_end ?
891 obd->obd_recovery_end - obd->obd_recovery_start :
892 ktime_get_seconds() - obd->obd_recovery_start);
893 /* Number of clients that have completed recovery */
894 seq_printf(m, "completed_clients: %d/%d\n",
895 atomic_read(&obd->obd_max_recoverable_clients) -
896 obd->obd_stale_clients,
897 atomic_read(&obd->obd_max_recoverable_clients));
898 seq_printf(m, "replayed_requests: %d\n",
899 obd->obd_replayed_requests);
900 seq_printf(m, "last_transno: %lld\n",
901 obd->obd_next_recovery_transno - 1);
902 seq_printf(m, "VBR: %s\n", obd->obd_version_recov ?
903 "ENABLED" : "DISABLED");
904 seq_printf(m, "IR: %s\n", obd->obd_no_ir ?
905 "DISABLED" : "ENABLED");
909 tdtd = obd->u.obt.obt_lut->lut_tdtd;
910 if (tdtd && tdtd->tdtd_show_update_logs_retrievers) {
915 buf = tdtd->tdtd_show_update_logs_retrievers(
916 tdtd->tdtd_show_retrievers_cbdata,
919 seq_printf(m, "WAITING\n");
920 seq_printf(m, "non-ready MDTs: %s\n",
921 buf ? buf : "unknown (not enough RAM)");
922 seq_printf(m, "recovery_start: %lld\n",
923 (s64)ktime_get_real_seconds() -
924 (ktime_get_seconds() -
925 obd->obd_recovery_start));
926 seq_printf(m, "time_waited: %lld\n",
927 (s64)(ktime_get_seconds() -
928 obd->obd_recovery_start));
934 if (likely(count > 0))
938 /* recovery won't start until the clients connect */
939 if (obd->obd_recovery_start == 0) {
940 seq_printf(m, "WAITING_FOR_CLIENTS\n");
944 seq_printf(m, "RECOVERING\n");
945 seq_printf(m, "recovery_start: %lld\n", (s64)ktime_get_real_seconds() -
946 (ktime_get_seconds() - obd->obd_recovery_start));
947 seq_printf(m, "time_remaining: %lld\n",
948 ktime_get_seconds() >=
949 obd->obd_recovery_start +
950 obd->obd_recovery_timeout ? 0 :
951 (s64)(obd->obd_recovery_start +
952 obd->obd_recovery_timeout -
953 ktime_get_seconds()));
954 seq_printf(m, "connected_clients: %d/%d\n",
955 atomic_read(&obd->obd_connected_clients),
956 atomic_read(&obd->obd_max_recoverable_clients));
957 /* Number of clients that have completed recovery */
958 seq_printf(m, "req_replay_clients: %d\n",
959 atomic_read(&obd->obd_req_replay_clients));
960 seq_printf(m, "lock_repay_clients: %d\n",
961 atomic_read(&obd->obd_lock_replay_clients));
962 seq_printf(m, "completed_clients: %d\n",
963 atomic_read(&obd->obd_connected_clients) -
964 atomic_read(&obd->obd_lock_replay_clients));
965 seq_printf(m, "evicted_clients: %d\n", obd->obd_stale_clients);
966 seq_printf(m, "replayed_requests: %d\n", obd->obd_replayed_requests);
967 seq_printf(m, "queued_requests: %d\n",
968 obd->obd_requests_queued_for_recovery);
969 seq_printf(m, "next_transno: %lld\n",
970 obd->obd_next_recovery_transno);
974 EXPORT_SYMBOL(lprocfs_recovery_status_seq_show);
976 ssize_t ir_factor_show(struct kobject *kobj, struct attribute *attr,
979 struct obd_device *obd = container_of(kobj, struct obd_device,
982 return scnprintf(buf, PAGE_SIZE, "%d\n", obd->obd_recovery_ir_factor);
984 EXPORT_SYMBOL(ir_factor_show);
986 ssize_t ir_factor_store(struct kobject *kobj, struct attribute *attr,
987 const char *buffer, size_t count)
989 struct obd_device *obd = container_of(kobj, struct obd_device,
994 rc = kstrtoint(buffer, 10, &val);
998 if (val < OBD_IR_FACTOR_MIN || val > OBD_IR_FACTOR_MAX)
1001 obd->obd_recovery_ir_factor = val;
1004 EXPORT_SYMBOL(ir_factor_store);
1006 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data)
1008 struct obd_device *obd = m->private;
1010 LASSERT(obd != NULL);
1011 seq_printf(m, "%d\n", obd->obd_checksum_dump);
1014 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_show);
1017 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
1018 size_t count, loff_t *off)
1020 struct seq_file *m = file->private_data;
1021 struct obd_device *obd = m->private;
1025 LASSERT(obd != NULL);
1026 rc = kstrtobool_from_user(buffer, count, &val);
1030 obd->obd_checksum_dump = val;
1033 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_write);
1035 ssize_t recovery_time_soft_show(struct kobject *kobj, struct attribute *attr,
1038 struct obd_device *obd = container_of(kobj, struct obd_device,
1041 return scnprintf(buf, PAGE_SIZE, "%d\n", obd->obd_recovery_timeout);
1043 EXPORT_SYMBOL(recovery_time_soft_show);
1045 ssize_t recovery_time_soft_store(struct kobject *kobj,
1046 struct attribute *attr,
1047 const char *buffer, size_t count)
1049 struct obd_device *obd = container_of(kobj, struct obd_device,
1054 rc = kstrtouint(buffer, 0, &val);
1058 obd->obd_recovery_timeout = val;
1061 EXPORT_SYMBOL(recovery_time_soft_store);
1063 ssize_t recovery_time_hard_show(struct kobject *kobj, struct attribute *attr,
1066 struct obd_device *obd = container_of(kobj, struct obd_device,
1069 return scnprintf(buf, PAGE_SIZE, "%d\n", obd->obd_recovery_time_hard);
1071 EXPORT_SYMBOL(recovery_time_hard_show);
1073 ssize_t recovery_time_hard_store(struct kobject *kobj,
1074 struct attribute *attr,
1075 const char *buffer, size_t count)
1077 struct obd_device *obd = container_of(kobj, struct obd_device,
1082 rc = kstrtouint(buffer, 0, &val);
1086 obd->obd_recovery_time_hard = val;
1089 EXPORT_SYMBOL(recovery_time_hard_store);
1091 ssize_t instance_show(struct kobject *kobj, struct attribute *attr,
1094 struct obd_device *obd = container_of(kobj, struct obd_device,
1096 struct obd_device_target *target = &obd->u.obt;
1098 LASSERT(target->obt_magic == OBT_MAGIC);
1099 return scnprintf(buf, PAGE_SIZE, "%u\n", obd->u.obt.obt_instance);
1101 EXPORT_SYMBOL(instance_show);
1103 #endif /* CONFIG_PROC_FS*/