History

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.

Mike Christie committed 3 years ago

Commit e2f4ea41 parent 42892676 files · +57 −12Browse files

Unified · Split

6 files
  1. drivers/target/loopback/tcm_loop.c +1 −1
  2. drivers/target/target_core_configfs.c +22 −0
  3. drivers/target/target_core_device.c +1 −0
  4. drivers/target/target_core_transport.c +31 −10
  5. drivers/vhost/scsi.c +1 −1
  6. include/target/target_core_base.h +1 −0
drivers/target/loopback/tcm_loop.c+1−1
@@ -154,7 +154,7 @@ static void tcm_loop_target_queue_cmd(struct tcm_loop_cmd *tl_cmd) · 153 unmodified lines
154154 GFP_ATOMIC))
155155 return;
156156
157− target_queue_submission(se_cmd);
157+ target_submit(se_cmd);
158158 return;
159159
160160 out_done:
drivers/target/target_core_configfs.c+22−0
@@ -577,6 +577,7 @@ DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity_alignment); · 576 unmodified lines
577577 DEF_CONFIGFS_ATTRIB_SHOW(unmap_zeroes_data);
578578 DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len);
579579 DEF_CONFIGFS_ATTRIB_SHOW(emulate_rsoc);
580+DEF_CONFIGFS_ATTRIB_SHOW(submit_type);
580581
581582 #define DEF_CONFIGFS_ATTRIB_STORE_U32(_name) \
582583 static ssize_t _name##_store(struct config_item *item, const char *page,\
@@ -1231,6 +1232,24 @@ static ssize_t emulate_rsoc_store(struct config_item *item, · 648 unmodified lines
12311232 return count;
12321233 }
12331234
1235+static ssize_t submit_type_store(struct config_item *item, const char *page,
1236+ size_t count)
1237+{
1238+ struct se_dev_attrib *da = to_attrib(item);
1239+ int ret;
1240+ u8 val;
1241+
1242+ ret = kstrtou8(page, 0, &val);
1243+ if (ret < 0)
1244+ return ret;
1245+
1246+ if (val > TARGET_QUEUE_SUBMIT)
1247+ return -EINVAL;
1248+
1249+ da->submit_type = val;
1250+ return count;
1251+}
1252+
12341253 CONFIGFS_ATTR(, emulate_model_alias);
12351254 CONFIGFS_ATTR(, emulate_dpo);
12361255 CONFIGFS_ATTR(, emulate_fua_write);
@@ -1266,6 +1285,7 @@ CONFIGFS_ATTR(, unmap_zeroes_data); · 29 unmodified lines
12661285 CONFIGFS_ATTR(, max_write_same_len);
12671286 CONFIGFS_ATTR(, alua_support);
12681287 CONFIGFS_ATTR(, pgr_support);
1288+CONFIGFS_ATTR(, submit_type);
12691289
12701290 /*
12711291 * dev_attrib attributes for devices using the target core SBC/SPC
@@ -1308,6 +1328,7 @@ struct configfs_attribute *sbc_attrib_attrs[] = { · 36 unmodified lines
13081328 &attr_alua_support,
13091329 &attr_pgr_support,
13101330 &attr_emulate_rsoc,
1331+ &attr_submit_type,
13111332 NULL,
13121333 };
13131334 EXPORT_SYMBOL(sbc_attrib_attrs);
@@ -1325,6 +1346,7 @@ struct configfs_attribute *passthrough_attrib_attrs[] = { · 11 unmodified lines
13251346 &attr_emulate_pr,
13261347 &attr_alua_support,
13271348 &attr_pgr_support,
1349+ &attr_submit_type,
13281350 NULL,
13291351 };
13301352 EXPORT_SYMBOL(passthrough_attrib_attrs);
drivers/target/target_core_device.c+1−0
@@ -779,6 +779,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) · 778 unmodified lines
779779 dev->dev_attrib.unmap_zeroes_data =
780780 DA_UNMAP_ZEROES_DATA_DEFAULT;
781781 dev->dev_attrib.max_write_same_len = DA_MAX_WRITE_SAME_LEN;
782+ dev->dev_attrib.submit_type = TARGET_FABRIC_DEFAULT_SUBMIT;
782783
783784 xcopy_lun = &dev->xcopy_lun;
784785 rcu_assign_pointer(xcopy_lun->lun_se_dev, dev);
drivers/target/target_core_transport.c+31−10
@@ -1575,14 +1575,7 @@ target_cmd_parse_cdb(struct se_cmd *cmd) · 1574 unmodified lines
15751575 }
15761576 EXPORT_SYMBOL(target_cmd_parse_cdb);
15771577
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)
15861579 {
15871580 sense_reason_t ret;
15881581
@@ -1642,7 +1635,6 @@ int target_submit(struct se_cmd *cmd) · 53 unmodified lines
16421635 transport_generic_request_failure(cmd, ret);
16431636 return 0;
16441637 }
1645−EXPORT_SYMBOL_GPL(target_submit);
16461638
16471639 sense_reason_t
16481640 transport_generic_map_mem_to_cmd(struct se_cmd *cmd, struct scatterlist *sgl,
@@ -1904,7 +1896,7 @@ void target_queued_submit_work(struct work_struct *work) · 255 unmodified lines
19041896 se_plug = target_plug_device(se_dev);
19051897 }
19061898
1907− target_submit(se_cmd);
1899+ __target_submit(se_cmd);
19081900 }
19091901
19101902 if (se_plug)
@@ -1927,6 +1919,35 @@ void target_queue_submission(struct se_cmd *se_cmd) · 16 unmodified lines
19271919 }
19281920 EXPORT_SYMBOL_GPL(target_queue_submission);
19291921
1922+/**
1923+ * target_submit - perform final initialization and submit cmd to LIO core
1924+ * @cmd: command descriptor to submit
1925+ *
1926+ * target_submit_prep or something similar must have been called on the cmd,
1927+ * and this must be called from process context.
1928+ */
1929+int target_submit(struct se_cmd *se_cmd)
1930+{
1931+ const struct target_core_fabric_ops *tfo = se_cmd->se_sess->se_tpg->se_tpg_tfo;
1932+ struct se_dev_attrib *da = &se_cmd->se_dev->dev_attrib;
1933+ u8 submit_type;
1934+
1935+ if (da->submit_type == TARGET_FABRIC_DEFAULT_SUBMIT)
1936+ submit_type = tfo->default_submit_type;
1937+ else if (da->submit_type == TARGET_DIRECT_SUBMIT &&
1938+ tfo->direct_submit_supp)
1939+ submit_type = TARGET_DIRECT_SUBMIT;
1940+ else
1941+ submit_type = TARGET_QUEUE_SUBMIT;
1942+
1943+ if (submit_type == TARGET_DIRECT_SUBMIT)
1944+ return __target_submit(se_cmd);
1945+
1946+ target_queue_submission(se_cmd);
1947+ return 0;
1948+}
1949+EXPORT_SYMBOL_GPL(target_submit);
1950+
19301951 static void target_complete_tmr_failure(struct work_struct *work)
19311952 {
19321953 struct se_cmd *se_cmd = container_of(work, struct se_cmd, work);
drivers/vhost/scsi.c+1−1
@@ -909,7 +909,7 @@ static void vhost_scsi_target_queue_cmd(struct vhost_scsi_cmd *cmd) · 908 unmodified lines
909909 cmd->tvc_prot_sgl_count, GFP_KERNEL))
910910 return;
911911
912− target_queue_submission(se_cmd);
912+ target_submit(se_cmd);
913913 }
914914
915915 static void
include/target/target_core_base.h+1−0
@@ -726,6 +726,7 @@ struct se_dev_attrib { · 725 unmodified lines
726726 u32 unmap_granularity;
727727 u32 unmap_granularity_alignment;
728728 u32 max_write_same_len;
729+ u8 submit_type;
729730 struct se_device *da_dev;
730731 struct config_group da_group;
731732 };