Exemplo n.º 1
0
static struct lu_device *osc_device_alloc(const struct lu_env *env,
					  struct lu_device_type *t,
					  struct lustre_cfg *cfg)
{
	struct lu_device *d;
	struct osc_device *od;
	struct obd_device *obd;
	int rc;

	od = kzalloc(sizeof(*od), GFP_NOFS);
	if (!od)
		return ERR_PTR(-ENOMEM);

	cl_device_init(&od->od_cl, t);
	d = osc2lu_dev(od);
	d->ld_ops = &osc_lu_ops;

	/* Setup OSC OBD */
	obd = class_name2obd(lustre_cfg_string(cfg, 0));
	LASSERT(obd);
	rc = osc_setup(obd, cfg);
	if (rc) {
		osc_device_free(env, d);
		return ERR_PTR(rc);
	}
	od->od_exp = obd->obd_self_export;
	return d;
}
Exemplo n.º 2
0
static struct lu_device *osc_device_alloc(const struct lu_env *env,
                                          struct lu_device_type *t,
                                          struct lustre_cfg *cfg)
{
        struct lu_device *d;
        struct osc_device *od;
        struct obd_device *obd;
        int rc;

        OBD_ALLOC_PTR(od);
        if (od == NULL)
                RETURN(ERR_PTR(-ENOMEM));

        cl_device_init(&od->od_cl, t);
        d = osc2lu_dev(od);
        d->ld_ops = &osc_lu_ops;
        od->od_cl.cd_ops = &osc_cl_ops;

        /* Setup OSC OBD */
        obd = class_name2obd(lustre_cfg_string(cfg, 0));
        LASSERT(obd != NULL);
        rc = osc_setup(obd, cfg);
        if (rc) {
                osc_device_free(env, d);
                RETURN(ERR_PTR(rc));
        }
        od->od_exp = obd->obd_self_export;
        RETURN(d);
}
Exemplo n.º 3
0
static struct lu_device *lov_device_alloc(const struct lu_env *env,
					  struct lu_device_type *t,
					  struct lustre_cfg *cfg)
{
	struct lu_device *d;
	struct lov_device *ld;
	struct obd_device *obd;
	int rc;

	ld = kzalloc(sizeof(*ld), GFP_NOFS);
	if (!ld)
		return ERR_PTR(-ENOMEM);

	cl_device_init(&ld->ld_cl, t);
	d = lov2lu_dev(ld);
	d->ld_ops	= &lov_lu_ops;
	ld->ld_cl.cd_ops = &lov_cl_ops;

	mutex_init(&ld->ld_mutex);
	lockdep_set_class(&ld->ld_mutex, &cl_lov_device_mutex_class);

	/* setup the LOV OBD */
	obd = class_name2obd(lustre_cfg_string(cfg, 0));
	LASSERT(obd != NULL);
	rc = lov_setup(obd, cfg);
	if (rc) {
		lov_device_free(env, d);
		return ERR_PTR(rc);
	}

	ld->ld_lov = &obd->u.lov;
	return d;
}
Exemplo n.º 4
0
static struct lu_device *lovsub_device_alloc(const struct lu_env *env,
                                             struct lu_device_type *t,
                                             struct lustre_cfg *cfg)
{
        struct lu_device     *d;
        struct lovsub_device *lsd;

        OBD_ALLOC_PTR(lsd);
        if (lsd != NULL) {
                int result;

                result = cl_device_init(&lsd->acid_cl, t);
                if (result == 0) {
                        d = lovsub2lu_dev(lsd);
                        d->ld_ops         = &lovsub_lu_ops;
                } else
                        d = ERR_PTR(result);
        } else
                d = ERR_PTR(-ENOMEM);
        return d;
}
Exemplo n.º 5
0
static struct lu_device *vvp_device_alloc(const struct lu_env *env,
					  struct lu_device_type *t,
					  struct lustre_cfg *cfg)
{
	struct vvp_device *vdv;
	struct lu_device  *lud;
	struct cl_site    *site;
	int rc;

	vdv = kzalloc(sizeof(*vdv), GFP_NOFS);
	if (!vdv)
		return ERR_PTR(-ENOMEM);

	lud = &vdv->vdv_cl.cd_lu_dev;
	cl_device_init(&vdv->vdv_cl, t);
	vvp2lu_dev(vdv)->ld_ops = &vvp_lu_ops;
	vdv->vdv_cl.cd_ops = &vvp_cl_ops;

	site = kzalloc(sizeof(*site), GFP_NOFS);
	if (site) {
		rc = cl_site_init(site, &vdv->vdv_cl);
		if (rc == 0) {
			rc = lu_site_init_finish(&site->cs_lu);
		} else {
			LASSERT(!lud->ld_site);
			CERROR("Cannot init lu_site, rc %d.\n", rc);
			kfree(site);
		}
	} else {
		rc = -ENOMEM;
	}
	if (rc != 0) {
		vvp_device_free(env, lud);
		lud = ERR_PTR(rc);
	}
	return lud;
}