Whamcloud - gitweb
LU-9679 lustre: add OBD_ALLOC_PTR_ARRAY() and others
[fs/lustre-release.git] / lustre / utils / liblustreapi_layout.c
index e47b303..aefde5d 100644 (file)
@@ -135,11 +135,11 @@ llapi_layout_swab_lov_user_md(struct lov_user_md *lum, int lum_size)
                comp_v1 = (struct lov_comp_md_v1 *)lum;
 
        if (comp_v1 != NULL) {
-               __swab32s(&comp_v1->lcm_magic);
-               __swab32s(&comp_v1->lcm_size);
-               __swab32s(&comp_v1->lcm_layout_gen);
-               __swab16s(&comp_v1->lcm_flags);
-               __swab16s(&comp_v1->lcm_entry_count);
+               comp_v1->lcm_magic = __swab32(comp_v1->lcm_magic);
+               comp_v1->lcm_size = __swab32(comp_v1->lcm_size);
+               comp_v1->lcm_layout_gen = __swab32(comp_v1->lcm_layout_gen);
+               comp_v1->lcm_flags = __swab16(comp_v1->lcm_flags);
+               comp_v1->lcm_entry_count = __swab16(comp_v1->lcm_entry_count);
                ent_count = comp_v1->lcm_entry_count;
        } else {
                ent_count = 1;
@@ -148,13 +148,13 @@ llapi_layout_swab_lov_user_md(struct lov_user_md *lum, int lum_size)
        for (i = 0; i < ent_count; i++) {
                if (comp_v1 != NULL) {
                        ent = &comp_v1->lcm_entries[i];
-                       __swab32s(&ent->lcme_id);
-                       __swab32s(&ent->lcme_flags);
-                       __swab64s(&ent->lcme_timestamp);
-                       __swab64s(&ent->lcme_extent.e_start);
-                       __swab64s(&ent->lcme_extent.e_end);
-                       __swab32s(&ent->lcme_offset);
-                       __swab32s(&ent->lcme_size);
+                       ent->lcme_id = __swab32(ent->lcme_id);
+                       ent->lcme_flags = __swab32(ent->lcme_flags);
+                       ent->lcme_timestamp = __swab64(ent->lcme_timestamp);
+                       ent->lcme_extent.e_start = __swab64(ent->lcme_extent.e_start);
+                       ent->lcme_extent.e_end = __swab64(ent->lcme_extent.e_end);
+                       ent->lcme_offset = __swab32(ent->lcme_offset);
+                       ent->lcme_size = __swab32(ent->lcme_size);
 
                        lum = (struct lov_user_md *)((char *)comp_v1 +
                                        ent->lcme_offset);
@@ -162,11 +162,11 @@ llapi_layout_swab_lov_user_md(struct lov_user_md *lum, int lum_size)
                }
                obj_count = llapi_layout_objects_in_lum(lum, lum_size);
 
-               __swab32s(&lum->lmm_magic);
-               __swab32s(&lum->lmm_pattern);
-               __swab32s(&lum->lmm_stripe_size);
-               __swab16s(&lum->lmm_stripe_count);
-               __swab16s(&lum->lmm_stripe_offset);
+               lum->lmm_magic = __swab32(lum->lmm_magic);
+               lum->lmm_pattern = __swab32(lum->lmm_pattern);
+               lum->lmm_stripe_size = __swab32(lum->lmm_stripe_size);
+               lum->lmm_stripe_count = __swab16(lum->lmm_stripe_count);
+               lum->lmm_stripe_offset = __swab16(lum->lmm_stripe_offset);
 
                if (lum->lmm_magic != LOV_MAGIC_V1) {
                        struct lov_user_md_v3 *v3;
@@ -177,7 +177,7 @@ llapi_layout_swab_lov_user_md(struct lov_user_md *lum, int lum_size)
                }
 
                for (j = 0; j < obj_count; j++)
-                       __swab32s(&lod[j].l_ost_idx);
+                       lod[j].l_ost_idx = __swab32(lod[j].l_ost_idx);
        }
 }
 
@@ -549,8 +549,12 @@ struct llapi_layout *llapi_layout_get_by_xattr(void *lov_xattr,
                else if (v1->lmm_pattern == (LOV_PATTERN_RAID0 |
                                         LOV_PATTERN_OVERSTRIPING))
                        comp->llc_pattern = LLAPI_LAYOUT_OVERSTRIPING;
+               else if (v1->lmm_pattern == LOV_PATTERN_MDT)
+                       comp->llc_pattern = LLAPI_LAYOUT_MDT;
                else
-                       /* Lustre only supports RAID0 for now. */
+                       /* Lustre only supports RAID0, overstripping
+                        * and DoM for now.
+                        */
                        comp->llc_pattern = v1->lmm_pattern;
 
                if (v1->lmm_stripe_size == 0)
@@ -2935,7 +2939,7 @@ int llapi_mirror_resync_many(int fd, struct llapi_layout *layout,
                                 */
                                comp_array[i].lrc_synced = true;
                                llapi_error(LLAPI_MSG_ERROR, written,
-                                           "component %u not synced\n",
+                                           "component %u not synced",
                                            comp_array[i].lrc_id);
                                if (rc2 == 0)
                                        rc2 = (int)written;