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

Configure Feed

Select the types of activity you want to include in your feed.

scsi: target: core: Move buffer clearing hack

Move the hack to clear some buffers to transport_handle_cdb_direct() so we
can eventually merge transport_handle_cdb_direct() and target_submit().

This also fixes up the comment so it's clear it was only for udev and
reflects that the referenced function does not exist and we now allow more
than 1 page for control CDBs.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20230928020907.5730-4-michael.christie@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Mike Christie and committed by
Martin K. Petersen
5c48a4ea ee48345e

+21 -28
+21 -28
drivers/target/target_core_transport.c
··· 1592 1592 */ 1593 1593 core_alua_check_nonop_delay(cmd); 1594 1594 1595 + if (cmd->t_data_nents != 0) { 1596 + /* 1597 + * This is primarily a hack for udev and tcm loop which sends 1598 + * INQUIRYs with a single page and expects the data to be 1599 + * cleared. 1600 + */ 1601 + if (!(cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) && 1602 + cmd->data_direction == DMA_FROM_DEVICE) { 1603 + struct scatterlist *sgl = cmd->t_data_sg; 1604 + unsigned char *buf = NULL; 1605 + 1606 + BUG_ON(!sgl); 1607 + 1608 + buf = kmap_local_page(sg_page(sgl)); 1609 + if (buf) { 1610 + memset(buf + sgl->offset, 0, sgl->length); 1611 + kunmap_local(buf); 1612 + } 1613 + } 1614 + } 1615 + 1595 1616 if (!cmd->se_lun) { 1596 1617 dump_stack(); 1597 1618 pr_err("cmd->se_lun is NULL\n"); ··· 1816 1795 */ 1817 1796 void target_submit(struct se_cmd *se_cmd) 1818 1797 { 1819 - struct scatterlist *sgl = se_cmd->t_data_sg; 1820 - unsigned char *buf = NULL; 1821 - 1822 - might_sleep(); 1823 - 1824 - if (se_cmd->t_data_nents != 0) { 1825 - BUG_ON(!sgl); 1826 - /* 1827 - * A work-around for tcm_loop as some userspace code via 1828 - * scsi-generic do not memset their associated read buffers, 1829 - * so go ahead and do that here for type non-data CDBs. Also 1830 - * note that this is currently guaranteed to be a single SGL 1831 - * for this case by target core in target_setup_cmd_from_cdb() 1832 - * -> transport_generic_cmd_sequencer(). 1833 - */ 1834 - if (!(se_cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) && 1835 - se_cmd->data_direction == DMA_FROM_DEVICE) { 1836 - if (sgl) 1837 - buf = kmap(sg_page(sgl)) + sgl->offset; 1838 - 1839 - if (buf) { 1840 - memset(buf, 0, sgl->length); 1841 - kunmap(sg_page(sgl)); 1842 - } 1843 - } 1844 - 1845 - } 1846 - 1847 1798 transport_handle_cdb_direct(se_cmd); 1848 1799 } 1849 1800 EXPORT_SYMBOL_GPL(target_submit);