-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
#define DEBUG_SUBSYSTEM S_LOV
#ifdef __KERNEL__
}
cfs_down_write(&lov->lov_qos.lq_rw_sem);
- cfs_mutex_down(&lov->lov_lock);
+ cfs_mutex_lock(&lov->lov_lock);
cfs_list_for_each_entry(oss, &lov->lov_qos.lq_oss_list, lqo_oss_list) {
if (obd_uuid_equals(&oss->lqo_uuid,
&exp->exp_connection->c_remote_uuid)) {
oss->lqo_ost_count);
out:
- cfs_mutex_up(&lov->lov_lock);
+ cfs_mutex_unlock(&lov->lov_lock);
cfs_up_write(&lov->lov_qos.lq_rw_sem);
RETURN(rc);
}
lov->lov_qos.lq_active_oss_count++;
lov->lov_tgts[i]->ltd_qos.ltq_oss->lqo_bavail += temp;
- /* per-OST penalty is prio * TGT_bavail / (num_ost - 1) / 2 */
- temp >>= 1;
- do_div(temp, num_active);
- lov->lov_tgts[i]->ltd_qos.ltq_penalty_per_obj =
- (temp * prio_wide) >> 8;
+ /* per-OST penalty is prio * TGT_bavail / (num_ost - 1) / 2 */
+ temp >>= 1;
+ lov_do_div64(temp, num_active);
+ lov->lov_tgts[i]->ltd_qos.ltq_penalty_per_obj =
+ (temp * prio_wide) >> 8;
age = (now - lov->lov_tgts[i]->ltd_qos.ltq_used) >> 3;
if (lov->lov_qos.lq_reset || age > 32 * lov->desc.ld_qos_maxage)
/* Per-OSS penalty is prio * oss_avail / oss_osts / (num_oss - 1) / 2 */
cfs_list_for_each_entry(oss, &lov->lov_qos.lq_oss_list, lqo_oss_list) {
- temp = oss->lqo_bavail >> 1;
- do_div(temp, oss->lqo_ost_count * num_active);
- oss->lqo_penalty_per_obj = (temp * prio_wide) >> 8;
+ temp = oss->lqo_bavail >> 1;
+ lov_do_div64(temp, oss->lqo_ost_count * num_active);
+ oss->lqo_penalty_per_obj = (temp * prio_wide) >> 8;
age = (now - oss->lqo_used) >> 3;
if (lov->lov_qos.lq_reset || age > 32 * lov->desc.ld_qos_maxage)
oti_alloc_cookies(set->set_oti, set->set_count);
if (set->set_oti->oti_logcookies) {
memcpy(set->set_oti->oti_logcookies, cookies, newsize);
- OBD_FREE(cookies, oldsize);
+ OBD_FREE_LARGE(cookies, oldsize);
set->set_cookies = set->set_oti->oti_logcookies;
} else {
CWARN("'leaking' %d bytes\n", oldsize - newsize);
LASSERT(lsm->lsm_stripe_count >= set->set_count);
newsize = lov_stripe_md_size(set->set_count);
- OBD_ALLOC(lsm_new, newsize);
+ OBD_ALLOC_LARGE(lsm_new, newsize);
if (lsm_new != NULL) {
int i;
memcpy(lsm_new, lsm, sizeof(*lsm));
sizeof(struct lov_oinfo));
}
lsm_new->lsm_stripe_count = set->set_count;
- OBD_FREE(lsm, sizeof(struct lov_stripe_md) +
- lsm->lsm_stripe_count * sizeof(struct lov_oinfo *));
+ OBD_FREE_LARGE(lsm, sizeof(struct lov_stripe_md) +
+ lsm->lsm_stripe_count*sizeof(struct lov_oinfo*));
set->set_oi->oi_md = lsm_new;
} else {
CWARN("'leaking' few bytes\n");
struct lov_request *req,
struct obd_trans_info *oti)
{
- int stripe;
+ __u16 stripe;
int rc = -EIO;
ENTRY;
if (stripe >= lsm->lsm_stripe_count) {
req->rq_idx = ost_idx;
- rc = obd_create(lov->lov_tgts[ost_idx]->ltd_exp,
+ rc = obd_create(NULL, lov->lov_tgts[ost_idx]->ltd_exp,
req->rq_oi.oi_oa, &req->rq_oi.oi_md,
oti);
}
stripe_cnt - (stripe_cnt / 4) : stripe_cnt);
}
-#define LOV_CREATE_RESEED_MULT 4
-#define LOV_CREATE_RESEED_MIN 1000
+#define LOV_CREATE_RESEED_MULT 30
+#define LOV_CREATE_RESEED_MIN 2000
/* Allocate objects on osts with round-robin algorithm */
static int alloc_rr(struct lov_obd *lov, int *idx_arr, int *stripe_cnt,
char *poolname, int flags)
GOTO(out, rc);
if (--lqr->lqr_start_count <= 0) {
- lqr->lqr_start_idx = ll_rand() % osts->op_count;
+ lqr->lqr_start_idx = cfs_rand() % 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);
int stripe_cnt_min = min_stripe_count(*stripe_cnt, flags);
struct pool_desc *pool;
struct ost_pool *osts;
- struct lov_qos_rr *lqr;
ENTRY;
if (stripe_cnt_min < 1)
pool = lov_find_pool(lov, poolname);
if (pool == NULL) {
osts = &(lov->lov_packed);
- lqr = &(lov->lov_qos.lq_rr);
} else {
cfs_down_read(&pool_tgt_rw_sem(pool));
osts = &(pool->pool_obds);
- lqr = &(pool->pool_rr);
}
obd_getref(exp->exp_obd);
if (total_weight) {
#if BITS_PER_LONG == 32
- rand = ll_rand() % (unsigned)total_weight;
+ 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)(ll_rand() %
+ rand = (__u64)(cfs_rand() %
(unsigned)(total_weight >> 32)) << 32;
else
rand = 0;
if (rand == (total_weight & 0xffffffff00000000ULL))
- rand |= ll_rand() % (unsigned)total_weight;
+ rand |= cfs_rand() % (unsigned)total_weight;
else
- rand |= ll_rand();
+ rand |= cfs_rand();
#else
- rand = ((__u64)ll_rand() << 32 | ll_rand()) %
+ rand = ((__u64)cfs_rand() << 32 | cfs_rand()) %
total_weight;
#endif
} else {
LASSERT(src_oa->o_valid & OBD_MD_FLGROUP);
if (set->set_oi->oi_md == NULL) {
- int stripes_def = lov_get_stripecnt(lov, 0);
+ __u16 stripes_def = lov_get_stripecnt(lov, LOV_MAGIC, 0);
/* If the MDS file was truncated up to some size, stripe over
* enough OSTs to allow the file to be created at that size.
if (stripes < stripes_def)
stripes = stripes_def;
} else {
- flag = LOV_USES_DEFAULT_STRIPE;
- stripes = stripes_def;
+ flag = LOV_USES_DEFAULT_STRIPE;
+ stripes = stripes_def;
}
rc = lov_alloc_memmd(&set->set_oi->oi_md, stripes,
lsm = set->set_oi->oi_md;
lsm->lsm_object_id = src_oa->o_id;
lsm->lsm_object_seq = src_oa->o_seq;
+ lsm->lsm_layout_gen = 0; /* actual generation set in mdd_lov_create() */
if (!lsm->lsm_stripe_size)
lsm->lsm_stripe_size = lov->desc.ld_default_stripe_size;
lov_set_add_req(req, set);
req->rq_buflen = sizeof(*req->rq_oi.oi_md);
- OBD_ALLOC(req->rq_oi.oi_md, req->rq_buflen);
+ OBD_ALLOC_LARGE(req->rq_oi.oi_md, req->rq_buflen);
if (req->rq_oi.oi_md == NULL)
GOTO(out_err, rc = -ENOMEM);
void qos_statfs_done(struct lov_obd *lov)
{
- LASSERT(lov->lov_qos.lq_statfs_in_progress);
cfs_down_write(&lov->lov_qos.lq_rw_sem);
- lov->lov_qos.lq_statfs_in_progress = 0;
- /* wake up any threads waiting for the statfs rpcs to complete */
- cfs_waitq_signal(&lov->lov_qos.lq_statfs_waitq);
+ if (lov->lov_qos.lq_statfs_in_progress) {
+ lov->lov_qos.lq_statfs_in_progress = 0;
+ /* wake up any threads waiting for the statfs rpcs to complete*/
+ cfs_waitq_signal(&lov->lov_qos.lq_statfs_waitq);
+ }
cfs_up_write(&lov->lov_qos.lq_rw_sem);
}
if (!set)
GOTO(out_failed, rc = -ENOMEM);
- rc = obd_statfs_async(obd, oinfo, max_age, set);
+ rc = obd_statfs_async(obd->obd_self_export, oinfo, max_age, set);
if (rc || cfs_list_empty(&set->set_requests)) {
if (rc)
CWARN("statfs failed with %d\n", rc);