From 1670c57315340db997c9058950148a05634f43f1 Mon Sep 17 00:00:00 2001 From: wang di Date: Thu, 11 Jun 2015 08:01:07 -0700 Subject: [PATCH] LU-6713 lmv: lock necessary part of lmv_add_target Release lmv_init_mutex once the new target is added into lmv_tgt_desc, so lmv_obd_connect will not be serialized. New target should be allowed to added to fld client lists, so FLD can always choose new added target to do the FLD lookup request, and also remove some noise error messages in this process. Signed-off-by: wang di Change-Id: I1aa2e31108f2da672b41e2a5c1c544605328ceea Reviewed-on: http://review.whamcloud.com/15269 Tested-by: Jenkins Reviewed-by: Niu Yawei Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/fld/fld_internal.h | 5 ----- lustre/fld/fld_request.c | 28 ++++++++---------------- lustre/include/lustre_fld.h | 2 -- lustre/lmv/lmv_obd.c | 53 ++++++++++++++++++++++----------------------- 4 files changed, 35 insertions(+), 53 deletions(-) diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index 473f9fd..3e25314 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -64,11 +64,6 @@ #include #include -enum { - LUSTRE_FLD_INIT = 1 << 0, - LUSTRE_FLD_RUN = 1 << 1 -}; - struct fld_stats { __u64 fst_count; __u64 fst_cache; diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index 8ab76ed..a59ab95 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -164,15 +164,8 @@ int fld_client_add_target(struct lu_client_fld *fld, LASSERT(name != NULL); LASSERT(tar->ft_srv != NULL || tar->ft_exp != NULL); - if (fld->lcf_flags != LUSTRE_FLD_INIT) { - CERROR("%s: Attempt to add target %s (idx "LPU64") " - "on fly - skip it\n", fld->lcf_name, name, - tar->ft_idx); - RETURN(0); - } else { - CDEBUG(D_INFO, "%s: Adding target %s (idx " - LPU64")\n", fld->lcf_name, name, tar->ft_idx); - } + CDEBUG(D_INFO, "%s: Adding target %s (idx "LPU64")\n", fld->lcf_name, + name, tar->ft_idx); OBD_ALLOC_PTR(target); if (target == NULL) @@ -304,10 +297,9 @@ int fld_client_init(struct lu_client_fld *fld, RETURN(-EINVAL); } - fld->lcf_count = 0; + fld->lcf_count = 0; spin_lock_init(&fld->lcf_lock); - fld->lcf_hash = &fld_hash[hash]; - fld->lcf_flags = LUSTRE_FLD_INIT; + fld->lcf_hash = &fld_hash[hash]; INIT_LIST_HEAD(&fld->lcf_targets); cache_size = FLD_CLIENT_CACHE_SIZE / @@ -474,13 +466,11 @@ int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds, int rc; ENTRY; - fld->lcf_flags |= LUSTRE_FLD_RUN; - - rc = fld_cache_lookup(fld->lcf_cache, seq, &res); - if (rc == 0) { - *mds = res.lsr_index; - RETURN(0); - } + rc = fld_cache_lookup(fld->lcf_cache, seq, &res); + if (rc == 0) { + *mds = res.lsr_index; + RETURN(0); + } /* Can not find it in the cache */ target = fld_client_get_target(fld, seq); diff --git a/lustre/include/lustre_fld.h b/lustre/include/lustre_fld.h index f02639b..bc22acf 100644 --- a/lustre/include/lustre_fld.h +++ b/lustre/include/lustre_fld.h @@ -137,8 +137,6 @@ struct lu_client_fld { /** * Client fld proc entry name. */ char lcf_name[80]; - - int lcf_flags; }; /* Server methods */ diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 01f0d6d..86c803b 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -422,6 +422,7 @@ static void lmv_del_target(struct lmv_obd *lmv, int index) static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, __u32 index, int gen) { + struct obd_device *mdc_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int orig_tgt_count = 0; @@ -429,22 +430,15 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, ENTRY; CDEBUG(D_CONFIG, "Target uuid: %s. index %d\n", uuidp->uuid, index); - - mutex_lock(&lmv->lmv_init_mutex); - - if (lmv->desc.ld_tgt_count == 0) { - struct obd_device *mdc_obd; - - mdc_obd = class_find_client_obd(uuidp, LUSTRE_MDC_NAME, - &obd->obd_uuid); - if (!mdc_obd) { - mutex_unlock(&lmv->lmv_init_mutex); - CERROR("%s: Target %s not attached: rc = %d\n", - obd->obd_name, uuidp->uuid, -EINVAL); - RETURN(-EINVAL); - } + mdc_obd = class_find_client_obd(uuidp, LUSTRE_MDC_NAME, + &obd->obd_uuid); + if (!mdc_obd) { + CERROR("%s: Target %s not attached: rc = %d\n", + obd->obd_name, uuidp->uuid, -EINVAL); + RETURN(-EINVAL); } + mutex_lock(&lmv->lmv_init_mutex); if ((index < lmv->tgts_size) && (lmv->tgts[index] != NULL)) { tgt = lmv->tgts[index]; CERROR("%s: UUID %s already assigned at LOV target index %d:" @@ -501,22 +495,27 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lmv->desc.ld_tgt_count = index + 1; } - if (lmv->connected) { - rc = lmv_connect_mdc(obd, tgt); - if (rc != 0) { - spin_lock(&lmv->lmv_lock); - if (lmv->desc.ld_tgt_count == index + 1) - lmv->desc.ld_tgt_count = orig_tgt_count; - memset(tgt, 0, sizeof(*tgt)); - spin_unlock(&lmv->lmv_lock); - } else { - int easize = sizeof(struct lmv_stripe_md) + - lmv->desc.ld_tgt_count * sizeof(struct lu_fid); - lmv_init_ea_size(obd->obd_self_export, easize, 0); - } + if (lmv->connected == 0) { + /* lmv_check_connect() will connect this target. */ + mutex_unlock(&lmv->lmv_init_mutex); + RETURN(0); } + /* Otherwise let's connect it ourselves */ mutex_unlock(&lmv->lmv_init_mutex); + rc = lmv_connect_mdc(obd, tgt); + if (rc != 0) { + spin_lock(&lmv->lmv_lock); + if (lmv->desc.ld_tgt_count == index + 1) + lmv->desc.ld_tgt_count = orig_tgt_count; + memset(tgt, 0, sizeof(*tgt)); + spin_unlock(&lmv->lmv_lock); + } else { + int easize = sizeof(struct lmv_stripe_md) + + lmv->desc.ld_tgt_count * sizeof(struct lu_fid); + lmv_init_ea_size(obd->obd_self_export, easize, 0); + } + RETURN(rc); } -- 1.8.3.1