/* Error codes:
*
* -EINVAL : UUID can't be found in the LOV's target list
- * -ENOTCONN: The UUID is found, but the target connection is bad (!)
- * -EBADF : The UUID is found, but the OBD is the wrong type (!)
+ * - any other is lov index
*/
static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
int activate)
{
struct lov_obd *lov = &obd->u.lov;
struct lov_tgt_desc *tgt;
- int i, rc = 0;
+ int index;
ENTRY;
CDEBUG(D_INFO, "Searching in lov %p for uuid %s (activate=%d)\n",
lov, uuid->uuid, activate);
lov_getref(obd);
- for (i = 0; i < lov->desc.ld_tgt_count; i++) {
- tgt = lov->lov_tgts[i];
+ for (index = 0; index < lov->desc.ld_tgt_count; index++) {
+ tgt = lov->lov_tgts[index];
if (!tgt || !tgt->ltd_exp)
continue;
CDEBUG(D_INFO, "lov idx %d is %s conn "LPX64"\n",
- i, obd_uuid2str(&tgt->ltd_uuid),
+ index, obd_uuid2str(&tgt->ltd_uuid),
tgt->ltd_exp->exp_handle.h_cookie);
if (obd_uuid_equals(uuid, &tgt->ltd_uuid))
break;
}
- if (i == lov->desc.ld_tgt_count)
- GOTO(out, rc = -EINVAL);
+ if (index == lov->desc.ld_tgt_count)
+ GOTO(out, index = -EINVAL);
- if (lov->lov_tgts[i]->ltd_active == activate) {
+ if (lov->lov_tgts[index]->ltd_active == activate) {
CDEBUG(D_INFO, "OSC %s already %sactive!\n", uuid->uuid,
activate ? "" : "in");
- GOTO(out, rc);
+ GOTO(out, index);
}
CDEBUG(D_CONFIG, "Marking OSC %s %sactive\n", obd_uuid2str(uuid),
activate ? "" : "in");
- lov->lov_tgts[i]->ltd_active = activate;
+ lov->lov_tgts[index]->ltd_active = activate;
if (activate) {
lov->desc.ld_active_tgt_count++;
- lov->lov_tgts[i]->ltd_exp->exp_obd->obd_inactive = 0;
+ lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 0;
} else {
lov->desc.ld_active_tgt_count--;
- lov->lov_tgts[i]->ltd_exp->exp_obd->obd_inactive = 1;
+ lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 1;
}
/* remove any old qos penalty */
- lov->lov_tgts[i]->ltd_qos.ltq_penalty = 0;
+ lov->lov_tgts[index]->ltd_qos.ltq_penalty = 0;
out:
lov_putref(obd);
- RETURN(rc);
+ RETURN(index);
}
static int lov_notify(struct obd_device *obd, struct obd_device *watched,
* observer can use the OSC normally.
*/
rc = lov_set_osc_active(obd, uuid, ev == OBD_NOTIFY_ACTIVE);
- if (rc) {
+ if (rc < 0) {
CERROR("%sactivation of %s failed: %d\n",
(ev == OBD_NOTIFY_ACTIVE) ? "" : "de",
obd_uuid2str(uuid), rc);
RETURN(rc);
}
+ data = &rc;
}
/* Pass the notification up the chain. */
rc = obd_notify_observer(obd, watched, ev, data);
} else {
/* NULL watched means all osc's in the lov (only for syncs) */
+ /* sync event should be send lov idx as data */
struct lov_obd *lov = &obd->u.lov;
struct obd_device *tgt_obd;
int i;
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
if (!lov->lov_tgts[i])
continue;
+
+ if ((ev == OBD_NOTIFY_SYNC) ||
+ (ev == OBD_NOTIFY_SYNC_NONBLOCK))
+ data = &i;
+
tgt_obd = class_exp2obd(lov->lov_tgts[i]->ltd_exp);
rc = obd_notify_observer(obd, tgt_obd, ev, data);
if (rc) {
*desc_ret = lov->desc;
GOTO(out, rc = 0);
- } else if (KEY_IS(KEY_LOV_IDX)) {
- struct lov_tgt_desc *tgt;
-
- for(i = 0; i < lov->desc.ld_tgt_count; i++) {
- tgt = lov->lov_tgts[i];
- if (tgt && obd_uuid_equals(val, &tgt->ltd_uuid))
- GOTO(out, rc = i);
- }
} else if (KEY_IS(KEY_FIEMAP)) {
rc = lov_fiemap(lov, keylen, key, vallen, val, lsm);
GOTO(out, rc);
RETURN(rc);
}
-static __u32 mds_lov_get_idx(struct obd_export *lov,
- struct obd_uuid *ost_uuid)
-{
- int rc;
- int valsize = sizeof(ost_uuid);
-
- rc = obd_get_info(lov, sizeof(KEY_LOV_IDX), KEY_LOV_IDX,
- &valsize, ost_uuid, NULL);
- LASSERT(rc >= 0);
-
- RETURN(rc);
-}
-
/* Update the lov desc for a new size lov. */
static int mds_lov_update_desc(struct obd_device *obd, struct obd_export *lov)
{
RETURN(rc);
}
-
-#define MDSLOV_NO_INDEX -1
-
/* Inform MDS about new/updated target */
static int mds_lov_update_mds(struct obd_device *obd,
struct obd_device *watched,
{
struct mds_lov_sync_info *mlsi;
int rc;
- struct mds_obd *mds = &obd->u.mds;
struct obd_uuid *uuid;
ENTRY;
mlsi->mlsi_obd = obd;
mlsi->mlsi_watched = watched;
- if (data)
- mlsi->mlsi_index = *(__u32 *)data;
- else
- mlsi->mlsi_index = mds_lov_get_idx(mds->mds_osc_exp, uuid);
+ mlsi->mlsi_index = *(__u32 *)data;
/* Although class_export_get(obd->obd_self_export) would lock
the MDS in place, since it's only a self-export