From 3ededde903c92f8485cae0dc9f958f194ff0b140 Mon Sep 17 00:00:00 2001 From: wang di Date: Mon, 30 Mar 2015 19:43:23 -0700 Subject: [PATCH] LU-6419 fld: fld client lookup should retry If FLD client lookup fails because of the remote target is shutdown (or deactive), it should retry another target, otherwise it will cause the application failure. And FLD client should stop retry if the import has been deactive. Signed-off-by: wang di Change-Id: Ic5934054bf0aff3158b6fe040fcb26699336f038 Reviewed-on: http://review.whamcloud.com/14313 Tested-by: Jenkins Reviewed-by: Lai Siyao Reviewed-by: Fan Yong Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/fld/fld_request.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index 2217475..8ab76ed 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -433,7 +433,7 @@ again: } if (rc != 0) { - if (imp->imp_state != LUSTRE_IMP_CLOSED) { + if (imp->imp_state != LUSTRE_IMP_CLOSED && !imp->imp_deactive) { /* Since LWP is not replayable, so it will keep * trying unless umount happens, otherwise it would * cause unecessary failure of the application. */ @@ -470,6 +470,7 @@ int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds, { struct lu_seq_range res = { 0 }; struct lu_fld_target *target; + struct lu_fld_target *origin; int rc; ENTRY; @@ -484,7 +485,8 @@ int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds, /* Can not find it in the cache */ target = fld_client_get_target(fld, seq); LASSERT(target != NULL); - + origin = target; +again: CDEBUG(D_INFO, "%s: Lookup fld entry (seq: "LPX64") on " "target %s (idx "LPU64")\n", fld->lcf_name, seq, fld_target_name(target), target->ft_idx); @@ -502,6 +504,22 @@ int fld_client_lookup(struct lu_client_fld *fld, u64 seq, u32 *mds, rc = fld_client_rpc(target->ft_exp, &res, FLD_QUERY, NULL); } + if (rc == -ESHUTDOWN) { + /* If fld lookup failed because the target has been shutdown, + * then try next target in the list, until trying all targets + * or fld lookup succeeds */ + spin_lock(&fld->lcf_lock); + if (target->ft_chain.next == fld->lcf_targets.prev) + target = list_entry(fld->lcf_targets.next, + struct lu_fld_target, ft_chain); + else + target = list_entry(target->ft_chain.next, + struct lu_fld_target, + ft_chain); + spin_unlock(&fld->lcf_lock); + if (target != origin) + goto again; + } if (rc == 0) { *mds = res.lsr_index; fld_cache_insert(fld->lcf_cache, &res); -- 1.8.3.1