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);
75 if (IS_ERR_OR_NULL(entry)) {
76 CERROR("LdebugFS: Could not create symbolic link from %s to %s\n",
81 OBD_FREE(dest, MAX_STRING_SIZE + 1);
86 EXPORT_SYMBOL(ldebugfs_add_symlink);
90 int lprocfs_evict_client_open(struct inode *inode, struct file *f)
92 struct obd_device *obd = PDE_DATA(file_inode(f));
94 atomic_inc(&obd->obd_evict_inprogress);
98 int lprocfs_evict_client_release(struct inode *inode, struct file *f)
100 struct obd_device *obd = PDE_DATA(file_inode(f));
102 atomic_dec(&obd->obd_evict_inprogress);
103 wake_up(&obd->obd_evict_inprogress_waitq);
108 #define BUFLEN (UUID_MAX + 5)
111 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
112 size_t count, loff_t *off)
114 struct seq_file *m = file->private_data;
115 struct obd_device *obd = m->private;
118 OBD_ALLOC(kbuf, BUFLEN);
123 * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
124 * bytes into kbuf, to ensure that the string is NUL-terminated.
125 * UUID_MAX should include a trailing NUL already.
127 if (copy_from_user(kbuf, buffer,
128 min_t(unsigned long, BUFLEN - 1, count))) {
132 tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
133 class_incref(obd, __func__, current);
135 if (strncmp(tmpbuf, "nid:", 4) == 0)
136 obd_export_evict_by_nid(obd, tmpbuf + 4);
137 else if (strncmp(tmpbuf, "uuid:", 5) == 0)
138 obd_export_evict_by_uuid(obd, tmpbuf + 5);
140 obd_export_evict_by_uuid(obd, tmpbuf);
142 class_decref(obd, __func__, current);
145 OBD_FREE(kbuf, BUFLEN);
148 EXPORT_SYMBOL(lprocfs_evict_client_seq_write);
152 int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
154 struct obd_device *obd = data;
156 LASSERT(obd != NULL);
157 seq_printf(m, "%u\n", obd->obd_num_exports);
160 EXPORT_SYMBOL(lprocfs_num_exports_seq_show);
162 static int obd_export_flags2str(struct obd_export *exp, struct seq_file *m)
166 flag2str(exp, failed);
167 flag2str(exp, in_recovery);
168 flag2str(exp, disconnected);
169 flag2str(exp, connecting);
175 lprocfs_exp_print_export_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
176 struct hlist_node *hnode, void *cb_data)
178 struct seq_file *m = cb_data;
179 struct obd_export *exp = cfs_hash_object(hs, hnode);
180 struct obd_device *obd;
181 struct obd_connect_data *ocd;
183 LASSERT(exp != NULL);
184 if (exp->exp_nid_stats == NULL)
187 ocd = &exp->exp_connect_data;
189 seq_printf(m, "%s:\n"
192 " connect_flags: [ ",
193 obd_uuid2str(&exp->exp_client_uuid),
195 obd_export_nid2str(exp));
196 obd_connect_seq_flags2str(m, ocd->ocd_connect_flags,
197 ocd->ocd_connect_flags2, ", ");
198 seq_printf(m, " ]\n");
199 obd_connect_data_seqprint(m, ocd);
200 seq_printf(m, " export_flags: [ ");
201 obd_export_flags2str(exp, m);
202 seq_printf(m, " ]\n");
209 * RPC connections are composed of an import and an export. Using the
210 * lctl utility we can extract important information about the state.
211 * The lprocfs_exp_export_seq_show routine displays the state information
214 * \param[in] m seq file
215 * \param[in] data unused
217 * \retval 0 on success
219 * The format of the export state information is like:
220 * a793e354-49c0-aa11-8c4f-a4f2b1a1a92b:
222 * client: 10.211.55.10@tcp
223 * connect_flags: [ version, barrier, adaptive_timeouts, ... ]
225 * flags: 0x2000011005002020
227 * target_version: 2.10.51.0
228 * export_flags: [ ... ]
231 static int lprocfs_exp_export_seq_show(struct seq_file *m, void *data)
233 struct nid_stat *stats = m->private;
234 struct obd_device *obd = stats->nid_obd;
236 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
237 lprocfs_exp_print_export_seq, m);
240 LPROC_SEQ_FOPS_RO(lprocfs_exp_export);
242 static void lprocfs_free_client_stats(struct nid_stat *client_stat)
244 CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat,
245 client_stat->nid_proc, client_stat->nid_stats);
247 LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
248 "nid %s:count %d\n", libcfs_nid2str(client_stat->nid),
249 atomic_read(&client_stat->nid_exp_ref_count));
251 if (client_stat->nid_proc)
252 lprocfs_remove(&client_stat->nid_proc);
254 if (client_stat->nid_stats)
255 lprocfs_free_stats(&client_stat->nid_stats);
257 if (client_stat->nid_ldlm_stats)
258 lprocfs_free_stats(&client_stat->nid_ldlm_stats);
260 OBD_FREE_PTR(client_stat);
264 void lprocfs_free_per_client_stats(struct obd_device *obd)
266 struct cfs_hash *hash = obd->obd_nid_stats_hash;
267 struct nid_stat *stat;
270 /* we need extra list - because hash_exit called to early */
271 /* not need locking because all clients is died */
272 while (!list_empty(&obd->obd_nid_stats)) {
273 stat = list_entry(obd->obd_nid_stats.next,
274 struct nid_stat, nid_list);
275 list_del_init(&stat->nid_list);
276 cfs_hash_del(hash, &stat->nid, &stat->nid_hash);
277 lprocfs_free_client_stats(stat);
281 EXPORT_SYMBOL(lprocfs_free_per_client_stats);
284 lprocfs_exp_print_uuid_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
285 struct hlist_node *hnode, void *cb_data)
287 struct seq_file *m = cb_data;
288 struct obd_export *exp = cfs_hash_object(hs, hnode);
290 if (exp->exp_nid_stats != NULL)
291 seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid));
296 lprocfs_exp_print_nodemap_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
297 struct hlist_node *hnode, void *cb_data)
299 struct seq_file *m = cb_data;
300 struct obd_export *exp = cfs_hash_object(hs, hnode);
301 struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
304 seq_printf(m, "%s\n", nodemap->nm_name);
309 lprocfs_exp_nodemap_seq_show(struct seq_file *m, void *data)
311 struct nid_stat *stats = m->private;
312 struct obd_device *obd = stats->nid_obd;
314 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
315 lprocfs_exp_print_nodemap_seq, m);
318 LPROC_SEQ_FOPS_RO(lprocfs_exp_nodemap);
320 static int lprocfs_exp_uuid_seq_show(struct seq_file *m, void *data)
322 struct nid_stat *stats = m->private;
323 struct obd_device *obd = stats->nid_obd;
325 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
326 lprocfs_exp_print_uuid_seq, m);
329 LPROC_SEQ_FOPS_RO(lprocfs_exp_uuid);
332 lprocfs_exp_print_hash_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
333 struct hlist_node *hnode, void *cb_data)
336 struct seq_file *m = cb_data;
337 struct obd_export *exp = cfs_hash_object(hs, hnode);
339 if (exp->exp_lock_hash != NULL) {
340 cfs_hash_debug_header(m);
341 cfs_hash_debug_str(hs, m);
346 static int lprocfs_exp_hash_seq_show(struct seq_file *m, void *data)
348 struct nid_stat *stats = m->private;
349 struct obd_device *obd = stats->nid_obd;
351 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
352 lprocfs_exp_print_hash_seq, m);
355 LPROC_SEQ_FOPS_RO(lprocfs_exp_hash);
357 int lprocfs_exp_print_replydata_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
358 struct hlist_node *hnode, void *cb_data)
361 struct obd_export *exp = cfs_hash_object(hs, hnode);
362 struct seq_file *m = cb_data;
363 struct tg_export_data *ted = &exp->exp_target_data;
365 seq_printf(m, "reply_cnt: %d\n"
367 "reply_released_by_xid: %d\n"
368 "reply_released_by_tag: %d\n\n",
371 ted->ted_release_xid,
372 ted->ted_release_tag);
376 int lprocfs_exp_replydata_seq_show(struct seq_file *m, void *data)
378 struct nid_stat *stats = m->private;
379 struct obd_device *obd = stats->nid_obd;
381 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
382 lprocfs_exp_print_replydata_seq, m);
385 LPROC_SEQ_FOPS_RO(lprocfs_exp_replydata);
387 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
389 seq_puts(m, "Write into this file to clear all nid stats and stale nid entries\n");
392 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_show);
394 static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
396 struct nid_stat *stat = obj;
399 CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count));
400 if (atomic_read(&stat->nid_exp_ref_count) == 1) {
401 /* object has only hash references. */
402 spin_lock(&stat->nid_obd->obd_nid_lock);
403 list_move(&stat->nid_list, data);
404 spin_unlock(&stat->nid_obd->obd_nid_lock);
407 /* we has reference to object - only clear data*/
409 lprocfs_clear_stats(stat->nid_stats);
415 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
416 size_t count, loff_t *off)
418 struct seq_file *m = file->private_data;
419 struct obd_device *obd = m->private;
420 struct nid_stat *client_stat;
421 struct list_head free_list;
423 INIT_LIST_HEAD(&free_list);
424 cfs_hash_cond_del(obd->obd_nid_stats_hash,
425 lprocfs_nid_stats_clear_write_cb, &free_list);
427 while (!list_empty(&free_list)) {
428 client_stat = list_entry(free_list.next, struct nid_stat,
430 list_del_init(&client_stat->nid_list);
431 lprocfs_free_client_stats(client_stat);
435 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_write);
437 int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid)
439 struct nid_stat *new_stat, *old_stat;
440 struct obd_device *obd = NULL;
441 struct proc_dir_entry *entry;
442 char nidstr[LNET_NIDSTR_SIZE];
446 if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry ||
447 !exp->exp_obd->obd_nid_stats_hash)
450 /* not test against zero because eric say:
451 * You may only test nid against another nid, or LNET_NID_ANY.
452 * Anything else is nonsense.*/
453 if (nid == NULL || *nid == LNET_NID_ANY)
456 libcfs_nid2str_r(*nid, nidstr, sizeof(nidstr));
458 spin_lock(&exp->exp_lock);
459 if (exp->exp_nid_stats != NULL) {
460 spin_unlock(&exp->exp_lock);
463 spin_unlock(&exp->exp_lock);
467 CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
469 OBD_ALLOC_PTR(new_stat);
470 if (new_stat == NULL)
473 new_stat->nid = *nid;
474 new_stat->nid_obd = exp->exp_obd;
475 /* we need set default refcount to 1 to balance obd_disconnect */
476 atomic_set(&new_stat->nid_exp_ref_count, 1);
478 old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash,
479 nid, &new_stat->nid_hash);
480 CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
481 old_stat, nidstr, atomic_read(&old_stat->nid_exp_ref_count));
483 /* Return -EALREADY here so that we know that the /proc
484 * entry already has been created */
485 if (old_stat != new_stat) {
486 spin_lock(&exp->exp_lock);
487 if (exp->exp_nid_stats) {
488 LASSERT(exp->exp_nid_stats == old_stat);
489 nidstat_putref(exp->exp_nid_stats);
491 exp->exp_nid_stats = old_stat;
492 spin_unlock(&exp->exp_lock);
493 GOTO(destroy_new, rc = -EALREADY);
495 /* not found - create */
496 new_stat->nid_proc = lprocfs_register(nidstr,
497 obd->obd_proc_exports_entry,
500 if (IS_ERR(new_stat->nid_proc)) {
501 rc = PTR_ERR(new_stat->nid_proc);
502 new_stat->nid_proc = NULL;
503 CERROR("%s: cannot create proc entry for export %s: rc = %d\n",
504 obd->obd_name, nidstr, rc);
505 GOTO(destroy_new_ns, rc);
508 entry = lprocfs_add_simple(new_stat->nid_proc, "nodemap", new_stat,
509 &lprocfs_exp_nodemap_fops);
512 CWARN("%s: error adding the nodemap file: rc = %d\n",
514 GOTO(destroy_new_ns, rc);
517 entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", new_stat,
518 &lprocfs_exp_uuid_fops);
521 CWARN("%s: error adding the NID stats file: rc = %d\n",
523 GOTO(destroy_new_ns, rc);
526 entry = lprocfs_add_simple(new_stat->nid_proc, "hash", new_stat,
527 &lprocfs_exp_hash_fops);
530 CWARN("%s: error adding the hash file: rc = %d\n",
532 GOTO(destroy_new_ns, rc);
535 entry = lprocfs_add_simple(new_stat->nid_proc, "export",
536 new_stat, &lprocfs_exp_export_fops);
539 CWARN("%s: error adding the export file: rc = %d\n",
541 GOTO(destroy_new_ns, rc);
544 entry = lprocfs_add_simple(new_stat->nid_proc, "reply_data", new_stat,
545 &lprocfs_exp_replydata_fops);
548 CWARN("%s: error adding the reply_data file: rc = %d\n",
550 GOTO(destroy_new_ns, rc);
553 spin_lock(&exp->exp_lock);
554 exp->exp_nid_stats = new_stat;
555 spin_unlock(&exp->exp_lock);
557 /* protect competitive add to list, not need locking on destroy */
558 spin_lock(&obd->obd_nid_lock);
559 list_add(&new_stat->nid_list, &obd->obd_nid_stats);
560 spin_unlock(&obd->obd_nid_lock);
565 if (new_stat->nid_proc != NULL)
566 lprocfs_remove(&new_stat->nid_proc);
567 cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
570 nidstat_putref(new_stat);
571 OBD_FREE_PTR(new_stat);
574 EXPORT_SYMBOL(lprocfs_exp_setup);
576 int lprocfs_exp_cleanup(struct obd_export *exp)
578 struct nid_stat *stat = exp->exp_nid_stats;
580 if (!stat || !exp->exp_obd)
583 nidstat_putref(exp->exp_nid_stats);
584 exp->exp_nid_stats = NULL;
589 #define LPROCFS_OBD_OP_INIT(base, stats, op) \
591 unsigned int coffset = base + OBD_COUNTER_OFFSET(op); \
592 LASSERT(coffset < stats->ls_num); \
593 lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \
596 void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
598 LPROCFS_OBD_OP_INIT(num_private_stats, stats, iocontrol);
599 LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_info);
600 LPROCFS_OBD_OP_INIT(num_private_stats, stats, set_info_async);
601 LPROCFS_OBD_OP_INIT(num_private_stats, stats, setup);
602 LPROCFS_OBD_OP_INIT(num_private_stats, stats, precleanup);
603 LPROCFS_OBD_OP_INIT(num_private_stats, stats, cleanup);
604 LPROCFS_OBD_OP_INIT(num_private_stats, stats, process_config);
605 LPROCFS_OBD_OP_INIT(num_private_stats, stats, postrecov);
606 LPROCFS_OBD_OP_INIT(num_private_stats, stats, add_conn);
607 LPROCFS_OBD_OP_INIT(num_private_stats, stats, del_conn);
608 LPROCFS_OBD_OP_INIT(num_private_stats, stats, connect);
609 LPROCFS_OBD_OP_INIT(num_private_stats, stats, reconnect);
610 LPROCFS_OBD_OP_INIT(num_private_stats, stats, disconnect);
611 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_init);
612 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_fini);
613 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_alloc);
614 LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs);
615 LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs_async);
616 LPROCFS_OBD_OP_INIT(num_private_stats, stats, create);
617 LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy);
618 LPROCFS_OBD_OP_INIT(num_private_stats, stats, setattr);
619 LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr);
620 LPROCFS_OBD_OP_INIT(num_private_stats, stats, preprw);
621 LPROCFS_OBD_OP_INIT(num_private_stats, stats, commitrw);
622 LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_export);
623 LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy_export);
624 LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event);
625 LPROCFS_OBD_OP_INIT(num_private_stats, stats, notify);
626 LPROCFS_OBD_OP_INIT(num_private_stats, stats, health_check);
627 LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_uuid);
628 LPROCFS_OBD_OP_INIT(num_private_stats, stats, quotactl);
629 LPROCFS_OBD_OP_INIT(num_private_stats, stats, ping);
630 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_new);
631 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_rem);
632 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_add);
633 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_del);
634 LPROCFS_OBD_OP_INIT(num_private_stats, stats, getref);
635 LPROCFS_OBD_OP_INIT(num_private_stats, stats, putref);
637 CLASSERT(NUM_OBD_STATS == OBD_COUNTER_OFFSET(putref) + 1);
639 EXPORT_SYMBOL(lprocfs_init_ops_stats);
641 int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats)
643 struct lprocfs_stats *stats;
644 unsigned int num_stats;
647 LASSERT(obd->obd_stats == NULL);
648 LASSERT(obd->obd_proc_entry != NULL);
649 LASSERT(obd->obd_cntr_base == 0);
651 num_stats = NUM_OBD_STATS + num_private_stats;
652 stats = lprocfs_alloc_stats(num_stats, 0);
656 lprocfs_init_ops_stats(num_private_stats, stats);
658 for (i = num_private_stats; i < num_stats; i++) {
659 /* If this LBUGs, it is likely that an obd
660 * operation was added to struct obd_ops in
661 * <obd.h>, and that the corresponding line item
662 * LPROCFS_OBD_OP_INIT(.., .., opname)
663 * is missing from the list above. */
664 LASSERTF(stats->ls_cnt_header[i].lc_name != NULL,
665 "Missing obd_stat initializer obd_op "
666 "operation at offset %d.\n", i - num_private_stats);
668 rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats);
670 lprocfs_free_stats(&stats);
672 obd->obd_stats = stats;
673 obd->obd_cntr_base = num_private_stats;
677 EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
679 void lprocfs_free_obd_stats(struct obd_device *obd)
682 lprocfs_free_stats(&obd->obd_stats);
684 EXPORT_SYMBOL(lprocfs_free_obd_stats);
686 int lprocfs_hash_seq_show(struct seq_file *m, void *data)
688 struct obd_device *obd = m->private;
693 cfs_hash_debug_header(m);
694 cfs_hash_debug_str(obd->obd_uuid_hash, m);
695 cfs_hash_debug_str(obd->obd_nid_hash, m);
696 cfs_hash_debug_str(obd->obd_nid_stats_hash, m);
699 EXPORT_SYMBOL(lprocfs_hash_seq_show);
701 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data)
703 struct obd_device *obd = m->private;
704 struct target_distribute_txn_data *tdtd;
706 LASSERT(obd != NULL);
708 seq_printf(m, "status: ");
709 if (obd->obd_max_recoverable_clients == 0) {
710 seq_printf(m, "INACTIVE\n");
714 /* sampled unlocked, but really... */
715 if (obd->obd_recovering == 0) {
716 seq_printf(m, "COMPLETE\n");
717 seq_printf(m, "recovery_start: %lld\n",
718 (s64)obd->obd_recovery_start);
719 seq_printf(m, "recovery_duration: %lld\n",
720 obd->obd_recovery_end ?
721 obd->obd_recovery_end - obd->obd_recovery_start :
722 ktime_get_real_seconds() - obd->obd_recovery_start);
723 /* Number of clients that have completed recovery */
724 seq_printf(m, "completed_clients: %d/%d\n",
725 obd->obd_max_recoverable_clients -
726 obd->obd_stale_clients,
727 obd->obd_max_recoverable_clients);
728 seq_printf(m, "replayed_requests: %d\n",
729 obd->obd_replayed_requests);
730 seq_printf(m, "last_transno: %lld\n",
731 obd->obd_next_recovery_transno - 1);
732 seq_printf(m, "VBR: %s\n", obd->obd_version_recov ?
733 "ENABLED" : "DISABLED");
734 seq_printf(m, "IR: %s\n", obd->obd_no_ir ?
735 "DISABLED" : "ENABLED");
739 tdtd = obd->u.obt.obt_lut->lut_tdtd;
740 if (tdtd && tdtd->tdtd_show_update_logs_retrievers) {
745 buf = tdtd->tdtd_show_update_logs_retrievers(
746 tdtd->tdtd_show_retrievers_cbdata,
749 seq_printf(m, "WAITING\n");
750 seq_printf(m, "non-ready MDTs: %s\n",
751 buf ? buf : "unknown (not enough RAM)");
752 seq_printf(m, "recovery_start: %lld\n",
753 (s64)obd->obd_recovery_start);
754 seq_printf(m, "time_waited: %lld\n",
755 (s64)(ktime_get_real_seconds() -
756 obd->obd_recovery_start));
762 if (likely(count > 0))
766 /* recovery won't start until the clients connect */
767 if (obd->obd_recovery_start == 0) {
768 seq_printf(m, "WAITING_FOR_CLIENTS\n");
772 seq_printf(m, "RECOVERING\n");
773 seq_printf(m, "recovery_start: %lld\n", (s64)obd->obd_recovery_start);
774 seq_printf(m, "time_remaining: %lld\n",
775 ktime_get_real_seconds() >=
776 obd->obd_recovery_start +
777 obd->obd_recovery_timeout ? 0 :
778 (s64)(obd->obd_recovery_start +
779 obd->obd_recovery_timeout -
780 ktime_get_real_seconds()));
781 seq_printf(m, "connected_clients: %d/%d\n",
782 atomic_read(&obd->obd_connected_clients),
783 obd->obd_max_recoverable_clients);
784 /* Number of clients that have completed recovery */
785 seq_printf(m, "req_replay_clients: %d\n",
786 atomic_read(&obd->obd_req_replay_clients));
787 seq_printf(m, "lock_repay_clients: %d\n",
788 atomic_read(&obd->obd_lock_replay_clients));
789 seq_printf(m, "completed_clients: %d\n",
790 atomic_read(&obd->obd_connected_clients) -
791 atomic_read(&obd->obd_lock_replay_clients));
792 seq_printf(m, "evicted_clients: %d\n", obd->obd_stale_clients);
793 seq_printf(m, "replayed_requests: %d\n", obd->obd_replayed_requests);
794 seq_printf(m, "queued_requests: %d\n",
795 obd->obd_requests_queued_for_recovery);
796 seq_printf(m, "next_transno: %lld\n",
797 obd->obd_next_recovery_transno);
801 EXPORT_SYMBOL(lprocfs_recovery_status_seq_show);
803 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data)
805 struct obd_device *obd = m->private;
807 LASSERT(obd != NULL);
808 seq_printf(m, "%d\n", obd->obd_recovery_ir_factor);
811 EXPORT_SYMBOL(lprocfs_ir_factor_seq_show);
814 lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
815 size_t count, loff_t *off)
817 struct seq_file *m = file->private_data;
818 struct obd_device *obd = m->private;
822 LASSERT(obd != NULL);
823 rc = kstrtoint_from_user(buffer, count, 10, &val);
827 if (val < OBD_IR_FACTOR_MIN || val > OBD_IR_FACTOR_MAX)
830 obd->obd_recovery_ir_factor = val;
833 EXPORT_SYMBOL(lprocfs_ir_factor_seq_write);
835 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data)
837 struct obd_device *obd = m->private;
839 LASSERT(obd != NULL);
840 seq_printf(m, "%d\n", obd->obd_checksum_dump);
843 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_show);
846 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
847 size_t count, loff_t *off)
849 struct seq_file *m = file->private_data;
850 struct obd_device *obd = m->private;
854 LASSERT(obd != NULL);
855 rc = kstrtobool_from_user(buffer, count, &val);
859 obd->obd_checksum_dump = val;
862 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_write);
864 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data)
866 struct obd_device *obd = m->private;
868 LASSERT(obd != NULL);
869 seq_printf(m, "%llu\n", obd->obd_recovery_timeout);
872 EXPORT_SYMBOL(lprocfs_recovery_time_soft_seq_show);
875 lprocfs_recovery_time_soft_seq_write(struct file *file,
876 const char __user *buffer,
877 size_t count, loff_t *off)
879 struct seq_file *m = file->private_data;
880 struct obd_device *obd = m->private;
884 LASSERT(obd != NULL);
885 rc = kstrtouint_from_user(buffer, count, 0, &val);
889 obd->obd_recovery_timeout = val;
892 EXPORT_SYMBOL(lprocfs_recovery_time_soft_seq_write);
894 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data)
896 struct obd_device *obd = m->private;
898 LASSERT(obd != NULL);
899 seq_printf(m, "%lld\n", obd->obd_recovery_time_hard);
902 EXPORT_SYMBOL(lprocfs_recovery_time_hard_seq_show);
905 lprocfs_recovery_time_hard_seq_write(struct file *file,
906 const char __user *buffer,
907 size_t count, loff_t *off)
909 struct seq_file *m = file->private_data;
910 struct obd_device *obd = m->private;
914 LASSERT(obd != NULL);
915 rc = kstrtouint_from_user(buffer, count, 0, &val);
919 obd->obd_recovery_time_hard = val;
922 EXPORT_SYMBOL(lprocfs_recovery_time_hard_seq_write);
924 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data)
926 struct obd_device *obd = m->private;
927 struct obd_device_target *target = &obd->u.obt;
929 LASSERT(obd != NULL);
930 LASSERT(target->obt_magic == OBT_MAGIC);
931 seq_printf(m, "%u\n", obd->u.obt.obt_instance);
934 EXPORT_SYMBOL(lprocfs_target_instance_seq_show);
936 #endif /* CONFIG_PROC_FS*/