OBD_ALLOC(ctxt, sizeof(*ctxt));
if (!ctxt)
return NULL;
-
+
ctxt->loc_obd = obd;
atomic_set(&ctxt->loc_refcount, 1);
-
+
return ctxt;
}
if (index < 0 || index >= LLOG_MAX_CTXTS)
RETURN(-EFAULT);
- ctxt = llog_get_context(obd, index);
+ /* someone can call lov_llog_init with NULL uuid - this can produce
+ * parallel enter to this function */
+ mutex_down(&obd->obd_llog_alloc);
+ ctxt = llog_get_context(obd, index);
if (ctxt) {
/* mds_lov_update_mds might call here multiple times. So if the
llog is already set up then don't to do it again. */
- CDEBUG(D_CONFIG, "obd %s ctxt %d already set up\n",
+ CDEBUG(D_CONFIG, "obd %s ctxt %d already set up\n",
obd->obd_name, index);
LASSERT(ctxt->loc_obd == obd);
LASSERT(ctxt->loc_exp == disk_obd->obd_self_export);
LASSERT(ctxt->loc_logops == op);
- llog_ctxt_put(ctxt);
+ llog_ctxt_put(ctxt);
GOTO(out, rc = 0);
}
+
ctxt = llog_new_ctxt(obd);
if (!ctxt)
GOTO(out, rc = -ENOMEM);
obd->obd_llog_ctxt[index] = NULL;
}
out:
+ mutex_up(&obd->obd_llog_alloc);
RETURN(rc);
}
EXPORT_SYMBOL(llog_setup);
}
EXPORT_SYMBOL(llog_obd_origin_add);
-int llog_cat_initialize(struct obd_device *obd, int count,
+int llog_cat_initialize(struct obd_device *obd, int idx,
struct obd_uuid *uuid)
{
+ struct llog_catid idarray;
char name[32] = CATLIST;
- struct llog_catid *idarray = NULL;
- int size = sizeof(*idarray) * count;
int rc;
ENTRY;
- if (count) {
- OBD_VMALLOC(idarray, size);
- if (!idarray)
- RETURN(-ENOMEM);
- }
-
- rc = llog_get_cat_list(obd, obd, name, count, idarray);
+ rc = llog_get_cat_list(obd, obd, name, idx, 1, &idarray);
if (rc) {
CERROR("rc: %d\n", rc);
GOTO(out, rc);
}
- rc = obd_llog_init(obd, obd, count, idarray, uuid);
+ rc = obd_llog_init(obd, obd, 1, &idarray, uuid);
if (rc) {
CERROR("rc: %d\n", rc);
GOTO(out, rc);
}
- rc = llog_put_cat_list(obd, obd, name, count, idarray);
+ rc = llog_put_cat_list(obd, obd, name, idx, 1, &idarray);
if (rc) {
CERROR("rc: %d\n", rc);
GOTO(out, rc);
}
out:
- if (idarray)
- OBD_VFREE(idarray, size);
RETURN(rc);
}
EXPORT_SYMBOL(llog_cat_initialize);