Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / mdt / mdt_recovery.c
index 4e03c7f..bbad09f 100644 (file)
@@ -335,8 +335,9 @@ static int mdt_clients_data_init(const struct lu_env *env,
                         if (PTR_ERR(exp) == -EALREADY) {
                                 /* export already exists, zero out this one */
                                 lcd->lcd_uuid[0] = '\0';
-                        } else
+                        } else {
                                 GOTO(err_client, rc = PTR_ERR(exp));
+                        }
                 } else {
                         struct mdt_thread_info *mti;
                         mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
@@ -415,9 +416,10 @@ static int mdt_server_data_init(const struct lu_env *env,
                 lsd->lsd_server_size = LR_SERVER_SIZE;
                 lsd->lsd_client_start = LR_CLIENT_START;
                 lsd->lsd_client_size = LR_CLIENT_SIZE;
+                lsd->lsd_feature_compat = OBD_COMPAT_MDT;
                 lsd->lsd_feature_rocompat = OBD_ROCOMPAT_LOVOBJID;
                 lsd->lsd_feature_incompat = OBD_INCOMPAT_MDT |
-                                                       OBD_INCOMPAT_COMMON_LR;
+                                            OBD_INCOMPAT_COMMON_LR;
         } else {
                 LCONSOLE_WARN("%s: used disk, loading\n", obd->obd_name);
                 rc = mdt_last_rcvd_header_read(env, mdt);
@@ -432,15 +434,42 @@ static int mdt_server_data_init(const struct lu_env *env,
                                            obd->obd_uuid.uuid, lsd->lsd_uuid);
                         GOTO(out, rc = -EINVAL);
                 }
+                lsd->lsd_feature_compat |= OBD_COMPAT_MDT;
+                lsd->lsd_feature_incompat |= OBD_INCOMPAT_MDT |
+                                             OBD_INCOMPAT_COMMON_LR;
         }
         mount_count = lsd->lsd_mount_count;
 
         ldd = lsi->lsi_ldd;
 
+        if (lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP) {
+                CERROR("%s: unsupported incompat filesystem feature(s) %x\n",
+                       obd->obd_name,
+                       lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP);
+                GOTO(out, rc = -EINVAL);
+        }
+        if (lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP) {
+                CERROR("%s: unsupported read-only filesystem feature(s) %x\n",
+                       obd->obd_name,
+                       lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP);
+                /* XXX: Do something like remount filesystem read-only */
+                GOTO(out, rc = -EINVAL);
+        }
+        /** Interop: evict all clients at first boot with 1.8 last_rcvd */
+        if (!(lsd->lsd_feature_compat & OBD_COMPAT_20)) {
+                LCONSOLE_WARN("Mounting %s at first time on 1.8 FS, remove all"
+                              " clients for interop needs\n", obd->obd_name);
+                simple_truncate(lsi->lsi_srv_mnt->mnt_sb->s_root,
+                                lsi->lsi_srv_mnt, LAST_RCVD,
+                                lsd->lsd_client_start);
+                last_rcvd_size = lsd->lsd_client_start;
+                /** set 2.0 flag to upgrade/downgrade between 1.8 and 2.0 */
+                lsd->lsd_feature_compat |= OBD_COMPAT_20;
+        }
+
         if (ldd->ldd_flags & LDD_F_IAM_DIR)
                 lsd->lsd_feature_incompat |= OBD_INCOMPAT_IAM_DIR;
 
-        lsd->lsd_feature_compat = OBD_COMPAT_MDT;
         lsd->lsd_feature_incompat |= OBD_INCOMPAT_FID;
 
         spin_lock(&mdt->mdt_transno_lock);
@@ -482,7 +511,7 @@ static int mdt_server_data_init(const struct lu_env *env,
         obd->obd_last_committed = mdt->mdt_last_transno;
         spin_unlock(&mdt->mdt_transno_lock);
 
-        mdt->mdt_mount_count++;
+        mdt->mdt_mount_count = mount_count + 1;
         lsd->lsd_mount_count = mdt->mdt_mount_count;
 
         /* save it, so mount count and last_transno is current */
@@ -591,8 +620,8 @@ int mdt_client_new(const struct lu_env *env, struct mdt_device *mdt)
         spin_unlock(&mti->mti_exp->exp_lock);
 
         rc = mdt_last_rcvd_write(env, mdt, lcd, &off, th);
-        CDEBUG(D_INFO, "wrote client lcd at idx %u off %llu (len "LPSZ")\n",
-               cl_idx, med->med_lr_off, sizeof(*lcd));
+        CDEBUG(D_INFO, "wrote client lcd at idx %u off %llu (len %u)\n",
+               cl_idx, med->med_lr_off, (int)sizeof(*lcd));
         mdt_trans_stop(env, mdt, th);
 
         RETURN(rc);
@@ -913,7 +942,8 @@ static int mdt_txn_stop_cb(const struct lu_env *env,
 
         /* add separate commit callback for transaction handling because we need
          * export as parameter */
-        mdt_trans_add_cb(txn, lut_cb_last_committed, mti->mti_exp);
+        mdt_trans_add_cb(txn, lut_cb_last_committed,
+                         class_export_cb_get(mti->mti_exp));
 
         return mdt_last_rcvd_update(mti, txn);
 }
@@ -1012,12 +1042,11 @@ static void mdt_steal_ack_locks(struct ptlrpc_request *req)
                 if (oldrep->rs_xid != req->rq_xid)
                         continue;
 
-                if (lustre_msg_get_opc(oldrep->rs_msg) !=
-                    lustre_msg_get_opc(req->rq_reqmsg))
+                if (oldrep->rs_opc != lustre_msg_get_opc(req->rq_reqmsg))
                         CERROR ("Resent req xid "LPU64" has mismatched opc: "
                                 "new %d old %d\n", req->rq_xid,
                                 lustre_msg_get_opc(req->rq_reqmsg),
-                                lustre_msg_get_opc(oldrep->rs_msg));
+                                oldrep->rs_opc);
 
                 svc = oldrep->rs_service;
                 spin_lock (&svc->srv_lock);
@@ -1027,8 +1056,7 @@ static void mdt_steal_ack_locks(struct ptlrpc_request *req)
                 CWARN("Stealing %d locks from rs %p x"LPD64".t"LPD64
                       " o%d NID %s\n",
                       oldrep->rs_nlocks, oldrep,
-                      oldrep->rs_xid, oldrep->rs_transno,
-                      lustre_msg_get_opc(oldrep->rs_msg),
+                      oldrep->rs_xid, oldrep->rs_transno, oldrep->rs_opc,
                       libcfs_nid2str(exp->exp_connection->c_peer.nid));
 
                 for (i = 0; i < oldrep->rs_nlocks; i++)