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(parent, 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);
74 if (IS_ERR_OR_NULL(entry)) {
75 CERROR("LdebugFS: Could not create symbolic link from %s to %s\n",
80 OBD_FREE(dest, MAX_STRING_SIZE + 1);
85 EXPORT_SYMBOL(ldebugfs_add_symlink);
89 int lprocfs_evict_client_open(struct inode *inode, struct file *f)
91 struct obd_device *obd = PDE_DATA(file_inode(f));
93 atomic_inc(&obd->obd_evict_inprogress);
97 int lprocfs_evict_client_release(struct inode *inode, struct file *f)
99 struct obd_device *obd = PDE_DATA(file_inode(f));
101 atomic_dec(&obd->obd_evict_inprogress);
102 wake_up(&obd->obd_evict_inprogress_waitq);
107 #define BUFLEN (UUID_MAX + 5)
110 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
111 size_t count, loff_t *off)
113 struct seq_file *m = file->private_data;
114 struct obd_device *obd = m->private;
117 OBD_ALLOC(kbuf, BUFLEN);
122 * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
123 * bytes into kbuf, to ensure that the string is NUL-terminated.
124 * UUID_MAX should include a trailing NUL already.
126 if (copy_from_user(kbuf, buffer,
127 min_t(unsigned long, BUFLEN - 1, count))) {
131 tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
132 class_incref(obd, __func__, current);
134 if (strncmp(tmpbuf, "nid:", 4) == 0)
135 obd_export_evict_by_nid(obd, tmpbuf + 4);
136 else if (strncmp(tmpbuf, "uuid:", 5) == 0)
137 obd_export_evict_by_uuid(obd, tmpbuf + 5);
139 obd_export_evict_by_uuid(obd, tmpbuf);
141 class_decref(obd, __func__, current);
144 OBD_FREE(kbuf, BUFLEN);
147 EXPORT_SYMBOL(lprocfs_evict_client_seq_write);
151 int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
153 struct obd_device *obd = data;
155 LASSERT(obd != NULL);
156 seq_printf(m, "%u\n", obd->obd_num_exports);
159 EXPORT_SYMBOL(lprocfs_num_exports_seq_show);
161 static int obd_export_flags2str(struct obd_export *exp, struct seq_file *m)
165 flag2str(exp, failed);
166 flag2str(exp, in_recovery);
167 flag2str(exp, disconnected);
168 flag2str(exp, connecting);
174 lprocfs_exp_print_export_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
175 struct hlist_node *hnode, void *cb_data)
177 struct seq_file *m = cb_data;
178 struct obd_export *exp = cfs_hash_object(hs, hnode);
179 struct obd_device *obd;
180 struct obd_connect_data *ocd;
182 LASSERT(exp != NULL);
183 if (exp->exp_nid_stats == NULL)
186 ocd = &exp->exp_connect_data;
188 seq_printf(m, "%s:\n"
191 " connect_flags: [ ",
192 obd_uuid2str(&exp->exp_client_uuid),
194 obd_export_nid2str(exp));
195 obd_connect_seq_flags2str(m, ocd->ocd_connect_flags,
196 ocd->ocd_connect_flags2, ", ");
197 seq_printf(m, " ]\n");
198 obd_connect_data_seqprint(m, ocd);
199 seq_printf(m, " export_flags: [ ");
200 obd_export_flags2str(exp, m);
201 seq_printf(m, " ]\n");
208 * RPC connections are composed of an import and an export. Using the
209 * lctl utility we can extract important information about the state.
210 * The lprocfs_exp_export_seq_show routine displays the state information
213 * \param[in] m seq file
214 * \param[in] data unused
216 * \retval 0 on success
218 * The format of the export state information is like:
219 * a793e354-49c0-aa11-8c4f-a4f2b1a1a92b:
221 * client: 10.211.55.10@tcp
222 * connect_flags: [ version, barrier, adaptive_timeouts, ... ]
224 * flags: 0x2000011005002020
226 * target_version: 2.10.51.0
227 * export_flags: [ ... ]
230 static int lprocfs_exp_export_seq_show(struct seq_file *m, void *data)
232 struct nid_stat *stats = m->private;
233 struct obd_device *obd = stats->nid_obd;
235 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
236 lprocfs_exp_print_export_seq, m);
239 LPROC_SEQ_FOPS_RO(lprocfs_exp_export);
241 static void lprocfs_free_client_stats(struct nid_stat *client_stat)
243 CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat,
244 client_stat->nid_proc, client_stat->nid_stats);
246 LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
247 "nid %s:count %d\n", libcfs_nid2str(client_stat->nid),
248 atomic_read(&client_stat->nid_exp_ref_count));
250 if (client_stat->nid_proc)
251 lprocfs_remove(&client_stat->nid_proc);
253 if (client_stat->nid_stats)
254 lprocfs_free_stats(&client_stat->nid_stats);
256 if (client_stat->nid_ldlm_stats)
257 lprocfs_free_stats(&client_stat->nid_ldlm_stats);
259 OBD_FREE_PTR(client_stat);
263 void lprocfs_free_per_client_stats(struct obd_device *obd)
265 struct cfs_hash *hash = obd->obd_nid_stats_hash;
266 struct nid_stat *stat;
269 /* we need extra list - because hash_exit called to early */
270 /* not need locking because all clients is died */
271 while (!list_empty(&obd->obd_nid_stats)) {
272 stat = list_entry(obd->obd_nid_stats.next,
273 struct nid_stat, nid_list);
274 list_del_init(&stat->nid_list);
275 cfs_hash_del(hash, &stat->nid, &stat->nid_hash);
276 lprocfs_free_client_stats(stat);
280 EXPORT_SYMBOL(lprocfs_free_per_client_stats);
283 lprocfs_exp_print_uuid_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
284 struct hlist_node *hnode, void *cb_data)
286 struct seq_file *m = cb_data;
287 struct obd_export *exp = cfs_hash_object(hs, hnode);
289 if (exp->exp_nid_stats != NULL)
290 seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid));
295 lprocfs_exp_print_nodemap_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
296 struct hlist_node *hnode, void *cb_data)
298 struct seq_file *m = cb_data;
299 struct obd_export *exp = cfs_hash_object(hs, hnode);
300 struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
303 seq_printf(m, "%s\n", nodemap->nm_name);
308 lprocfs_exp_nodemap_seq_show(struct seq_file *m, void *data)
310 struct nid_stat *stats = m->private;
311 struct obd_device *obd = stats->nid_obd;
313 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
314 lprocfs_exp_print_nodemap_seq, m);
317 LPROC_SEQ_FOPS_RO(lprocfs_exp_nodemap);
319 static int lprocfs_exp_uuid_seq_show(struct seq_file *m, void *data)
321 struct nid_stat *stats = m->private;
322 struct obd_device *obd = stats->nid_obd;
324 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
325 lprocfs_exp_print_uuid_seq, m);
328 LPROC_SEQ_FOPS_RO(lprocfs_exp_uuid);
331 lprocfs_exp_print_hash_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
332 struct hlist_node *hnode, void *cb_data)
335 struct seq_file *m = cb_data;
336 struct obd_export *exp = cfs_hash_object(hs, hnode);
338 if (exp->exp_lock_hash != NULL) {
339 cfs_hash_debug_header(m);
340 cfs_hash_debug_str(hs, m);
345 static int lprocfs_exp_hash_seq_show(struct seq_file *m, void *data)
347 struct nid_stat *stats = m->private;
348 struct obd_device *obd = stats->nid_obd;
350 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
351 lprocfs_exp_print_hash_seq, m);
354 LPROC_SEQ_FOPS_RO(lprocfs_exp_hash);
356 int lprocfs_exp_print_replydata_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
357 struct hlist_node *hnode, void *cb_data)
360 struct obd_export *exp = cfs_hash_object(hs, hnode);
361 struct seq_file *m = cb_data;
362 struct tg_export_data *ted = &exp->exp_target_data;
364 seq_printf(m, "reply_cnt: %d\n"
366 "reply_released_by_xid: %d\n"
367 "reply_released_by_tag: %d\n\n",
370 ted->ted_release_xid,
371 ted->ted_release_tag);
375 int lprocfs_exp_replydata_seq_show(struct seq_file *m, void *data)
377 struct nid_stat *stats = m->private;
378 struct obd_device *obd = stats->nid_obd;
380 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
381 lprocfs_exp_print_replydata_seq, m);
384 LPROC_SEQ_FOPS_RO(lprocfs_exp_replydata);
386 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
388 seq_puts(m, "Write into this file to clear all nid stats and stale nid entries\n");
391 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_show);
393 static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
395 struct nid_stat *stat = obj;
398 CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count));
399 if (atomic_read(&stat->nid_exp_ref_count) == 1) {
400 /* object has only hash references. */
401 spin_lock(&stat->nid_obd->obd_nid_lock);
402 list_move(&stat->nid_list, data);
403 spin_unlock(&stat->nid_obd->obd_nid_lock);
406 /* we has reference to object - only clear data*/
408 lprocfs_clear_stats(stat->nid_stats);
414 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
415 size_t count, loff_t *off)
417 struct seq_file *m = file->private_data;
418 struct obd_device *obd = m->private;
419 struct nid_stat *client_stat;
420 struct list_head free_list;
422 INIT_LIST_HEAD(&free_list);
423 cfs_hash_cond_del(obd->obd_nid_stats_hash,
424 lprocfs_nid_stats_clear_write_cb, &free_list);
426 while (!list_empty(&free_list)) {
427 client_stat = list_entry(free_list.next, struct nid_stat,
429 list_del_init(&client_stat->nid_list);
430 lprocfs_free_client_stats(client_stat);
434 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_write);
436 int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid)
438 struct nid_stat *new_stat, *old_stat;
439 struct obd_device *obd = NULL;
440 struct proc_dir_entry *entry;
441 char nidstr[LNET_NIDSTR_SIZE];
445 if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry ||
446 !exp->exp_obd->obd_nid_stats_hash)
449 /* not test against zero because eric say:
450 * You may only test nid against another nid, or LNET_NID_ANY.
451 * Anything else is nonsense.*/
452 if (nid == NULL || *nid == LNET_NID_ANY)
455 libcfs_nid2str_r(*nid, nidstr, sizeof(nidstr));
457 spin_lock(&exp->exp_lock);
458 if (exp->exp_nid_stats != NULL) {
459 spin_unlock(&exp->exp_lock);
462 spin_unlock(&exp->exp_lock);
466 CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
468 OBD_ALLOC_PTR(new_stat);
469 if (new_stat == NULL)
472 new_stat->nid = *nid;
473 new_stat->nid_obd = exp->exp_obd;
474 /* we need set default refcount to 1 to balance obd_disconnect */
475 atomic_set(&new_stat->nid_exp_ref_count, 1);
477 old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash,
478 nid, &new_stat->nid_hash);
479 CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
480 old_stat, nidstr, atomic_read(&old_stat->nid_exp_ref_count));
482 /* Return -EALREADY here so that we know that the /proc
483 * entry already has been created */
484 if (old_stat != new_stat) {
485 spin_lock(&exp->exp_lock);
486 if (exp->exp_nid_stats) {
487 LASSERT(exp->exp_nid_stats == old_stat);
488 nidstat_putref(exp->exp_nid_stats);
490 exp->exp_nid_stats = old_stat;
491 spin_unlock(&exp->exp_lock);
492 GOTO(destroy_new, rc = -EALREADY);
494 /* not found - create */
495 new_stat->nid_proc = lprocfs_register(nidstr,
496 obd->obd_proc_exports_entry,
499 if (IS_ERR(new_stat->nid_proc)) {
500 rc = PTR_ERR(new_stat->nid_proc);
501 new_stat->nid_proc = NULL;
502 CERROR("%s: cannot create proc entry for export %s: rc = %d\n",
503 obd->obd_name, nidstr, rc);
504 GOTO(destroy_new_ns, rc);
507 entry = lprocfs_add_simple(new_stat->nid_proc, "nodemap", new_stat,
508 &lprocfs_exp_nodemap_fops);
511 CWARN("%s: error adding the nodemap file: rc = %d\n",
513 GOTO(destroy_new_ns, rc);
516 entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", new_stat,
517 &lprocfs_exp_uuid_fops);
520 CWARN("%s: error adding the NID stats file: rc = %d\n",
522 GOTO(destroy_new_ns, rc);
525 entry = lprocfs_add_simple(new_stat->nid_proc, "hash", new_stat,
526 &lprocfs_exp_hash_fops);
529 CWARN("%s: error adding the hash file: rc = %d\n",
531 GOTO(destroy_new_ns, rc);
534 entry = lprocfs_add_simple(new_stat->nid_proc, "export",
535 new_stat, &lprocfs_exp_export_fops);
538 CWARN("%s: error adding the export file: rc = %d\n",
540 GOTO(destroy_new_ns, rc);
543 entry = lprocfs_add_simple(new_stat->nid_proc, "reply_data", new_stat,
544 &lprocfs_exp_replydata_fops);
547 CWARN("%s: error adding the reply_data file: rc = %d\n",
549 GOTO(destroy_new_ns, rc);
552 spin_lock(&exp->exp_lock);
553 exp->exp_nid_stats = new_stat;
554 spin_unlock(&exp->exp_lock);
556 /* protect competitive add to list, not need locking on destroy */
557 spin_lock(&obd->obd_nid_lock);
558 list_add(&new_stat->nid_list, &obd->obd_nid_stats);
559 spin_unlock(&obd->obd_nid_lock);
564 if (new_stat->nid_proc != NULL)
565 lprocfs_remove(&new_stat->nid_proc);
566 cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
569 nidstat_putref(new_stat);
570 OBD_FREE_PTR(new_stat);
573 EXPORT_SYMBOL(lprocfs_exp_setup);
575 int lprocfs_exp_cleanup(struct obd_export *exp)
577 struct nid_stat *stat = exp->exp_nid_stats;
579 if (!stat || !exp->exp_obd)
582 nidstat_putref(exp->exp_nid_stats);
583 exp->exp_nid_stats = NULL;
588 #define LPROCFS_OBD_OP_INIT(base, stats, op) \
590 unsigned int coffset = base + OBD_COUNTER_OFFSET(op); \
591 LASSERT(coffset < stats->ls_num); \
592 lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \
595 void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
597 LPROCFS_OBD_OP_INIT(num_private_stats, stats, iocontrol);
598 LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_info);
599 LPROCFS_OBD_OP_INIT(num_private_stats, stats, set_info_async);
600 LPROCFS_OBD_OP_INIT(num_private_stats, stats, setup);
601 LPROCFS_OBD_OP_INIT(num_private_stats, stats, precleanup);
602 LPROCFS_OBD_OP_INIT(num_private_stats, stats, cleanup);
603 LPROCFS_OBD_OP_INIT(num_private_stats, stats, process_config);
604 LPROCFS_OBD_OP_INIT(num_private_stats, stats, postrecov);
605 LPROCFS_OBD_OP_INIT(num_private_stats, stats, add_conn);
606 LPROCFS_OBD_OP_INIT(num_private_stats, stats, del_conn);
607 LPROCFS_OBD_OP_INIT(num_private_stats, stats, connect);
608 LPROCFS_OBD_OP_INIT(num_private_stats, stats, reconnect);
609 LPROCFS_OBD_OP_INIT(num_private_stats, stats, disconnect);
610 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_init);
611 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_fini);
612 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_alloc);
613 LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs);
614 LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs_async);
615 LPROCFS_OBD_OP_INIT(num_private_stats, stats, create);
616 LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy);
617 LPROCFS_OBD_OP_INIT(num_private_stats, stats, setattr);
618 LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr);
619 LPROCFS_OBD_OP_INIT(num_private_stats, stats, preprw);
620 LPROCFS_OBD_OP_INIT(num_private_stats, stats, commitrw);
621 LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_export);
622 LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy_export);
623 LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event);
624 LPROCFS_OBD_OP_INIT(num_private_stats, stats, notify);
625 LPROCFS_OBD_OP_INIT(num_private_stats, stats, health_check);
626 LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_uuid);
627 LPROCFS_OBD_OP_INIT(num_private_stats, stats, quotactl);
628 LPROCFS_OBD_OP_INIT(num_private_stats, stats, ping);
629 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_new);
630 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_rem);
631 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_add);
632 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_del);
633 LPROCFS_OBD_OP_INIT(num_private_stats, stats, getref);
634 LPROCFS_OBD_OP_INIT(num_private_stats, stats, putref);
636 CLASSERT(NUM_OBD_STATS == OBD_COUNTER_OFFSET(putref) + 1);
638 EXPORT_SYMBOL(lprocfs_init_ops_stats);
640 int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats)
642 struct lprocfs_stats *stats;
643 unsigned int num_stats;
646 LASSERT(obd->obd_stats == NULL);
647 LASSERT(obd->obd_proc_entry != NULL);
648 LASSERT(obd->obd_cntr_base == 0);
650 num_stats = NUM_OBD_STATS + num_private_stats;
651 stats = lprocfs_alloc_stats(num_stats, 0);
655 lprocfs_init_ops_stats(num_private_stats, stats);
657 for (i = num_private_stats; i < num_stats; i++) {
658 /* If this LBUGs, it is likely that an obd
659 * operation was added to struct obd_ops in
660 * <obd.h>, and that the corresponding line item
661 * LPROCFS_OBD_OP_INIT(.., .., opname)
662 * is missing from the list above. */
663 LASSERTF(stats->ls_cnt_header[i].lc_name != NULL,
664 "Missing obd_stat initializer obd_op "
665 "operation at offset %d.\n", i - num_private_stats);
667 rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats);
669 lprocfs_free_stats(&stats);
671 obd->obd_stats = stats;
672 obd->obd_cntr_base = num_private_stats;
676 EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
678 void lprocfs_free_obd_stats(struct obd_device *obd)
681 lprocfs_free_stats(&obd->obd_stats);
683 EXPORT_SYMBOL(lprocfs_free_obd_stats);
685 int lprocfs_hash_seq_show(struct seq_file *m, void *data)
687 struct obd_device *obd = m->private;
692 cfs_hash_debug_header(m);
693 cfs_hash_debug_str(obd->obd_uuid_hash, m);
694 cfs_hash_debug_str(obd->obd_nid_hash, m);
695 cfs_hash_debug_str(obd->obd_nid_stats_hash, m);
698 EXPORT_SYMBOL(lprocfs_hash_seq_show);
700 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data)
702 struct obd_device *obd = m->private;
703 struct target_distribute_txn_data *tdtd;
705 LASSERT(obd != NULL);
707 seq_printf(m, "status: ");
708 if (obd->obd_max_recoverable_clients == 0) {
709 seq_printf(m, "INACTIVE\n");
713 /* sampled unlocked, but really... */
714 if (obd->obd_recovering == 0) {
715 seq_printf(m, "COMPLETE\n");
716 seq_printf(m, "recovery_start: %lld\n",
717 (s64)obd->obd_recovery_start);
718 seq_printf(m, "recovery_duration: %lld\n",
719 obd->obd_recovery_end ?
720 obd->obd_recovery_end - obd->obd_recovery_start :
721 ktime_get_real_seconds() - obd->obd_recovery_start);
722 /* Number of clients that have completed recovery */
723 seq_printf(m, "completed_clients: %d/%d\n",
724 obd->obd_max_recoverable_clients -
725 obd->obd_stale_clients,
726 obd->obd_max_recoverable_clients);
727 seq_printf(m, "replayed_requests: %d\n",
728 obd->obd_replayed_requests);
729 seq_printf(m, "last_transno: %lld\n",
730 obd->obd_next_recovery_transno - 1);
731 seq_printf(m, "VBR: %s\n", obd->obd_version_recov ?
732 "ENABLED" : "DISABLED");
733 seq_printf(m, "IR: %s\n", obd->obd_no_ir ?
734 "DISABLED" : "ENABLED");
738 tdtd = obd->u.obt.obt_lut->lut_tdtd;
739 if (tdtd && tdtd->tdtd_show_update_logs_retrievers) {
744 buf = tdtd->tdtd_show_update_logs_retrievers(
745 tdtd->tdtd_show_retrievers_cbdata,
748 seq_printf(m, "WAITING\n");
749 seq_printf(m, "non-ready MDTs: %s\n",
750 buf ? buf : "unknown (not enough RAM)");
751 seq_printf(m, "recovery_start: %lld\n",
752 (s64)obd->obd_recovery_start);
753 seq_printf(m, "time_waited: %lld\n",
754 (s64)(ktime_get_real_seconds() -
755 obd->obd_recovery_start));
761 if (likely(count > 0))
765 /* recovery won't start until the clients connect */
766 if (obd->obd_recovery_start == 0) {
767 seq_printf(m, "WAITING_FOR_CLIENTS\n");
771 seq_printf(m, "RECOVERING\n");
772 seq_printf(m, "recovery_start: %lld\n", (s64)obd->obd_recovery_start);
773 seq_printf(m, "time_remaining: %lld\n",
774 ktime_get_real_seconds() >=
775 obd->obd_recovery_start +
776 obd->obd_recovery_timeout ? 0 :
777 (s64)(obd->obd_recovery_start +
778 obd->obd_recovery_timeout -
779 ktime_get_real_seconds()));
780 seq_printf(m, "connected_clients: %d/%d\n",
781 atomic_read(&obd->obd_connected_clients),
782 obd->obd_max_recoverable_clients);
783 /* Number of clients that have completed recovery */
784 seq_printf(m, "req_replay_clients: %d\n",
785 atomic_read(&obd->obd_req_replay_clients));
786 seq_printf(m, "lock_repay_clients: %d\n",
787 atomic_read(&obd->obd_lock_replay_clients));
788 seq_printf(m, "completed_clients: %d\n",
789 atomic_read(&obd->obd_connected_clients) -
790 atomic_read(&obd->obd_lock_replay_clients));
791 seq_printf(m, "evicted_clients: %d\n", obd->obd_stale_clients);
792 seq_printf(m, "replayed_requests: %d\n", obd->obd_replayed_requests);
793 seq_printf(m, "queued_requests: %d\n",
794 obd->obd_requests_queued_for_recovery);
795 seq_printf(m, "next_transno: %lld\n",
796 obd->obd_next_recovery_transno);
800 EXPORT_SYMBOL(lprocfs_recovery_status_seq_show);
802 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data)
804 struct obd_device *obd = m->private;
806 LASSERT(obd != NULL);
807 seq_printf(m, "%d\n", obd->obd_recovery_ir_factor);
810 EXPORT_SYMBOL(lprocfs_ir_factor_seq_show);
813 lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
814 size_t count, loff_t *off)
816 struct seq_file *m = file->private_data;
817 struct obd_device *obd = m->private;
821 LASSERT(obd != NULL);
822 rc = kstrtoint_from_user(buffer, count, 10, &val);
826 if (val < OBD_IR_FACTOR_MIN || val > OBD_IR_FACTOR_MAX)
829 obd->obd_recovery_ir_factor = val;
832 EXPORT_SYMBOL(lprocfs_ir_factor_seq_write);
834 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data)
836 struct obd_device *obd = m->private;
838 LASSERT(obd != NULL);
839 seq_printf(m, "%d\n", obd->obd_checksum_dump);
842 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_show);
845 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
846 size_t count, loff_t *off)
848 struct seq_file *m = file->private_data;
849 struct obd_device *obd = m->private;
853 LASSERT(obd != NULL);
854 rc = kstrtobool_from_user(buffer, count, &val);
858 obd->obd_checksum_dump = val;
861 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_write);
863 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data)
865 struct obd_device *obd = m->private;
867 LASSERT(obd != NULL);
868 seq_printf(m, "%llu\n", obd->obd_recovery_timeout);
871 EXPORT_SYMBOL(lprocfs_recovery_time_soft_seq_show);
874 lprocfs_recovery_time_soft_seq_write(struct file *file,
875 const char __user *buffer,
876 size_t count, loff_t *off)
878 struct seq_file *m = file->private_data;
879 struct obd_device *obd = m->private;
883 LASSERT(obd != NULL);
884 rc = kstrtouint_from_user(buffer, count, 0, &val);
888 obd->obd_recovery_timeout = val;
891 EXPORT_SYMBOL(lprocfs_recovery_time_soft_seq_write);
893 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data)
895 struct obd_device *obd = m->private;
897 LASSERT(obd != NULL);
898 seq_printf(m, "%lld\n", obd->obd_recovery_time_hard);
901 EXPORT_SYMBOL(lprocfs_recovery_time_hard_seq_show);
904 lprocfs_recovery_time_hard_seq_write(struct file *file,
905 const char __user *buffer,
906 size_t count, loff_t *off)
908 struct seq_file *m = file->private_data;
909 struct obd_device *obd = m->private;
913 LASSERT(obd != NULL);
914 rc = kstrtouint_from_user(buffer, count, 0, &val);
918 obd->obd_recovery_time_hard = val;
921 EXPORT_SYMBOL(lprocfs_recovery_time_hard_seq_write);
923 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data)
925 struct obd_device *obd = m->private;
926 struct obd_device_target *target = &obd->u.obt;
928 LASSERT(obd != NULL);
929 LASSERT(target->obt_magic == OBT_MAGIC);
930 seq_printf(m, "%u\n", obd->u.obt.obt_instance);
933 EXPORT_SYMBOL(lprocfs_target_instance_seq_show);
935 #endif /* CONFIG_PROC_FS*/