*/
int class_attach(struct lustre_cfg *lcfg)
{
+ int minor;
struct obd_type *type;
+ int err = 0;
+ int len;
+ char *typename;
+ char *name;
+ char *uuid;
struct obd_device *obd;
- char *typename, *name, *uuid;
- int minor, rc, len, dev, stage = 0;
+ int dev;
if (!lcfg->lcfg_inllen1 || !lcfg->lcfg_inlbuf1) {
CERROR("No type passed!\n");
CERROR("OBD: unknown type: %s\n", typename);
RETURN(-EINVAL);
}
- stage = 1;
obd = class_name2obd(name);
if (obd != NULL) {
CERROR("obd %s already attached\n", name);
- GOTO(out, rc = -EEXIST);
+ RETURN(-EEXIST);
}
obd = class_newdev(&dev);
if (obd == NULL)
- GOTO(out, rc = -EINVAL);
+ RETURN(-EINVAL);
/* have we attached a type to this device */
if (obd->obd_attached || obd->obd_type) {
CERROR("OBD: Device %d already typed as %s.\n",
obd->obd_minor, MKSTR(obd->obd_type->typ_name));
- GOTO(out, rc = -EBUSY);
+ RETURN(-EBUSY);
}
LASSERT(obd == (obd_dev + obd->obd_minor));
/* XXX belongs in setup not attach */
/* recovery data */
- init_timer(&obd->obd_recovery_timer);
spin_lock_init(&obd->obd_processing_task_lock);
init_waitqueue_head(&obd->obd_next_transno_waitq);
INIT_LIST_HEAD(&obd->obd_recovery_queue);
INIT_LIST_HEAD(&obd->obd_delayed_reply_queue);
- spin_lock_init(&obd->obd_uncommitted_replies_lock);
- INIT_LIST_HEAD(&obd->obd_uncommitted_replies);
+ spin_lock_init (&obd->obd_uncommitted_replies_lock);
+ INIT_LIST_HEAD (&obd->obd_uncommitted_replies);
len = strlen(name) + 1;
OBD_ALLOC(obd->obd_name, len);
- if (!obd->obd_name)
- GOTO(out, rc = -ENOMEM);
+ if (!obd->obd_name) {
+ class_put_type(obd->obd_type);
+ obd->obd_type = NULL;
+ RETURN(-ENOMEM);
+ }
memcpy(obd->obd_name, name, len);
- stage = 2;
len = strlen(uuid);
if (len >= sizeof(obd->obd_uuid)) {
CERROR("uuid must be < "LPSZ" bytes long\n",
sizeof(obd->obd_uuid));
- GOTO(out, rc = -EINVAL);
+ OBD_FREE(obd->obd_name, strlen(obd->obd_name) + 1);
+ class_put_type(obd->obd_type);
+ obd->obd_type = NULL;
+ RETURN(-EINVAL);
}
memcpy(obd->obd_uuid.uuid, uuid, len);
/* do the attach */
- if (OBP(obd, attach)) {
- rc = OBP(obd,attach)(obd, sizeof *lcfg, lcfg);
- if (rc)
- GOTO(out, rc = -EINVAL);
- }
+ if (OBP(obd, attach))
+ err = OBP(obd,attach)(obd, sizeof *lcfg, lcfg);
- obd->obd_attached = 1;
- type->typ_refcnt++;
- CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
- obd->obd_minor, typename);
- RETURN(0);
- out:
- switch (stage) {
- case 2:
+ if (err) {
OBD_FREE(obd->obd_name, strlen(obd->obd_name) + 1);
- case 1:
class_put_type(obd->obd_type);
obd->obd_type = NULL;
+ } else {
+ obd->obd_attached = 1;
+ type->typ_refcnt++;
+ CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
+ obd->obd_minor, typename);
}
- return rc;
+ RETURN(err);
}
int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
int rc;
if (!(flags & OBD_OPT_FORCE)) {
- CERROR("OBD device %d (%p) has refcount %d\n",
- obd->obd_minor, obd,
+ CERROR("OBD device %d (%p,%s) has refcount %d\n",
+ obd->obd_minor, obd, obd->obd_name,
atomic_read(&obd->obd_refcount));
dump_exports(obd);
GOTO(out, err = -EBUSY);
pcfg->pcfg_nid = cfg->cfg_local_nid;
}
- rc = libcfs_nal_cmd(pcfg);
+ rc = kportal_nal_cmd(pcfg);
}
out:
RETURN(rc);