Skip to contentSkip to conversation

tcm: Move SYNCHRONIZE_CACHE_* 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 4/4 tcm: Move SYNCHRONIZE_CACHE_* emulation into transport_emulate_control_cdb()

From: Nicholas Bellinger <[email protected]>

This patch updates TCM Core to perform SYNCHRONIZE_CACHE and SYNCHRONIZE_CACHE_16 emulation using the unified control CDB infrastructure. This includes adding a new struct se_subsystem_api_cdb->emulate_sync_cache() caller used in transport_emulate_control_cdb(), and removing the original struct se_subsystem_api ->do_sync_cache_range() and transport_generic_synchronize_cache() code.

This patch also updates IBLOCK and FILEIO to set ->emulate_sync_cache() and hooks up the existing SYNCHRONIZE_CACHE_* logic to the new caller.

---
 drivers/target/target_core_file.c      |   15 ++++++----
 drivers/target/target_core_iblock.c    |   12 +++++---
 drivers/target/target_core_transport.c |   45 ++++++++-----------------------
 include/target/target_core_transport.h |    8 +-----
 4 files changed, 29 insertions(+), 51 deletions(-)
drivers/target/target_core_file.c +9 -6
index 55e9ad5..62b4b4e 100644
@@ -724,12 +724,15 @@ int __fd_do_sync_cache_range(
 	return 0;
 }
 
-void fd_do_sync_cache_range(
-	struct se_cmd *cmd,
-	unsigned long long lba,
-	u32 size_in_bytes)
+/*
+ * Called by target_core_transport():transport_emulate_control_cdb()
+ * to emulate SYCHRONIZE_CACHE_*
+ */
+void fd_emulate_sync_cache(struct se_task *task)
 {
-	__fd_do_sync_cache_range(cmd, lba, size_in_bytes);	
+	struct se_cmd *cmd = TASK_CMD(task);
+
+	__fd_do_sync_cache_range(cmd, T_TASK(cmd)->t_task_lba, cmd->data_length);
 }
 
 /*
@@ -1182,7 +1185,6 @@ static struct se_subsystem_api fileio_template = {
 	.activate_device	= fd_activate_device,
 	.deactivate_device	= fd_deactivate_device,
 	.free_device		= fd_free_device,
-	.do_sync_cache_range	= fd_do_sync_cache_range,
 	.dpo_emulated		= fd_emulated_dpo,
 	.fua_write_emulated	= fd_emulated_fua_write,
 	.fua_read_emulated	= fd_emulated_fua_read,
@@ -1217,6 +1219,7 @@ static struct se_subsystem_api_cdb fileio_cdb_template = {
 	.emulate_read_cap16	= fd_emulate_read_cap16,
 	.emulate_unmap		= fd_emulate_unmap,
 	.emulate_write_same	= fd_emulate_write_same_unmap,
+	.emulate_sync_cache	= fd_emulate_sync_cache,
 };
 
 int __init fileio_module_init(void)
drivers/target/target_core_iblock.c +7 -5
index a0a9ea3..061c513 100644
@@ -508,11 +508,13 @@ static int __iblock_do_sync_cache(struct se_device *dev)
 	return 0;
 }
 
-void iblock_do_sync_cache_range(
-	struct se_cmd *cmd,
-	unsigned long long lba,
-	u32 size_in_bytes)
+/*
+ * Called by target_core_transport():transport_emulate_control_cdb()
+ * to emulate SYCHRONIZE_CACHE_*
+ */
+void iblock_emulate_sync_cache(struct se_task *task)
 {
+	struct se_cmd *cmd = TASK_CMD(task);
 	int ret, immed = (T_TASK(cmd)->t_task_cdb[1] & 0x2);
 	/*
 	 * If the Immediate bit is set, queue up the GOOD response
@@ -1102,7 +1104,6 @@ static struct se_subsystem_api iblock_template = {
 	.activate_device	= iblock_activate_device,
 	.deactivate_device	= iblock_deactivate_device,
 	.free_device		= iblock_free_device,
-	.do_sync_cache_range	= iblock_do_sync_cache_range,
 	.dpo_emulated		= iblock_emulated_dpo,
 	.fua_write_emulated	= iblock_emulated_fua_write,
 	.fua_read_emulated	= iblock_emulated_fua_read,
@@ -1138,6 +1139,7 @@ static struct se_subsystem_api_cdb iblock_cdb_template = {
 	.emulate_read_cap16	= iblock_emulate_read_cap16,
 	.emulate_unmap		= iblock_emulate_unmap,
 	.emulate_write_same	= iblock_emulate_write_same_unmap,
+	.emulate_sync_cache	= iblock_emulate_sync_cache,
 };
 
 int __init iblock_module_init(void)
drivers/target/target_core_transport.c +12 -33

77 lines not on this page · raw message

include/target/target_core_transport.h +1 -7
index 31e726f..8e59144 100644
@@ -324,6 +324,7 @@ struct se_subsystem_api_cdb {
 	int (*emulate_read_cap16)(struct se_task *);
 	int (*emulate_unmap)(struct se_task *);
 	int (*emulate_write_same)(struct se_task *);
+	void (*emulate_sync_cache)(struct se_task *);
 };
 
 /*
@@ -434,13 +435,6 @@ struct se_subsystem_api {
 	 */
 	int (*do_tmr)(struct se_cmd *cmd);
 	/*
-	 * do_sync_cache_range():
-	 *
-	 * Notify subsystem backstore when a SYNCHRONIZE_CACHE w/ explict
-	 * LBA + Range has been received with WriteCache=1
-	 */
-	void (*do_sync_cache_range)(struct se_cmd *, unsigned long long, u32);
-	/*
 	 * dpo_emulated():
 	 */
 	int (*dpo_emulated)(struct se_device *);
Signature · 1 line
1.5.6.5