Whamcloud - gitweb
LU-1581 ofd: learn osd to be used from lmi
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 27 Jun 2012 12:10:19 +0000 (16:10 +0400)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 5 Jul 2012 10:10:56 +0000 (06:10 -0400)
so that OSS can work with different type of backends (ldiskfs, zfs)

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Ia630d010b77a8d7ca74d67122d77a3ceb98e95e1
Reviewed-on: http://review.whamcloud.com/3236
Tested-by: Hudson
Reviewed-by: Li Wei <liwei@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/ofd/ofd_dev.c

index 9297ec3..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 lu_device_type   *ldt;
        struct lu_device        *d;
        struct ofd_thread_info  *info = ofd_info(env);
+       struct lustre_mount_info *lmi;
        int                      rc;
 
        ENTRY;
 
        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) {
        if (!type) {
-               CERROR("Unknown type: '%s'\n", LUSTRE_OSD_NAME);
+               CERROR("Unknown type: '%s'\n",
+                      s2lsi(lmi->lmi_sb)->lsi_osd_type);
                RETURN(-ENODEV);
        }
 
                RETURN(-ENODEV);
        }
 
@@ -89,14 +96,15 @@ static int ofd_stack_init(const struct lu_env *env,
 
        ldt = type->typ_lu;
        if (ldt == NULL) {
 
        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)) {
                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);
        }
 
                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) {
        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);
                GOTO(out_free, rc);
        }
        lu_device_get(d);