Whamcloud - gitweb
LU-10629 lod: Clear OST pool with setstripe
[fs/lustre-release.git] / lustre / osp / lwp_dev.c
index 8f33435..c240e25 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2013, 2015, Intel Corporation.
+ * Copyright (c) 2013, 2017, Intel Corporation.
  * Use is subject to license terms.
  *
  * lustre/osp/lwp_dev.c
@@ -40,7 +40,7 @@
 #define DEBUG_SUBSYSTEM S_OST
 
 #include <obd_class.h>
-#include <lustre_param.h>
+#include <uapi/linux/lustre/lustre_param.h>
 #include <lustre_log.h>
 #include <linux/kthread.h>
 
@@ -114,9 +114,10 @@ static int lwp_setup(const struct lu_env *env, struct lwp_device *lwp,
        lustre_cfg_bufs_reset(bufs, lwp_name);
        lustre_cfg_bufs_set_string(bufs, 1, server_uuid);
        lustre_cfg_bufs_set_string(bufs, 2, nidstring);
-       lcfg = lustre_cfg_new(LCFG_SETUP, bufs);
-       if (lcfg == NULL)
+       OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen));
+       if (!lcfg)
                GOTO(out, rc = -ENOMEM);
+       lustre_cfg_init(lcfg, LCFG_SETUP, bufs);
 
        rc = client_obd_setup(lwp->lpd_obd, lcfg);
        if (rc != 0) {
@@ -137,8 +138,9 @@ out:
                OBD_FREE_PTR(bufs);
        if (server_uuid != NULL)
                OBD_FREE(server_uuid, len);
-       if (lcfg != NULL)
-               lustre_cfg_free(lcfg);
+       if (lcfg)
+               OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount,
+                                             lcfg->lcfg_buflens));
        if (rc)
                client_obd_cleanup(lwp->lpd_obd);
 
@@ -273,11 +275,24 @@ static int lwp_init0(const struct lu_env *env, struct lwp_device *lwp,
                RETURN(rc);
        }
 
-       if (lprocfs_obd_setup(lwp->lpd_obd) == 0) {
-               sptlrpc_lprocfs_cliobd_attach(lwp->lpd_obd);
-               ptlrpc_lprocfs_register_obd(lwp->lpd_obd);
+       rc = lprocfs_obd_setup(lwp->lpd_obd, true);
+       if (rc) {
+               CERROR("%s: lprocfs_obd_setup failed. %d\n",
+                      lwp->lpd_obd->obd_name, rc);
+               ptlrpcd_decref();
+               RETURN(rc);
        }
 
+       rc = sptlrpc_lprocfs_cliobd_attach(lwp->lpd_obd);
+       if (rc) {
+               CERROR("%s: sptlrpc_lprocfs_cliobd_attached failed. %d\n",
+                      lwp->lpd_obd->obd_name, rc);
+               ptlrpcd_decref();
+               RETURN(rc);
+       }
+
+       ptlrpc_lprocfs_register_obd(lwp->lpd_obd);
+
        RETURN(0);
 }
 
@@ -373,7 +388,6 @@ static struct lu_device *lwp_device_fini(const struct lu_env *env,
 
        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);