* [PATCH 1/5] target: fix ordered CMD_T_SENT handling
@ 2021-09-30 1:38 Mike Christie
0 siblings, 0 replies; 3+ messages in thread
From: Mike Christie @ 2021-09-30 1:38 UTC (permalink / raw)
To: martin.petersen, james.bottomley, linux-scsi, target-devel; +Cc: Mike Christie
We can race where target_handle_task_attr has put the cmd on the
delayed_cmd_list. Then target_restart_delayed_cmds has removed it and
set CMD_T_SENT, but then target_execute_cmd now clears that bit.
This patch moves the clearing to before we've put the cmd on the list.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
drivers/target/target_core_transport.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 14c6f2bb1b01..e02173a4b7bc 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2200,6 +2200,10 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
if (atomic_read(&dev->dev_ordered_sync) == 0)
return false;
+ spin_lock_irq(&cmd->t_state_lock);
+ cmd->transport_state &= ~CMD_T_SENT;
+ spin_unlock_irq(&cmd->t_state_lock);
+
spin_lock(&dev->delayed_cmd_lock);
list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
spin_unlock(&dev->delayed_cmd_lock);
@@ -2228,12 +2232,8 @@ void target_execute_cmd(struct se_cmd *cmd)
if (target_write_prot_action(cmd))
return;
- if (target_handle_task_attr(cmd)) {
- spin_lock_irq(&cmd->t_state_lock);
- cmd->transport_state &= ~CMD_T_SENT;
- spin_unlock_irq(&cmd->t_state_lock);
+ if (target_handle_task_attr(cmd))
return;
- }
__target_execute_cmd(cmd, true);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/5] target: fix ordered CMD_T_SENT handling
2021-09-30 2:04 ` [PATCH 1/5] target: fix ordered CMD_T_SENT handling Mike Christie
@ 2021-10-05 18:02 ` Lee Duncan
0 siblings, 0 replies; 3+ messages in thread
From: Lee Duncan @ 2021-10-05 18:02 UTC (permalink / raw)
To: Mike Christie, martin.petersen, james.bottomley, linux-scsi,
target-devel
On 9/29/21 7:04 PM, Mike Christie wrote:
> We can race where target_handle_task_attr has put the cmd on the
> delayed_cmd_list. Then target_restart_delayed_cmds has removed it and
> set CMD_T_SENT, but then target_execute_cmd now clears that bit.
>
> This patch moves the clearing to before we've put the cmd on the list.
>
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
> drivers/target/target_core_transport.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index 14c6f2bb1b01..e02173a4b7bc 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -2200,6 +2200,10 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
> if (atomic_read(&dev->dev_ordered_sync) == 0)
> return false;
>
> + spin_lock_irq(&cmd->t_state_lock);
> + cmd->transport_state &= ~CMD_T_SENT;
> + spin_unlock_irq(&cmd->t_state_lock);
> +
> spin_lock(&dev->delayed_cmd_lock);
> list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
> spin_unlock(&dev->delayed_cmd_lock);
> @@ -2228,12 +2232,8 @@ void target_execute_cmd(struct se_cmd *cmd)
> if (target_write_prot_action(cmd))
> return;
>
> - if (target_handle_task_attr(cmd)) {
> - spin_lock_irq(&cmd->t_state_lock);
> - cmd->transport_state &= ~CMD_T_SENT;
> - spin_unlock_irq(&cmd->t_state_lock);
> + if (target_handle_task_attr(cmd))
> return;
> - }
>
> __target_execute_cmd(cmd, true);
> }
>
Reviewed-by: Lee Duncan <lduncan@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/5] target: fix ordered CMD_T_SENT handling
2021-09-30 2:04 [PATCH 0/5] target: fixes and perf improvements Mike Christie
@ 2021-09-30 2:04 ` Mike Christie
2021-10-05 18:02 ` Lee Duncan
0 siblings, 1 reply; 3+ messages in thread
From: Mike Christie @ 2021-09-30 2:04 UTC (permalink / raw)
To: martin.petersen, james.bottomley, linux-scsi, target-devel; +Cc: Mike Christie
We can race where target_handle_task_attr has put the cmd on the
delayed_cmd_list. Then target_restart_delayed_cmds has removed it and
set CMD_T_SENT, but then target_execute_cmd now clears that bit.
This patch moves the clearing to before we've put the cmd on the list.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
drivers/target/target_core_transport.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 14c6f2bb1b01..e02173a4b7bc 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2200,6 +2200,10 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
if (atomic_read(&dev->dev_ordered_sync) == 0)
return false;
+ spin_lock_irq(&cmd->t_state_lock);
+ cmd->transport_state &= ~CMD_T_SENT;
+ spin_unlock_irq(&cmd->t_state_lock);
+
spin_lock(&dev->delayed_cmd_lock);
list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
spin_unlock(&dev->delayed_cmd_lock);
@@ -2228,12 +2232,8 @@ void target_execute_cmd(struct se_cmd *cmd)
if (target_write_prot_action(cmd))
return;
- if (target_handle_task_attr(cmd)) {
- spin_lock_irq(&cmd->t_state_lock);
- cmd->transport_state &= ~CMD_T_SENT;
- spin_unlock_irq(&cmd->t_state_lock);
+ if (target_handle_task_attr(cmd))
return;
- }
__target_execute_cmd(cmd, true);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-05 18:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 1:38 [PATCH 1/5] target: fix ordered CMD_T_SENT handling Mike Christie
2021-09-30 2:04 [PATCH 0/5] target: fixes and perf improvements Mike Christie
2021-09-30 2:04 ` [PATCH 1/5] target: fix ordered CMD_T_SENT handling Mike Christie
2021-10-05 18:02 ` Lee Duncan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.