scsi: Only add commands to the device command list if required by the LLD
Just like for the scsi-mq code path, in the single queue SCSI code path only add commands to the per-device command list if required by the SCSI LLD. This patch will make it easier to merge the single-queue and multiqueue command initialization code. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Cc: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
255ee9320e
commit
2dd6fb5957
|
@ -108,14 +108,7 @@ EXPORT_SYMBOL(scsi_sd_pm_domain);
|
||||||
*/
|
*/
|
||||||
void scsi_put_command(struct scsi_cmnd *cmd)
|
void scsi_put_command(struct scsi_cmnd *cmd)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
scsi_del_cmd_from_list(cmd);
|
||||||
|
|
||||||
/* serious error if the command hasn't come from a device list */
|
|
||||||
spin_lock_irqsave(&cmd->device->list_lock, flags);
|
|
||||||
BUG_ON(list_empty(&cmd->list));
|
|
||||||
list_del_init(&cmd->list);
|
|
||||||
spin_unlock_irqrestore(&cmd->device->list_lock, flags);
|
|
||||||
|
|
||||||
BUG_ON(delayed_work_pending(&cmd->abort_work));
|
BUG_ON(delayed_work_pending(&cmd->abort_work));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -584,19 +584,9 @@ static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
|
||||||
|
|
||||||
static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
|
static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
|
||||||
{
|
{
|
||||||
struct scsi_device *sdev = cmd->device;
|
|
||||||
struct Scsi_Host *shost = sdev->host;
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
scsi_mq_free_sgtables(cmd);
|
scsi_mq_free_sgtables(cmd);
|
||||||
scsi_uninit_cmd(cmd);
|
scsi_uninit_cmd(cmd);
|
||||||
|
scsi_del_cmd_from_list(cmd);
|
||||||
if (shost->use_cmd_list) {
|
|
||||||
BUG_ON(list_empty(&cmd->list));
|
|
||||||
spin_lock_irqsave(&sdev->list_lock, flags);
|
|
||||||
list_del_init(&cmd->list);
|
|
||||||
spin_unlock_irqrestore(&sdev->list_lock, flags);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1134,12 +1124,40 @@ err_exit:
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(scsi_init_io);
|
EXPORT_SYMBOL(scsi_init_io);
|
||||||
|
|
||||||
|
/* Add a command to the list used by the aacraid and dpt_i2o drivers */
|
||||||
|
void scsi_add_cmd_to_list(struct scsi_cmnd *cmd)
|
||||||
|
{
|
||||||
|
struct scsi_device *sdev = cmd->device;
|
||||||
|
struct Scsi_Host *shost = sdev->host;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
if (shost->use_cmd_list) {
|
||||||
|
spin_lock_irqsave(&sdev->list_lock, flags);
|
||||||
|
list_add_tail(&cmd->list, &sdev->cmd_list);
|
||||||
|
spin_unlock_irqrestore(&sdev->list_lock, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove a command from the list used by the aacraid and dpt_i2o drivers */
|
||||||
|
void scsi_del_cmd_from_list(struct scsi_cmnd *cmd)
|
||||||
|
{
|
||||||
|
struct scsi_device *sdev = cmd->device;
|
||||||
|
struct Scsi_Host *shost = sdev->host;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
if (shost->use_cmd_list) {
|
||||||
|
spin_lock_irqsave(&sdev->list_lock, flags);
|
||||||
|
BUG_ON(list_empty(&cmd->list));
|
||||||
|
list_del_init(&cmd->list);
|
||||||
|
spin_unlock_irqrestore(&sdev->list_lock, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
|
void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
|
||||||
{
|
{
|
||||||
void *buf = cmd->sense_buffer;
|
void *buf = cmd->sense_buffer;
|
||||||
void *prot = cmd->prot_sdb;
|
void *prot = cmd->prot_sdb;
|
||||||
unsigned int unchecked_isa_dma = cmd->flags & SCMD_UNCHECKED_ISA_DMA;
|
unsigned int unchecked_isa_dma = cmd->flags & SCMD_UNCHECKED_ISA_DMA;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
/* zero out the cmd, except for the embedded scsi_request */
|
/* zero out the cmd, except for the embedded scsi_request */
|
||||||
memset((char *)cmd + sizeof(cmd->req), 0,
|
memset((char *)cmd + sizeof(cmd->req), 0,
|
||||||
|
@ -1152,9 +1170,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
|
||||||
INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
|
INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
|
||||||
cmd->jiffies_at_alloc = jiffies;
|
cmd->jiffies_at_alloc = jiffies;
|
||||||
|
|
||||||
spin_lock_irqsave(&dev->list_lock, flags);
|
scsi_add_cmd_to_list(cmd);
|
||||||
list_add_tail(&cmd->list, &dev->cmd_list);
|
|
||||||
spin_unlock_irqrestore(&dev->list_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req)
|
static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req)
|
||||||
|
@ -1871,11 +1887,7 @@ static int scsi_mq_prep_fn(struct request *req)
|
||||||
INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
|
INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
|
||||||
cmd->jiffies_at_alloc = jiffies;
|
cmd->jiffies_at_alloc = jiffies;
|
||||||
|
|
||||||
if (shost->use_cmd_list) {
|
scsi_add_cmd_to_list(cmd);
|
||||||
spin_lock_irq(&sdev->list_lock);
|
|
||||||
list_add_tail(&cmd->list, &sdev->cmd_list);
|
|
||||||
spin_unlock_irq(&sdev->list_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
sg = (void *)cmd + sizeof(struct scsi_cmnd) + shost->hostt->cmd_size;
|
sg = (void *)cmd + sizeof(struct scsi_cmnd) + shost->hostt->cmd_size;
|
||||||
cmd->sdb.table.sgl = sg;
|
cmd->sdb.table.sgl = sg;
|
||||||
|
|
|
@ -80,6 +80,8 @@ int scsi_eh_get_sense(struct list_head *work_q,
|
||||||
int scsi_noretry_cmd(struct scsi_cmnd *scmd);
|
int scsi_noretry_cmd(struct scsi_cmnd *scmd);
|
||||||
|
|
||||||
/* scsi_lib.c */
|
/* scsi_lib.c */
|
||||||
|
extern void scsi_add_cmd_to_list(struct scsi_cmnd *cmd);
|
||||||
|
extern void scsi_del_cmd_from_list(struct scsi_cmnd *cmd);
|
||||||
extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
|
extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
|
||||||
extern void scsi_device_unbusy(struct scsi_device *sdev);
|
extern void scsi_device_unbusy(struct scsi_device *sdev);
|
||||||
extern void scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
|
extern void scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
|
||||||
|
|
Loading…
Reference in New Issue