Whamcloud - gitweb
LU-3751 ost: disable OUT_PORTAL request handler on OST.
[fs/lustre-release.git] / lustre / ost / ost_handler.c
index df2710d..405d69c 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #include <lustre_dlm.h>
 #include <lustre_export.h>
 #include <lustre_debug.h>
+#include <lustre_fid.h>
+#include <lustre_fld.h>
 #include <linux/init.h>
 #include <lprocfs_status.h>
 #include <libcfs/list.h>
+#include <lustre_quota.h>
+#include <lustre_fid.h>
 #include "ost_internal.h"
+#include <lustre_fid.h>
 
 static int oss_num_threads;
 CFS_MODULE_PARM(oss_num_threads, "i", int, 0444,
@@ -98,28 +103,72 @@ static void ost_drop_id(struct obd_export *exp, struct obdo *oa)
  * Validate oa from client.
  * If the request comes from 2.0 clients, currently only RSVD seq and IDIF
  * req are valid.
- *    a. for single MDS  seq = FID_SEQ_OST_MDT0,
- *    b. for CMD, seq = FID_SEQ_OST_MDT0, FID_SEQ_OST_MDT1 - FID_SEQ_OST_MAX
+ *    a. objects in Single MDT FS  seq = FID_SEQ_OST_MDT0, oi_id != 0
+ *    b. Echo objects(seq = 2), old echo client still use oi_id/oi_seq to
+ *       pack ost_id. Because non-zero oi_seq will make it diffcult to tell
+ *       whether this is oi_fid or real ostid. So it will check
+ *       OBD_CONNECT_FID, then convert the ostid to FID for old client.
+ *    c. Old FID-disable osc will send IDIF.
+ *    d. new FID-enable osc/osp will send normal FID.
+ *
+ * And also oi_id/f_oid should always start from 1. oi_id/f_oid = 0 will
+ * be used for LAST_ID file, and only being accessed inside OST now.
  */
 static int ost_validate_obdo(struct obd_export *exp, struct obdo *oa,
-                             struct obd_ioobj *ioobj)
+                            struct obd_ioobj *ioobj)
 {
-        if (oa != NULL && !(oa->o_valid & OBD_MD_FLGROUP)) {
-                oa->o_seq = FID_SEQ_OST_MDT0;
-                if (ioobj)
-                        ioobj->ioo_seq = FID_SEQ_OST_MDT0;
-        /* remove fid_seq_is_rsvd() after FID-on-OST allows SEQ > 9 */
-        } else if (oa == NULL || !(fid_seq_is_rsvd(oa->o_seq) ||
-                                   fid_seq_is_mdt0(oa->o_seq))) {
-                CERROR("%s: client %s sent invalid object "POSTID"\n",
-                       exp->exp_obd->obd_name, obd_export_nid2str(exp),
-                       oa ? oa->o_id : -1, oa ? oa->o_seq : -1);
-                return -EPROTO;
-        }
-        obdo_from_ostid(oa, &oa->o_oi);
-        if (ioobj)
-                ioobj_from_obdo(ioobj, oa);
-        return 0;
+       int rc = 0;
+
+       if (unlikely(!(exp_connect_flags(exp) & OBD_CONNECT_FID) &&
+                    fid_seq_is_echo(oa->o_oi.oi.oi_seq) && oa != NULL)) {
+               /* Sigh 2.[123] client still sends echo req with oi_id = 0
+                * during create, and we will reset this to 1, since this
+                * oi_id is basically useless in the following create process,
+                * but oi_id == 0 will make it difficult to tell whether it is
+                * real FID or ost_id. */
+               oa->o_oi.oi_fid.f_oid = oa->o_oi.oi.oi_id ?: 1;
+               oa->o_oi.oi_fid.f_seq = FID_SEQ_ECHO;
+               oa->o_oi.oi_fid.f_ver = 0;
+       } else {
+               if (unlikely((oa == NULL) || ostid_id(&oa->o_oi) == 0))
+                       GOTO(out, rc = -EPROTO);
+
+               /* Note: this check might be forced in 2.5 or 2.6, i.e.
+                * all of the requests are required to setup FLGROUP */
+               if (unlikely(!(oa->o_valid & OBD_MD_FLGROUP))) {
+                       ostid_set_seq_mdt0(&oa->o_oi);
+                       if (ioobj)
+                               ostid_set_seq_mdt0(&ioobj->ioo_oid);
+                       oa->o_valid |= OBD_MD_FLGROUP;
+               }
+
+               if (unlikely(!(fid_seq_is_idif(ostid_seq(&oa->o_oi)) ||
+                              fid_seq_is_mdt0(ostid_seq(&oa->o_oi)) ||
+                              fid_seq_is_norm(ostid_seq(&oa->o_oi)) ||
+                              fid_seq_is_echo(ostid_seq(&oa->o_oi)))))
+                       GOTO(out, rc = -EPROTO);
+       }
+
+       if (ioobj != NULL) {
+               unsigned max_brw = ioobj_max_brw_get(ioobj);
+
+               if (unlikely((max_brw & (max_brw - 1)) != 0)) {
+                       CERROR("%s: client %s sent bad ioobj max %u for "DOSTID
+                              ": rc = -EPROTO\n", exp->exp_obd->obd_name,
+                              obd_export_nid2str(exp), max_brw,
+                              POSTID(&oa->o_oi));
+                       GOTO(out, rc = -EPROTO);
+               }
+               ioobj->ioo_oid = oa->o_oi;
+       }
+
+out:
+       if (rc != 0)
+               CERROR("%s: client %s sent bad object "DOSTID": rc = %d\n",
+                      exp->exp_obd->obd_name, obd_export_nid2str(exp),
+                      oa ? ostid_seq(&oa->o_oi) : -1,
+                      oa ? ostid_id(&oa->o_oi) : -1, rc);
+       return rc;
 }
 
 void oti_to_request(struct obd_trans_info *oti, struct ptlrpc_request *req)
@@ -160,8 +209,8 @@ static int ost_destroy(struct obd_export *exp, struct ptlrpc_request *req,
         if (body == NULL)
                 RETURN(-EFAULT);
 
-        if (body->oa.o_id == 0)
-                RETURN(-EPROTO);
+       if (ostid_id(&body->oa.o_oi) == 0)
+               RETURN(-EPROTO);
 
         rc = ost_validate_obdo(exp, &body->oa, NULL);
         if (rc)
@@ -230,7 +279,7 @@ static int ost_lock_get(struct obd_export *exp, struct obdo *oa,
             !(oa->o_flags & OBD_FL_SRVLOCK))
                 RETURN(0);
 
-        osc_build_res_name(oa->o_id, oa->o_seq, &res_id);
+       ostid_build_res_name(&oa->o_oi, &res_id);
         CDEBUG(D_INODE, "OST-side extent lock.\n");
 
         policy.l_extent.start = start & CFS_PAGE_MASK;
@@ -397,7 +446,7 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
         /* standard truncate optimization: if file body is completely
          * destroyed, don't send data back to the server. */
         if (body->oa.o_size == 0)
-                flags |= LDLM_AST_DISCARD_DATA;
+               flags |= LDLM_FL_AST_DISCARD_DATA;
 
         repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
         repbody->oa = body->oa;
@@ -624,7 +673,7 @@ static int ost_brw_lock_get(int mode, struct obd_export *exp,
         int i;
         ENTRY;
 
-        osc_build_res_name(obj->ioo_id, obj->ioo_seq, &res_id);
+       ostid_build_res_name(&obj->ioo_oid, &res_id);
         LASSERT(mode == LCK_PR || mode == LCK_PW);
         LASSERT(!lustre_handle_is_used(lh));
 
@@ -776,20 +825,20 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         if (rc != 0)
                 GOTO(out_tls, rc);
 
-        /*
-         * If getting the lock took more time than
-         * client was willing to wait, drop it. b=11330
-         */
-        if (cfs_time_current_sec() > req->rq_deadline ||
-            OBD_FAIL_CHECK(OBD_FAIL_OST_DROP_REQ)) {
-                no_reply = 1;
-                CERROR("Dropping timed-out read from %s because locking"
-                       "object "LPX64" took %ld seconds (limit was %ld).\n",
-                       libcfs_id2str(req->rq_peer), ioo->ioo_id,
-                       cfs_time_current_sec() - req->rq_arrival_time.tv_sec,
-                       req->rq_deadline - req->rq_arrival_time.tv_sec);
-                GOTO(out_lock, rc = -ETIMEDOUT);
-        }
+       /*
+        * If getting the lock took more time than
+        * client was willing to wait, drop it. b=11330
+        */
+       if (cfs_time_current_sec() > req->rq_deadline ||
+           OBD_FAIL_CHECK(OBD_FAIL_OST_DROP_REQ)) {
+               no_reply = 1;
+               CERROR("Dropping timed-out read from %s because locking"
+                      "object "DOSTID" took %ld seconds (limit was %ld).\n",
+                      libcfs_id2str(req->rq_peer), POSTID(&ioo->ioo_oid),
+                      cfs_time_current_sec() - req->rq_arrival_time.tv_sec,
+                      req->rq_deadline - req->rq_arrival_time.tv_sec);
+               GOTO(out_lock, rc = -ETIMEDOUT);
+       }
 
         repbody = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
         memcpy(&repbody->oa, &body->oa, sizeof(repbody->oa));
@@ -801,10 +850,10 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         if (rc != 0)
                 GOTO(out_lock, rc);
 
-        desc = ptlrpc_prep_bulk_exp(req, npages,
-                                     BULK_PUT_SOURCE, OST_BULK_PORTAL);
-        if (desc == NULL)
-                GOTO(out_commitrw, rc = -ENOMEM);
+       desc = ptlrpc_prep_bulk_exp(req, npages, ioobj_max_brw_get(ioo),
+                                   BULK_PUT_SOURCE, OST_BULK_PORTAL);
+       if (desc == NULL)
+               GOTO(out_commitrw, rc = -ENOMEM);
 
         nob = 0;
         for (i = 0; i < npages; i++) {
@@ -936,7 +985,7 @@ static void ost_warn_on_cksum(struct ptlrpc_request *req,
        }
 
        LCONSOLE_ERROR_MSG(0x168, "BAD WRITE CHECKSUM: %s from %s%s%s inode "
-                          DFID" object "LPU64"/"LPU64" extent ["LPU64"-"LPU64
+                          DFID" object "DOSTID" extent ["LPU64"-"LPU64
                           "]: client csum %x, server csum %x\n",
                           exp->exp_obd->obd_name, libcfs_id2str(req->rq_peer),
                           via, router,
@@ -946,9 +995,7 @@ static void ost_warn_on_cksum(struct ptlrpc_request *req,
                           body->oa.o_parent_oid : 0,
                           body->oa.o_valid & OBD_MD_FLFID ?
                           body->oa.o_parent_ver : 0,
-                          body->oa.o_id,
-                          body->oa.o_valid & OBD_MD_FLGROUP ?
-                          body->oa.o_seq : (__u64)0,
+                          POSTID(&body->oa.o_oi),
                           local_nb[0].lnb_file_offset,
                           local_nb[npages-1].lnb_file_offset +
                           local_nb[npages-1].len - 1,
@@ -1017,7 +1064,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
 
         if ((remote_nb[0].flags & OBD_BRW_MEMALLOC) &&
             (exp->exp_connection->c_peer.nid == exp->exp_connection->c_self))
-                cfs_memory_pressure_set();
+               memory_pressure_set();
 
         if (body->oa.o_valid & OBD_MD_FLOSSCAPA) {
                 capa = req_capsule_client_get(&req->rq_pill, &RMF_CAPA1);
@@ -1044,20 +1091,20 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         if (rc != 0)
                 GOTO(out_tls, rc);
 
-        /*
-         * If getting the lock took more time than
-         * client was willing to wait, drop it. b=11330
-         */
-        if (cfs_time_current_sec() > req->rq_deadline ||
-            OBD_FAIL_CHECK(OBD_FAIL_OST_DROP_REQ)) {
-                no_reply = 1;
-                CERROR("Dropping timed-out write from %s because locking "
-                       "object "LPX64" took %ld seconds (limit was %ld).\n",
-                       libcfs_id2str(req->rq_peer), ioo->ioo_id,
-                       cfs_time_current_sec() - req->rq_arrival_time.tv_sec,
-                       req->rq_deadline - req->rq_arrival_time.tv_sec);
-                GOTO(out_lock, rc = -ETIMEDOUT);
-        }
+       /*
+        * If getting the lock took more time than
+        * client was willing to wait, drop it. b=11330
+        */
+       if (cfs_time_current_sec() > req->rq_deadline ||
+           OBD_FAIL_CHECK(OBD_FAIL_OST_DROP_REQ)) {
+               no_reply = 1;
+               CERROR("Dropping timed-out write from %s because locking "
+                      "object "DOSTID" took %ld seconds (limit was %ld).\n",
+                      libcfs_id2str(req->rq_peer), POSTID(&ioo->ioo_oid),
+                      cfs_time_current_sec() - req->rq_arrival_time.tv_sec,
+                      req->rq_deadline - req->rq_arrival_time.tv_sec);
+               GOTO(out_lock, rc = -ETIMEDOUT);
+       }
 
         /* obd_preprw clobbers oa->valid, so save what we need */
         if (body->oa.o_valid & OBD_MD_FLCKSUM) {
@@ -1091,14 +1138,13 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         if (rc != 0)
                 GOTO(out_lock, rc);
 
-        desc = ptlrpc_prep_bulk_exp(req, npages,
-                                     BULK_GET_SINK, OST_BULK_PORTAL);
-        if (desc == NULL)
-                GOTO(skip_transfer, rc = -ENOMEM);
-
-        /* NB Having prepped, we must commit... */
+       desc = ptlrpc_prep_bulk_exp(req, npages, ioobj_max_brw_get(ioo),
+                                   BULK_GET_SINK, OST_BULK_PORTAL);
+       if (desc == NULL)
+               GOTO(skip_transfer, rc = -ENOMEM);
 
-        for (i = 0; i < npages; i++)
+       /* NB Having prepped, we must commit... */
+       for (i = 0; i < npages; i++)
                ptlrpc_prep_bulk_page_nopin(desc, local_nb[i].page,
                                            local_nb[i].lnb_page_offset,
                                            local_nb[i].len);
@@ -1201,7 +1247,7 @@ out:
                               obd_uuid2str(&exp->exp_client_uuid),
                               obd_export_nid2str(exp), rc);
         }
-        cfs_memory_pressure_clr();
+       memory_pressure_clr();
         RETURN(rc);
 }
 
@@ -1284,11 +1330,89 @@ out:
         RETURN(rc);
 }
 
+struct locked_region {
+       cfs_list_t  list;
+       struct lustre_handle lh;
+};
+
+static int lock_region(struct obd_export *exp, struct obdo *oa,
+                      unsigned long long begin, unsigned long long end,
+                      cfs_list_t *locked)
+{
+       struct locked_region *region = NULL;
+       int rc;
+
+       LASSERT(begin <= end);
+       OBD_ALLOC_PTR(region);
+       if (region == NULL)
+               return -ENOMEM;
+
+       rc = ost_lock_get(exp, oa, begin, end - begin, &region->lh, LCK_PR, 0);
+       if (rc) {
+               OBD_FREE_PTR(region);
+               return rc;
+       }
+
+       CDEBUG(D_OTHER, "ost lock [%llu,%llu], lh=%p\n",
+              begin, end, &region->lh);
+       cfs_list_add(&region->list, locked);
+
+       return 0;
+}
+
+static int lock_zero_regions(struct obd_export *exp, struct obdo *oa,
+                            struct ll_user_fiemap *fiemap,
+                            cfs_list_t *locked)
+{
+       __u64 begin = fiemap->fm_start;
+       unsigned int i;
+       int rc = 0;
+       struct ll_fiemap_extent *fiemap_start = fiemap->fm_extents;
+       ENTRY;
+
+       CDEBUG(D_OTHER, "extents count %u\n", fiemap->fm_mapped_extents);
+       for (i = 0; i < fiemap->fm_mapped_extents; i++) {
+               if (fiemap_start[i].fe_logical > begin) {
+                       CDEBUG(D_OTHER, "ost lock [%llu,%llu]\n",
+                              begin, fiemap_start[i].fe_logical);
+                       rc = lock_region(exp, oa, begin,
+                                   fiemap_start[i].fe_logical, locked);
+                       if (rc)
+                               RETURN(rc);
+               }
+
+               begin = fiemap_start[i].fe_logical + fiemap_start[i].fe_length;
+       }
+
+       if (begin < (fiemap->fm_start + fiemap->fm_length)) {
+               CDEBUG(D_OTHER, "ost lock [%llu,%llu]\n",
+                      begin, fiemap->fm_start + fiemap->fm_length);
+               rc = lock_region(exp, oa, begin,
+                                fiemap->fm_start + fiemap->fm_length, locked);
+       }
+
+       RETURN(rc);
+}
+
+static void unlock_zero_regions(struct obd_export *exp, cfs_list_t *locked)
+{
+       struct locked_region *entry, *temp;
+       cfs_list_for_each_entry_safe(entry, temp, locked, list) {
+               CDEBUG(D_OTHER, "ost unlock lh=%p\n", &entry->lh);
+               ost_lock_put(exp, &entry->lh, LCK_PR);
+               cfs_list_del(&entry->list);
+               OBD_FREE_PTR(entry);
+       }
+}
+
 static int ost_get_info(struct obd_export *exp, struct ptlrpc_request *req)
 {
         void *key, *reply;
         int keylen, replylen, rc = 0;
         struct req_capsule *pill = &req->rq_pill;
+       cfs_list_t locked = CFS_LIST_HEAD_INIT(locked);
+       struct ll_fiemap_info_key *fm_key = NULL;
+       struct ll_user_fiemap *fiemap;
         ENTRY;
 
         /* this common part for get_info rpc */
@@ -1300,35 +1424,67 @@ static int ost_get_info(struct obd_export *exp, struct ptlrpc_request *req)
         keylen = req_capsule_get_size(pill, &RMF_SETINFO_KEY, RCL_CLIENT);
 
         if (KEY_IS(KEY_FIEMAP)) {
-                struct ll_fiemap_info_key *fm_key = key;
-                int rc;
-
+               fm_key = key;
                 rc = ost_validate_obdo(exp, &fm_key->oa, NULL);
                 if (rc)
                         RETURN(rc);
-        }
+       }
 
         rc = obd_get_info(req->rq_svc_thread->t_env, exp, keylen, key,
                           &replylen, NULL, NULL);
         if (rc)
-                RETURN(rc);
+               RETURN(rc);
 
         req_capsule_set_size(pill, &RMF_GENERIC_DATA,
                              RCL_SERVER, replylen);
 
         rc = req_capsule_server_pack(pill);
         if (rc)
-                RETURN(rc);
+               RETURN(rc);
 
         reply = req_capsule_server_get(pill, &RMF_GENERIC_DATA);
         if (reply == NULL)
-                RETURN(-ENOMEM);
+               RETURN(-ENOMEM);
+
+       if (KEY_IS(KEY_LAST_FID)) {
+               void *val;
+               int vallen;
+
+               req_capsule_extend(pill, &RQF_OST_GET_INFO_LAST_FID);
+               val = req_capsule_client_get(pill, &RMF_SETINFO_VAL);
+               vallen = req_capsule_get_size(pill, &RMF_SETINFO_VAL,
+                                             RCL_CLIENT);
+               if (val != NULL && vallen > 0 && replylen >= vallen) {
+                       memcpy(reply, val, vallen);
+               } else {
+                       CERROR("%s: invalid req val %p vallen %d replylen %d\n",
+                              exp->exp_obd->obd_name, val, vallen, replylen);
+                       RETURN(-EINVAL);
+               }
+       }
 
-        /* call again to fill in the reply buffer */
-        rc = obd_get_info(req->rq_svc_thread->t_env, exp, keylen, key,
-                          &replylen, reply, NULL);
+       /* call again to fill in the reply buffer */
+       rc = obd_get_info(req->rq_svc_thread->t_env, exp, keylen, key,
+                         &replylen, reply, NULL);
+
+       /* LU-3219: Lock the sparse areas to make sure dirty flushed back
+        * from client, then call fiemap again. */
+       if (KEY_IS(KEY_FIEMAP) && (fm_key->oa.o_valid & OBD_MD_FLFLAGS) &&
+           (fm_key->oa.o_flags & OBD_FL_SRVLOCK)) {
+               fiemap = (struct ll_user_fiemap *)reply;
+               fm_key = key;
+
+               rc = lock_zero_regions(exp, &fm_key->oa, fiemap, &locked);
+               if (rc == 0 && !cfs_list_empty(&locked))
+                       rc = obd_get_info(req->rq_svc_thread->t_env, exp,
+                                         keylen, key, &replylen, reply, NULL);
+               unlock_zero_regions(exp, &locked);
+               if (rc)
+                       RETURN(rc);
+       }
+
+       lustre_msg_set_status(req->rq_repmsg, 0);
 
-        lustre_msg_set_status(req->rq_repmsg, 0);
         RETURN(rc);
 }
 
@@ -1391,7 +1547,7 @@ do {                                                                      \
                                      OBD_CONNECT_RMT_CLIENT_FORCE |    \
                                      OBD_CONNECT_OSS_CAPA);            \
        spin_lock(&exp->exp_lock);                                      \
-       exp->exp_connect_flags = reply->ocd_connect_flags;              \
+       *exp_connect_flags_ptr(exp) = reply->ocd_connect_flags;         \
        spin_unlock(&exp->exp_lock);                                    \
 } while (0)
 
@@ -1490,7 +1646,7 @@ static int ost_init_sec_level(struct ptlrpc_request *req)
                                 reply->ocd_connect_flags &= ~OBD_CONNECT_OSS_CAPA;
 
                        spin_lock(&exp->exp_lock);
-                       exp->exp_connect_flags = reply->ocd_connect_flags;
+                       *exp_connect_flags_ptr(exp) = reply->ocd_connect_flags;
                        spin_unlock(&exp->exp_lock);
                 }
                 break;
@@ -1595,8 +1751,8 @@ int ost_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                        OBD_FREE_PTR(oinfo);
                        GOTO(out_env, rc = -ENOMEM);
                }
-               oa->o_id = lock->l_resource->lr_name.name[0];
-               oa->o_seq = lock->l_resource->lr_name.name[1];
+
+               ostid_res_name_to_id(&oa->o_oi, &lock->l_resource->lr_name);
                oa->o_valid = OBD_MD_FLID|OBD_MD_FLGROUP;
                oinfo->oi_oa = oa;
                oinfo->oi_capa = BYPASS_CAPA;
@@ -1745,7 +1901,7 @@ static void ost_prolong_lock_one(struct ost_prolong_data *opd,
 {
        LASSERT(lock->l_export == opd->opd_exp);
 
-       if (lock->l_destroyed) /* lock already cancelled */
+       if (lock->l_flags & LDLM_FL_DESTROYED) /* lock already cancelled */
                return;
 
         /* XXX: never try to grab resource lock here because we're inside
@@ -1839,10 +1995,9 @@ static int ost_rw_hpreq_lock_match(struct ptlrpc_request *req,
         nb += ioo->ioo_bufcnt - 1;
         ext.end = nb->offset + nb->len - 1;
 
-        LASSERT(lock->l_resource != NULL);
-        if (!osc_res_name_eq(ioo->ioo_id, ioo->ioo_seq,
-                             &lock->l_resource->lr_name))
-                RETURN(0);
+       LASSERT(lock->l_resource != NULL);
+       if (!ostid_res_name_eq(&ioo->ioo_oid, &lock->l_resource->lr_name))
+               RETURN(0);
 
         mode = LCK_PW;
         if (opc == OST_READ)
@@ -1890,7 +2045,7 @@ static int ost_rw_hpreq_check(struct ptlrpc_request *req)
         LASSERT(nb != NULL);
         LASSERT(!(nb->flags & OBD_BRW_SRVLOCK));
 
-        osc_build_res_name(ioo->ioo_id, ioo->ioo_seq, &opd.opd_resid);
+       ostid_build_res_name(&ioo->ioo_oid, &opd.opd_resid);
 
         opd.opd_req = req;
         mode = LCK_PW;
@@ -1915,7 +2070,7 @@ static int ost_rw_hpreq_check(struct ptlrpc_request *req)
         CDEBUG(D_DLMTRACE, "%s: refreshed %u locks timeout for req %p.\n",
                obd->obd_name, opd.opd_locks, req);
 
-        RETURN(opd.opd_locks);
+        RETURN(opd.opd_locks > 0);
 }
 
 static void ost_rw_hpreq_fini(struct ptlrpc_request *req)
@@ -1974,7 +2129,7 @@ static int ost_punch_hpreq_check(struct ptlrpc_request *req)
                 opd.opd_extent.end = OBD_OBJECT_EOF;
         opd.opd_timeout = prolong_timeout(req);
 
-        osc_build_res_name(oa->o_id, oa->o_seq, &opd.opd_resid);
+       ostid_build_res_name(&oa->o_oi, &opd.opd_resid);
 
         CDEBUG(D_DLMTRACE,
                "%s: refresh locks: "LPU64"/"LPU64" ("LPU64"->"LPU64")\n",
@@ -2114,35 +2269,35 @@ static int ost_io_hpreq_handler(struct ptlrpc_request *req)
 /* TODO: handle requests in a similar way as MDT: see mdt_handle_common() */
 int ost_handle(struct ptlrpc_request *req)
 {
-        struct obd_trans_info trans_info = { 0, };
-        struct obd_trans_info *oti = &trans_info;
-        int should_process, fail = OBD_FAIL_OST_ALL_REPLY_NET, rc = 0;
-        struct obd_device *obd = NULL;
-        ENTRY;
+       struct obd_trans_info trans_info = { 0, };
+       struct obd_trans_info *oti = &trans_info;
+       int should_process, fail = OBD_FAIL_OST_ALL_REPLY_NET, rc = 0;
+       struct obd_device *obd = NULL;
+       __u32 opc = lustre_msg_get_opc(req->rq_reqmsg);
+       ENTRY;
 
-        /* OST module is kept between remounts, but the last reference
-         * to specific module (say, osd or ofd) kills all related keys
-         * from the environment. so we have to refill it until the root
-         * cause is fixed properly */
-        lu_env_refill(req->rq_svc_thread->t_env);
+       /* OST module is kept between remounts, but the last reference
+        * to specific module (say, osd or ofd) kills all related keys
+        * from the environment. so we have to refill it until the root
+        * cause is fixed properly */
+       lu_env_refill(req->rq_svc_thread->t_env);
 
-        LASSERT(current->journal_info == NULL);
+       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);
-        }
+       /* primordial rpcs don't affect server recovery */
+       switch (opc) {
+       case SEC_CTX_INIT:
+       case SEC_CTX_INIT_CONT:
+       case SEC_CTX_FINI:
+               GOTO(out, rc = 0);
+       }
 
-        req_capsule_init(&req->rq_pill, req, RCL_SERVER);
+       req_capsule_init(&req->rq_pill, req, RCL_SERVER);
 
-        if (lustre_msg_get_opc(req->rq_reqmsg) != OST_CONNECT) {
-                if (!class_connected_export(req->rq_export)) {
-                        CDEBUG(D_HA,"operation %d on unconnected OST from %s\n",
-                               lustre_msg_get_opc(req->rq_reqmsg),
-                               libcfs_id2str(req->rq_peer));
+       if (opc != OST_CONNECT) {
+               if (!class_connected_export(req->rq_export)) {
+                       CDEBUG(D_HA,"operation %d on unconnected OST from %s\n",
+                              opc, libcfs_id2str(req->rq_peer));
                         req->rq_status = -ENOTCONN;
                         GOTO(out, rc = -ENOTCONN);
                 }
@@ -2170,10 +2325,10 @@ int ost_handle(struct ptlrpc_request *req)
                 RETURN(rc);
 
        if (req && req->rq_reqmsg && req->rq_export &&
-           (req->rq_export->exp_connect_flags & OBD_CONNECT_JOBSTATS))
+           (exp_connect_flags(req->rq_export) & OBD_CONNECT_JOBSTATS))
                oti->oti_jobid = lustre_msg_get_jobid(req->rq_reqmsg);
 
-        switch (lustre_msg_get_opc(req->rq_reqmsg)) {
+       switch (opc) {
         case OST_CONNECT: {
                 CDEBUG(D_INODE, "connect\n");
                 req_capsule_set(&req->rq_pill, &RQF_OST_CONNECT);
@@ -2328,19 +2483,6 @@ int ost_handle(struct ptlrpc_request *req)
                 if (rc)
                         RETURN(rc);
                 RETURN(ptlrpc_reply(req));
-        case OBD_LOG_CANCEL:
-                CDEBUG(D_INODE, "log cancel\n");
-                req_capsule_set(&req->rq_pill, &RQF_LOG_CANCEL);
-                if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOG_CANCEL_NET))
-                        RETURN(0);
-                rc = llog_origin_handle_cancel(req);
-                if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOG_CANCEL_REP))
-                        RETURN(0);
-                req->rq_status = rc;
-                rc = req_capsule_server_pack(&req->rq_pill);
-                if (rc)
-                        RETURN(rc);
-                RETURN(ptlrpc_reply(req));
        case LDLM_ENQUEUE:
                CDEBUG(D_INODE, "enqueue\n");
                req_capsule_set(&req->rq_pill, &RQF_LDLM_ENQUEUE);
@@ -2371,8 +2513,7 @@ int ost_handle(struct ptlrpc_request *req)
                 CERROR("callbacks should not happen on OST\n");
                 /* fall through */
         default:
-                CERROR("Unexpected opcode %d\n",
-                       lustre_msg_get_opc(req->rq_reqmsg));
+               CERROR("Unexpected opcode %d\n", opc);
                 req->rq_status = -ENOTSUPP;
                 rc = ptlrpc_error(req);
                 RETURN(rc);
@@ -2382,7 +2523,7 @@ int ost_handle(struct ptlrpc_request *req)
 
         EXIT;
         /* If we're DISCONNECTing, the export_data is already freed */
-        if (!rc && lustre_msg_get_opc(req->rq_reqmsg) != OST_DISCONNECT)
+       if (!rc && opc != OST_DISCONNECT)
                 target_committed_to_req(req);
 
 out:
@@ -2567,9 +2708,9 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
                .psc_watchdog_factor    = OSS_SERVICE_WATCHDOG_FACTOR,
                .psc_buf                = {
                        .bc_nbufs               = OST_NBUFS,
-                       .bc_buf_size            = OST_BUFSIZE,
-                       .bc_req_max_size        = OST_MAXREQSIZE,
-                       .bc_rep_max_size        = OST_MAXREPSIZE,
+                       .bc_buf_size            = OST_IO_BUFSIZE,
+                       .bc_req_max_size        = OST_IO_MAXREQSIZE,
+                       .bc_rep_max_size        = OST_IO_MAXREPSIZE,
                        .bc_req_portal          = OST_IO_PORTAL,
                        .bc_rep_portal          = OSC_REPLY_PORTAL,
                },
@@ -2605,10 +2746,99 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
                GOTO(out_create, rc);
         }
 
-        ping_evictor_start();
+       memset(&svc_conf, 0, sizeof(svc_conf));
+       svc_conf = (typeof(svc_conf)) {
+               .psc_name               = "ost_seq",
+               .psc_watchdog_factor    = OSS_SERVICE_WATCHDOG_FACTOR,
+               .psc_buf                = {
+                       .bc_nbufs               = OST_NBUFS,
+                       .bc_buf_size            = OST_BUFSIZE,
+                       .bc_req_max_size        = OST_MAXREQSIZE,
+                       .bc_rep_max_size        = OST_MAXREPSIZE,
+                       .bc_req_portal          = SEQ_DATA_PORTAL,
+                       .bc_rep_portal          = OSC_REPLY_PORTAL,
+               },
+               .psc_thr                = {
+                       .tc_thr_name            = "ll_ost_seq",
+                       .tc_thr_factor          = OSS_CR_THR_FACTOR,
+                       .tc_nthrs_init          = OSS_CR_NTHRS_INIT,
+                       .tc_nthrs_base          = OSS_CR_NTHRS_BASE,
+                       .tc_nthrs_max           = OSS_CR_NTHRS_MAX,
+                       .tc_nthrs_user          = oss_num_create_threads,
+                       .tc_cpu_affinity        = 1,
+                       .tc_ctx_tags            = LCT_DT_THREAD,
+               },
 
-        RETURN(0);
+               .psc_cpt                = {
+                       .cc_pattern          = oss_cpts,
+               },
+               .psc_ops                = {
+                       .so_req_handler         = tgt_request_handle,
+                       .so_req_printer         = target_print_req,
+                       .so_hpreq_handler       = NULL,
+               },
+       };
+       ost->ost_seq_service = ptlrpc_register_service(&svc_conf,
+                                                     obd->obd_proc_entry);
+       if (IS_ERR(ost->ost_seq_service)) {
+               rc = PTR_ERR(ost->ost_seq_service);
+               CERROR("failed to start OST seq service: %d\n", rc);
+               ost->ost_seq_service = NULL;
+               GOTO(out_io, rc);
+       }
+
+#if 0
+       /* Object update service */
+       memset(&svc_conf, 0, sizeof(svc_conf));
+       svc_conf = (typeof(svc_conf)) {
+               .psc_name               = "ost_out",
+               .psc_watchdog_factor    = OSS_SERVICE_WATCHDOG_FACTOR,
+               .psc_buf                = {
+                       .bc_nbufs               = OST_NBUFS,
+                       .bc_buf_size            = OUT_BUFSIZE,
+                       .bc_req_max_size        = OUT_MAXREQSIZE,
+                       .bc_rep_max_size        = OUT_MAXREPSIZE,
+                       .bc_req_portal          = OUT_PORTAL,
+                       .bc_rep_portal          = OSC_REPLY_PORTAL,
+               },
+               /*
+                * We'd like to have a mechanism to set this on a per-device
+                * basis, but alas...
+                */
+               .psc_thr                = {
+                       .tc_thr_name            = "ll_ost_out",
+                       .tc_thr_factor          = OSS_CR_THR_FACTOR,
+                       .tc_nthrs_init          = OSS_CR_NTHRS_INIT,
+                       .tc_nthrs_base          = OSS_CR_NTHRS_BASE,
+                       .tc_nthrs_max           = OSS_CR_NTHRS_MAX,
+                       .tc_nthrs_user          = oss_num_create_threads,
+                       .tc_cpu_affinity        = 1,
+                       .tc_ctx_tags            = LCT_DT_THREAD,
+               },
+               .psc_cpt                = {
+                       .cc_pattern             = oss_cpts,
+               },
+               .psc_ops                = {
+                       .so_req_handler         = tgt_request_handle,
+                       .so_req_printer         = target_print_req,
+                       .so_hpreq_handler       = NULL,
+               },
+       };
+       ost->ost_out_service = ptlrpc_register_service(&svc_conf,
+                                                      obd->obd_proc_entry);
+       if (IS_ERR(ost->ost_out_service)) {
+               rc = PTR_ERR(ost->ost_out_service);
+               CERROR("failed to start out service: %d\n", rc);
+               ost->ost_out_service = NULL;
+               GOTO(out_seq, rc);
+       }
+#endif
+       ping_evictor_start();
 
+       RETURN(0);
+out_io:
+       ptlrpc_unregister_service(ost->ost_io_service);
+       ost->ost_io_service = NULL;
 out_create:
         ptlrpc_unregister_service(ost->ost_create_service);
         ost->ost_create_service = NULL;
@@ -2622,22 +2852,28 @@ out_lprocfs:
 
 static int ost_cleanup(struct obd_device *obd)
 {
-        struct ost_obd *ost = &obd->u.ost;
-        int err = 0;
-        ENTRY;
+       struct ost_obd *ost = &obd->u.ost;
+       int err = 0;
+       ENTRY;
 
-        ping_evictor_stop();
+       ping_evictor_stop();
 
-        /* there is no recovery for OST OBD, all recovery is controlled by
-         * obdfilter OBD */
-        LASSERT(obd->obd_recovering == 0);
+       /* there is no recovery for OST OBD, all recovery is controlled by
+        * obdfilter OBD */
+       LASSERT(obd->obd_recovering == 0);
        mutex_lock(&ost->ost_health_mutex);
-        ptlrpc_unregister_service(ost->ost_service);
-        ptlrpc_unregister_service(ost->ost_create_service);
-        ptlrpc_unregister_service(ost->ost_io_service);
-        ost->ost_service = NULL;
-        ost->ost_create_service = NULL;
+       ptlrpc_unregister_service(ost->ost_service);
+       ptlrpc_unregister_service(ost->ost_create_service);
+       ptlrpc_unregister_service(ost->ost_io_service);
+       ptlrpc_unregister_service(ost->ost_seq_service);
+#if 0
+       ptlrpc_unregister_service(ost->ost_out_service);
+#endif
+       ost->ost_service = NULL;
+       ost->ost_create_service = NULL;
        ost->ost_io_service = NULL;
+       ost->ost_seq_service = NULL;
+       ost->ost_out_service = NULL;
 
        mutex_unlock(&ost->ost_health_mutex);
 
@@ -2692,7 +2928,7 @@ static int __init ost_init(void)
         int rc;
         ENTRY;
 
-       ost_page_to_corrupt = cfs_alloc_page(CFS_ALLOC_STD);
+       ost_page_to_corrupt = alloc_page(GFP_IOFS);
 
         lprocfs_ost_init_vars(&lvars);
         rc = class_register_type(&ost_obd_ops, NULL, lvars.module_vars,