Whamcloud - gitweb
LU-1581 osd: zfs osd to take svname from lsi
[fs/lustre-release.git] / lustre / osd-zfs / osd_handler.c
index 4efe29e..3c2abe5 100644 (file)
@@ -403,23 +403,6 @@ static int osd_init_capa_ctxt(const struct lu_env *env, struct dt_device *d,
        RETURN(0);
 }
 
-static char *osd_label_get(const struct lu_env *env, const struct dt_device *d)
-{
-       struct osd_device *dev = osd_dt_dev(d);
-       int rc;
-       ENTRY;
-
-       rc = -udmu_userprop_get_str(&dev->od_objset, DMU_OSD_SVNAME,
-                                   dev->od_svname, sizeof(dev->od_svname));
-       if (rc != 0) {
-               if (rc == -EOVERFLOW)
-                       CWARN("%s: buffer too small\n", dev->od_svname);
-               RETURN(NULL);
-       }
-
-       RETURN(&dev->od_svname[0]);
-}
-
 static struct dt_device_operations osd_dt_ops = {
        .dt_root_get            = osd_root_get,
        .dt_statfs              = osd_statfs,
@@ -486,6 +469,14 @@ struct lu_context_key osd_key = {
 
 static int osd_shutdown(const struct lu_env *env, struct osd_device *o)
 {
+       ENTRY;
+
+       /* shutdown quota slave instance associated with the device */
+       if (o->od_quota_slave != NULL) {
+               qsd_fini(env, o->od_quota_slave);
+               o->od_quota_slave = NULL;
+       }
+
        RETURN(0);
 }
 
@@ -496,7 +487,6 @@ static int osd_mount(const struct lu_env *env,
        struct lustre_mount_info        *lmi;
        struct lustre_sb_info           *lsi;
        dmu_buf_t                       *rootdb;
-       char                            *label;
        int                              rc;
        ENTRY;
 
@@ -516,8 +506,9 @@ static int osd_mount(const struct lu_env *env,
                RETURN(-E2BIG);
 
        strcpy(o->od_mntdev, dev);
+       strcpy(o->od_svname, lsi->lsi_ldd->ldd_svname);
 
-       rc = -udmu_objset_open(o->od_mntdev + 1, &o->od_objset);
+       rc = -udmu_objset_open(o->od_mntdev, &o->od_objset);
        if (rc) {
                CERROR("can't open objset %s: %d\n", o->od_mntdev, rc);
                RETURN(rc);
@@ -539,15 +530,11 @@ static int osd_mount(const struct lu_env *env,
        if (rc)
                GOTO(err, rc);
 
-       label = osd_label_get(env, &o->od_dt_dev);
-       if (label == NULL)
-               GOTO(err, rc = -ENODEV);
-
        /* Use our own ZAP for inode accounting by default, this can be changed
         * via procfs to estimate the inode usage from the block usage */
        o->od_quota_iused_est = 0;
 
-       rc = osd_procfs_init(o, label);
+       rc = osd_procfs_init(o, o->od_svname);
        if (rc)
                GOTO(err, rc);
 
@@ -715,7 +702,19 @@ static int osd_recovery_complete(const struct lu_env *env, struct lu_device *d)
 static int osd_prepare(const struct lu_env *env, struct lu_device *pdev,
                       struct lu_device *dev)
 {
-       return 0;
+       struct osd_device       *osd = osd_dev(dev);
+       int                      rc = 0;
+       ENTRY;
+
+       /* initialize quota slave instance */
+       osd->od_quota_slave = qsd_init(env, osd->od_svname, &osd->od_dt_dev,
+                                      osd->od_proc_entry);
+       if (IS_ERR(osd->od_quota_slave)) {
+               rc = PTR_ERR(osd->od_quota_slave);
+               osd->od_quota_slave = NULL;
+       }
+
+       RETURN(rc);
 }
 
 struct lu_device_operations osd_lu_ops = {