#define DEBUG_SUBSYSTEM S_LOV
#include <asm/div64.h>
+#include <linux/random.h>
+
#include <libcfs/libcfs.h>
#include <uapi/linux/lustre/lustre_idl.h>
#include <lustre_swab.h>
* \retval negative negated errno on error
*/
-static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d,
- int index, struct obd_statfs *sfs)
+int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d,
+ int index, struct obd_statfs *sfs,
+ struct obd_statfs_info *info)
{
struct lod_tgt_desc *ost;
int rc;
ost = OST_TGT(d,index);
LASSERT(ost);
- rc = dt_statfs(env, ost->ltd_ost, sfs);
+ rc = dt_statfs(env, ost->ltd_ost, sfs, info);
if (rc == 0 && ((sfs->os_state & OS_STATE_ENOSPC) ||
(sfs->os_state & OS_STATE_ENOINO && sfs->os_fprecreated == 0)))
idx = osts->op_array[i];
avail = OST_TGT(lod,idx)->ltd_statfs.os_bavail;
if (lod_statfs_and_check(env, lod, idx,
- &OST_TGT(lod, idx)->ltd_statfs))
+ &OST_TGT(lod, idx)->ltd_statfs, NULL))
continue;
if (OST_TGT(lod,idx)->ltd_statfs.os_bavail != avail)
/* recalculate weigths */
RETURN(0);
}
-void lod_qos_rr_init(struct lu_qos_rr *lqr)
-{
- spin_lock_init(&lqr->lqr_alloc);
- lqr->lqr_dirty = 1;
-}
-
#define LOV_QOS_EMPTY ((__u32)-1)
/**
int rc;
ENTRY;
- rc = lod_statfs_and_check(env, lod, ost_idx, sfs);
+ rc = lod_statfs_and_check(env, lod, ost_idx, sfs, NULL);
if (rc)
RETURN(rc);
down_read(&m->lod_qos.lq_rw_sem);
spin_lock(&lqr->lqr_alloc);
if (--lqr->lqr_start_count <= 0) {
- lqr->lqr_start_idx = cfs_rand() % osts->op_count;
+ lqr->lqr_start_idx = prandom_u32_max(osts->op_count);
lqr->lqr_start_count =
(LOV_CREATE_RESEED_MIN / max(osts->op_count, 1U) +
LOV_CREATE_RESEED_MULT) * max(osts->op_count, 1U);
break;
}
- rc = lod_statfs_and_check(env, m, ost_idx, sfs);
+ rc = lod_statfs_and_check(env, m, ost_idx, sfs, NULL);
if (rc < 0) /* this OSP doesn't feel well */
break;
* 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, ost_idx, sfs);
+ rc = lod_statfs_and_check(env, m, ost_idx, sfs, NULL);
if (rc) {
/* this OSP doesn't feel well */
continue;
ost = OST_TGT(lod, osts->op_array[i]);
ost->ltd_qos.ltq_usable = 0;
- rc = lod_statfs_and_check(env, lod, osts->op_array[i], sfs);
+ rc = lod_statfs_and_check(env, lod, osts->op_array[i],
+ sfs, NULL);
if (rc) {
/* this OSP doesn't feel well */
continue;
/* Find enough OSTs with weighted random allocation. */
nfound = 0;
while (nfound < stripe_count) {
- __u64 rand, cur_weight;
+ u64 rand, cur_weight;
cur_weight = 0;
rc = -ENOSPC;
- if (total_weight) {
-#if BITS_PER_LONG == 32
- rand = cfs_rand() % (unsigned)total_weight;
- /* If total_weight > 32-bit, first generate the high
- * 32 bits of the random number, then add in the low
- * 32 bits (truncated to the upper limit, if needed) */
- if (total_weight > 0xffffffffULL)
- rand = (__u64)(cfs_rand() %
- (unsigned)(total_weight >> 32)) << 32;
- else
- rand = 0;
-
- if (rand == (total_weight & 0xffffffff00000000ULL))
- rand |= cfs_rand() % (unsigned)total_weight;
- else
- rand |= cfs_rand();
-
-#else
- rand = ((__u64)cfs_rand() << 32 | cfs_rand()) %
- total_weight;
-#endif
- } else {
- rand = 0;
- }
+ rand = lu_prandom_u64_max(total_weight);
/* On average, this will hit larger-weighted OSTs more often.
* 0-weight OSTs will always get used last (only when rand=0) */
lod_comp->llc_extent = *ext;
lod_comp->llc_flags =
comp_v1->lcm_entries[i].lcme_flags &
- LCME_USER_FLAGS;
+ LCME_CL_COMP_FLAGS;
}
pool_name = NULL;
LASSERT(lo);
LASSERT(lo->ldo_comp_cnt > comp_idx && lo->ldo_comp_entries != NULL);
lod_comp = &lo->ldo_comp_entries[comp_idx];
+ LASSERT(!(lod_comp->llc_flags & LCME_FL_EXTENSION));
/* A released component is being created */
if (lod_comp->llc_pattern & LOV_PATTERN_F_RELEASED)