/* XXX - right now there is a dependency on ld_tgt_count
* being the maximum tgt index for computing the
* mds_max_easize. So we can't shrink it. */
- lov_ost_pool_remove(&lov->lov_packed, i);
+ tgt_pool_remove(&lov->lov_packed, i);
lov->lov_tgts[i] = NULL;
lov->lov_death_row--;
}
}
}
-static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
- enum obd_notify_event ev);
static int lov_notify(struct obd_device *obd, struct obd_device *watched,
enum obd_notify_event ev);
static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
{
- struct lov_obd *lov = &obd->u.lov;
- struct obd_device *osc_obd;
- int rc;
- ENTRY;
+ struct lov_obd *lov = &obd->u.lov;
+ struct obd_device *osc_obd;
+ int rc;
+ ENTRY;
- osc_obd = class_exp2obd(tgt->ltd_exp);
- CDEBUG(D_CONFIG, "%s: disconnecting target %s\n",
- obd->obd_name, osc_obd->obd_name);
+ osc_obd = class_exp2obd(tgt->ltd_exp);
+ CDEBUG(D_CONFIG, "%s: disconnecting target %s\n", obd->obd_name,
+ osc_obd ? osc_obd->obd_name : "<no obd>");
- if (tgt->ltd_active) {
- tgt->ltd_active = 0;
- lov->desc.ld_active_tgt_count--;
- tgt->ltd_exp->exp_obd->obd_inactive = 1;
- }
+ if (tgt->ltd_active) {
+ tgt->ltd_active = 0;
+ lov->desc.ld_active_tgt_count--;
+ tgt->ltd_exp->exp_obd->obd_inactive = 1;
+ }
if (osc_obd) {
if (lov->lov_tgts_kobj)
osc_obd->obd_force = obd->obd_force;
osc_obd->obd_fail = obd->obd_fail;
osc_obd->obd_no_recov = obd->obd_no_recov;
-
- if (lov->targets_proc_entry != NULL)
- lprocfs_remove_proc_entry(osc_obd->obd_name,
- lov->targets_proc_entry);
}
- obd_register_observer(osc_obd, NULL);
+ obd_register_observer(osc_obd, NULL);
- rc = obd_disconnect(tgt->ltd_exp);
- if (rc) {
- CERROR("Target %s disconnect error %d\n",
- tgt->ltd_uuid.uuid, rc);
- rc = 0;
- }
+ rc = obd_disconnect(tgt->ltd_exp);
+ if (rc) {
+ CERROR("Target %s disconnect error %d\n",
+ tgt->ltd_uuid.uuid, rc);
+ rc = 0;
+ }
- tgt->ltd_exp = NULL;
- RETURN(0);
+ tgt->ltd_exp = NULL;
+ RETURN(0);
}
static int lov_disconnect(struct obd_export *exp)
* any >= 0 : is log target index
*/
static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
- enum obd_notify_event ev)
+ enum obd_notify_event ev)
{
- struct lov_obd *lov = &obd->u.lov;
- struct lov_tgt_desc *tgt;
- int index, activate, active;
- ENTRY;
+ struct lov_obd *lov = &obd->u.lov;
+ struct lov_tgt_desc *tgt;
+ int index;
+ bool activate, active;
+ ENTRY;
- CDEBUG(D_INFO, "Searching in lov %p for uuid %s event(%d)\n",
- lov, uuid->uuid, ev);
+ CDEBUG(D_INFO, "Searching in lov %p for uuid %s event(%d)\n",
+ lov, uuid->uuid, ev);
lov_tgts_getref(obd);
for (index = 0; index < lov->desc.ld_tgt_count; index++) {
tgt = lov->lov_tgts[index];
- if (!tgt)
- continue;
- if (obd_uuid_equals(uuid, &tgt->ltd_uuid))
+ if (tgt && obd_uuid_equals(uuid, &tgt->ltd_uuid))
break;
- }
+ }
- if (index == lov->desc.ld_tgt_count)
- GOTO(out, index = -EINVAL);
+ if (index == lov->desc.ld_tgt_count)
+ GOTO(out, index = -EINVAL);
- if (ev == OBD_NOTIFY_DEACTIVATE || ev == OBD_NOTIFY_ACTIVATE) {
- activate = (ev == OBD_NOTIFY_ACTIVATE) ? 1 : 0;
+ if (ev == OBD_NOTIFY_DEACTIVATE || ev == OBD_NOTIFY_ACTIVATE) {
+ activate = (ev == OBD_NOTIFY_ACTIVATE);
/*
* LU-642, initially inactive OSC could miss the obd_connect,
rc = obd_connect(NULL, &tgt->ltd_exp, tgt->ltd_obd,
&lov_osc_uuid, &lov->lov_ocd,
lov->lov_cache);
- if (rc || tgt->ltd_exp == NULL)
+ if (rc || !tgt->ltd_exp)
GOTO(out, index = rc);
}
- if (lov->lov_tgts[index]->ltd_activate == activate) {
- CDEBUG(D_INFO, "OSC %s already %sactivate!\n",
- uuid->uuid, activate ? "" : "de");
- } else {
- lov->lov_tgts[index]->ltd_activate = activate;
- CDEBUG(D_CONFIG, "%sactivate OSC %s\n",
- activate ? "" : "de", obd_uuid2str(uuid));
- }
-
- } else if (ev == OBD_NOTIFY_INACTIVE || ev == OBD_NOTIFY_ACTIVE) {
- active = (ev == OBD_NOTIFY_ACTIVE) ? 1 : 0;
-
- if (lov->lov_tgts[index]->ltd_active == active) {
- CDEBUG(D_INFO, "OSC %s already %sactive!\n",
- uuid->uuid, active ? "" : "in");
- GOTO(out, index);
- } else {
- CDEBUG(D_CONFIG, "Marking OSC %s %sactive\n",
- obd_uuid2str(uuid), active ? "" : "in");
- }
+ if (lov->lov_tgts[index]->ltd_activate == activate) {
+ CDEBUG(D_INFO, "OSC %s already %sactivate!\n",
+ uuid->uuid, activate ? "" : "de");
+ } else {
+ lov->lov_tgts[index]->ltd_activate = activate;
+ CDEBUG(D_CONFIG, "%sactivate OSC %s\n",
+ activate ? "" : "de", obd_uuid2str(uuid));
+ }
+ } else if (ev == OBD_NOTIFY_INACTIVE || ev == OBD_NOTIFY_ACTIVE) {
+ active = (ev == OBD_NOTIFY_ACTIVE);
- lov->lov_tgts[index]->ltd_active = active;
- if (active) {
- lov->desc.ld_active_tgt_count++;
- lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 0;
- } else {
- lov->desc.ld_active_tgt_count--;
- lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 1;
- }
+ if (lov->lov_tgts[index]->ltd_active == active) {
+ CDEBUG(D_INFO, "OSC %s already %sactive!\n",
+ uuid->uuid, active ? "" : "in");
+ GOTO(out, index);
+ }
+ CDEBUG(D_CONFIG, "Marking OSC %s %sactive\n",
+ obd_uuid2str(uuid), active ? "" : "in");
+
+ lov->lov_tgts[index]->ltd_active = active;
+ if (active) {
+ lov->desc.ld_active_tgt_count++;
+ lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 0;
+ } else {
+ lov->desc.ld_active_tgt_count--;
+ lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 1;
+ }
} else {
CERROR("%s: unknown event %d for uuid %s\n", obd->obd_name,
ev, uuid->uuid);
RETURN(-ENOMEM);
}
- rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
+ rc = tgt_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
if (rc) {
mutex_unlock(&lov->lov_lock);
OBD_FREE_PTR(tgt);
if (rc)
GOTO(out, rc);
- rc = lov_ost_pool_init(&lov->lov_packed, 0);
+ rc = tgt_pool_init(&lov->lov_packed, 0);
if (rc)
GOTO(out, rc);
lov_pool_del(obd, pool->pool_name);
}
lov_pool_hash_destroy(&lov->lov_pools_hash_body);
- lov_ost_pool_free(&lov->lov_packed);
+ tgt_pool_free(&lov->lov_packed);
lprocfs_obd_cleanup(obd);
if (lov->lov_tgts) {
continue;
/* Inactive targets may never have connected */
- if (lov->lov_tgts[i]->ltd_active ||
- atomic_read(&lov->lov_refcount))
+ if (lov->lov_tgts[i]->ltd_active)
/* We should never get here - these
* should have been removed in the
* disconnect. */
struct obd_device *obd = class_exp2obd(exp);
struct lov_obd *lov = &obd->u.lov;
int i = 0, rc = 0, count = lov->desc.ld_tgt_count;
- struct obd_uuid *uuidp;
ENTRY;
switch (cmd) {
RETURN(-EFAULT);
break;
}
- case OBD_IOC_LOV_GET_CONFIG: {
- struct obd_ioctl_data *data;
- struct lov_desc *desc;
- char *buf = NULL;
- __u32 *genp;
-
- len = 0;
- if (obd_ioctl_getdata(&buf, &len, uarg))
- RETURN(-EINVAL);
-
- data = (struct obd_ioctl_data *)buf;
-
- if (sizeof(*desc) > data->ioc_inllen1) {
- OBD_FREE_LARGE(buf, len);
- RETURN(-EINVAL);
- }
-
- if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) {
- OBD_FREE_LARGE(buf, len);
- RETURN(-EINVAL);
- }
-
- if (sizeof(__u32) * count > data->ioc_inllen3) {
- OBD_FREE_LARGE(buf, len);
- RETURN(-EINVAL);
- }
-
- desc = (struct lov_desc *)data->ioc_inlbuf1;
- memcpy(desc, &(lov->desc), sizeof(*desc));
-
- uuidp = (struct obd_uuid *)data->ioc_inlbuf2;
- genp = (__u32 *)data->ioc_inlbuf3;
- /* the uuid will be empty for deleted OSTs */
- for (i = 0; i < count; i++, uuidp++, genp++) {
- if (!lov->lov_tgts[i])
- continue;
- *uuidp = lov->lov_tgts[i]->ltd_uuid;
- *genp = lov->lov_tgts[i]->ltd_gen;
- }
-
- if (copy_to_user(uarg, buf, len))
- rc = -EFAULT;
- OBD_FREE_LARGE(buf, len);
- break;
- }
case OBD_IOC_QUOTACTL: {
struct if_quotactl *qctl = karg;
struct lov_tgt_desc *tgt = NULL;
OBD_FREE_PTR(oqctl);
break;
}
- default: {
- int set = 0;
+ default: {
+ int set = 0;
- if (count == 0)
- RETURN(-ENOTTY);
+ if (count == 0)
+ RETURN(-ENOTTY);
- for (i = 0; i < count; i++) {
- int err;
- struct obd_device *osc_obd;
+ for (i = 0; i < count; i++) {
+ int err;
+ struct obd_device *osc_obd;
- /* OST was disconnected */
- if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_exp)
- continue;
+ /* OST was disconnected */
+ if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_exp)
+ continue;
/* ll_umount_begin() sets force on lov, pass to osc */
osc_obd = class_exp2obd(lov->lov_tgts[i]->ltd_exp);
- osc_obd->obd_force = obd->obd_force;
+ if (osc_obd)
+ osc_obd->obd_force = obd->obd_force;
err = obd_iocontrol(cmd, lov->lov_tgts[i]->ltd_exp,
len, karg, uarg);
if (err) {
- if (lov->lov_tgts[i]->ltd_active) {
- CDEBUG(err == -ENOTTY ?
- D_IOCTL : D_WARNING,
- "iocontrol OSC %s on OST "
- "idx %d cmd %x: err = %d\n",
- lov_uuid2str(lov, i),
- i, cmd, err);
- if (!rc)
- rc = err;
- }
- } else {
- set = 1;
- }
- }
- if (!set && !rc)
- rc = -EIO;
- }
- }
+ if (lov->lov_tgts[i]->ltd_active) {
+ CDEBUG_LIMIT(err == -ENOTTY ?
+ D_IOCTL : D_WARNING,
+ "iocontrol OSC %s on OST idx %d cmd %x: err = %d\n",
+ lov_uuid2str(lov, i),
+ i, cmd, err);
+ if (!rc)
+ rc = err;
+ }
+ } else {
+ set = 1;
+ }
+ }
+ if (!set && !rc)
+ rc = -EIO;
+ }
+ }
- RETURN(rc);
+ RETURN(rc);
}
static int lov_get_info(const struct lu_env *env, struct obd_export *exp,
}
if (oqctl->qc_cmd == LUSTRE_Q_GETQUOTAPOOL) {
- rcu_read_lock();
- pool = rhashtable_lookup(&lov->lov_pools_hash_body,
- oqctl->qc_poolname,
- pools_hash_params);
- if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
- pool = NULL;
- rcu_read_unlock();
+ pool = lov_pool_find(obd, oqctl->qc_poolname);
if (!pool)
RETURN(-ENOENT);
/* Set Q_GETOQUOTA back as targets report it's own
return -ENOMEM;
}
- rc = class_register_type(&lov_obd_ops, NULL, true, NULL,
+ rc = class_register_type(&lov_obd_ops, NULL, true,
LUSTRE_LOV_NAME, &lov_device_type);
if (rc) {
kmem_cache_destroy(lov_oinfo_slab);