X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flov%2Flov_pack.c;h=164bceca977252c152c694fcac9c5118b3f689ac;hb=7a7e17d4db28fac1ca4bc333d60cbeb8dbc530d6;hp=ef04e681c0441a58bd1869b12996cb64e7f1d470;hpb=30c3a18963d1d6d70175fbbbdd9554e1eb2fa40d;p=fs%2Flustre-release.git diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index ef04e68..164bcec 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include "lov_internal.h" @@ -186,7 +186,7 @@ static int lov_verify_lmm_v0(struct lov_mds_md_v0 *lmm, int lmm_bytes, if (lmm_bytes < lov_mds_md_v0_size(*stripe_count)) { CERROR("LOV EA too small: %d, need %d\n", - lmm_bytes, lov_mds_md_size(*stripe_count)); + lmm_bytes, lov_mds_md_v0_size(*stripe_count)); lov_dump_lmm_v0(D_WARNING, lmm); return -EINVAL; } @@ -238,9 +238,9 @@ static int lov_verify_lmm_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes, return -EINVAL; } - if (lmm_bytes < lov_mds_md_size(*stripe_count)) { + if (lmm_bytes < lov_mds_md_v1_size(*stripe_count)) { CERROR("LOV EA too small: %d, need %d\n", - lmm_bytes, lov_mds_md_size(*stripe_count)); + lmm_bytes, lov_mds_md_v1_size(*stripe_count)); lov_dump_lmm_v1(D_WARNING, lmm); return -EINVAL; } @@ -295,6 +295,7 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, int pattern) (*lsmp)->lsm_magic = LOV_MAGIC; (*lsmp)->lsm_stripe_count = stripe_count; (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES * stripe_count; + (*lsmp)->lsm_xfersize = PTLRPC_MAX_BRW_SIZE * stripe_count; (*lsmp)->lsm_pattern = pattern; (*lsmp)->lsm_oinfo[0].loi_ost_idx = ~0; @@ -319,6 +320,7 @@ int lov_unpackmd_v0(struct lov_obd *lov, struct lov_stripe_md *lsm, lsm->lsm_object_id = le64_to_cpu(lmm->lmm_object_id); /* lsm->lsm_object_gr = 0; implicit */ lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size); + lsm->lsm_xfersize = lsm->lsm_stripe_size * lsm->lsm_stripe_count; lsm->lsm_pattern = LOV_PATTERN_RAID0; ost_offset = le32_to_cpu(lmm->lmm_stripe_offset); ost_count = le16_to_cpu(lmm->lmm_ost_count); @@ -356,6 +358,7 @@ int lov_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, lsm->lsm_object_gr = le64_to_cpu(lmm->lmm_object_gr); lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size); lsm->lsm_pattern = le32_to_cpu(lmm->lmm_pattern); + lsm->lsm_xfersize = lsm->lsm_stripe_size * lsm->lsm_stripe_count; for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++) { /* XXX LOV STACKING call down to osc_unpackmd() */ @@ -496,6 +499,7 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp, (*lsmp)->lsm_oinfo[0].loi_ost_idx = lum.lmm_stripe_offset; (*lsmp)->lsm_stripe_size = lum.lmm_stripe_size; + (*lsmp)->lsm_xfersize = lum.lmm_stripe_size * stripe_count; RETURN(0); } @@ -512,25 +516,26 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, for (i = 0; i < lump->lmm_stripe_count; i++) { __u32 len = sizeof(last_id); oexp = lov->tgts[lump->lmm_objects[i].l_ost_idx].ltd_exp; - rc = obd_get_info(oexp, strlen("last_id"), "last_id", - &len, &last_id); + rc = obd_get_info(oexp, strlen("last_id"), "last_id", + &len, &last_id); if (rc) RETURN(rc); - if (last_id < lump->lmm_objects[i].l_object_id) { + if (lump->lmm_objects[i].l_object_id > last_id) { CERROR("Setting EA for object > than last id on " - "ost idx %d "LPD64" > "LPD64" \n", - lump->lmm_objects[i].l_ost_idx, - lump->lmm_objects[i].l_object_id, last_id); + "ost idx %d "LPD64" > "LPD64" \n", + lump->lmm_objects[i].l_ost_idx, + lump->lmm_objects[i].l_object_id, last_id); RETURN(-EINVAL); } } rc = lov_setstripe(exp, lsmp, lump); - if (rc) + if (rc) RETURN(rc); + for (i = 0; i < lump->lmm_stripe_count; i++) { - (*lsmp)->lsm_oinfo[i].loi_ost_idx = - lump->lmm_objects[i].l_ost_idx; + (*lsmp)->lsm_oinfo[i].loi_ost_idx = + lump->lmm_objects[i].l_ost_idx; (*lsmp)->lsm_oinfo[i].loi_id = lump->lmm_objects[i].l_object_id; (*lsmp)->lsm_oinfo[i].loi_gr = lump->lmm_objects[i].l_object_gr; } @@ -573,10 +578,14 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lmmk->lmm_objects[0])); /* User wasn't expecting this many OST entries */ - if (lum.lmm_stripe_count < lmmk->lmm_stripe_count) + if (lum.lmm_stripe_count == 0) { + if (copy_to_user(lump, lmmk, sizeof(lum))) + rc = -EFAULT; + } else if (lum.lmm_stripe_count < lmmk->lmm_stripe_count) { rc = -EOVERFLOW; - else if (copy_to_user(lump, lmmk, lmm_size)) + } else if (copy_to_user(lump, lmmk, lmm_size)) { rc = -EFAULT; + } obd_free_diskmd(exp, &lmmk);