aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/tcm_fc
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2011-05-27 16:58:48 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-07-22 05:37:47 -0400
commit2be18149d9d7ebfde7c3081d60f7c9d8d3b6f8c7 (patch)
tree2d6d602112049f4e6188d8ee3412168760e302ae /drivers/target/tcm_fc
parenta1fa3759583ef2379da6e2cc346ee9f99dfba309 (diff)
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')
-rw-r--r--drivers/target/tcm_fc/tfc_cmd.c17
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c4
2 files changed, 10 insertions, 11 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)
94 94
95static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd) 95static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd)
96{ 96{
97 struct se_queue_obj *qobj; 97 struct ft_tpg *tpg = sess->tport->tpg;
98 struct se_queue_obj *qobj = &tpg->qobj;
98 unsigned long flags; 99 unsigned long flags;
99 100
100 qobj = &sess->tport->tpg->qobj; 101 qobj = &sess->tport->tpg->qobj;
101 spin_lock_irqsave(&qobj->cmd_queue_lock, flags); 102 spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
102 list_add_tail(&cmd->se_req.qr_list, &qobj->qobj_list); 103 list_add_tail(&cmd->se_req.qr_list, &qobj->qobj_list);
103 spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
104 atomic_inc(&qobj->queue_cnt); 104 atomic_inc(&qobj->queue_cnt);
105 wake_up_interruptible(&qobj->thread_wq); 105 spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
106
107 wake_up_process(tpg->thread);
106} 108}
107 109
108static struct ft_cmd *ft_dequeue_cmd(struct se_queue_obj *qobj) 110static struct ft_cmd *ft_dequeue_cmd(struct se_queue_obj *qobj)
@@ -688,15 +690,12 @@ int ft_thread(void *arg)
688 struct ft_tpg *tpg = arg; 690 struct ft_tpg *tpg = arg;
689 struct se_queue_obj *qobj = &tpg->qobj; 691 struct se_queue_obj *qobj = &tpg->qobj;
690 struct ft_cmd *cmd; 692 struct ft_cmd *cmd;
691 int ret;
692
693 set_user_nice(current, -20);
694 693
695 while (!kthread_should_stop()) { 694 while (!kthread_should_stop()) {
696 ret = wait_event_interruptible(qobj->thread_wq, 695 schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT);
697 atomic_read(&qobj->queue_cnt) || kthread_should_stop()); 696 if (kthread_should_stop())
698 if (ret < 0 || kthread_should_stop())
699 goto out; 697 goto out;
698
700 cmd = ft_dequeue_cmd(qobj); 699 cmd = ft_dequeue_cmd(qobj);
701 if (cmd) 700 if (cmd)
702 ft_exec_req(cmd); 701 ft_exec_req(cmd);
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index 1cb3d345183f..ec9e40dc4514 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -223,7 +223,7 @@ static struct se_node_acl *ft_add_acl(
223 return ERR_PTR(-EINVAL); 223 return ERR_PTR(-EINVAL);
224 224
225 acl = kzalloc(sizeof(struct ft_node_acl), GFP_KERNEL); 225 acl = kzalloc(sizeof(struct ft_node_acl), GFP_KERNEL);
226 if (!(acl)) 226 if (!acl)
227 return ERR_PTR(-ENOMEM); 227 return ERR_PTR(-ENOMEM);
228 acl->node_auth.port_name = wwpn; 228 acl->node_auth.port_name = wwpn;
229 229
@@ -280,7 +280,7 @@ struct se_node_acl *ft_tpg_alloc_fabric_acl(struct se_portal_group *se_tpg)
280 struct ft_node_acl *acl; 280 struct ft_node_acl *acl;
281 281
282 acl = kzalloc(sizeof(*acl), GFP_KERNEL); 282 acl = kzalloc(sizeof(*acl), GFP_KERNEL);
283 if (!(acl)) { 283 if (!acl) {
284 printk(KERN_ERR "Unable to allocate struct ft_node_acl\n"); 284 printk(KERN_ERR "Unable to allocate struct ft_node_acl\n");
285 return NULL; 285 return NULL;
286 } 286 }