int rc;
ENTRY;
+ if ((__swab32(lum->lmm_magic) & le32_to_cpu(LOV_MAGIC_MASK)) ==
+ le32_to_cpu(LOV_MAGIC_MAGIC)) {
+ /* this code will only exist for big-endian systems */
+ lustre_swab_lov_user_md(lum);
+ }
+
ll_inode_size_lock(inode);
rc = ll_intent_file_open(dentry, lum, lum_size, &oit);
if (rc < 0)
lmm->lmm_magic != cpu_to_le32(LOV_MAGIC_FOREIGN))
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 (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) {
- int stripe_count;
+ /*
+ * 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_MAGIC)) ==
+ __swab32(LOV_MAGIC_MAGIC)) {
+ int stripe_count = 0;
if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V1) ||
lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V3)) {
stripe_count = 0;
}
- /* if function called for directory - we should
- * avoid swab not existent lsm objects */
- if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) {
- lustre_swab_lov_user_md_v1(
- (struct lov_user_md_v1 *)lmm);
- if (S_ISREG(body->mbo_mode))
- lustre_swab_lov_user_md_objects(
- ((struct lov_user_md_v1 *)lmm)->lmm_objects,
- stripe_count);
- } else if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V3)) {
- lustre_swab_lov_user_md_v3(
- (struct lov_user_md_v3 *)lmm);
- if (S_ISREG(body->mbo_mode))
- lustre_swab_lov_user_md_objects(
- ((struct lov_user_md_v3 *)lmm)->lmm_objects,
- stripe_count);
- } else if (lmm->lmm_magic ==
- cpu_to_le32(LOV_MAGIC_COMP_V1)) {
- lustre_swab_lov_comp_md_v1(
- (struct lov_comp_md_v1 *)lmm);
- } else if (lmm->lmm_magic ==
- cpu_to_le32(LOV_MAGIC_FOREIGN)) {
- struct lov_foreign_md *lfm;
-
- lfm = (struct lov_foreign_md *)lmm;
- __swab32s(&lfm->lfm_magic);
- __swab32s(&lfm->lfm_length);
- __swab32s(&lfm->lfm_type);
- __swab32s(&lfm->lfm_flags);
- }
+ lustre_swab_lov_user_md((struct lov_user_md *)lmm);
+
+ /* if function called for directory - we should
+ * avoid swab not existent lsm objects */
+ if (lmm->lmm_magic == LOV_MAGIC_V1 && S_ISREG(body->mbo_mode))
+ lustre_swab_lov_user_md_objects(
+ ((struct lov_user_md_v1 *)lmm)->lmm_objects,
+ stripe_count);
+ else if (lmm->lmm_magic == LOV_MAGIC_V3 &&
+ S_ISREG(body->mbo_mode))
+ lustre_swab_lov_user_md_objects(
+ ((struct lov_user_md_v3 *)lmm)->lmm_objects,
+ stripe_count);
}
out:
cl_lov_delay_create_clear(&file->f_flags);
out:
- OBD_FREE(klum, lum_size);
+ OBD_FREE_LARGE(klum, lum_size);
RETURN(rc);
}