Commit 060c2820 authored by John L. Hammond's avatar John L. Hammond Committed by Greg Kroah-Hartman

staging: lustre: remove uses of IS_ERR_VALUE()

Remove most uses of IS_ERR_VALUE(). This macro was often given an int
argument coming from PTR_ERR(). This invokes implementation defined
behavior since the long value gotten by applying PTR_ERR() to a kernel
pointer will usually not be representable as an int. Moreover it may
be just plain wrong to do this since the expressions IS_ERR(p) and
IS_ERR_VALUE((int) PTR_ERR(p)) are not equivalent for a general
pointer p.
Signed-off-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3498
Reviewed-on: http://review.whamcloud.com/6759Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarDmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 764d2e9a
...@@ -439,6 +439,7 @@ accept2secure(const char *acc, long *sec) ...@@ -439,6 +439,7 @@ accept2secure(const char *acc, long *sec)
int int
lnet_acceptor_start(void) lnet_acceptor_start(void)
{ {
struct task_struct *task;
int rc; int rc;
long rc2; long rc2;
long secure; long secure;
...@@ -457,10 +458,10 @@ lnet_acceptor_start(void) ...@@ -457,10 +458,10 @@ lnet_acceptor_start(void)
if (!lnet_count_acceptor_nis()) /* not required */ if (!lnet_count_acceptor_nis()) /* not required */
return 0; return 0;
rc2 = PTR_ERR(kthread_run(lnet_acceptor, task = kthread_run(lnet_acceptor, (void *)(ulong_ptr_t)secure,
(void *)(ulong_ptr_t)secure, "acceptor_%03ld", secure);
"acceptor_%03ld", secure)); if (IS_ERR(task)) {
if (IS_ERR_VALUE(rc2)) { rc2 = PTR_ERR(task);
CERROR("Can't start acceptor thread: %ld\n", rc2); CERROR("Can't start acceptor thread: %ld\n", rc2);
return -ESRCH; return -ESRCH;
......
...@@ -1004,6 +1004,7 @@ lnet_ping_router_locked(lnet_peer_t *rtr) ...@@ -1004,6 +1004,7 @@ lnet_ping_router_locked(lnet_peer_t *rtr)
int int
lnet_router_checker_start(void) lnet_router_checker_start(void)
{ {
struct task_struct *task;
int rc; int rc;
int eqsz; int eqsz;
...@@ -1034,9 +1035,9 @@ lnet_router_checker_start(void) ...@@ -1034,9 +1035,9 @@ lnet_router_checker_start(void)
} }
the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING; the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING;
rc = PTR_ERR(kthread_run(lnet_router_checker, task = kthread_run(lnet_router_checker, NULL, "router_checker");
NULL, "router_checker")); if (IS_ERR(task)) {
if (IS_ERR_VALUE(rc)) { rc = PTR_ERR(task);
CERROR("Can't start router checker thread: %d\n", rc); CERROR("Can't start router checker thread: %d\n", rc);
/* block until event callback signals exit */ /* block until event callback signals exit */
down(&the_lnet.ln_rc_signal); down(&the_lnet.ln_rc_signal);
......
...@@ -1056,6 +1056,7 @@ static int tracefiled(void *arg) ...@@ -1056,6 +1056,7 @@ static int tracefiled(void *arg)
int cfs_trace_start_thread(void) int cfs_trace_start_thread(void)
{ {
struct tracefiled_ctl *tctl = &trace_tctl; struct tracefiled_ctl *tctl = &trace_tctl;
struct task_struct *task;
int rc = 0; int rc = 0;
mutex_lock(&cfs_trace_thread_mutex); mutex_lock(&cfs_trace_thread_mutex);
...@@ -1067,8 +1068,9 @@ int cfs_trace_start_thread(void) ...@@ -1067,8 +1068,9 @@ int cfs_trace_start_thread(void)
init_waitqueue_head(&tctl->tctl_waitq); init_waitqueue_head(&tctl->tctl_waitq);
atomic_set(&tctl->tctl_shutdown, 0); atomic_set(&tctl->tctl_shutdown, 0);
if (IS_ERR(kthread_run(tracefiled, tctl, "ktracefiled"))) { task = kthread_run(tracefiled, tctl, "ktracefiled");
rc = -ECHILD; if (IS_ERR(task)) {
rc = PTR_ERR(task);
goto out; goto out;
} }
......
...@@ -1498,6 +1498,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, ...@@ -1498,6 +1498,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
struct ll_sa_entry *entry; struct ll_sa_entry *entry;
struct ptlrpc_thread *thread; struct ptlrpc_thread *thread;
struct l_wait_info lwi = { 0 }; struct l_wait_info lwi = { 0 };
struct task_struct *task;
int rc = 0; int rc = 0;
struct ll_inode_info *plli; struct ll_inode_info *plli;
...@@ -1656,10 +1657,11 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, ...@@ -1656,10 +1657,11 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
lli->lli_sai = sai; lli->lli_sai = sai;
plli = ll_i2info(d_inode(parent)); plli = ll_i2info(d_inode(parent));
rc = PTR_ERR(kthread_run(ll_statahead_thread, parent, task = kthread_run(ll_statahead_thread, parent, "ll_sa_%u",
"ll_sa_%u", plli->lli_opendir_pid)); plli->lli_opendir_pid);
thread = &sai->sai_thread; thread = &sai->sai_thread;
if (IS_ERR_VALUE(rc)) { if (IS_ERR(task)) {
rc = PTR_ERR(task);
CERROR("can't start ll_sa thread, rc: %d\n", rc); CERROR("can't start ll_sa thread, rc: %d\n", rc);
dput(parent); dput(parent);
lli->lli_opendir_key = NULL; lli->lli_opendir_key = NULL;
......
...@@ -1554,6 +1554,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, ...@@ -1554,6 +1554,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
struct ioc_changelog *icc) struct ioc_changelog *icc)
{ {
struct changelog_show *cs; struct changelog_show *cs;
struct task_struct *task;
int rc; int rc;
/* Freed in mdc_changelog_send_thread */ /* Freed in mdc_changelog_send_thread */
...@@ -1571,15 +1572,20 @@ static int mdc_ioc_changelog_send(struct obd_device *obd, ...@@ -1571,15 +1572,20 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
* New thread because we should return to user app before * New thread because we should return to user app before
* writing into our pipe * writing into our pipe
*/ */
rc = PTR_ERR(kthread_run(mdc_changelog_send_thread, cs, task = kthread_run(mdc_changelog_send_thread, cs,
"mdc_clg_send_thread")); "mdc_clg_send_thread");
if (!IS_ERR_VALUE(rc)) { if (IS_ERR(task)) {
CDEBUG(D_CHANGELOG, "start changelog thread\n"); rc = PTR_ERR(task);
return 0; CERROR("%s: can't start changelog thread: rc = %d\n",
obd->obd_name, rc);
kfree(cs);
} else {
rc = 0;
CDEBUG(D_CHANGELOG, "%s: started changelog thread\n",
obd->obd_name);
} }
CERROR("Failed to start changelog thread: %d\n", rc); CERROR("Failed to start changelog thread: %d\n", rc);
kfree(cs);
return rc; return rc;
} }
......
...@@ -711,6 +711,7 @@ static int mgc_cleanup(struct obd_device *obd) ...@@ -711,6 +711,7 @@ static int mgc_cleanup(struct obd_device *obd)
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{ {
struct lprocfs_static_vars lvars = { NULL }; struct lprocfs_static_vars lvars = { NULL };
struct task_struct *task;
int rc; int rc;
ptlrpcd_addref(); ptlrpcd_addref();
...@@ -734,10 +735,10 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) ...@@ -734,10 +735,10 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
init_waitqueue_head(&rq_waitq); init_waitqueue_head(&rq_waitq);
/* start requeue thread */ /* start requeue thread */
rc = PTR_ERR(kthread_run(mgc_requeue_thread, NULL, task = kthread_run(mgc_requeue_thread, NULL, "ll_cfg_requeue");
"ll_cfg_requeue")); if (IS_ERR(task)) {
if (IS_ERR_VALUE(rc)) { rc = PTR_ERR(task);
CERROR("%s: Cannot start requeue thread (%d),no more log updates!\n", CERROR("%s: cannot start requeue thread: rc = %d; no more log updates\n",
obd->obd_name, rc); obd->obd_name, rc);
goto err_cleanup; goto err_cleanup;
} }
......
...@@ -376,17 +376,19 @@ int llog_process_or_fork(const struct lu_env *env, ...@@ -376,17 +376,19 @@ int llog_process_or_fork(const struct lu_env *env,
lpi->lpi_catdata = catdata; lpi->lpi_catdata = catdata;
if (fork) { if (fork) {
struct task_struct *task;
/* The new thread can't use parent env, /* The new thread can't use parent env,
* init the new one in llog_process_thread_daemonize. */ * init the new one in llog_process_thread_daemonize. */
lpi->lpi_env = NULL; lpi->lpi_env = NULL;
init_completion(&lpi->lpi_completion); init_completion(&lpi->lpi_completion);
rc = PTR_ERR(kthread_run(llog_process_thread_daemonize, lpi, task = kthread_run(llog_process_thread_daemonize, lpi,
"llog_process_thread")); "llog_process_thread");
if (IS_ERR_VALUE(rc)) { if (IS_ERR(task)) {
rc = PTR_ERR(task);
CERROR("%s: cannot start thread: rc = %d\n", CERROR("%s: cannot start thread: rc = %d\n",
loghandle->lgh_ctxt->loc_obd->obd_name, rc); loghandle->lgh_ctxt->loc_obd->obd_name, rc);
kfree(lpi); goto out_lpi;
return rc;
} }
wait_for_completion(&lpi->lpi_completion); wait_for_completion(&lpi->lpi_completion);
} else { } else {
...@@ -394,6 +396,7 @@ int llog_process_or_fork(const struct lu_env *env, ...@@ -394,6 +396,7 @@ int llog_process_or_fork(const struct lu_env *env,
llog_process_thread(lpi); llog_process_thread(lpi);
} }
rc = lpi->lpi_rc; rc = lpi->lpi_rc;
out_lpi:
kfree(lpi); kfree(lpi);
return rc; return rc;
} }
......
...@@ -293,6 +293,7 @@ static struct ptlrpc_thread pinger_thread; ...@@ -293,6 +293,7 @@ static struct ptlrpc_thread pinger_thread;
int ptlrpc_start_pinger(void) int ptlrpc_start_pinger(void)
{ {
struct l_wait_info lwi = { 0 }; struct l_wait_info lwi = { 0 };
struct task_struct *task;
int rc; int rc;
if (!thread_is_init(&pinger_thread) && if (!thread_is_init(&pinger_thread) &&
...@@ -303,10 +304,11 @@ int ptlrpc_start_pinger(void) ...@@ -303,10 +304,11 @@ int ptlrpc_start_pinger(void)
strcpy(pinger_thread.t_name, "ll_ping"); strcpy(pinger_thread.t_name, "ll_ping");
rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, &pinger_thread, task = kthread_run(ptlrpc_pinger_main, &pinger_thread,
"%s", pinger_thread.t_name)); pinger_thread.t_name);
if (IS_ERR_VALUE(rc)) { if (IS_ERR(task)) {
CERROR("cannot start thread: %d\n", rc); rc = PTR_ERR(task);
CERROR("cannot start pinger thread: rc = %d\n", rc);
return rc; return rc;
} }
l_wait_event(pinger_thread.t_ctl_waitq, l_wait_event(pinger_thread.t_ctl_waitq,
......
...@@ -2255,24 +2255,27 @@ static int ptlrpc_start_hr_threads(void) ...@@ -2255,24 +2255,27 @@ static int ptlrpc_start_hr_threads(void)
for (j = 0; j < hrp->hrp_nthrs; j++) { for (j = 0; j < hrp->hrp_nthrs; j++) {
struct ptlrpc_hr_thread *hrt = &hrp->hrp_thrs[j]; struct ptlrpc_hr_thread *hrt = &hrp->hrp_thrs[j];
struct task_struct *task;
rc = PTR_ERR(kthread_run(ptlrpc_hr_main, task = kthread_run(ptlrpc_hr_main,
&hrp->hrp_thrs[j], &hrp->hrp_thrs[j],
"ptlrpc_hr%02d_%03d", "ptlrpc_hr%02d_%03d",
hrp->hrp_cpt, hrp->hrp_cpt,
hrt->hrt_id)); hrt->hrt_id);
if (IS_ERR_VALUE(rc)) if (IS_ERR(task)) {
rc = PTR_ERR(task);
break; break;
}
} }
wait_event(ptlrpc_hr.hr_waitq, wait_event(ptlrpc_hr.hr_waitq,
atomic_read(&hrp->hrp_nstarted) == j); atomic_read(&hrp->hrp_nstarted) == j);
if (!IS_ERR_VALUE(rc))
continue;
CERROR("Reply handling thread %d:%d Failed on starting: rc = %d\n", if (rc < 0) {
i, j, rc); CERROR("cannot start reply handler thread %d:%d: rc = %d\n",
ptlrpc_stop_hr_threads(); i, j, rc);
return rc; ptlrpc_stop_hr_threads();
return rc;
}
} }
return 0; return 0;
} }
...@@ -2374,6 +2377,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) ...@@ -2374,6 +2377,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
struct l_wait_info lwi = { 0 }; struct l_wait_info lwi = { 0 };
struct ptlrpc_thread *thread; struct ptlrpc_thread *thread;
struct ptlrpc_service *svc; struct ptlrpc_service *svc;
struct task_struct *task;
int rc; int rc;
LASSERT(svcpt != NULL); LASSERT(svcpt != NULL);
...@@ -2442,9 +2446,10 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) ...@@ -2442,9 +2446,10 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
} }
CDEBUG(D_RPCTRACE, "starting thread '%s'\n", thread->t_name); CDEBUG(D_RPCTRACE, "starting thread '%s'\n", thread->t_name);
rc = PTR_ERR(kthread_run(ptlrpc_main, thread, "%s", thread->t_name)); task = kthread_run(ptlrpc_main, thread, "%s", thread->t_name);
if (IS_ERR_VALUE(rc)) { if (IS_ERR(task)) {
CERROR("cannot start thread '%s': rc %d\n", rc = PTR_ERR(task);
CERROR("cannot start thread '%s': rc = %d\n",
thread->t_name, rc); thread->t_name, rc);
spin_lock(&svcpt->scp_lock); spin_lock(&svcpt->scp_lock);
--svcpt->scp_nthrs_starting; --svcpt->scp_nthrs_starting;
......
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