From 96360e631635e82fe469d2cba3128310a5c41110 Mon Sep 17 00:00:00 2001 From: "robert.read" Date: Tue, 7 Apr 2009 05:05:20 +0000 Subject: [PATCH] Branch HEAD b=18554 o=shadow,rread i=zam i=eric.mei Full fix for 18554. Includes original patch, Shadow's new fixes, and a test. --- lustre/include/obd.h | 1 + lustre/lov/lov_dev.c | 32 ++++++++++++++++++++------------ lustre/lov/lov_obd.c | 25 +++++++++++-------------- lustre/lov/lov_object.c | 1 + lustre/tests/replay-single.sh | 13 +++++++++++++ 5 files changed, 46 insertions(+), 26 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 4925fc8..79c9fb2 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -693,6 +693,7 @@ struct lov_qos { struct lov_tgt_desc { struct list_head ltd_kill; struct obd_uuid ltd_uuid; + struct obd_device *ltd_obd; struct obd_export *ltd_exp; struct ltd_qos ltd_qos; /* qos info per target */ __u32 ltd_gen; diff --git a/lustre/lov/lov_dev.c b/lustre/lov/lov_dev.c index cab0e3b..fd5e24a 100644 --- a/lustre/lov/lov_dev.c +++ b/lustre/lov/lov_dev.c @@ -243,18 +243,19 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, struct lov_tgt_desc *desc; desc = ld->ld_lov->lov_tgts[i]; - if (desc->ltd_active) { - cl = cl_type_setup(env, d->ld_site, &lovsub_device_type, - desc->ltd_exp->exp_obd->obd_lu_dev); - if (IS_ERR(cl)) { - rc = PTR_ERR(cl); - break; - } - lsd = cl2lovsub_dev(cl); - lsd->acid_idx = i; - lsd->acid_super = ld; - ld->ld_target[i] = lsd; + if (desc == NULL) + continue; + + cl = cl_type_setup(env, d->ld_site, &lovsub_device_type, + desc->ltd_obd->obd_lu_dev); + if (IS_ERR(cl)) { + rc = PTR_ERR(cl); + break; } + lsd = cl2lovsub_dev(cl); + lsd->acid_idx = i; + lsd->acid_super = ld; + ld->ld_target[i] = lsd; } if (rc) @@ -424,12 +425,19 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, tgt = obd->u.lov.lov_tgts[index]; LASSERT(tgt != NULL); + LASSERT(tgt->ltd_obd != NULL); + + if (!tgt->ltd_obd->obd_set_up) { + CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid)); + RETURN(-EINVAL); + } rc = lov_expand_targets(env, ld); if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) { LASSERT(dev->ld_site != NULL); + cl = cl_type_setup(env, dev->ld_site, &lovsub_device_type, - tgt->ltd_exp->exp_obd->obd_lu_dev); + tgt->ltd_obd->obd_lu_dev); if (!IS_ERR(cl)) { lsd = cl2lovsub_dev(cl); lsd->acid_idx = index; diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index e51b0e2..d0b0d77 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -134,7 +134,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, struct lov_obd *lov = &obd->u.lov; struct obd_uuid tgt_uuid; struct obd_device *tgt_obd; - struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; + static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; struct obd_import *imp; #ifdef __KERNEL__ @@ -147,14 +147,8 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, RETURN(-EINVAL); tgt_uuid = lov->lov_tgts[index]->ltd_uuid; + tgt_obd = lov->lov_tgts[index]->ltd_obd; - tgt_obd = class_find_client_obd(&tgt_uuid, LUSTRE_OSC_NAME, - &obd->obd_uuid); - - if (!tgt_obd) { - CERROR("Target %s not attached\n", obd_uuid2str(&tgt_uuid)); - RETURN(-EINVAL); - } if (!tgt_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(&tgt_uuid)); RETURN(-EINVAL); @@ -201,11 +195,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, } lov->lov_tgts[index]->ltd_reap = 0; - if (activate) { - lov->lov_tgts[index]->ltd_active = 1; - lov->desc.ld_active_tgt_count++; - lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 0; - } + CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index, obd_uuid2str(&tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); @@ -453,7 +443,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, { int rc = 0; ENTRY; - + if (ev == OBD_NOTIFY_ACTIVE || ev == OBD_NOTIFY_INACTIVE) { struct obd_uuid *uuid; @@ -524,6 +514,7 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, { struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; + struct obd_device *tgt_obd; int rc; ENTRY; @@ -536,6 +527,11 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, RETURN(-EINVAL); } + tgt_obd = class_find_client_obd(uuidp, LUSTRE_OSC_NAME, + &obd->obd_uuid); + if (tgt_obd == NULL) + RETURN(-EINVAL); + mutex_down(&lov->lov_lock); if ((index < lov->lov_tgt_size) && (lov->lov_tgts[index] != NULL)) { @@ -587,6 +583,7 @@ int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, memset(tgt, 0, sizeof(*tgt)); tgt->ltd_uuid = *uuidp; + tgt->ltd_obd = tgt_obd; /* XXX - add a sanity check on the generation number. */ tgt->ltd_gen = gen; tgt->ltd_index = index; diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index 2ecd756..8ef1413 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -218,6 +218,7 @@ static int lov_init_raid0(const struct lu_env *env, oinfo_get_fid(oinfo, ofid); subdev = lovsub2cl_dev(dev->ld_target[ost_idx]); subconf->u.coc_oinfo = oinfo; + LASSERTF(subdev != NULL, "not init ost %d\n", ost_idx); stripe = lov_sub_find(env, subdev, ofid, subconf); if (!IS_ERR(stripe)) result = lov_init_sub(env, lov, stripe, r0, i); diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 3fd3517..4521ad9 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -1898,6 +1898,19 @@ test_73c() { } run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close" +# bug 18554 +test_74() { + stop ost1 + zconf_umount $(hostname) $MOUNT + fail $SINGLEMDS + zconf_mount $(hostname) $MOUNT + mount_facet ost1 + touch $DIR/$tfile || return 1 + rm $DIR/$tfile || return 2 + return 0 +} +run_test 74 "Ensure applications don't fail waiting for OST reocvery" + test_80a() { [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0 -- 1.8.3.1