Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / mds / mds_lov.c
index ced694c..6d78907 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/obd_lov.h>
 #include <linux/lustre_lib.h>
 #include <linux/lustre_fsfilt.h>
+#include <linux/lustre_sec.h>
 
 #include "mds_internal.h"
 
@@ -239,6 +240,7 @@ int mds_dt_connect(struct obd_device *obd, char *lov_name)
 {
         struct mds_obd *mds = &obd->u.mds;
         struct lustre_handle conn = { 0 };
+        unsigned long sec_flags = PTLRPC_SEC_FL_MDS;
         int i, rc = 0;
         ENTRY;
 
@@ -259,14 +261,21 @@ int mds_dt_connect(struct obd_device *obd, char *lov_name)
         if (mds->mds_ost_sec) {
                 rc = obd_set_info(mds->mds_dt_obd->obd_self_export,
                                   strlen("sec"), "sec",
-                                  strlen(mds->mds_ost_sec),
-                                  mds->mds_ost_sec);
+                                  strlen(mds->mds_ost_sec), mds->mds_ost_sec);
                 if (rc) {
                         mds->mds_dt_obd = ERR_PTR(rc);
                         RETURN(rc);
                 }
         }
 
+        rc = obd_set_info(mds->mds_dt_obd->obd_self_export,
+                          strlen("sec_flags"), "sec_flags",
+                          sizeof(sec_flags), &sec_flags);
+        if (rc) {
+                mds->mds_dt_obd = ERR_PTR(rc);
+                RETURN(rc);
+        }
+
         CDEBUG(D_HA, "obd: %s osc: %s lov_name: %s\n",
                obd->obd_name, mds->mds_dt_obd->obd_name, lov_name);
 
@@ -323,6 +332,7 @@ int mds_dt_connect(struct obd_device *obd, char *lov_name)
                                        "writing objids file: %d\n", rc);
                 }
         }
+
         /*
          * I want to see a callback happen when the OBD moves to a "For General
          * Use" state, and that's when we'll call set_nextid(). The class driver
@@ -332,8 +342,19 @@ int mds_dt_connect(struct obd_device *obd, char *lov_name)
         if (!obd->obd_recovering) {
                 CDEBUG(D_OTHER, "call mds_postrecov_common()\n");
                 rc = mds_postrecov_common(obd);
-                if (rc > 0) 
-                        rc = 0;
+                if (rc < 0)
+                        GOTO(err_reg, rc);
+                rc = 0;
+        }
+
+        for (i = 0; i < 2; i++) {
+                if (!mds->mds_capa_keys[i].k_key)
+                        break;
+                rc = obd_set_info(mds->mds_dt_exp, strlen("capa_key"),
+                                  "capa_key", sizeof(struct lustre_capa_key),
+                                  mds->mds_capa_keys[i].k_key);
+                if (rc)
+                        GOTO(err_reg, rc);
         }
         RETURN(rc);
 
@@ -605,11 +626,8 @@ int mds_dt_synchronize(void *data)
         struct obd_uuid *uuid;
         obd_id vals[2];
         unsigned long flags;
-        __u32  vallen;
-        __u32  group;
-        int old_count;
-        int count;
-        int index;
+        __u32  vallen, group;
+        int old_count, count, index, i;
         int rc;
         char name[32] = "CATLIST";
 
@@ -637,6 +655,8 @@ int mds_dt_synchronize(void *data)
         down(&mds->mds_orphan_recovery_sem);
 
         uuid = &watched->u.cli.cl_import->imp_target_uuid;
+        CWARN("MDS %s: %s now active, repairing the connection\n",
+              obd->obd_name, uuid->uuid);
 
         group = FILTER_GROUP_FIRST_MDS + mds->mds_num;
         rc = obd_set_info(watched->obd_self_export, strlen("mds_conn"),
@@ -659,11 +679,25 @@ int mds_dt_synchronize(void *data)
         if (rc)
                 GOTO(cleanup, rc);
 
+        for (i = 0; i < 2; i++) {
+                if (!mds->mds_capa_keys[i].k_key)
+                        break;
+                rc = obd_set_info(mds->mds_dt_exp, strlen("capa_key"),
+                                  "capa_key", sizeof(struct lustre_capa_key),
+                                  mds->mds_capa_keys[i].k_key);
+                if (rc)
+                        GOTO(cleanup, rc);
+        }
+
+        /* we don't set next id manually, instead OSCs will set them
+         * during own recovery from DELORPHAN reply -bzzz */
+#if 0
         vals[0] = index;
         rc = mds_dt_set_info(obd->obd_self_export, strlen("next_id"),
                              "next_id", 2, vals);
         if (rc)
                 GOTO(cleanup, rc);
+#endif
 
         obd_llog_finish(obd, &obd->obd_llogs, old_count);
         obd_llog_cat_initialize(obd, &obd->obd_llogs, count, name);
@@ -734,10 +768,10 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched,
         if (!active)
                 RETURN(0);
 
-        if (!strcmp(watched->obd_type->typ_name, LUSTRE_MDC_NAME))
+        if (!strcmp(watched->obd_type->typ_name, OBD_MDC_DEVICENAME))
                 RETURN(0);
 
-        if (strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) {
+        if (strcmp(watched->obd_type->typ_name, OBD_OSC_DEVICENAME)) {
                 CERROR("unexpected notification of %s %s!\n",
                        watched->obd_type->typ_name, watched->obd_name);
                 RETURN(-EINVAL);
@@ -793,15 +827,15 @@ int mds_dt_update_config(struct obd_device *obd, int clean)
 {
         struct mds_obd *mds = &obd->u.mds;
         struct lvfs_run_ctxt saved;
-        struct config_llog_instance cfg;
         struct llog_ctxt *ctxt;
+        struct config_llog_instance cfg;
         char *profile = mds->mds_profile, *name;
-        int rc, version, namelen;
+         int rc, version, namelen, value;
+        __u32 valsize;
         ENTRY;
 
         if (profile == NULL)
                 RETURN(0);
-
         cfg.cfg_instance = NULL;
         cfg.cfg_uuid = mds->mds_dt_uuid;
 
@@ -809,7 +843,6 @@ int mds_dt_update_config(struct obd_device *obd, int clean)
         OBD_ALLOC(name, namelen);
         if (name == NULL)
                 RETURN(-ENOMEM);
-
         if (clean) {
                 version = mds->mds_config_version - 1;
                 sprintf(name, "%s-clean-%d", profile, version);
@@ -817,17 +850,28 @@ int mds_dt_update_config(struct obd_device *obd, int clean)
                 version = mds->mds_config_version + 1;
                 sprintf(name, "%s-%d", profile, version);
         }
-
         CWARN("Applying configuration log %s\n", name);
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         ctxt = llog_get_context(&obd->obd_llogs, LLOG_CONFIG_ORIG_CTXT);
         rc = class_config_process_llog(ctxt, name, &cfg);
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        if (rc == 0)
-                mds->mds_config_version = version;
         CWARN("Finished applying configuration log %s: %d\n", name, rc);
+        if (rc != 0) { 
+                GOTO(exit, rc);
+        }
+        /* retrieve size of EA */
+        rc = obd_get_info(mds->mds_md_exp, strlen("mdsize"),
+                          "mdsize", &valsize, &value);
+        
+        if (value > mds->mds_max_mdsize)
+                mds->mds_max_mdsize = value;
 
+        CDEBUG(D_INFO, "mds max md size %d \n", mds->mds_max_mdsize);
+        
+        if (rc == 0)
+                mds->mds_config_version = version;
+exit:
         OBD_FREE(name, namelen);
         RETURN(rc);
 }