X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flod%2Flod_lov.c;h=fefa3c72bd79d1e0e07890421ca54e0e9e9f2c11;hb=db57d4cb311b5987f1006d4284e3bd10399ae4bb;hp=d477c88cf5e12d47ff2372bedd20511d53229130;hpb=cee1ab3997d70ee5eeece41b50fbe4479eda9d14;p=fs%2Flustre-release.git diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index d477c88..fefa3c7 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -243,8 +243,7 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod, OBD_CONNECT_MDS_MDS | OBD_CONNECT_FID | OBD_CONNECT_AT | - OBD_CONNECT_FULL20 | - OBD_CONNECT_PINGLESS; + OBD_CONNECT_FULL20; /* XXX set MDS-MDS flags, remove this when running this * on client*/ data->ocd_connect_flags |= OBD_CONNECT_MDS_MDS; @@ -266,7 +265,7 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod, } LASSERT(obd->obd_lu_dev); - LASSERT(obd->obd_lu_dev->ld_site = lod->lod_dt_dev.dd_lu_dev.ld_site); + LASSERT(obd->obd_lu_dev->ld_site == lod->lod_dt_dev.dd_lu_dev.ld_site); ldev = obd->obd_lu_dev; d = lu2dt_dev(ldev); @@ -501,6 +500,7 @@ int lod_generate_and_set_lovea(const struct lu_env *env, struct lov_ost_data_v1 *objs; __u32 magic; int i, rc, lmm_size; + int cplen = 0; ENTRY; LASSERT(lo); @@ -518,8 +518,8 @@ int lod_generate_and_set_lovea(const struct lu_env *env, lmm->lmm_magic = cpu_to_le32(magic); lmm->lmm_pattern = cpu_to_le32(LOV_PATTERN_RAID0); - lmm->lmm_object_id = cpu_to_le64(fid_ver_oid(fid)); - lmm->lmm_object_seq = cpu_to_le64(fid_seq(fid)); + fid_to_lmm_oi(fid, &lmm->lmm_oi); + lmm_oi_cpu_to_le(&lmm->lmm_oi, &lmm->lmm_oi); lmm->lmm_stripe_size = cpu_to_le32(lo->ldo_stripe_size); lmm->lmm_stripe_count = cpu_to_le16(lo->ldo_stripenr); lmm->lmm_layout_gen = 0; @@ -527,7 +527,10 @@ int lod_generate_and_set_lovea(const struct lu_env *env, objs = &lmm->lmm_objects[0]; } else { struct lov_mds_md_v3 *v3 = (struct lov_mds_md_v3 *) lmm; - strncpy(v3->lmm_pool_name, lo->ldo_pool, LOV_MAXPOOLNAME); + cplen = strlcpy(v3->lmm_pool_name, lo->ldo_pool, + sizeof(v3->lmm_pool_name)); + if (cplen >= sizeof(v3->lmm_pool_name)) + RETURN(-E2BIG); objs = &v3->lmm_objects[0]; } @@ -540,11 +543,10 @@ int lod_generate_and_set_lovea(const struct lu_env *env, LASSERT(lo->ldo_stripe[i]); fid = lu_object_fid(&lo->ldo_stripe[i]->do_lu); - rc = fid_ostid_pack(fid, &info->lti_ostid); + rc = fid_to_ostid(fid, &info->lti_ostid); LASSERT(rc == 0); - objs[i].l_object_id = cpu_to_le64(info->lti_ostid.oi_id); - objs[i].l_object_seq = cpu_to_le64(info->lti_ostid.oi_seq); + ostid_cpu_to_le(&info->lti_ostid, &objs[i].l_ost_oi); objs[i].l_ost_gen = cpu_to_le32(0); rc = lod_fld_lookup(env, lod, fid, &index, LU_SEQ_RANGE_OST); if (rc < 0) { @@ -613,6 +615,7 @@ int lod_store_def_striping(const struct lu_env *env, struct dt_object *dt, struct dt_object *next = dt_object_child(dt); struct lov_user_md_v3 *v3; int rc; + int cplen = 0; ENTRY; LASSERT(S_ISDIR(dt->do_lu.lo_header->loh_attr)); @@ -637,13 +640,17 @@ int lod_store_def_striping(const struct lu_env *env, struct dt_object *dt, v3->lmm_magic = cpu_to_le32(LOV_MAGIC_V3); v3->lmm_pattern = cpu_to_le32(LOV_PATTERN_RAID0); - v3->lmm_object_id = 0; - v3->lmm_object_seq = 0; v3->lmm_stripe_size = cpu_to_le32(lo->ldo_def_stripe_size); v3->lmm_stripe_count = cpu_to_le16(lo->ldo_def_stripenr); v3->lmm_stripe_offset = cpu_to_le16(lo->ldo_def_stripe_offset); - if (lo->ldo_pool) - strncpy(v3->lmm_pool_name, lo->ldo_pool, LOV_MAXPOOLNAME); + if (lo->ldo_pool) { + cplen = strlcpy(v3->lmm_pool_name, lo->ldo_pool, + sizeof(v3->lmm_pool_name)); + if (cplen >= sizeof(v3->lmm_pool_name)) { + OBD_FREE_PTR(v3); + RETURN(-E2BIG); + } + } info->lti_buf.lb_buf = v3; info->lti_buf.lb_len = sizeof(*v3); @@ -666,7 +673,9 @@ int lod_initialize_objects(const struct lu_env *env, struct lod_object *lo, struct lod_device *md = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev); struct lu_object *o, *n; struct lu_device *nd; - int i, idx, rc = 0; + struct dt_object **stripe; + int stripe_len; + int i, idx, rc = 0; ENTRY; LASSERT(lo); @@ -674,17 +683,17 @@ int lod_initialize_objects(const struct lu_env *env, struct lod_object *lo, LASSERT(lo->ldo_stripenr > 0); LASSERT(lo->ldo_stripe_size > 0); - i = sizeof(struct dt_object *) * lo->ldo_stripenr; - OBD_ALLOC(lo->ldo_stripe, i); - if (lo->ldo_stripe == NULL) - GOTO(out, rc = -ENOMEM); - lo->ldo_stripes_allocated = lo->ldo_stripenr; + stripe_len = lo->ldo_stripenr; + OBD_ALLOC(stripe, sizeof(stripe[0]) * stripe_len); + if (stripe == NULL) + RETURN(-ENOMEM); for (i = 0; i < lo->ldo_stripenr; i++) { - info->lti_ostid.oi_id = le64_to_cpu(objs[i].l_object_id); - info->lti_ostid.oi_seq = le64_to_cpu(objs[i].l_object_seq); + ostid_le_to_cpu(&objs[i].l_ost_oi, &info->lti_ostid); idx = le64_to_cpu(objs[i].l_ost_idx); - fid_ostid_unpack(&info->lti_fid, &info->lti_ostid, idx); + rc = ostid_to_fid(&info->lti_fid, &info->lti_ostid, idx); + if (rc != 0) + GOTO(out, rc); LASSERTF(fid_is_sane(&info->lti_fid), ""DFID" insane!\n", PFID(&info->lti_fid)); /* @@ -710,10 +719,21 @@ int lod_initialize_objects(const struct lu_env *env, struct lod_object *lo, n = lu_object_locate(o->lo_header, nd->ld_type); LASSERT(n); - lo->ldo_stripe[i] = container_of(n, struct dt_object, do_lu); + stripe[i] = container_of(n, struct dt_object, do_lu); } out: + if (rc != 0) { + for (i = 0; i < stripe_len; i++) + if (stripe[i] != NULL) + lu_object_put(env, &stripe[i]->do_lu); + + OBD_FREE(stripe, sizeof(stripe[0]) * stripe_len); + } else { + lo->ldo_stripe = stripe; + lo->ldo_stripes_allocated = stripe_len; + } + RETURN(rc); }