diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-05-27 22:58:48 +0200 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-07-22 11:37:47 +0200 |
commit | 2be18149d9d7ebfde7c3081d60f7c9d8d3b6f8c7 (patch) | |
tree | 2d6d602112049f4e6188d8ee3412168760e302ae /drivers/target/tcm_fc/tfc_cmd.c | |
parent | tcm_fc: Makefile cleanups (diff) | |
download | linux-2be18149d9d7ebfde7c3081d60f7c9d8d3b6f8c7.tar.xz linux-2be18149d9d7ebfde7c3081d60f7c9d8d3b6f8c7.zip |
tcm_fc: Convert to wake_up_process and schedule_timeout_interruptible
This patch converts ft_queue_cmd() to use wake_up_process() and
ft_thread() to use schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT)
instead of wait_event_interruptible(). This fixes a potential race with
the wait_event_interruptible() conditional with qobj->queue_cnt in
ft_thread().
This patch also drops the unnecessary set_user_nice(current, -20) in
ft_thread(), and drops extra () around two if (!(acl)) conditionals in
tfc_conf.c.
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/tcm_fc/tfc_cmd.c')
-rw-r--r-- | drivers/target/tcm_fc/tfc_cmd.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 74d5bb766201..a00951c80324 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c @@ -94,15 +94,17 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller) static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd) { - struct se_queue_obj *qobj; + struct ft_tpg *tpg = sess->tport->tpg; + struct se_queue_obj *qobj = &tpg->qobj; unsigned long flags; qobj = &sess->tport->tpg->qobj; spin_lock_irqsave(&qobj->cmd_queue_lock, flags); list_add_tail(&cmd->se_req.qr_list, &qobj->qobj_list); - spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags); atomic_inc(&qobj->queue_cnt); - wake_up_interruptible(&qobj->thread_wq); + spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags); + + wake_up_process(tpg->thread); } static struct ft_cmd *ft_dequeue_cmd(struct se_queue_obj *qobj) @@ -688,15 +690,12 @@ int ft_thread(void *arg) struct ft_tpg *tpg = arg; struct se_queue_obj *qobj = &tpg->qobj; struct ft_cmd *cmd; - int ret; - - set_user_nice(current, -20); while (!kthread_should_stop()) { - ret = wait_event_interruptible(qobj->thread_wq, - atomic_read(&qobj->queue_cnt) || kthread_should_stop()); - if (ret < 0 || kthread_should_stop()) + schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT); + if (kthread_should_stop()) goto out; + cmd = ft_dequeue_cmd(qobj); if (cmd) ft_exec_req(cmd); |