1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/ptlrpc/pinger.c
38 * Portal-RPC reconnection and replay operations, for use in recovery.
42 #include <liblustre.h>
44 #define DEBUG_SUBSYSTEM S_RPC
47 #include <obd_support.h>
48 #include <obd_class.h>
49 #include "ptlrpc_internal.h"
51 struct semaphore pinger_sem;
52 static struct list_head pinger_imports = CFS_LIST_HEAD_INIT(pinger_imports);
53 static struct list_head timeout_list = CFS_LIST_HEAD_INIT(timeout_list);
55 struct ptlrpc_request *
56 ptlrpc_prep_ping(struct obd_import *imp)
58 struct ptlrpc_request *req;
60 req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION,
61 OBD_PING, 1, NULL, NULL);
63 ptlrpc_req_set_repsize(req, 1, NULL);
64 req->rq_no_resend = req->rq_no_delay = 1;
69 int ptlrpc_obd_ping(struct obd_device *obd)
72 struct ptlrpc_request *req;
75 req = ptlrpc_prep_ping(obd->u.cli.cl_import);
79 req->rq_send_state = LUSTRE_IMP_FULL;
81 rc = ptlrpc_queue_wait(req);
83 ptlrpc_req_finished(req);
87 EXPORT_SYMBOL(ptlrpc_obd_ping);
89 int ptlrpc_ping(struct obd_import *imp)
91 struct ptlrpc_request *req;
95 req = ptlrpc_prep_ping(imp);
97 DEBUG_REQ(D_INFO, req, "pinging %s->%s",
98 imp->imp_obd->obd_uuid.uuid,
99 obd2cli_tgt(imp->imp_obd));
100 ptlrpcd_add_req(req);
102 CERROR("OOM trying to ping %s->%s\n",
103 imp->imp_obd->obd_uuid.uuid,
104 obd2cli_tgt(imp->imp_obd));
110 EXPORT_SYMBOL(ptlrpc_ping);
112 void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
115 int time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL;
116 if (imp->imp_state == LUSTRE_IMP_DISCON) {
117 int dtime = max_t(int, CONNECTION_SWITCH_MIN,
119 at_get(&imp->imp_at.iat_net_latency));
120 time = min(time, dtime);
122 imp->imp_next_ping = cfs_time_shift(time);
123 #endif /* ENABLE_PINGER */
126 void ptlrpc_ping_import_soon(struct obd_import *imp)
128 imp->imp_next_ping = cfs_time_current();
131 static inline int imp_is_deactive(struct obd_import *imp)
133 return (imp->imp_deactive ||
134 OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_IMP_DEACTIVE));
137 cfs_duration_t pinger_check_timeout(cfs_time_t time)
139 struct timeout_item *item;
140 cfs_time_t timeout = PING_INTERVAL;
142 /* The timeout list is a increase order sorted list */
143 mutex_down(&pinger_sem);
144 list_for_each_entry(item, &timeout_list, ti_chain) {
145 int ti_timeout = item->ti_timeout;
146 if (timeout > ti_timeout)
147 timeout = ti_timeout;
150 mutex_up(&pinger_sem);
152 return cfs_time_sub(cfs_time_add(time, cfs_time_seconds(timeout)),
157 static int ptlrpc_pinger_main(void *arg)
159 struct ptlrpc_svc_data *data = (struct ptlrpc_svc_data *)arg;
160 struct ptlrpc_thread *thread = data->thread;
163 cfs_daemonize(data->name);
165 /* Record that the thread is running */
166 thread->t_flags = SVC_RUNNING;
167 cfs_waitq_signal(&thread->t_ctl_waitq);
169 /* And now, loop forever, pinging as needed. */
171 cfs_time_t this_ping = cfs_time_current();
172 struct l_wait_info lwi;
173 cfs_duration_t time_to_next_wake;
174 struct timeout_item *item;
175 struct list_head *iter;
177 mutex_down(&pinger_sem);
178 list_for_each_entry(item, &timeout_list, ti_chain) {
179 item->ti_cb(item, item->ti_cb_data);
181 list_for_each(iter, &pinger_imports) {
182 struct obd_import *imp =
183 list_entry(iter, struct obd_import,
187 spin_lock(&imp->imp_lock);
188 level = imp->imp_state;
189 force = imp->imp_force_verify;
190 imp->imp_force_verify = 0;
191 spin_unlock(&imp->imp_lock);
193 CDEBUG(level == LUSTRE_IMP_FULL ? D_INFO : D_RPCTRACE,
194 "level %s/%u force %u deactive %u pingable %u\n",
195 ptlrpc_import_state_name(level), level,
196 force, imp->imp_deactive, imp->imp_pingable);
199 /* if the next ping is within, say, 5 jiffies from
200 now, go ahead and ping. See note below. */
201 cfs_time_aftereq(this_ping,
202 imp->imp_next_ping - 5 * CFS_TICK)) {
203 if (level == LUSTRE_IMP_DISCON &&
204 !imp_is_deactive(imp)) {
205 /* wait at least a timeout before
206 trying recovery again. */
207 imp->imp_next_ping = cfs_time_shift(obd_timeout);
208 ptlrpc_initiate_recovery(imp);
209 } else if (level != LUSTRE_IMP_FULL ||
210 imp->imp_obd->obd_no_recov ||
211 imp_is_deactive(imp)) {
212 CDEBUG(D_HA, "not pinging %s "
213 "(in recovery: %s or recovery "
214 "disabled: %u/%u)\n",
215 obd2cli_tgt(imp->imp_obd),
216 ptlrpc_import_state_name(level),
218 imp->imp_obd->obd_no_recov);
219 } else if (imp->imp_pingable || force) {
223 if (!imp->imp_pingable)
226 "don't need to ping %s ("CFS_TIME_T
227 " > "CFS_TIME_T")\n",
228 obd2cli_tgt(imp->imp_obd),
229 imp->imp_next_ping, this_ping);
232 /* obd_timeout might have changed */
233 if (cfs_time_after(imp->imp_next_ping,
234 cfs_time_add(this_ping,
235 cfs_time_seconds(PING_INTERVAL))))
236 ptlrpc_update_next_ping(imp, 0);
238 mutex_up(&pinger_sem);
239 /* update memory usage info */
240 obd_update_maxusage();
242 /* Wait until the next ping time, or until we're stopped. */
243 time_to_next_wake = pinger_check_timeout(this_ping);
244 /* The ping sent by ptlrpc_send_rpc may get sent out
245 say .01 second after this.
246 ptlrpc_pinger_eending_on_import will then set the
247 next ping time to next_ping + .01 sec, which means
248 we will SKIP the next ping at next_ping, and the
249 ping will get sent 2 timeouts from now! Beware. */
250 CDEBUG(D_INFO, "next wakeup in "CFS_DURATION_T" ("CFS_TIME_T")\n",
252 cfs_time_add(this_ping, cfs_time_seconds(PING_INTERVAL)));
253 if (time_to_next_wake > 0) {
254 lwi = LWI_TIMEOUT(max_t(cfs_duration_t, time_to_next_wake, cfs_time_seconds(1)),
256 l_wait_event(thread->t_ctl_waitq,
257 thread->t_flags & (SVC_STOPPING|SVC_EVENT),
259 if (thread->t_flags & SVC_STOPPING) {
260 thread->t_flags &= ~SVC_STOPPING;
263 } else if (thread->t_flags & SVC_EVENT) {
264 /* woken after adding import to reset timer */
265 thread->t_flags &= ~SVC_EVENT;
270 thread->t_flags = SVC_STOPPED;
271 cfs_waitq_signal(&thread->t_ctl_waitq);
273 CDEBUG(D_NET, "pinger thread exiting, process %d\n", cfs_curproc_pid());
277 static struct ptlrpc_thread *pinger_thread = NULL;
279 int ptlrpc_start_pinger(void)
281 struct l_wait_info lwi = { 0 };
282 struct ptlrpc_svc_data d;
284 #ifndef ENABLE_PINGER
289 if (pinger_thread != NULL)
292 OBD_ALLOC(pinger_thread, sizeof(*pinger_thread));
293 if (pinger_thread == NULL)
295 cfs_waitq_init(&pinger_thread->t_ctl_waitq);
298 d.thread = pinger_thread;
300 /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
301 * just drop the VM and FILES in ptlrpc_daemonize() right away. */
302 rc = cfs_kernel_thread(ptlrpc_pinger_main, &d, CLONE_VM | CLONE_FILES);
304 CERROR("cannot start thread: %d\n", rc);
305 OBD_FREE(pinger_thread, sizeof(*pinger_thread));
306 pinger_thread = NULL;
309 l_wait_event(pinger_thread->t_ctl_waitq,
310 pinger_thread->t_flags & SVC_RUNNING, &lwi);
315 int ptlrpc_pinger_remove_timeouts(void);
317 int ptlrpc_stop_pinger(void)
319 struct l_wait_info lwi = { 0 };
321 #ifndef ENABLE_PINGER
326 if (pinger_thread == NULL)
329 ptlrpc_pinger_remove_timeouts();
330 mutex_down(&pinger_sem);
331 pinger_thread->t_flags = SVC_STOPPING;
332 cfs_waitq_signal(&pinger_thread->t_ctl_waitq);
333 mutex_up(&pinger_sem);
335 l_wait_event(pinger_thread->t_ctl_waitq,
336 (pinger_thread->t_flags & SVC_STOPPED), &lwi);
338 OBD_FREE(pinger_thread, sizeof(*pinger_thread));
339 pinger_thread = NULL;
343 void ptlrpc_pinger_sending_on_import(struct obd_import *imp)
345 ptlrpc_update_next_ping(imp, 0);
348 void ptlrpc_pinger_commit_expected(struct obd_import *imp)
350 ptlrpc_update_next_ping(imp, 1);
353 int ptlrpc_pinger_add_import(struct obd_import *imp)
356 if (!list_empty(&imp->imp_pinger_chain))
359 mutex_down(&pinger_sem);
360 CDEBUG(D_HA, "adding pingable import %s->%s\n",
361 imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
362 /* if we add to pinger we want recovery on this import */
363 imp->imp_obd->obd_no_recov = 0;
365 ptlrpc_update_next_ping(imp, 0);
366 /* XXX sort, blah blah */
367 list_add_tail(&imp->imp_pinger_chain, &pinger_imports);
368 class_import_get(imp);
370 ptlrpc_pinger_wake_up();
371 mutex_up(&pinger_sem);
376 int ptlrpc_pinger_del_import(struct obd_import *imp)
379 if (list_empty(&imp->imp_pinger_chain))
382 mutex_down(&pinger_sem);
383 list_del_init(&imp->imp_pinger_chain);
384 CDEBUG(D_HA, "removing pingable import %s->%s\n",
385 imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
386 /* if we remove from pinger we don't want recovery on this import */
387 imp->imp_obd->obd_no_recov = 1;
388 class_import_put(imp);
389 mutex_up(&pinger_sem);
394 * Register a timeout callback to the pinger list, and the callback will
395 * be called when timeout happens.
397 struct timeout_item* ptlrpc_new_timeout(int time, enum timeout_event event,
398 timeout_cb_t cb, void *data)
400 struct timeout_item *ti;
406 CFS_INIT_LIST_HEAD(&ti->ti_obd_list);
407 CFS_INIT_LIST_HEAD(&ti->ti_chain);
408 ti->ti_timeout = time;
409 ti->ti_event = event;
411 ti->ti_cb_data = data;
417 * Register timeout event on the the pinger thread.
418 * Note: the timeout list is an sorted list with increased timeout value.
420 static struct timeout_item*
421 ptlrpc_pinger_register_timeout(int time, enum timeout_event event,
422 timeout_cb_t cb, void *data)
424 struct timeout_item *item, *tmp;
426 LASSERT_SEM_LOCKED(&pinger_sem);
428 list_for_each_entry(item, &timeout_list, ti_chain)
429 if (item->ti_event == event)
432 item = ptlrpc_new_timeout(time, event, cb, data);
434 list_for_each_entry_reverse(tmp, &timeout_list, ti_chain) {
435 if (tmp->ti_timeout < time) {
436 list_add(&item->ti_chain, &tmp->ti_chain);
440 list_add(&item->ti_chain, &timeout_list);
446 /* Add a client_obd to the timeout event list, when timeout(@time)
447 * happens, the callback(@cb) will be called.
449 int ptlrpc_add_timeout_client(int time, enum timeout_event event,
450 timeout_cb_t cb, void *data,
451 struct list_head *obd_list)
453 struct timeout_item *ti;
455 mutex_down(&pinger_sem);
456 ti = ptlrpc_pinger_register_timeout(time, event, cb, data);
458 mutex_up(&pinger_sem);
461 list_add(obd_list, &ti->ti_obd_list);
462 mutex_up(&pinger_sem);
466 int ptlrpc_del_timeout_client(struct list_head *obd_list)
468 mutex_down(&pinger_sem);
469 list_del_init(obd_list);
470 mutex_up(&pinger_sem);
474 int ptlrpc_pinger_remove_timeouts(void)
476 struct timeout_item *item, *tmp;
478 mutex_down(&pinger_sem);
479 list_for_each_entry_safe(item, tmp, &timeout_list, ti_chain) {
480 LASSERT(list_empty(&item->ti_obd_list));
481 list_del(&item->ti_chain);
484 mutex_up(&pinger_sem);
488 void ptlrpc_pinger_wake_up()
491 pinger_thread->t_flags |= SVC_EVENT;
492 cfs_waitq_signal(&pinger_thread->t_ctl_waitq);
496 /* Ping evictor thread */
498 #define PET_TERMINATE 2
500 static int pet_refcount = 0;
501 static int pet_state;
502 static wait_queue_head_t pet_waitq;
503 static struct obd_export *pet_exp = NULL;
504 static spinlock_t pet_lock = SPIN_LOCK_UNLOCKED;
506 int ping_evictor_wake(struct obd_export *exp)
508 spin_lock(&pet_lock);
509 if (pet_exp || (pet_state != PET_READY)) {
510 /* eventually the new obd will call here again. */
511 spin_unlock(&pet_lock);
515 /* We have to make sure the obd isn't destroyed between now and when
516 * the ping evictor runs. We'll take a reference here, and drop it
517 * when we finish in the evictor. We don't really care about this
518 * export in particular; we just need one to keep the obd alive. */
519 pet_exp = class_export_get(exp);
520 spin_unlock(&pet_lock);
526 static int ping_evictor_main(void *arg)
528 struct obd_device *obd;
529 struct obd_export *exp;
530 struct l_wait_info lwi = { 0 };
534 ptlrpc_daemonize("ll_evictor");
536 CDEBUG(D_HA, "Starting Ping Evictor\n");
538 pet_state = PET_READY;
540 l_wait_event(pet_waitq, pet_exp ||
541 (pet_state == PET_TERMINATE), &lwi);
542 if (pet_state == PET_TERMINATE)
545 /* we only get here if pet_exp != NULL, and the end of this
546 * loop is the only place which sets it NULL again, so lock
547 * is not strictly necessary. */
548 spin_lock(&pet_lock);
549 obd = pet_exp->exp_obd;
550 spin_unlock(&pet_lock);
552 expire_time = cfs_time_current_sec() - PING_EVICT_TIMEOUT;
554 CDEBUG(D_HA, "evicting all exports of obd %s older than %ld\n",
555 obd->obd_name, expire_time);
557 /* Exports can't be deleted out of the list while we hold
558 * the obd lock (class_unlink_export), which means we can't
559 * lose the last ref on the export. If they've already been
560 * removed from the list, we won't find them here. */
561 spin_lock(&obd->obd_dev_lock);
562 while (!list_empty(&obd->obd_exports_timed)) {
563 exp = list_entry(obd->obd_exports_timed.next,
564 struct obd_export,exp_obd_chain_timed);
565 if (expire_time > exp->exp_last_request_time) {
566 class_export_get(exp);
567 spin_unlock(&obd->obd_dev_lock);
568 LCONSOLE_WARN("%s: haven't heard from client %s"
569 " (at %s) in %ld seconds. I think"
570 " it's dead, and I am evicting"
571 " it.\n", obd->obd_name,
572 obd_uuid2str(&exp->exp_client_uuid),
573 obd_export_nid2str(exp),
574 (long)(cfs_time_current_sec() -
575 exp->exp_last_request_time));
576 CDEBUG(D_HA, "Last request was at %ld\n",
577 exp->exp_last_request_time);
578 class_fail_export(exp);
579 class_export_put(exp);
580 spin_lock(&obd->obd_dev_lock);
582 /* List is sorted, so everyone below is ok */
586 spin_unlock(&obd->obd_dev_lock);
588 class_export_put(pet_exp);
590 spin_lock(&pet_lock);
592 spin_unlock(&pet_lock);
594 CDEBUG(D_HA, "Exiting Ping Evictor\n");
599 void ping_evictor_start(void)
603 if (++pet_refcount > 1)
606 init_waitqueue_head(&pet_waitq);
608 rc = cfs_kernel_thread(ping_evictor_main, NULL, CLONE_VM | CLONE_FILES);
611 CERROR("Cannot start ping evictor thread: %d\n", rc);
614 EXPORT_SYMBOL(ping_evictor_start);
616 void ping_evictor_stop(void)
618 if (--pet_refcount > 0)
621 pet_state = PET_TERMINATE;
624 EXPORT_SYMBOL(ping_evictor_stop);
625 #else /* !__KERNEL__ */
628 * the current implementation of pinger in liblustre is not optimized
632 static struct pinger_data {
634 cfs_time_t pd_this_ping; /* jiffies */
635 cfs_time_t pd_next_ping; /* jiffies */
636 struct ptlrpc_request_set *pd_set;
639 static int pinger_check_rpcs(void *arg)
641 cfs_time_t curtime = cfs_time_current();
642 struct ptlrpc_request *req;
643 struct ptlrpc_request_set *set;
644 struct list_head *iter;
645 struct obd_import *imp;
646 struct pinger_data *pd = &pinger_args;
649 /* prevent recursion */
650 if (pd->pd_recursion++) {
651 CDEBUG(D_HA, "pinger: recursion! quit\n");
657 /* have we reached ping point? */
658 if (!pd->pd_set && time_before(curtime, pd->pd_next_ping)) {
663 /* if we have rpc_set already, continue processing it */
665 LASSERT(pd->pd_this_ping);
670 pd->pd_this_ping = curtime;
671 pd->pd_set = ptlrpc_prep_set();
672 if (pd->pd_set == NULL)
676 /* add rpcs into set */
677 mutex_down(&pinger_sem);
678 list_for_each(iter, &pinger_imports) {
679 struct obd_import *imp =
680 list_entry(iter, struct obd_import, imp_pinger_chain);
681 int generation, level;
683 if (cfs_time_aftereq(pd->pd_this_ping,
684 imp->imp_next_ping - 5 * CFS_TICK)) {
686 spin_lock(&imp->imp_lock);
687 generation = imp->imp_generation;
688 level = imp->imp_state;
689 spin_unlock(&imp->imp_lock);
691 if (level != LUSTRE_IMP_FULL) {
693 "not pinging %s (in recovery)\n",
694 obd2cli_tgt(imp->imp_obd));
698 req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, OBD_PING,
701 CERROR("out of memory\n");
704 req->rq_no_resend = 1;
705 ptlrpc_req_set_repsize(req, 1, NULL);
706 req->rq_send_state = LUSTRE_IMP_FULL;
707 ptlrpc_rqphase_move(req, RQ_PHASE_RPC);
708 req->rq_import_generation = generation;
709 ptlrpc_set_add_req(set, req);
711 CDEBUG(D_INFO, "don't need to ping %s ("CFS_TIME_T
712 " > "CFS_TIME_T")\n", obd2cli_tgt(imp->imp_obd),
713 imp->imp_next_ping, pd->pd_this_ping);
716 pd->pd_this_ping = curtime;
717 mutex_up(&pinger_sem);
719 /* Might be empty, that's OK. */
720 if (set->set_remaining == 0)
721 CDEBUG(D_RPCTRACE, "nothing to ping\n");
723 list_for_each(iter, &set->set_requests) {
724 struct ptlrpc_request *req =
725 list_entry(iter, struct ptlrpc_request,
727 DEBUG_REQ(D_RPCTRACE, req, "pinging %s->%s",
728 req->rq_import->imp_obd->obd_uuid.uuid,
729 obd2cli_tgt(req->rq_import->imp_obd));
730 (void)ptl_send_rpc(req, 0);
734 rc = ptlrpc_check_set(set);
736 /* not finished, and we are not expired, simply return */
737 if (!rc && cfs_time_before(curtime, cfs_time_add(pd->pd_this_ping,
738 cfs_time_seconds(PING_INTERVAL)))) {
739 CDEBUG(D_RPCTRACE, "not finished, but also not expired\n");
744 /* Expire all the requests that didn't come back. */
745 mutex_down(&pinger_sem);
746 list_for_each(iter, &set->set_requests) {
747 req = list_entry(iter, struct ptlrpc_request,
750 if (req->rq_phase == RQ_PHASE_COMPLETE)
753 CDEBUG(D_RPCTRACE, "Pinger initiate expire request(%p)\n",
756 /* This will also unregister reply. */
757 ptlrpc_expire_one_request(req, 0);
759 /* We're done with this req, let's finally move it to complete
760 * phase and take care of inflights. */
761 ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE);
762 imp = req->rq_import;
763 spin_lock(&imp->imp_lock);
764 if (!list_empty(&req->rq_list)) {
765 list_del_init(&req->rq_list);
766 atomic_dec(&imp->imp_inflight);
768 spin_unlock(&imp->imp_lock);
769 set->set_remaining--;
771 mutex_up(&pinger_sem);
773 ptlrpc_set_destroy(set);
777 pd->pd_next_ping = cfs_time_add(pd->pd_this_ping,
778 cfs_time_seconds(PING_INTERVAL));
779 pd->pd_this_ping = 0; /* XXX for debug */
781 CDEBUG(D_INFO, "finished a round ping\n");
786 static void *pinger_callback = NULL;
787 #endif /* ENABLE_PINGER */
789 int ptlrpc_start_pinger(void)
792 memset(&pinger_args, 0, sizeof(pinger_args));
793 pinger_callback = liblustre_register_wait_callback("pinger_check_rpcs",
800 int ptlrpc_stop_pinger(void)
804 liblustre_deregister_wait_callback(pinger_callback);
809 void ptlrpc_pinger_sending_on_import(struct obd_import *imp)
812 mutex_down(&pinger_sem);
813 ptlrpc_update_next_ping(imp, 0);
814 if (pinger_args.pd_set == NULL &&
815 time_before(imp->imp_next_ping, pinger_args.pd_next_ping)) {
816 CDEBUG(D_HA, "set next ping to "CFS_TIME_T"(cur "CFS_TIME_T")\n",
817 imp->imp_next_ping, cfs_time_current());
818 pinger_args.pd_next_ping = imp->imp_next_ping;
820 mutex_up(&pinger_sem);
824 int ptlrpc_add_timeout_client(int time, enum timeout_event event,
825 timeout_cb_t cb, void *data,
826 struct list_head *obd_list)
831 int ptlrpc_del_timeout_client(struct list_head *obd_list)
836 int ptlrpc_pinger_add_import(struct obd_import *imp)
839 if (!list_empty(&imp->imp_pinger_chain))
842 CDEBUG(D_HA, "adding pingable import %s->%s\n",
843 imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
844 ptlrpc_pinger_sending_on_import(imp);
846 mutex_down(&pinger_sem);
847 list_add_tail(&imp->imp_pinger_chain, &pinger_imports);
848 class_import_get(imp);
849 mutex_up(&pinger_sem);
854 int ptlrpc_pinger_del_import(struct obd_import *imp)
857 if (list_empty(&imp->imp_pinger_chain))
860 mutex_down(&pinger_sem);
861 list_del_init(&imp->imp_pinger_chain);
862 CDEBUG(D_HA, "removing pingable import %s->%s\n",
863 imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
864 class_import_put(imp);
865 mutex_up(&pinger_sem);
869 void ptlrpc_pinger_wake_up()
873 /* XXX force pinger to run, if needed */
874 struct obd_import *imp;
875 list_for_each_entry(imp, &pinger_imports, imp_pinger_chain) {
876 CDEBUG(D_RPCTRACE, "checking import %s->%s\n",
877 imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
878 #ifdef ENABLE_LIBLUSTRE_RECOVERY
879 if (imp->imp_state == LUSTRE_IMP_DISCON &&
880 !imp_is_deactive(imp))
882 /*XXX only recover for the initial connection */
883 if (!lustre_handle_is_used(&imp->imp_remote_handle) &&
884 imp->imp_state == LUSTRE_IMP_DISCON &&
885 !imp_is_deactive(imp))
887 ptlrpc_initiate_recovery(imp);
888 else if (imp->imp_state != LUSTRE_IMP_FULL)
889 CDEBUG(D_HA, "Refused to recover import %s->%s "
890 "state %d, deactive %d\n",
891 imp->imp_obd->obd_uuid.uuid,
892 obd2cli_tgt(imp->imp_obd), imp->imp_state,
893 imp_is_deactive(imp));
898 #endif /* !__KERNEL__ */