Whamcloud - gitweb
LU-1581 ofd: learn osd to be used from lmi
[fs/lustre-release.git] / lustre / ofd / ofd_dev.c
index c0e3f8f..8711a30 100644 (file)
@@ -70,14 +70,21 @@ static int ofd_stack_init(const struct lu_env *env,
        struct lu_device_type   *ldt;
        struct lu_device        *d;
        struct ofd_thread_info  *info = ofd_info(env);
+       struct lustre_mount_info *lmi;
        int                      rc;
 
        ENTRY;
 
-       /* XXX: we should be able to use different OSDs here */
-       type = class_get_type(LUSTRE_OSD_NAME);
+       lmi = server_get_mount_2(dev);
+       if (lmi == NULL) {
+               CERROR("Cannot get mount info for %s!\n", dev);
+               RETURN(-EFAULT);
+       }
+
+       type = class_get_type(s2lsi(lmi->lmi_sb)->lsi_osd_type);
        if (!type) {
-               CERROR("Unknown type: '%s'\n", LUSTRE_OSD_NAME);
+               CERROR("Unknown type: '%s'\n",
+                      s2lsi(lmi->lmi_sb)->lsi_osd_type);
                RETURN(-ENODEV);
        }
 
@@ -89,14 +96,15 @@ static int ofd_stack_init(const struct lu_env *env,
 
        ldt = type->typ_lu;
        if (ldt == NULL) {
-               CERROR("type: '%s'\n", LUSTRE_OSD_NAME);
+               CERROR("type: '%s'\n", s2lsi(lmi->lmi_sb)->lsi_osd_type);
                GOTO(out_type, rc = -EINVAL);
        }
 
        ldt->ldt_obd_type = type;
        d = ldt->ldt_ops->ldto_device_alloc(env, ldt, cfg);
        if (IS_ERR(d)) {
-               CERROR("Cannot allocate device: '%s'\n", LUSTRE_OSD_NAME);
+               CERROR("Cannot allocate device: '%s'\n",
+                      s2lsi(lmi->lmi_sb)->lsi_osd_type);
                GOTO(out_type, rc = -ENODEV);
        }
 
@@ -109,7 +117,8 @@ static int ofd_stack_init(const struct lu_env *env,
        type->typ_refcnt++;
        rc = ldt->ldt_ops->ldto_device_init(env, d, dev, NULL);
        if (rc) {
-               CERROR("can't init device '%s', rc %d\n", LUSTRE_OSD_NAME, rc);
+               CERROR("can't init device '%s', rc = %d\n",
+                      s2lsi(lmi->lmi_sb)->lsi_osd_type, rc);
                GOTO(out_free, rc);
        }
        lu_device_get(d);
@@ -517,6 +526,12 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
                GOTO(err_fini_stack, rc = -ENOMEM);
        /* set obd_namespace for compatibility with old code */
        obd->obd_namespace = m->ofd_namespace;
+       ldlm_register_intent(m->ofd_namespace, ofd_intent_policy);
+       m->ofd_namespace->ns_lvbo = &ofd_lvbo;
+       m->ofd_namespace->ns_lvbp = m;
+
+       ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
+                          "filter_ldlm_cb_client", &obd->obd_ldlm_client);
 
        dt_conf_get(env, m->ofd_osd, &m->ofd_dt_conf);
 
@@ -643,6 +658,16 @@ static void ofd_key_exit(const struct lu_context *ctx,
 
        info->fti_env = NULL;
        info->fti_exp = NULL;
+
+       info->fti_xid = 0;
+       info->fti_transno = 0;
+       info->fti_pre_version = 0;
+       info->fti_obj = NULL;
+       info->fti_has_trans = 0;
+       info->fti_mult_trans = 0;
+       info->fti_used = 0;
+
+       memset(&info->fti_attr, 0, sizeof info->fti_attr);
 }
 
 struct lu_context_key ofd_thread_key = {