Beispiel #1
0
int gss_init_lproc(void)
{
	int	rc;

	spin_lock_init(&gss_stat_oos.oos_lock);

	gss_proc_root = lprocfs_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_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;
}
Beispiel #2
0
int ldlm_proc_setup(void)
{
	int rc;
	struct lprocfs_vars list[] = {
		{ "dump_namespaces", &ldlm_dump_ns_fops, 0, 0222 },
		{ "dump_granted_max", &ldlm_rw_uint_fops,
		  &ldlm_dump_granted_max },
		{ "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops,
		  &ldlm_cancel_unused_locks_before_replay },
		{ NULL }};
	ENTRY;
	LASSERT(ldlm_ns_proc_dir == NULL);

	ldlm_type_proc_dir = lprocfs_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_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);
	}

	ldlm_svc_proc_dir = lprocfs_register("services",
					    ldlm_type_proc_dir,
					    NULL, NULL);
	if (IS_ERR(ldlm_svc_proc_dir)) {
		CERROR("LProcFS failed in ldlm-init\n");
		rc = PTR_ERR(ldlm_svc_proc_dir);
		GOTO(err_ns, rc);
	}

	rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL);

	RETURN(0);

err_ns:
	lprocfs_remove(&ldlm_ns_proc_dir);
err_type:
	lprocfs_remove(&ldlm_type_proc_dir);
err:
	ldlm_svc_proc_dir = NULL;
	ldlm_type_proc_dir = NULL;
	ldlm_ns_proc_dir = NULL;
	RETURN(rc);
}
Beispiel #3
0
int mdd_procfs_init(struct mdd_device *mdd, const char *name)
{
    struct obd_device *obd = mdd2obd_dev(mdd);
    struct obd_type   *type;
    int		   rc;
    ENTRY;

    /* 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_MDD_NAME);

    LASSERT(name != NULL);
    LASSERT(type != NULL);
    LASSERT(obd  != NULL);

    /* Find the type procroot and add the proc entry for this device */
    obd->obd_vars = lprocfs_mdd_obd_vars;
    mdd->mdd_proc_entry = lprocfs_register(name, type->typ_procroot,
                                           obd->obd_vars, mdd);
    if (IS_ERR(mdd->mdd_proc_entry)) {
        rc = PTR_ERR(mdd->mdd_proc_entry);
        CERROR("Error %d setting up lprocfs for %s\n",
               rc, name);
        mdd->mdd_proc_entry = NULL;
        GOTO(out, rc);
    }
    rc = 0;
    EXIT;
out:
    if (rc)
        mdd_procfs_fini(mdd);
    return rc;
}
Beispiel #4
0
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_ZFS_NAME);

	LASSERT(name != NULL);
	LASSERT(type != NULL);

	osd->od_proc_entry = lprocfs_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);

	GOTO(out, rc);
out:
	if (rc)
		osd_procfs_fini(osd);
	return rc;
}
Beispiel #5
0
static int seq_client_proc_init(struct lu_client_seq *seq)
{
#ifdef CONFIG_PROC_FS
        int rc;
        ENTRY;

	seq->lcs_proc_dir = lprocfs_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_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 /* !CONFIG_PROC_FS */
	return 0;
#endif /* CONFIG_PROC_FS */
}
Beispiel #6
0
int osd_procfs_init(struct osd_device *osd, const char *name)
{
        struct lprocfs_static_vars lvars;
        struct lu_device    *ld = &osd->od_dt_dev.dd_lu_dev;
        struct obd_type     *type;
        int                  rc;
        ENTRY;

        type = ld->ld_type->ldt_obd_type;

        LASSERT(name != NULL);
        LASSERT(type != NULL);

        /* Find the type procroot and add the proc entry for this device */
        lprocfs_osd_init_vars(&lvars);
        osd->od_proc_entry = lprocfs_register(name, type->typ_procroot,
                                              lvars.obd_vars, osd);
        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 = lu_time_init(&osd->od_stats,
                          osd->od_proc_entry,
                          osd_counter_names, ARRAY_SIZE(osd_counter_names));
        EXIT;
out:
        if (rc)
               osd_procfs_fini(osd);
	return rc;
}
Beispiel #7
0
static int seq_server_proc_init(struct lu_server_seq *seq)
{
	int rc;
	ENTRY;

	seq->lss_proc_dir = lprocfs_register(seq->lss_name,
					     seq_type_proc_dir,
					     NULL, NULL);
	if (IS_ERR(seq->lss_proc_dir)) {
		rc = PTR_ERR(seq->lss_proc_dir);
		RETURN(rc);
	}

	rc = lprocfs_add_vars(seq->lss_proc_dir,
			      seq_server_proc_list, seq);
	if (rc) {
		CERROR("%s: Can't init sequence manager "
		       "proc, rc %d\n", seq->lss_name, rc);
		GOTO(out_cleanup, rc);
	}

	RETURN(0);

out_cleanup:
	seq_server_proc_fini(seq);
	return rc;
}
Beispiel #8
0
static int __init fid_mod_init(void)
{
	seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME,
					     proc_lustre_root,
					     NULL, NULL);
	return PTR_ERR_OR_ZERO(seq_type_proc_dir);
}
Beispiel #9
0
static int seq_client_proc_init(struct lu_client_seq *seq)
{
#if defined (CONFIG_PROC_FS)
	int rc;

	seq->lcs_proc_dir = lprocfs_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_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;
	}

	return 0;

out_cleanup:
	seq_client_proc_fini(seq);
	return rc;

#else /* CONFIG_PROC_FS */
	return 0;
#endif
}
Beispiel #10
0
static int __init fid_mod_init(void)
{
	seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME,
					     proc_lustre_root,
					     NULL, NULL);
	if (IS_ERR(seq_type_proc_dir))
		return PTR_ERR(seq_type_proc_dir);

	LU_CONTEXT_KEY_INIT(&seq_thread_key);
	lu_context_key_register(&seq_thread_key);
	return 0;
}
Beispiel #11
0
static int __init fid_init(void)
{
	seq_type_proc_dir = lprocfs_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;
}
Beispiel #12
0
int sptlrpc_lproc_init(void)
{
	int rc;

	LASSERT(sptlrpc_proc_root == NULL);

	sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root,
					     sptlrpc_lprocfs_vars, NULL);
	if (IS_ERR(sptlrpc_proc_root)) {
		rc = PTR_ERR(sptlrpc_proc_root);
		sptlrpc_proc_root = NULL;
		return rc;
	}
	return 0;
}
Beispiel #13
0
void osp_lprocfs_init(struct osp_device *osp)
{
	struct obd_device	*obd = osp->opd_obd;
	struct proc_dir_entry	*osc_proc_dir;
	int			 rc;

	obd->obd_proc_entry = lprocfs_register(obd->obd_name,
					       obd->obd_type->typ_procroot,
					       lprocfs_osp_osd_vars,
					       &osp->opd_dt_dev);
	if (IS_ERR(obd->obd_proc_entry)) {
		CERROR("%s: can't register in lprocfs: %ld\n",
		       obd->obd_name, PTR_ERR(obd->obd_proc_entry));
		obd->obd_proc_entry = NULL;
		return;
	}

	rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd);
	if (rc) {
		CERROR("%s: can't register in lprocfs: %ld\n",
		       obd->obd_name, PTR_ERR(obd->obd_proc_entry));
		return;
	}

	ptlrpc_lprocfs_register_obd(obd);

	/* for compatibility we link old procfs's OSC entries to osp ones */
	if (!osp->opd_connect_mdt) {
		osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc");
		if (osc_proc_dir) {
			cfs_proc_dir_entry_t	*symlink = NULL;
			char			*name;

			OBD_ALLOC(name, strlen(obd->obd_name) + 1);
			if (name == NULL)
				return;

			strcpy(name, obd->obd_name);
			if (strstr(name, "osc"))
				symlink = lprocfs_add_symlink(name,
						osc_proc_dir, "../osp/%s",
						obd->obd_name);
			OBD_FREE(name, strlen(obd->obd_name) + 1);
			osp->opd_symlink = symlink;
		}
	}
}
Beispiel #14
0
static int fld_server_proc_init(struct lu_server_fld *fld)
{
        int rc = 0;
        ENTRY;

	fld->lsf_proc_dir = lprocfs_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);
}
Beispiel #15
0
static int seq_server_proc_init(struct lu_server_seq *seq)
{
#ifdef CONFIG_PROC_FS
	int rc;
	ENTRY;

	seq->lss_proc_dir = lprocfs_register(seq->lss_name,
					     seq_type_proc_dir,
					     NULL, NULL);
	if (IS_ERR(seq->lss_proc_dir)) {
		rc = PTR_ERR(seq->lss_proc_dir);
		RETURN(rc);
	}

	rc = lprocfs_add_vars(seq->lss_proc_dir, seq_server_proc_list, seq);
	if (rc) {
		CERROR("%s: Can't init sequence manager "
		       "proc, rc %d\n", seq->lss_name, rc);
		GOTO(out_cleanup, rc);
	}

	if (seq->lss_type == LUSTRE_SEQ_CONTROLLER) {
		rc = lprocfs_seq_create(seq->lss_proc_dir, "fldb", 0644,
					&seq_fld_proc_seq_fops, seq);
		if (rc) {
			CERROR("%s: Can't create fldb for sequence manager "
			       "proc: rc = %d\n", seq->lss_name, rc);
			GOTO(out_cleanup, rc);
		}
	}

	RETURN(0);

out_cleanup:
	seq_server_proc_fini(seq);
	return rc;
#else /* !CONFIG_PROC_FS */
	return 0;
#endif /* CONFIG_PROC_FS */
}
Beispiel #16
0
static int __init init_lustre_lite(void)
{
	int i, rc, seed[2];
	struct timeval tv;
	lnet_process_id_t lnet_id;

	CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1);

	/* print an address of _any_ initialized kernel symbol from this
	 * module, to allow debugging with gdb that doesn't support data
	 * symbols from modules.*/
	CDEBUG(D_INFO, "Lustre client module (%p).\n",
	       &lustre_super_operations);

        rc = ll_init_inodecache();
        if (rc)
                return -ENOMEM;
        ll_file_data_slab = cfs_mem_cache_create("ll_file_data",
                                                 sizeof(struct ll_file_data), 0,
                                                 CFS_SLAB_HWCACHE_ALIGN);
        if (ll_file_data_slab == NULL) {
                ll_destroy_inodecache();
                return -ENOMEM;
        }

        ll_remote_perm_cachep = cfs_mem_cache_create("ll_remote_perm_cache",
                                                  sizeof(struct ll_remote_perm),
                                                      0, 0);
        if (ll_remote_perm_cachep == NULL) {
                cfs_mem_cache_destroy(ll_file_data_slab);
                ll_file_data_slab = NULL;
                ll_destroy_inodecache();
                return -ENOMEM;
        }

        ll_rmtperm_hash_cachep = cfs_mem_cache_create("ll_rmtperm_hash_cache",
                                                   REMOTE_PERM_HASHSIZE *
                                                   sizeof(cfs_list_t),
                                                   0, 0);
        if (ll_rmtperm_hash_cachep == NULL) {
                cfs_mem_cache_destroy(ll_remote_perm_cachep);
                ll_remote_perm_cachep = NULL;
                cfs_mem_cache_destroy(ll_file_data_slab);
                ll_file_data_slab = NULL;
                ll_destroy_inodecache();
                return -ENOMEM;
        }

        proc_lustre_fs_root = proc_lustre_root ?
                              lprocfs_register("llite", proc_lustre_root, NULL, NULL) : NULL;

        lustre_register_client_fill_super(ll_fill_super);
        lustre_register_kill_super_cb(ll_kill_super);

        lustre_register_client_process_config(ll_process_config);

        cfs_get_random_bytes(seed, sizeof(seed));

        /* Nodes with small feet have little entropy
         * the NID for this node gives the most entropy in the low bits */
        for (i=0; ; i++) {
                if (LNetGetId(i, &lnet_id) == -ENOENT) {
                        break;
                }
                if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) {
                        seed[0] ^= LNET_NIDADDR(lnet_id.nid);
                }
        }

        cfs_gettimeofday(&tv);
        cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);

        init_timer(&ll_capa_timer);
        ll_capa_timer.function = ll_capa_timer_callback;
        rc = ll_capa_thread_start();
        /*
         * XXX normal cleanup is needed here.
         */
        if (rc == 0)
                rc = vvp_global_init();

        return rc;
}
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);
}
Beispiel #18
0
static int __init lustre_init(void)
{
	struct proc_dir_entry *entry;
	lnet_process_id_t lnet_id;
	struct timeval tv;
	int i, rc, seed[2];

	CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1);

	/* print an address of _any_ initialized kernel symbol from this
	 * module, to allow debugging with gdb that doesn't support data
	 * symbols from modules.*/
	CDEBUG(D_INFO, "Lustre client module (%p).\n",
	       &lustre_super_operations);

	ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
					    sizeof(struct ll_inode_info),
					    0, SLAB_HWCACHE_ALIGN, NULL);
	if (ll_inode_cachep == NULL)
		GOTO(out_cache, rc = -ENOMEM);

	ll_file_data_slab = kmem_cache_create("ll_file_data",
						 sizeof(struct ll_file_data), 0,
						 SLAB_HWCACHE_ALIGN, NULL);
	if (ll_file_data_slab == NULL)
		GOTO(out_cache, rc = -ENOMEM);

	ll_remote_perm_cachep = kmem_cache_create("ll_remote_perm_cache",
						  sizeof(struct ll_remote_perm),
						  0, 0, NULL);
	if (ll_remote_perm_cachep == NULL)
		GOTO(out_cache, rc = -ENOMEM);

	ll_rmtperm_hash_cachep = kmem_cache_create("ll_rmtperm_hash_cache",
						   REMOTE_PERM_HASHSIZE *
						   sizeof(struct hlist_head),
						   0, 0, NULL);
	if (ll_rmtperm_hash_cachep == NULL)
		GOTO(out_cache, rc = -ENOMEM);

	entry = lprocfs_register("llite", proc_lustre_root, NULL, NULL);
	if (IS_ERR(entry)) {
		rc = PTR_ERR(entry);
		CERROR("cannot register '/proc/fs/lustre/llite': rc = %d\n",
		       rc);
		GOTO(out_cache, rc);
	}

	proc_lustre_fs_root = entry;

	cfs_get_random_bytes(seed, sizeof(seed));

	/* Nodes with small feet have little entropy. The NID for this
	 * node gives the most entropy in the low bits. */
	for (i = 0;; i++) {
		if (LNetGetId(i, &lnet_id) == -ENOENT)
			break;

		if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND)
			seed[0] ^= LNET_NIDADDR(lnet_id.nid);
	}

	do_gettimeofday(&tv);
	cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);

	rc = vvp_global_init();
	if (rc != 0)
		GOTO(out_proc, rc);

	cl_inode_fini_env = cl_env_alloc(&cl_inode_fini_refcheck,
					 LCT_REMEMBER | LCT_NOREF);
	if (IS_ERR(cl_inode_fini_env))
		GOTO(out_vvp, rc = PTR_ERR(cl_inode_fini_env));

	cl_inode_fini_env->le_ctx.lc_cookie = 0x4;

	rc = ll_xattr_init();
	if (rc != 0)
		GOTO(out_inode_fini_env, rc);

	lustre_register_client_fill_super(ll_fill_super);
	lustre_register_kill_super_cb(ll_kill_super);
	lustre_register_client_process_config(ll_process_config);

	RETURN(0);

out_inode_fini_env:
	cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck);
out_vvp:
	vvp_global_fini();
out_proc:
	lprocfs_remove(&proc_lustre_fs_root);
out_cache:
	if (ll_inode_cachep != NULL)
		kmem_cache_destroy(ll_inode_cachep);

	if (ll_file_data_slab != NULL)
		kmem_cache_destroy(ll_file_data_slab);

	if (ll_remote_perm_cachep != NULL)
		kmem_cache_destroy(ll_remote_perm_cachep);

	if (ll_rmtperm_hash_cachep != NULL)
		kmem_cache_destroy(ll_rmtperm_hash_cachep);

	return rc;
}
Beispiel #19
0
/*
 * 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_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;
}
Beispiel #20
0
int lquota_proc_setup(struct obd_device *obd, int is_master)
{
        struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
        int rc = 0;
        ENTRY;

        LASSERT(lquota_type_proc_dir && obd);
        qctxt->lqc_proc_dir = lprocfs_register(obd->obd_name,
                                               lquota_type_proc_dir,
                                               lprocfs_quota_common_vars, obd);
        if (IS_ERR(qctxt->lqc_proc_dir)) {
                rc = PTR_ERR(qctxt->lqc_proc_dir);
                CERROR("%s: error %d setting up lprocfs\n",
                       obd->obd_name, rc);
                qctxt->lqc_proc_dir = NULL;
                GOTO(out, rc);
        }

        if (is_master) {
                rc = lprocfs_add_vars(qctxt->lqc_proc_dir,
                                      lprocfs_quota_master_vars, obd);
                if (rc) {
                        CERROR("%s: error %d setting up lprocfs for "
                               "quota master\n", obd->obd_name, rc);
                        GOTO(out_free_proc, rc);
                }
        }

        qctxt->lqc_stats = lprocfs_alloc_stats(LQUOTA_LAST_STAT -
                                               LQUOTA_FIRST_STAT, 0);
        if (!qctxt->lqc_stats)
                GOTO(out_free_proc, rc = -ENOMEM);

        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_SYNC_ACQ,
                             LPROCFS_CNTR_AVGMINMAX, "sync_acq_req", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_SYNC_REL,
                             LPROCFS_CNTR_AVGMINMAX, "sync_rel_req", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_ASYNC_ACQ,
                             LPROCFS_CNTR_AVGMINMAX, "async_acq_req", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_ASYNC_REL,
                             LPROCFS_CNTR_AVGMINMAX, "async_rel_req", "us");

        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_FOR_CHK_BLK,
                             LPROCFS_CNTR_AVGMINMAX,
                             "wait_for_blk_quota(lquota_chkquota)", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_FOR_CHK_INO,
                             LPROCFS_CNTR_AVGMINMAX,
                             "wait_for_ino_quota(lquota_chkquota)", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_FOR_COMMIT_BLK,
                             LPROCFS_CNTR_AVGMINMAX,
                             "wait_for_blk_quota(lquota_pending_commit)",
                             "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_FOR_COMMIT_INO,
                             LPROCFS_CNTR_AVGMINMAX,
                             "wait_for_ino_quota(lquota_pending_commit)",
                             "us");

        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_PENDING_BLK_QUOTA,
                             LPROCFS_CNTR_AVGMINMAX,
                             "wait_for_pending_blk_quota_req"
                             "(qctxt_wait_pending_dqacq)", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_WAIT_PENDING_INO_QUOTA,
                             LPROCFS_CNTR_AVGMINMAX,
                             "wait_for_pending_ino_quota_req"
                             "(qctxt_wait_pending_dqacq)", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_NOWAIT_PENDING_BLK_QUOTA,
                             LPROCFS_CNTR_AVGMINMAX,
                             "nowait_for_pending_blk_quota_req"
                             "(qctxt_wait_pending_dqacq)", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_NOWAIT_PENDING_INO_QUOTA,
                             LPROCFS_CNTR_AVGMINMAX,
                             "nowait_for_pending_ino_quota_req"
                             "(qctxt_wait_pending_dqacq)", "us");

        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_QUOTA_CTL,
                             LPROCFS_CNTR_AVGMINMAX, "quota_ctl", "us");
        lprocfs_counter_init(qctxt->lqc_stats, LQUOTA_ADJUST_QUNIT,
                             LPROCFS_CNTR_AVGMINMAX, "adjust_qunit", "us");

        lprocfs_register_stats(qctxt->lqc_proc_dir, "stats", qctxt->lqc_stats);

        RETURN(rc);

out_free_proc:
        lprocfs_remove(&qctxt->lqc_proc_dir);
out:
        RETURN(rc);
}