X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Flod%2Flod_qos.c;h=f4a77835f0d38ee71b19c8b8a0f3dd545f9e6971;hp=b4f9f05703b6d21a786ecc8cc0499b160c969bb5;hb=dd15646cc557357af7f8751dd136293b12588ce4;hpb=ea957ca7fa0376accce0dd773cb627e0dba72312 diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index b4f9f05..f4a7783 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -65,17 +65,17 @@ static inline int lod_statfs_check(struct lu_tgt_descs *ltd, { struct obd_statfs *sfs = &tgt->ltd_statfs; - if (((sfs->os_state & OS_STATE_ENOSPC) || - (!ltd->ltd_is_mdt && sfs->os_state & OS_STATE_ENOINO && + if (((sfs->os_state & OS_STATFS_ENOSPC) || + (!ltd->ltd_is_mdt && sfs->os_state & OS_STATFS_ENOINO && sfs->os_fprecreated == 0))) return -ENOSPC; /* If the OST is readonly then we can't allocate objects there */ - if (sfs->os_state & OS_STATE_READONLY) + if (sfs->os_state & OS_STATFS_READONLY) return -EROFS; /* object precreation is skipped on the OST with max_create_count=0 */ - if (!ltd->ltd_is_mdt && sfs->os_state & OS_STATE_NOPRECREATE) + if (!ltd->ltd_is_mdt && sfs->os_state & OS_STATFS_NOPRECREATE) return -ENOBUFS; return 0; @@ -100,8 +100,9 @@ static inline int lod_statfs_check(struct lu_tgt_descs *ltd, */ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, struct lu_tgt_descs *ltd, - struct lu_tgt_desc *tgt) + struct lu_tgt_desc *tgt, __u64 reserve) { + struct obd_statfs_info info = { 0 }; struct lov_desc *desc = <d->ltd_lov_desc; int rc; ENTRY; @@ -109,7 +110,8 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, LASSERT(d); LASSERT(tgt); - rc = dt_statfs(env, tgt->ltd_tgt, &tgt->ltd_statfs); + info.os_enable_pre = 1; + rc = dt_statfs_info(env, tgt->ltd_tgt, &tgt->ltd_statfs, &info); if (rc && rc != -ENOTCONN) CERROR("%s: statfs: rc = %d\n", lod2obd(d)->obd_name, rc); @@ -119,6 +121,11 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, return rc; } + if (reserve && + (reserve + (info.os_reserved_mb_low << 20) > + tgt->ltd_statfs.os_bavail * tgt->ltd_statfs.os_bsize)) + return -ENOSPC; + /* check whether device has changed state (active, inactive) */ if (rc != 0 && tgt->ltd_active) { /* turned inactive? */ @@ -130,8 +137,8 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, LASSERT(desc->ld_active_tgt_count > 0); desc->ld_active_tgt_count--; - ltd->ltd_qos.lq_dirty = 1; - ltd->ltd_qos.lq_rr.lqr_dirty = 1; + set_bit(LQ_DIRTY, <d->ltd_qos.lq_flags); + set_bit(LQ_DIRTY, <d->ltd_qos.lq_rr.lqr_flags); CDEBUG(D_CONFIG, "%s: turns inactive\n", tgt->ltd_exp->exp_obd->obd_name); } @@ -146,8 +153,8 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, tgt->ltd_active = 1; tgt->ltd_connecting = 0; desc->ld_active_tgt_count++; - ltd->ltd_qos.lq_dirty = 1; - ltd->ltd_qos.lq_rr.lqr_dirty = 1; + set_bit(LQ_DIRTY, <d->ltd_qos.lq_flags); + set_bit(LQ_DIRTY, <d->ltd_qos.lq_rr.lqr_flags); CDEBUG(D_CONFIG, "%s: turns active\n", tgt->ltd_exp->exp_obd->obd_name); } @@ -211,12 +218,12 @@ void lod_qos_statfs_update(const struct lu_env *env, struct lod_device *lod, ltd_foreach_tgt(ltd, tgt) { avail = tgt->ltd_statfs.os_bavail; - if (lod_statfs_and_check(env, lod, ltd, tgt)) + if (lod_statfs_and_check(env, lod, ltd, tgt, 0)) continue; if (tgt->ltd_statfs.os_bavail != avail) /* recalculate weigths */ - ltd->ltd_qos.lq_dirty = 1; + set_bit(LQ_DIRTY, <d->ltd_qos.lq_flags); } obd->obd_osfs_age = ktime_get_seconds(); @@ -255,7 +262,7 @@ static int lod_qos_calc_rr(struct lod_device *lod, struct lu_tgt_descs *ltd, int rc; ENTRY; - if (!lqr->lqr_dirty) { + if (!test_bit(LQ_DIRTY, &lqr->lqr_flags)) { LASSERT(lqr->lqr_pool.op_size); RETURN(0); } @@ -267,7 +274,7 @@ static int lod_qos_calc_rr(struct lod_device *lod, struct lu_tgt_descs *ltd, * Check again. While we were sleeping on @lq_rw_sem something could * change. */ - if (!lqr->lqr_dirty) { + if (!test_bit(LQ_DIRTY, &lqr->lqr_flags)) { LASSERT(lqr->lqr_pool.op_size); up_write(<d->ltd_qos.lq_rw_sem); RETURN(0); @@ -296,8 +303,8 @@ static int lod_qos_calc_rr(struct lod_device *lod, struct lu_tgt_descs *ltd, for (i = 0; i < lqr->lqr_pool.op_count; i++) { int next; - if (!cfs_bitmap_check(ltd->ltd_tgt_bitmap, - src_pool->op_array[i])) + if (!test_bit(src_pool->op_array[i], + ltd->ltd_tgt_bitmap)) continue; tgt = LTD_TGT(ltd, src_pool->op_array[i]); @@ -316,7 +323,7 @@ static int lod_qos_calc_rr(struct lod_device *lod, struct lu_tgt_descs *ltd, } } - lqr->lqr_dirty = 0; + clear_bit(LQ_DIRTY, &lqr->lqr_flags); up_write(<d->ltd_qos.lq_rw_sem); if (placed != real_count) { @@ -328,7 +335,7 @@ static int lod_qos_calc_rr(struct lod_device *lod, struct lu_tgt_descs *ltd, LCONSOLE(D_WARNING, "rr #%d tgt idx=%d\n", i, lqr->lqr_pool.op_array[i]); } - lqr->lqr_dirty = 1; + set_bit(LQ_DIRTY, &lqr->lqr_flags); RETURN(-EAGAIN); } @@ -387,7 +394,7 @@ static struct dt_object *lod_qos_declare_object_on(const struct lu_env *env, */ o = lu_object_anon(env, nd, NULL); if (IS_ERR(o)) - GOTO(out, dt = ERR_PTR(PTR_ERR(o))); + GOTO(out, dt = ERR_CAST(o)); n = lu_object_locate(o->lo_header, nd->ld_type); if (unlikely(n == NULL)) { @@ -572,7 +579,7 @@ static inline bool lod_should_avoid_ost(struct lod_object *lo, bool used = false; int i; - if (!cfs_bitmap_check(lod->lod_ost_bitmap, index)) { + if (!test_bit(index, lod->lod_ost_bitmap)) { QOS_DEBUG("OST%d: been used in conflicting mirror component\n", index); return true; @@ -600,7 +607,7 @@ static inline bool lod_should_avoid_ost(struct lod_object *lo, return false; /* if the OSS has been used, check whether the OST has been used */ - if (!cfs_bitmap_check(lag->lag_ost_avoid_bitmap, index)) + if (!test_bit(index, lag->lag_ost_avoid_bitmap)) used = false; else QOS_DEBUG("OST%d: been used in conflicting mirror component\n", @@ -615,7 +622,8 @@ static int lod_check_and_reserve_ost(const struct lu_env *env, struct dt_object **stripe, __u32 *ost_indices, struct thandle *th, - bool *overstriped) + bool *overstriped, + __u64 reserve) { struct lod_device *lod = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev); struct lod_avoid_guide *lag = &lod_env_info(env)->lti_avoid; @@ -626,7 +634,7 @@ static int lod_check_and_reserve_ost(const struct lu_env *env, ENTRY; - rc = lod_statfs_and_check(env, lod, &lod->lod_ost_descs, ost); + rc = lod_statfs_and_check(env, lod, &lod->lod_ost_descs, ost, reserve); if (rc) RETURN(rc); @@ -642,7 +650,7 @@ static int lod_check_and_reserve_ost(const struct lu_env *env, /* * try to use another OSP if this one is degraded */ - if (ost->ltd_statfs.os_state & OS_STATE_DEGRADED && speed < 2) { + if (ost->ltd_statfs.os_state & OS_STATFS_DEGRADED && speed < 2) { QOS_DEBUG("#%d: degraded\n", ost_idx); RETURN(rc); } @@ -725,7 +733,8 @@ static int lod_check_and_reserve_ost(const struct lu_env *env, */ static int lod_ost_alloc_rr(const struct lu_env *env, struct lod_object *lo, struct dt_object **stripe, __u32 *ost_indices, - int flags, struct thandle *th, int comp_idx) + int flags, struct thandle *th, int comp_idx, + __u64 reserve) { struct lod_layout_component *lod_comp; struct lod_device *m = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev); @@ -808,7 +817,7 @@ repeat_find: stripe_idx, array_idx, ost_idx); if ((ost_idx == LOV_QOS_EMPTY) || - !cfs_bitmap_check(m->lod_ost_bitmap, ost_idx)) + !test_bit(ost_idx, m->lod_ost_bitmap)) continue; /* Fail Check before osc_precreate() is called @@ -819,7 +828,8 @@ repeat_find: spin_unlock(&lqr->lqr_alloc); rc = lod_check_and_reserve_ost(env, lo, lod_comp, ost_idx, speed, &stripe_idx, stripe, - ost_indices, th, &overstriped); + ost_indices, th, &overstriped, + reserve); spin_lock(&lqr->lqr_alloc); if (rc != 0 && OST_TGT(m, ost_idx)->ltd_connecting) @@ -890,7 +900,7 @@ lod_qos_mdt_in_use_init(const struct lu_env *env, for (j = 0; j < pool->op_count; j++) { mdt_idx = pool->op_array[j]; - if (!cfs_bitmap_check(ltd->ltd_tgt_bitmap, mdt_idx)) + if (!test_bit(mdt_idx, ltd->ltd_tgt_bitmap)) continue; mdt = LTD_TGT(ltd, mdt_idx); @@ -993,7 +1003,7 @@ repeat_find: stripe_idx, pool_idx, mdt_idx); if (mdt_idx == LOV_QOS_EMPTY || - !cfs_bitmap_check(ltd->ltd_tgt_bitmap, mdt_idx)) + !test_bit(mdt_idx, ltd->ltd_tgt_bitmap)) continue; /* do not put >1 objects on one MDT */ @@ -1008,7 +1018,7 @@ repeat_find: } /* try to use another OSP if this one is degraded */ - if (mdt->ltd_statfs.os_state & OS_STATE_DEGRADED && + if (mdt->ltd_statfs.os_state & OS_STATFS_DEGRADED && !use_degraded) { QOS_DEBUG("#%d: degraded\n", mdt_idx); continue; @@ -1089,7 +1099,7 @@ repeat_find: */ static int lod_alloc_ost_list(const struct lu_env *env, struct lod_object *lo, struct dt_object **stripe, __u32 *ost_indices, - struct thandle *th, int comp_idx) + struct thandle *th, int comp_idx, __u64 reserve) { struct lod_layout_component *lod_comp; struct lod_device *m = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev); @@ -1132,7 +1142,7 @@ static int lod_alloc_ost_list(const struct lu_env *env, struct lod_object *lo, i++, array_idx = (array_idx + 1) % lod_comp->llc_stripe_count) { __u32 ost_idx = lod_comp->llc_ostlist.op_array[array_idx]; - if (!cfs_bitmap_check(m->lod_ost_bitmap, ost_idx)) { + if (!test_bit(ost_idx, m->lod_ost_bitmap)) { rc = -ENODEV; break; } @@ -1147,7 +1157,8 @@ static int lod_alloc_ost_list(const struct lu_env *env, struct lod_object *lo, } rc = lod_statfs_and_check(env, m, &m->lod_ost_descs, - LTD_TGT(&m->lod_ost_descs, ost_idx)); + LTD_TGT(&m->lod_ost_descs, ost_idx), + reserve); if (rc < 0) /* this OSP doesn't feel well */ break; @@ -1201,7 +1212,8 @@ static int lod_alloc_ost_list(const struct lu_env *env, struct lod_object *lo, static int lod_ost_alloc_specific(const struct lu_env *env, struct lod_object *lo, struct dt_object **stripe, __u32 *ost_indices, - int flags, struct thandle *th, int comp_idx) + int flags, struct thandle *th, int comp_idx, + __u64 reserve) { struct lod_layout_component *lod_comp; struct lod_device *m = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev); @@ -1260,7 +1272,7 @@ repeat_find: i++, array_idx = (array_idx + 1) % ost_count) { ost_idx = osts->op_array[array_idx]; - if (!cfs_bitmap_check(m->lod_ost_bitmap, ost_idx)) + if (!test_bit(ost_idx, m->lod_ost_bitmap)) continue; /* Fail Check before osc_precreate() is called @@ -1294,7 +1306,8 @@ repeat_find: * start OST, then it can be skipped, otherwise skip it only * if it is inactive/recovering/out-of-space." */ - rc = lod_statfs_and_check(env, m, &m->lod_ost_descs, tgt); + rc = lod_statfs_and_check(env, m, &m->lod_ost_descs, + tgt, reserve); if (rc) { /* this OSP doesn't feel well */ continue; @@ -1395,7 +1408,8 @@ out: */ static int lod_ost_alloc_qos(const struct lu_env *env, struct lod_object *lo, struct dt_object **stripe, __u32 *ost_indices, - int flags, struct thandle *th, int comp_idx) + int flags, struct thandle *th, int comp_idx, + __u64 reserve) { struct lod_layout_component *lod_comp; struct lod_device *lod = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev); @@ -1458,19 +1472,20 @@ static int lod_ost_alloc_qos(const struct lu_env *env, struct lod_object *lo, good_osts = 0; /* Find all the OSTs that are valid stripe candidates */ for (i = 0; i < osts->op_count; i++) { - if (!cfs_bitmap_check(lod->lod_ost_bitmap, osts->op_array[i])) + if (!test_bit(osts->op_array[i], lod->lod_ost_bitmap)) continue; ost = OST_TGT(lod, osts->op_array[i]); ost->ltd_qos.ltq_usable = 0; - rc = lod_statfs_and_check(env, lod, &lod->lod_ost_descs, ost); + rc = lod_statfs_and_check(env, lod, &lod->lod_ost_descs, + ost, reserve); if (rc) { /* this OSP doesn't feel well */ continue; } - if (ost->ltd_statfs.os_state & OS_STATE_DEGRADED) + if (ost->ltd_statfs.os_state & OS_STATFS_DEGRADED) continue; /* Fail Check before osc_precreate() is called @@ -1588,9 +1603,8 @@ static int lod_ost_alloc_qos(const struct lu_env *env, struct lod_object *lo, } /* makes sense to rebalance next time */ - lod->lod_ost_descs.ltd_qos.lq_dirty = 1; - lod->lod_ost_descs.ltd_qos.lq_same_space = 0; - + set_bit(LQ_DIRTY, &lod->lod_ost_descs.ltd_qos.lq_flags); + clear_bit(LQ_SAME_SPACE, &lod->lod_ost_descs.ltd_qos.lq_flags); rc = -EAGAIN; } @@ -1702,7 +1716,7 @@ int lod_mdt_alloc_qos(const struct lu_env *env, struct lod_object *lo, good_mdts = 0; /* Find all the MDTs that are valid stripe candidates */ for (i = 0; i < pool->op_count; i++) { - if (!cfs_bitmap_check(ltd->ltd_tgt_bitmap, pool->op_array[i])) + if (!test_bit(pool->op_array[i], ltd->ltd_tgt_bitmap)) continue; mdt = LTD_TGT(ltd, pool->op_array[i]); @@ -1712,7 +1726,7 @@ int lod_mdt_alloc_qos(const struct lu_env *env, struct lod_object *lo, if (rc) continue; - if (mdt->ltd_statfs.os_state & OS_STATE_DEGRADED) + if (mdt->ltd_statfs.os_state & OS_STATFS_DEGRADED) continue; mdt->ltd_qos.ltq_usable = 1; @@ -1809,8 +1823,8 @@ int lod_mdt_alloc_qos(const struct lu_env *env, struct lod_object *lo, } /* makes sense to rebalance next time */ - ltd->ltd_qos.lq_dirty = 1; - ltd->ltd_qos.lq_same_space = 0; + set_bit(LQ_DIRTY, <d->ltd_qos.lq_flags); + clear_bit(LQ_SAME_SPACE, <d->ltd_qos.lq_flags); rc = -EAGAIN; } else { @@ -1836,19 +1850,20 @@ unlock: * * \param[in] lod LOD device * \param[in] lo The lod_object + * \param[in] comp_idx The component id, which the amount of stripes is + calculated for * \param[in] stripe_count count the caller would like to use * * \retval the maximum usable stripe count */ __u16 lod_get_stripe_count(struct lod_device *lod, struct lod_object *lo, - __u16 stripe_count, bool overstriping) + int comp_idx, __u16 stripe_count, bool overstriping) { __u32 max_stripes = LOV_MAX_STRIPE_COUNT_OLD; /* max stripe count is based on OSD ea size */ unsigned int easize = lod->lod_osd_max_easize; int i; - if (!stripe_count) stripe_count = lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_count; @@ -1872,9 +1887,17 @@ __u16 lod_get_stripe_count(struct lod_device *lod, struct lod_object *lo, lo->ldo_comp_cnt; for (i = 0; i < lo->ldo_comp_cnt; i++) { + unsigned int stripes; + + if (i == comp_idx) + continue; + lod_comp = &lo->ldo_comp_entries[i]; - comp_sz = lov_mds_md_size(lod_comp->llc_stripe_count, - LOV_MAGIC_V3); + /* Extension comp is never inited - 0 stripes on disk */ + stripes = lod_comp->llc_flags & LCME_FL_EXTENSION ? 0 : + lod_comp->llc_stripe_count; + + comp_sz = lov_mds_md_size(stripes, LOV_MAGIC_V3); total_comp_sz += comp_sz; if (lod_comp->llc_flags & LCME_FL_INIT) init_comp_sz += comp_sz; @@ -2297,7 +2320,7 @@ int lod_prepare_avoidance(const struct lu_env *env, struct lod_object *lo) { struct lod_device *lod = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev); struct lod_avoid_guide *lag = &lod_env_info(env)->lti_avoid; - struct cfs_bitmap *bitmap = NULL; + unsigned long *bitmap = NULL; __u32 *new_oss = NULL; lag->lag_ost_avail = lod->lod_ost_count; @@ -2313,16 +2336,17 @@ int lod_prepare_avoidance(const struct lu_env *env, struct lod_object *lo) /* init OST avoid guide bitmap */ if (lag->lag_ost_avoid_bitmap) { - if (lod->lod_ost_count <= lag->lag_ost_avoid_bitmap->size) { - CFS_RESET_BITMAP(lag->lag_ost_avoid_bitmap); + if (lod->lod_ost_count <= lag->lag_ost_avoid_size) { + bitmap_zero(lag->lag_ost_avoid_bitmap, + lag->lag_ost_avoid_size); } else { - CFS_FREE_BITMAP(lag->lag_ost_avoid_bitmap); + bitmap_free(lag->lag_ost_avoid_bitmap); lag->lag_ost_avoid_bitmap = NULL; } } if (!lag->lag_ost_avoid_bitmap) { - bitmap = CFS_ALLOCATE_BITMAP(lod->lod_ost_count); + bitmap = bitmap_zalloc(lod->lod_ost_count, GFP_KERNEL); if (!bitmap) return -ENOMEM; } @@ -2336,7 +2360,7 @@ int lod_prepare_avoidance(const struct lu_env *env, struct lod_object *lo) */ OBD_ALLOC_PTR_ARRAY(new_oss, lod->lod_ost_count); if (!new_oss) { - CFS_FREE_BITMAP(bitmap); + bitmap_free(bitmap); return -ENOMEM; } } @@ -2345,8 +2369,10 @@ int lod_prepare_avoidance(const struct lu_env *env, struct lod_object *lo) lag->lag_oss_avoid_array = new_oss; lag->lag_oaa_size = lod->lod_ost_count; } - if (bitmap) + if (bitmap) { lag->lag_ost_avoid_bitmap = bitmap; + lag->lag_ost_avoid_size = lod->lod_ost_count; + } return 0; } @@ -2360,7 +2386,7 @@ void lod_collect_avoidance(struct lod_object *lo, struct lod_avoid_guide *lag, { struct lod_device *lod = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev); struct lod_layout_component *lod_comp = &lo->ldo_comp_entries[comp_idx]; - struct cfs_bitmap *bitmap = lag->lag_ost_avoid_bitmap; + unsigned long *bitmap = lag->lag_ost_avoid_bitmap; int i, j; /* iterate mirrors */ @@ -2407,12 +2433,12 @@ void lod_collect_avoidance(struct lod_object *lo, struct lod_avoid_guide *lag, ost = OST_TGT(lod, comp->llc_ost_indices[j]); lsq = ost->ltd_qos.ltq_svr; - if (cfs_bitmap_check(bitmap, ost->ltd_index)) + if (test_bit(ost->ltd_index, bitmap)) continue; QOS_DEBUG("OST%d used in conflicting mirror " "component\n", ost->ltd_index); - cfs_bitmap_set(bitmap, ost->ltd_index); + set_bit(ost->ltd_index, bitmap); lag->lag_ost_avail--; for (k = 0; k < lag->lag_oaa_count; k++) { @@ -2450,7 +2476,7 @@ void lod_collect_avoidance(struct lod_object *lo, struct lod_avoid_guide *lag, */ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo, struct lu_attr *attr, struct thandle *th, - int comp_idx) + int comp_idx, __u64 reserve) { struct lod_layout_component *lod_comp; struct lod_device *d = lu2lod_dev(lod2lu_obj(lo)->lo_dev); @@ -2485,7 +2511,7 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo, * could be changed if some OSTs are [de]activated manually. */ lod_qos_statfs_update(env, d, &d->lod_ost_descs); - stripe_len = lod_get_stripe_count(d, lo, + stripe_len = lod_get_stripe_count(d, lo, comp_idx, lod_comp->llc_stripe_count, lod_comp->llc_pattern & LOV_PATTERN_OVERSTRIPING); @@ -2500,6 +2526,7 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo, if (!ost_indices) GOTO(out, rc = -ENOMEM); +repeat: lod_getref(&d->lod_ost_descs); /* XXX: support for non-0 files w/o objects */ CDEBUG(D_OTHER, "tgt_count %d stripe_count %d\n", @@ -2508,7 +2535,7 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo, if (lod_comp->llc_ostlist.op_array && lod_comp->llc_ostlist.op_count) { rc = lod_alloc_ost_list(env, lo, stripe, ost_indices, - th, comp_idx); + th, comp_idx, reserve); } else if (lod_comp->llc_stripe_offset == LOV_OFFSET_DEFAULT) { /** * collect OSTs and OSSs used in other mirrors whose @@ -2523,15 +2550,15 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo, lod_collect_avoidance(lo, lag, comp_idx); rc = lod_ost_alloc_qos(env, lo, stripe, ost_indices, - flag, th, comp_idx); + flag, th, comp_idx, reserve); if (rc == -EAGAIN) rc = lod_ost_alloc_rr(env, lo, stripe, ost_indices, flag, th, - comp_idx); + comp_idx, reserve); } else { rc = lod_ost_alloc_specific(env, lo, stripe, ost_indices, flag, th, - comp_idx); + comp_idx, reserve); } put_ldts: lod_putref(d, &d->lod_ost_descs); @@ -2539,6 +2566,15 @@ put_ldts: for (i = 0; i < stripe_len; i++) if (stripe[i] != NULL) dt_object_put(env, stripe[i]); + + /* In case there is no space on any OST, let's ignore + * the @reserve space to avoid an error at the init + * time, probably the actual IO will be less than the + * given @reserve space (aka extension_size). */ + if (reserve) { + reserve = 0; + goto repeat; + } lod_comp->llc_stripe_count = 0; } else { lod_comp->llc_stripe = stripe; @@ -2629,7 +2665,7 @@ int lod_prepare_create(const struct lu_env *env, struct lod_object *lo, extent = &lod_comp->llc_extent; QOS_DEBUG("comp[%d] %lld "DEXT"\n", i, size, PEXT(extent)); if (!lo->ldo_is_composite || size >= extent->e_start) { - rc = lod_qos_prep_create(env, lo, attr, th, i); + rc = lod_qos_prep_create(env, lo, attr, th, i, 0); if (rc) break; }