mirror of https://gitee.com/openkylin/linux.git
scsi: aacraid: use scsi_host_busy_iter() in get_num_of_incomplete_fibs()
Use the SCSI midlayer helper to traverse the number of outstanding commands. This also eliminates the last usage for the cmd_list functionality so we can drop it. Link: https://lore.kernel.org/r/20200228075318.91255-13-hare@suse.de Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Balsundar P <balsundar.p@microchip.com> Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
f4a0c9dbc6
commit
35d2ce0b65
|
@ -622,54 +622,56 @@ static int aac_ioctl(struct scsi_device *sdev, unsigned int cmd,
|
|||
return aac_do_ioctl(dev, cmd, arg);
|
||||
}
|
||||
|
||||
struct fib_count_data {
|
||||
int mlcnt;
|
||||
int llcnt;
|
||||
int ehcnt;
|
||||
int fwcnt;
|
||||
int krlcnt;
|
||||
};
|
||||
|
||||
static bool fib_count_iter(struct scsi_cmnd *scmnd, void *data, bool reserved)
|
||||
{
|
||||
struct fib_count_data *fib_count = data;
|
||||
|
||||
switch (scmnd->SCp.phase) {
|
||||
case AAC_OWNER_FIRMWARE:
|
||||
fib_count->fwcnt++;
|
||||
break;
|
||||
case AAC_OWNER_ERROR_HANDLER:
|
||||
fib_count->ehcnt++;
|
||||
break;
|
||||
case AAC_OWNER_LOWLEVEL:
|
||||
fib_count->llcnt++;
|
||||
break;
|
||||
case AAC_OWNER_MIDLEVEL:
|
||||
fib_count->mlcnt++;
|
||||
break;
|
||||
default:
|
||||
fib_count->krlcnt++;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Called during SCSI EH, so we don't need to block requests */
|
||||
static int get_num_of_incomplete_fibs(struct aac_dev *aac)
|
||||
{
|
||||
|
||||
unsigned long flags;
|
||||
struct scsi_device *sdev = NULL;
|
||||
struct Scsi_Host *shost = aac->scsi_host_ptr;
|
||||
struct scsi_cmnd *scmnd = NULL;
|
||||
struct device *ctrl_dev;
|
||||
struct fib_count_data fcnt = { };
|
||||
|
||||
int mlcnt = 0;
|
||||
int llcnt = 0;
|
||||
int ehcnt = 0;
|
||||
int fwcnt = 0;
|
||||
int krlcnt = 0;
|
||||
|
||||
__shost_for_each_device(sdev, shost) {
|
||||
spin_lock_irqsave(&sdev->list_lock, flags);
|
||||
list_for_each_entry(scmnd, &sdev->cmd_list, list) {
|
||||
switch (scmnd->SCp.phase) {
|
||||
case AAC_OWNER_FIRMWARE:
|
||||
fwcnt++;
|
||||
break;
|
||||
case AAC_OWNER_ERROR_HANDLER:
|
||||
ehcnt++;
|
||||
break;
|
||||
case AAC_OWNER_LOWLEVEL:
|
||||
llcnt++;
|
||||
break;
|
||||
case AAC_OWNER_MIDLEVEL:
|
||||
mlcnt++;
|
||||
break;
|
||||
default:
|
||||
krlcnt++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&sdev->list_lock, flags);
|
||||
}
|
||||
scsi_host_busy_iter(shost, fib_count_iter, &fcnt);
|
||||
|
||||
ctrl_dev = &aac->pdev->dev;
|
||||
|
||||
dev_info(ctrl_dev, "outstanding cmd: midlevel-%d\n", mlcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: lowlevel-%d\n", llcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: error handler-%d\n", ehcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: firmware-%d\n", fwcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: kernel-%d\n", krlcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: midlevel-%d\n", fcnt.mlcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: lowlevel-%d\n", fcnt.llcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: error handler-%d\n", fcnt.ehcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: firmware-%d\n", fcnt.fwcnt);
|
||||
dev_info(ctrl_dev, "outstanding cmd: kernel-%d\n", fcnt.krlcnt);
|
||||
|
||||
return mlcnt + llcnt + ehcnt + fwcnt;
|
||||
return fcnt.mlcnt + fcnt.llcnt + fcnt.ehcnt + fcnt.fwcnt;
|
||||
}
|
||||
|
||||
static int aac_eh_abort(struct scsi_cmnd* cmd)
|
||||
|
@ -1675,7 +1677,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
shost->irq = pdev->irq;
|
||||
shost->unique_id = unique_id;
|
||||
shost->max_cmd_len = 16;
|
||||
shost->use_cmd_list = 1;
|
||||
|
||||
if (aac_cfg_major == AAC_CHARDEV_NEEDS_REINIT)
|
||||
aac_init_char();
|
||||
|
|
Loading…
Reference in New Issue