Whamcloud - gitweb
LU-6419 fld: fld client lookup should retry 13/14313/4
authorwang di <di.wang@intel.com>
Tue, 31 Mar 2015 02:43:23 +0000 (19:43 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 7 May 2015 16:17:23 +0000 (16:17 +0000)
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 <di.wang@intel.com>
Change-Id: Ic5934054bf0aff3158b6fe040fcb26699336f038
Reviewed-on: http://review.whamcloud.com/14313
Tested-by: Jenkins
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/fld/fld_request.c

index 2217475..8ab76ed 100644 (file)
@@ -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);