Whamcloud - gitweb
LU-11505 tests: customise run_*() functions
[fs/lustre-release.git] / lustre / osp / lwp_dev.c
index e4e6364..4c5828e 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2013, 2016, Intel Corporation.
+ * Copyright (c) 2013, 2017, Intel Corporation.
  * Use is subject to license terms.
  *
  * lustre/osp/lwp_dev.c
@@ -49,7 +49,6 @@
 struct lwp_device {
        struct lu_device        lpd_dev;
        struct obd_device      *lpd_obd;   /* corresponding OBD device */
-       struct obd_uuid         lpd_cluuid;/* UUID of LWP */
        struct obd_export      *lpd_exp;   /* export of LWP */
        struct ptlrpc_thread    lpd_notify_thread; /* notify thread */
        int                     lpd_connects; /* use count, 0 or 1 */
@@ -83,7 +82,6 @@ static int lwp_setup(const struct lu_env *env, struct lwp_device *lwp,
        char                    *lwp_name = lwp->lpd_obd->obd_name;
        char                    *server_uuid = NULL;
        char                    *ptr;
-       class_uuid_t             uuid;
        struct obd_import       *imp;
        int                      len = strlen(lwp_name) + 1;
        int                      rc;
@@ -128,11 +126,6 @@ static int lwp_setup(const struct lu_env *env, struct lwp_device *lwp,
 
        imp = lwp->lpd_obd->u.cli.cl_import;
        rc = ptlrpc_init_import(imp);
-       if (rc)
-               GOTO(out, rc);
-
-       ll_generate_random_uuid(uuid);
-       class_uuid_unparse(uuid, &lwp->lpd_cluuid);
 out:
        if (bufs != NULL)
                OBD_FREE_PTR(bufs);
@@ -267,18 +260,19 @@ static int lwp_init0(const struct lu_env *env, struct lwp_device *lwp,
                RETURN(rc);
        }
 
-       rc = lwp_setup(env, lwp, lustre_cfg_string(cfg, 1));
+       rc = lprocfs_obd_setup(lwp->lpd_obd, true);
        if (rc) {
-               CERROR("%s: setup lwp failed. %d\n",
+               CERROR("%s: lprocfs_obd_setup failed. %d\n",
                       lwp->lpd_obd->obd_name, rc);
                ptlrpcd_decref();
                RETURN(rc);
        }
 
-       rc = lprocfs_obd_setup(lwp->lpd_obd, true);
+       rc = lwp_setup(env, lwp, lustre_cfg_string(cfg, 1));
        if (rc) {
-               CERROR("%s: lprocfs_obd_setup failed. %d\n",
+               CERROR("%s: setup lwp failed. %d\n",
                       lwp->lpd_obd->obd_name, rc);
+               lprocfs_obd_cleanup(lwp->lpd_obd);
                ptlrpcd_decref();
                RETURN(rc);
        }
@@ -375,24 +369,20 @@ static struct lu_device *lwp_device_fini(const struct lu_env *env,
 {
        struct lwp_device       *m = lu2lwp_dev(ludev);
        struct ptlrpc_thread    *thread = &m->lpd_notify_thread;
-       struct l_wait_info       lwi = { 0 };
        int                      rc;
        ENTRY;
 
-       if (!thread_is_stopped(thread))
-               l_wait_event(thread->t_ctl_waitq, thread_is_stopped(thread),
-                            &lwi);
+       wait_event_idle(thread->t_ctl_waitq, thread_is_stopped(thread));
 
        if (m->lpd_exp != NULL)
                class_disconnect(m->lpd_exp);
 
        LASSERT(m->lpd_obd);
-       ptlrpc_lprocfs_unregister_obd(m->lpd_obd);
-       lprocfs_obd_cleanup(m->lpd_obd);
-
        rc = client_obd_cleanup(m->lpd_obd);
        LASSERTF(rc == 0, "error %d\n", rc);
 
+       ptlrpc_lprocfs_unregister_obd(m->lpd_obd);
+
        ptlrpcd_decref();
 
        RETURN(NULL);
@@ -444,7 +434,6 @@ static void lwp_notify_users(struct obd_export *exp)
        struct lwp_device       *lwp;
        struct ptlrpc_thread    *thread;
        struct task_struct      *task;
-       struct l_wait_info       lwi = { 0 };
        char                     name[MTI_NAME_MAXLEN];
 
        LASSERT(exp != NULL);
@@ -468,9 +457,8 @@ static void lwp_notify_users(struct obd_export *exp)
                       name, PTR_ERR(task));
        }
 
-       l_wait_event(thread->t_ctl_waitq,
-                    thread_is_running(thread) || thread_is_stopped(thread),
-                    &lwi);
+       wait_event_idle(thread->t_ctl_waitq,
+                       thread_is_running(thread) || thread_is_stopped(thread));
 }
 
 /**
@@ -634,7 +622,7 @@ static int lwp_set_info_async(const struct lu_env *env,
        RETURN(-EINVAL);
 }
 
-struct obd_ops lwp_obd_device_ops = {
+const struct obd_ops lwp_obd_device_ops = {
        .o_owner        = THIS_MODULE,
        .o_add_conn     = client_import_add_conn,
        .o_del_conn     = client_import_del_conn,