int ldlm_debugfs_setup(void) { int rc; ldlm_debugfs_dir = ldebugfs_register(OBD_LDLM_DEVICENAME, debugfs_lustre_root, NULL, NULL); if (IS_ERR_OR_NULL(ldlm_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); rc = ldlm_debugfs_dir ? PTR_ERR(ldlm_debugfs_dir) : -ENOMEM; goto err; } ldlm_ns_debugfs_dir = ldebugfs_register("namespaces", ldlm_debugfs_dir, NULL, NULL); if (IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); rc = ldlm_ns_debugfs_dir ? PTR_ERR(ldlm_ns_debugfs_dir) : -ENOMEM; goto err_type; } ldlm_svc_debugfs_dir = ldebugfs_register("services", ldlm_debugfs_dir, NULL, NULL); if (IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) { CERROR("LProcFS failed in ldlm-init\n"); rc = ldlm_svc_debugfs_dir ? PTR_ERR(ldlm_svc_debugfs_dir) : -ENOMEM; goto err_ns; } rc = ldebugfs_add_vars(ldlm_debugfs_dir, ldlm_debugfs_list, NULL); if (rc) { CERROR("LProcFS failed in ldlm-init\n"); goto err_svc; } return 0; err_svc: ldebugfs_remove(&ldlm_svc_debugfs_dir); err_ns: ldebugfs_remove(&ldlm_ns_debugfs_dir); err_type: ldebugfs_remove(&ldlm_debugfs_dir); err: ldlm_svc_debugfs_dir = NULL; ldlm_ns_debugfs_dir = NULL; ldlm_debugfs_dir = NULL; return rc; }
void ldlm_debugfs_cleanup(void) { if (!IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) ldebugfs_remove(&ldlm_svc_debugfs_dir); if (!IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) ldebugfs_remove(&ldlm_ns_debugfs_dir); if (!IS_ERR_OR_NULL(ldlm_debugfs_dir)) ldebugfs_remove(&ldlm_debugfs_dir); ldlm_svc_debugfs_dir = NULL; ldlm_ns_debugfs_dir = NULL; ldlm_debugfs_dir = NULL; }
static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns) { if (IS_ERR_OR_NULL(ns->ns_debugfs_entry)) CERROR("dlm namespace %s has no procfs dir?\n", ldlm_ns_name(ns)); else ldebugfs_remove(&ns->ns_debugfs_entry); if (ns->ns_stats) lprocfs_free_stats(&ns->ns_stats); }
static void __exit fid_exit(void) { if (!IS_ERR_OR_NULL(seq_debugfs_dir)) ldebugfs_remove(&seq_debugfs_dir); }
static void seq_client_debugfs_fini(struct lu_client_seq *seq) { if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) ldebugfs_remove(&seq->lcs_debugfs_entry); }
void sptlrpc_lproc_fini(void) { if (!IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) ldebugfs_remove(&sptlrpc_debugfs_dir); }
static void ptlrpc_ldebugfs_register(struct dentry *root, char *dir, char *name, struct dentry **debugfs_root_ret, struct lprocfs_stats **stats_ret) { struct dentry *svc_debugfs_entry; struct lprocfs_stats *svc_stats; int i, rc; unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV; LASSERT(!*debugfs_root_ret); LASSERT(!*stats_ret); svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES+LUSTRE_MAX_OPCODES, 0); if (!svc_stats) return; if (dir) { svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL); if (IS_ERR(svc_debugfs_entry)) { lprocfs_free_stats(&svc_stats); return; } } else { svc_debugfs_entry = root; } lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR, svc_counter_config, "req_waittime", "usec"); lprocfs_counter_init(svc_stats, PTLRPC_REQQDEPTH_CNTR, svc_counter_config, "req_qdepth", "reqs"); lprocfs_counter_init(svc_stats, PTLRPC_REQACTIVE_CNTR, svc_counter_config, "req_active", "reqs"); lprocfs_counter_init(svc_stats, PTLRPC_TIMEOUT, svc_counter_config, "req_timeout", "sec"); lprocfs_counter_init(svc_stats, PTLRPC_REQBUF_AVAIL_CNTR, svc_counter_config, "reqbuf_avail", "bufs"); for (i = 0; i < EXTRA_LAST_OPC; i++) { char *units; switch (i) { case BRW_WRITE_BYTES: case BRW_READ_BYTES: units = "bytes"; break; default: units = "reqs"; break; } lprocfs_counter_init(svc_stats, PTLRPC_LAST_CNTR + i, svc_counter_config, ll_eopcode2str(i), units); } for (i = 0; i < LUSTRE_MAX_OPCODES; i++) { __u32 opcode = ll_rpc_opcode_table[i].opcode; lprocfs_counter_init(svc_stats, EXTRA_MAX_OPCODES + i, svc_counter_config, ll_opcode2str(opcode), "usec"); } rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats); if (rc < 0) { if (dir) ldebugfs_remove(&svc_debugfs_entry); lprocfs_free_stats(&svc_stats); } else { if (dir) *debugfs_root_ret = svc_debugfs_entry; *stats_ret = svc_stats; } }