From 43ac895c7082ea58136a7436faa2ab04d9944a04 Mon Sep 17 00:00:00 2001 From: shadow <shadow> Date: Mon, 1 Sep 2008 11:27:05 +0000 Subject: [PATCH] force send lov target as data for ACTIVE and SYNC events. Branch HEAD b=16826 i=adilger i=green --- lustre/lov/lov_obd.c | 46 +++++++++++++++++++++----------------------- lustre/mds/mds_lov.c | 22 +-------------------- 2 files changed, 23 insertions(+), 45 deletions(-) diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 64d9291c52..739fee3055 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -486,60 +486,59 @@ out: /* 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, @@ -565,12 +564,13 @@ 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. */ @@ -578,6 +578,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, 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; @@ -585,6 +586,11 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, 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) { @@ -2925,14 +2931,6 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, *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); diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index d2b1462982..1f0f995a38 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -340,19 +340,6 @@ static int mds_lov_set_one_nextid(struct obd_device *obd, __u32 idx, obd_id *id) 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) { @@ -403,9 +390,6 @@ out: 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, @@ -753,7 +737,6 @@ int mds_lov_start_synchronize(struct obd_device *obd, { struct mds_lov_sync_info *mlsi; int rc; - struct mds_obd *mds = &obd->u.mds; struct obd_uuid *uuid; ENTRY; @@ -766,10 +749,7 @@ int mds_lov_start_synchronize(struct obd_device *obd, 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 -- GitLab