Skip to content

Commit e057f53

Browse files
Christoph HellwigNicholas Bellinger
authored andcommitted
target: remove the transport_qf_callback se_cmd callback
Remove the need for the transport_qf_callback callback by making sure we have specific states with specific handlers for the two queue full cases. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent f55918f commit e057f53

2 files changed

Lines changed: 37 additions & 44 deletions

File tree

‎drivers/target/target_core_transport.c‎

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ static int transport_generic_write_pending(struct se_cmd *);
7272
static int transport_processing_thread(void *param);
7373
static int __transport_execute_tasks(struct se_device *dev);
7474
static void transport_complete_task_attr(struct se_cmd *cmd);
75-
static int transport_complete_qf(struct se_cmd *cmd);
7675
static void transport_handle_queue_full(struct se_cmd *cmd,
77-
struct se_device *dev, int (*qf_callback)(struct se_cmd *));
76+
struct se_device *dev);
7877
static void transport_direct_request_timeout(struct se_cmd *cmd);
7978
static void transport_free_dev_tasks(struct se_cmd *cmd);
8079
static u32 transport_allocate_tasks(struct se_cmd *cmd,
@@ -969,7 +968,7 @@ static void target_qf_do_work(struct work_struct *work)
969968

970969
pr_debug("Processing %s cmd: %p QUEUE_FULL in work queue"
971970
" context: %s\n", cmd->se_tfo->get_fabric_name(), cmd,
972-
(cmd->t_state == TRANSPORT_COMPLETE_OK) ? "COMPLETE_OK" :
971+
(cmd->t_state == TRANSPORT_COMPLETE_QF_OK) ? "COMPLETE_OK" :
973972
(cmd->t_state == TRANSPORT_COMPLETE_QF_WP) ? "WRITE_PENDING"
974973
: "UNKNOWN");
975974
/*
@@ -1968,8 +1967,8 @@ static void transport_generic_request_failure(
19681967
return;
19691968

19701969
queue_full:
1971-
cmd->t_state = TRANSPORT_COMPLETE_OK;
1972-
transport_handle_queue_full(cmd, cmd->se_dev, transport_complete_qf);
1970+
cmd->t_state = TRANSPORT_COMPLETE_QF_OK;
1971+
transport_handle_queue_full(cmd, cmd->se_dev);
19731972
}
19741973

19751974
static void transport_direct_request_timeout(struct se_cmd *cmd)
@@ -3431,12 +3430,19 @@ static void transport_complete_task_attr(struct se_cmd *cmd)
34313430
wake_up_interruptible(&dev->dev_queue_obj.thread_wq);
34323431
}
34333432

3434-
static int transport_complete_qf(struct se_cmd *cmd)
3433+
static void transport_complete_qf(struct se_cmd *cmd)
34353434
{
34363435
int ret = 0;
34373436

3438-
if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE)
3439-
return cmd->se_tfo->queue_status(cmd);
3437+
transport_stop_all_task_timers(cmd);
3438+
if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED)
3439+
transport_complete_task_attr(cmd);
3440+
3441+
if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) {
3442+
ret = cmd->se_tfo->queue_status(cmd);
3443+
if (ret)
3444+
goto out;
3445+
}
34403446

34413447
switch (cmd->data_direction) {
34423448
case DMA_FROM_DEVICE:
@@ -3446,7 +3452,7 @@ static int transport_complete_qf(struct se_cmd *cmd)
34463452
if (cmd->t_bidi_data_sg) {
34473453
ret = cmd->se_tfo->queue_data_in(cmd);
34483454
if (ret < 0)
3449-
return ret;
3455+
break;
34503456
}
34513457
/* Fall through for DMA_TO_DEVICE */
34523458
case DMA_NONE:
@@ -3456,17 +3462,21 @@ static int transport_complete_qf(struct se_cmd *cmd)
34563462
break;
34573463
}
34583464

3459-
return ret;
3465+
out:
3466+
if (ret < 0) {
3467+
transport_handle_queue_full(cmd, cmd->se_dev);
3468+
return;
3469+
}
3470+
transport_lun_remove_cmd(cmd);
3471+
transport_cmd_check_stop_to_fabric(cmd);
34603472
}
34613473

34623474
static void transport_handle_queue_full(
34633475
struct se_cmd *cmd,
3464-
struct se_device *dev,
3465-
int (*qf_callback)(struct se_cmd *))
3476+
struct se_device *dev)
34663477
{
34673478
spin_lock_irq(&dev->qf_cmd_lock);
34683479
cmd->se_cmd_flags |= SCF_EMULATE_QUEUE_FULL;
3469-
cmd->transport_qf_callback = qf_callback;
34703480
list_add_tail(&cmd->se_qf_node, &cmd->se_dev->qf_cmd_list);
34713481
atomic_inc(&dev->dev_qf_count);
34723482
smp_mb__after_atomic_inc();
@@ -3492,14 +3502,6 @@ static void transport_generic_complete_ok(struct se_cmd *cmd)
34923502
if (atomic_read(&cmd->se_dev->dev_qf_count) != 0)
34933503
schedule_work(&cmd->se_dev->qf_work_queue);
34943504

3495-
if (cmd->transport_qf_callback) {
3496-
ret = cmd->transport_qf_callback(cmd);
3497-
if (ret < 0)
3498-
goto queue_full;
3499-
3500-
cmd->transport_qf_callback = NULL;
3501-
goto done;
3502-
}
35033505
/*
35043506
* Check if we need to retrieve a sense buffer from
35053507
* the struct se_cmd in question.
@@ -3575,15 +3577,15 @@ static void transport_generic_complete_ok(struct se_cmd *cmd)
35753577
break;
35763578
}
35773579

3578-
done:
35793580
transport_lun_remove_cmd(cmd);
35803581
transport_cmd_check_stop_to_fabric(cmd);
35813582
return;
35823583

35833584
queue_full:
35843585
pr_debug("Handling complete_ok QUEUE_FULL: se_cmd: %p,"
35853586
" data_direction: %d\n", cmd, cmd->data_direction);
3586-
transport_handle_queue_full(cmd, cmd->se_dev, transport_complete_qf);
3587+
cmd->t_state = TRANSPORT_COMPLETE_QF_OK;
3588+
transport_handle_queue_full(cmd, cmd->se_dev);
35873589
}
35883590

35893591
static void transport_free_dev_tasks(struct se_cmd *cmd)
@@ -4110,15 +4112,15 @@ void transport_generic_process_write(struct se_cmd *cmd)
41104112
}
41114113
EXPORT_SYMBOL(transport_generic_process_write);
41124114

4113-
static int transport_write_pending_qf(struct se_cmd *cmd)
4115+
static void transport_write_pending_qf(struct se_cmd *cmd)
41144116
{
4115-
return cmd->se_tfo->write_pending(cmd);
4117+
if (cmd->se_tfo->write_pending(cmd) == -EAGAIN) {
4118+
pr_debug("Handling write_pending QUEUE__FULL: se_cmd: %p\n",
4119+
cmd);
4120+
transport_handle_queue_full(cmd, cmd->se_dev);
4121+
}
41164122
}
41174123

4118-
/* transport_generic_write_pending():
4119-
*
4120-
*
4121-
*/
41224124
static int transport_generic_write_pending(struct se_cmd *cmd)
41234125
{
41244126
unsigned long flags;
@@ -4128,17 +4130,6 @@ static int transport_generic_write_pending(struct se_cmd *cmd)
41284130
cmd->t_state = TRANSPORT_WRITE_PENDING;
41294131
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
41304132

4131-
if (cmd->transport_qf_callback) {
4132-
ret = cmd->transport_qf_callback(cmd);
4133-
if (ret == -EAGAIN)
4134-
goto queue_full;
4135-
else if (ret < 0)
4136-
return ret;
4137-
4138-
cmd->transport_qf_callback = NULL;
4139-
return 0;
4140-
}
4141-
41424133
/*
41434134
* Clear the se_cmd for WRITE_PENDING status in order to set
41444135
* cmd->t_transport_active=0 so that transport_generic_handle_data
@@ -4163,8 +4154,7 @@ static int transport_generic_write_pending(struct se_cmd *cmd)
41634154
queue_full:
41644155
pr_debug("Handling write_pending QUEUE__FULL: se_cmd: %p\n", cmd);
41654156
cmd->t_state = TRANSPORT_COMPLETE_QF_WP;
4166-
transport_handle_queue_full(cmd, cmd->se_dev,
4167-
transport_write_pending_qf);
4157+
transport_handle_queue_full(cmd, cmd->se_dev);
41684158
return ret;
41694159
}
41704160

@@ -4851,7 +4841,10 @@ static int transport_processing_thread(void *param)
48514841
transport_generic_request_timeout(cmd);
48524842
break;
48534843
case TRANSPORT_COMPLETE_QF_WP:
4854-
transport_generic_write_pending(cmd);
4844+
transport_write_pending_qf(cmd);
4845+
break;
4846+
case TRANSPORT_COMPLETE_QF_OK:
4847+
transport_complete_qf(cmd);
48554848
break;
48564849
default:
48574850
pr_err("Unknown t_state: %d deferred_t_state:"

‎include/target/target_core_base.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ enum transport_state_table {
102102
TRANSPORT_NEW_CMD_MAP = 16,
103103
TRANSPORT_FREE_CMD_INTR = 17,
104104
TRANSPORT_COMPLETE_QF_WP = 18,
105+
TRANSPORT_COMPLETE_QF_OK = 19,
105106
};
106107

107108
/* Used for struct se_cmd->se_cmd_flags */
@@ -471,7 +472,6 @@ struct se_cmd {
471472
struct target_core_fabric_ops *se_tfo;
472473
int (*transport_emulate_cdb)(struct se_cmd *);
473474
void (*transport_complete_callback)(struct se_cmd *);
474-
int (*transport_qf_callback)(struct se_cmd *);
475475

476476
unsigned char *t_task_cdb;
477477
unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];

0 commit comments

Comments
 (0)