static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, __u32 index) { struct obd_device *obd = dev->ld_obd; struct lov_device *ld = lu2lov_dev(dev); struct lov_tgt_desc *tgt; struct lovsub_device *lsd; struct cl_device *cl; int rc; obd_getref(obd); tgt = obd->u.lov.lov_tgts[index]; LASSERT(tgt != NULL); LASSERT(tgt->ltd_obd != NULL); if (!tgt->ltd_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid)); return -EINVAL; } rc = lov_expand_targets(env, ld); if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) { LASSERT(dev->ld_site != NULL); cl = cl_type_setup(env, dev->ld_site, &lovsub_device_type, tgt->ltd_obd->obd_lu_dev); if (!IS_ERR(cl)) { lsd = cl2lovsub_dev(cl); lsd->acid_idx = index; lsd->acid_super = ld; ld->ld_target[index] = lsd; } else { CERROR("add failed (%d), deleting %s\n", rc, obd_uuid2str(&tgt->ltd_uuid)); lov_cl_del_target(env, dev, index); rc = PTR_ERR(cl); } } obd_putref(obd); return rc; }
int cl_sb_init(struct llu_sb_info *sbi) { struct cl_device *cl; struct lu_env *env; int rc = 0; int refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) RETURN(PTR_ERR(env)); cl = cl_type_setup(env, NULL, &slp_device_type, sbi->ll_dt_exp->exp_obd->obd_lu_dev); if (IS_ERR(cl)) GOTO(out, rc = PTR_ERR(cl)); sbi->ll_cl = cl; sbi->ll_site = cl2lu_dev(cl)->ld_site; out: cl_env_put(env, &refcheck); RETURN(rc); }
static int lov_device_init(const struct lu_env *env, struct lu_device *d, const char *name, struct lu_device *next) { struct lov_device *ld = lu2lov_dev(d); int i; int rc = 0; LASSERT(d->ld_site != NULL); if (ld->ld_target == NULL) return rc; lov_foreach_target(ld, i) { struct lovsub_device *lsd; struct cl_device *cl; struct lov_tgt_desc *desc; desc = ld->ld_lov->lov_tgts[i]; if (desc == NULL) continue; cl = cl_type_setup(env, d->ld_site, &lovsub_device_type, desc->ltd_obd->obd_lu_dev); if (IS_ERR(cl)) { rc = PTR_ERR(cl); break; } lsd = cl2lovsub_dev(cl); lsd->acid_idx = i; lsd->acid_super = ld; ld->ld_target[i] = lsd; } if (rc) lov_device_fini(env, d); else ld->ld_flags |= LOV_DEV_INITIALIZED; return rc; }
int cl_sb_init(struct super_block *sb) { struct ll_sb_info *sbi; struct cl_device *cl; struct lu_env *env; int rc = 0; u16 refcheck; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); if (!IS_ERR(env)) { cl = cl_type_setup(env, NULL, &vvp_device_type, sbi->ll_dt_exp->exp_obd->obd_lu_dev); if (!IS_ERR(cl)) { sbi->ll_cl = cl; sbi->ll_site = cl2lu_dev(cl)->ld_site; } cl_env_put(env, &refcheck); } else { rc = PTR_ERR(env); } return rc; }