struct mdd_device *m = lu2mdd_dev(d);
struct dt_device *dt = m->mdd_child;
struct lu_device *next = &dt->dd_lu_dev;
- char *dev = lustre_cfg_string(cfg, 0);
int rc;
+ ENTRY;
switch (cfg->lcfg_command) {
case LCFG_SETUP:
rc = mdd_mount(ctxt, m);
if (rc)
GOTO(out, rc);
- rc = mdd_init_obd(ctxt, m, dev);
+ rc = mdd_init_obd(ctxt, m, cfg);
if (rc) {
CERROR("lov init error %d \n", rc);
GOTO(out, rc);
};
int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd,
- char *dev);
+ struct lustre_cfg *cfg);
int mdd_fini_obd(const struct lu_context *, struct mdd_device *);
int mdd_xattr_set_txn(const struct lu_context *ctxt, struct mdd_object *obj,
const void *buf, int buf_len, const char *name, int fl,
/*The obd is created for handling data stack for mdd*/
int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd,
- char *dev)
+ struct lustre_cfg *cfg)
{
struct lustre_cfg_bufs *bufs;
struct lustre_cfg *lcfg;
struct obd_device *obd;
- int rc;
+ char *dev = lustre_cfg_string(cfg, 0);
+ char *index_string = lustre_cfg_string(cfg, 2);
+ char *name, *uuid, *p;
+ int rc, name_size, uuid_size, index;
ENTRY;
- OBD_ALLOC_PTR(bufs);
- if (!bufs)
+ LASSERT(index_string);
+
+ index = simple_strtol(index_string, &p, 10);
+
+ name_size = strlen(MDD_OBD_NAME) + 5;
+ uuid_size = strlen(MDD_OBD_UUID) + 5;
+
+ OBD_ALLOC(name, name_size);
+ OBD_ALLOC(uuid, uuid_size);
+ if (!name || !uuid) {
+ if (name)
+ OBD_FREE(name, name_size);
+ if (uuid)
+ OBD_FREE(uuid, uuid_size);
RETURN(-ENOMEM);
- lustre_cfg_bufs_reset(bufs, MDD_OBD_NAME);
+ }
+
+ OBD_ALLOC_PTR(bufs);
+ if (!bufs) {
+ GOTO(cleanup_mem, rc = -ENOMEM);
+ }
+
+ snprintf(name, strlen(MDD_OBD_NAME) + 5, "%s-%d",
+ MDD_OBD_NAME, index);
+ snprintf(uuid, strlen(MDD_OBD_UUID) + 5, "%s-%d",
+ MDD_OBD_UUID, index);
+ lustre_cfg_bufs_reset(bufs, name);
lustre_cfg_bufs_set_string(bufs, 1, MDD_OBD_TYPE);
- lustre_cfg_bufs_set_string(bufs, 2, MDD_OBD_UUID);
+ lustre_cfg_bufs_set_string(bufs, 2, uuid);
lustre_cfg_bufs_set_string(bufs, 3, (char*)dev/*MDD_OBD_PROFILE*/);
lustre_cfg_bufs_set_string(bufs, 4, (char*)dev);
lcfg = lustre_cfg_new(LCFG_ATTACH, bufs);
OBD_FREE_PTR(bufs);
if (!lcfg)
- RETURN(-ENOMEM);
+ GOTO(cleanup_mem, rc = -ENOMEM);
rc = class_attach(lcfg);
if (rc)
GOTO(lcfg_cleanup, rc);
- obd = class_name2obd(MDD_OBD_NAME);
+ obd = class_name2obd(name);
if (!obd) {
CERROR("can not find obd %s \n", MDD_OBD_NAME);
LBUG();
class_detach(obd, lcfg);
lcfg_cleanup:
lustre_cfg_free(lcfg);
+cleanup_mem:
+ OBD_FREE(name, name_size);
+ OBD_FREE(uuid, uuid_size);
RETURN(rc);
}
OBD_FAIL_RETURN((OBD_FAIL_MDS_ALLOC_OBDO), -ENOMEM);
+ LASSERT(lov_exp != NULL);
oa = obdo_alloc();
if (oa == NULL)
RETURN(-ENOMEM);
}
/* clean PENDING dir */
- if (strcmp(obd->obd_name, MDD_OBD_NAME))
+ if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
rc = mds_cleanup_pending(obd);
if (rc < 0)
GOTO(out, rc);
/*XXX Use this for mdd mds cleanup, so comment out
*this target_cleanup_recovery for this tmp MDD MDS
*Wangdi*/
- if (strcmp(obd->obd_name, MDD_OBD_NAME))
+ if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
target_cleanup_recovery(obd);
mds_lov_early_clean(obd);
break;
ENTRY;
CDEBUG(D_INFO, "obd %s setup \n", obd->obd_name);
- if (strcmp(obd->obd_name, MDD_OBD_NAME))
+ if (strncmp(obd->obd_name, MDD_OBD_NAME, strlen(MDD_OBD_NAME)))
RETURN(0);
if (lcfg->lcfg_bufcount < 5) {
/* the owner of object file should always be root */
ucred.luc_cap = current->cap_effective | CAP_SYS_RESOURCE;
- if (strcmp(exp->exp_obd->obd_name, MDD_OBD_NAME)) {
+ if (strncmp(exp->exp_obd->obd_name, MDD_OBD_NAME,
+ strlen(MDD_OBD_NAME))) {
RETURN(0);
}
if (result != 0) {
OBD_FREE_PTR(m);
l = ERR_PTR(result);
+ return l;
}
m->mdt_md_dev.md_upcall.mu_upcall = mdt_upcall;
} else
rc = record_setup(obd, llh, mdcname, mti->mti_uuid, nodeuuid, 0, 0);
rc = mgs_write_log_failnids(obd, mti, llh, mdcname);
snprintf(index, sizeof(index), "%d", idx);
+
rc = record_mdc_add(obd, llh, logname, mdcuuid, mti->mti_uuid,
index, "1");
rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdc");
char *logname, char *lovname, int flags)
{
struct llog_handle *llh = NULL;
- char *nodeuuid, *oscname, *oscuuid, *lovuuid;
+ char *nodeuuid, *svname, *oscname, *oscuuid, *lovuuid;
char index[5];
int i, rc;
name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]), "");
- name_create(&oscname, mti->mti_svname, "-osc");
+ name_create(&svname, mti->mti_svname, lovname);
+ name_create(&oscname, svname, "-osc");
name_create(&oscuuid, oscname, "_UUID");
name_create(&lovuuid, lovname, "_UUID");
name_destroy(lovuuid);
name_destroy(oscuuid);
name_destroy(oscname);
+ name_destroy(svname);
name_destroy(nodeuuid);
RETURN(rc);
}