From c1bfad30e1853ac1f2a3755890a3c361e4f9e78c Mon Sep 17 00:00:00 2001 From: yangsheng Date: Wed, 29 Apr 2009 06:31:24 +0000 Subject: [PATCH] Branch b1_8 b=19276 i=johann, shadow, nathan Fixed the swab issue for PPC platform. --- lustre/lov/lov_pack.c | 9 ++++++++- lustre/ptlrpc/pack_generic.c | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index 7e07e34..fffd848 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -424,7 +424,8 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp, rc = copy_from_user(&lumv3, lump, sizeof(struct lov_user_md_v1)); if (rc) RETURN(-EFAULT); - if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) { + if ((lumv1->lmm_magic == LOV_USER_MAGIC_V3) || + (lumv1->lmm_magic == LOV_USER_MAGIC_V3_SWABBED)) { rc = copy_from_user(&lumv3, lump, sizeof(lumv3)); if (rc) RETURN(-EFAULT); @@ -638,6 +639,12 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, if (copy_to_user(lump, lmmk, lmm_size)) rc = -EFAULT; + /* Restore the LE endian to ensure obd_free_diskmd works well */ + if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) { + lmmk->lmm_stripe_count = lum.lmm_stripe_count; + lustre_swab_lov_mds_md(lmmk); + } + obd_free_diskmd(exp, &lmmk); RETURN(rc); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index bd26f7e..26d8104 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -2354,17 +2354,18 @@ void lustre_swab_lov_user_md_join(struct lov_user_md_join *lumj) int lustre_swab_lov_user_md_objects(struct lov_user_md *lum) { - int i, stripe_count = lum->lmm_stripe_count; + int i; + __u16 stripe_count = lum->lmm_stripe_count; struct lov_user_ost_data *lod; ENTRY; switch (lum->lmm_magic) { case LOV_USER_MAGIC_V1_SWABBED: - __swab32s(&stripe_count); + __swab16s(&stripe_count); case LOV_USER_MAGIC_V1: lod = lum->lmm_objects; break; case LOV_USER_MAGIC_V3_SWABBED: - __swab32s(&stripe_count); + __swab16s(&stripe_count); case LOV_USER_MAGIC_V3: lod = ((struct lov_user_md_v3 *)lum)->lmm_objects; break; -- 1.8.3.1