Whamcloud - gitweb
LU-1866 misc: fix some issues found during LFSCK
[fs/lustre-release.git] / lustre / ptlrpc / pack_generic.c
index 9ac472d..6de2ad3 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, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -310,7 +310,6 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt)
 
        spin_unlock(&svcpt->scp_rep_lock);
 
-       LASSERT(rs != NULL);
        memset(rs, 0, svcpt->scp_service->srv_max_reply_size);
        rs->rs_svcpt = svcpt;
        rs->rs_prealloc = 1;
@@ -1829,24 +1828,43 @@ 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_lvb);
+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_lquota_lvb);
 
 void lustre_swab_mdt_body (struct mdt_body *b)
 {
@@ -1860,7 +1878,7 @@ void lustre_swab_mdt_body (struct mdt_body *b)
         __swab64s (&b->ctime);
         __swab64s (&b->blocks);
         __swab64s (&b->ioepoch);
-        __swab64s (&b->ino);
+       CLASSERT(offsetof(typeof(*b), unused1) != 0);
         __swab32s (&b->fsuid);
         __swab32s (&b->fsgid);
         __swab32s (&b->capability);
@@ -1870,7 +1888,7 @@ void lustre_swab_mdt_body (struct mdt_body *b)
         __swab32s (&b->flags);
         __swab32s (&b->rdev);
         __swab32s (&b->nlink);
-        __swab32s (&b->generation);
+       CLASSERT(offsetof(typeof(*b), unused2) != 0);
         __swab32s (&b->suppgid);
         __swab32s (&b->eadatasize);
         __swab32s (&b->aclsize);
@@ -2459,40 +2477,88 @@ 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);