From 3bf72bc52c05beeeae0191576f2515b3119e4e10 Mon Sep 17 00:00:00 2001 From: anserper Date: Thu, 18 Sep 2008 21:50:36 +0000 Subject: [PATCH] Branch b1_8_gate b=16935 i=Johann Lombardi i=Alexey Lyashkov add V3 magic handling, fix swabbing --- lustre/llite/dir.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 1daf47d..8d6d123 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1265,21 +1265,27 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, if (rc) GOTO(free_lmm, rc = -EFAULT); - if (lmm->lmm_magic != LOV_USER_MAGIC) - GOTO(free_lmm, rc = -EINVAL); - - if (LOV_USER_MAGIC != cpu_to_le32(LOV_USER_MAGIC)) { - if (cpu_to_le32(LOV_USER_MAGIC_V1) == cpu_to_le32(lmm->lmm_magic)) { - lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lmm); + switch (lmm->lmm_magic) { + case LOV_USER_MAGIC_V1: + if (LOV_USER_MAGIC == cpu_to_le32(LOV_USER_MAGIC)) + break; + /* swab objects first so that stripes num will be sane */ lustre_swab_lov_user_md_objects( ((struct lov_user_md_v1 *)lmm)->lmm_objects, ((struct lov_user_md_v1 *)lmm)->lmm_stripe_count); - } else if (cpu_to_le32(LOV_USER_MAGIC_V3) == cpu_to_le32(lmm->lmm_magic)) { - lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm); + lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lmm); + break; + case LOV_USER_MAGIC_V3: + if (LOV_USER_MAGIC == cpu_to_le32(LOV_USER_MAGIC)) + break; + /* swab objects first so that stripes num will be sane */ lustre_swab_lov_user_md_objects( ((struct lov_user_md_v3 *)lmm)->lmm_objects, ((struct lov_user_md_v3 *)lmm)->lmm_stripe_count); - } + lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm); + break; + default: + GOTO(free_lmm, rc = -EINVAL); } rc = obd_unpackmd(sbi->ll_osc_exp, &lsm, lmm, lmmsize); -- 1.8.3.1