From 41edf631c7b44563bb2e2d07bf8e347efa876a7a Mon Sep 17 00:00:00 2001 From: wangdi Date: Wed, 7 Sep 2005 06:28:51 +0000 Subject: [PATCH] Branch: HEAD merge HP fixes about ost add/del --- lustre/liblustre/rw.c | 4 ++++ lustre/lov/lov_internal.h | 15 +++++++++++++++ lustre/lov/lov_obd.c | 27 ++++++++++++++++++++++----- lustre/obdclass/obd_config.c | 9 ++++----- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index e0ffe6c..fb41272 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -147,6 +147,10 @@ static int llu_extent_lock_callback(struct ldlm_lock *lock, lsm = lli->lli_smd; stripe = llu_lock_to_stripe_offset(inode, lock); + if (stripe < 0) { + CERROR("lock on inode without such object\n"); + break; + } #warning "fix l_lock() using here!" // l_lock(&lock->l_resource->lr_namespace->ns_lock); kms = ldlm_extent_shift_kms(lock, diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 75258d7..3d944bc 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -126,6 +126,21 @@ lov_tgt_ready(struct lov_obd *lov, struct lov_tgt_desc *tgt, int gen) return rc; } +static inline int +lov_tgt_valid(struct lov_obd *lov, struct lov_tgt_desc *tgt, int gen) +{ + int rc = 0; + lov_tgts_lock(lov); + + if (((gen == 0) || (gen == tgt->ltd_gen)) && (tgt->ltd_exp != NULL)) { + tgt->ltd_refcount++; + rc = 1; + } + + lov_tgts_unlock(lov); + return rc; +} + static inline void lov_tgt_decref(struct lov_obd *lov, struct lov_tgt_desc *tgt) { diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index ba15470..cbb114d 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1469,6 +1469,7 @@ static int lov_prep_async_page(struct obd_export *exp, lap->lap_sub_offset, &lov_async_page_ops, lap, &lap->lap_sub_cookie); + lov_tgt_decref(lov, tgt); } else { rc = -EIO; } @@ -1503,9 +1504,9 @@ static int lov_queue_async_io(struct obd_export *exp, loi = &lsm->lsm_oinfo[lap->lap_stripe]; tgt = lov->tgts + loi->loi_ost_idx; - if (!lov_tgt_ready(lov, tgt, loi->loi_ost_gen)) - RETURN(-EIO); - + if (!lov_tgt_valid(lov, tgt, loi->loi_ost_gen)) + RETURN(-EIO); + rc = obd_queue_async_io(tgt->ltd_exp, lsm, loi, lap->lap_sub_cookie, cmd, off, count, brw_flags, async_flags); @@ -1563,8 +1564,8 @@ static int lov_queue_group_io(struct obd_export *exp, loi = &lsm->lsm_oinfo[lap->lap_stripe]; tgt = lov->tgts + loi->loi_ost_idx; - if (!lov_tgt_ready(lov, tgt, loi->loi_ost_gen)) - RETURN(-EIO); + if (!lov_tgt_valid(lov, tgt, loi->loi_ost_gen)) + RETURN(-EIO); rc = obd_queue_group_io(tgt->ltd_exp, lsm, loi, oig, lap->lap_sub_cookie, cmd, off, count, @@ -1629,6 +1630,13 @@ static int lov_teardown_async_page(struct obd_export *exp, loi = &lsm->lsm_oinfo[lap->lap_stripe]; tgt = lov->tgts + loi->loi_ost_idx; + /* FIXME: this leaks the page, but it should never really happen. + * Should we make this an LBUG() ? */ + if (!lov_tgt_valid(lov, tgt, loi->loi_ost_gen)) { + CERROR("page found with invalid OSC !"); + RETURN(-EIO); + } + rc = obd_teardown_async_page(tgt->ltd_exp, lsm, loi, lap->lap_sub_cookie); lov_tgt_decref(lov, tgt); @@ -1763,6 +1771,11 @@ static int lov_change_cbdata(struct obd_export *exp, submd.lsm_object_id = loi->loi_id; submd.lsm_object_gr = lsm->lsm_object_gr; submd.lsm_stripe_count = 0; + + if (!lov_tgt_valid(lov, tgt, loi->loi_ost_gen)) { + CDEBUG(D_HA, "lov idx %d invalid.\n", loi->loi_ost_idx); + continue; + } rc = obd_change_cbdata(tgt->ltd_exp, &submd, it, data); lov_tgt_decref(lov, tgt); } @@ -2131,9 +2144,13 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, } } lov_tgts_unlock(lov); + + /* This can happen if a deleted OST has been replaced + * in the lsm by the MDS. */ LDLM_ERROR(data->lock, "lock on inode without such object"); dump_lsm(D_ERROR, data->lsm); portals_debug_dumpstack(NULL); + RETURN(-ENXIO); } else if (keylen >= strlen("size_to_stripe") && strcmp(key, "size_to_stripe") == 0) { diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index de792fa..a96e32b 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -640,10 +640,6 @@ static int class_config_parse_handler(struct llog_handle * handle, cfg->cfg_instance); lustre_cfg_bufs_set_string(&bufs, 0, inst_name); } - if (lcfg->lcfg_command == LCFG_ATTACH) { - lustre_cfg_bufs_set_string(&bufs, 2, - (char *)cfg->cfg_uuid.uuid); - } if (lcfg->lcfg_command == LCFG_SETUP) { /*add cfg_instance to the end of lcfg buffers*/ lustre_cfg_bufs_set_string(&bufs, @@ -651,7 +647,10 @@ static int class_config_parse_handler(struct llog_handle * handle, cfg->cfg_instance); } } - + if (cfg && (lcfg->lcfg_command == LCFG_ATTACH)) { + lustre_cfg_bufs_set_string(&bufs, 2, + (char *)cfg->cfg_uuid.uuid); + } lcfg_new = lustre_cfg_new(lcfg->lcfg_command, &bufs); lcfg_new->lcfg_num = lcfg->lcfg_num; -- 1.8.3.1