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/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/obdclass/lprocfs_status_server.c
35 #define DEBUG_SUBSYSTEM S_CLASS
37 #include <linux/kobject.h>
38 #include <linux/sysfs.h>
40 #include <obd_class.h>
41 #include <lprocfs_status.h>
42 #include <lustre_nodemap.h>
44 #define MAX_STRING_SIZE 128
46 struct dentry *ldebugfs_add_symlink(const char *name, const char *target,
47 const char *format, ...)
49 struct dentry *entry = NULL;
50 struct dentry *parent;
55 if (!target || !format)
59 dname.len = strlen(dname.name);
60 dname.hash = ll_full_name_hash(debugfs_lustre_root,
61 dname.name, dname.len);
62 parent = d_lookup(debugfs_lustre_root, &dname);
66 OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1);
71 vsnprintf(dest, MAX_STRING_SIZE, format, ap);
74 entry = debugfs_create_symlink(name, parent, dest);
76 OBD_FREE(dest, MAX_STRING_SIZE + 1);
81 EXPORT_SYMBOL(ldebugfs_add_symlink);
85 int lprocfs_evict_client_open(struct inode *inode, struct file *f)
87 struct obd_device *obd = PDE_DATA(file_inode(f));
89 atomic_inc(&obd->obd_evict_inprogress);
93 int lprocfs_evict_client_release(struct inode *inode, struct file *f)
95 struct obd_device *obd = PDE_DATA(file_inode(f));
97 atomic_dec(&obd->obd_evict_inprogress);
98 wake_up(&obd->obd_evict_inprogress_waitq);
103 #define BUFLEN (UUID_MAX + 5)
106 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
107 size_t count, loff_t *off)
109 struct seq_file *m = file->private_data;
110 struct obd_device *obd = m->private;
113 OBD_ALLOC(kbuf, BUFLEN);
118 * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
119 * bytes into kbuf, to ensure that the string is NUL-terminated.
120 * UUID_MAX should include a trailing NUL already.
122 if (copy_from_user(kbuf, buffer,
123 min_t(unsigned long, BUFLEN - 1, count))) {
127 tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
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 static int obd_export_flags2str(struct obd_export *exp, struct seq_file *m)
161 flag2str(exp, failed);
162 flag2str(exp, in_recovery);
163 flag2str(exp, disconnected);
164 flag2str(exp, connecting);
165 flag2str(exp, no_recovery);
171 lprocfs_exp_print_export_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
172 struct hlist_node *hnode, void *cb_data)
174 struct seq_file *m = cb_data;
175 struct obd_export *exp = cfs_hash_object(hs, hnode);
176 struct obd_device *obd;
177 struct obd_connect_data *ocd;
179 LASSERT(exp != NULL);
180 if (exp->exp_nid_stats == NULL)
183 ocd = &exp->exp_connect_data;
185 seq_printf(m, "%s:\n"
188 " connect_flags: [ ",
189 obd_uuid2str(&exp->exp_client_uuid),
191 obd_export_nid2str(exp));
192 obd_connect_seq_flags2str(m, ocd->ocd_connect_flags,
193 ocd->ocd_connect_flags2, ", ");
194 seq_printf(m, " ]\n");
195 obd_connect_data_seqprint(m, ocd);
196 seq_printf(m, " export_flags: [ ");
197 obd_export_flags2str(exp, m);
198 seq_printf(m, " ]\n");
205 * RPC connections are composed of an import and an export. Using the
206 * lctl utility we can extract important information about the state.
207 * The lprocfs_exp_export_seq_show routine displays the state information
210 * \param[in] m seq file
211 * \param[in] data unused
213 * \retval 0 on success
215 * The format of the export state information is like:
216 * a793e354-49c0-aa11-8c4f-a4f2b1a1a92b:
218 * client: 10.211.55.10@tcp
219 * connect_flags: [ version, barrier, adaptive_timeouts, ... ]
221 * flags: 0x2000011005002020
223 * target_version: 2.10.51.0
224 * export_flags: [ ... ]
227 static int lprocfs_exp_export_seq_show(struct seq_file *m, void *data)
229 struct nid_stat *stats = m->private;
230 struct obd_device *obd = stats->nid_obd;
232 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
233 lprocfs_exp_print_export_seq, m);
236 LPROC_SEQ_FOPS_RO(lprocfs_exp_export);
238 static void lprocfs_free_client_stats(struct nid_stat *client_stat)
240 CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat,
241 client_stat->nid_proc, client_stat->nid_stats);
243 LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
244 "nid %s:count %d\n", libcfs_nid2str(client_stat->nid),
245 atomic_read(&client_stat->nid_exp_ref_count));
247 if (client_stat->nid_proc)
248 lprocfs_remove(&client_stat->nid_proc);
250 if (client_stat->nid_stats)
251 lprocfs_free_stats(&client_stat->nid_stats);
253 if (client_stat->nid_ldlm_stats)
254 lprocfs_free_stats(&client_stat->nid_ldlm_stats);
256 OBD_FREE_PTR(client_stat);
259 void lprocfs_free_per_client_stats(struct obd_device *obd)
261 struct cfs_hash *hash = obd->obd_nid_stats_hash;
262 struct nid_stat *stat;
265 /* we need extra list - because hash_exit called to early */
266 /* not need locking because all clients is died */
267 while (!list_empty(&obd->obd_nid_stats)) {
268 stat = list_entry(obd->obd_nid_stats.next,
269 struct nid_stat, nid_list);
270 list_del_init(&stat->nid_list);
271 cfs_hash_del(hash, &stat->nid, &stat->nid_hash);
272 lprocfs_free_client_stats(stat);
276 EXPORT_SYMBOL(lprocfs_free_per_client_stats);
279 lprocfs_exp_print_uuid_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
280 struct hlist_node *hnode, void *cb_data)
282 struct seq_file *m = cb_data;
283 struct obd_export *exp = cfs_hash_object(hs, hnode);
285 if (exp->exp_nid_stats != NULL)
286 seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid));
291 lprocfs_exp_print_nodemap_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
292 struct hlist_node *hnode, void *cb_data)
294 struct seq_file *m = cb_data;
295 struct obd_export *exp = cfs_hash_object(hs, hnode);
296 struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
299 seq_printf(m, "%s\n", nodemap->nm_name);
304 lprocfs_exp_nodemap_seq_show(struct seq_file *m, void *data)
306 struct nid_stat *stats = m->private;
307 struct obd_device *obd = stats->nid_obd;
309 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
310 lprocfs_exp_print_nodemap_seq, m);
313 LPROC_SEQ_FOPS_RO(lprocfs_exp_nodemap);
315 static int lprocfs_exp_uuid_seq_show(struct seq_file *m, void *data)
317 struct nid_stat *stats = m->private;
318 struct obd_device *obd = stats->nid_obd;
320 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
321 lprocfs_exp_print_uuid_seq, m);
324 LPROC_SEQ_FOPS_RO(lprocfs_exp_uuid);
326 #define HASH_NAME_LEN 16
328 static void ldebugfs_rhash_seq_show(const char *name, struct rhashtable *ht,
331 unsigned int max_size = ht->p.max_size ? ht->p.max_size : UINT_MAX;
332 struct bucket_table *tbl;
333 int dist[8] = { 0, };
338 tbl = rht_dereference(ht->tbl, ht);
339 for (i = 0; i < tbl->size; i++) {
340 struct rhash_head *pos;
343 rht_for_each(pos, tbl, i)
347 maxdep = max(maxdep, count);
349 dist[min(fls(count), 7)]++;
352 seq_printf(m, "%-*s %5d %5d %10u %d.%03d 0.300 0.750 0x%03x %7d %7d %7d ",
353 HASH_NAME_LEN, name, tbl->size, ht->p.min_size, max_size,
354 atomic_read(&ht->nelems) / tbl->size,
355 atomic_read(&ht->nelems) * 1000 / tbl->size,
356 ht->p.automatic_shrinking, 0,
357 atomic_read(&ht->nelems), maxdep);
360 for (i = 0; i < 8; i++)
361 seq_printf(m, "%d%c", dist[i], (i == 7) ? '\n' : '/');
365 lprocfs_exp_print_hash_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
366 struct hlist_node *hnode, void *cb_data)
369 struct seq_file *m = cb_data;
370 struct obd_export *exp = cfs_hash_object(hs, hnode);
372 if (exp->exp_lock_hash != NULL) {
373 cfs_hash_debug_header(m);
374 cfs_hash_debug_str(hs, m);
379 static int lprocfs_exp_hash_seq_show(struct seq_file *m, void *data)
381 struct nid_stat *stats = m->private;
382 struct obd_device *obd = stats->nid_obd;
384 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
385 lprocfs_exp_print_hash_seq, m);
388 LPROC_SEQ_FOPS_RO(lprocfs_exp_hash);
390 int lprocfs_exp_print_replydata_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
391 struct hlist_node *hnode, void *cb_data)
394 struct obd_export *exp = cfs_hash_object(hs, hnode);
395 struct seq_file *m = cb_data;
396 struct tg_export_data *ted = &exp->exp_target_data;
398 seq_printf(m, "reply_cnt: %d\n"
400 "reply_released_by_xid: %d\n"
401 "reply_released_by_tag: %d\n\n",
404 ted->ted_release_xid,
405 ted->ted_release_tag);
409 int lprocfs_exp_replydata_seq_show(struct seq_file *m, void *data)
411 struct nid_stat *stats = m->private;
412 struct obd_device *obd = stats->nid_obd;
414 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
415 lprocfs_exp_print_replydata_seq, m);
418 LPROC_SEQ_FOPS_RO(lprocfs_exp_replydata);
420 int lprocfs_exp_print_fmd_count_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
421 struct hlist_node *hnode, void *cb_data)
424 struct obd_export *exp = cfs_hash_object(hs, hnode);
425 struct seq_file *m = cb_data;
426 struct tg_export_data *ted = &exp->exp_target_data;
428 seq_printf(m, "%d\n", ted->ted_fmd_count);
433 int lprocfs_exp_fmd_count_seq_show(struct seq_file *m, void *data)
435 struct nid_stat *stats = m->private;
436 struct obd_device *obd = stats->nid_obd;
438 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
439 lprocfs_exp_print_fmd_count_seq, m);
442 LPROC_SEQ_FOPS_RO(lprocfs_exp_fmd_count);
444 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
446 seq_puts(m, "Write into this file to clear all nid stats and stale nid entries\n");
449 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_show);
451 static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
453 struct nid_stat *stat = obj;
456 CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count));
457 if (atomic_read(&stat->nid_exp_ref_count) == 1) {
458 /* object has only hash references. */
459 spin_lock(&stat->nid_obd->obd_nid_lock);
460 list_move(&stat->nid_list, data);
461 spin_unlock(&stat->nid_obd->obd_nid_lock);
464 /* we has reference to object - only clear data*/
466 lprocfs_clear_stats(stat->nid_stats);
472 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
473 size_t count, loff_t *off)
475 struct seq_file *m = file->private_data;
476 struct obd_device *obd = m->private;
477 struct nid_stat *client_stat;
478 LIST_HEAD(free_list);
480 cfs_hash_cond_del(obd->obd_nid_stats_hash,
481 lprocfs_nid_stats_clear_write_cb, &free_list);
483 while (!list_empty(&free_list)) {
484 client_stat = list_entry(free_list.next, struct nid_stat,
486 list_del_init(&client_stat->nid_list);
487 lprocfs_free_client_stats(client_stat);
491 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_write);
493 int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid)
495 struct nid_stat *new_stat, *old_stat;
496 struct obd_device *obd = NULL;
497 struct proc_dir_entry *entry;
498 char nidstr[LNET_NIDSTR_SIZE];
502 if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry ||
503 !exp->exp_obd->obd_nid_stats_hash)
506 /* not test against zero because eric say:
507 * You may only test nid against another nid, or LNET_NID_ANY.
508 * Anything else is nonsense.*/
509 if (nid == NULL || *nid == LNET_NID_ANY)
512 libcfs_nid2str_r(*nid, nidstr, sizeof(nidstr));
514 spin_lock(&exp->exp_lock);
515 if (exp->exp_nid_stats != NULL) {
516 spin_unlock(&exp->exp_lock);
519 spin_unlock(&exp->exp_lock);
523 CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
525 OBD_ALLOC_PTR(new_stat);
526 if (new_stat == NULL)
529 new_stat->nid = *nid;
530 new_stat->nid_obd = exp->exp_obd;
531 /* we need set default refcount to 1 to balance obd_disconnect */
532 atomic_set(&new_stat->nid_exp_ref_count, 1);
534 old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash,
535 nid, &new_stat->nid_hash);
536 CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
537 old_stat, nidstr, atomic_read(&old_stat->nid_exp_ref_count));
539 /* Return -EALREADY here so that we know that the /proc
540 * entry already has been created */
541 if (old_stat != new_stat) {
542 spin_lock(&exp->exp_lock);
543 if (exp->exp_nid_stats) {
544 LASSERT(exp->exp_nid_stats == old_stat);
545 nidstat_putref(exp->exp_nid_stats);
547 exp->exp_nid_stats = old_stat;
548 spin_unlock(&exp->exp_lock);
549 GOTO(destroy_new, rc = -EALREADY);
551 /* not found - create */
552 new_stat->nid_proc = lprocfs_register(nidstr,
553 obd->obd_proc_exports_entry,
556 if (IS_ERR(new_stat->nid_proc)) {
557 rc = PTR_ERR(new_stat->nid_proc);
558 new_stat->nid_proc = NULL;
559 CERROR("%s: cannot create proc entry for export %s: rc = %d\n",
560 obd->obd_name, nidstr, rc);
561 GOTO(destroy_new_ns, rc);
564 entry = lprocfs_add_simple(new_stat->nid_proc, "nodemap", new_stat,
565 &lprocfs_exp_nodemap_fops);
568 CWARN("%s: error adding the nodemap file: rc = %d\n",
570 GOTO(destroy_new_ns, rc);
573 entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", new_stat,
574 &lprocfs_exp_uuid_fops);
577 CWARN("%s: error adding the NID stats file: rc = %d\n",
579 GOTO(destroy_new_ns, rc);
582 entry = lprocfs_add_simple(new_stat->nid_proc, "hash", new_stat,
583 &lprocfs_exp_hash_fops);
586 CWARN("%s: error adding the hash file: rc = %d\n",
588 GOTO(destroy_new_ns, rc);
591 entry = lprocfs_add_simple(new_stat->nid_proc, "export",
592 new_stat, &lprocfs_exp_export_fops);
595 CWARN("%s: error adding the export file: rc = %d\n",
597 GOTO(destroy_new_ns, rc);
600 entry = lprocfs_add_simple(new_stat->nid_proc, "reply_data", new_stat,
601 &lprocfs_exp_replydata_fops);
604 CWARN("%s: error adding the reply_data file: rc = %d\n",
606 GOTO(destroy_new_ns, rc);
609 entry = lprocfs_add_simple(new_stat->nid_proc, "fmd_count", new_stat,
610 &lprocfs_exp_fmd_count_fops);
613 CWARN("%s: error adding the fmd_count file: rc = %d\n",
615 GOTO(destroy_new_ns, rc);
618 spin_lock(&exp->exp_lock);
619 exp->exp_nid_stats = new_stat;
620 spin_unlock(&exp->exp_lock);
622 /* protect competitive add to list, not need locking on destroy */
623 spin_lock(&obd->obd_nid_lock);
624 list_add(&new_stat->nid_list, &obd->obd_nid_stats);
625 spin_unlock(&obd->obd_nid_lock);
630 if (new_stat->nid_proc != NULL)
631 lprocfs_remove(&new_stat->nid_proc);
632 cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
635 nidstat_putref(new_stat);
636 OBD_FREE_PTR(new_stat);
639 EXPORT_SYMBOL(lprocfs_exp_setup);
641 int lprocfs_exp_cleanup(struct obd_export *exp)
643 struct nid_stat *stat = exp->exp_nid_stats;
645 if (!stat || !exp->exp_obd)
648 nidstat_putref(exp->exp_nid_stats);
649 exp->exp_nid_stats = NULL;
654 int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned int num_stats)
656 struct lprocfs_stats *stats;
659 LASSERT(obd->obd_stats == NULL);
660 LASSERT(obd->obd_proc_entry != NULL);
662 stats = lprocfs_alloc_stats(num_stats, 0);
666 rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats);
668 lprocfs_free_stats(&stats);
670 obd->obd_stats = stats;
674 EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
676 void lprocfs_free_obd_stats(struct obd_device *obd)
679 lprocfs_free_stats(&obd->obd_stats);
681 EXPORT_SYMBOL(lprocfs_free_obd_stats);
683 int lprocfs_hash_seq_show(struct seq_file *m, void *data)
685 struct obd_device *obd = m->private;
690 /* header for rhashtable state */
691 seq_printf(m, "%-*s cur min max theta t-min t-max flags rehash count maxdep distribution\n",
692 HASH_NAME_LEN, "name");
693 ldebugfs_rhash_seq_show("UUID_HASH", &obd->obd_uuid_hash, m);
695 cfs_hash_debug_header(m);
696 cfs_hash_debug_str(obd->obd_nid_hash, m);
697 cfs_hash_debug_str(obd->obd_nid_stats_hash, m);
700 EXPORT_SYMBOL(lprocfs_hash_seq_show);
702 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data)
704 struct obd_device *obd = m->private;
705 struct target_distribute_txn_data *tdtd;
707 LASSERT(obd != NULL);
709 seq_printf(m, "status: ");
710 if (atomic_read(&obd->obd_max_recoverable_clients) == 0) {
711 seq_printf(m, "INACTIVE\n");
715 /* sampled unlocked, but really... */
716 if (obd->obd_recovering == 0) {
717 seq_printf(m, "COMPLETE\n");
718 seq_printf(m, "recovery_start: %lld\n",
719 (s64)ktime_get_real_seconds() -
720 (ktime_get_seconds() - obd->obd_recovery_start));
721 seq_printf(m, "recovery_duration: %lld\n",
722 obd->obd_recovery_end ?
723 obd->obd_recovery_end - obd->obd_recovery_start :
724 ktime_get_seconds() - obd->obd_recovery_start);
725 /* Number of clients that have completed recovery */
726 seq_printf(m, "completed_clients: %d/%d\n",
727 atomic_read(&obd->obd_max_recoverable_clients) -
728 obd->obd_stale_clients,
729 atomic_read(&obd->obd_max_recoverable_clients));
730 seq_printf(m, "replayed_requests: %d\n",
731 obd->obd_replayed_requests);
732 seq_printf(m, "last_transno: %lld\n",
733 obd->obd_next_recovery_transno - 1);
734 seq_printf(m, "VBR: %s\n", obd->obd_version_recov ?
735 "ENABLED" : "DISABLED");
736 seq_printf(m, "IR: %s\n", obd->obd_no_ir ?
737 "DISABLED" : "ENABLED");
741 tdtd = obd->u.obt.obt_lut->lut_tdtd;
742 if (tdtd && tdtd->tdtd_show_update_logs_retrievers) {
747 buf = tdtd->tdtd_show_update_logs_retrievers(
748 tdtd->tdtd_show_retrievers_cbdata,
751 seq_printf(m, "WAITING\n");
752 seq_printf(m, "non-ready MDTs: %s\n",
753 buf ? buf : "unknown (not enough RAM)");
754 seq_printf(m, "recovery_start: %lld\n",
755 (s64)ktime_get_real_seconds() -
756 (ktime_get_seconds() -
757 obd->obd_recovery_start));
758 seq_printf(m, "time_waited: %lld\n",
759 (s64)(ktime_get_seconds() -
760 obd->obd_recovery_start));
766 if (likely(count > 0))
770 /* recovery won't start until the clients connect */
771 if (obd->obd_recovery_start == 0) {
772 seq_printf(m, "WAITING_FOR_CLIENTS\n");
776 seq_printf(m, "RECOVERING\n");
777 seq_printf(m, "recovery_start: %lld\n", (s64)ktime_get_real_seconds() -
778 (ktime_get_seconds() - obd->obd_recovery_start));
779 seq_printf(m, "time_remaining: %lld\n",
780 ktime_get_seconds() >=
781 obd->obd_recovery_start +
782 obd->obd_recovery_timeout ? 0 :
783 (s64)(obd->obd_recovery_start +
784 obd->obd_recovery_timeout -
785 ktime_get_seconds()));
786 seq_printf(m, "connected_clients: %d/%d\n",
787 atomic_read(&obd->obd_connected_clients),
788 atomic_read(&obd->obd_max_recoverable_clients));
789 /* Number of clients that have completed recovery */
790 seq_printf(m, "req_replay_clients: %d\n",
791 atomic_read(&obd->obd_req_replay_clients));
792 seq_printf(m, "lock_repay_clients: %d\n",
793 atomic_read(&obd->obd_lock_replay_clients));
794 seq_printf(m, "completed_clients: %d\n",
795 atomic_read(&obd->obd_connected_clients) -
796 atomic_read(&obd->obd_lock_replay_clients));
797 seq_printf(m, "evicted_clients: %d\n", obd->obd_stale_clients);
798 seq_printf(m, "replayed_requests: %d\n", obd->obd_replayed_requests);
799 seq_printf(m, "queued_requests: %d\n",
800 obd->obd_requests_queued_for_recovery);
801 seq_printf(m, "next_transno: %lld\n",
802 obd->obd_next_recovery_transno);
806 EXPORT_SYMBOL(lprocfs_recovery_status_seq_show);
808 ssize_t ir_factor_show(struct kobject *kobj, struct attribute *attr,
811 struct obd_device *obd = container_of(kobj, struct obd_device,
814 return scnprintf(buf, PAGE_SIZE, "%d\n", obd->obd_recovery_ir_factor);
816 EXPORT_SYMBOL(ir_factor_show);
818 ssize_t ir_factor_store(struct kobject *kobj, struct attribute *attr,
819 const char *buffer, size_t count)
821 struct obd_device *obd = container_of(kobj, struct obd_device,
826 rc = kstrtoint(buffer, 10, &val);
830 if (val < OBD_IR_FACTOR_MIN || val > OBD_IR_FACTOR_MAX)
833 obd->obd_recovery_ir_factor = val;
836 EXPORT_SYMBOL(ir_factor_store);
838 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data)
840 struct obd_device *obd = m->private;
842 LASSERT(obd != NULL);
843 seq_printf(m, "%d\n", obd->obd_checksum_dump);
846 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_show);
849 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
850 size_t count, loff_t *off)
852 struct seq_file *m = file->private_data;
853 struct obd_device *obd = m->private;
857 LASSERT(obd != NULL);
858 rc = kstrtobool_from_user(buffer, count, &val);
862 obd->obd_checksum_dump = val;
865 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_write);
867 ssize_t recovery_time_soft_show(struct kobject *kobj, struct attribute *attr,
870 struct obd_device *obd = container_of(kobj, struct obd_device,
873 return scnprintf(buf, PAGE_SIZE, "%d\n", obd->obd_recovery_timeout);
875 EXPORT_SYMBOL(recovery_time_soft_show);
877 ssize_t recovery_time_soft_store(struct kobject *kobj,
878 struct attribute *attr,
879 const char *buffer, size_t count)
881 struct obd_device *obd = container_of(kobj, struct obd_device,
886 rc = kstrtouint(buffer, 0, &val);
890 obd->obd_recovery_timeout = val;
893 EXPORT_SYMBOL(recovery_time_soft_store);
895 ssize_t recovery_time_hard_show(struct kobject *kobj, struct attribute *attr,
898 struct obd_device *obd = container_of(kobj, struct obd_device,
901 return scnprintf(buf, PAGE_SIZE, "%d\n", obd->obd_recovery_time_hard);
903 EXPORT_SYMBOL(recovery_time_hard_show);
905 ssize_t recovery_time_hard_store(struct kobject *kobj,
906 struct attribute *attr,
907 const char *buffer, size_t count)
909 struct obd_device *obd = container_of(kobj, struct obd_device,
914 rc = kstrtouint(buffer, 0, &val);
918 obd->obd_recovery_time_hard = val;
921 EXPORT_SYMBOL(recovery_time_hard_store);
923 ssize_t instance_show(struct kobject *kobj, struct attribute *attr,
926 struct obd_device *obd = container_of(kobj, struct obd_device,
928 struct obd_device_target *target = &obd->u.obt;
930 LASSERT(target->obt_magic == OBT_MAGIC);
931 return scnprintf(buf, PAGE_SIZE, "%u\n", obd->u.obt.obt_instance);
933 EXPORT_SYMBOL(instance_show);
935 #endif /* CONFIG_PROC_FS*/