Whamcloud - gitweb
LU-887 mgc: prevent client IR with old server
[fs/lustre-release.git] / lustre / mgc / mgc_request.c
index f4c7d13..49262b4 100644 (file)
@@ -1231,7 +1231,7 @@ enum {
         CONFIG_READ_NRPAGES      = 4
 };
 
-static int mgc_apply_recover_logs(struct obd_device *obd,
+static int mgc_apply_recover_logs(struct obd_device *mgc,
                                   struct config_llog_data *cld,
                                   __u64 max_version,
                                   void *data, int datalen)
@@ -1244,26 +1244,29 @@ static int mgc_apply_recover_logs(struct obd_device *obd,
         u64   prev_version = 0;
         char *inst;
         char *buf;
-        int   bufsz = CFS_PAGE_SIZE;
+        int   bufsz;
         int   pos;
         int   rc  = 0;
         int   off = 0;
-
-        OBD_ALLOC(buf, CFS_PAGE_SIZE);
-        if (buf == NULL)
-                return -ENOMEM;
+        ENTRY;
 
         LASSERT(cfg->cfg_instance != NULL);
         LASSERT(cfg->cfg_sb == cfg->cfg_instance);
-        inst = buf;
+
+        OBD_ALLOC(inst, CFS_PAGE_SIZE);
+        if (inst == NULL)
+                RETURN(-ENOMEM);
+
         if (!(lsi->lsi_flags & LSI_SERVER)) {
                 pos = sprintf(inst, "%p", cfg->cfg_instance);
         } else {
                 LASSERT(IS_MDT(lsi->lsi_ldd));
                 pos = sprintf(inst, "MDT%04x", lsi->lsi_ldd->ldd_svindex);
         }
-        buf   += pos + 1;
-        bufsz -= pos + 1;
+
+        ++pos;
+        buf   = inst + pos;
+        bufsz = CFS_PAGE_SIZE - pos;
 
         while (datalen > 0) {
                 int   entry_len = sizeof(*entry);
@@ -1329,7 +1332,8 @@ static int mgc_apply_recover_logs(struct obd_device *obd,
                 strcpy(obdname, cld->cld_logname);
                 cname = strrchr(obdname, '-');
                 if (cname == NULL) {
-                        CERROR("mgc: invalid logname %s\n", obdname);
+                        CERROR("mgc %s: invalid logname %s\n",
+                               mgc->obd_name, obdname);
                         break;
                 }
 
@@ -1345,8 +1349,8 @@ static int mgc_apply_recover_logs(struct obd_device *obd,
                 /* find the obd by obdname */
                 obd = class_name2obd(obdname);
                 if (obd == NULL) {
-                        CDEBUG(D_INFO, "mgc: cannot find obdname %s\n",
-                               obdname);
+                        CDEBUG(D_INFO, "mgc %s: cannot find obdname %s\n",
+                               mgc->obd_name, obdname);
 
                         /* this is a safe race, when the ost is starting up...*/
                         continue;
@@ -1398,7 +1402,7 @@ static int mgc_apply_recover_logs(struct obd_device *obd,
         }
 
         OBD_FREE(inst, CFS_PAGE_SIZE);
-        return rc;
+        RETURN(rc);
 }
 
 /**
@@ -1773,7 +1777,7 @@ out_pop:
 int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld)
 {
         struct lustre_handle lockh = { 0 };
-        int rc = 0, rcl, flags = 0;
+        int rc = 0, rcl, flags = LDLM_FL_NO_LRU;
         ENTRY;
 
         LASSERT(cld);
@@ -1901,8 +1905,15 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf)
                 cld->cld_cfg.cfg_flags |= CFG_F_COMPAT146;
 
                 rc = mgc_process_log(obd, cld);
-                if (rc == 0 && cld->cld_recover) {
-                        rc = mgc_process_log(obd, cld->cld_recover);
+                if (rc == 0 && cld->cld_recover != NULL) {
+                        if (OCD_HAS_FLAG(&obd->u.cli.cl_import->
+                                         imp_connect_data, IMP_RECOV)) {
+                                rc = mgc_process_log(obd, cld->cld_recover);
+                        } else {
+                                struct config_llog_data *cir = cld->cld_recover;
+                                cld->cld_recover = NULL;
+                                config_log_put(cir);
+                        }
                         if (rc)
                                 CERROR("Cannot process recover llog %d\n", rc);
                 }