Whamcloud - gitweb
- make HEAD from b_post_cmd3
[fs/lustre-release.git] / lustre / mgs / mgs_handler.c
index b53339a..9fb82c7 100644 (file)
@@ -48,7 +48,8 @@
 
 
 /* Establish a connection to the MGS.*/
-static int mgs_connect(struct lustre_handle *conn, struct obd_device *obd,
+static int mgs_connect(const struct lu_env *env,
+                       struct lustre_handle *conn, struct obd_device *obd,
                        struct obd_uuid *cluuid, struct obd_connect_data *data)
 {
         struct obd_export *exp;
@@ -114,7 +115,7 @@ static int mgs_cleanup(struct obd_device *obd);
 static int mgs_handle(struct ptlrpc_request *req);
 
 /* Start the MGS obd */
-static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
+static int mgs_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
         struct lprocfs_static_vars lvars;
         struct mgs_obd *mgs = &obd->u.mgs;
@@ -128,7 +129,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
 
         /* Find our disk */
         lmi = server_get_mount(obd->obd_name);
-        if (!lmi) 
+        if (!lmi)
                 RETURN(rc = -EINVAL);
 
         mnt = lmi->lmi_mnt;
@@ -161,7 +162,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
         if (rc < 0)
                 GOTO(err_fs, rc);
 
-        rc = llog_setup(obd, LLOG_CONFIG_ORIG_CTXT, obd, 0, NULL,
+        rc = llog_setup(obd, NULL, LLOG_CONFIG_ORIG_CTXT, obd, 0, NULL,
                         &llog_lvfs_ops);
         if (rc)
                 GOTO(err_fs, rc);
@@ -181,7 +182,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
                                 mgs_handle, LUSTRE_MGS_NAME,
                                 obd->obd_proc_entry, NULL,
                                 MGS_THREADS_AUTO_MIN, MGS_THREADS_AUTO_MAX,
-                                "ll_mgs");
+                                "ll_mgs", LCT_MD_THREAD);
 
         if (!mgs->mgs_service) {
                 CERROR("failed to start service\n");
@@ -259,7 +260,7 @@ static int mgs_cleanup(struct obd_device *obd)
 
         if (mgs->mgs_sb == NULL)
                 RETURN(0);
-        
+
         ptlrpc_unregister_service(mgs->mgs_service);
 
         mgs_cleanup_fsdb_list(obd);
@@ -272,12 +273,13 @@ static int mgs_cleanup(struct obd_device *obd)
         server_put_mount(obd->obd_name, mgs->mgs_vfsmnt);
         mgs->mgs_sb = NULL;
 
-        /* Free the namespace in it's own thread, so that if the 
-           ldlm_cancel_handler put the last mgs obd ref, we won't 
+        /* Free the namespace in it's own thread, so that if the
+           ldlm_cancel_handler put the last mgs obd ref, we won't
            deadlock here. */
-        cfs_kernel_thread(mgs_ldlm_nsfree, obd->obd_namespace, 
+        cfs_kernel_thread(mgs_ldlm_nsfree, obd->obd_namespace,
                           CLONE_VM | CLONE_FILES);
 
+
         fsfilt_put_ops(obd->obd_fsops);
 
         LCONSOLE_INFO("%s has stopped.\n", obd->obd_name);
@@ -293,15 +295,15 @@ static int mgs_get_cfg_lock(struct obd_device *obd, char *fsname,
         ENTRY;
 
         rc = mgc_logname2resid(fsname, &res_id);
-        if (!rc) 
-                rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id,
+        if (!rc)
+                rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id,
                                             LDLM_PLAIN, NULL, LCK_EX,
                                             &flags, ldlm_blocking_ast,
                                             ldlm_completion_ast, NULL,
                                             fsname, 0, NULL, lockh);
-        if (rc) 
+        if (rc)
                 CERROR("can't take cfg lock for %s (%d)\n", fsname, rc);
-        
+
         RETURN(rc);
 }
 
@@ -322,21 +324,21 @@ static int mgs_check_target(struct obd_device *obd, struct mgs_target_info *mti)
 
         rc = mgs_check_index(obd, mti);
         if (rc == 0) {
-                LCONSOLE_ERROR("%s claims to have registered, but this MGS "
-                               "does not know about it.  Assuming writeconf.\n",
-                               mti->mti_svname);
+                LCONSOLE_ERROR_MSG(0x13b, "%s claims to have registered, but "
+                                   "this MGS does not know about it. Assuming"
+                                   " writeconf.\n", mti->mti_svname);
                 mti->mti_flags |= LDD_F_WRITECONF;
                 rc = 1;
         } else if (rc == -1) {
-                LCONSOLE_ERROR("Client log %s-client has disappeared! "
-                               "Regenerating all logs.\n",
-                               mti->mti_fsname);
+                LCONSOLE_ERROR_MSG(0x13c, "Client log %s-client has "
+                                   "disappeared! Regenerating all logs.\n",
+                                   mti->mti_fsname);
                 mti->mti_flags |= LDD_F_WRITECONF;
                 rc = 1;
         } else {
                 /* Index is correctly marked as used */
 
-                /* If the logs don't contain the mti_nids then add 
+                /* If the logs don't contain the mti_nids then add
                    them as failover nids */
                 rc = mgs_check_failnid(obd, mti);
         }
@@ -346,7 +348,7 @@ static int mgs_check_target(struct obd_device *obd, struct mgs_target_info *mti)
 
 /* Called whenever a target starts up.  Flags indicate first connect, etc. */
 static int mgs_handle_target_reg(struct ptlrpc_request *req)
-{    
+{
         struct obd_device *obd = req->rq_export->exp_obd;
         struct lustre_handle lockh;
         struct mgs_target_info *mti, *rep_mti;
@@ -356,7 +358,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req)
 
         mti = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*mti),
                                  lustre_swab_mgs_target_info);
-        
+
         if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 |
                                 LDD_F_UPDATE))) {
                 /* We're just here as a startup ping. */
@@ -364,22 +366,23 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req)
                        mti->mti_svname, obd_export_nid2str(req->rq_export));
                 rc = mgs_check_target(obd, mti);
                 /* above will set appropriate mti flags */
-                if (rc <= 0) 
+                if (rc <= 0)
                         /* Nothing wrong, or fatal error */
                         GOTO(out_nolock, rc);
         }
 
         /* Revoke the config lock to make sure nobody is reading. */
         /* Although actually I think it should be alright if
-           someone was reading while we were updating the logs - if we 
+           someone was reading while we were updating the logs - if we
            revoke at the end they will just update from where they left off. */
         lockrc = mgs_get_cfg_lock(obd, mti->mti_fsname, &lockh);
         if (lockrc != ELDLM_OK) {
-                LCONSOLE_ERROR("%s: Can't signal other nodes to update "
-                               "their configuration (%d). Updating local logs "
-                               "anyhow; you might have to manually restart "
-                               "other nodes to get the latest configuration.\n",
-                               obd->obd_name, lockrc);
+                LCONSOLE_ERROR_MSG(0x13d, "%s: Can't signal other nodes to "
+                                   "update their configuration (%d). Updating "
+                                   "local logs anyhow; you might have to "
+                                   "manually restart other nodes to get the "
+                                   "latest configuration.\n",
+                                   obd->obd_name, lockrc);
         }
 
         OBD_FAIL_TIMEOUT(OBD_FAIL_MGS_SLOW_TARGET_REG, 10);
@@ -418,19 +421,19 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req)
         /* end COMPAT_146 */
 
         if (mti->mti_flags & LDD_F_UPDATE) {
-                CDEBUG(D_MGS, "updating %s, index=%d\n", mti->mti_svname, 
+                CDEBUG(D_MGS, "updating %s, index=%d\n", mti->mti_svname,
                        mti->mti_stripe_index);
-                
-                /* create or update the target log 
+
+                /* create or update the target log
                    and update the client/mdt logs */
                 rc = mgs_write_log_target(obd, mti);
                 if (rc) {
-                        CERROR("Failed to write %s log (%d)\n", 
+                        CERROR("Failed to write %s log (%d)\n",
                                mti->mti_svname, rc);
                         GOTO(out, rc);
                 }
 
-                mti->mti_flags &= ~(LDD_F_VIRGIN | LDD_F_UPDATE | 
+                mti->mti_flags &= ~(LDD_F_VIRGIN | LDD_F_UPDATE |
                                     LDD_F_NEED_INDEX | LDD_F_WRITECONF |
                                     LDD_F_UPGRADE14);
                 mti->mti_flags |= LDD_F_REWRITE_LDD;
@@ -441,9 +444,9 @@ out:
         if (lockrc == ELDLM_OK)
                 mgs_put_cfg_lock(&lockh);
 out_nolock:
-        CDEBUG(D_MGS, "replying with %s, index=%d, rc=%d\n", mti->mti_svname, 
+        CDEBUG(D_MGS, "replying with %s, index=%d, rc=%d\n", mti->mti_svname,
                mti->mti_stripe_index, rc);
-        lustre_pack_reply(req, 2, rep_size, NULL); 
+        lustre_pack_reply(req, 2, rep_size, NULL);
         /* send back the whole mti in the reply */
         rep_mti = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
                                  sizeof(*rep_mti));
@@ -461,7 +464,6 @@ int mgs_handle(struct ptlrpc_request *req)
         ENTRY;
 
         OBD_FAIL_TIMEOUT(OBD_FAIL_MGS_SLOW_REQUEST_NET, 2);
-        OBD_FAIL_RETURN(OBD_FAIL_MGS_ALL_REQUEST_NET | OBD_FAIL_ONCE, 0);
 
         LASSERT(current->journal_info == NULL);
         opc = lustre_msg_get_opc(req->rq_reqmsg);
@@ -477,7 +479,7 @@ int mgs_handle(struct ptlrpc_request *req)
         switch (opc) {
         case MGS_CONNECT:
                 DEBUG_REQ(D_MGS, req, "connect");
-                rc = target_handle_connect(req, mgs_handle);
+                rc = target_handle_connect(req);
                 if (!rc && (lustre_msg_get_conn_cnt(req->rq_reqmsg) > 1))
                         /* Make clients trying to reconnect after a MGS restart
                            happy; also requires obd_replayable */
@@ -490,11 +492,11 @@ int mgs_handle(struct ptlrpc_request *req)
                 req->rq_status = rc;            /* superfluous? */
                 break;
         case MGS_TARGET_REG:
-                DEBUG_REQ(D_MGS, req, "target add\n");
+                DEBUG_REQ(D_MGS, req, "target add");
                 rc = mgs_handle_target_reg(req);
                 break;
         case MGS_TARGET_DEL:
-                DEBUG_REQ(D_MGS, req, "target del\n");
+                DEBUG_REQ(D_MGS, req, "target del");
                 //rc = mgs_handle_target_del(req);
                 break;
 
@@ -515,7 +517,7 @@ int mgs_handle(struct ptlrpc_request *req)
                 rc = target_handle_ping(req);
                 break;
         case OBD_LOG_CANCEL:
-                DEBUG_REQ(D_MGS, req, "log cancel\n");
+                DEBUG_REQ(D_MGS, req, "log cancel");
                 rc = -ENOTSUPP; /* la la la */
                 break;
 
@@ -546,11 +548,11 @@ int mgs_handle(struct ptlrpc_request *req)
         }
 
         LASSERT(current->journal_info == NULL);
-        
-        if (rc) 
+
+        if (rc)
                 CERROR("MGS handle cmd=%d rc=%d\n", opc, rc);
 
- out:
+out:
         target_send_reply(req, rc, fail);
         RETURN(0);
 }
@@ -598,7 +600,7 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 if (lcfg == NULL)
                         RETURN(-ENOMEM);
                 rc = copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1);
-                if (rc) 
+                if (rc)
                         GOTO(out_free, rc);
 
                 if (lcfg->lcfg_bufcount < 1)
@@ -616,8 +618,8 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                    writing (above). */
                 if (fsname[0]) {
                         lockrc = mgs_get_cfg_lock(obd, fsname, &lockh);
-                        if (lockrc != ELDLM_OK) 
-                                CERROR("lock error %d for fs %s\n", lockrc, 
+                        if (lockrc != ELDLM_OK)
+                                CERROR("lock error %d for fs %s\n", lockrc,
                                        fsname);
                         else
                                 mgs_put_cfg_lock(&lockh);
@@ -677,7 +679,8 @@ static int __init mgs_init(void)
         struct lprocfs_static_vars lvars;
 
         lprocfs_init_vars(mgs, &lvars);
-        class_register_type(&mgs_obd_ops, lvars.module_vars, LUSTRE_MGS_NAME);
+        class_register_type(&mgs_obd_ops, NULL,
+                            lvars.module_vars, LUSTRE_MGS_NAME, NULL);
 
         return 0;
 }