Whamcloud - gitweb
LU-921 llite: warning in case of discarding dirty pages
[fs/lustre-release.git] / lustre / ofd / ofd_dev.c
index 7b2710e..bc26331 100644 (file)
@@ -293,17 +293,35 @@ static struct lu_object *ofd_object_alloc(const struct lu_env *env,
 
 extern int ost_handle(struct ptlrpc_request *req);
 
-static int ofd_start(const struct lu_env *env, struct lu_device *dev)
+static int ofd_prepare(const struct lu_env *env, struct lu_device *pdev,
+                      struct lu_device *dev)
 {
+       struct ofd_thread_info *info;
        struct ofd_device       *ofd = ofd_dev(dev);
+       struct obd_device       *obd = ofd_obd(ofd);
        struct lu_device        *next = &ofd->ofd_osd->dd_lu_dev;
        int                      rc;
 
        ENTRY;
 
+       rc = lu_env_refill((struct lu_env *)env);
+       if (rc != 0) {
+               CERROR("Failure to refill session: '%d'\n", rc);
+               RETURN(rc);
+       }
+
+       info = ofd_info_init(env, NULL);
+       if (info == NULL)
+               RETURN(-EFAULT);
+
        /* initialize lower device */
        rc = next->ld_ops->ldo_prepare(env, dev, next);
 
+       target_recovery_init(&ofd->ofd_lut, ost_handle);
+
+       if (obd->obd_recovering == 0)
+               ofd_postrecov(env, ofd);
+
        RETURN(rc);
 }
 
@@ -331,6 +349,7 @@ static struct lu_device_operations ofd_lu_ops = {
        .ldo_object_alloc       = ofd_object_alloc,
        .ldo_process_config     = ofd_process_config,
        .ldo_recovery_complete  = ofd_recovery_complete,
+       .ldo_prepare            = ofd_prepare,
 };
 
 static int ofd_procfs_init(struct ofd_device *ofd)
@@ -389,8 +408,14 @@ static int ofd_procfs_init(struct ofd_device *ofd)
                       obd->obd_name, rc);
                GOTO(free_obd_stats, rc);
        }
-       RETURN(0);
 
+       rc = lprocfs_job_stats_init(obd, LPROC_OFD_STATS_LAST,
+                                   ofd_stats_counter_init);
+       if (rc)
+               GOTO(remove_entry_clear, rc);
+       RETURN(0);
+remove_entry_clear:
+       lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
 free_obd_stats:
        lprocfs_free_obd_stats(obd);
 obd_cleanup:
@@ -402,6 +427,7 @@ static int ofd_procfs_fini(struct ofd_device *ofd)
 {
        struct obd_device *obd = ofd_obd(ofd);
 
+       lprocfs_job_stats_fini(obd);
        lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
        lprocfs_free_per_client_stats(obd);
        lprocfs_free_obd_stats(obd);
@@ -539,11 +565,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        m->ofd_grant_ratio =
                ofd_grant_ratio_conv(m->ofd_dt_conf.ddp_grant_reserved);
 
-       rc = ofd_start(env, &m->ofd_dt_dev.dd_lu_dev);
-       if (rc)
-               GOTO(err_fini_stack, rc);
-
-       rc = lut_init(env, &m->ofd_lut, obd, m->ofd_osd);
+       rc = tgt_init(env, &m->ofd_lut, obd, m->ofd_osd);
        if (rc)
                GOTO(err_free_ns, rc);
 
@@ -551,11 +573,9 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
        if (rc)
                GOTO(err_fini_lut, rc);
 
-       target_recovery_init(&m->ofd_lut, ost_handle);
-
        RETURN(0);
 err_fini_lut:
-       lut_fini(env, &m->ofd_lut);
+       tgt_fini(env, &m->ofd_lut);
 err_free_ns:
        ldlm_namespace_free(m->ofd_namespace, 0, obd->obd_force);
        obd->obd_namespace = m->ofd_namespace = NULL;
@@ -575,7 +595,7 @@ static void ofd_fini(const struct lu_env *env, struct ofd_device *m)
        obd_exports_barrier(obd);
        obd_zombie_barrier();
 
-       lut_fini(env, &m->ofd_lut);
+       tgt_fini(env, &m->ofd_lut);
        ofd_fs_cleanup(env, m);
 
        ofd_free_capa_keys(m);