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: Allow userspace to request direct submissions

This allows userspace to request the fabric drivers do direct submissions
if they support it. With the new device file, submit_type, users can
write 0 - 2 to control how commands are submitted to the backend:

0 - TARGET_FABRIC_DEFAULT_SUBMIT - LIO will use the fabric's default
submission type. This is the default for compat.

1 - TARGET_DIRECT_SUBMIT - LIO will submit the cmd to the backend from the
calling context if the fabric the cmd was received on supports it,
else it will use the fabric's default type.

2 - TARGET_QUEUE_SUBMIT - LIO will queue the cmd to the LIO submission
workqueue which will pass it to the backend.

When using an NVMe drive and vhost-scsi with direct submission we see
around a 20% improvement in 4K I/Os:

fio jobs 1 2 4 8 10
--------------------------------------------------
defer 94K 190K 394K 770K 890K
direct 128K 252K 488K 950K -

And when using the queueing mode, we now no longer see issues like where
the iSCSI tx thread is blocked in the block layer waiting on a tag so it
can't respond to a nop or perform I/Os for other LUs.

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

authored by

Mike Christie and committed by
Martin K. Petersen
e2f4ea40 42892679

+57 -12
+1 -1
drivers/target/loopback/tcm_loop.c
··· 154 154 GFP_ATOMIC)) 155 155 return; 156 156 157 - target_queue_submission(se_cmd); 157 + target_submit(se_cmd); 158 158 return; 159 159 160 160 out_done:
+22
drivers/target/target_core_configfs.c
··· 577 577 DEF_CONFIGFS_ATTRIB_SHOW(unmap_zeroes_data); 578 578 DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len); 579 579 DEF_CONFIGFS_ATTRIB_SHOW(emulate_rsoc); 580 + DEF_CONFIGFS_ATTRIB_SHOW(submit_type); 580 581 581 582 #define DEF_CONFIGFS_ATTRIB_STORE_U32(_name) \ 582 583 static ssize_t _name##_store(struct config_item *item, const char *page,\ ··· 1232 1231 return count; 1233 1232 } 1234 1233 1234 + static ssize_t submit_type_store(struct config_item *item, const char *page, 1235 + size_t count) 1236 + { 1237 + struct se_dev_attrib *da = to_attrib(item); 1238 + int ret; 1239 + u8 val; 1240 + 1241 + ret = kstrtou8(page, 0, &val); 1242 + if (ret < 0) 1243 + return ret; 1244 + 1245 + if (val > TARGET_QUEUE_SUBMIT) 1246 + return -EINVAL; 1247 + 1248 + da->submit_type = val; 1249 + return count; 1250 + } 1251 + 1235 1252 CONFIGFS_ATTR(, emulate_model_alias); 1236 1253 CONFIGFS_ATTR(, emulate_dpo); 1237 1254 CONFIGFS_ATTR(, emulate_fua_write); ··· 1285 1266 CONFIGFS_ATTR(, max_write_same_len); 1286 1267 CONFIGFS_ATTR(, alua_support); 1287 1268 CONFIGFS_ATTR(, pgr_support); 1269 + CONFIGFS_ATTR(, submit_type); 1288 1270 1289 1271 /* 1290 1272 * dev_attrib attributes for devices using the target core SBC/SPC ··· 1328 1308 &attr_alua_support, 1329 1309 &attr_pgr_support, 1330 1310 &attr_emulate_rsoc, 1311 + &attr_submit_type, 1331 1312 NULL, 1332 1313 }; 1333 1314 EXPORT_SYMBOL(sbc_attrib_attrs); ··· 1346 1325 &attr_emulate_pr, 1347 1326 &attr_alua_support, 1348 1327 &attr_pgr_support, 1328 + &attr_submit_type, 1349 1329 NULL, 1350 1330 }; 1351 1331 EXPORT_SYMBOL(passthrough_attrib_attrs);
+1
drivers/target/target_core_device.c
··· 779 779 dev->dev_attrib.unmap_zeroes_data = 780 780 DA_UNMAP_ZEROES_DATA_DEFAULT; 781 781 dev->dev_attrib.max_write_same_len = DA_MAX_WRITE_SAME_LEN; 782 + dev->dev_attrib.submit_type = TARGET_FABRIC_DEFAULT_SUBMIT; 782 783 783 784 xcopy_lun = &dev->xcopy_lun; 784 785 rcu_assign_pointer(xcopy_lun->lun_se_dev, dev);
+31 -10
drivers/target/target_core_transport.c
··· 1575 1575 } 1576 1576 EXPORT_SYMBOL(target_cmd_parse_cdb); 1577 1577 1578 - /** 1579 - * target_submit - perform final initialization and submit cmd to LIO core 1580 - * @cmd: command descriptor to submit 1581 - * 1582 - * target_submit_prep or something similar must have been called on the cmd, 1583 - * and this must be called from process context. 1584 - */ 1585 - int target_submit(struct se_cmd *cmd) 1578 + static int __target_submit(struct se_cmd *cmd) 1586 1579 { 1587 1580 sense_reason_t ret; 1588 1581 ··· 1635 1642 transport_generic_request_failure(cmd, ret); 1636 1643 return 0; 1637 1644 } 1638 - EXPORT_SYMBOL_GPL(target_submit); 1639 1645 1640 1646 sense_reason_t 1641 1647 transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *sgl, ··· 1896 1904 se_plug = target_plug_device(se_dev); 1897 1905 } 1898 1906 1899 - target_submit(se_cmd); 1907 + __target_submit(se_cmd); 1900 1908 } 1901 1909 1902 1910 if (se_plug) ··· 1918 1926 queue_work_on(cpu, target_submission_wq, &sq->work); 1919 1927 } 1920 1928 EXPORT_SYMBOL_GPL(target_queue_submission); 1929 + 1930 + /** 1931 + * target_submit - perform final initialization and submit cmd to LIO core 1932 + * @cmd: command descriptor to submit 1933 + * 1934 + * target_submit_prep or something similar must have been called on the cmd, 1935 + * and this must be called from process context. 1936 + */ 1937 + int target_submit(struct se_cmd *se_cmd) 1938 + { 1939 + const struct target_core_fabric_ops *tfo = se_cmd->se_sess->se_tpg->se_tpg_tfo; 1940 + struct se_dev_attrib *da = &se_cmd->se_dev->dev_attrib; 1941 + u8 submit_type; 1942 + 1943 + if (da->submit_type == TARGET_FABRIC_DEFAULT_SUBMIT) 1944 + submit_type = tfo->default_submit_type; 1945 + else if (da->submit_type == TARGET_DIRECT_SUBMIT && 1946 + tfo->direct_submit_supp) 1947 + submit_type = TARGET_DIRECT_SUBMIT; 1948 + else 1949 + submit_type = TARGET_QUEUE_SUBMIT; 1950 + 1951 + if (submit_type == TARGET_DIRECT_SUBMIT) 1952 + return __target_submit(se_cmd); 1953 + 1954 + target_queue_submission(se_cmd); 1955 + return 0; 1956 + } 1957 + EXPORT_SYMBOL_GPL(target_submit); 1921 1958 1922 1959 static void target_complete_tmr_failure(struct work_struct *work) 1923 1960 {
+1 -1
drivers/vhost/scsi.c
··· 909 909 cmd->tvc_prot_sgl_count, GFP_KERNEL)) 910 910 return; 911 911 912 - target_queue_submission(se_cmd); 912 + target_submit(se_cmd); 913 913 } 914 914 915 915 static void
+1
include/target/target_core_base.h
··· 726 726 u32 unmap_granularity; 727 727 u32 unmap_granularity_alignment; 728 728 u32 max_write_same_len; 729 + u8 submit_type; 729 730 struct se_device *da_dev; 730 731 struct config_group da_group; 731 732 };