Whamcloud - gitweb
LU-3467 mdt: call MDT handlers via unified request handler
[fs/lustre-release.git] / lustre / mdt / mdt_open.c
index 76ed060..dcd18c5 100644 (file)
@@ -905,7 +905,7 @@ int mdt_finish_open(struct mdt_thread_info *info,
         }
 #endif
 
-       if (info->mti_mdt->mdt_opts.mo_mds_capa &&
+       if (info->mti_mdt->mdt_lut.lut_mds_capa &&
            exp_connect_flags(exp) & OBD_CONNECT_MDS_CAPA) {
                 struct lustre_capa *capa;
 
@@ -917,8 +917,7 @@ int mdt_finish_open(struct mdt_thread_info *info,
                         RETURN(rc);
                 repbody->valid |= OBD_MD_FLMDSCAPA;
         }
-
-       if (info->mti_mdt->mdt_opts.mo_oss_capa &&
+       if (info->mti_mdt->mdt_lut.lut_oss_capa &&
            exp_connect_flags(exp) & OBD_CONNECT_OSS_CAPA &&
            S_ISREG(lu_object_attr(&o->mot_obj))) {
                 struct lustre_capa *capa;
@@ -1492,12 +1491,6 @@ out:
        return rc;
 }
 
-int mdt_pin(struct mdt_thread_info* info)
-{
-        ENTRY;
-        RETURN(err_serious(-EOPNOTSUPP));
-}
-
 /* Cross-ref request. Currently it can only be a pure open (w/o create) */
 static int mdt_cross_open(struct mdt_thread_info *info,
                          const struct lu_fid *parent_fid,
@@ -2243,22 +2236,23 @@ int mdt_mfd_close(struct mdt_thread_info *info, struct mdt_file_data *mfd)
        RETURN(rc ? rc : ret);
 }
 
-int mdt_close(struct mdt_thread_info *info)
+int mdt_close(struct tgt_session_info *tsi)
 {
+       struct mdt_thread_info  *info = tsi2mdt_info(tsi);
+       struct ptlrpc_request   *req = tgt_ses_req(tsi);
         struct mdt_export_data *med;
         struct mdt_file_data   *mfd;
         struct mdt_object      *o;
         struct md_attr         *ma = &info->mti_attr;
         struct mdt_body        *repbody = NULL;
-        struct ptlrpc_request  *req = mdt_info_req(info);
         int rc, ret = 0;
         ENTRY;
 
        mdt_counter_incr(req, LPROC_MDT_CLOSE);
-        /* Close may come with the Size-on-MDS update. Unpack it. */
-        rc = mdt_close_unpack(info);
-        if (rc)
-                RETURN(err_serious(rc));
+       /* Close may come with the Size-on-MDS update. Unpack it. */
+       rc = mdt_close_unpack(info);
+       if (rc)
+               GOTO(out, rc = err_serious(rc));
 
         LASSERT(info->mti_ioepoch);
 
@@ -2272,7 +2266,7 @@ int mdt_close(struct mdt_thread_info *info)
                 if (rc == 0)
                         mdt_fix_reply(info);
                mdt_exit_ucred(info);
-                RETURN(lustre_msg_get_status(req->rq_repmsg));
+               GOTO(out, rc = lustre_msg_get_status(req->rq_repmsg));
         }
 
         /* Continue to close handle even if we can not pack reply */
@@ -2327,13 +2321,15 @@ int mdt_close(struct mdt_thread_info *info)
         }
 
        mdt_exit_ucred(info);
-        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK))
-                RETURN(err_serious(-ENOMEM));
+       if (OBD_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK))
+               GOTO(out, rc = err_serious(-ENOMEM));
 
-        if (OBD_FAIL_CHECK_RESET(OBD_FAIL_MDS_CLOSE_NET_REP,
-                                 OBD_FAIL_MDS_CLOSE_NET_REP))
-                info->mti_fail_id = OBD_FAIL_MDS_CLOSE_NET_REP;
-        RETURN(rc ? rc : ret);
+       if (OBD_FAIL_CHECK_RESET(OBD_FAIL_MDS_CLOSE_NET_REP,
+                                OBD_FAIL_MDS_CLOSE_NET_REP))
+               tsi->tsi_reply_fail_id = OBD_FAIL_MDS_CLOSE_NET_REP;
+out:
+       mdt_thread_info_fini(info);
+       RETURN(rc ? rc : ret);
 }
 
 /**
@@ -2344,35 +2340,35 @@ int mdt_close(struct mdt_thread_info *info)
  * and got a trasid. Waiting for such DONE_WRITING is not reliable, so just
  * skip attributes and reconstruct the reply here.
  */
-int mdt_done_writing(struct mdt_thread_info *info)
+int mdt_done_writing(struct tgt_session_info *tsi)
 {
-        struct ptlrpc_request   *req = mdt_info_req(info);
+       struct ptlrpc_request   *req = tgt_ses_req(tsi);
+       struct mdt_thread_info  *info = tsi2mdt_info(tsi);
         struct mdt_body         *repbody = NULL;
         struct mdt_export_data  *med;
         struct mdt_file_data    *mfd;
         int rc;
         ENTRY;
 
-        rc = req_capsule_server_pack(info->mti_pill);
-        if (rc)
-                RETURN(err_serious(rc));
+       rc = req_capsule_server_pack(tsi->tsi_pill);
+       if (rc)
+               GOTO(out, rc = err_serious(rc));
 
-        repbody = req_capsule_server_get(info->mti_pill,
-                                         &RMF_MDT_BODY);
-        repbody->eadatasize = 0;
-        repbody->aclsize = 0;
+       repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_MDT_BODY);
+       repbody->eadatasize = 0;
+       repbody->aclsize = 0;
 
-        /* Done Writing may come with the Size-on-MDS update. Unpack it. */
-        rc = mdt_close_unpack(info);
-        if (rc)
-                RETURN(err_serious(rc));
+       /* Done Writing may come with the Size-on-MDS update. Unpack it. */
+       rc = mdt_close_unpack(info);
+       if (rc)
+               GOTO(out, rc = err_serious(rc));
 
        if (mdt_check_resent(info, mdt_reconstruct_generic, NULL)) {
                mdt_exit_ucred(info);
-               RETURN(lustre_msg_get_status(req->rq_repmsg));
+               GOTO(out, rc = lustre_msg_get_status(req->rq_repmsg));
        }
 
-        med = &info->mti_exp->exp_mdt_data;
+       med = &info->mti_exp->exp_mdt_data;
        spin_lock(&med->med_open_lock);
        mfd = mdt_handle2mfd(med, &info->mti_ioepoch->handle,
                             req_is_replay(req));
@@ -2414,5 +2410,7 @@ int mdt_done_writing(struct mdt_thread_info *info)
         mdt_empty_transno(info, rc);
 error_ucred:
        mdt_exit_ucred(info);
+out:
+       mdt_thread_info_fini(info);
        RETURN(rc);
 }