X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Flmv%2Flmv_obd.c;h=ba1b6560399a06c4b99cbef4d38eba65bb28af7e;hp=9560c162e0d4a679a5728f9032ec613052a4392b;hb=002c2a80266b23c1df02d554fbdc7e5817c42d13;hpb=8d1895f2f69bd2eec3ff6af5eb356740fa2c8766 diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 9560c16..ba1b656 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -1462,6 +1462,7 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data, static struct lu_tgt_desc *lmv_locate_tgt_qos(struct lmv_obd *lmv, __u32 *mdt) { struct lu_tgt_desc *tgt, *cur = NULL; + __u64 total_avail = 0; __u64 total_weight = 0; __u64 cur_weight = 0; int total_usable = 0; @@ -1490,22 +1491,24 @@ static struct lu_tgt_desc *lmv_locate_tgt_qos(struct lmv_obd *lmv, __u32 *mdt) tgt->ltd_qos.ltq_usable = 1; lu_tgt_qos_weight_calc(tgt); - if (tgt->ltd_index == *mdt) { + if (tgt->ltd_index == *mdt) cur = tgt; - cur_weight = tgt->ltd_qos.ltq_weight; - } + total_avail += tgt->ltd_qos.ltq_avail; total_weight += tgt->ltd_qos.ltq_weight; total_usable++; } - /* if current MDT has higher-than-average space, stay on same MDT */ - rand = total_weight / total_usable; - if (cur_weight >= rand) { + /* if current MDT has above-average space, within range of the QOS + * threshold, stay on the same MDT to avoid creating needless remote + * MDT directories. + */ + rand = total_avail * (256 - lmv->lmv_qos.lq_threshold_rr) / + (total_usable * 256); + if (cur && cur->ltd_qos.ltq_avail >= rand) { tgt = cur; GOTO(unlock, rc = 0); } - cur_weight = 0; rand = lu_prandom_u64_max(total_weight); lmv_foreach_connected_tgt(lmv, tgt) {