int gss_init_lproc(void) { int rc; spin_lock_init(&gss_stat_oos.oos_lock); gss_proc_root = lprocfs_seq_register("gss", sptlrpc_proc_root, gss_lprocfs_vars, NULL); if (IS_ERR(gss_proc_root)) { rc = PTR_ERR(gss_proc_root); gss_proc_root = NULL; GOTO(out, rc); } gss_proc_lk = lprocfs_seq_register("lgss_keyring", gss_proc_root, gss_lk_lprocfs_vars, NULL); if (IS_ERR(gss_proc_lk)) { rc = PTR_ERR(gss_proc_lk); gss_proc_lk = NULL; GOTO(out, rc); } return 0; out: CERROR("failed to initialize gss lproc entries: %d\n", rc); gss_exit_lproc(); return rc; }
static int seq_client_proc_init(struct lu_client_seq *seq) { #ifdef LPROCFS int rc; ENTRY; seq->lcs_proc_dir = lprocfs_seq_register(seq->lcs_name, seq_type_proc_dir, NULL, NULL); if (IS_ERR(seq->lcs_proc_dir)) { CERROR("%s: LProcFS failed in seq-init\n", seq->lcs_name); rc = PTR_ERR(seq->lcs_proc_dir); RETURN(rc); } rc = lprocfs_seq_add_vars(seq->lcs_proc_dir, seq_client_proc_list, seq); if (rc) { CERROR("%s: Can't init sequence manager " "proc, rc %d\n", seq->lcs_name, rc); GOTO(out_cleanup, rc); } RETURN(0); out_cleanup: seq_client_proc_fini(seq); return rc; #else /* LPROCFS */ return 0; #endif }
static int __init fid_mod_init(void) { seq_type_proc_dir = lprocfs_seq_register(LUSTRE_SEQ_NAME, proc_lustre_root, NULL, NULL); if (IS_ERR(seq_type_proc_dir)) return PTR_ERR(seq_type_proc_dir); # ifdef HAVE_SERVER_SUPPORT fid_server_mod_init(); # endif return 0; }
static int fld_server_proc_init(struct lu_server_fld *fld) { int rc = 0; ENTRY; fld->lsf_proc_dir = lprocfs_seq_register(fld->lsf_name, fld_type_proc_dir, fld_server_proc_list, fld); if (IS_ERR(fld->lsf_proc_dir)) { rc = PTR_ERR(fld->lsf_proc_dir); RETURN(rc); } rc = lprocfs_seq_create(fld->lsf_proc_dir, "fldb", 0444, &fld_proc_seq_fops, fld); if (rc) { lprocfs_remove(&fld->lsf_proc_dir); fld->lsf_proc_dir = NULL; } RETURN(rc); }
int osd_procfs_init(struct osd_device *osd, const char *name) { struct obd_type *type; int rc; ENTRY; if (osd->od_proc_entry) RETURN(0); /* at the moment there is no linkage between lu_type * and obd_type, so we lookup obd_type this way */ type = class_search_type(LUSTRE_OSD_LDISKFS_NAME); LASSERT(name != NULL); LASSERT(type != NULL); /* Find the type procroot and add the proc entry for this device */ osd->od_proc_entry = lprocfs_seq_register(name, type->typ_procroot, lprocfs_osd_obd_vars, &osd->od_dt_dev); if (IS_ERR(osd->od_proc_entry)) { rc = PTR_ERR(osd->od_proc_entry); CERROR("Error %d setting up lprocfs for %s\n", rc, name); osd->od_proc_entry = NULL; GOTO(out, rc); } rc = osd_stats_init(osd); EXIT; out: if (rc) osd_procfs_fini(osd); return rc; }
/* * Create a new qsd_instance to be associated with backend osd device * identified by \dev. * * \param env - the environment passed by the caller * \param svname - is the service name of the OSD device creating this instance * \param dev - is the dt_device where to store quota index files * \param osd_proc - is the procfs parent directory where to create procfs file * related to this new qsd instance * * \retval - pointer to new qsd_instance associated with dev \dev on success, * appropriate error on failure */ struct qsd_instance *qsd_init(const struct lu_env *env, char *svname, struct dt_device *dev, cfs_proc_dir_entry_t *osd_proc) { struct qsd_thread_info *qti = qsd_info(env); struct qsd_instance *qsd; int rc, type, idx; ENTRY; /* only configure qsd for MDT & OST */ type = server_name2index(svname, &idx, NULL); if (type != LDD_F_SV_TYPE_MDT && type != LDD_F_SV_TYPE_OST) RETURN(NULL); /* allocate qsd instance */ OBD_ALLOC_PTR(qsd); if (qsd == NULL) RETURN(ERR_PTR(-ENOMEM)); /* generic initializations */ rwlock_init(&qsd->qsd_lock); CFS_INIT_LIST_HEAD(&qsd->qsd_link); thread_set_flags(&qsd->qsd_upd_thread, SVC_STOPPED); init_waitqueue_head(&qsd->qsd_upd_thread.t_ctl_waitq); CFS_INIT_LIST_HEAD(&qsd->qsd_upd_list); spin_lock_init(&qsd->qsd_adjust_lock); CFS_INIT_LIST_HEAD(&qsd->qsd_adjust_list); qsd->qsd_prepared = false; qsd->qsd_started = false; /* copy service name */ if (strlcpy(qsd->qsd_svname, svname, sizeof(qsd->qsd_svname)) >= sizeof(qsd->qsd_svname)) GOTO(out, rc = -E2BIG); /* grab reference on osd device */ lu_device_get(&dev->dd_lu_dev); lu_ref_add(&dev->dd_lu_dev.ld_reference, "qsd", qsd); qsd->qsd_dev = dev; /* we only support pool ID 0 (default data or metadata pool) for the * time being. A different pool ID could be assigned to this target via * the configuration log in the future */ qsd->qsd_pool_id = 0; /* get fsname from svname */ rc = server_name2fsname(svname, qti->qti_buf, NULL); if (rc) { CERROR("%s: fail to extract filesystem name\n", svname); GOTO(out, rc); } /* look up quota setting for the filesystem the target belongs to */ qsd->qsd_fsinfo = qsd_get_fsinfo(qti->qti_buf, 1); if (qsd->qsd_fsinfo == NULL) { CERROR("%s: failed to locate filesystem information\n", svname); GOTO(out, rc = -EINVAL); } /* add in the list of lquota_fsinfo */ mutex_lock(&qsd->qsd_fsinfo->qfs_mutex); list_add_tail(&qsd->qsd_link, &qsd->qsd_fsinfo->qfs_qsd_list); mutex_unlock(&qsd->qsd_fsinfo->qfs_mutex); /* register procfs directory */ qsd->qsd_proc = lprocfs_seq_register(QSD_DIR, osd_proc, lprocfs_quota_qsd_vars, qsd); if (IS_ERR(qsd->qsd_proc)) { rc = PTR_ERR(qsd->qsd_proc); qsd->qsd_proc = NULL; CERROR("%s: fail to create quota slave proc entry (%d)\n", svname, rc); GOTO(out, rc); } EXIT; out: if (rc) { qsd_fini(env, qsd); return ERR_PTR(rc); } RETURN(qsd); }
int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) { struct nid_stat *new_stat, *old_stat; struct obd_device *obd = NULL; struct proc_dir_entry *entry; char *buffer = NULL; int rc = 0; ENTRY; *newnid = 0; if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry || !exp->exp_obd->obd_nid_stats_hash) RETURN(-EINVAL); /* not test against zero because eric say: * You may only test nid against another nid, or LNET_NID_ANY. * Anything else is nonsense.*/ if (!nid || *nid == LNET_NID_ANY) RETURN(0); spin_lock(&exp->exp_lock); if (exp->exp_nid_stats != NULL) { spin_unlock(&exp->exp_lock); RETURN(-EALREADY); } spin_unlock(&exp->exp_lock); obd = exp->exp_obd; CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash); OBD_ALLOC_PTR(new_stat); if (new_stat == NULL) RETURN(-ENOMEM); new_stat->nid = *nid; new_stat->nid_obd = exp->exp_obd; /* we need set default refcount to 1 to balance obd_disconnect */ atomic_set(&new_stat->nid_exp_ref_count, 1); old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash); CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n", old_stat, libcfs_nid2str(*nid), atomic_read(&new_stat->nid_exp_ref_count)); /* Return -EALREADY here so that we know that the /proc * entry already has been created */ if (old_stat != new_stat) { spin_lock(&exp->exp_lock); if (exp->exp_nid_stats) { LASSERT(exp->exp_nid_stats == old_stat); nidstat_putref(exp->exp_nid_stats); } exp->exp_nid_stats = old_stat; spin_unlock(&exp->exp_lock); GOTO(destroy_new, rc = -EALREADY); } /* not found - create */ OBD_ALLOC(buffer, LNET_NIDSTR_SIZE); if (buffer == NULL) GOTO(destroy_new, rc = -ENOMEM); memcpy(buffer, libcfs_nid2str(*nid), LNET_NIDSTR_SIZE); #ifndef HAVE_ONLY_PROCFS_SEQ new_stat->nid_proc = lprocfs_register(buffer, obd->obd_proc_exports_entry, NULL, NULL); #else new_stat->nid_proc = lprocfs_seq_register(buffer, obd->obd_proc_exports_entry, NULL, NULL); #endif OBD_FREE(buffer, LNET_NIDSTR_SIZE); if (IS_ERR(new_stat->nid_proc)) { rc = PTR_ERR(new_stat->nid_proc); new_stat->nid_proc = NULL; CERROR("%s: cannot create proc entry for export %s: rc = %d\n", obd->obd_name, libcfs_nid2str(*nid), rc); GOTO(destroy_new_ns, rc); } entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", new_stat, &lprocfs_exp_uuid_fops); if (IS_ERR(entry)) { CWARN("Error adding the NID stats file\n"); rc = PTR_ERR(entry); GOTO(destroy_new_ns, rc); } entry = lprocfs_add_simple(new_stat->nid_proc, "hash", new_stat, &lprocfs_exp_hash_fops); if (IS_ERR(entry)) { CWARN("Error adding the hash file\n"); rc = PTR_ERR(entry); GOTO(destroy_new_ns, rc); } spin_lock(&exp->exp_lock); exp->exp_nid_stats = new_stat; spin_unlock(&exp->exp_lock); *newnid = 1; /* protect competitive add to list, not need locking on destroy */ spin_lock(&obd->obd_nid_lock); list_add(&new_stat->nid_list, &obd->obd_nid_stats); spin_unlock(&obd->obd_nid_lock); RETURN(rc); destroy_new_ns: if (new_stat->nid_proc != NULL) lprocfs_remove(&new_stat->nid_proc); cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash); destroy_new: nidstat_putref(new_stat); OBD_FREE_PTR(new_stat); RETURN(rc); }
struct lprocfs_seq_vars list[] = { { .name = "dump_namespaces", .fops = &ldlm_dump_ns_fops, .proc_mode = 0222 }, { .name = "dump_granted_max", .fops = &ldlm_rw_uint_fops, .data = &ldlm_dump_granted_max }, { .name = "cancel_unused_locks_before_replay", .fops = &ldlm_rw_uint_fops, .data = &ldlm_cancel_unused_locks_before_replay }, { NULL }}; ENTRY; LASSERT(ldlm_ns_proc_dir == NULL); ldlm_type_proc_dir = lprocfs_seq_register(OBD_LDLM_DEVICENAME, proc_lustre_root, NULL, NULL); if (IS_ERR(ldlm_type_proc_dir)) { CERROR("LProcFS failed in ldlm-init\n"); rc = PTR_ERR(ldlm_type_proc_dir); GOTO(err, rc); } ldlm_ns_proc_dir = lprocfs_seq_register("namespaces", ldlm_type_proc_dir, NULL, NULL); if (IS_ERR(ldlm_ns_proc_dir)) { CERROR("LProcFS failed in ldlm-init\n"); rc = PTR_ERR(ldlm_ns_proc_dir); GOTO(err_type, rc); }
/* * Initialize quota master target device. This includers connecting to * the backend OSD device, initializing the pool configuration and creating the * root procfs directory dedicated to this quota target. * The rest of the initialization is done when the stack is fully configured * (i.e. when ->ldo_start is called across the stack). * * This function is called on MDT0 setup. * * \param env - is the environment passed by the caller * \param qmt - is the quota master target to be initialized * \param ldt - is the device type structure associated with the qmt device * \param cfg - is the configuration record used to configure the qmt device * * \retval - 0 on success, appropriate error on failure */ static int qmt_device_init0(const struct lu_env *env, struct qmt_device *qmt, struct lu_device_type *ldt, struct lustre_cfg *cfg) { struct lu_device *ld = qmt2lu_dev(qmt); struct obd_device *obd, *mdt_obd; struct obd_type *type; int rc; ENTRY; /* record who i am, it might be useful ... */ strncpy(qmt->qmt_svname, lustre_cfg_string(cfg, 0), sizeof(qmt->qmt_svname) - 1); /* look-up the obd_device associated with the qmt */ obd = class_name2obd(qmt->qmt_svname); if (obd == NULL) RETURN(-ENOENT); /* reference each other */ obd->obd_lu_dev = ld; ld->ld_obd = obd; /* look-up the parent MDT to steal its ldlm namespace ... */ mdt_obd = class_name2obd(lustre_cfg_string(cfg, 2)); if (mdt_obd == NULL) RETURN(-ENOENT); /* borrow MDT namespace. kind of a hack until we have our own namespace * & service threads */ LASSERT(mdt_obd->obd_namespace != NULL); obd->obd_namespace = mdt_obd->obd_namespace; qmt->qmt_ns = obd->obd_namespace; /* connect to backend osd device */ rc = qmt_connect_to_osd(env, qmt, cfg); if (rc) GOTO(out, rc); /* set up and start rebalance thread */ thread_set_flags(&qmt->qmt_reba_thread, SVC_STOPPED); init_waitqueue_head(&qmt->qmt_reba_thread.t_ctl_waitq); CFS_INIT_LIST_HEAD(&qmt->qmt_reba_list); spin_lock_init(&qmt->qmt_reba_lock); rc = qmt_start_reba_thread(qmt); if (rc) { CERROR("%s: failed to start rebalance thread (%d)\n", qmt->qmt_svname, rc); GOTO(out, rc); } /* at the moment there is no linkage between lu_type and obd_type, so * we lookup obd_type this way */ type = class_search_type(LUSTRE_QMT_NAME); LASSERT(type != NULL); /* register proc directory associated with this qmt */ qmt->qmt_proc = lprocfs_seq_register(qmt->qmt_svname, type->typ_procroot, NULL, NULL); if (IS_ERR(qmt->qmt_proc)) { rc = PTR_ERR(qmt->qmt_proc); CERROR("%s: failed to create qmt proc entry (%d)\n", qmt->qmt_svname, rc); GOTO(out, rc); } /* initialize pool configuration */ rc = qmt_pool_init(env, qmt); if (rc) GOTO(out, rc); EXIT; out: if (rc) qmt_device_fini(env, ld); return rc; }