X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fosp%2Flwp_dev.c;h=829555e0d541b3aa0e91bfd581cc0ab266886a71;hp=b28f32cf07554f8005f096a4023865e3cf5e2ae1;hb=3cce65712d94cffe8f1626545845b95b88aef672;hpb=107c1d022ffd976b4a335f794de731cf9d57a514 diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c index b28f32c..829555e 100644 --- a/lustre/osp/lwp_dev.c +++ b/lustre/osp/lwp_dev.c @@ -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 -#include +#include #include #include @@ -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; @@ -114,9 +112,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) { @@ -127,18 +126,14 @@ 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); 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); @@ -265,19 +260,33 @@ static int lwp_init0(const struct lu_env *env, struct lwp_device *lwp, RETURN(rc); } + 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 = lwp_setup(env, lwp, lustre_cfg_string(cfg, 1)); if (rc) { CERROR("%s: setup lwp failed. %d\n", lwp->lpd_obd->obd_name, rc); + lprocfs_obd_cleanup(lwp->lpd_obd); ptlrpcd_decref(); 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 = 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); } @@ -372,12 +381,11 @@ static struct lu_device *lwp_device_fini(const struct lu_env *env, 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); @@ -403,6 +411,8 @@ static int lwp_notify_main(void *args) struct ptlrpc_thread *thread; LASSERT(exp != NULL); + class_export_get(exp); + lwp = lu2lwp_dev(exp->exp_obd->obd_lu_dev); thread = &lwp->lpd_notify_thread; @@ -411,6 +421,7 @@ static int lwp_notify_main(void *args) lustre_notify_lwp_list(exp); + class_export_put(exp); thread_set_flags(thread, SVC_STOPPED); wake_up(&thread->t_ctl_waitq); return 0;