From 1ae726743b5a051bb4daa731d93496a3e7f7a93c Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 15 Jul 2014 09:12:00 -0500 Subject: [PATCH] LU-5342 lmv: fix some byte order issues In the handler for LL_IOC_LMV_GETSTRIPE convert stripe FIDs from little to CPU endian when unpacking lmv_user_md. In lmv_unpack_md_v1() fix a double conversion of the stripe count. In lustre_swab_lmv_user_md() do not convert stripe FIDs. Signed-off-by: John L. Hammond Change-Id: I0aa623a544c1b4d05a0ecf6ac99863c0e75daa54 Reviewed-on: http://review.whamcloud.com/11106 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/llite/dir.c | 8 ++++---- lustre/lmv/lmv_obd.c | 2 +- lustre/ptlrpc/pack_generic.c | 7 ------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 7a761b2..0233cce 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1261,15 +1261,15 @@ lmv_out_free: tmp->lum_stripe_count = 0; tmp->lum_stripe_offset = mdt_index; for (i = 0; i < stripe_count; i++) { - struct lu_fid *fid; + struct lu_fid fid; - fid = &lmm->lmv_md_v1.lmv_stripe_fids[i]; - mdt_index = ll_get_mdt_idx_by_fid(sbi, fid); + fid_le_to_cpu(&fid, &lmm->lmv_md_v1.lmv_stripe_fids[i]); + mdt_index = ll_get_mdt_idx_by_fid(sbi, &fid); if (mdt_index < 0) GOTO(out_tmp, rc = mdt_index); tmp->lum_objects[i].lum_mds = mdt_index; - tmp->lum_objects[i].lum_fid = *fid; + tmp->lum_objects[i].lum_fid = fid; tmp->lum_stripe_count++; } diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 8e9d844..5c452db 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -3036,7 +3036,7 @@ static int lmv_unpack_md_v1(struct obd_export *exp, struct lmv_stripe_md *lsm, lsm->lsm_md_layout_version); stripe_count = le32_to_cpu(lmm1->lmv_stripe_count); - for (i = 0; i < le32_to_cpu(stripe_count); i++) { + for (i = 0; i < stripe_count; i++) { fid_le_to_cpu(&lsm->lsm_md_oinfo[i].lmo_fid, &lmm1->lmv_stripe_fids[i]); rc = lmv_fld_lookup(lmv, &lsm->lsm_md_oinfo[i].lmo_fid, diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index c672cda..03515ca 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -2150,19 +2150,12 @@ EXPORT_SYMBOL(lustre_swab_lmv_mds_md); void lustre_swab_lmv_user_md(struct lmv_user_md *lum) { - 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); - 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); -- 1.8.3.1