Skip to contentSkip to conversation

tcm: Move WRITE_SAME_* emulation into transport_emulate_control_cdb()

PATCH In review Nicholas A. Bellinger 1 participant 1 message Oct 10, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/4 tcm: Move WRITE_SAME_* emulation into transport_emulate_control_cdb()

From: Nicholas Bellinger <[email protected]>

This patch updates TCM Core to perform WRITE_SAME_16 and WRITE_SAME_32 w/ UNMAP=1 emulation using the unified control CDB infrastructure. This includes adding a new struct se_subsystem_api_cdb->emulate_write_same() caller used in transport_emulate_control_cdb(), changing transport_generic_cmd_sequencer() to return type TGCS_CONTROL_SG_IO_CDB and removing the now unnecessary struct se_transport_task->t_tasks_unmap and SCF_ECDB_ALLOCATION define.

This patch also updates IBLOCK and FILEIO to set ->emulate_write_same() and hooks up the existing WRITE_SAME_* -> Block Discard logic to the new caller.

---
 drivers/target/target_core_file.c      |    3 +-
 drivers/target/target_core_iblock.c    |    3 +-
 drivers/target/target_core_transport.c |   67 +++++++++++++++++--------------
 include/target/target_core_base.h      |    4 +-
 include/target/target_core_transport.h |    1 +
 5 files changed, 41 insertions(+), 37 deletions(-)
drivers/target/target_core_file.c +1 -2
index 33c6510..55e9ad5 100644
@@ -782,8 +782,6 @@ static int fd_do_task(struct se_task *task)
 
 	if (!(TASK_CMD(task)->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB))
 		return transport_emulate_control_cdb(task);
-	else if (T_TASK(cmd)->t_tasks_unmap)
-		return fd_emulate_write_same_unmap(task);
 
 	req->fd_lba = task->task_lba;
 	req->fd_size = task->task_size;
@@ -1218,6 +1216,7 @@ static struct se_subsystem_api_cdb fileio_cdb_template = {
 	.emulate_read_cap	= fd_emulate_read_cap,
 	.emulate_read_cap16	= fd_emulate_read_cap16,
 	.emulate_unmap		= fd_emulate_unmap,
+	.emulate_write_same	= fd_emulate_write_same_unmap,
 };
 
 int __init fileio_module_init(void)
drivers/target/target_core_iblock.c +1 -2
index d102e0b..a0a9ea3 100644
@@ -584,8 +584,6 @@ static int iblock_do_task(struct se_task *task)
 
 	if (!(TASK_CMD(task)->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB))
 		return transport_emulate_control_cdb(task);
-	else if (T_TASK(task->task_se_cmd)->t_tasks_unmap)
-		return iblock_emulate_write_same_unmap(task);
 
 	while (bio) {
 		nbio = bio->bi_next;
@@ -1139,6 +1137,7 @@ static struct se_subsystem_api_cdb iblock_cdb_template = {
 	.emulate_read_cap	= iblock_emulate_read_cap,
 	.emulate_read_cap16	= iblock_emulate_read_cap16,
 	.emulate_unmap		= iblock_emulate_unmap,
+	.emulate_write_same	= iblock_emulate_write_same_unmap,
 };
 
 int __init iblock_module_init(void)
drivers/target/target_core_transport.c +37 -30

120 lines not on this page · raw message

include/target/target_core_base.h +1 -3
index f13193a..eb546f4 100644
@@ -138,8 +138,7 @@ enum se_cmd_flags_table {
 	SCF_EMULATE_SYNC_CACHE		= 0x01000000,
 	SCF_EMULATE_CDB_ASYNC		= 0x02000000,
 	SCF_EMULATE_SYNC_UNMAP		= 0x04000000,
-	SCF_ECDB_ALLOCATION		= 0x08000000,
-	SCF_EMULATE_SYNC_WRITE_SAME	= 0x10000000
+	SCF_ECDB_ALLOCATION		= 0x08000000
 };
 	
 /* struct se_device->type for known subsystem plugins */
@@ -432,7 +431,6 @@ struct se_transport_task {
 	int			t_tasks_failed;
 	int			t_tasks_fua;
 	int			t_tasks_bidi:1;
-	int			t_tasks_unmap:1;
 	u32			t_task_cdbs;
 	u32			t_tasks_check;
 	u32			t_tasks_no;
include/target/target_core_transport.h +1 -0
index 0374876..31e726f 100644
@@ -323,6 +323,7 @@ struct se_subsystem_api_cdb {
 	int (*emulate_read_cap)(struct se_task *);
 	int (*emulate_read_cap16)(struct se_task *);
 	int (*emulate_unmap)(struct se_task *);
+	int (*emulate_write_same)(struct se_task *);
 };
 
 /*
Signature · 1 line
1.5.6.5