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, 2016, 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/lustre_idl.h>
43 #include <lustre_nodemap.h>
45 static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
48 struct obd_device *obd = class_name2obd(kobj->name);
50 return sprintf(buf, "%s\n", obd->obd_uuid.uuid);
54 static struct attribute *server_uuid_attrs[] = {
55 &lustre_attr_uuid.attr,
59 static struct attribute_group server_def_attr_group = {
60 .attrs = server_uuid_attrs,
63 void lprocfs_kset_unregister(struct obd_device *obd, struct kset *kset)
65 if (obd->obd_proc_entry) {
66 lprocfs_remove(&obd->obd_proc_entry);
67 obd->obd_proc_entry = NULL;
71 kset_unregister(kset);
73 EXPORT_SYMBOL(lprocfs_kset_unregister);
75 int lprocfs_kset_register(struct obd_device *obd, struct kset **kset)
77 struct kset *obd_kset;
80 obd_kset = kset_create_and_add(obd->obd_name, NULL,
81 obd->obd_type->typ_kobj);
83 CERROR("%s: cannot add new kset: rc = %d\n", obd->obd_name, rc);
88 obd->obd_attrs = &server_def_attr_group;
90 rc = sysfs_create_group(&obd_kset->kobj, obd->obd_attrs);
92 CERROR("%s: cannot create attr group: rc = %d\n", obd->obd_name,
94 kset_unregister(obd_kset);
99 obd->obd_proc_entry = lprocfs_register(obd->obd_name,
100 obd->obd_type->typ_procroot,
102 if (IS_ERR(obd->obd_proc_entry)) {
103 rc = PTR_ERR(obd->obd_proc_entry);
104 CERROR("%s: error %d setting up lprocfs\n", obd->obd_name, rc);
105 obd->obd_proc_entry = NULL;
107 kset_unregister(obd_kset);
113 EXPORT_SYMBOL(lprocfs_kset_register);
115 #ifdef CONFIG_PROC_FS
117 int lprocfs_evict_client_open(struct inode *inode, struct file *f)
119 struct obd_device *obd = PDE_DATA(file_inode(f));
121 atomic_inc(&obd->obd_evict_inprogress);
125 int lprocfs_evict_client_release(struct inode *inode, struct file *f)
127 struct obd_device *obd = PDE_DATA(file_inode(f));
129 atomic_dec(&obd->obd_evict_inprogress);
130 wake_up(&obd->obd_evict_inprogress_waitq);
135 #define BUFLEN (UUID_MAX + 5)
138 lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer,
139 size_t count, loff_t *off)
141 struct seq_file *m = file->private_data;
142 struct obd_device *obd = m->private;
145 OBD_ALLOC(kbuf, BUFLEN);
150 * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1
151 * bytes into kbuf, to ensure that the string is NUL-terminated.
152 * UUID_MAX should include a trailing NUL already.
154 if (copy_from_user(kbuf, buffer,
155 min_t(unsigned long, BUFLEN - 1, count))) {
159 tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count));
160 class_incref(obd, __func__, current);
162 if (strncmp(tmpbuf, "nid:", 4) == 0)
163 obd_export_evict_by_nid(obd, tmpbuf + 4);
164 else if (strncmp(tmpbuf, "uuid:", 5) == 0)
165 obd_export_evict_by_uuid(obd, tmpbuf + 5);
167 obd_export_evict_by_uuid(obd, tmpbuf);
169 class_decref(obd, __func__, current);
172 OBD_FREE(kbuf, BUFLEN);
175 EXPORT_SYMBOL(lprocfs_evict_client_seq_write);
179 int lprocfs_num_exports_seq_show(struct seq_file *m, void *data)
181 struct obd_device *obd = data;
183 LASSERT(obd != NULL);
184 seq_printf(m, "%u\n", obd->obd_num_exports);
187 EXPORT_SYMBOL(lprocfs_num_exports_seq_show);
189 static void lprocfs_free_client_stats(struct nid_stat *client_stat)
191 CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat,
192 client_stat->nid_proc, client_stat->nid_stats);
194 LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
195 "nid %s:count %d\n", libcfs_nid2str(client_stat->nid),
196 atomic_read(&client_stat->nid_exp_ref_count));
198 if (client_stat->nid_proc)
199 lprocfs_remove(&client_stat->nid_proc);
201 if (client_stat->nid_stats)
202 lprocfs_free_stats(&client_stat->nid_stats);
204 if (client_stat->nid_ldlm_stats)
205 lprocfs_free_stats(&client_stat->nid_ldlm_stats);
207 OBD_FREE_PTR(client_stat);
211 void lprocfs_free_per_client_stats(struct obd_device *obd)
213 struct cfs_hash *hash = obd->obd_nid_stats_hash;
214 struct nid_stat *stat;
217 /* we need extra list - because hash_exit called to early */
218 /* not need locking because all clients is died */
219 while (!list_empty(&obd->obd_nid_stats)) {
220 stat = list_entry(obd->obd_nid_stats.next,
221 struct nid_stat, nid_list);
222 list_del_init(&stat->nid_list);
223 cfs_hash_del(hash, &stat->nid, &stat->nid_hash);
224 lprocfs_free_client_stats(stat);
228 EXPORT_SYMBOL(lprocfs_free_per_client_stats);
231 lprocfs_exp_print_uuid_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
232 struct hlist_node *hnode, void *cb_data)
234 struct seq_file *m = cb_data;
235 struct obd_export *exp = cfs_hash_object(hs, hnode);
237 if (exp->exp_nid_stats != NULL)
238 seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid));
243 lprocfs_exp_print_nodemap_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
244 struct hlist_node *hnode, void *cb_data)
246 struct seq_file *m = cb_data;
247 struct obd_export *exp = cfs_hash_object(hs, hnode);
248 struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
251 seq_printf(m, "%s\n", nodemap->nm_name);
256 lprocfs_exp_nodemap_seq_show(struct seq_file *m, void *data)
258 struct nid_stat *stats = m->private;
259 struct obd_device *obd = stats->nid_obd;
261 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
262 lprocfs_exp_print_nodemap_seq, m);
265 LPROC_SEQ_FOPS_RO(lprocfs_exp_nodemap);
267 static int lprocfs_exp_uuid_seq_show(struct seq_file *m, void *data)
269 struct nid_stat *stats = m->private;
270 struct obd_device *obd = stats->nid_obd;
272 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
273 lprocfs_exp_print_uuid_seq, m);
276 LPROC_SEQ_FOPS_RO(lprocfs_exp_uuid);
279 lprocfs_exp_print_hash_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
280 struct hlist_node *hnode, void *cb_data)
283 struct seq_file *m = cb_data;
284 struct obd_export *exp = cfs_hash_object(hs, hnode);
286 if (exp->exp_lock_hash != NULL) {
287 cfs_hash_debug_header(m);
288 cfs_hash_debug_str(hs, m);
293 static int lprocfs_exp_hash_seq_show(struct seq_file *m, void *data)
295 struct nid_stat *stats = m->private;
296 struct obd_device *obd = stats->nid_obd;
298 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
299 lprocfs_exp_print_hash_seq, m);
302 LPROC_SEQ_FOPS_RO(lprocfs_exp_hash);
304 int lprocfs_exp_print_replydata_seq(struct cfs_hash *hs, struct cfs_hash_bd *bd,
305 struct hlist_node *hnode, void *cb_data)
308 struct obd_export *exp = cfs_hash_object(hs, hnode);
309 struct seq_file *m = cb_data;
310 struct tg_export_data *ted = &exp->exp_target_data;
312 seq_printf(m, "reply_cnt: %d\n"
314 "reply_released_by_xid: %d\n"
315 "reply_released_by_tag: %d\n\n",
318 ted->ted_release_xid,
319 ted->ted_release_tag);
323 int lprocfs_exp_replydata_seq_show(struct seq_file *m, void *data)
325 struct nid_stat *stats = m->private;
326 struct obd_device *obd = stats->nid_obd;
328 cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
329 lprocfs_exp_print_replydata_seq, m);
332 LPROC_SEQ_FOPS_RO(lprocfs_exp_replydata);
334 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
336 seq_puts(m, "Write into this file to clear all nid stats and stale nid entries\n");
339 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_show);
341 static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
343 struct nid_stat *stat = obj;
346 CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count));
347 if (atomic_read(&stat->nid_exp_ref_count) == 1) {
348 /* object has only hash references. */
349 spin_lock(&stat->nid_obd->obd_nid_lock);
350 list_move(&stat->nid_list, data);
351 spin_unlock(&stat->nid_obd->obd_nid_lock);
354 /* we has reference to object - only clear data*/
356 lprocfs_clear_stats(stat->nid_stats);
362 lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
363 size_t count, loff_t *off)
365 struct seq_file *m = file->private_data;
366 struct obd_device *obd = m->private;
367 struct nid_stat *client_stat;
368 struct list_head free_list;
370 INIT_LIST_HEAD(&free_list);
371 cfs_hash_cond_del(obd->obd_nid_stats_hash,
372 lprocfs_nid_stats_clear_write_cb, &free_list);
374 while (!list_empty(&free_list)) {
375 client_stat = list_entry(free_list.next, struct nid_stat,
377 list_del_init(&client_stat->nid_list);
378 lprocfs_free_client_stats(client_stat);
382 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_write);
384 int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid)
386 struct nid_stat *new_stat, *old_stat;
387 struct obd_device *obd = NULL;
388 struct proc_dir_entry *entry;
389 char nidstr[LNET_NIDSTR_SIZE];
393 if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry ||
394 !exp->exp_obd->obd_nid_stats_hash)
397 /* not test against zero because eric say:
398 * You may only test nid against another nid, or LNET_NID_ANY.
399 * Anything else is nonsense.*/
400 if (nid == NULL || *nid == LNET_NID_ANY)
403 libcfs_nid2str_r(*nid, nidstr, sizeof(nidstr));
405 spin_lock(&exp->exp_lock);
406 if (exp->exp_nid_stats != NULL) {
407 spin_unlock(&exp->exp_lock);
410 spin_unlock(&exp->exp_lock);
414 CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
416 OBD_ALLOC_PTR(new_stat);
417 if (new_stat == NULL)
420 new_stat->nid = *nid;
421 new_stat->nid_obd = exp->exp_obd;
422 /* we need set default refcount to 1 to balance obd_disconnect */
423 atomic_set(&new_stat->nid_exp_ref_count, 1);
425 old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash,
426 nid, &new_stat->nid_hash);
427 CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
428 old_stat, nidstr, atomic_read(&old_stat->nid_exp_ref_count));
430 /* Return -EALREADY here so that we know that the /proc
431 * entry already has been created */
432 if (old_stat != new_stat) {
433 spin_lock(&exp->exp_lock);
434 if (exp->exp_nid_stats) {
435 LASSERT(exp->exp_nid_stats == old_stat);
436 nidstat_putref(exp->exp_nid_stats);
438 exp->exp_nid_stats = old_stat;
439 spin_unlock(&exp->exp_lock);
440 GOTO(destroy_new, rc = -EALREADY);
442 /* not found - create */
443 new_stat->nid_proc = lprocfs_register(nidstr,
444 obd->obd_proc_exports_entry,
447 if (IS_ERR(new_stat->nid_proc)) {
448 rc = PTR_ERR(new_stat->nid_proc);
449 new_stat->nid_proc = NULL;
450 CERROR("%s: cannot create proc entry for export %s: rc = %d\n",
451 obd->obd_name, nidstr, rc);
452 GOTO(destroy_new_ns, rc);
455 entry = lprocfs_add_simple(new_stat->nid_proc, "nodemap", new_stat,
456 &lprocfs_exp_nodemap_fops);
459 CWARN("Error adding the nodemap file: rc = %d\n", rc);
460 GOTO(destroy_new_ns, rc);
463 entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", new_stat,
464 &lprocfs_exp_uuid_fops);
467 CWARN("Error adding the NID stats file: rc = %d\n", rc);
468 GOTO(destroy_new_ns, rc);
471 entry = lprocfs_add_simple(new_stat->nid_proc, "hash", new_stat,
472 &lprocfs_exp_hash_fops);
475 CWARN("Error adding the hash file: rc = %d\n", rc);
476 GOTO(destroy_new_ns, rc);
479 entry = lprocfs_add_simple(new_stat->nid_proc, "reply_data", new_stat,
480 &lprocfs_exp_replydata_fops);
483 CWARN("%s: Error adding the reply_data file: rc = %d\n",
485 GOTO(destroy_new_ns, rc);
488 spin_lock(&exp->exp_lock);
489 exp->exp_nid_stats = new_stat;
490 spin_unlock(&exp->exp_lock);
492 /* protect competitive add to list, not need locking on destroy */
493 spin_lock(&obd->obd_nid_lock);
494 list_add(&new_stat->nid_list, &obd->obd_nid_stats);
495 spin_unlock(&obd->obd_nid_lock);
500 if (new_stat->nid_proc != NULL)
501 lprocfs_remove(&new_stat->nid_proc);
502 cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
505 nidstat_putref(new_stat);
506 OBD_FREE_PTR(new_stat);
509 EXPORT_SYMBOL(lprocfs_exp_setup);
511 int lprocfs_exp_cleanup(struct obd_export *exp)
513 struct nid_stat *stat = exp->exp_nid_stats;
515 if (!stat || !exp->exp_obd)
518 nidstat_putref(exp->exp_nid_stats);
519 exp->exp_nid_stats = NULL;
524 #define LPROCFS_OBD_OP_INIT(base, stats, op) \
526 unsigned int coffset = base + OBD_COUNTER_OFFSET(op); \
527 LASSERT(coffset < stats->ls_num); \
528 lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \
531 void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
533 LPROCFS_OBD_OP_INIT(num_private_stats, stats, iocontrol);
534 LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_info);
535 LPROCFS_OBD_OP_INIT(num_private_stats, stats, set_info_async);
536 LPROCFS_OBD_OP_INIT(num_private_stats, stats, setup);
537 LPROCFS_OBD_OP_INIT(num_private_stats, stats, precleanup);
538 LPROCFS_OBD_OP_INIT(num_private_stats, stats, cleanup);
539 LPROCFS_OBD_OP_INIT(num_private_stats, stats, process_config);
540 LPROCFS_OBD_OP_INIT(num_private_stats, stats, postrecov);
541 LPROCFS_OBD_OP_INIT(num_private_stats, stats, add_conn);
542 LPROCFS_OBD_OP_INIT(num_private_stats, stats, del_conn);
543 LPROCFS_OBD_OP_INIT(num_private_stats, stats, connect);
544 LPROCFS_OBD_OP_INIT(num_private_stats, stats, reconnect);
545 LPROCFS_OBD_OP_INIT(num_private_stats, stats, disconnect);
546 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_init);
547 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_fini);
548 LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_alloc);
549 LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs);
550 LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs_async);
551 LPROCFS_OBD_OP_INIT(num_private_stats, stats, create);
552 LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy);
553 LPROCFS_OBD_OP_INIT(num_private_stats, stats, setattr);
554 LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr);
555 LPROCFS_OBD_OP_INIT(num_private_stats, stats, preprw);
556 LPROCFS_OBD_OP_INIT(num_private_stats, stats, commitrw);
557 LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_export);
558 LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy_export);
559 LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event);
560 LPROCFS_OBD_OP_INIT(num_private_stats, stats, notify);
561 LPROCFS_OBD_OP_INIT(num_private_stats, stats, health_check);
562 LPROCFS_OBD_OP_INIT(num_private_stats, stats, get_uuid);
563 LPROCFS_OBD_OP_INIT(num_private_stats, stats, quotactl);
564 LPROCFS_OBD_OP_INIT(num_private_stats, stats, ping);
565 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_new);
566 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_rem);
567 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_add);
568 LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_del);
569 LPROCFS_OBD_OP_INIT(num_private_stats, stats, getref);
570 LPROCFS_OBD_OP_INIT(num_private_stats, stats, putref);
572 CLASSERT(NUM_OBD_STATS == OBD_COUNTER_OFFSET(putref) + 1);
574 EXPORT_SYMBOL(lprocfs_init_ops_stats);
576 int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats)
578 struct lprocfs_stats *stats;
579 unsigned int num_stats;
582 LASSERT(obd->obd_stats == NULL);
583 LASSERT(obd->obd_proc_entry != NULL);
584 LASSERT(obd->obd_cntr_base == 0);
586 num_stats = NUM_OBD_STATS + num_private_stats;
587 stats = lprocfs_alloc_stats(num_stats, 0);
591 lprocfs_init_ops_stats(num_private_stats, stats);
593 for (i = num_private_stats; i < num_stats; i++) {
594 /* If this LBUGs, it is likely that an obd
595 * operation was added to struct obd_ops in
596 * <obd.h>, and that the corresponding line item
597 * LPROCFS_OBD_OP_INIT(.., .., opname)
598 * is missing from the list above. */
599 LASSERTF(stats->ls_cnt_header[i].lc_name != NULL,
600 "Missing obd_stat initializer obd_op "
601 "operation at offset %d.\n", i - num_private_stats);
603 rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats);
605 lprocfs_free_stats(&stats);
607 obd->obd_stats = stats;
608 obd->obd_cntr_base = num_private_stats;
612 EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
614 void lprocfs_free_obd_stats(struct obd_device *obd)
617 lprocfs_free_stats(&obd->obd_stats);
619 EXPORT_SYMBOL(lprocfs_free_obd_stats);
621 int lprocfs_hash_seq_show(struct seq_file *m, void *data)
623 struct obd_device *obd = m->private;
628 cfs_hash_debug_header(m);
629 cfs_hash_debug_str(obd->obd_uuid_hash, m);
630 cfs_hash_debug_str(obd->obd_nid_hash, m);
631 cfs_hash_debug_str(obd->obd_nid_stats_hash, m);
634 EXPORT_SYMBOL(lprocfs_hash_seq_show);
636 int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data)
638 struct obd_device *obd = m->private;
639 struct target_distribute_txn_data *tdtd;
641 LASSERT(obd != NULL);
643 seq_printf(m, "status: ");
644 if (obd->obd_max_recoverable_clients == 0) {
645 seq_printf(m, "INACTIVE\n");
649 /* sampled unlocked, but really... */
650 if (obd->obd_recovering == 0) {
651 seq_printf(m, "COMPLETE\n");
652 seq_printf(m, "recovery_start: %lld\n",
653 (s64)obd->obd_recovery_start);
654 seq_printf(m, "recovery_duration: %lld\n",
655 obd->obd_recovery_end ?
656 obd->obd_recovery_end - obd->obd_recovery_start :
657 ktime_get_real_seconds() - obd->obd_recovery_start);
658 /* Number of clients that have completed recovery */
659 seq_printf(m, "completed_clients: %d/%d\n",
660 obd->obd_max_recoverable_clients -
661 obd->obd_stale_clients,
662 obd->obd_max_recoverable_clients);
663 seq_printf(m, "replayed_requests: %d\n",
664 obd->obd_replayed_requests);
665 seq_printf(m, "last_transno: %lld\n",
666 obd->obd_next_recovery_transno - 1);
667 seq_printf(m, "VBR: %s\n", obd->obd_version_recov ?
668 "ENABLED" : "DISABLED");
669 seq_printf(m, "IR: %s\n", obd->obd_no_ir ?
670 "DISABLED" : "ENABLED");
674 tdtd = obd->u.obt.obt_lut->lut_tdtd;
675 if (tdtd && tdtd->tdtd_show_update_logs_retrievers) {
680 buf = tdtd->tdtd_show_update_logs_retrievers(
681 tdtd->tdtd_show_retrievers_cbdata,
684 seq_printf(m, "WAITING\n");
685 seq_printf(m, "non-ready MDTs: %s\n",
686 buf ? buf : "unknown (not enough RAM)");
687 seq_printf(m, "recovery_start: %lld\n",
688 (s64)obd->obd_recovery_start);
689 seq_printf(m, "time_waited: %lld\n",
690 (s64)(ktime_get_real_seconds() -
691 obd->obd_recovery_start));
697 if (likely(count > 0))
701 seq_printf(m, "RECOVERING\n");
702 seq_printf(m, "recovery_start: %lld\n", (s64)obd->obd_recovery_start);
703 seq_printf(m, "time_remaining: %lld\n",
704 ktime_get_real_seconds() >=
705 obd->obd_recovery_start +
706 obd->obd_recovery_timeout ? 0 :
707 (s64)(obd->obd_recovery_start +
708 obd->obd_recovery_timeout -
709 ktime_get_real_seconds()));
710 seq_printf(m, "connected_clients: %d/%d\n",
711 atomic_read(&obd->obd_connected_clients),
712 obd->obd_max_recoverable_clients);
713 /* Number of clients that have completed recovery */
714 seq_printf(m, "req_replay_clients: %d\n",
715 atomic_read(&obd->obd_req_replay_clients));
716 seq_printf(m, "lock_repay_clients: %d\n",
717 atomic_read(&obd->obd_lock_replay_clients));
718 seq_printf(m, "completed_clients: %d\n",
719 atomic_read(&obd->obd_connected_clients) -
720 atomic_read(&obd->obd_lock_replay_clients));
721 seq_printf(m, "evicted_clients: %d\n", obd->obd_stale_clients);
722 seq_printf(m, "replayed_requests: %d\n", obd->obd_replayed_requests);
723 seq_printf(m, "queued_requests: %d\n",
724 obd->obd_requests_queued_for_recovery);
725 seq_printf(m, "next_transno: %lld\n",
726 obd->obd_next_recovery_transno);
730 EXPORT_SYMBOL(lprocfs_recovery_status_seq_show);
732 int lprocfs_ir_factor_seq_show(struct seq_file *m, void *data)
734 struct obd_device *obd = m->private;
736 LASSERT(obd != NULL);
737 seq_printf(m, "%d\n", obd->obd_recovery_ir_factor);
740 EXPORT_SYMBOL(lprocfs_ir_factor_seq_show);
743 lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
744 size_t count, loff_t *off)
746 struct seq_file *m = file->private_data;
747 struct obd_device *obd = m->private;
751 LASSERT(obd != NULL);
752 rc = lprocfs_str_to_s64(buffer, count, &val);
756 if (val < OBD_IR_FACTOR_MIN || val > OBD_IR_FACTOR_MAX)
759 obd->obd_recovery_ir_factor = val;
762 EXPORT_SYMBOL(lprocfs_ir_factor_seq_write);
764 int lprocfs_checksum_dump_seq_show(struct seq_file *m, void *data)
766 struct obd_device *obd = m->private;
768 LASSERT(obd != NULL);
769 seq_printf(m, "%d\n", obd->obd_checksum_dump);
772 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_show);
775 lprocfs_checksum_dump_seq_write(struct file *file, const char __user *buffer,
776 size_t count, loff_t *off)
778 struct seq_file *m = file->private_data;
779 struct obd_device *obd = m->private;
783 LASSERT(obd != NULL);
784 rc = lprocfs_str_to_s64(buffer, count, &val);
788 obd->obd_checksum_dump = !!val;
791 EXPORT_SYMBOL(lprocfs_checksum_dump_seq_write);
793 int lprocfs_recovery_time_soft_seq_show(struct seq_file *m, void *data)
795 struct obd_device *obd = m->private;
797 LASSERT(obd != NULL);
798 seq_printf(m, "%llu\n", obd->obd_recovery_timeout);
801 EXPORT_SYMBOL(lprocfs_recovery_time_soft_seq_show);
804 lprocfs_recovery_time_soft_seq_write(struct file *file,
805 const char __user *buffer,
806 size_t count, loff_t *off)
808 struct seq_file *m = file->private_data;
809 struct obd_device *obd = m->private;
813 LASSERT(obd != NULL);
814 rc = lprocfs_str_to_s64(buffer, count, &val);
817 if (val < 0 || val > INT_MAX)
820 obd->obd_recovery_timeout = val;
823 EXPORT_SYMBOL(lprocfs_recovery_time_soft_seq_write);
825 int lprocfs_recovery_time_hard_seq_show(struct seq_file *m, void *data)
827 struct obd_device *obd = m->private;
829 LASSERT(obd != NULL);
830 seq_printf(m, "%lld\n", obd->obd_recovery_time_hard);
833 EXPORT_SYMBOL(lprocfs_recovery_time_hard_seq_show);
836 lprocfs_recovery_time_hard_seq_write(struct file *file,
837 const char __user *buffer,
838 size_t count, loff_t *off)
840 struct seq_file *m = file->private_data;
841 struct obd_device *obd = m->private;
845 LASSERT(obd != NULL);
846 rc = lprocfs_str_to_s64(buffer, count, &val);
849 if (val < 0 || val > INT_MAX)
852 obd->obd_recovery_time_hard = val;
855 EXPORT_SYMBOL(lprocfs_recovery_time_hard_seq_write);
857 int lprocfs_target_instance_seq_show(struct seq_file *m, void *data)
859 struct obd_device *obd = m->private;
860 struct obd_device_target *target = &obd->u.obt;
862 LASSERT(obd != NULL);
863 LASSERT(target->obt_magic == OBT_MAGIC);
864 seq_printf(m, "%u\n", obd->u.obt.obt_instance);
867 EXPORT_SYMBOL(lprocfs_target_instance_seq_show);
869 #endif /* CONFIG_PROC_FS*/