Whamcloud - gitweb
LU-1267 lfsck: framework (3) for MDT-OST consistency
[fs/lustre-release.git] / lustre / ptlrpc / pack_generic.c
index ea1c641..0707ec3 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -261,20 +261,20 @@ EXPORT_SYMBOL(lustre_pack_request);
 
 #if RS_DEBUG
 CFS_LIST_HEAD(ptlrpc_rs_debug_lru);
-cfs_spinlock_t ptlrpc_rs_debug_lock;
+spinlock_t ptlrpc_rs_debug_lock;
 
-#define PTLRPC_RS_DEBUG_LRU_ADD(rs)                                     \
-do {                                                                    \
-        cfs_spin_lock(&ptlrpc_rs_debug_lock);                           \
-        cfs_list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru);  \
-        cfs_spin_unlock(&ptlrpc_rs_debug_lock);                         \
+#define PTLRPC_RS_DEBUG_LRU_ADD(rs)                                    \
+do {                                                                   \
+       spin_lock(&ptlrpc_rs_debug_lock);                               \
+       cfs_list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru);  \
+       spin_unlock(&ptlrpc_rs_debug_lock);                             \
 } while (0)
 
-#define PTLRPC_RS_DEBUG_LRU_DEL(rs)             \
-do {                                            \
-        cfs_spin_lock(&ptlrpc_rs_debug_lock);   \
-        cfs_list_del(&(rs)->rs_debug_list);     \
-        cfs_spin_unlock(&ptlrpc_rs_debug_lock); \
+#define PTLRPC_RS_DEBUG_LRU_DEL(rs)                                    \
+do {                                                                   \
+       spin_lock(&ptlrpc_rs_debug_lock);                               \
+       cfs_list_del(&(rs)->rs_debug_list);                             \
+       spin_unlock(&ptlrpc_rs_debug_lock);                             \
 } while (0)
 #else
 # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while(0)
@@ -286,14 +286,14 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt)
 {
        struct ptlrpc_reply_state *rs = NULL;
 
-       cfs_spin_lock(&svcpt->scp_rep_lock);
+       spin_lock(&svcpt->scp_rep_lock);
 
        /* See if we have anything in a pool, and wait if nothing */
        while (cfs_list_empty(&svcpt->scp_rep_idle)) {
                struct l_wait_info      lwi;
                int                     rc;
 
-               cfs_spin_unlock(&svcpt->scp_rep_lock);
+               spin_unlock(&svcpt->scp_rep_lock);
                /* If we cannot get anything for some long time, we better
                 * bail out instead of waiting infinitely */
                lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL);
@@ -301,17 +301,17 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt)
                                  !cfs_list_empty(&svcpt->scp_rep_idle), &lwi);
                if (rc != 0)
                        goto out;
-               cfs_spin_lock(&svcpt->scp_rep_lock);
+               spin_lock(&svcpt->scp_rep_lock);
        }
 
        rs = cfs_list_entry(svcpt->scp_rep_idle.next,
                            struct ptlrpc_reply_state, rs_list);
        cfs_list_del(&rs->rs_list);
 
-       cfs_spin_unlock(&svcpt->scp_rep_lock);
+       spin_unlock(&svcpt->scp_rep_lock);
 
-       LASSERT(rs != NULL);
        memset(rs, 0, svcpt->scp_service->srv_max_reply_size);
+       rs->rs_size = svcpt->scp_service->srv_max_reply_size;
        rs->rs_svcpt = svcpt;
        rs->rs_prealloc = 1;
 out:
@@ -322,10 +322,10 @@ void lustre_put_emerg_rs(struct ptlrpc_reply_state *rs)
 {
        struct ptlrpc_service_part *svcpt = rs->rs_svcpt;
 
-       cfs_spin_lock(&svcpt->scp_rep_lock);
+       spin_lock(&svcpt->scp_rep_lock);
        cfs_list_add(&rs->rs_list, &svcpt->scp_rep_idle);
-       cfs_spin_unlock(&svcpt->scp_rep_lock);
-       cfs_waitq_signal(&svcpt->scp_rep_waitq);
+       spin_unlock(&svcpt->scp_rep_lock);
+       wake_up(&svcpt->scp_rep_waitq);
 }
 
 int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
@@ -338,9 +338,9 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
         LASSERT(req->rq_reply_state == NULL);
 
         if ((flags & LPRFL_EARLY_REPLY) == 0) {
-                cfs_spin_lock(&req->rq_lock);
-                req->rq_packed_final = 1;
-                cfs_spin_unlock(&req->rq_lock);
+               spin_lock(&req->rq_lock);
+               req->rq_packed_final = 1;
+               spin_unlock(&req->rq_lock);
         }
 
         msg_len = lustre_msg_size_v2(count, lens);
@@ -356,7 +356,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
         CFS_INIT_LIST_HEAD(&rs->rs_exp_list);
         CFS_INIT_LIST_HEAD(&rs->rs_obd_list);
         CFS_INIT_LIST_HEAD(&rs->rs_list);
-        cfs_spin_lock_init(&rs->rs_lock);
+       spin_lock_init(&rs->rs_lock);
 
         req->rq_replen = msg_len;
         req->rq_reply_state = rs;
@@ -646,6 +646,9 @@ static inline int lustre_unpack_ptlrpc_body_v2(struct ptlrpc_request *req,
                  return -EINVAL;
         }
 
+       if (!inout)
+               pb->pb_status = ptlrpc_status_ntoh(pb->pb_status);
+
         return 0;
 }
 
@@ -1730,8 +1733,7 @@ void lustre_swab_connect(struct obd_connect_data *ocd)
 void lustre_swab_obdo (struct obdo  *o)
 {
         __swab64s (&o->o_valid);
-        __swab64s (&o->o_id);
-        __swab64s (&o->o_seq);
+       lustre_swab_ost_id(&o->o_oi);
         __swab64s (&o->o_parent_seq);
         __swab64s (&o->o_size);
         __swab64s (&o->o_mtime);
@@ -1787,12 +1789,11 @@ void lustre_swab_obd_statfs (struct obd_statfs *os)
 }
 EXPORT_SYMBOL(lustre_swab_obd_statfs);
 
-void lustre_swab_obd_ioobj (struct obd_ioobj *ioo)
+void lustre_swab_obd_ioobj(struct obd_ioobj *ioo)
 {
-        __swab64s (&ioo->ioo_id);
-        __swab64s (&ioo->ioo_seq);
-        __swab32s (&ioo->ioo_type);
-        __swab32s (&ioo->ioo_bufcnt);
+       lustre_swab_ost_id(&ioo->ioo_oid);
+       __swab32s(&ioo->ioo_max_brw);
+       __swab32s(&ioo->ioo_bufcnt);
 }
 EXPORT_SYMBOL(lustre_swab_obd_ioobj);
 
@@ -1829,56 +1830,75 @@ void lustre_swab_gl_desc(union ldlm_gl_desc *desc)
        __swab64s(&desc->lquota_desc.gl_ver);
        __swab64s(&desc->lquota_desc.gl_hardlimit);
        __swab64s(&desc->lquota_desc.gl_softlimit);
-       CLASSERT(offsetof(typeof(desc->lquota_desc), gl_pad1) != 0);
+       __swab64s(&desc->lquota_desc.gl_time);
        CLASSERT(offsetof(typeof(desc->lquota_desc), gl_pad2) != 0);
 }
 
-void lustre_swab_lvb(union ldlm_wire_lvb *lvb)
+void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb)
 {
-        /* The ldlm_wire_lvb union represents all the possible LVB types.
-         * Unfortunately, there is no way to know what member of the union we
-         * are dealing with at this point. Therefore, all LVB structures must
-         * have fields of the same types, although used for different purposes
-         */
-        __swab64s(&lvb->l_ost.lvb_size);
-        __swab64s(&lvb->l_ost.lvb_mtime);
-        __swab64s(&lvb->l_ost.lvb_atime);
-        __swab64s(&lvb->l_ost.lvb_ctime);
-        __swab64s(&lvb->l_ost.lvb_blocks);
+       __swab64s(&lvb->lvb_size);
+       __swab64s(&lvb->lvb_mtime);
+       __swab64s(&lvb->lvb_atime);
+       __swab64s(&lvb->lvb_ctime);
+       __swab64s(&lvb->lvb_blocks);
+}
+EXPORT_SYMBOL(lustre_swab_ost_lvb_v1);
+
+void lustre_swab_ost_lvb(struct ost_lvb *lvb)
+{
+       __swab64s(&lvb->lvb_size);
+       __swab64s(&lvb->lvb_mtime);
+       __swab64s(&lvb->lvb_atime);
+       __swab64s(&lvb->lvb_ctime);
+       __swab64s(&lvb->lvb_blocks);
+       __swab32s(&lvb->lvb_mtime_ns);
+       __swab32s(&lvb->lvb_atime_ns);
+       __swab32s(&lvb->lvb_ctime_ns);
+       __swab32s(&lvb->lvb_padding);
+}
+EXPORT_SYMBOL(lustre_swab_ost_lvb);
+
+void lustre_swab_lquota_lvb(struct lquota_lvb *lvb)
+{
+       __swab64s(&lvb->lvb_flags);
+       __swab64s(&lvb->lvb_id_may_rel);
+       __swab64s(&lvb->lvb_id_rel);
+       __swab64s(&lvb->lvb_id_qunit);
+       __swab64s(&lvb->lvb_pad1);
 }
-EXPORT_SYMBOL(lustre_swab_lvb);
+EXPORT_SYMBOL(lustre_swab_lquota_lvb);
 
 void lustre_swab_mdt_body (struct mdt_body *b)
 {
-        lustre_swab_lu_fid (&b->fid1);
-        lustre_swab_lu_fid (&b->fid2);
-        /* handle is opaque */
-        __swab64s (&b->valid);
-        __swab64s (&b->size);
-        __swab64s (&b->mtime);
-        __swab64s (&b->atime);
-        __swab64s (&b->ctime);
-        __swab64s (&b->blocks);
-        __swab64s (&b->ioepoch);
-        __swab64s (&b->ino);
-        __swab32s (&b->fsuid);
-        __swab32s (&b->fsgid);
-        __swab32s (&b->capability);
-        __swab32s (&b->mode);
-        __swab32s (&b->uid);
-        __swab32s (&b->gid);
-        __swab32s (&b->flags);
-        __swab32s (&b->rdev);
-        __swab32s (&b->nlink);
-        __swab32s (&b->generation);
-        __swab32s (&b->suppgid);
-        __swab32s (&b->eadatasize);
-        __swab32s (&b->aclsize);
-        __swab32s (&b->max_mdsize);
-        __swab32s (&b->max_cookiesize);
-        __swab32s (&b->uid_h);
-        __swab32s (&b->gid_h);
-        CLASSERT(offsetof(typeof(*b), padding_5) != 0);
+       lustre_swab_lu_fid(&b->fid1);
+       lustre_swab_lu_fid(&b->fid2);
+       /* handle is opaque */
+       __swab64s(&b->valid);
+       __swab64s(&b->size);
+       __swab64s(&b->mtime);
+       __swab64s(&b->atime);
+       __swab64s(&b->ctime);
+       __swab64s(&b->blocks);
+       __swab64s(&b->ioepoch);
+       __swab64s(&b->t_state);
+       __swab32s(&b->fsuid);
+       __swab32s(&b->fsgid);
+       __swab32s(&b->capability);
+       __swab32s(&b->mode);
+       __swab32s(&b->uid);
+       __swab32s(&b->gid);
+       __swab32s(&b->flags);
+       __swab32s(&b->rdev);
+       __swab32s(&b->nlink);
+       CLASSERT(offsetof(typeof(*b), unused2) != 0);
+       __swab32s(&b->suppgid);
+       __swab32s(&b->eadatasize);
+       __swab32s(&b->aclsize);
+       __swab32s(&b->max_mdsize);
+       __swab32s(&b->max_cookiesize);
+       __swab32s(&b->uid_h);
+       __swab32s(&b->gid_h);
+       CLASSERT(offsetof(typeof(*b), padding_5) != 0);
 }
 EXPORT_SYMBOL(lustre_swab_mdt_body);
 
@@ -2049,30 +2069,30 @@ EXPORT_SYMBOL(lustre_swab_lip_header);
 
 void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr)
 {
-        __swab32s (&rr->rr_opcode);
-        __swab32s (&rr->rr_cap);
-        __swab32s (&rr->rr_fsuid);
-        /* rr_fsuid_h is unused */
-        __swab32s (&rr->rr_fsgid);
-        /* rr_fsgid_h is unused */
-        __swab32s (&rr->rr_suppgid1);
-        /* rr_suppgid1_h is unused */
-        __swab32s (&rr->rr_suppgid2);
-        /* rr_suppgid2_h is unused */
-        lustre_swab_lu_fid (&rr->rr_fid1);
-        lustre_swab_lu_fid (&rr->rr_fid2);
-        __swab64s (&rr->rr_mtime);
-        __swab64s (&rr->rr_atime);
-        __swab64s (&rr->rr_ctime);
-        __swab64s (&rr->rr_size);
-        __swab64s (&rr->rr_blocks);
-        __swab32s (&rr->rr_bias);
-        __swab32s (&rr->rr_mode);
-        __swab32s (&rr->rr_flags);
-
-        CLASSERT(offsetof(typeof(*rr), rr_padding_2) != 0);
-        CLASSERT(offsetof(typeof(*rr), rr_padding_3) != 0);
-        CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0);
+       __swab32s(&rr->rr_opcode);
+       __swab32s(&rr->rr_cap);
+       __swab32s(&rr->rr_fsuid);
+       /* rr_fsuid_h is unused */
+       __swab32s(&rr->rr_fsgid);
+       /* rr_fsgid_h is unused */
+       __swab32s(&rr->rr_suppgid1);
+       /* rr_suppgid1_h is unused */
+       __swab32s(&rr->rr_suppgid2);
+       /* rr_suppgid2_h is unused */
+       lustre_swab_lu_fid(&rr->rr_fid1);
+       lustre_swab_lu_fid(&rr->rr_fid2);
+       __swab64s(&rr->rr_mtime);
+       __swab64s(&rr->rr_atime);
+       __swab64s(&rr->rr_ctime);
+       __swab64s(&rr->rr_size);
+       __swab64s(&rr->rr_blocks);
+       __swab32s(&rr->rr_bias);
+       __swab32s(&rr->rr_mode);
+       __swab32s(&rr->rr_flags);
+       __swab32s(&rr->rr_flags_h);
+       __swab32s(&rr->rr_umask);
+
+       CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0);
 };
 EXPORT_SYMBOL(lustre_swab_mdt_rec_reint);
 
@@ -2100,40 +2120,57 @@ void lustre_swab_lmv_desc (struct lmv_desc *ld)
         /* uuid endian insensitive */
 }
 
-void lustre_swab_lmv_stripe_md (struct lmv_stripe_md *mea)
+void lustre_swab_lmv_user_md(struct lmv_user_md *lum)
 {
-        __swab32s(&mea->mea_magic);
-        __swab32s(&mea->mea_count);
-        __swab32s(&mea->mea_master);
-        CLASSERT(offsetof(typeof(*mea), mea_padding) != 0);
-}
+       int i;
 
+       __swab32s(&lum->lum_magic);
+       __swab32s(&lum->lum_stripe_count);
+       __swab32s(&lum->lum_stripe_offset);
+       __swab32s(&lum->lum_hash_type);
+       __swab32s(&lum->lum_type);
+       CLASSERT(offsetof(typeof(*lum), lum_padding1) != 0);
+       CLASSERT(offsetof(typeof(*lum), lum_padding2) != 0);
+       CLASSERT(offsetof(typeof(*lum), lum_padding3) != 0);
+
+       for (i = 0; i < lum->lum_stripe_count; i++) {
+               __swab32s(&lum->lum_objects[i].lum_mds);
+               lustre_swab_lu_fid(&lum->lum_objects[i].lum_fid);
+       }
+
+}
+EXPORT_SYMBOL(lustre_swab_lmv_user_md);
 
 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_seq);
-        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/lmm_layout_gen: %#x\n",
-               lum->u.lum_stripe_offset);
+       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", lmm_oi_id(&lum->lmm_oi));
+       CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lmm_oi_seq(&lum->lmm_oi));
+       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/lmm_layout_gen: %#x\n",
+                       lum->lmm_stripe_offset);
+}
+
+static void lustre_swab_lmm_oi(struct ost_id *oi)
+{
+       __swab64s(&oi->oi.oi_id);
+       __swab64s(&oi->oi.oi_seq);
 }
 
 static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
 {
-        ENTRY;
-        __swab32s(&lum->lmm_magic);
-        __swab32s(&lum->lmm_pattern);
-        __swab64s(&lum->lmm_object_id);
-        __swab64s(&lum->lmm_object_seq);
-        __swab32s(&lum->lmm_stripe_size);
-        __swab16s(&lum->lmm_stripe_count);
-        __swab16s(&lum->u.lum_stripe_offset);
-        print_lum(lum);
-        EXIT;
+       ENTRY;
+       __swab32s(&lum->lmm_magic);
+       __swab32s(&lum->lmm_pattern);
+       lustre_swab_lmm_oi(&lum->lmm_oi);
+       __swab32s(&lum->lmm_stripe_size);
+       __swab16s(&lum->lmm_stripe_count);
+       __swab16s(&lum->lmm_stripe_offset);
+       print_lum(lum);
+       EXIT;
 }
 
 void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum)
@@ -2157,16 +2194,15 @@ EXPORT_SYMBOL(lustre_swab_lov_user_md_v3);
 
 void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
 {
-        ENTRY;
-        CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
-        __swab32s(&lmm->lmm_magic);
-        __swab32s(&lmm->lmm_pattern);
-        __swab64s(&lmm->lmm_object_id);
-        __swab64s(&lmm->lmm_object_seq);
-        __swab32s(&lmm->lmm_stripe_size);
-        __swab16s(&lmm->lmm_stripe_count);
-        __swab16s(&lmm->lmm_layout_gen);
-        EXIT;
+       ENTRY;
+       CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
+       __swab32s(&lmm->lmm_magic);
+       __swab32s(&lmm->lmm_pattern);
+       lustre_swab_lmm_oi(&lmm->lmm_oi);
+       __swab32s(&lmm->lmm_stripe_size);
+       __swab16s(&lmm->lmm_stripe_count);
+       __swab16s(&lmm->lmm_layout_gen);
+       EXIT;
 }
 EXPORT_SYMBOL(lustre_swab_lov_mds_md);
 
@@ -2176,8 +2212,7 @@ void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
         int i;
         ENTRY;
         for (i = 0; i < stripe_count; i++) {
-                __swab64s(&(lod[i].l_object_id));
-                __swab64s(&(lod[i].l_object_seq));
+                lustre_swab_ost_id(&(lod[i].l_ost_oi));
                 __swab32s(&(lod[i].l_ost_gen));
                 __swab32s(&(lod[i].l_ost_idx));
         }
@@ -2250,16 +2285,6 @@ void lustre_swab_ldlm_reply (struct ldlm_reply *r)
 }
 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
 
-/* no one calls this */
-int llog_log_swabbed(struct llog_log_hdr *hdr)
-{
-        if (hdr->llh_hdr.lrh_type == __swab32(LLOG_HDR_MAGIC))
-                return 1;
-        if (hdr->llh_hdr.lrh_type == LLOG_HDR_MAGIC)
-                return 0;
-        return -1;
-}
-
 void lustre_swab_quota_body(struct quota_body *b)
 {
        lustre_swab_lu_fid(&b->qb_fid);
@@ -2273,10 +2298,10 @@ void lustre_swab_quota_body(struct quota_body *b)
 /* Dump functions */
 void dump_ioo(struct obd_ioobj *ioo)
 {
-        CDEBUG(D_RPCTRACE,
-               "obd_ioobj: ioo_id="LPD64", ioo_seq="LPD64", ioo_type=%d, "
-               "ioo_bufct=%d\n", ioo->ioo_id, ioo->ioo_seq, ioo->ioo_type,
-               ioo->ioo_bufcnt);
+       CDEBUG(D_RPCTRACE,
+              "obd_ioobj: ioo_oid="DOSTID", ioo_max_brw=%#x, "
+              "ioo_bufct=%d\n", POSTID(&ioo->ioo_oid), ioo->ioo_max_brw,
+              ioo->ioo_bufcnt);
 }
 EXPORT_SYMBOL(dump_ioo);
 
@@ -2289,16 +2314,14 @@ EXPORT_SYMBOL(dump_rniobuf);
 
 void dump_obdo(struct obdo *oa)
 {
-        __u32 valid = oa->o_valid;
+       __u32 valid = oa->o_valid;
 
-        CDEBUG(D_RPCTRACE, "obdo: o_valid = %08x\n", valid);
-        if (valid & OBD_MD_FLID)
-                CDEBUG(D_RPCTRACE, "obdo: o_id = "LPD64"\n", oa->o_id);
-        if (valid & OBD_MD_FLGROUP)
-                CDEBUG(D_RPCTRACE, "obdo: o_seq = "LPD64"\n", oa->o_seq);
-        if (valid & OBD_MD_FLFID)
-                CDEBUG(D_RPCTRACE, "obdo: o_parent_seq = "LPX64"\n",
-                       oa->o_parent_seq);
+       CDEBUG(D_RPCTRACE, "obdo: o_valid = %08x\n", valid);
+       if (valid & OBD_MD_FLID)
+               CDEBUG(D_RPCTRACE, "obdo: id = "DOSTID"\n", POSTID(&oa->o_oi));
+       if (valid & OBD_MD_FLFID)
+               CDEBUG(D_RPCTRACE, "obdo: o_parent_seq = "LPX64"\n",
+                      oa->o_parent_seq);
         if (valid & OBD_MD_FLSIZE)
                 CDEBUG(D_RPCTRACE, "obdo: o_size = "LPD64"\n", oa->o_size);
         if (valid & OBD_MD_FLMTIME)
@@ -2435,6 +2458,7 @@ void _debug_req(struct ptlrpc_request *req,
                            rep_ok ? lustre_msg_get_flags(req->rq_repmsg) : -1,
                            req->rq_status,
                            rep_ok ? lustre_msg_get_status(req->rq_repmsg) : -1);
+       va_end(args);
 }
 EXPORT_SYMBOL(_debug_req);
 
@@ -2459,40 +2483,126 @@ void lustre_swab_lustre_capa_key(struct lustre_capa_key *k)
 }
 EXPORT_SYMBOL(lustre_swab_lustre_capa_key);
 
-void lustre_swab_hsm_state(struct hsm_state_set_ioc *hssi)
+void lustre_swab_hsm_user_state(struct hsm_user_state *state)
 {
-        lustre_swab_lu_fid(&hssi->hssi_fid);
-        __swab64s(&hssi->hssi_setmask);
-        __swab64s(&hssi->hssi_clearmask);
+       __swab32s(&state->hus_states);
+       __swab32s(&state->hus_archive_id);
 }
-EXPORT_SYMBOL(lustre_swab_hsm_state);
+EXPORT_SYMBOL(lustre_swab_hsm_user_state);
 
-void lustre_swab_hsm_user_request(struct hsm_user_request *hur)
+void lustre_swab_hsm_state_set(struct hsm_state_set *hss)
 {
-        int i;
+       __swab32s(&hss->hss_valid);
+       __swab64s(&hss->hss_setmask);
+       __swab64s(&hss->hss_clearmask);
+       __swab32s(&hss->hss_archive_id);
+}
+EXPORT_SYMBOL(lustre_swab_hsm_state_set);
 
-        __swab32s(&hur->hur_action);
-        __swab32s(&hur->hur_itemcount);
-        __swab32s(&hur->hur_data_len);
-        for (i = 0; i < hur->hur_itemcount; i++) {
-                struct hsm_user_item *hui = &hur->hur_user_item[i];
-                lustre_swab_lu_fid(&hui->hui_fid);
-                __swab64s(&hui->hui_extent.offset);
-                __swab64s(&hui->hui_extent.length);
-        }
-        /* Note: data blob is not swabbed here */
+void lustre_swab_hsm_extent(struct hsm_extent *extent)
+{
+       __swab64s(&extent->offset);
+       __swab64s(&extent->length);
 }
-EXPORT_SYMBOL(lustre_swab_hsm_user_request);
 
-void lustre_swab_hsm_progress(struct hsm_progress *hp)
+void lustre_swab_hsm_current_action(struct hsm_current_action *action)
 {
-        lustre_swab_lu_fid(&hp->hp_fid);
-        __swab64s(&hp->hp_cookie);
-        __swab64s(&hp->hp_extent.offset);
-        __swab64s(&hp->hp_extent.length);
-        __swab16s(&hp->hp_flags);
-        __swab16s(&hp->hp_errval);
+       __swab32s(&action->hca_state);
+       __swab32s(&action->hca_action);
+       lustre_swab_hsm_extent(&action->hca_location);
 }
-EXPORT_SYMBOL(lustre_swab_hsm_progress);
+EXPORT_SYMBOL(lustre_swab_hsm_current_action);
 
+void lustre_swab_hsm_user_item(struct hsm_user_item *hui)
+{
+       lustre_swab_lu_fid(&hui->hui_fid);
+       lustre_swab_hsm_extent(&hui->hui_extent);
+}
+EXPORT_SYMBOL(lustre_swab_hsm_user_item);
+
+void lustre_swab_layout_intent(struct layout_intent *li)
+{
+       __swab32s(&li->li_opc);
+       __swab32s(&li->li_flags);
+       __swab64s(&li->li_start);
+       __swab64s(&li->li_end);
+}
+EXPORT_SYMBOL(lustre_swab_layout_intent);
+
+void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk)
+{
+       lustre_swab_lu_fid(&hpk->hpk_fid);
+       __swab64s(&hpk->hpk_cookie);
+       __swab64s(&hpk->hpk_extent.offset);
+       __swab64s(&hpk->hpk_extent.length);
+       __swab16s(&hpk->hpk_flags);
+       __swab16s(&hpk->hpk_errval);
+}
+EXPORT_SYMBOL(lustre_swab_hsm_progress_kernel);
 
+void lustre_swab_hsm_request(struct hsm_request *hr)
+{
+       __swab32s(&hr->hr_action);
+       __swab32s(&hr->hr_archive_id);
+       __swab64s(&hr->hr_flags);
+       __swab32s(&hr->hr_itemcount);
+       __swab32s(&hr->hr_data_len);
+}
+EXPORT_SYMBOL(lustre_swab_hsm_request);
+
+void lustre_swab_update_buf(struct update_buf *ub)
+{
+       __swab32s(&ub->ub_magic);
+       __swab32s(&ub->ub_count);
+}
+EXPORT_SYMBOL(lustre_swab_update_buf);
+
+void lustre_swab_update_reply_buf(struct update_reply *ur)
+{
+       int i;
+
+       __swab32s(&ur->ur_version);
+       __swab32s(&ur->ur_count);
+       for (i = 0; i < ur->ur_count; i++)
+               __swab32s(&ur->ur_lens[i]);
+}
+EXPORT_SYMBOL(lustre_swab_update_reply_buf);
+
+void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl)
+{
+       __swab64s(&msl->msl_flags);
+}
+EXPORT_SYMBOL(lustre_swab_swap_layouts);
+
+void lustre_swab_close_data(struct close_data *cd)
+{
+       lustre_swab_lu_fid(&cd->cd_fid);
+       __swab64s(&cd->cd_data_version);
+}
+EXPORT_SYMBOL(lustre_swab_close_data);
+
+void lustre_swab_lfsck_request(struct lfsck_request *lr)
+{
+       __swab32s(&lr->lr_event);
+       __swab32s(&lr->lr_index);
+       __swab32s(&lr->lr_flags);
+       __swab32s(&lr->lr_valid);
+       __swab32s(&lr->lr_speed);
+       __swab16s(&lr->lr_version);
+       __swab16s(&lr->lr_active);
+       __swab16s(&lr->lr_param);
+       __swab16s(&lr->lr_async_windows);
+       CLASSERT(offsetof(typeof(*lr), lr_padding_1) != 0);
+       lustre_swab_lu_fid(&lr->lr_fid);
+       CLASSERT(offsetof(typeof(*lr), lr_padding_2) != 0);
+       CLASSERT(offsetof(typeof(*lr), lr_padding_3) != 0);
+}
+EXPORT_SYMBOL(lustre_swab_lfsck_request);
+
+void lustre_swab_lfsck_reply(struct lfsck_reply *lr)
+{
+       __swab32s(&lr->lr_status);
+       CLASSERT(offsetof(typeof(*lr), lr_padding_1) != 0);
+       CLASSERT(offsetof(typeof(*lr), lr_padding_2) != 0);
+}
+EXPORT_SYMBOL(lustre_swab_lfsck_reply);