Whamcloud - gitweb
LU-3319 procfs: move mdd/ofd proc handling to seq_files
[fs/lustre-release.git] / lustre / mdd / mdd_device.c
index 07b606d..d55f358 100644 (file)
@@ -148,17 +148,12 @@ static int mdd_init0(const struct lu_env *env, struct mdd_device *mdd,
 static struct lu_device *mdd_device_fini(const struct lu_env *env,
                                          struct lu_device *d)
 {
-        struct mdd_device *mdd = lu2mdd_dev(d);
-        int rc;
+       struct mdd_device *mdd = lu2mdd_dev(d);
 
        if (d->ld_site)
                lu_dev_del_linkage(d->ld_site, d);
 
-        rc = mdd_procfs_fini(mdd);
-        if (rc) {
-                CERROR("proc fini error %d \n", rc);
-                return ERR_PTR(rc);
-        }
+       mdd_procfs_fini(mdd);
        return NULL;
 }
 
@@ -535,7 +530,7 @@ int mdd_changelog_write_header(const struct lu_env *env,
        ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT);
        LASSERT(ctxt);
 
-       rc = llog_cat_add(env, ctxt->loc_handle, &rec->cr_hdr, NULL, NULL);
+       rc = llog_cat_add(env, ctxt->loc_handle, &rec->cr_hdr, NULL);
        if (rc > 0)
                rc = 0;
        llog_ctxt_put(ctxt);
@@ -864,6 +859,7 @@ static int mdd_hsm_actions_llog_fini(const struct lu_env *env,
 static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m,
                                struct lustre_cfg *cfg)
 {
+       mdd_generic_thread_stop(&m->mdd_orph_cleanup_thread);
        lfsck_degister(env, m->mdd_bottom);
        mdd_hsm_actions_llog_fini(env, m);
        mdd_changelog_fini(env, m);
@@ -889,16 +885,16 @@ static int mdd_process_config(const struct lu_env *env,
         ENTRY;
 
         switch (cfg->lcfg_command) {
-        case LCFG_PARAM: {
-                struct lprocfs_static_vars lvars;
-
-                lprocfs_mdd_init_vars(&lvars);
-                rc = class_process_proc_param(PARAM_MDD, lvars.obd_vars, cfg,m);
-                if (rc > 0 || rc == -ENOSYS)
-                        /* we don't understand; pass it on */
-                        rc = next->ld_ops->ldo_process_config(env, next, cfg);
-                break;
-        }
+       case LCFG_PARAM: {
+               struct obd_device *obd = mdd2obd_dev(m);
+
+               rc = class_process_proc_seq_param(PARAM_MDD, obd->obd_vars,
+                                                 cfg, m);
+               if (rc > 0 || rc == -ENOSYS)
+                       /* we don't understand; pass it on */
+                       rc = next->ld_ops->ldo_process_config(env, next, cfg);
+               break;
+       }
         case LCFG_SETUP:
                 rc = next->ld_ops->ldo_process_config(env, next, cfg);
                 if (rc)
@@ -930,7 +926,7 @@ static int mdd_recovery_complete(const struct lu_env *env,
        next = &mdd->mdd_child->dd_lu_dev;
 
         /* XXX: orphans handling. */
-        __mdd_orphan_cleanup(env, mdd);
+        mdd_orphan_cleanup(env, mdd);
         rc = next->ld_ops->ldo_recovery_complete(env, next);
 
         RETURN(rc);
@@ -1305,7 +1301,7 @@ static int mdd_changelog_user_register(const struct lu_env *env,
        rec->cur_endrec = mdd->mdd_cl.mc_index;
        spin_unlock(&mdd->mdd_cl.mc_user_lock);
 
-       rc = llog_cat_add(env, ctxt->loc_handle, &rec->cur_hdr, NULL, NULL);
+       rc = llog_cat_add(env, ctxt->loc_handle, &rec->cur_hdr, NULL);
 
         CDEBUG(D_IOCTL, "Registered changelog user %d\n", *id);
 out:
@@ -1380,10 +1376,7 @@ static int mdd_changelog_user_purge_cb(const struct lu_env *env,
         CDEBUG(D_IOCTL, "Rewriting changelog user %d endrec to "LPU64"\n",
                mcud->mcud_id, rec->cur_endrec);
 
-        /* hdr+1 is loc of data */
-        hdr->lrh_len -= sizeof(*hdr) + sizeof(struct llog_rec_tail);
-       rc = llog_write(env, llh, hdr, NULL, 0, (void *)(hdr + 1),
-                       hdr->lrh_index);
+       rc = llog_write(env, llh, hdr, hdr->lrh_index);
 
         RETURN(rc);
 }
@@ -1567,13 +1560,39 @@ static void mdd_key_fini(const struct lu_context *ctx,
 /* context key: mdd_thread_key */
 LU_CONTEXT_KEY_DEFINE(mdd, LCT_MD_THREAD);
 
+int mdd_generic_thread_start(struct mdd_generic_thread *thread,
+                            int (*func)(void *), void *data, char *name)
+{
+       struct task_struct      *task;
+
+       LASSERT(thread->mgt_init == false);
+       init_completion(&thread->mgt_started);
+       init_completion(&thread->mgt_finished);
+       thread->mgt_data = data;
+       thread->mgt_abort = false;
+       thread->mgt_init = true;
+
+       task = kthread_run(func, thread, name);
+       if (IS_ERR(task)) {
+               complete(&thread->mgt_finished);
+               return PTR_ERR(task);
+       }
+       wait_for_completion(&thread->mgt_started);
+       return 0;
+}
+
+void mdd_generic_thread_stop(struct mdd_generic_thread *thread)
+{
+       if (thread->mgt_init == true) {
+               thread->mgt_abort = true;
+               wait_for_completion(&thread->mgt_finished);
+       }
+}
+
 static int __init mdd_mod_init(void)
 {
-       struct lprocfs_static_vars lvars;
        int rc;
 
-       lprocfs_mdd_init_vars(&lvars);
-
        rc = lu_kmem_init(mdd_caches);
        if (rc)
                return rc;
@@ -1589,7 +1608,7 @@ static int __init mdd_mod_init(void)
 
        rc = class_register_type(&mdd_obd_device_ops, NULL, true, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-                                lvars.module_vars,
+                                NULL,
 #endif
                                 LUSTRE_MDD_NAME, &mdd_device_type);
        if (rc)