Commit 87c7d315 authored by Dmitry Eremin's avatar Dmitry Eremin Committed by Greg Kroah-Hartman

staging/lustre/ptlrpc: better error handling in ptlrpcd_start

This is only part of the original Lustre tree commit. It cleans up
ptlrpcd_start error handling a bit.

Lustre-change: http://review.whamcloud.com/6139
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3204Signed-off-by: default avatarDmitry Eremin <dmitry.eremin@intel.com>
Signed-off-by: default avatarNed Bass <bass6@llnl.gov>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarPeng Tao <bergwolf@gmail.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 645ae203
...@@ -600,7 +600,6 @@ static int ptlrpcd_bind(int index, int max) ...@@ -600,7 +600,6 @@ static int ptlrpcd_bind(int index, int max)
int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc)
{ {
int rc; int rc;
int env = 0;
/* /*
* Do not allow start second thread for one pc. * Do not allow start second thread for one pc.
...@@ -619,6 +618,7 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) ...@@ -619,6 +618,7 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc)
pc->pc_set = ptlrpc_prep_set(); pc->pc_set = ptlrpc_prep_set();
if (pc->pc_set == NULL) if (pc->pc_set == NULL)
GOTO(out, rc = -ENOMEM); GOTO(out, rc = -ENOMEM);
/* /*
* So far only "client" ptlrpcd uses an environment. In the future, * So far only "client" ptlrpcd uses an environment. In the future,
* ptlrpcd thread (or a thread-set) has to be given an argument, * ptlrpcd thread (or a thread-set) has to be given an argument,
...@@ -626,40 +626,40 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) ...@@ -626,40 +626,40 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc)
*/ */
rc = lu_context_init(&pc->pc_env.le_ctx, LCT_CL_THREAD|LCT_REMEMBER); rc = lu_context_init(&pc->pc_env.le_ctx, LCT_CL_THREAD|LCT_REMEMBER);
if (rc != 0) if (rc != 0)
GOTO(out, rc); GOTO(out_set, rc);
env = 1;
{ {
struct task_struct *task; struct task_struct *task;
if (index >= 0) { if (index >= 0) {
rc = ptlrpcd_bind(index, max); rc = ptlrpcd_bind(index, max);
if (rc < 0) if (rc < 0)
GOTO(out, rc); GOTO(out_env, rc);
} }
task = kthread_run(ptlrpcd, pc, "%s", pc->pc_name); task = kthread_run(ptlrpcd, pc, pc->pc_name);
if (IS_ERR(task)) if (IS_ERR(task))
GOTO(out, rc = PTR_ERR(task)); GOTO(out_env, rc = PTR_ERR(task));
rc = 0;
wait_for_completion(&pc->pc_starting); wait_for_completion(&pc->pc_starting);
} }
out: return 0;
if (rc) {
if (pc->pc_set != NULL) { out_env:
struct ptlrpc_request_set *set = pc->pc_set; lu_context_fini(&pc->pc_env.le_ctx);
spin_lock(&pc->pc_lock); out_set:
pc->pc_set = NULL; if (pc->pc_set != NULL) {
spin_unlock(&pc->pc_lock); struct ptlrpc_request_set *set = pc->pc_set;
ptlrpc_set_destroy(set);
} spin_lock(&pc->pc_lock);
if (env != 0) pc->pc_set = NULL;
lu_context_fini(&pc->pc_env.le_ctx); spin_unlock(&pc->pc_lock);
clear_bit(LIOD_BIND, &pc->pc_flags); ptlrpc_set_destroy(set);
clear_bit(LIOD_START, &pc->pc_flags);
} }
clear_bit(LIOD_BIND, &pc->pc_flags);
out:
clear_bit(LIOD_START, &pc->pc_flags);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment