X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flov%2Flov_pack.c;h=4f65c2ab17f1cd7f8e3a68e24b8258c312f896c0;hb=e55771f4b498416db9abc975207808ccb30df74c;hp=1b40327bd0492542b0f9d69fcb69ecf436ed06f2;hpb=ff17cc7e0282d9b1522810e0c5d12171c4d46a2d;p=fs%2Flustre-release.git diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index 1b40327..4f65c2a 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -22,7 +22,9 @@ * (Un)packing of OST/MDS requests * */ - +#ifndef EXPORT_SYMTAB +# define EXPORT_SYMTAB +#endif #define DEBUG_SUBSYSTEM S_LOV #ifndef __KERNEL__ #include @@ -33,7 +35,7 @@ #include #include #include -#include +#include #include "lov_internal.h" @@ -106,7 +108,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, if (lsm) { if (lsm->lsm_magic != LOV_MAGIC) { - CERROR("bad mem LOV MAGIC: 0x%08X != 0x%08X\n", + CWARN("bad LOV MAGIC: 0x%08X != 0x%08X\n", lsm->lsm_magic, LOV_MAGIC); RETURN(-EINVAL); } @@ -186,7 +188,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 +240,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,7 +297,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 = PTL_MTU * stripe_count; + (*lsmp)->lsm_xfersize = PTLRPC_MAX_BRW_SIZE * stripe_count; (*lsmp)->lsm_pattern = pattern; (*lsmp)->lsm_oinfo[0].loi_ost_idx = ~0; @@ -304,12 +306,14 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, int pattern) return lsm_size; } +EXPORT_SYMBOL(lov_alloc_memmd); void lov_free_memmd(struct lov_stripe_md **lsmp) { OBD_FREE(*lsmp, lov_stripe_md_size((*lsmp)->lsm_stripe_count)); *lsmp = NULL; } +EXPORT_SYMBOL(lov_free_memmd); int lov_unpackmd_v0(struct lov_obd *lov, struct lov_stripe_md *lsm, struct lov_mds_md_v0 *lmm) @@ -366,7 +370,7 @@ int lov_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, loi->loi_gr = le64_to_cpu(lmm->lmm_objects[i].l_object_gr); loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx); loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen); - if (loi->loi_ost_idx > lov->desc.ld_tgt_count) { + if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) { CERROR("OST index %d more than OST count %d\n", loi->loi_ost_idx, lov->desc.ld_tgt_count); lov_dump_lmm_v1(D_WARNING, lmm); @@ -505,7 +509,7 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp, } int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, - struct lov_user_md *lump) + struct lov_user_md *lump) { int i; int rc; @@ -516,25 +520,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; } @@ -578,7 +583,8 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, /* User wasn't expecting this many OST entries */ if (lum.lmm_stripe_count == 0) { - if (copy_to_user(lump, lmmk, sizeof(lum))) + rc = copy_to_user(lump, lmmk, sizeof(lum)); + if (rc) rc = -EFAULT; } else if (lum.lmm_stripe_count < lmmk->lmm_stripe_count) { rc = -EOVERFLOW;