Whamcloud - gitweb
- make HEAD from b_post_cmd3
[fs/lustre-release.git] / lustre / ost / ost_handler.c
index 1992393..2b14646 100644 (file)
@@ -55,6 +55,10 @@ static int oss_num_threads;
 CFS_MODULE_PARM(oss_num_threads, "i", int, 0444,
                 "number of OSS service threads to start");
 
+static int ost_num_threads;
+CFS_MODULE_PARM(ost_num_threads, "i", int, 0444,
+                "number of OST service threads to start (deprecated)");
+
 void oti_to_request(struct obd_trans_info *oti, struct ptlrpc_request *req)
 {
         struct oti_req_ack_lock *ack_lock;
@@ -119,9 +123,12 @@ static int ost_getattr(struct obd_export *exp, struct ptlrpc_request *req)
 
         repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
                                  sizeof(*repbody));
-        memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
+        repbody->oa = body->oa;
 
         oinfo.oi_oa = &repbody->oa;
+        if (oinfo.oi_oa->o_valid & OBD_MD_FLOSSCAPA)
+                oinfo.oi_capa = lustre_unpack_capa(req->rq_reqmsg,
+                                                   REQ_REC_OFF + 1);
         req->rq_status = obd_getattr(exp, &oinfo);
         RETURN(0);
 }
@@ -138,7 +145,7 @@ static int ost_statfs(struct ptlrpc_request *req)
 
         osfs = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*osfs));
 
-        req->rq_status = obd_statfs(req->rq_export->exp_obd, osfs, 
+        req->rq_status = obd_statfs(req->rq_export->exp_obd, osfs,
                                     cfs_time_current_64() - HZ);
         if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_OST_ENOSPC))
                 osfs->os_bfree = osfs->os_bavail = 64;
@@ -181,7 +188,7 @@ static int ost_punch_lock_get(struct obd_export *exp, struct obdo *oa,
                               struct lustre_handle *lh)
 {
         int flags;
-        struct ldlm_res_id res_id = { .name = { oa->o_id } };
+        struct ldlm_res_id res_id = { .name = { oa->o_id, 0, oa->o_gr, 0} };
         ldlm_policy_data_t policy;
         __u64 start;
         __u64 finis;
@@ -216,7 +223,7 @@ static int ost_punch_lock_get(struct obd_export *exp, struct obdo *oa,
         else
                 policy.l_extent.end = finis | ~CFS_PAGE_MASK;
 
-        RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, res_id, 
+        RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, &res_id,
                                       LDLM_EXTENT, &policy, LCK_PW, &flags,
                                       ldlm_blocking_ast, ldlm_completion_ast,
                                       ldlm_glimpse_ast, NULL, 0, NULL, lh));
@@ -277,6 +284,9 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
                          */
                         oinfo.oi_oa->o_valid &= ~OBD_MD_FLFLAGS;
 
+                if (oinfo.oi_oa->o_valid & OBD_MD_FLOSSCAPA)
+                        oinfo.oi_capa = lustre_unpack_capa(req->rq_reqmsg,
+                                                           REQ_REC_OFF + 1);
                 req->rq_status = obd_punch(exp, &oinfo, oti, NULL);
                 ost_punch_lock_put(exp, oinfo.oi_oa, &lh);
         }
@@ -287,6 +297,7 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
 static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req)
 {
         struct ost_body *body, *repbody;
+        struct lustre_capa *capa = NULL;
         int rc, size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
         ENTRY;
 
@@ -295,6 +306,9 @@ static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req)
         if (body == NULL)
                 RETURN(-EFAULT);
 
+        if (body->oa.o_valid & OBD_MD_FLOSSCAPA)
+                capa = lustre_unpack_capa(req->rq_reqmsg, REQ_REC_OFF + 1);
+
         rc = lustre_pack_reply(req, 2, size, NULL);
         if (rc)
                 RETURN(rc);
@@ -303,7 +317,7 @@ static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req)
                                  sizeof(*repbody));
         memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
         req->rq_status = obd_sync(exp, &repbody->oa, NULL, repbody->oa.o_size,
-                                  repbody->oa.o_blocks);
+                                  repbody->oa.o_blocks, capa);
         RETURN(0);
 }
 
@@ -326,9 +340,12 @@ static int ost_setattr(struct obd_export *exp, struct ptlrpc_request *req,
 
         repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
                                  sizeof(*repbody));
-        memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
+        repbody->oa = body->oa;
 
         oinfo.oi_oa = &repbody->oa;
+        if (oinfo.oi_oa->o_valid & OBD_MD_FLOSSCAPA)
+                oinfo.oi_capa = lustre_unpack_capa(req->rq_reqmsg,
+                                                   REQ_REC_OFF + 1);
         req->rq_status = obd_setattr(exp, &oinfo, oti);
         RETURN(0);
 }
@@ -366,7 +383,8 @@ static int get_per_page_niobufs(struct obd_ioobj *ioo, int nioo,
                 for (j = 0; j < ioo->ioo_bufcnt; j++, rnbidx++) {
                         obd_off offset = rnb[rnbidx].offset;
                         obd_off p0 = offset >> CFS_PAGE_SHIFT;
-                        obd_off pn = (offset + rnb[rnbidx].len - 1)>>CFS_PAGE_SHIFT;
+                        obd_off pn = (offset + rnb[rnbidx].len - 1) >>
+                                     CFS_PAGE_SHIFT;
 
                         LASSERT(rnbidx < nrnb);
 
@@ -409,7 +427,7 @@ static int get_per_page_niobufs(struct obd_ioobj *ioo, int nioo,
                         do {
                                 obd_off  poff = off & ~CFS_PAGE_MASK;
                                 int      pnob = (poff + nob > CFS_PAGE_SIZE) ?
-                                                CFS_PAGE_SIZE - poff : nob;
+                                                PAGE_SIZE - poff : nob;
 
                                 LASSERT(page < npages);
                                 pp_rnb[page].len = pnob;
@@ -449,7 +467,8 @@ static __u32 ost_checksum_bulk(struct ptlrpc_bulk_desc *desc)
 
                 /* corrupt the data before we compute the checksum, to
                  * simulate a client->OST data error */
-                if (i == 0 &&OBD_FAIL_CHECK_ONCE(OBD_FAIL_OST_CHECKSUM_RECEIVE))
+                if (i == 0 &&
+                    OBD_FAIL_CHECK_ONCE(OBD_FAIL_OST_CHECKSUM_RECEIVE))
                         memcpy(ptr, "bad3", min(4, len));
                 cksum = crc32_le(cksum, ptr, len);
                 /* corrupt the data after we compute the checksum, to
@@ -516,7 +535,8 @@ static int ost_brw_lock_get(int mode, struct obd_export *exp,
 {
         int flags                 = 0;
         int nrbufs                = obj->ioo_bufcnt;
-        struct ldlm_res_id res_id = { .name = { obj->ioo_id } };
+        struct ldlm_res_id res_id = { .name = { obj->ioo_id, 0,
+                                                obj->ioo_gr, 0} };
         ldlm_policy_data_t policy;
         int i;
 
@@ -537,7 +557,7 @@ static int ost_brw_lock_get(int mode, struct obd_export *exp,
         policy.l_extent.end   = (nb[nrbufs - 1].offset +
                                  nb[nrbufs - 1].len - 1) | ~CFS_PAGE_MASK;
 
-        RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, res_id, 
+        RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, &res_id,
                                       LDLM_EXTENT, &policy, mode, &flags,
                                       ldlm_blocking_ast, ldlm_completion_ast,
                                       ldlm_glimpse_ast, NULL, 0, NULL, lh));
@@ -604,7 +624,8 @@ static int ost_prolong_locks_iter(struct ldlm_lock *lock, void *data)
 static void ost_prolong_locks(struct obd_export *exp, struct obd_ioobj *obj,
                               struct niobuf_remote *nb, ldlm_mode_t mode)
 {
-        struct ldlm_res_id res_id = { .name = { obj->ioo_id } };
+        struct ldlm_res_id res_id = { .name = { obj->ioo_id, 0,
+                                                obj->ioo_gr, 0} };
         int nrbufs = obj->ioo_bufcnt;
         struct ost_prolong_data opd;
 
@@ -631,6 +652,7 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         struct niobuf_local *local_nb;
         struct obd_ioobj *ioo;
         struct ost_body *body, *repbody;
+        struct lustre_capa *capa = NULL;
         struct l_wait_info lwi;
         struct lustre_handle lockh = { 0 };
         int size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
@@ -638,6 +660,8 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         int no_reply = 0;
         ENTRY;
 
+        req->rq_bulk_read = 1;
+
         if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_READ_BULK))
                 GOTO(out, rc = -EIO);
 
@@ -660,7 +684,7 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
 
         niocount = ioo->ioo_bufcnt;
         if (niocount > PTLRPC_MAX_BRW_PAGES) {
-                DEBUG_REQ(D_ERROR, req, "bulk has too many pages (%d)\n",
+                DEBUG_REQ(D_ERROR, req, "bulk has too many pages (%d)",
                           niocount);
                 GOTO(out, rc = -EFAULT);
         }
@@ -677,6 +701,9 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
                         lustre_swab_niobuf_remote (&remote_nb[i]);
         }
 
+        if (body->oa.o_valid & OBD_MD_FLOSSCAPA)
+                capa = lustre_unpack_capa(req->rq_reqmsg, REQ_REC_OFF + 3);
+
         rc = lustre_pack_reply(req, 2, size, NULL);
         if (rc)
                 GOTO(out, rc);
@@ -722,7 +749,7 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         }
 
         rc = obd_preprw(OBD_BRW_READ, req->rq_export, &body->oa, 1,
-                        ioo, npages, pp_rnb, local_nb, oti);
+                        ioo, npages, pp_rnb, local_nb, oti, capa);
         if (rc != 0)
                 GOTO(out_lock, rc);
 
@@ -769,8 +796,12 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         if (rc == 0) {
                 if (desc->bd_export->exp_failed)
                         rc = -ENOTCONN;
-                else
+                else {
+                        sptlrpc_svc_wrap_bulk(req, desc);
+
                         rc = ptlrpc_start_bulk_transfer(desc);
+                }
+
                 if (rc == 0) {
                         lwi = LWI_TIMEOUT_INTERVAL(obd_timeout * HZ / 4, HZ,
                                                    ost_bulk_timeout, desc);
@@ -796,7 +827,7 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
                                 rc = -ETIMEDOUT;
                         }
                 } else {
-                        DEBUG_REQ(D_ERROR, req, "bulk PUT failed: rc %d\n", rc);
+                        DEBUG_REQ(D_ERROR, req, "bulk PUT failed: rc %d", rc);
                 }
                 comms_error = rc != 0;
         }
@@ -813,13 +844,13 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 memcpy(&repbody->oa, &body->oa, sizeof(repbody->oa));
         }
 
- out_lock:
+out_lock:
         ost_brw_lock_put(LCK_PR, ioo, pp_rnb, &lockh);
- out_bulk:
+out_bulk:
         ptlrpc_free_bulk(desc);
         if (no_reply)
                 RETURN(rc);
- out:
+out:
         LASSERT(rc <= 0);
         if (rc == 0) {
                 req->rq_status = nob;
@@ -857,6 +888,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         struct ost_body         *body, *repbody;
         struct l_wait_info       lwi;
         struct lustre_handle     lockh = {0};
+        struct lustre_capa      *capa = NULL;
         __u32                   *rcs;
         int size[3] = { sizeof(struct ptlrpc_body), sizeof(*body) };
         int objcount, niocount, npages, comms_error = 0;
@@ -865,6 +897,8 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         int                      no_reply = 0; 
         ENTRY;
 
+        req->rq_bulk_write = 1;
+
         if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_WRITE_BULK))
                 GOTO(out, rc = -EIO);
 
@@ -906,7 +940,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         }
 
         if (niocount > PTLRPC_MAX_BRW_PAGES) {
-                DEBUG_REQ(D_ERROR, req, "bulk has too many pages (%d)\n",
+                DEBUG_REQ(D_ERROR, req, "bulk has too many pages (%d)",
                           niocount);
                 GOTO(out, rc = -EFAULT);
         }
@@ -923,6 +957,9 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                         lustre_swab_niobuf_remote (&remote_nb[i]);
         }
 
+        if (body->oa.o_valid & OBD_MD_FLOSSCAPA)
+                capa = lustre_unpack_capa(req->rq_reqmsg, REQ_REC_OFF + 3);
+
         size[REPLY_REC_OFF + 1] = niocount * sizeof(*rcs);
         rc = lustre_pack_reply(req, 3, size, NULL);
         if (rc != 0)
@@ -974,9 +1011,17 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
 
         /* obd_preprw clobbers oa->valid, so save what we need */
         client_cksum = body->oa.o_valid & OBD_MD_FLCKSUM ? body->oa.o_cksum : 0;
+        
+        /* Because we already sync grant info with client when reconnect,
+         * grant info will be cleared for resent req, then fed_grant and 
+         * total_grant will not be modified in following preprw_write */ 
+        if (lustre_msg_get_flags(req->rq_reqmsg) & (MSG_RESENT | MSG_REPLAY)) {
+                DEBUG_REQ(D_CACHE, req, "clear resent/replay req grant info\n");
+                body->oa.o_valid &= ~OBD_MD_FLGRANT;
+        }
 
         rc = obd_preprw(OBD_BRW_WRITE, req->rq_export, &body->oa, objcount,
-                        ioo, npages, pp_rnb, local_nb, oti);
+                        ioo, npages, pp_rnb, local_nb, oti, capa);
         if (rc != 0)
                 GOTO(out_lock, rc);
 
@@ -1016,7 +1061,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                         rc = -ETIMEDOUT;
                 }
         } else {
-                DEBUG_REQ(D_ERROR, req, "ptlrpc_bulk_get failed: rc %d\n", rc);
+                DEBUG_REQ(D_ERROR, req, "ptlrpc_bulk_get failed: rc %d", rc);
         }
         comms_error = rc != 0;
 
@@ -1026,7 +1071,6 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
 
         if (unlikely(client_cksum != 0 && rc == 0)) {
                 static int cksum_counter;
-
                 server_cksum = ost_checksum_bulk(desc);
                 repbody->oa.o_valid |= OBD_MD_FLCKSUM;
                 repbody->oa.o_cksum = server_cksum;
@@ -1042,6 +1086,8 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 }
         }
 
+        sptlrpc_svc_unwrap_bulk(req, desc);
+
         /* Must commit after prep above in all cases */
         rc = obd_commitrw(OBD_BRW_WRITE, req->rq_export, &repbody->oa,
                            objcount, ioo, npages, local_nb, oti, rc);
@@ -1066,21 +1112,22 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                         router = libcfs_nid2str(desc->bd_sender);
                 }
                 
-                LCONSOLE_ERROR("%s: BAD WRITE CHECKSUM: %s from %s%s%s inum "
-                               LPU64"/"LPU64" object "LPU64"/"LPU64
-                               " extent ["LPU64"-"LPU64"]\n",
-                               req->rq_export->exp_obd->obd_name, msg,
-                               libcfs_id2str(req->rq_peer),
-                               via, router,
-                               body->oa.o_valid & OBD_MD_FLFID ?
+                LCONSOLE_ERROR_MSG(0x168, "%s: BAD WRITE CHECKSUM: %s from "
+                                   "%s%s%s inum "LPU64"/"LPU64" object "
+                                   LPU64"/"LPU64" extent ["LPU64"-"LPU64"]\n",
+                                   req->rq_export->exp_obd->obd_name, msg,
+                                   libcfs_id2str(req->rq_peer),
+                                   via, router,
+                                   body->oa.o_valid & OBD_MD_FLFID ?
                                                 body->oa.o_fid : (__u64)0,
-                               body->oa.o_valid & OBD_MD_FLFID ?
+                                   body->oa.o_valid & OBD_MD_FLFID ?
                                                 body->oa.o_generation :(__u64)0,
-                               body->oa.o_id,
-                               body->oa.o_valid & OBD_MD_FLGROUP ?
+                                   body->oa.o_id,
+                                   body->oa.o_valid & OBD_MD_FLGROUP ?
                                                 body->oa.o_gr : (__u64)0,
-                               pp_rnb[0].offset,
-                               pp_rnb[npages-1].offset+pp_rnb[npages-1].len-1);
+                                   pp_rnb[0].offset,
+                                   pp_rnb[npages-1].offset+pp_rnb[npages-1].len
+                                   - 1 );
                 CERROR("client csum %x, original server csum %x, "
                        "server csum now %x\n",
                        client_cksum, server_cksum, new_cksum);
@@ -1106,13 +1153,13 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 LASSERT(j == npages);
         }
 
- out_lock:
+out_lock:
         ost_brw_lock_put(LCK_PW, ioo, pp_rnb, &lockh);
- out_bulk:
+out_bulk:
         ptlrpc_free_bulk(desc);
         if (no_reply)
                 RETURN(rc);
- out:
+out:
         if (rc == 0) {
                 oti_to_request(oti, req);
                 target_committed_to_req(req);
@@ -1231,7 +1278,7 @@ static int ost_handle_quotacheck(struct ptlrpc_request *req)
 
         oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
                                    lustre_swab_obd_quotactl);
-        if (oqctl == NULL) 
+        if (oqctl == NULL)
                 RETURN(-EPROTO);
 
         rc = lustre_pack_reply(req, 1, NULL, NULL);
@@ -1244,6 +1291,19 @@ static int ost_handle_quotacheck(struct ptlrpc_request *req)
         RETURN(0);
 }
 
+static int ost_llog_handle_connect(struct obd_export *exp,
+                                                   struct ptlrpc_request *req)
+{
+        struct llogd_conn_body *body;
+        int rc;
+        ENTRY;
+
+        body = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*body));
+        rc = obd_llog_connect(exp, body);
+        RETURN(rc);
+}
+
+
 static int ost_filter_recovery_request(struct ptlrpc_request *req,
                                        struct obd_device *obd, int *process)
 {
@@ -1267,10 +1327,8 @@ static int ost_filter_recovery_request(struct ptlrpc_request *req,
 
         default:
                 DEBUG_REQ(D_ERROR, req, "not permitted during recovery");
-                *process = 0;
-                /* XXX what should we set rq_status to here? */
-                req->rq_status = -EAGAIN;
-                RETURN(ptlrpc_error(req));
+                *process = -EAGAIN;
+                RETURN(0);
         }
 }
 
@@ -1282,6 +1340,9 @@ int ost_msg_check_version(struct lustre_msg *msg)
         case OST_CONNECT:
         case OST_DISCONNECT:
         case OBD_PING:
+        case SEC_CTX_INIT:
+        case SEC_CTX_INIT_CONT:
+        case SEC_CTX_FINI:
                 rc = lustre_msg_check_version(msg, LUSTRE_OBD_VERSION);
                 if (rc)
                         CERROR("bad opc %u version %08x, expecting %08x\n",
@@ -1337,7 +1398,7 @@ int ost_msg_check_version(struct lustre_msg *msg)
         return rc;
 }
 
-static int ost_handle(struct ptlrpc_request *req)
+int ost_handle(struct ptlrpc_request *req)
 {
         struct obd_trans_info trans_info = { 0, };
         struct obd_trans_info *oti = &trans_info;
@@ -1346,9 +1407,18 @@ static int ost_handle(struct ptlrpc_request *req)
         ENTRY;
 
         LASSERT(current->journal_info == NULL);
+
+        /* primordial rpcs don't affect server recovery */
+        switch (lustre_msg_get_opc(req->rq_reqmsg)) {
+        case SEC_CTX_INIT:
+        case SEC_CTX_INIT_CONT:
+        case SEC_CTX_FINI:
+                GOTO(out, rc = 0);
+        }
+
         /* XXX identical to MDS */
         if (lustre_msg_get_opc(req->rq_reqmsg) != OST_CONNECT) {
-                int abort_recovery, recovering;
+                int recovering;
 
                 if (req->rq_export == NULL) {
                         CDEBUG(D_HA,"operation %d on unconnected OST from %s\n",
@@ -1362,24 +1432,23 @@ static int ost_handle(struct ptlrpc_request *req)
 
                 /* Check for aborted recovery. */
                 spin_lock_bh(&obd->obd_processing_task_lock);
-                abort_recovery = obd->obd_abort_recovery;
                 recovering = obd->obd_recovering;
                 spin_unlock_bh(&obd->obd_processing_task_lock);
-                if (abort_recovery) {
-                        target_abort_recovery(obd);
-                } else if (recovering) {
+                if (recovering) {
                         rc = ost_filter_recovery_request(req, obd,
                                                          &should_process);
                         if (rc || !should_process)
                                 RETURN(rc);
+                        else if (should_process < 0) {
+                                req->rq_status = should_process;
+                                rc = ptlrpc_error(req);
+                                RETURN(rc);
+                        }
                 }
         }
 
         oti_init(oti, req);
-        rc = ost_msg_check_version(req->rq_reqmsg);
-        if (rc)
-                RETURN(rc);
-
+        
         rc = ost_msg_check_version(req->rq_reqmsg);
         if (rc)
                 RETURN(rc);
@@ -1388,7 +1457,7 @@ static int ost_handle(struct ptlrpc_request *req)
         case OST_CONNECT: {
                 CDEBUG(D_INODE, "connect\n");
                 OBD_FAIL_RETURN(OBD_FAIL_OST_CONNECT_NET, 0);
-                rc = target_handle_connect(req, ost_handle);
+                rc = target_handle_connect(req);
                 if (!rc)
                         obd = req->rq_export->exp_obd;
                 break;
@@ -1426,6 +1495,14 @@ static int ost_handle(struct ptlrpc_request *req)
                 break;
         case OST_WRITE:
                 CDEBUG(D_INODE, "write\n");
+                /* req->rq_request_portal would be nice, if it was set */
+                if (req->rq_rqbd->rqbd_service->srv_req_portal !=OST_IO_PORTAL){
+                        CERROR("%s: deny write request from %s to portal %u\n",
+                               req->rq_export->exp_obd->obd_name,
+                               obd_export_nid2str(req->rq_export),
+                               req->rq_rqbd->rqbd_service->srv_req_portal);
+                        GOTO(out, rc = -EPROTO);
+                }
                 OBD_FAIL_RETURN(OBD_FAIL_OST_BRW_NET, 0);
                 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_OST_ENOSPC))
                         GOTO(out, rc = -ENOSPC);
@@ -1437,6 +1514,14 @@ static int ost_handle(struct ptlrpc_request *req)
                 RETURN(rc);
         case OST_READ:
                 CDEBUG(D_INODE, "read\n");
+                /* req->rq_request_portal would be nice, if it was set */
+                if (req->rq_rqbd->rqbd_service->srv_req_portal !=OST_IO_PORTAL){
+                        CERROR("%s: deny read request from %s to portal %u\n",
+                               req->rq_export->exp_obd->obd_name,
+                               obd_export_nid2str(req->rq_export),
+                               req->rq_rqbd->rqbd_service->srv_req_portal);
+                        GOTO(out, rc = -EPROTO);
+                }
                 OBD_FAIL_RETURN(OBD_FAIL_OST_BRW_NET, 0);
                 rc = ost_brw_read(req, oti);
                 LASSERT(current->journal_info == NULL);
@@ -1483,8 +1568,8 @@ static int ost_handle(struct ptlrpc_request *req)
                 break;
         /* FIXME - just reply status */
         case LLOG_ORIGIN_CONNECT:
-                DEBUG_REQ(D_INODE, req, "log connect\n");
-                rc = llog_handle_connect(req);
+                DEBUG_REQ(D_INODE, req, "log connect");
+                rc = ost_llog_handle_connect(req->rq_export, req);
                 req->rq_status = rc;
                 rc = lustre_pack_reply(req, 1, NULL, NULL);
                 if (rc)
@@ -1538,22 +1623,13 @@ static int ost_handle(struct ptlrpc_request *req)
                 target_committed_to_req(req);
 
 out:
-        if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY) {
-                if (obd && obd->obd_recovering) {
-                        DEBUG_REQ(D_HA, req, "LAST_REPLAY, queuing reply");
-                        return target_queue_final_reply(req, rc);
-                }
-                /* Lost a race with recovery; let the error path DTRT. */
-                rc = req->rq_status = -ENOTCONN;
-        }
-
         if (!rc)
                 oti_to_request(oti, req);
 
         target_send_reply(req, rc, fail);
         return 0;
 }
-
+EXPORT_SYMBOL(ost_handle);
 /*
  * free per-thread pool created by ost_thread_init().
  */
@@ -1596,7 +1672,7 @@ static int ost_thread_init(struct ptlrpc_thread *thread)
 
         LASSERT(thread != NULL);
         LASSERT(thread->t_data == NULL);
-        LASSERT(thread->t_id <= OSS_THREADS_MAX);
+        LASSERTF(thread->t_id <= OSS_THREADS_MAX, "%u\n", thread->t_id);
 
         OBD_ALLOC_PTR(tls);
         if (tls != NULL) {
@@ -1618,8 +1694,10 @@ static int ost_thread_init(struct ptlrpc_thread *thread)
         RETURN(result);
 }
 
+#define OST_WATCHDOG_TIMEOUT (obd_timeout * 1000)
+
 /* Sigh - really, this is an OSS, the _server_, not the _target_ */
-static int ost_setup(struct obd_device *obd, obd_count len, void *buf)
+static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
 {
         struct ost_obd *ost = &obd->u.ost;
         struct lprocfs_static_vars lvars;
@@ -1664,11 +1742,13 @@ static int ost_setup(struct obd_device *obd, obd_count len, void *buf)
                 ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE,
                                 OST_MAXREPSIZE, OST_REQUEST_PORTAL,
                                 OSC_REPLY_PORTAL,
-                                obd_timeout * 1000, ost_handle, LUSTRE_OSS_NAME,
-                                obd->obd_proc_entry, ost_print_req,
-                                oss_min_threads, oss_max_threads, "ll_ost");
+                                OST_WATCHDOG_TIMEOUT, ost_handle,
+                                LUSTRE_OSS_NAME, obd->obd_proc_entry,
+                                ost_print_req, oss_min_threads,
+                                oss_max_threads, "ll_ost",
+                                LCT_DT_THREAD);
         if (ost->ost_service == NULL) {
-                CERROR("failed to start OST service\n");
+                CERROR("failed to start service\n");
                 GOTO(out_lprocfs, rc = -ENOMEM);
         }
 
@@ -1680,9 +1760,9 @@ static int ost_setup(struct obd_device *obd, obd_count len, void *buf)
                 ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE,
                                 OST_MAXREPSIZE, OST_CREATE_PORTAL,
                                 OSC_REPLY_PORTAL,
-                                obd_timeout * 1000, ost_handle, "ost_create",
-                                obd->obd_proc_entry, ost_print_req,
-                                1, 1, "ll_ost_creat");
+                                OST_WATCHDOG_TIMEOUT, ost_handle, "ost_create",
+                                obd->obd_proc_entry, ost_print_req, 1, 1,
+                                "ll_ost_creat", LCT_DT_THREAD);
         if (ost->ost_create_service == NULL) {
                 CERROR("failed to start OST create service\n");
                 GOTO(out_service, rc = -ENOMEM);
@@ -1696,9 +1776,10 @@ static int ost_setup(struct obd_device *obd, obd_count len, void *buf)
                 ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE,
                                 OST_MAXREPSIZE, OST_IO_PORTAL,
                                 OSC_REPLY_PORTAL,
-                                obd_timeout * 1000, ost_handle, "ost_io",
+                                OST_WATCHDOG_TIMEOUT, ost_handle, "ost_io",
                                 obd->obd_proc_entry, ost_print_req,
-                                oss_min_threads, oss_max_threads, "ll_ost_io");
+                                oss_min_threads, oss_max_threads,
+                                "ll_ost_io", LCT_DT_THREAD);
         if (ost->ost_io_service == NULL) {
                 CERROR("failed to start OST I/O service\n");
                 GOTO(out_create, rc = -ENOMEM);
@@ -1799,8 +1880,16 @@ static int __init ost_init(void)
         ENTRY;
 
         lprocfs_init_vars(ost, &lvars);
-        rc = class_register_type(&ost_obd_ops, lvars.module_vars,
-                                 LUSTRE_OSS_NAME);
+        rc = class_register_type(&ost_obd_ops, NULL, lvars.module_vars,
+                                 LUSTRE_OSS_NAME, NULL);
+
+        if (ost_num_threads != 0 && oss_num_threads == 0) {
+                LCONSOLE_INFO("ost_num_threads module parameter is deprecated, "
+                              "use oss_num_threads instead or unset both for "
+                              "dynamic thread startup\n");
+                oss_num_threads = ost_num_threads;
+        }
+
         RETURN(rc);
 }