diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index 7201156ccf088947436f7973672a870aae4d7029..acc00b64e01ff6cdd4da5c04e4c16ea4c2fc9af1 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -24,6 +24,14 @@ tbd Sun Microsystems, Inc.
 	  	'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV'.
 	  For more information, please refer to bugzilla 13904.
 
+Severity   : normal
+Frequency  : always, on ppc.
+Bugzilla   : 14856
+Description: cleanup in ptlrpc code, related to ppc platform
+Details    : store magic in native order avoid panic's in recovery on ppc node
+             and forbid from this error in future. Also fix posibily of twice swab
+             data. Fix get lov striping to userpace.
+
 Severity   : normal
 Bugzilla   : 15756
 Frequency  : rare, replay get lost on server
diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h
index 8d4d57b2bbefcb9895400ed76d3310d8550768ac..255aa43721318588379f2eafd01db048e47d6ade 100644
--- a/lustre/include/lustre/lustre_idl.h
+++ b/lustre/include/lustre/lustre_idl.h
@@ -33,8 +33,7 @@
  *
  * We assume all nodes are either little-endian or big-endian, and we
  * always send messages in the sender's native format.  The receiver
- * detects the message format by checking the 'magic' field of the message
- * (see lustre_msg_swabbed() below).
+ * detects the message format by checking the 'magic' field of the message.
  *
  * Each wire type has corresponding 'lustre_swab_xxxtypexxx()' routines,
  * implemented either here, inline (trivial implementations) or in
@@ -241,6 +240,9 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define DLM_LOCKREPLY_OFF               1 /* lockrep offset */
 #define DLM_REPLY_REC_OFF               2 /* reply record offset */
 
+/* only use in req->rq_{req,rep}_swab_mask */
+#define MSG_PTLRPC_HEADER_OFF           31
+
 /* Flags that are operation-specific go in the top 16 bits. */
 #define MSG_OP_FLAG_MASK   0xffff0000
 #define MSG_OP_FLAG_SHIFT  16
diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h
index a1865c31145f84555cbf565dfc999cf145b9b35d..70a0733b3c52f4132d15c9ce67a34dddf804360f 100644
--- a/lustre/include/lustre_dlm.h
+++ b/lustre/include/lustre_dlm.h
@@ -265,7 +265,7 @@ typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **,
 
 struct ldlm_valblock_ops {
         int (*lvbo_init)(struct ldlm_resource *res);
-        int (*lvbo_update)(struct ldlm_resource *res, struct lustre_msg *m,
+        int (*lvbo_update)(struct ldlm_resource *res, struct ptlrpc_request *r,
                            int buf_idx, int increase);
 };
 
@@ -631,12 +631,12 @@ static inline struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *h)
 }
 
 static inline int ldlm_res_lvbo_update(struct ldlm_resource *res,
-                                       struct lustre_msg *m, int buf_idx,
+                                       struct ptlrpc_request *r, int buf_idx,
                                        int increase)
 {
         if (res->lr_namespace->ns_lvbo &&
             res->lr_namespace->ns_lvbo->lvbo_update) {
-                return res->lr_namespace->ns_lvbo->lvbo_update(res, m, buf_idx,
+                return res->lr_namespace->ns_lvbo->lvbo_update(res, r, buf_idx,
                                                                increase);
         }
         return 0;
diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h
index 515cd9e71bc4c1b670b75e3dfb77b4e61227fa01..7e57a14173c86f08b9a891dd20b37f27d2f2e422 100644
--- a/lustre/include/lustre_net.h
+++ b/lustre/include/lustre_net.h
@@ -373,7 +373,7 @@ static inline void lustre_set_rep_swabbed(struct ptlrpc_request *req, int index)
 }
 
 static inline int lustre_req_swabbed(struct ptlrpc_request *req, int index)
-{ 
+{
         LASSERT(index < sizeof(req->rq_req_swab_mask) * 8);
         return req->rq_req_swab_mask & (1 << index);
 }
@@ -384,6 +384,17 @@ static inline int lustre_rep_swabbed(struct ptlrpc_request *req, int index)
         return req->rq_rep_swab_mask & (1 << index);
 }
 
+static inline int lustre_req_need_swab(struct ptlrpc_request *req)
+{
+        return req->rq_req_swab_mask & (1 << MSG_PTLRPC_HEADER_OFF);
+}
+
+static inline int lustre_rep_need_swab(struct ptlrpc_request *req)
+{
+        return req->rq_rep_swab_mask & (1 << MSG_PTLRPC_HEADER_OFF);
+}
+
+
 static inline const char *
 ptlrpc_rqphase2str(struct ptlrpc_request *req)
 {
@@ -781,7 +792,6 @@ int lustre_msg_buflen(struct lustre_msg *m, int n);
 void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len);
 int lustre_msg_bufcount(struct lustre_msg *m);
 char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
-void *lustre_swab_buf(struct lustre_msg *, int n, int minlen, void *swabber);
 void *lustre_swab_reqbuf(struct ptlrpc_request *req, int n, int minlen,
                          void *swabber);
 void *lustre_swab_repbuf(struct ptlrpc_request *req, int n, int minlen,
diff --git a/lustre/include/obd.h b/lustre/include/obd.h
index cb6f45e2ef94d14ddfb408aa94418056b8e9ef0b..fd2c0601918671f05162fc56f3151dc72dbc2451 100644
--- a/lustre/include/obd.h
+++ b/lustre/include/obd.h
@@ -1106,7 +1106,7 @@ static inline struct lsm_operations *lsm_op_find(int magic)
         case LOV_MAGIC_JOIN:
                return &lsm_join_ops;
         default:
-               CERROR("Cannot recognize lsm_magic %d", magic);
+               CERROR("Cannot recognize lsm_magic %x\n", magic);
                return NULL;
         }
 }
diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c
index 93d140b44a381f74a79e4a59fb0aea26885ba4d3..1caf259ee71380237f38e113c4ed56365455e6c5 100644
--- a/lustre/ldlm/ldlm_lockd.c
+++ b/lustre/ldlm/ldlm_lockd.c
@@ -799,7 +799,7 @@ int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data)
         else if (rc != 0)
                 rc = ldlm_handle_ast_error(lock, req, rc, "glimpse");
         else
-                rc = ldlm_res_lvbo_update(res, req->rq_repmsg,
+                rc = ldlm_res_lvbo_update(res, req,
                                           REPLY_REC_OFF, 1);
         ptlrpc_req_finished(req);
         if (rc == -ERESTART)
diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c
index fef5f0f4e012d3010fb3e2d8f64b23bbe8977ef4..31e59dac00188ff5a9fabd63d8530615da5c4439 100644
--- a/lustre/llite/dir.c
+++ b/lustre/llite/dir.c
@@ -574,9 +574,9 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp,
          * little endian.  We convert it to host endian before
          * passing it to userspace.
          */
-        if (lmm->lmm_magic == __swab32(LOV_MAGIC)) {
+        if ((LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) &&
+            (cpu_to_le32(LOV_MAGIC) == lmm->lmm_magic))
                 lustre_swab_lov_user_md((struct lov_user_md *)lmm);
-        }
 out:
         *lmmp = lmm;
         *lmm_size = lmmsize;
@@ -776,6 +776,15 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 if (rc)
                         GOTO(free_lmm, rc = -EFAULT);
 
+                if (lmm->lmm_magic != LOV_USER_MAGIC)
+                        GOTO(free_lmm, rc = -EINVAL);
+
+                if (LOV_USER_MAGIC != cpu_to_le32(LOV_USER_MAGIC) &&
+                    cpu_to_le32(LOV_USER_MAGIC) == cpu_to_le32(lmm->lmm_magic)) {
+                        lustre_swab_lov_user_md_objects((struct lov_user_md *)lmm);
+                        lustre_swab_lov_user_md((struct lov_user_md *)lmm);
+                }
+
                 rc = obd_unpackmd(sbi->ll_osc_exp, &lsm, lmm, lmmsize);
                 if (rc < 0)
                         GOTO(free_lmm, rc = -ENOMEM);
diff --git a/lustre/llite/file.c b/lustre/llite/file.c
index 4c42e52449631c4ffb7d16123e6beffb9ab210b5..e29e9d2215dca58e56a8a773ae1aa8a3bf57d9c1 100644
--- a/lustre/llite/file.c
+++ b/lustre/llite/file.c
@@ -2040,16 +2040,22 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
         LASSERT(lmm != NULL);
         LASSERT(lustre_rep_swabbed(req, REPLY_REC_OFF + 1));
 
+        if ((lmm->lmm_magic != cpu_to_le32(LOV_MAGIC)) &&
+             (lmm->lmm_magic != cpu_to_le32(LOV_MAGIC_JOIN))) {
+                GOTO(out, rc = -EPROTO);
+        }
         /*
          * This is coming from the MDS, so is probably in
          * little endian.  We convert it to host endian before
          * passing it to userspace.
          */
-        if (lmm->lmm_magic == __swab32(LOV_MAGIC)) {
-                lustre_swab_lov_user_md((struct lov_user_md *)lmm);
-                lustre_swab_lov_user_md_objects((struct lov_user_md *)lmm);
-        } else if (lmm->lmm_magic == __swab32(LOV_MAGIC_JOIN)) {
-                lustre_swab_lov_user_md_join((struct lov_user_md_join *)lmm);
+        if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) {
+                if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC)) {
+                        lustre_swab_lov_user_md((struct lov_user_md *)lmm);
+                        lustre_swab_lov_user_md_objects((struct lov_user_md *)lmm);
+                } else if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_JOIN)) {
+                        lustre_swab_lov_user_md_join((struct lov_user_md_join *)lmm);
+                }
         }
 
         if (lmm->lmm_magic == LOV_MAGIC_JOIN) {
diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c
index f672ddb30dfdd5186b85a6cbc23d35f4eb6043ff..d82f83fba9925071a482b5a6729fd6ba5668d172 100644
--- a/lustre/mdc/mdc_request.c
+++ b/lustre/mdc/mdc_request.c
@@ -154,7 +154,7 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
                         RETURN (-EPROTO);
                 }
         }
-        
+
         if (body->valid & OBD_MD_FLMODEASIZE) {
                 if (exp->exp_obd->u.cli.cl_max_mds_easize < body->max_mdsize) 
                         exp->exp_obd->u.cli.cl_max_mds_easize = 
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index 0e7c005aa8e52be2285f8e218f350d1baea5b21b..de4108f2c2c00f73d6a0b71669930c04beac5979 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -1658,7 +1658,7 @@ int mds_handle(struct ptlrpc_request *req)
                         break;
                 }
                 opc = *opcp;
-                if (lustre_msg_swabbed(req->rq_reqmsg))
+                if (lustre_req_need_swab(req))
                         __swab32s(&opc);
 
                 DEBUG_REQ(D_INODE, req, "reint %d (%s)", opc,
diff --git a/lustre/mds/mds_lib.c b/lustre/mds/mds_lib.c
index 9a144a6a75d8fe0b51e44ff8ce3ed41a86f6f2b3..6a33465c3a999632d9a7b942f34e2d2c356c8747 100644
--- a/lustre/mds/mds_lib.c
+++ b/lustre/mds/mds_lib.c
@@ -413,7 +413,7 @@ int mds_update_unpack(struct ptlrpc_request *req, int offset,
                 RETURN(-EFAULT);
 
         opcode = *opcodep;
-        if (lustre_msg_swabbed(req->rq_reqmsg))
+        if (lustre_req_need_swab(req))
                 __swab32s(&opcode);
 
         if (opcode >= REINT_MAX || mds_unpackers[opcode] == NULL) {
diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c
index 0ada5c989da2246bbe479588e1833720461e10ba..c97ca561ad852536981de691102a1503f55bb74e 100644
--- a/lustre/obdclass/class_obd.c
+++ b/lustre/obdclass/class_obd.c
@@ -490,7 +490,7 @@ int obd_init_checks(void)
         }
         if ((u64val & ~CFS_PAGE_MASK) >= CFS_PAGE_SIZE) {
                 CWARN("mask failed: u64val "LPU64" >= %lu\n", u64val, 
-                      CFS_PAGE_SIZE);
+                      (unsigned long)CFS_PAGE_SIZE);
                 ret = -EINVAL;
         }
 
diff --git a/lustre/obdfilter/filter_lvb.c b/lustre/obdfilter/filter_lvb.c
index cb0eb9ce0da71c3749fcbf31b8d4cb534b8a2219..678119b2b1bbd23cb63d4d47fa5e5b49da81fcfe 100644
--- a/lustre/obdfilter/filter_lvb.c
+++ b/lustre/obdfilter/filter_lvb.c
@@ -107,7 +107,7 @@ out_dentry:
  *
  *   If 'increase_only' is true, don't allow values to move backwards.
  */
-static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
+static int filter_lvbo_update(struct ldlm_resource *res, struct ptlrpc_request *r,
                               int buf_idx, int increase_only)
 {
         int rc = 0;
@@ -131,11 +131,12 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
         }
 
         /* Update the LVB from the network message */
-        if (m != NULL) {
+        if (r != NULL) {
                 struct ost_lvb *new;
 
-                new = lustre_swab_buf(m, buf_idx, sizeof(*new),
-                                      lustre_swab_ost_lvb);
+                /* XXX update always from reply buffer */
+                new = lustre_swab_repbuf(r, buf_idx, sizeof(*new),
+                                         lustre_swab_ost_lvb);
                 if (new == NULL) {
                         CERROR("lustre_swab_buf failed\n");
                         goto disk_update;
diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c
index b214be9e0a2069e5584d771d625b6dfc37862eef..0ae446231efff83e5435de448b1b74b6c48e4d87 100644
--- a/lustre/osc/osc_request.c
+++ b/lustre/osc/osc_request.c
@@ -870,7 +870,7 @@ static int check_write_rcs(struct ptlrpc_request *req,
                 CERROR("Missing/short RC vector on BRW_WRITE reply\n");
                 return(-EPROTO);
         }
-        if (lustre_msg_swabbed(req->rq_repmsg))
+        if (lustre_rep_need_swab(req))
                 for (i = 0; i < niocount; i++)
                         __swab32s(&remote_rcs[i]);
 
diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c
index e191bf2e872746af9f26dc2da129337fa85390cd..76c4228ab4acacfe5872a7baeedfae3d23d0ad71 100644
--- a/lustre/ost/ost_handler.c
+++ b/lustre/ost/ost_handler.c
@@ -725,7 +725,8 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 CERROR("Missing/short niobuf\n");
                 GOTO(out, rc = -EFAULT);
         }
-        if (lustre_msg_swabbed(req->rq_reqmsg)) { /* swab remaining niobufs */
+        if (lustre_req_need_swab(req)) {
+                /* swab remaining niobufs */
                 for (i = 1; i < niocount; i++)
                         lustre_swab_niobuf_remote (&remote_nb[i]);
         }
@@ -967,7 +968,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         if (exp->exp_failed)
                 GOTO(out, rc = -ENOTCONN);
 
-        swab = lustre_msg_swabbed(req->rq_reqmsg);
+        swab = lustre_req_need_swab(req);
         body = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*body),
                                   lustre_swab_ost_body);
         if (body == NULL) {
@@ -975,7 +976,6 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 GOTO(out, rc = -EFAULT);
         }
 
-        lustre_set_req_swabbed(req, REQ_REC_OFF + 1);
         objcount = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF + 1) /
                    sizeof(*ioo);
         if (objcount == 0) {
@@ -987,6 +987,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 GOTO(out, rc = -EFAULT);
         }
 
+        lustre_set_req_swabbed(req, REQ_REC_OFF + 1);
         ioo = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1,
                              objcount * sizeof(*ioo));
         LASSERT (ioo != NULL);
diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c
index c763faa1e2f816c48f6726f9852f7881edc4e590..772667ef5bb4d7f30f08b5a6e9d27e603af51e8f 100644
--- a/lustre/ptlrpc/client.c
+++ b/lustre/ptlrpc/client.c
@@ -258,9 +258,9 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req)
         time_t now = cfs_time_current_sec();
 
         LASSERT(req->rq_import);
-        
+
         st = lustre_msg_get_service_time(req->rq_repmsg);
-        
+
         /* Network latency is total time less server processing time */
         nl = max_t(int, now - req->rq_sent - st, 0) + 1/*st rounding*/;
         if (st > now - req->rq_sent + 2 /* rounding */)
@@ -281,15 +281,16 @@ static int unpack_reply(struct ptlrpc_request *req)
 {
         int rc;
 
-        /* Clear reply swab mask; we may have already swabbed an early reply */
         req->rq_rep_swab_mask = 0;
-
         rc = lustre_unpack_msg(req->rq_repmsg, req->rq_nob_received);
-        if (rc) {
+        if (rc < 0) {
                 DEBUG_REQ(D_ERROR, req, "unpack_rep failed: %d", rc);
                 return(-EPROTO);
         }
 
+        if (rc > 0)
+                lustre_set_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF);
+
         rc = lustre_unpack_rep_ptlrpc_body(req, MSG_PTLRPC_BODY_OFF);
         if (rc) {
                 DEBUG_REQ(D_ERROR, req, "unpack ptlrpc body failed: %d", rc);
diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c
index 3f3d746538a00b44b7efd81ff92a99d08fb6724f..32c40c130f2417397f49c9d5c142bf7b575dd7df 100644
--- a/lustre/ptlrpc/pack_generic.c
+++ b/lustre/ptlrpc/pack_generic.c
@@ -55,14 +55,13 @@ static inline int lustre_msg_hdr_size_v2(int count)
         return size_round(offsetof(struct lustre_msg_v2, lm_buflens[count]));
 }
 
-int lustre_msg_swabbed(struct lustre_msg *msg)
+static int lustre_msg_need_swab(struct lustre_msg *msg)
 {
         return (msg->lm_magic == LUSTRE_MSG_MAGIC_V1_SWABBED) ||
                (msg->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED);
 }
 
-static inline int
-lustre_msg_check_version_v2(struct lustre_msg_v2 *msg, __u32 version)
+int lustre_msg_check_version_v2(struct lustre_msg_v2 *msg, __u32 version)
 {
         __u32 ver = lustre_msg_get_version(msg);
         return (ver & LUSTRE_VERSION_MASK) != version;
@@ -72,21 +71,40 @@ int lustre_msg_check_version(struct lustre_msg *msg, __u32 version)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 0;
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 return lustre_msg_check_version_v2(msg, version);
         default:
-                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
                 return -EINVAL;
         }
 }
 
+static int ptlrpc_reqbuf_need_swab(struct ptlrpc_request *req, int index)
+{
+        int swabb;
+
+        swabb = (!lustre_req_need_swab(req)) ||
+                 lustre_req_swabbed(req, index);
+
+        return !swabb;
+}
+
+static int ptlrpc_repbuf_need_swab(struct ptlrpc_request *req, int index)
+{
+        int swabb;
+
+        swabb = (!lustre_rep_need_swab(req)) ||
+                 lustre_rep_swabbed(req, index);
+
+        return !swabb;
+}
+
+
 /* early reply size */
 int lustre_msg_early_size() {
         static int size = 0;
-        if (!size) 
+        if (!size)
                 size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, NULL);
         return size;
 }
@@ -346,7 +364,7 @@ static struct ptlrpc_reply_state *lustre_get_emerg_rs(struct ptlrpc_service *svc
                         goto out;
                 spin_lock(&svc->srv_lock);
         }
-        
+
         rs = list_entry(svc->srv_free_rs_list.next, struct ptlrpc_reply_state,
                         rs_list);
         list_del(&rs->rs_list);
@@ -460,14 +478,12 @@ int lustre_pack_reply_flags(struct ptlrpc_request *req, int count, int *lens,
 
         switch (req->rq_reqmsg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return lustre_pack_reply_v1(req, count - 1, lens + 1,
                                             bufs ? bufs + 1 : NULL, flags);
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 return lustre_pack_reply_v2(req, count, lens, bufs, flags);
         default:
-                LASSERTF(0, "incorrect message magic: %08x\n",
+                CERROR("incorrect message magic: %08x\n",
                          req->rq_reqmsg->lm_magic);
                 return -EINVAL;
         }
@@ -546,13 +562,11 @@ void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
 {
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return lustre_msg_buf_v1(m, n - 1, min_size);
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 return lustre_msg_buf_v2(m, n, min_size);
         default:
-                LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
+                CERROR("incorrect message magic: %08x\n", m->lm_magic);
                 return NULL;
         }
 }
@@ -706,9 +720,9 @@ int lustre_unpack_msg_v1(void *msg, int len)
                 RETURN(-EINVAL);
         }
 
-        flipped = lustre_msg_swabbed((struct lustre_msg *)m);
-
+        flipped = m->lm_magic == LUSTRE_MSG_MAGIC_V1_SWABBED;
         if (flipped) {
+                __swab32s(&m->lm_magic);
                 __swab32s(&m->lm_type);
                 __swab32s(&m->lm_version);
                 __swab32s(&m->lm_opc);
@@ -763,9 +777,9 @@ static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len)
                 RETURN(-EINVAL);
         }
 
-        flipped = lustre_msg_swabbed(m);
-
+        flipped = m->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED;
         if (flipped) {
+                __swab32s(&m->lm_magic);
                 __swab32s(&m->lm_bufcount);
                 __swab32s(&m->lm_secflvr);
                 __swab32s(&m->lm_repsize);
@@ -800,9 +814,15 @@ static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len)
         return 0;
 }
 
+/*
+ * return 1 if some endianness conversions are needed for the req buffers,
+ * 0 if not neeed, or
+ * -EINVAL if message has wrong magic
+ */
 int lustre_unpack_msg(struct lustre_msg *m, int len)
 {
         int required_len, rc;
+        int swab_needed;
         ENTRY;
 
         /* We can provide a slightly better error log, if we check the
@@ -820,6 +840,8 @@ int lustre_unpack_msg(struct lustre_msg *m, int len)
                 RETURN(-EINVAL);
         }
 
+        swab_needed = lustre_msg_need_swab(m);
+
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
         case LUSTRE_MSG_MAGIC_V1_SWABBED:
@@ -830,15 +852,18 @@ int lustre_unpack_msg(struct lustre_msg *m, int len)
                 rc = lustre_unpack_msg_v2(m, len);
                 break;
         default:
-                CERROR("bad lustre msg magic: %#08X\n", m->lm_magic);
+                CERROR("incorrect message magic: %08x\n", m->lm_magic);
                 return -EINVAL;
         }
 
+        if (!rc)
+                rc = swab_needed;
+
         RETURN(rc);
 }
 
 static inline int lustre_unpack_ptlrpc_body_v2(struct lustre_msg_v2 *m,
-                                               int offset)
+                                               int offset, int swab_needed)
 {
         struct ptlrpc_body *pb;
 
@@ -847,7 +872,7 @@ static inline int lustre_unpack_ptlrpc_body_v2(struct lustre_msg_v2 *m,
                 CERROR("error unpacking ptlrpc body\n");
                 return -EFAULT;
         }
-        if (lustre_msg_swabbed(m))
+        if (swab_needed)
                 lustre_swab_ptlrpc_body(pb);
 
         if ((pb->pb_version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
@@ -862,14 +887,15 @@ int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset)
 {
         switch (req->rq_reqmsg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 0;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
+        case LUSTRE_MSG_MAGIC_V2: {
+                int swab_needed = ptlrpc_reqbuf_need_swab(req, offset);
                 lustre_set_req_swabbed(req, offset);
-                return lustre_unpack_ptlrpc_body_v2(req->rq_reqmsg, offset);
+                return lustre_unpack_ptlrpc_body_v2(req->rq_reqmsg, offset,
+                                                    swab_needed);
+        }
         default:
-                CERROR("bad lustre msg magic: %#08X\n",
+                CERROR("incorrect message magic: %08x\n",
                        req->rq_reqmsg->lm_magic);
                 return -EINVAL;
         }
@@ -879,14 +905,15 @@ int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset)
 {
         switch (req->rq_repmsg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 0;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
+        case LUSTRE_MSG_MAGIC_V2:{
+                int swab_needed = ptlrpc_repbuf_need_swab(req, offset);
                 lustre_set_rep_swabbed(req, offset);
-                return lustre_unpack_ptlrpc_body_v2(req->rq_repmsg, offset);
+                return lustre_unpack_ptlrpc_body_v2(req->rq_repmsg, offset,
+                                                    swab_needed);
+        }
         default:
-                CERROR("bad lustre msg magic: %#08X\n",
+                CERROR("incorrect message magic: %08x\n",
                        req->rq_repmsg->lm_magic);
                 return -EINVAL;
         }
@@ -922,10 +949,8 @@ int lustre_msg_buflen(struct lustre_msg *m, int n)
 {
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return lustre_msg_buflen_v1(m, n - 1);
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 return lustre_msg_buflen_v2(m, n);
         default:
                 CERROR("incorrect message magic: %08x\n", m->lm_magic);
@@ -976,10 +1001,8 @@ int lustre_msg_bufcount(struct lustre_msg *m)
 {
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)m)->lm_bufcount + 1;
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 return m->lm_bufcount;
         default:
                 CERROR("incorrect message magic: %08x\n", m->lm_magic);
@@ -996,12 +1019,10 @@ char *lustre_msg_string(struct lustre_msg *m, int index, int max_len)
 
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 str = lustre_msg_buf_v1(m, index - 1, 0);
                 blen = lustre_msg_buflen_v1(m, index - 1);
                 break;
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 str = lustre_msg_buf_v2(m, index, 0);
                 blen = lustre_msg_buflen_v2(m, index);
                 break;
@@ -1047,11 +1068,9 @@ void *lustre_swab_buf(struct lustre_msg *msg, int index, int min_size,
 
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 ptr = lustre_msg_buf_v1(msg, index - 1, min_size);
                 break;
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 ptr = lustre_msg_buf_v2(msg, index, min_size);
                 break;
         default:
@@ -1060,8 +1079,10 @@ void *lustre_swab_buf(struct lustre_msg *msg, int index, int min_size,
         if (ptr == NULL)
                 return NULL;
 
-        if (swabber != NULL && lustre_msg_swabbed(msg))
+        if (swabber != NULL) {
+                CDEBUG(D_NET, "Swab buffer %d\n", index);
                 ((void (*)(void *))swabber)(ptr);
+        }
 
         return ptr;
 }
@@ -1069,6 +1090,9 @@ void *lustre_swab_buf(struct lustre_msg *msg, int index, int min_size,
 void *lustre_swab_reqbuf(struct ptlrpc_request *req, int index, int min_size,
                          void *swabber)
 {
+        if (!ptlrpc_reqbuf_need_swab(req, index))
+                 swabber = NULL;
+
         lustre_set_req_swabbed(req, index);
         return lustre_swab_buf(req->rq_reqmsg, index, min_size, swabber);
 }
@@ -1076,6 +1100,9 @@ void *lustre_swab_reqbuf(struct ptlrpc_request *req, int index, int min_size,
 void *lustre_swab_repbuf(struct ptlrpc_request *req, int index, int min_size,
                          void *swabber)
 {
+        if (!ptlrpc_repbuf_need_swab(req, index))
+                swabber = NULL;
+
         lustre_set_rep_swabbed(req, index);
         return lustre_swab_buf(req->rq_repmsg, index, min_size, swabber);
 }
@@ -1084,10 +1111,8 @@ __u32 lustre_msghdr_get_flags(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 0;
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 /* already in host endian */
                 return msg->lm_flags;
         default:
@@ -1113,11 +1138,9 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_flags &
                        MSG_GEN_FLAG_MASK;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1128,6 +1151,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
                 return pb->pb_flags;
         }
         default:
+                CERROR("Wrong magic %x\n", msg->lm_magic);
                 /* flags might be printed in debug code while message
                  * uninitialized */
                 return 0;
@@ -1179,12 +1203,10 @@ void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 ((struct lustre_msg_v1 *)msg)->lm_flags &=
                                         ~(MSG_GEN_FLAG_MASK & flags);
                 return;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1201,11 +1223,9 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_flags >>
                        MSG_OP_FLAG_SHIFT;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1216,6 +1236,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
                 return pb->pb_op_flags;
         }
         default:
+                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
                 return 0;
         }
 }
@@ -1265,10 +1286,8 @@ struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return &((struct lustre_msg_v1 *)msg)->lm_handle;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1288,10 +1307,8 @@ __u32 lustre_msg_get_type(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_type;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1311,10 +1328,8 @@ __u32 lustre_msg_get_version(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_version;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1334,10 +1349,8 @@ void lustre_msg_add_version(struct lustre_msg *msg, int version)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1354,10 +1367,8 @@ __u32 lustre_msg_get_opc(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_opc;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1377,10 +1388,8 @@ __u64 lustre_msg_get_last_xid(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_last_xid;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1400,10 +1409,8 @@ __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_last_committed;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1423,10 +1430,8 @@ __u64 lustre_msg_get_transno(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_transno;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1460,6 +1465,7 @@ int lustre_msg_get_status(struct lustre_msg *msg)
                 return pb->pb_status;
         }
         default:
+                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
                 /* status might be printed in debug code while message
                  * uninitialized */
                 return -EINVAL;
@@ -1470,10 +1476,8 @@ __u64 lustre_msg_get_slv(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 1;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1484,7 +1488,7 @@ __u64 lustre_msg_get_slv(struct lustre_msg *msg)
                 return pb->pb_slv;
         }
         default:
-                CERROR("invalid msg magic %x\n", msg->lm_magic);
+                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
                 return -EINVAL;
         }
 }
@@ -1494,10 +1498,8 @@ void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1509,7 +1511,7 @@ void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv)
                 return;
         }
         default:
-                CERROR("invalid msg magic %x\n", msg->lm_magic);
+                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
                 return;
         }
 }
@@ -1518,10 +1520,8 @@ __u32 lustre_msg_get_limit(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 1;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1532,7 +1532,7 @@ __u32 lustre_msg_get_limit(struct lustre_msg *msg)
                 return pb->pb_limit;
         }
         default:
-                CERROR("invalid msg magic %x\n", msg->lm_magic);
+                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
                 return -EINVAL;
         }
 }
@@ -1542,10 +1542,8 @@ void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1557,7 +1555,7 @@ void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit)
                 return;
         }
         default:
-                CERROR("invalid msg magic %x\n", msg->lm_magic);
+                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
                 return;
         }
 }
@@ -1566,10 +1564,8 @@ __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return ((struct lustre_msg_v1 *)msg)->lm_conn_cnt;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
 
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
@@ -1614,17 +1610,14 @@ __u32 lustre_msg_get_timeout(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 0;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
-                
+
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
-                        
                 }
                 return pb->pb_timeout;
         }
@@ -1638,17 +1631,14 @@ __u32 lustre_msg_get_service_time(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 0;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
-        
+
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
-                        
                 }
                 return pb->pb_service_time;
         }
@@ -1662,10 +1652,8 @@ __u32 lustre_msg_get_cksum(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 0;
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 return msg->lm_cksum;
         default:
                 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
@@ -1677,10 +1665,8 @@ __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 0;
-        case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED: {
+        case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
@@ -1851,7 +1837,7 @@ void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout)
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
                 struct ptlrpc_body *pb;
-                
+
                 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_timeout = timeout;
@@ -2209,17 +2195,6 @@ void lustre_swab_lov_desc (struct lov_desc *ld)
         /* uuid endian insensitive */
 }
 
-static void print_lum (struct lov_user_md *lum)
-{
-        CDEBUG(D_OTHER, "lov_user_md %p:\n", lum);
-        CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic);
-        CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern);
-        CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lum->lmm_object_id);
-        CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lum->lmm_object_gr);
-        CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size);
-        CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count);
-        CDEBUG(D_OTHER, "\tlmm_stripe_offset: %#x\n", lum->lmm_stripe_offset);
-}
 
 void lustre_swab_lov_user_md(struct lov_user_md *lum)
 {
@@ -2232,22 +2207,9 @@ void lustre_swab_lov_user_md(struct lov_user_md *lum)
         __swab32s(&lum->lmm_stripe_size);
         __swab16s(&lum->lmm_stripe_count);
         __swab16s(&lum->lmm_stripe_offset);
-        print_lum(lum);
         EXIT;
 }
 
-static void print_lumj (struct lov_user_md_join *lumj)
-{
-        CDEBUG(D_OTHER, "lov_user_md %p:\n", lumj);
-        CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lumj->lmm_magic);
-        CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lumj->lmm_pattern);
-        CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lumj->lmm_object_id);
-        CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lumj->lmm_object_gr);
-        CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lumj->lmm_stripe_size);
-        CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lumj->lmm_stripe_count);
-        CDEBUG(D_OTHER, "\tlmm_extent_count: %#x\n", lumj->lmm_extent_count);
-}
-
 void lustre_swab_lov_user_md_join(struct lov_user_md_join *lumj)
 {
         ENTRY;
@@ -2259,25 +2221,6 @@ void lustre_swab_lov_user_md_join(struct lov_user_md_join *lumj)
         __swab32s(&lumj->lmm_stripe_size);
         __swab32s(&lumj->lmm_stripe_count);
         __swab32s(&lumj->lmm_extent_count);
-        print_lumj(lumj);
-        EXIT;
-}
-
-static void print_lum_objs(struct lov_user_md *lum)
-{
-        struct lov_user_ost_data *lod;
-        int i;
-        ENTRY;
-        if (!(libcfs_debug & D_OTHER)) /* don't loop on nothing */
-                return;
-        CDEBUG(D_OTHER, "lov_user_md_objects: %p\n", lum);
-        for (i = 0; i < lum->lmm_stripe_count; i++) {
-                lod = &lum->lmm_objects[i];
-                CDEBUG(D_OTHER, "(%i) lod->l_object_id: "LPX64"\n", i, lod->l_object_id);
-                CDEBUG(D_OTHER, "(%i) lod->l_object_gr: "LPX64"\n", i, lod->l_object_gr);
-                CDEBUG(D_OTHER, "(%i) lod->l_ost_gen: %#x\n", i, lod->l_ost_gen);
-                CDEBUG(D_OTHER, "(%i) lod->l_ost_idx: %#x\n", i, lod->l_ost_idx);
-        }
         EXIT;
 }
 
@@ -2293,7 +2236,6 @@ void lustre_swab_lov_user_md_objects(struct lov_user_md *lum)
                 __swab32s(&lod->l_ost_gen);
                 __swab32s(&lod->l_ost_idx);
         }
-        print_lum_objs(lum);
         EXIT;
 }
 
@@ -2665,13 +2607,11 @@ static inline int req_ptlrpc_body_swabbed(struct ptlrpc_request *req)
 
         switch (req->rq_reqmsg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 1;
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 return lustre_req_swabbed(req, MSG_PTLRPC_BODY_OFF);
         default:
-                CERROR("bad lustre msg magic: %#08X\n",
+                CERROR("incorrect message magic: %08x\n",
                        req->rq_reqmsg->lm_magic);
         }
         return 0;
@@ -2683,13 +2623,12 @@ static inline int rep_ptlrpc_body_swabbed(struct ptlrpc_request *req)
 
         switch (req->rq_repmsg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
-        case LUSTRE_MSG_MAGIC_V1_SWABBED:
                 return 1;
         case LUSTRE_MSG_MAGIC_V2:
-        case LUSTRE_MSG_MAGIC_V2_SWABBED:
                 return lustre_rep_swabbed(req, MSG_PTLRPC_BODY_OFF);
         default:
-                /* uninitialized yet */
+                CERROR("incorrect message magic: %08x\n",
+                        req->rq_repmsg->lm_magic);
                 return 0;
         }
 }
@@ -2699,6 +2638,24 @@ void _debug_req(struct ptlrpc_request *req, __u32 mask,
 
 {
         va_list args;
+        int opc = -1;
+        int req_fl = 0;
+        int rep_fl = 0;
+        int rep_status = 0;
+
+        if (req->rq_reqmsg &&
+            (!lustre_msg_need_swab(req->rq_reqmsg) ||
+            lustre_req_need_swab(req))) {
+                opc = lustre_msg_get_opc(req->rq_reqmsg);
+                req_fl = lustre_msg_get_flags(req->rq_reqmsg);
+        }
+
+        if (req->rq_repmsg &&
+           (!lustre_msg_need_swab(req->rq_repmsg) ||
+            lustre_rep_need_swab(req))) {
+                rep_fl = lustre_msg_get_flags(req->rq_repmsg);
+                rep_status = lustre_msg_get_status(req->rq_repmsg);
+        }
 
         va_start(args, fmt);
         libcfs_debug_vmsg2(data->msg_cdls, data->msg_subsys, mask, data->msg_file,
@@ -2706,8 +2663,7 @@ void _debug_req(struct ptlrpc_request *req, __u32 mask,
                            " req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d/%d "
                            "lens %d/%d e %d to %d dl %ld ref %d "
                            "fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n",
-                           req, req->rq_xid, req->rq_transno,
-                           req->rq_reqmsg ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
+                           req, req->rq_xid, req->rq_transno, opc,
                            req->rq_import ? obd2cli_tgt(req->rq_import->imp_obd) :
                            req->rq_export ?
                                 (char*)req->rq_export->exp_client_uuid.uuid : "<?>",
@@ -2719,11 +2675,9 @@ void _debug_req(struct ptlrpc_request *req, __u32 mask,
                            req->rq_reqlen, req->rq_replen,
                            req->rq_early_count, req->rq_timeout, req->rq_deadline,
                            atomic_read(&req->rq_refcount), DEBUG_REQ_FLAGS(req),
-                           req->rq_reqmsg ? lustre_msg_get_flags(req->rq_reqmsg) : 0,
-                           req->rq_repmsg ? lustre_msg_get_flags(req->rq_repmsg) : 0,
-                           req->rq_status,
-                           req->rq_repmsg ? lustre_msg_get_status(req->rq_repmsg) : 0);
+                           req_fl, rep_fl, req->rq_status, rep_status);
         va_end(args);
 }
 
+
 EXPORT_SYMBOL(_debug_req);
diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c
index 60eb510d28151111b5cfac625028751dfbd1957a..3bcf3d2a876cdf903ad9428a01ffb3354e88fe94 100644
--- a/lustre/ptlrpc/ptlrpc_module.c
+++ b/lustre/ptlrpc/ptlrpc_module.c
@@ -186,7 +186,6 @@ EXPORT_SYMBOL(ptlrpc_daemonize);
 EXPORT_SYMBOL(ptlrpc_service_health_check);
 
 /* pack_generic.c */
-EXPORT_SYMBOL(lustre_msg_swabbed);
 EXPORT_SYMBOL(lustre_msg_check_version);
 EXPORT_SYMBOL(lustre_pack_request);
 EXPORT_SYMBOL(lustre_pack_reply);
@@ -198,7 +197,6 @@ EXPORT_SYMBOL(lustre_packed_msg_size);
 EXPORT_SYMBOL(lustre_unpack_msg);
 EXPORT_SYMBOL(lustre_msg_buf);
 EXPORT_SYMBOL(lustre_msg_string);
-EXPORT_SYMBOL(lustre_swab_buf);
 EXPORT_SYMBOL(lustre_swab_reqbuf);
 EXPORT_SYMBOL(lustre_swab_repbuf);
 EXPORT_SYMBOL(lustre_swab_obdo);
diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c
index fb23933af4b9094123a00a1204d8c14cbc195c6e..cc54a41711fc17b22aa6b017126a086450d26c59 100644
--- a/lustre/ptlrpc/service.c
+++ b/lustre/ptlrpc/service.c
@@ -855,7 +855,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc)
         }
         spin_unlock(&svc->srv_at_lock);
 
-        RETURN(0);      
+        RETURN(0);
 }
 
 /* Handle freshly incoming reqs, add to timed early reply list,
@@ -882,18 +882,21 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service *svc)
         /* Consider this still a "queued" request as far as stats are
            concerned */
         spin_unlock(&svc->srv_lock);
-        
+
         /* Clear request swab mask; this is a new request */
         req->rq_req_swab_mask = 0;
 
         rc = lustre_unpack_msg(req->rq_reqmsg, req->rq_reqlen);
-        if (rc != 0) {
+        if (rc < 0) {
                 CERROR ("error unpacking request: ptl %d from %s"
                         " xid "LPU64"\n", svc->srv_req_portal,
                         libcfs_id2str(req->rq_peer), req->rq_xid);
                 goto err_req;
         }
 
+        if (rc > 0)
+                lustre_set_req_swabbed(req, MSG_PTLRPC_HEADER_OFF);
+
         rc = lustre_unpack_req_ptlrpc_body(req, MSG_PTLRPC_BODY_OFF);
         if (rc) {
                 CERROR ("error unpacking ptlrpc body: ptl %d from %s"
@@ -911,7 +914,7 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service *svc)
         }
 
         CDEBUG(D_NET, "got req "LPD64"\n", req->rq_xid);
-        
+
         req->rq_export = class_conn2export(
                 lustre_msg_get_handle(req->rq_reqmsg));
         if (req->rq_export) {