From 50021977720a419f6df809ee43cdf687bc9f0877 Mon Sep 17 00:00:00 2001 From: Giuseppe Di Natale Date: Mon, 8 Jan 2018 08:50:39 -0800 Subject: [PATCH] LU-10462 lod: Correct lfs --component-add striping lfs --component-add -E -c -1 would apply the default stripe count to a file when it should be striping across all OSTs. This was due to incorrect handling of sentinel values in various portions of lod_object. Lustre-change: https://review.whamcloud.com/30790 Lustre-commit: b7285d387c78fbd11579c577230593ba1b0be84e Signed-off-by: Giuseppe Di Natale Change-Id: I178f13be81ee546f44edcdadcf7086a1a57f7e9a Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/31048 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond --- lustre/lod/lod_object.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 112768a..d66dd34 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -1046,6 +1046,18 @@ static int lod_attr_get(const struct lu_env *env, return dt_attr_get(env, dt_object_child(dt), attr); } +static inline void lod_adjust_stripe_info(struct lod_layout_component *comp, + struct lov_desc *desc) +{ + if (comp->llc_pattern != LOV_PATTERN_FIRST) { + if (!comp->llc_stripe_count) + comp->llc_stripe_count = + desc->ld_default_stripe_count; + } + if (comp->llc_stripe_size <= 0) + comp->llc_stripe_size = desc->ld_default_stripe_size; +} + int lod_obj_for_each_stripe(const struct lu_env *env, struct lod_object *lo, struct thandle *th, lod_obj_stripe_cb_t cb, struct lod_obj_stripe_cb_data *data) @@ -2262,14 +2274,8 @@ static int lod_declare_layout_add(const struct lu_env *env, lod_comp->llc_stripe_offset = v1->lmm_stripe_offset; lod_comp->llc_stripe_count = v1->lmm_stripe_count; - if (!lod_comp->llc_stripe_count || - lod_comp->llc_stripe_count == (__u16)-1) - lod_comp->llc_stripe_count = - desc->ld_default_stripe_count; lod_comp->llc_stripe_size = v1->lmm_stripe_size; - if (!lod_comp->llc_stripe_size) - lod_comp->llc_stripe_size = - desc->ld_default_stripe_size; + lod_adjust_stripe_info(lod_comp, desc); if (v1->lmm_magic == LOV_USER_MAGIC_V3) { v3 = (struct lov_user_md_v3 *) v1; @@ -3776,12 +3782,7 @@ static void lod_striping_from_default(struct lod_object *lo, if (!lo->ldo_is_composite) continue; - if (obj_comp->llc_stripe_count <= 0) - obj_comp->llc_stripe_count = - desc->ld_default_stripe_count; - if (obj_comp->llc_stripe_size <= 0) - obj_comp->llc_stripe_size = - desc->ld_default_stripe_size; + lod_adjust_stripe_info(obj_comp, desc); } } else if (lds->lds_dir_def_striping_set && S_ISDIR(mode)) { if (lo->ldo_dir_stripe_count == 0) @@ -4014,12 +4015,7 @@ out: LASSERT(!lc->ldo_is_composite); lod_comp = &lc->ldo_comp_entries[0]; desc = &d->lod_desc; - if (lod_comp->llc_stripe_count <= 0) - lod_comp->llc_stripe_count = - desc->ld_default_stripe_count; - if (lod_comp->llc_stripe_size <= 0) - lod_comp->llc_stripe_size = - desc->ld_default_stripe_size; + lod_adjust_stripe_info(lod_comp, desc); } EXIT; -- 1.8.3.1