mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-06 05:13:18 +00:00
scsi: target: tcmu: Use priv pointer in se_cmd
We initialize and clean up the se_cmd's priv pointer under cmd_ring_lock to point to the corresponding tcmu_cmd. In the patch that implements tmr_notify callback in tcmu we will use the priv pointer. Link: https://lore.kernel.org/r/20200726153510.13077-4-bstroesser@ts.fujitsu.com Reviewed-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Bodo Stroesser <bstroesser@ts.fujitsu.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
2e45a1a9c7
commit
a35129024e
@ -541,6 +541,8 @@ tcmu_get_block_page(struct tcmu_dev *udev, uint32_t dbi)
|
|||||||
|
|
||||||
static inline void tcmu_free_cmd(struct tcmu_cmd *tcmu_cmd)
|
static inline void tcmu_free_cmd(struct tcmu_cmd *tcmu_cmd)
|
||||||
{
|
{
|
||||||
|
if (tcmu_cmd->se_cmd)
|
||||||
|
tcmu_cmd->se_cmd->priv = NULL;
|
||||||
kfree(tcmu_cmd->dbi);
|
kfree(tcmu_cmd->dbi);
|
||||||
kmem_cache_free(tcmu_cmd_cache, tcmu_cmd);
|
kmem_cache_free(tcmu_cmd_cache, tcmu_cmd);
|
||||||
}
|
}
|
||||||
@ -1109,10 +1111,11 @@ tcmu_queue_cmd(struct se_cmd *se_cmd)
|
|||||||
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
||||||
|
|
||||||
mutex_lock(&udev->cmdr_lock);
|
mutex_lock(&udev->cmdr_lock);
|
||||||
|
se_cmd->priv = tcmu_cmd;
|
||||||
ret = queue_cmd_ring(tcmu_cmd, &scsi_ret);
|
ret = queue_cmd_ring(tcmu_cmd, &scsi_ret);
|
||||||
mutex_unlock(&udev->cmdr_lock);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
tcmu_free_cmd(tcmu_cmd);
|
tcmu_free_cmd(tcmu_cmd);
|
||||||
|
mutex_unlock(&udev->cmdr_lock);
|
||||||
return scsi_ret;
|
return scsi_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1179,7 +1182,6 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
|
|||||||
target_complete_cmd(cmd->se_cmd, entry->rsp.scsi_status);
|
target_complete_cmd(cmd->se_cmd, entry->rsp.scsi_status);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
cmd->se_cmd = NULL;
|
|
||||||
tcmu_cmd_free_data(cmd, cmd->dbi_cnt);
|
tcmu_cmd_free_data(cmd, cmd->dbi_cnt);
|
||||||
tcmu_free_cmd(cmd);
|
tcmu_free_cmd(cmd);
|
||||||
}
|
}
|
||||||
@ -1285,6 +1287,7 @@ static void tcmu_check_expired_ring_cmd(struct tcmu_cmd *cmd)
|
|||||||
set_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags);
|
set_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags);
|
||||||
list_del_init(&cmd->queue_entry);
|
list_del_init(&cmd->queue_entry);
|
||||||
se_cmd = cmd->se_cmd;
|
se_cmd = cmd->se_cmd;
|
||||||
|
se_cmd->priv = NULL;
|
||||||
cmd->se_cmd = NULL;
|
cmd->se_cmd = NULL;
|
||||||
|
|
||||||
pr_debug("Timing out inflight cmd %u on dev %s.\n",
|
pr_debug("Timing out inflight cmd %u on dev %s.\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user