|
@@ -62,8 +62,8 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
|
|
|
int count;
|
|
|
|
|
|
se_cmd = &cmd->se_cmd;
|
|
|
- pr_debug("%s: cmd %p state %d sess %p seq %p se_cmd %p\n",
|
|
|
- caller, cmd, cmd->state, cmd->sess, cmd->seq, se_cmd);
|
|
|
+ pr_debug("%s: cmd %p sess %p seq %p se_cmd %p\n",
|
|
|
+ caller, cmd, cmd->sess, cmd->seq, se_cmd);
|
|
|
pr_debug("%s: cmd %p cdb %p\n",
|
|
|
caller, cmd, cmd->cdb);
|
|
|
pr_debug("%s: cmd %p lun %d\n", caller, cmd, cmd->lun);
|
|
@@ -90,38 +90,6 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
|
|
|
16, 4, cmd->cdb, MAX_COMMAND_SIZE, 0);
|
|
|
}
|
|
|
|
|
|
-static void ft_queue_cmd(struct ft_sess *sess, struct ft_cmd *cmd)
|
|
|
-{
|
|
|
- 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);
|
|
|
- atomic_inc(&qobj->queue_cnt);
|
|
|
- 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)
|
|
|
-{
|
|
|
- unsigned long flags;
|
|
|
- struct se_queue_req *qr;
|
|
|
-
|
|
|
- spin_lock_irqsave(&qobj->cmd_queue_lock, flags);
|
|
|
- if (list_empty(&qobj->qobj_list)) {
|
|
|
- spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
|
|
|
- return NULL;
|
|
|
- }
|
|
|
- qr = list_first_entry(&qobj->qobj_list, struct se_queue_req, qr_list);
|
|
|
- list_del(&qr->qr_list);
|
|
|
- atomic_dec(&qobj->queue_cnt);
|
|
|
- spin_unlock_irqrestore(&qobj->cmd_queue_lock, flags);
|
|
|
- return container_of(qr, struct ft_cmd, se_req);
|
|
|
-}
|
|
|
-
|
|
|
static void ft_free_cmd(struct ft_cmd *cmd)
|
|
|
{
|
|
|
struct fc_frame *fp;
|
|
@@ -282,9 +250,7 @@ u32 ft_get_task_tag(struct se_cmd *se_cmd)
|
|
|
|
|
|
int ft_get_cmd_state(struct se_cmd *se_cmd)
|
|
|
{
|
|
|
- struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd);
|
|
|
-
|
|
|
- return cmd->state;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
int ft_is_state_remove(struct se_cmd *se_cmd)
|
|
@@ -505,6 +471,8 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static void ft_send_work(struct work_struct *work);
|
|
|
+
|
|
|
/*
|
|
|
* Handle incoming FCP command.
|
|
|
*/
|
|
@@ -523,7 +491,9 @@ static void ft_recv_cmd(struct ft_sess *sess, struct fc_frame *fp)
|
|
|
goto busy;
|
|
|
}
|
|
|
cmd->req_frame = fp; /* hold frame during cmd */
|
|
|
- ft_queue_cmd(sess, cmd);
|
|
|
+
|
|
|
+ INIT_WORK(&cmd->work, ft_send_work);
|
|
|
+ queue_work(sess->tport->tpg->workqueue, &cmd->work);
|
|
|
return;
|
|
|
|
|
|
busy:
|
|
@@ -563,12 +533,13 @@ void ft_recv_req(struct ft_sess *sess, struct fc_frame *fp)
|
|
|
/*
|
|
|
* Send new command to target.
|
|
|
*/
|
|
|
-static void ft_send_cmd(struct ft_cmd *cmd)
|
|
|
+static void ft_send_work(struct work_struct *work)
|
|
|
{
|
|
|
+ struct ft_cmd *cmd = container_of(work, struct ft_cmd, work);
|
|
|
struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame);
|
|
|
struct se_cmd *se_cmd;
|
|
|
struct fcp_cmnd *fcp;
|
|
|
- int data_dir;
|
|
|
+ int data_dir = 0;
|
|
|
u32 data_len;
|
|
|
int task_attr;
|
|
|
int ret;
|
|
@@ -675,42 +646,3 @@ static void ft_send_cmd(struct ft_cmd *cmd)
|
|
|
err:
|
|
|
ft_send_resp_code_and_free(cmd, FCP_CMND_FIELDS_INVALID);
|
|
|
}
|
|
|
-
|
|
|
-/*
|
|
|
- * Handle request in the command thread.
|
|
|
- */
|
|
|
-static void ft_exec_req(struct ft_cmd *cmd)
|
|
|
-{
|
|
|
- pr_debug("cmd state %x\n", cmd->state);
|
|
|
- switch (cmd->state) {
|
|
|
- case FC_CMD_ST_NEW:
|
|
|
- ft_send_cmd(cmd);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/*
|
|
|
- * Processing thread.
|
|
|
- * Currently one thread per tpg.
|
|
|
- */
|
|
|
-int ft_thread(void *arg)
|
|
|
-{
|
|
|
- struct ft_tpg *tpg = arg;
|
|
|
- struct se_queue_obj *qobj = &tpg->qobj;
|
|
|
- struct ft_cmd *cmd;
|
|
|
-
|
|
|
- while (!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);
|
|
|
- }
|
|
|
-
|
|
|
-out:
|
|
|
- return 0;
|
|
|
-}
|