struct obd_connect_data *data)
{
struct lov_obd *lov = &obd->u.lov;
- struct obd_uuid tgt_uuid = lov->lov_tgts[index]->ltd_uuid;
+ struct obd_uuid tgt_uuid;
struct obd_device *tgt_obd;
struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
struct lustre_handle conn = {0, };
if (!lov->lov_tgts[index])
RETURN(-EINVAL);
+ tgt_uuid = lov->lov_tgts[index]->ltd_uuid;
+
tgt_obd = class_find_client_obd(&tgt_uuid, LUSTRE_OSC_NAME,
&obd->obd_uuid);
{
cfs_proc_dir_entry_t *lov_proc_dir;
struct lov_obd *lov = &obd->u.lov;
- struct obd_device *osc_obd =
- class_exp2obd(lov->lov_tgts[index]->ltd_exp);
+ struct obd_device *osc_obd;
int rc;
ENTRY;
CDEBUG(D_CONFIG, "%s: disconnecting target %s\n",
obd->obd_name, osc_obd->obd_name);
+ if (lov->lov_tgts[index] == NULL)
+ RETURN(-EINVAL);
+ osc_obd = class_exp2obd(lov->lov_tgts[index]->ltd_exp);
if (lov->lov_tgts[index]->ltd_active) {
lov->lov_tgts[index]->ltd_active = 0;
lov->desc.ld_active_tgt_count--;
if (lov->lov_tgts) {
int i;
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
- if (lov->lov_tgts[i]) {
- /* Inactive targets may never have connected */
- if (lov->lov_tgts[i]->ltd_active ||
- atomic_read(&lov->lov_refcount))
- /* We should never get here - these
- should have been removed in the
- disconnect. */
- CERROR("lov tgt %d not cleaned!"
- " deathrow=%d, lovrc=%d\n",
- i, lov->lov_death_row,
- atomic_read(&lov->lov_refcount));
- lov_del_target(obd, i, 0, 0);
- }
+ if (!lov->lov_tgts[i])
+ continue;
+
+ /* Inactive targets may never have connected */
+ if (lov->lov_tgts[i]->ltd_active ||
+ atomic_read(&lov->lov_refcount))
+ /* We should never get here - these
+ should have been removed in the
+ disconnect. */
+ CERROR("lov tgt %d not cleaned!"
+ " deathrow=%d, lovrc=%d\n",
+ i, lov->lov_death_row,
+ atomic_read(&lov->lov_refcount));
+ lov_del_target(obd, i, 0, 0);
}
OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) *
lov->lov_tgt_size);
for(i = 0; i < lov->desc.ld_tgt_count; i++) {
tgt = lov->lov_tgts[i];
- if (obd_uuid_equals(val, &tgt->ltd_uuid))
+ if (tgt && obd_uuid_equals(val, &tgt->ltd_uuid))
GOTO(out, rc = i);
}
}
static int qos_calc_weight(struct lov_obd *lov, int i)
{
__u64 temp, temp2;
-
+
/* Final ost weight = TGT_BAVAIL - ost_penalty - oss_penalty */
temp = TGT_BAVAIL(i);
temp2 = lov->lov_tgts[i]->ltd_qos.ltq_penalty +
lov->lov_tgts[index]->ltd_qos.ltq_usable = 0;
oss = lov->lov_tgts[index]->ltd_qos.ltq_oss;
-
+
/* Decay old penalty by half (we're adding max penalty, and don't
want it to run away.) */
lov->lov_tgts[index]->ltd_qos.ltq_penalty >>= 1;
lov->desc.ld_active_tgt_count;
oss->lqo_penalty += oss->lqo_penalty_per_obj *
lov->lov_qos.lq_active_oss_count;
-
+
/* Decrease all OSS penalties */
list_for_each_entry(oss, &lov->lov_qos.lq_oss_list, lqo_oss_list) {
if (oss->lqo_penalty < oss->lqo_penalty_per_obj)
list_for_each_entry(oss, &lov->lov_qos.lq_oss_list, lqo_oss_list) {
int j = 0;
for (i = 0; i < ost_count; i++) {
- LASSERT(lov->lov_tgts[i] != NULL);
- if (lov->lov_tgts[i]->ltd_qos.ltq_oss == oss) {
+ if(lov->lov_tgts[i] &&
+ lov->lov_tgts[i]->ltd_qos.ltq_oss == oss) {
/* Evenly space these OSTs across arrayspace */
int next = j * ost_count / oss->lqo_ost_count;
LASSERT(next < ost_count);
lov->lov_qos.lq_rr_array[next] = i;
j++;
placed++;
- }
+ }
}
LASSERT(j == oss->lqo_ost_count);
}
struct obd_device *dev = p->private;
struct lov_obd *lov = &dev->u.lov;
- return (*pos >= lov->desc.ld_tgt_count) ? NULL : lov->lov_tgts[*pos];
-
+ while (*pos < lov->desc.ld_tgt_count) {
+ if (lov->lov_tgts[*pos])
+ return lov->lov_tgts[*pos];
+ ++*pos;
+ }
+ return NULL;
}
static void lov_tgt_seq_stop(struct seq_file *p, void *v)
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq;
int rc;
-
+
LPROCFS_ENTRY_AND_CHECK(dp);
rc = seq_open(file, &lov_tgt_sops);
if (rc) {