Whamcloud - gitweb
LU-3540 lod: update recovery thread
[fs/lustre-release.git] / lustre / mdt / mdt_handler.c
index 0e26b18..a2cc964 100644 (file)
@@ -128,33 +128,33 @@ static struct lu_kmem_descr mdt_caches[] = {
        }
 };
 
-int mdt_get_disposition(struct ldlm_reply *rep, int flag)
+__u64 mdt_get_disposition(struct ldlm_reply *rep, __u64 op_flag)
 {
-        if (!rep)
-                return 0;
-        return (rep->lock_policy_res1 & flag);
+       if (!rep)
+               return 0;
+       return rep->lock_policy_res1 & op_flag;
 }
 
 void mdt_clear_disposition(struct mdt_thread_info *info,
-                          struct ldlm_reply *rep, int flag)
+                          struct ldlm_reply *rep, __u64 op_flag)
 {
        if (info) {
-               info->mti_opdata &= ~flag;
-               tgt_opdata_clear(info->mti_env, flag);
+               info->mti_opdata &= ~op_flag;
+               tgt_opdata_clear(info->mti_env, op_flag);
        }
        if (rep)
-               rep->lock_policy_res1 &= ~flag;
+               rep->lock_policy_res1 &= ~op_flag;
 }
 
 void mdt_set_disposition(struct mdt_thread_info *info,
-                        struct ldlm_reply *rep, int flag)
+                        struct ldlm_reply *rep, __u64 op_flag)
 {
        if (info) {
-               info->mti_opdata |= flag;
-               tgt_opdata_set(info->mti_env, flag);
+               info->mti_opdata |= op_flag;
+               tgt_opdata_set(info->mti_env, op_flag);
        }
        if (rep)
-               rep->lock_policy_res1 |= flag;
+               rep->lock_policy_res1 |= op_flag;
 }
 
 void mdt_lock_reg_init(struct mdt_lock_handle *lh, ldlm_mode_t lm)
@@ -284,24 +284,6 @@ static int mdt_getstatus(struct tgt_session_info *tsi)
        repbody->mbo_fid1 = mdt->mdt_md_root_fid;
        repbody->mbo_valid |= OBD_MD_FLID;
 
-       if (tsi->tsi_tgt->lut_mds_capa &&
-           exp_connect_flags(info->mti_exp) & OBD_CONNECT_MDS_CAPA) {
-               struct mdt_object       *root;
-               struct lustre_capa      *capa;
-
-               root = mdt_object_find(info->mti_env, mdt, &repbody->mbo_fid1);
-               if (IS_ERR(root))
-                       GOTO(out, rc = PTR_ERR(root));
-
-                capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA1);
-                LASSERT(capa);
-                capa->lc_opc = CAPA_OPC_MDS_DEFAULT;
-                rc = mo_capa_get(info->mti_env, mdt_object_child(root), capa,
-                                 0);
-                mdt_object_put(info->mti_env, root);
-                if (rc == 0)
-                       repbody->mbo_valid |= OBD_MD_FLMDSCAPA;
-        }
        EXIT;
 out:
        mdt_thread_info_fini(info);
@@ -362,33 +344,6 @@ out:
        RETURN(rc);
 }
 
-/**
- * Pack SOM attributes into the reply.
- * Call under a DLM UPDATE lock.
- */
-static void mdt_pack_size2body(struct mdt_thread_info *info,
-                               struct mdt_object *mo)
-{
-        struct mdt_body *b;
-        struct md_attr *ma = &info->mti_attr;
-
-        LASSERT(ma->ma_attr.la_valid & LA_MODE);
-        b = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
-
-        /* Check if Size-on-MDS is supported, if this is a regular file,
-         * if SOM is enabled on the object and if SOM cache exists and valid.
-         * Otherwise do not pack Size-on-MDS attributes to the reply. */
-        if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM) ||
-            !S_ISREG(ma->ma_attr.la_mode) ||
-            !mdt_object_is_som_enabled(mo) ||
-            !(ma->ma_valid & MA_SOM))
-                return;
-
-       b->mbo_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
-       b->mbo_size = ma->ma_som->msd_size;
-       b->mbo_blocks = ma->ma_som->msd_blocks;
-}
-
 #ifdef CONFIG_FS_POSIX_ACL
 /*
  * Pack ACL data into the reply. UIDs/GIDs are mapped and filtered by nodemap.
@@ -814,19 +769,6 @@ int mdt_attr_get_complex(struct mdt_thread_info *info,
                        GOTO(out, rc);
        }
 
-       if (need & MA_SOM && S_ISREG(mode)) {
-               buf->lb_buf = info->mti_xattr_buf;
-               buf->lb_len = sizeof(info->mti_xattr_buf);
-               CLASSERT(sizeof(struct som_attrs) <=
-                        sizeof(info->mti_xattr_buf));
-               rc2 = mo_xattr_get(info->mti_env, next, buf, XATTR_NAME_SOM);
-               rc2 = lustre_buf2som(info->mti_xattr_buf, rc2, ma->ma_som);
-               if (rc2 == 0)
-                       ma->ma_valid |= MA_SOM;
-               else if (rc2 < 0 && rc2 != -ENODATA)
-                       GOTO(out, rc = rc2);
-       }
-
        if (need & MA_HSM && S_ISREG(mode)) {
                buf->lb_buf = info->mti_xattr_buf;
                buf->lb_len = sizeof(info->mti_xattr_buf);
@@ -941,8 +883,6 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
                 ma->ma_need |= MA_LOV_DEF;
         }
         ma->ma_need |= ma_need;
-        if (ma->ma_need & MA_SOM)
-                ma->ma_som = &info->mti_u.som.data;
 
        rc = mdt_attr_get_complex(info, o, ma);
        if (unlikely(rc)) {
@@ -1060,12 +1000,10 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
         }
 
        if (reqbody->mbo_valid & OBD_MD_FLMODEASIZE) {
-               repbody->mbo_max_cookiesize = 0;
                repbody->mbo_max_mdsize = info->mti_mdt->mdt_max_mdsize;
                repbody->mbo_valid |= OBD_MD_FLMODEASIZE;
-               CDEBUG(D_INODE, "I am going to change the MAX_MD_SIZE & "
-                      "MAX_COOKIE to : %d:%d\n", repbody->mbo_max_mdsize,
-                      repbody->mbo_max_cookiesize);
+               CDEBUG(D_INODE, "changing the max MD size to %u\n",
+                      repbody->mbo_max_mdsize);
        }
 
        if (exp_connect_rmtclient(info->mti_exp) &&
@@ -1089,20 +1027,6 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
                rc = mdt_pack_acl2body(info, repbody, o, nodemap);
 #endif
 
-       if (reqbody->mbo_valid & OBD_MD_FLMDSCAPA &&
-           info->mti_mdt->mdt_lut.lut_mds_capa &&
-           exp_connect_flags(info->mti_exp) & OBD_CONNECT_MDS_CAPA) {
-                struct lustre_capa *capa;
-
-                capa = req_capsule_server_get(pill, &RMF_CAPA1);
-                LASSERT(capa);
-                capa->lc_opc = CAPA_OPC_MDS_DEFAULT;
-                rc = mo_capa_get(env, next, capa, 0);
-                if (rc)
-                        RETURN(rc);
-               repbody->mbo_valid |= OBD_MD_FLMDSCAPA;
-        }
-
 out:
         if (rc == 0)
                mdt_counter_incr(req, LPROC_MDT_GETATTR);
@@ -1110,38 +1034,6 @@ out:
         RETURN(rc);
 }
 
-static int mdt_renew_capa(struct mdt_thread_info *info)
-{
-        struct mdt_object  *obj = info->mti_object;
-        struct mdt_body    *body;
-        struct lustre_capa *capa, *c;
-        int rc;
-        ENTRY;
-
-        /* if object doesn't exist, or server has disabled capability,
-         * return directly, client will find body->valid OBD_MD_FLOSSCAPA
-         * flag not set.
-         */
-       if (!obj || !info->mti_mdt->mdt_lut.lut_oss_capa ||
-           !(exp_connect_flags(info->mti_exp) & OBD_CONNECT_OSS_CAPA))
-               RETURN(0);
-
-        body = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
-        LASSERT(body != NULL);
-
-        c = req_capsule_client_get(info->mti_pill, &RMF_CAPA1);
-        LASSERT(c);
-
-        capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA2);
-        LASSERT(capa);
-
-        *capa = *c;
-        rc = mo_capa_get(info->mti_env, mdt_object_child(obj), capa, 1);
-        if (rc == 0)
-               body->mbo_valid |= OBD_MD_FLOSSCAPA;
-        RETURN(rc);
-}
-
 static int mdt_getattr(struct tgt_session_info *tsi)
 {
        struct mdt_thread_info  *info = tsi2mdt_info(tsi);
@@ -1154,15 +1046,6 @@ static int mdt_getattr(struct tgt_session_info *tsi)
 
         reqbody = req_capsule_client_get(pill, &RMF_MDT_BODY);
         LASSERT(reqbody);
-
-       if (reqbody->mbo_valid & OBD_MD_FLOSSCAPA) {
-                rc = req_capsule_server_pack(pill);
-                if (unlikely(rc))
-                        RETURN(err_serious(rc));
-                rc = mdt_renew_capa(info);
-                GOTO(out_shrink, rc);
-        }
-
         LASSERT(obj != NULL);
        LASSERT(lu_object_assert_exists(&obj->mot_obj));
 
@@ -1215,11 +1098,6 @@ static int mdt_getattr(struct tgt_session_info *tsi)
 
        info->mti_cross_ref = !!(reqbody->mbo_valid & OBD_MD_FLCROSSREF);
 
-       /*
-        * Don't check capability at all, because rename might getattr for
-        * remote obj, and at that time no capability is available.
-        */
-       mdt_set_capainfo(info, 1, &reqbody->mbo_fid1, BYPASS_CAPA);
        rc = mdt_getattr_internal(info, obj, 0);
        if (reqbody->mbo_valid & OBD_MD_FLRMTPERM)
                 mdt_exit_ucred(info);
@@ -1286,16 +1164,6 @@ static int mdt_swap_layouts(struct tgt_session_info *tsi)
        if (info->mti_dlm_req != NULL)
                ldlm_request_cancel(req, info->mti_dlm_req, 0, LATF_SKIP);
 
-       if (req_capsule_get_size(info->mti_pill, &RMF_CAPA1, RCL_CLIENT))
-               mdt_set_capainfo(info, 0, &info->mti_body->mbo_fid1,
-                                req_capsule_client_get(info->mti_pill,
-                                                       &RMF_CAPA1));
-
-       if (req_capsule_get_size(info->mti_pill, &RMF_CAPA2, RCL_CLIENT))
-               mdt_set_capainfo(info, 1, &info->mti_body->mbo_fid2,
-                                req_capsule_client_get(info->mti_pill,
-                                                       &RMF_CAPA2));
-
        o1 = info->mti_object;
        o = o2 = mdt_object_find(info->mti_env, info->mti_mdt,
                                &info->mti_body->mbo_fid2);
@@ -1391,7 +1259,7 @@ static int mdt_raw_lookup(struct mdt_thread_info *info,
 }
 
 /*
- * UPDATE lock should be taken against parent, and be release before exit;
+ * UPDATE lock should be taken against parent, and be released before exit;
  * child_bits lock should be taken against child, and be returned back:
  *            (1)normal request should release the child lock;
  *            (2)intent request will grant the lock to client.
@@ -1461,7 +1329,6 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                        RETURN(-ENOENT);
                }
 
-               mdt_set_capainfo(info, 0, mdt_object_fid(child), BYPASS_CAPA);
                rc = mdt_getattr_internal(info, child, 0);
                if (unlikely(rc != 0))
                        mdt_object_unlock(info, child, lhc, 1);
@@ -1565,11 +1432,11 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
        if (unlikely(IS_ERR(child)))
                GOTO(out_parent, rc = PTR_ERR(child));
 
+       OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_RESEND, obd_timeout * 2);
        rc = mdt_check_resent_lock(info, child, lhc);
        if (rc < 0) {
                GOTO(out_child, rc);
        } else if (rc > 0) {
-                OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_RESEND, obd_timeout*2);
                 mdt_lock_handle_init(lhc);
                mdt_lock_reg_init(lhc, LCK_PR);
                try_layout = false;
@@ -1641,14 +1508,8 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
         }
 
         lock = ldlm_handle2lock(&lhc->mlh_reg_lh);
-        /* Get MA_SOM attributes if update lock is given. */
-        if (lock &&
-            lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_UPDATE &&
-            S_ISREG(lu_object_attr(&mdt_object_child(child)->mo_lu)))
-                ma_need |= MA_SOM;
 
         /* finally, we can get attr for child. */
-        mdt_set_capainfo(info, 1, child_fid, BYPASS_CAPA);
         rc = mdt_getattr_internal(info, child, ma_need);
         if (unlikely(rc != 0)) {
                 mdt_object_unlock(info, child, lhc, 1);
@@ -1660,8 +1521,6 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info,
                         "Lock res_id: "DLDLMRES", fid: "DFID"\n",
                         PLDLMRES(lock->l_resource),
                         PFID(mdt_object_fid(child)));
-               if (mdt_object_exists(child) && !mdt_object_remote(child))
-                       mdt_pack_size2body(info, child);
         }
         if (lock)
                 LDLM_LOCK_PUT(lock);
@@ -2072,14 +1931,6 @@ static int mdt_quotactl(struct tgt_session_info *tsi)
                RETURN(err_serious(rc));
 
        switch (oqctl->qc_cmd) {
-       case Q_QUOTACHECK:
-       case LUSTRE_Q_INVALIDATE:
-       case LUSTRE_Q_FINVALIDATE:
-       case Q_QUOTAON:
-       case Q_QUOTAOFF:
-       case Q_INITQUOTA:
-               /* deprecated, not used any more */
-               RETURN(-EOPNOTSUPP);
                /* master quotactl */
        case Q_SETINFO:
        case Q_SETQUOTA:
@@ -2463,8 +2314,6 @@ int mdt_remote_object_lock(struct mdt_thread_info *mti,
 
        LASSERT(mdt_object_remote(o));
 
-       LASSERT(ibits == MDS_INODELOCK_UPDATE);
-
        fid_build_reg_res_name(fid, res_id);
 
        memset(einfo, 0, sizeof(*einfo));
@@ -2713,7 +2562,7 @@ void mdt_save_lock(struct mdt_thread_info *info, struct lustre_handle *h,
  * Unlock mdt object.
  *
  * Immeditely release the regular lock and the PDO lock or save the
- * lock in reqeuest and keep them referenced until client ACK or
+ * lock in request and keep them referenced until client ACK or
  * transaction commit.
  *
  * \param info thread info object
@@ -2801,27 +2650,11 @@ static int mdt_body_unpack(struct mdt_thread_info *info, __u32 flags)
                 RETURN(-EINVAL);
         }
 
-        /*
-         * Do not get size or any capa fields before we check that request
-         * contains capa actually. There are some requests which do not, for
-         * instance MDS_IS_SUBDIR.
-         */
-        if (req_capsule_has_field(pill, &RMF_CAPA1, RCL_CLIENT) &&
-            req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT))
-               mdt_set_capainfo(info, 0, &body->mbo_fid1,
-                                req_capsule_client_get(pill, &RMF_CAPA1));
-
        obj = mdt_object_find(env, info->mti_mdt, &body->mbo_fid1);
        if (!IS_ERR(obj)) {
-               if ((flags & HABEO_CORPUS) &&
-                   !mdt_object_exists(obj)) {
+               if ((flags & HABEO_CORPUS) && !mdt_object_exists(obj)) {
                        mdt_object_put(env, obj);
-                       /* for capability renew ENOENT will be handled in
-                        * mdt_renew_capa */
-                       if (body->mbo_valid & OBD_MD_FLOSSCAPA)
-                                rc = 0;
-                        else
-                                rc = -ENOENT;
+                       rc = -ENOENT;
                 } else {
                         info->mti_object = obj;
                         rc = 0;
@@ -2857,17 +2690,6 @@ static int mdt_unpack_req_pack_rep(struct mdt_thread_info *info, __u32 flags)
         RETURN(rc);
 }
 
-static int mdt_init_capa_ctxt(const struct lu_env *env, struct mdt_device *m)
-{
-       struct md_device *next = m->mdt_child;
-
-       return next->md_ops->mdo_init_capa_ctxt(env, next,
-                                               m->mdt_lut.lut_mds_capa,
-                                               m->mdt_capa_timeout,
-                                               m->mdt_capa_alg,
-                                               m->mdt_capa_keys);
-}
-
 void mdt_lock_handle_init(struct mdt_lock_handle *lh)
 {
         lh->mlh_type = MDT_NUL_LOCK;
@@ -2950,28 +2772,14 @@ void mdt_thread_info_fini(struct mdt_thread_info *info)
 struct mdt_thread_info *tsi2mdt_info(struct tgt_session_info *tsi)
 {
        struct mdt_thread_info  *mti;
-       struct lustre_capa      *lc;
 
        mti = mdt_th_info(tsi->tsi_env);
        LASSERT(mti != NULL);
 
        mdt_thread_info_init(tgt_ses_req(tsi), mti);
        if (tsi->tsi_corpus != NULL) {
-               struct req_capsule *pill = tsi->tsi_pill;
-
                mti->mti_object = mdt_obj(tsi->tsi_corpus);
                lu_object_get(tsi->tsi_corpus);
-
-               /*
-                * XXX: must be part of tgt_mdt_body_unpack but moved here
-                * due to mdt_set_capainfo().
-                */
-               if (req_capsule_has_field(pill, &RMF_CAPA1, RCL_CLIENT) &&
-                   req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT) > 0) {
-                       lc = req_capsule_client_get(pill, &RMF_CAPA1);
-                       mdt_set_capainfo(mti, 0, &tsi->tsi_mdt_body->mbo_fid1,
-                                        lc);
-               }
        }
        mti->mti_body = tsi->tsi_mdt_body;
        mti->mti_dlm_req = tsi->tsi_dlm_req;
@@ -2988,9 +2796,10 @@ static int mdt_tgt_connect(struct tgt_session_info *tsi)
 
        if (OBD_FAIL_CHECK(OBD_FAIL_TGT_DELAY_CONDITIONAL) &&
            cfs_fail_val ==
-           tsi2mdt_info(tsi)->mti_mdt->mdt_seq_site.ss_node_id)
-               schedule_timeout_and_set_state(TASK_UNINTERRUPTIBLE,
-                       msecs_to_jiffies(3 * MSEC_PER_SEC));
+           tsi2mdt_info(tsi)->mti_mdt->mdt_seq_site.ss_node_id) {
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(msecs_to_jiffies(3 * MSEC_PER_SEC));
+       }
 
        rc = tgt_connect(tsi);
        if (rc != 0)
@@ -3694,20 +3503,26 @@ static int mdt_register_lwp_callback(void *data)
 
        LASSERT(mdt_seq_site(mdt)->ss_node_id != 0);
 
-       if (!likely(fld->lsf_new))
-               RETURN(0);
-
        rc = lu_env_init(&env, LCT_MD_THREAD);
-       if (rc) {
+       if (rc < 0) {
                CERROR("%s: cannot init env: rc = %d\n", mdt_obd_name(mdt), rc);
                RETURN(rc);
        }
 
-       rc = fld_update_from_controller(&env, fld);
-       if (rc != 0) {
-               CERROR("%s: cannot update controller: rc = %d\n",
-                      mdt_obd_name(mdt), rc);
+       /* Allocate new sequence now to avoid creating local transaction
+        * in the normal transaction process */
+       rc = seq_server_check_and_alloc_super(&env,
+                                             mdt_seq_site(mdt)->ss_server_seq);
+       if (rc < 0)
                GOTO(out, rc);
+
+       if (fld->lsf_new) {
+               rc = fld_update_from_controller(&env, fld);
+               if (rc != 0) {
+                       CERROR("%s: cannot update controller: rc = %d\n",
+                              mdt_obd_name(mdt), rc);
+                       GOTO(out, rc);
+               }
        }
 out:
        lu_env_fini(&env);
@@ -3828,7 +3643,7 @@ static int mdt_seq_init(const struct lu_env *env, struct mdt_device *mdt)
                GOTO(out_seq_fini, rc);
 
        if (ss->ss_node_id != 0)
-               /* register controler export through lwp */
+               /* register controller export through lwp */
                rc = mdt_register_seq_exp(mdt);
 
        EXIT;
@@ -4323,8 +4138,6 @@ TGT_MDT_HDL(HABEO_CORPUS,         MDS_GETXATTR,   mdt_tgt_getxattr),
 TGT_MDT_HDL(0          | HABEO_REFERO, MDS_STATFS,     mdt_statfs),
 TGT_MDT_HDL(0          | MUTABOR,      MDS_REINT,      mdt_reint),
 TGT_MDT_HDL(HABEO_CORPUS,              MDS_CLOSE,      mdt_close),
-TGT_MDT_HDL(HABEO_CORPUS,              MDS_DONE_WRITING,
-                                                       mdt_done_writing),
 TGT_MDT_HDL(HABEO_CORPUS| HABEO_REFERO,        MDS_READPAGE,   mdt_readpage),
 TGT_MDT_HDL(HABEO_CORPUS| HABEO_REFERO,        MDS_SYNC,       mdt_sync),
 TGT_MDT_HDL(0,                         MDS_QUOTACTL,   mdt_quotactl),
@@ -4459,10 +4272,6 @@ static void mdt_fini(const struct lu_env *env, struct mdt_device *m)
         mdt_seq_fini(env, m);
         mdt_fld_fini(env, m);
 
-        next->md_ops->mdo_init_capa_ctxt(env, next, 0, 0, 0, NULL);
-        cfs_timer_disarm(&m->mdt_ck_timer);
-        mdt_ck_thread_stop(m);
-
        /*
         * Finish the stack
         */
@@ -4516,8 +4325,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
 
         m->mdt_max_mdsize = MAX_MD_SIZE; /* 4 stripes */
 
-        m->mdt_som_conf = 0;
-
         m->mdt_opts.mo_cos = MDT_COS_DEFAULT;
 
        /* default is coordinator off, it is started through conf_param
@@ -4536,10 +4343,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
                obd->u.obt.obt_magic = OBT_MAGIC;
        }
 
-       spin_lock_init(&m->mdt_ioepoch_lock);
-        m->mdt_capa_timeout = CAPA_TIMEOUT;
-        m->mdt_capa_alg = CAPA_HMAC_ALG_SHA1;
-        m->mdt_ck_timeout = CAPA_KEY_TIMEOUT;
        m->mdt_squash.rsi_uid = 0;
        m->mdt_squash.rsi_gid = 0;
        INIT_LIST_HEAD(&m->mdt_squash.rsi_nosquash_nids);
@@ -4610,8 +4413,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         /* set obd_namespace for compatibility with old code */
         obd->obd_namespace = m->mdt_namespace;
 
-        cfs_timer_init(&m->mdt_ck_timer, mdt_ck_timer_callback, m);
-
        rc = mdt_hsm_cdt_init(m);
        if (rc != 0) {
                CERROR("%s: error initializing coordinator, rc %d\n",
@@ -4619,15 +4420,11 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
                 GOTO(err_free_ns, rc);
        }
 
-        rc = mdt_ck_thread_start(m);
-        if (rc)
-                GOTO(err_free_hsm, rc);
-
        rc = tgt_init(env, &m->mdt_lut, obd, m->mdt_bottom, mdt_common_slice,
                      OBD_FAIL_MDS_ALL_REQUEST_NET,
                      OBD_FAIL_MDS_ALL_REPLY_NET);
        if (rc)
-               GOTO(err_capa, rc);
+               GOTO(err_free_hsm, rc);
 
        rc = mdt_fs_setup(env, m, obd, lsi);
        if (rc)
@@ -4689,8 +4486,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         * when the whole stack is complete and ready
         * to serve the requests */
 
-        mdt_init_capa_ctxt(env, m);
-
         /* Reduce the initial timeout on an MDS because it doesn't need such
          * a long timeout as an OST does. Adaptive timeouts will adjust this
          * value appropriately. */
@@ -4708,9 +4503,6 @@ err_fs_cleanup:
        mdt_fs_cleanup(env, m);
 err_tgt:
        tgt_fini(env, &m->mdt_lut);
-err_capa:
-       cfs_timer_disarm(&m->mdt_ck_timer);
-       mdt_ck_thread_stop(m);
 err_free_hsm:
        mdt_hsm_cdt_fini(m);
 err_free_ns:
@@ -4831,7 +4623,7 @@ static struct lu_object *mdt_object_alloc(const struct lu_env *env,
                lu_object_init(o, h, d);
                lu_object_add_top(h, o);
                o->lo_ops = &mdt_obj_ops;
-               mutex_init(&mo->mot_ioepoch_mutex);
+               spin_lock_init(&mo->mot_write_lock);
                mutex_init(&mo->mot_lov_mutex);
                init_rwsem(&mo->mot_open_sem);
                RETURN(o);
@@ -4882,13 +4674,13 @@ static void mdt_object_free(const struct lu_env *env, struct lu_object *o)
 }
 
 static int mdt_object_print(const struct lu_env *env, void *cookie,
-                            lu_printer_t p, const struct lu_object *o)
+                           lu_printer_t p, const struct lu_object *o)
 {
-        struct mdt_object *mdto = mdt_obj((struct lu_object *)o);
-        return (*p)(env, cookie, LUSTRE_MDT_NAME"-object@%p(ioepoch="LPU64" "
-                    "flags="LPX64", epochcount=%d, writecount=%d)",
-                    mdto, mdto->mot_ioepoch, mdto->mot_flags,
-                    mdto->mot_ioepoch_count, mdto->mot_writecount);
+       struct mdt_object *mdto = mdt_obj((struct lu_object *)o);
+
+       return (*p)(env, cookie,
+                   LUSTRE_MDT_NAME"-object@%p(flags=%d, writecount=%d)",
+                   mdto, mdto->mot_flags, mdto->mot_write_count);
 }
 
 static int mdt_prepare(const struct lu_env *env,
@@ -4929,6 +4721,7 @@ static int mdt_prepare(const struct lu_env *env,
        }
 
        LASSERT(!test_bit(MDT_FL_CFGLOG, &mdt->mdt_state));
+
        target_recovery_init(&mdt->mdt_lut, tgt_request_handle);
        set_bit(MDT_FL_CFGLOG, &mdt->mdt_state);
        LASSERT(obd->obd_no_conn);
@@ -5017,9 +4810,6 @@ static int mdt_connect_internal(struct obd_export *exp,
        if (!mdt->mdt_opts.mo_user_xattr)
                data->ocd_connect_flags &= ~OBD_CONNECT_XATTR;
 
-       if (!mdt->mdt_som_conf)
-               data->ocd_connect_flags &= ~OBD_CONNECT_SOM;
-
        if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) {
                data->ocd_brw_size = min(data->ocd_brw_size,
                                         (__u32)MD_MAX_BRW_SIZE);
@@ -5057,15 +4847,6 @@ static int mdt_connect_internal(struct obd_export *exp,
                return -EBADE;
        }
 
-       if (mdt->mdt_som_conf &&
-           !(data->ocd_connect_flags & (OBD_CONNECT_LIGHTWEIGHT |
-                                        OBD_CONNECT_MDS_MDS |
-                                        OBD_CONNECT_SOM))) {
-               CWARN("%s: MDS has SOM enabled, but client does not support "
-                     "it\n", mdt_obd_name(mdt));
-               return -EBADE;
-       }
-
        if (OCD_HAS_FLAG(data, PINGLESS)) {
                if (ptlrpc_pinger_suppress_pings()) {
                        spin_lock(&exp->exp_obd->obd_dev_lock);
@@ -5167,7 +4948,7 @@ static int mdt_export_cleanup(struct obd_export *exp)
                         * archive request into a noop if it's not actually
                         * dirty.
                         */
-                       if (mfd->mfd_mode & (FMODE_WRITE|MDS_FMODE_TRUNC))
+                       if (mfd->mfd_mode & FMODE_WRITE)
                                rc = mdt_ctxt_add_dirty_flag(&env, info, mfd);
 
                        /* Don't unlink orphan on failover umount, LU-184 */
@@ -5232,10 +5013,11 @@ static int mdt_obd_connect(const struct lu_env *env,
         *      at some point we should find a better one
         */
        if (!test_bit(MDT_FL_SYNCED, &mdt->mdt_state) && data != NULL &&
-           !(data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT)) {
+           !(data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT) &&
+           !(data->ocd_connect_flags & OBD_CONNECT_MDS_MDS)) {
                rc = obd_get_info(env, mdt->mdt_child_exp,
                                  sizeof(KEY_OSP_CONNECTED),
-                                 KEY_OSP_CONNECTED, NULL, NULL, NULL);
+                                 KEY_OSP_CONNECTED, NULL, NULL);
                if (rc)
                        RETURN(-EAGAIN);
                set_bit(MDT_FL_SYNCED, &mdt->mdt_state);
@@ -5794,6 +5576,7 @@ static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 break;
        case OBD_IOC_ABORT_RECOVERY:
                CERROR("%s: Aborting recovery for device\n", mdt_obd_name(mdt));
+               obd->obd_force_abort_recovery = 1;
                target_stop_recovery_thread(obd);
                rc = 0;
                break;
@@ -6069,6 +5852,8 @@ static void __exit mdt_mod_exit(void)
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Metadata Target ("LUSTRE_MDT_NAME")");
+MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-cfs_module(mdt, LUSTRE_VERSION_STRING, mdt_mod_init, mdt_mod_exit);
+module_init(mdt_mod_init);
+module_exit(mdt_mod_exit);