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

scsi: target: core: Remove target_submit_cmd_map_sgls()

Convert target_submit_cmd() to do its own calls and then remove
target_submit_cmd_map_sgls() since no one uses it.

Link: https://lore.kernel.org/r/20210227170006.5077-15-michael.christie@oracle.com
Tested-by: Laurence Oberman <loberman@redhat.com>
Reviewed-by: Bodo Stroesser <bostroesser@gmail.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Mike Christie and committed by
Martin K. Petersen
0fa50a8b 47edc84f

+19 -65
+18 -60
drivers/target/target_core_transport.c
··· 1754 1754 EXPORT_SYMBOL_GPL(target_submit); 1755 1755 1756 1756 /** 1757 - * target_submit_cmd_map_sgls - lookup unpacked lun and submit uninitialized 1758 - * se_cmd + use pre-allocated SGL memory. 1759 - * 1760 - * @se_cmd: command descriptor to submit 1761 - * @se_sess: associated se_sess for endpoint 1762 - * @cdb: pointer to SCSI CDB 1763 - * @sense: pointer to SCSI sense buffer 1764 - * @unpacked_lun: unpacked LUN to reference for struct se_lun 1765 - * @data_length: fabric expected data transfer length 1766 - * @task_attr: SAM task attribute 1767 - * @data_dir: DMA data direction 1768 - * @flags: flags for command submission from target_sc_flags_tables 1769 - * @sgl: struct scatterlist memory for unidirectional mapping 1770 - * @sgl_count: scatterlist count for unidirectional mapping 1771 - * @sgl_bidi: struct scatterlist memory for bidirectional READ mapping 1772 - * @sgl_bidi_count: scatterlist count for bidirectional READ mapping 1773 - * @sgl_prot: struct scatterlist memory protection information 1774 - * @sgl_prot_count: scatterlist count for protection information 1775 - * 1776 - * Task tags are supported if the caller has set @se_cmd->tag. 1777 - * 1778 - * Returns non zero to signal active I/O shutdown failure. All other 1779 - * setup exceptions will be returned as a SCSI CHECK_CONDITION response, 1780 - * but still return zero here. 1781 - * 1782 - * This may only be called from process context, and also currently 1783 - * assumes internal allocation of fabric payload buffer by target-core. 1784 - */ 1785 - int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess, 1786 - unsigned char *cdb, unsigned char *sense, u64 unpacked_lun, 1787 - u32 data_length, int task_attr, int data_dir, int flags, 1788 - struct scatterlist *sgl, u32 sgl_count, 1789 - struct scatterlist *sgl_bidi, u32 sgl_bidi_count, 1790 - struct scatterlist *sgl_prot, u32 sgl_prot_count) 1791 - { 1792 - int rc; 1793 - 1794 - rc = target_init_cmd(se_cmd, se_sess, sense, unpacked_lun, 1795 - data_length, task_attr, data_dir, flags); 1796 - if (rc < 0) 1797 - return rc; 1798 - 1799 - if (target_submit_prep(se_cmd, cdb, sgl, sgl_count, sgl_bidi, 1800 - sgl_bidi_count, sgl_prot, sgl_prot_count)) 1801 - return 0; 1802 - 1803 - target_submit(se_cmd); 1804 - return 0; 1805 - } 1806 - EXPORT_SYMBOL(target_submit_cmd_map_sgls); 1807 - 1808 - /** 1809 1757 * target_submit_cmd - lookup unpacked lun and submit uninitialized se_cmd 1810 1758 * 1811 1759 * @se_cmd: command descriptor to submit ··· 1768 1820 * 1769 1821 * Task tags are supported if the caller has set @se_cmd->tag. 1770 1822 * 1771 - * Returns non zero to signal active I/O shutdown failure. All other 1772 - * setup exceptions will be returned as a SCSI CHECK_CONDITION response, 1773 - * but still return zero here. 1774 - * 1775 1823 * This may only be called from process context, and also currently 1776 1824 * assumes internal allocation of fabric payload buffer by target-core. 1777 1825 * 1778 1826 * It also assumes interal target core SGL memory allocation. 1827 + * 1828 + * This function must only be used by drivers that do their own 1829 + * sync during shutdown and does not use target_stop_session. If there 1830 + * is a failure this function will call into the fabric driver's 1831 + * queue_status with a CHECK_CONDITION. 1779 1832 */ 1780 - int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, 1833 + void target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, 1781 1834 unsigned char *cdb, unsigned char *sense, u64 unpacked_lun, 1782 1835 u32 data_length, int task_attr, int data_dir, int flags) 1783 1836 { 1784 - return target_submit_cmd_map_sgls(se_cmd, se_sess, cdb, sense, 1785 - unpacked_lun, data_length, task_attr, data_dir, 1786 - flags, NULL, 0, NULL, 0, NULL, 0); 1837 + int rc; 1838 + 1839 + rc = target_init_cmd(se_cmd, se_sess, sense, unpacked_lun, data_length, 1840 + task_attr, data_dir, flags); 1841 + WARN(rc, "Invalid target_submit_cmd use. Driver must not use target_stop_session or call target_init_cmd directly.\n"); 1842 + if (rc) 1843 + return; 1844 + 1845 + if (target_submit_prep(se_cmd, cdb, NULL, 0, NULL, 0, NULL, 0)) 1846 + return; 1847 + 1848 + target_submit(se_cmd); 1787 1849 } 1788 1850 EXPORT_SYMBOL(target_submit_cmd); 1789 1851
+1 -5
include/target/target_core_fabric.h
··· 162 162 sense_reason_t transport_lookup_cmd_lun(struct se_cmd *); 163 163 sense_reason_t target_cmd_init_cdb(struct se_cmd *, unsigned char *); 164 164 sense_reason_t target_cmd_parse_cdb(struct se_cmd *); 165 - int target_submit_cmd_map_sgls(struct se_cmd *, struct se_session *, 166 - unsigned char *, unsigned char *, u64, u32, int, int, int, 167 - struct scatterlist *, u32, struct scatterlist *, u32, 168 - struct scatterlist *, u32); 169 - int target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *, 165 + void target_submit_cmd(struct se_cmd *, struct se_session *, unsigned char *, 170 166 unsigned char *, u64, u32, int, int, int); 171 167 int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, 172 168 unsigned char *sense, u64 unpacked_lun,