Whamcloud - gitweb
b=17653
[fs/lustre-release.git] / lustre / mgs / mgs_handler.c
index 1bd26d6..e724962 100644 (file)
@@ -90,6 +90,8 @@ static int mgs_connect(const struct lu_env *env,
                 data->ocd_version = LUSTRE_VERSION_CODE;
         }
 
+        rc = mgs_client_add(obd, exp, localdata);
+
         if (rc) {
                 class_disconnect(exp);
         } else {
@@ -101,13 +103,16 @@ static int mgs_connect(const struct lu_env *env,
 
 static int mgs_reconnect(const struct lu_env *env,
                          struct obd_export *exp, struct obd_device *obd,
-                         struct obd_uuid *cluuid, struct obd_connect_data *data)
+                         struct obd_uuid *cluuid, struct obd_connect_data *data,
+                         void *localdata)
 {
         ENTRY;
 
         if (exp == NULL || obd == NULL || cluuid == NULL)
                 RETURN(-EINVAL);
 
+        mgs_counter_incr(exp, LPROC_MGS_CONNECT);
+
         if (data != NULL) {
                 data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED;
                 exp->exp_connect_flags = data->ocd_connect_flags;
@@ -343,7 +348,7 @@ static int mgs_get_cfg_lock(struct obd_device *obd, char *fsname,
                                             LDLM_PLAIN, NULL, LCK_EX,
                                             &flags, ldlm_blocking_ast,
                                             ldlm_completion_ast, NULL,
-                                            fsname, 0, NULL, lockh);
+                                            fsname, 0, NULL, NULL, lockh);
         if (rc)
                 CERROR("can't take cfg lock for %s (%d)\n", fsname, rc);
 
@@ -383,10 +388,9 @@ 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_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;
+                                   "this MGS does not know about it, preventing "
+                                   "registration.\n", mti->mti_svname);
+                rc = -ENOENT;
         } else if (rc == -1) {
                 LCONSOLE_ERROR_MSG(0x13c, "Client log %s-client has "
                                    "disappeared! Regenerating all logs.\n",
@@ -463,7 +467,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req)
                 }
                 mti->mti_flags |= LDD_F_UPDATE;
                 /* Erased logs means start from scratch. */
-                mti->mti_flags &= ~LDD_F_UPGRADE14; 
+                mti->mti_flags &= ~LDD_F_UPGRADE14;
         }
 
         /* COMPAT_146 */
@@ -473,7 +477,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req)
                         CERROR("Can't upgrade from 1.4 (%d)\n", rc);
                         GOTO(out, rc);
                 }
-                
+
                 /* We're good to go */
                 mti->mti_flags |= LDD_F_UPDATE;
         }
@@ -709,6 +713,7 @@ static inline int mgs_destroy_export(struct obd_export *exp)
         ENTRY;
 
         target_destroy_export(exp);
+        mgs_client_free(exp);
         ldlm_destroy_export(exp);
 
         RETURN(0);
@@ -732,7 +737,7 @@ static int mgs_extract_fs_pool(char * arg, char *fsname, char *poolname)
         RETURN(0);
 }
 
-static int mgs_iocontrol_pool(struct obd_device *obd, 
+static int mgs_iocontrol_pool(struct obd_device *obd,
                               struct obd_ioctl_data *data)
 {
         int rc;
@@ -747,7 +752,7 @@ static int mgs_iocontrol_pool(struct obd_device *obd,
         if (fsname == NULL)
                 RETURN(-ENOMEM);
 
-        OBD_ALLOC(poolname, MAXPOOLNAME + 1);
+        OBD_ALLOC(poolname, LOV_MAXPOOLNAME + 1);
         if (poolname == NULL) {
                 rc = -ENOMEM;
                 GOTO(out_pool, rc);
@@ -768,17 +773,14 @@ static int mgs_iocontrol_pool(struct obd_device *obd,
         }
 
         OBD_ALLOC(lcfg, data->ioc_plen1);
-        if (lcfg == NULL) {
-                rc = -ENOMEM;
-                GOTO(out_pool, rc);
-        }
-        rc = copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1);
-        if (rc)
-                GOTO(out_pool, rc);
+        if (lcfg == NULL)
+                GOTO(out_pool, rc = -ENOMEM);
+
+        if (copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
+                GOTO(out_pool, rc = -EFAULT);
 
         if (lcfg->lcfg_bufcount < 2) {
-                rc = -EINVAL;
-                GOTO(out_pool, rc);
+                GOTO(out_pool, rc = -EFAULT);
         }
 
         /* first arg is always <fsname>.<poolname> */
@@ -837,7 +839,7 @@ out_pool:
                 OBD_FREE(fsname, MTI_NAME_MAXLEN);
 
         if (poolname != NULL)
-                OBD_FREE(poolname, MAXPOOLNAME + 1);
+                OBD_FREE(poolname, LOV_MAXPOOLNAME + 1);
 
         RETURN(rc);
 }
@@ -874,9 +876,8 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 OBD_ALLOC(lcfg, data->ioc_plen1);
                 if (lcfg == NULL)
                         RETURN(-ENOMEM);
-                rc = copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1);
-                if (rc)
-                        GOTO(out_free, rc);
+                if (copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1))
+                        GOTO(out_free, rc = -EFAULT);
 
                 if (lcfg->lcfg_bufcount < 1)
                         GOTO(out_free, rc = -EINVAL);