#define DEBUG_SUBSYSTEM S_LOV
+#include <asm/div64.h>
#include <libcfs/libcfs.h>
#include <obd_class.h>
-#include <obd_lov.h>
#include <lustre/lustre_idl.h>
#include "lod_internal.h"
int qos_add_tgt(struct lod_device *lod, struct lod_tgt_desc *ost_desc)
{
- struct lov_qos_oss *oss = NULL, *temposs;
+ struct lod_qos_oss *oss = NULL, *temposs;
struct obd_export *exp = ost_desc->ltd_exp;
int rc = 0, found = 0;
- cfs_list_t *list;
+ struct list_head *list;
ENTRY;
down_write(&lod->lod_qos.lq_rw_sem);
* but there is no official API to access information like this
* with OSD API.
*/
- cfs_list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list) {
+ list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list) {
if (obd_uuid_equals(&oss->lqo_uuid,
&exp->exp_connection->c_remote_uuid)) {
found++;
sizeof(oss->lqo_uuid));
} else {
/* Assume we have to move this one */
- cfs_list_del(&oss->lqo_oss_list);
+ list_del(&oss->lqo_oss_list);
}
oss->lqo_ost_count++;
/* Add sorted by # of OSTs. Find the first entry that we're
bigger than... */
list = &lod->lod_qos.lq_oss_list;
- cfs_list_for_each_entry(temposs, list, lqo_oss_list) {
+ list_for_each_entry(temposs, list, lqo_oss_list) {
if (oss->lqo_ost_count > temposs->lqo_ost_count)
break;
}
/* ...and add before it. If we're the first or smallest, temposs
points to the list head, and we add to the end. */
- cfs_list_add_tail(&oss->lqo_oss_list, &temposs->lqo_oss_list);
+ list_add_tail(&oss->lqo_oss_list, &temposs->lqo_oss_list);
lod->lod_qos.lq_dirty = 1;
lod->lod_qos.lq_rr.lqr_dirty = 1;
int qos_del_tgt(struct lod_device *lod, struct lod_tgt_desc *ost_desc)
{
- struct lov_qos_oss *oss;
+ struct lod_qos_oss *oss;
int rc = 0;
ENTRY;
if (oss->lqo_ost_count == 0) {
CDEBUG(D_QOS, "removing OSS %s\n",
obd_uuid2str(&oss->lqo_uuid));
- cfs_list_del(&oss->lqo_oss_list);
+ list_del(&oss->lqo_oss_list);
ost_desc->ltd_qos.ltq_oss = NULL;
OBD_FREE_PTR(oss);
}
if (rc && rc != -ENOTCONN)
CERROR("%s: statfs: rc = %d\n", lod2obd(d)->obd_name, rc);
+ /* If the OST is readonly then we can't allocate objects there */
+ if (sfs->os_state & OS_STATE_READONLY)
+ rc = -EROFS;
+
/* check whether device has changed state (active, inactive) */
if (rc != 0 && ost->ltd_active) {
/* turned inactive? */
{
struct obd_device *obd = lod2obd(lod);
struct ost_pool *osts = &(lod->lod_pool_info);
- int i, idx, rc = 0;
+ unsigned int i;
+ int idx, rc = 0;
__u64 max_age, avail;
ENTRY;
depends on size of each ost in an oss */
static int lod_qos_calc_ppo(struct lod_device *lod)
{
- struct lov_qos_oss *oss;
+ struct lod_qos_oss *oss;
__u64 ba_max, ba_min, temp;
__u32 num_active;
- int rc, i, prio_wide;
+ unsigned int i;
+ int rc, prio_wide;
time_t now, age;
ENTRY;
GOTO(out, rc = -EAGAIN);
/* find bavail on each OSS */
- cfs_list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list)
+ list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list)
oss->lqo_bavail = 0;
lod->lod_qos.lq_active_oss_count = 0;
/* per-OST penalty is prio * TGT_bavail / (num_ost - 1) / 2 */
temp >>= 1;
- lov_do_div64(temp, num_active);
+ do_div(temp, num_active);
OST_TGT(lod,i)->ltd_qos.ltq_penalty_per_obj =
(temp * prio_wide) >> 8;
}
/* Per-OSS penalty is prio * oss_avail / oss_osts / (num_oss - 1) / 2 */
- cfs_list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list) {
+ list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list) {
temp = oss->lqo_bavail >> 1;
- lov_do_div64(temp, oss->lqo_ost_count * num_active);
+ do_div(temp, oss->lqo_ost_count * num_active);
oss->lqo_penalty_per_obj = (temp * prio_wide) >> 8;
age = (now - oss->lqo_used) >> 3;
__u32 index, __u64 *total_wt)
{
struct lod_tgt_desc *ost;
- struct lov_qos_oss *oss;
- int j;
+ struct lod_qos_oss *oss;
+ unsigned int j;
ENTRY;
ost = OST_TGT(lod,index);
lod->lod_qos.lq_active_oss_count;
/* Decrease all OSS penalties */
- cfs_list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list) {
+ list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list) {
if (oss->lqo_penalty < oss->lqo_penalty_per_obj)
oss->lqo_penalty = 0;
else
#define LOV_QOS_EMPTY ((__u32)-1)
/* compute optimal round-robin order, based on OSTs per OSS */
static int lod_qos_calc_rr(struct lod_device *lod, struct ost_pool *src_pool,
- struct lov_qos_rr *lqr)
+ struct lod_qos_rr *lqr)
{
- struct lov_qos_oss *oss;
+ struct lod_qos_oss *oss;
struct lod_tgt_desc *ost;
unsigned placed, real_count;
- int i, rc;
+ unsigned int i;
+ int rc;
ENTRY;
if (!lqr->lqr_dirty) {
/* Place all the OSTs from 1 OSS at the same time. */
placed = 0;
- cfs_list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list) {
+ list_for_each_entry(oss, &lod->lod_qos.lq_oss_list, lqo_oss_list) {
int j = 0;
for (i = 0; i < lqr->lqr_pool.op_count; i++) {
*/
static struct dt_object *lod_qos_declare_object_on(const struct lu_env *env,
struct lod_device *d,
- int ost_idx,
+ __u32 ost_idx,
struct thandle *th)
{
struct lod_tgt_desc *ost;
ENTRY;
LASSERT(d);
- LASSERT(ost_idx >= 0);
LASSERT(ost_idx < d->lod_osts_size);
ost = OST_TGT(d,ost_idx);
LASSERT(ost);
RETURN(dt);
}
-static int min_stripe_count(int stripe_cnt, int flags)
+static int min_stripe_count(__u32 stripe_cnt, int flags)
{
return (flags & LOV_USES_DEFAULT_STRIPE ?
stripe_cnt - (stripe_cnt / 4) : stripe_cnt);
return (msfs->os_bavail < used);
}
-int lod_ea_store_resize(struct lod_thread_info *info, int size);
-
-static inline int lod_qos_ost_in_use_clear(const struct lu_env *env, int stripes)
+static inline int lod_qos_ost_in_use_clear(const struct lu_env *env,
+ __u32 stripes)
{
struct lod_thread_info *info = lod_env_info(env);
osts[idx] = ost;
}
-static int lod_qos_is_ost_used(const struct lu_env *env, int ost, int stripes)
+static int lod_qos_is_ost_used(const struct lu_env *env, int ost, __u32 stripes)
{
struct lod_thread_info *info = lod_env_info(env);
int *osts = info->lti_ea_store;
- int j;
+ __u32 j;
for (j = 0; j < stripes; j++) {
if (osts[j] == ost)
struct obd_statfs *sfs = &lod_env_info(env)->lti_osfs;
struct pool_desc *pool = NULL;
struct ost_pool *osts;
- struct lov_qos_rr *lqr;
+ struct lod_qos_rr *lqr;
struct dt_object *o;
- unsigned array_idx;
- int i, rc;
- int ost_start_idx_temp;
+ unsigned int i, array_idx;
+ int rc;
+ __u32 ost_start_idx_temp;
int speed = 0;
- int stripe_idx = 0;
- int stripe_cnt = lo->ldo_stripenr;
- int stripe_cnt_min = min_stripe_count(stripe_cnt, flags);
+ __u32 stripe_idx = 0;
+ __u32 stripe_cnt = lo->ldo_stripenr;
+ __u32 stripe_cnt_min = min_stripe_count(stripe_cnt, flags);
__u32 ost_idx;
ENTRY;
/*
* try to use another OSP if this one is degraded
*/
- if (sfs->os_state == OS_STATE_DEGRADED && speed < 2) {
+ if (sfs->os_state & OS_STATE_DEGRADED && speed < 2) {
QOS_DEBUG("#%d: degraded\n", ost_idx);
continue;
}
struct lod_device *m = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev);
struct obd_statfs *sfs = &lod_env_info(env)->lti_osfs;
struct dt_object *o;
- unsigned ost_idx, array_idx, ost_count;
- int i, rc, stripe_num = 0;
+ __u32 ost_idx;
+ unsigned int i, array_idx, ost_count;
+ int rc, stripe_num = 0;
int speed = 0;
struct pool_desc *pool = NULL;
struct ost_pool *osts;
struct lod_tgt_desc *ost;
struct dt_object *o;
__u64 total_weight = 0;
- int nfound, good_osts, i, rc = 0;
- int stripe_cnt = lo->ldo_stripenr;
- int stripe_cnt_min;
+ unsigned int i;
+ int rc = 0;
+ __u32 nfound, good_osts;
+ __u32 stripe_cnt = lo->ldo_stripenr;
+ __u32 stripe_cnt_min;
struct pool_desc *pool = NULL;
struct ost_pool *osts;
ENTRY;
/* On average, this will hit larger-weighted osts more often.
0-weight osts will always get used last (only when rand=0) */
for (i = 0; i < osts->op_count; i++) {
- int idx = osts->op_array[i];
+ __u32 idx = osts->op_array[i];
if (!cfs_bitmap_check(m->lod_ost_bitmap, idx))
continue;
/* stripe count is based on whether OSD can handle larger EA sizes */
if (lod->lod_osd_max_easize > 0)
- max_stripes = lov_mds_md_stripecnt(lod->lod_osd_max_easize,
- magic);
+ max_stripes = lov_mds_md_max_stripe_count(
+ lod->lod_osd_max_easize, magic);
return (stripe_count < max_stripes) ? stripe_count : max_stripes;
}
lu_object_put(env, &stripe[i]->do_lu);
OBD_FREE(stripe, sizeof(stripe[0]) * stripe_len);
+ lo->ldo_stripenr = 0;
} else {
lo->ldo_stripe = stripe;
lo->ldo_stripes_allocated = stripe_len;