*/
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;
- int dev;
+ char *typename, *name, *uuid;
+ int minor, rc, len, dev, stage = 0;
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);
- RETURN(-EEXIST);
+ GOTO(out, rc = -EEXIST);
}
obd = class_newdev(&dev);
if (obd == NULL)
- RETURN(-EINVAL);
+ GOTO(out, rc = -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));
- RETURN(-EBUSY);
+ GOTO(out, rc = -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);
- init_waitqueue_head(&obd->obd_commit_waitq);
+ 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) {
- class_put_type(obd->obd_type);
- obd->obd_type = NULL;
- RETURN(-ENOMEM);
- }
+ if (!obd->obd_name)
+ GOTO(out, rc = -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));
- OBD_FREE(obd->obd_name, strlen(obd->obd_name) + 1);
- class_put_type(obd->obd_type);
- obd->obd_type = NULL;
- RETURN(-EINVAL);
+ GOTO(out, rc = -EINVAL);
}
memcpy(obd->obd_uuid.uuid, uuid, len);
/* do the attach */
- if (OBP(obd, attach))
- err = OBP(obd,attach)(obd, sizeof *lcfg, lcfg);
+ if (OBP(obd, attach)) {
+ rc = OBP(obd,attach)(obd, sizeof *lcfg, lcfg);
+ if (rc)
+ GOTO(out, rc = -EINVAL);
+ }
- if (err) {
+ 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:
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(err);
+ return rc;
}
int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
struct obd_export *exp, *n;
list_for_each_entry_safe(exp, n, &obd->obd_exports, exp_obd_chain) {
- CERROR("%s: %p %s %d %d %p\n",
+ struct ptlrpc_reply_state *rs;
+ struct ptlrpc_reply_state *first_reply = NULL;
+ int nreplies = 0;
+
+ list_for_each_entry (rs, &exp->exp_outstanding_replies,
+ rs_exp_list) {
+ if (nreplies == 0)
+ first_reply = rs;
+ nreplies++;
+ }
+
+ CERROR("%s: %p %s %d %d %d: %p %s\n",
obd->obd_name, exp, exp->exp_client_uuid.uuid,
atomic_read(&exp->exp_refcount),
- exp->exp_failed, exp->exp_outstanding_reply );
+ exp->exp_failed, nreplies, first_reply,
+ nreplies > 3 ? "..." : "");
}
}
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);
int cfg_len = rec->lrh_len;
char *cfg_buf = (char*) (rec + 1);
int rc = 0;
-
+ ENTRY;
if (rec->lrh_type == OBD_CFG_REC) {
char *buf;
struct lustre_cfg *lcfg;
pcfg->pcfg_nid = cfg->cfg_local_nid;
}
- rc = kportal_nal_cmd(pcfg);
+ rc = libcfs_nal_cmd(pcfg);
}
out:
RETURN(rc);
int cfg_len = rec->lrh_len;
char *cfg_buf = (char*) (rec + 1);
int rc = 0;
-
+ ENTRY;
if (rec->lrh_type == OBD_CFG_REC) {
char *buf;
struct lustre_cfg *lcfg;
if (lcfg->lcfg_inlbuf1)
CDEBUG(D_INFO, " inlbuf1: %s\n",lcfg->lcfg_inlbuf1);
if (lcfg->lcfg_inlbuf2)
- CDEBUG(D_INFO, " inlbuf1: %s\n",lcfg->lcfg_inlbuf2);
+ CDEBUG(D_INFO, " inlbuf3: %s\n",lcfg->lcfg_inlbuf2);
if (lcfg->lcfg_inlbuf3)
- CDEBUG(D_INFO, " inlbuf1: %s\n",lcfg->lcfg_inlbuf3);
+ CDEBUG(D_INFO, " inlbuf3: %s\n",lcfg->lcfg_inlbuf3);
if (lcfg->lcfg_inlbuf4)
- CDEBUG(D_INFO, " inlbuf1: %s\n",lcfg->lcfg_inlbuf4);
+ CDEBUG(D_INFO, " inlbuf4: %s\n",lcfg->lcfg_inlbuf4);
+ if (lcfg->lcfg_inlbuf5)
+ CDEBUG(D_INFO, " inlbuf5: %s\n",lcfg->lcfg_inlbuf5);
+ if (lcfg->lcfg_inlbuf6)
+ CDEBUG(D_INFO, " inlbuf6: %s\n",lcfg->lcfg_inlbuf6);
lustre_cfg_freedata(buf, cfg_len);
} else if (rec->lrh_type == PTL_CFG_REC) {
if (pcfg->pcfg_flags)
CDEBUG(D_INFO, " flags: %x\n",
pcfg->pcfg_flags);
+ } else {
+ CERROR("unhandled lrh_type: %#x\n", rec->lrh_type);
+ rc = -EINVAL;
}
out:
RETURN(rc);