aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lustre/ptlrpc/pinger.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/lustre/lustre/ptlrpc/pinger.c')
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/pinger.c82
1 files changed, 33 insertions, 49 deletions
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index ef5269aee0de..227a0ae9593b 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -51,7 +51,7 @@ struct mutex pinger_mutex;
static LIST_HEAD(pinger_imports);
static struct list_head timeout_list = LIST_HEAD_INIT(timeout_list);
-int ptlrpc_pinger_suppress_pings()
+int ptlrpc_pinger_suppress_pings(void)
{
return suppress_pings;
}
@@ -75,11 +75,10 @@ int ptlrpc_obd_ping(struct obd_device *obd)
{
int rc;
struct ptlrpc_request *req;
- ENTRY;
req = ptlrpc_prep_ping(obd->u.cli.cl_import);
if (req == NULL)
- RETURN(-ENOMEM);
+ return -ENOMEM;
req->rq_send_state = LUSTRE_IMP_FULL;
@@ -87,28 +86,27 @@ int ptlrpc_obd_ping(struct obd_device *obd)
ptlrpc_req_finished(req);
- RETURN(rc);
+ return rc;
}
EXPORT_SYMBOL(ptlrpc_obd_ping);
int ptlrpc_ping(struct obd_import *imp)
{
struct ptlrpc_request *req;
- ENTRY;
req = ptlrpc_prep_ping(imp);
if (req == NULL) {
CERROR("OOM trying to ping %s->%s\n",
imp->imp_obd->obd_uuid.uuid,
obd2cli_tgt(imp->imp_obd));
- RETURN(-ENOMEM);
+ return -ENOMEM;
}
DEBUG_REQ(D_INFO, req, "pinging %s->%s",
imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
- RETURN(0);
+ return 0;
}
void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
@@ -297,7 +295,6 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp,
static int ptlrpc_pinger_main(void *arg)
{
struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
- ENTRY;
/* Record that the thread is running */
thread_set_flags(thread, SVC_RUNNING);
@@ -353,7 +350,6 @@ static int ptlrpc_pinger_main(void *arg)
thread_is_event(thread),
&lwi);
if (thread_test_and_clear_flags(thread, SVC_STOPPING)) {
- EXIT;
break;
} else {
/* woken after adding import to reset timer */
@@ -369,37 +365,32 @@ static int ptlrpc_pinger_main(void *arg)
return 0;
}
-static struct ptlrpc_thread *pinger_thread = NULL;
+static struct ptlrpc_thread pinger_thread;
int ptlrpc_start_pinger(void)
{
struct l_wait_info lwi = { 0 };
int rc;
- ENTRY;
- if (pinger_thread != NULL)
- RETURN(-EALREADY);
+ if (!thread_is_init(&pinger_thread) &&
+ !thread_is_stopped(&pinger_thread))
+ return -EALREADY;
- OBD_ALLOC_PTR(pinger_thread);
- if (pinger_thread == NULL)
- RETURN(-ENOMEM);
- init_waitqueue_head(&pinger_thread->t_ctl_waitq);
+ init_waitqueue_head(&pinger_thread.t_ctl_waitq);
init_waitqueue_head(&suspend_timeouts_waitq);
- strcpy(pinger_thread->t_name, "ll_ping");
+ strcpy(pinger_thread.t_name, "ll_ping");
/* CLONE_VM and CLONE_FILES just avoid a needless copy, because we
* just drop the VM and FILES in cfs_daemonize_ctxt() right away. */
rc = PTR_ERR(kthread_run(ptlrpc_pinger_main,
- pinger_thread, pinger_thread->t_name));
+ &pinger_thread, pinger_thread.t_name));
if (IS_ERR_VALUE(rc)) {
CERROR("cannot start thread: %d\n", rc);
- OBD_FREE(pinger_thread, sizeof(*pinger_thread));
- pinger_thread = NULL;
- RETURN(rc);
+ return rc;
}
- l_wait_event(pinger_thread->t_ctl_waitq,
- thread_is_running(pinger_thread), &lwi);
+ l_wait_event(pinger_thread.t_ctl_waitq,
+ thread_is_running(&pinger_thread), &lwi);
if (suppress_pings)
CWARN("Pings will be suppressed at the request of the "
@@ -408,7 +399,7 @@ int ptlrpc_start_pinger(void)
"(Search for the \"suppress_pings\" kernel module "
"parameter.)\n");
- RETURN(0);
+ return 0;
}
int ptlrpc_pinger_remove_timeouts(void);
@@ -417,23 +408,19 @@ int ptlrpc_stop_pinger(void)
{
struct l_wait_info lwi = { 0 };
int rc = 0;
- ENTRY;
- if (pinger_thread == NULL)
- RETURN(-EALREADY);
+ if (!thread_is_init(&pinger_thread) &&
+ !thread_is_stopped(&pinger_thread))
+ return -EALREADY;
ptlrpc_pinger_remove_timeouts();
- mutex_lock(&pinger_mutex);
- thread_set_flags(pinger_thread, SVC_STOPPING);
- wake_up(&pinger_thread->t_ctl_waitq);
- mutex_unlock(&pinger_mutex);
+ thread_set_flags(&pinger_thread, SVC_STOPPING);
+ wake_up(&pinger_thread.t_ctl_waitq);
- l_wait_event(pinger_thread->t_ctl_waitq,
- thread_is_stopped(pinger_thread), &lwi);
+ l_wait_event(pinger_thread.t_ctl_waitq,
+ thread_is_stopped(&pinger_thread), &lwi);
- OBD_FREE_PTR(pinger_thread);
- pinger_thread = NULL;
- RETURN(rc);
+ return rc;
}
void ptlrpc_pinger_sending_on_import(struct obd_import *imp)
@@ -459,9 +446,8 @@ void ptlrpc_pinger_commit_expected(struct obd_import *imp)
int ptlrpc_pinger_add_import(struct obd_import *imp)
{
- ENTRY;
if (!list_empty(&imp->imp_pinger_chain))
- RETURN(-EALREADY);
+ return -EALREADY;
mutex_lock(&pinger_mutex);
CDEBUG(D_HA, "adding pingable import %s->%s\n",
@@ -476,15 +462,14 @@ int ptlrpc_pinger_add_import(struct obd_import *imp)
ptlrpc_pinger_wake_up();
mutex_unlock(&pinger_mutex);
- RETURN(0);
+ return 0;
}
EXPORT_SYMBOL(ptlrpc_pinger_add_import);
int ptlrpc_pinger_del_import(struct obd_import *imp)
{
- ENTRY;
if (list_empty(&imp->imp_pinger_chain))
- RETURN(-ENOENT);
+ return -ENOENT;
mutex_lock(&pinger_mutex);
list_del_init(&imp->imp_pinger_chain);
@@ -494,7 +479,7 @@ int ptlrpc_pinger_del_import(struct obd_import *imp)
imp->imp_obd->obd_no_recov = 1;
class_import_put(imp);
mutex_unlock(&pinger_mutex);
- RETURN(0);
+ return 0;
}
EXPORT_SYMBOL(ptlrpc_pinger_del_import);
@@ -615,10 +600,10 @@ int ptlrpc_pinger_remove_timeouts(void)
return 0;
}
-void ptlrpc_pinger_wake_up()
+void ptlrpc_pinger_wake_up(void)
{
- thread_add_flags(pinger_thread, SVC_EVENT);
- wake_up(&pinger_thread->t_ctl_waitq);
+ thread_add_flags(&pinger_thread, SVC_EVENT);
+ wake_up(&pinger_thread.t_ctl_waitq);
}
/* Ping evictor thread */
@@ -659,7 +644,6 @@ static int ping_evictor_main(void *arg)
struct obd_export *exp;
struct l_wait_info lwi = { 0 };
time_t expire_time;
- ENTRY;
unshare_fs_struct();
@@ -731,12 +715,12 @@ static int ping_evictor_main(void *arg)
}
CDEBUG(D_HA, "Exiting Ping Evictor\n");
- RETURN(0);
+ return 0;
}
void ping_evictor_start(void)
{
- task_t *task;
+ struct task_struct *task;
if (++pet_refcount > 1)
return;