Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: move scsi_dispatch_cmd to scsi_lib.c

scsi_lib.c is where the rest of the I/O submission path lives, so move
scsi_dispatch_cmd there and mark it static.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>

+81 -82
-81
drivers/scsi/scsi.c
··· 603 603 EXPORT_SYMBOL(scsi_cmd_get_serial); 604 604 605 605 /** 606 - * scsi_dispatch_command - Dispatch a command to the low-level driver. 607 - * @cmd: command block we are dispatching. 608 - * 609 - * Return: nonzero return request was rejected and device's queue needs to be 610 - * plugged. 611 - */ 612 - int scsi_dispatch_cmd(struct scsi_cmnd *cmd) 613 - { 614 - struct Scsi_Host *host = cmd->device->host; 615 - int rtn = 0; 616 - 617 - atomic_inc(&cmd->device->iorequest_cnt); 618 - 619 - /* check if the device is still usable */ 620 - if (unlikely(cmd->device->sdev_state == SDEV_DEL)) { 621 - /* in SDEV_DEL we error all commands. DID_NO_CONNECT 622 - * returns an immediate error upwards, and signals 623 - * that the device is no longer present */ 624 - cmd->result = DID_NO_CONNECT << 16; 625 - goto done; 626 - } 627 - 628 - /* Check to see if the scsi lld made this device blocked. */ 629 - if (unlikely(scsi_device_blocked(cmd->device))) { 630 - /* 631 - * in blocked state, the command is just put back on 632 - * the device queue. The suspend state has already 633 - * blocked the queue so future requests should not 634 - * occur until the device transitions out of the 635 - * suspend state. 636 - */ 637 - SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, 638 - "queuecommand : device blocked\n")); 639 - return SCSI_MLQUEUE_DEVICE_BUSY; 640 - } 641 - 642 - /* Store the LUN value in cmnd, if needed. */ 643 - if (cmd->device->lun_in_cdb) 644 - cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) | 645 - (cmd->device->lun << 5 & 0xe0); 646 - 647 - scsi_log_send(cmd); 648 - 649 - /* 650 - * Before we queue this command, check if the command 651 - * length exceeds what the host adapter can handle. 652 - */ 653 - if (cmd->cmd_len > cmd->device->host->max_cmd_len) { 654 - SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, 655 - "queuecommand : command too long. " 656 - "cdb_size=%d host->max_cmd_len=%d\n", 657 - cmd->cmd_len, cmd->device->host->max_cmd_len)); 658 - cmd->result = (DID_ABORT << 16); 659 - goto done; 660 - } 661 - 662 - if (unlikely(host->shost_state == SHOST_DEL)) { 663 - cmd->result = (DID_NO_CONNECT << 16); 664 - goto done; 665 - 666 - } 667 - 668 - trace_scsi_dispatch_cmd_start(cmd); 669 - rtn = host->hostt->queuecommand(host, cmd); 670 - if (rtn) { 671 - trace_scsi_dispatch_cmd_error(cmd, rtn); 672 - if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && 673 - rtn != SCSI_MLQUEUE_TARGET_BUSY) 674 - rtn = SCSI_MLQUEUE_HOST_BUSY; 675 - 676 - SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, 677 - "queuecommand : request rejected\n")); 678 - } 679 - 680 - return rtn; 681 - done: 682 - cmd->scsi_done(cmd); 683 - return 0; 684 - } 685 - 686 - /** 687 606 * scsi_finish_command - cleanup and pass command back to upper layer 688 607 * @cmd: the command 689 608 *
+81
drivers/scsi/scsi_lib.c
··· 1641 1641 } 1642 1642 1643 1643 /** 1644 + * scsi_dispatch_command - Dispatch a command to the low-level driver. 1645 + * @cmd: command block we are dispatching. 1646 + * 1647 + * Return: nonzero return request was rejected and device's queue needs to be 1648 + * plugged. 1649 + */ 1650 + static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) 1651 + { 1652 + struct Scsi_Host *host = cmd->device->host; 1653 + int rtn = 0; 1654 + 1655 + atomic_inc(&cmd->device->iorequest_cnt); 1656 + 1657 + /* check if the device is still usable */ 1658 + if (unlikely(cmd->device->sdev_state == SDEV_DEL)) { 1659 + /* in SDEV_DEL we error all commands. DID_NO_CONNECT 1660 + * returns an immediate error upwards, and signals 1661 + * that the device is no longer present */ 1662 + cmd->result = DID_NO_CONNECT << 16; 1663 + goto done; 1664 + } 1665 + 1666 + /* Check to see if the scsi lld made this device blocked. */ 1667 + if (unlikely(scsi_device_blocked(cmd->device))) { 1668 + /* 1669 + * in blocked state, the command is just put back on 1670 + * the device queue. The suspend state has already 1671 + * blocked the queue so future requests should not 1672 + * occur until the device transitions out of the 1673 + * suspend state. 1674 + */ 1675 + SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, 1676 + "queuecommand : device blocked\n")); 1677 + return SCSI_MLQUEUE_DEVICE_BUSY; 1678 + } 1679 + 1680 + /* Store the LUN value in cmnd, if needed. */ 1681 + if (cmd->device->lun_in_cdb) 1682 + cmd->cmnd[1] = (cmd->cmnd[1] & 0x1f) | 1683 + (cmd->device->lun << 5 & 0xe0); 1684 + 1685 + scsi_log_send(cmd); 1686 + 1687 + /* 1688 + * Before we queue this command, check if the command 1689 + * length exceeds what the host adapter can handle. 1690 + */ 1691 + if (cmd->cmd_len > cmd->device->host->max_cmd_len) { 1692 + SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, 1693 + "queuecommand : command too long. " 1694 + "cdb_size=%d host->max_cmd_len=%d\n", 1695 + cmd->cmd_len, cmd->device->host->max_cmd_len)); 1696 + cmd->result = (DID_ABORT << 16); 1697 + goto done; 1698 + } 1699 + 1700 + if (unlikely(host->shost_state == SHOST_DEL)) { 1701 + cmd->result = (DID_NO_CONNECT << 16); 1702 + goto done; 1703 + 1704 + } 1705 + 1706 + trace_scsi_dispatch_cmd_start(cmd); 1707 + rtn = host->hostt->queuecommand(host, cmd); 1708 + if (rtn) { 1709 + trace_scsi_dispatch_cmd_error(cmd, rtn); 1710 + if (rtn != SCSI_MLQUEUE_DEVICE_BUSY && 1711 + rtn != SCSI_MLQUEUE_TARGET_BUSY) 1712 + rtn = SCSI_MLQUEUE_HOST_BUSY; 1713 + 1714 + SCSI_LOG_MLQUEUE(3, scmd_printk(KERN_INFO, cmd, 1715 + "queuecommand : request rejected\n")); 1716 + } 1717 + 1718 + return rtn; 1719 + done: 1720 + cmd->scsi_done(cmd); 1721 + return 0; 1722 + } 1723 + 1724 + /** 1644 1725 * scsi_done - Invoke completion on finished SCSI command. 1645 1726 * @cmd: The SCSI Command for which a low-level device driver (LLDD) gives 1646 1727 * ownership back to SCSI Core -- i.e. the LLDD has finished with it.
-1
drivers/scsi/scsi_priv.h
··· 29 29 extern void scsi_exit_hosts(void); 30 30 31 31 /* scsi.c */ 32 - extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd); 33 32 extern int scsi_setup_command_freelist(struct Scsi_Host *shost); 34 33 extern void scsi_destroy_command_freelist(struct Scsi_Host *shost); 35 34 #ifdef CONFIG_SCSI_LOGGING