Whamcloud - gitweb
LU-56 ptlrpc: clean up ptlrpc svc initializing APIs
[fs/lustre-release.git] / lustre / mgs / mgs_handler.c
index 7686390..4e7068b 100644 (file)
@@ -167,6 +167,7 @@ static int mgs_llog_finish(struct obd_device *obd, int count)
 /* Start the MGS obd */
 static int mgs_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
+       static struct ptlrpc_service_conf       conf;
         struct lprocfs_static_vars lvars;
         struct mgs_obd *mgs = &obd->u.mgs;
         struct lustre_mount_info *lmi;
@@ -237,33 +238,42 @@ static int mgs_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                         GOTO(err_llog, rc);
         }
 
+       conf = (typeof(conf)) {
+               .psc_name               = LUSTRE_MGS_NAME,
+               .psc_watchdog_factor    = MGS_SERVICE_WATCHDOG_FACTOR,
+               .psc_buf                = {
+                       .bc_nbufs               = MGS_NBUFS,
+                       .bc_buf_size            = MGS_BUFSIZE,
+                       .bc_req_max_size        = MGS_MAXREQSIZE,
+                       .bc_rep_max_size        = MGS_MAXREPSIZE,
+                       .bc_req_portal          = MGS_REQUEST_PORTAL,
+                       .bc_rep_portal          = MGC_REPLY_PORTAL,
+               },
+               .psc_thr                = {
+                       .tc_thr_name            = "ll_mgs",
+                       .tc_nthrs_min           = MGS_THREADS_AUTO_MIN,
+                       .tc_nthrs_max           = MGS_THREADS_AUTO_MAX,
+                       .tc_ctx_tags            = LCT_MD_THREAD,
+               },
+               .psc_ops                = {
+                       .so_req_handler         = mgs_handle,
+                       .so_req_printer         = target_print_req,
+               },
+       };
         /* Start the service threads */
-        mgs->mgs_service =
-                ptlrpc_init_svc(MGS_NBUFS, MGS_BUFSIZE, MGS_MAXREQSIZE,
-                                MGS_MAXREPSIZE, MGS_REQUEST_PORTAL,
-                                MGC_REPLY_PORTAL, 2,
-                                mgs_handle, LUSTRE_MGS_NAME,
-                                obd->obd_proc_entry, target_print_req,
-                                MGS_THREADS_AUTO_MIN, MGS_THREADS_AUTO_MAX,
-                                "ll_mgs", LCT_MD_THREAD, NULL);
-
-        if (!mgs->mgs_service) {
-                CERROR("failed to start service\n");
-                GOTO(err_llog, rc = -ENOMEM);
+       mgs->mgs_service = ptlrpc_register_service(&conf, obd->obd_proc_entry);
+       if (IS_ERR(mgs->mgs_service)) {
+               rc = PTR_ERR(mgs->mgs_service);
+               CERROR("failed to start service: %d\n", rc);
+               GOTO(err_llog, rc);
         }
 
-        rc = ptlrpc_start_threads(mgs->mgs_service);
-        if (rc)
-                GOTO(err_thread, rc);
-
         ping_evictor_start();
 
         CDEBUG(D_INFO, "MGS %s started\n", obd->obd_name);
 
         RETURN(0);
 
-err_thread:
-        ptlrpc_unregister_service(mgs->mgs_service);
 err_llog:
         lproc_mgs_cleanup(obd);
         obd_llog_finish(obd, 0);