target: ->map_task_SG conversion to ->map_control_SG and ->map_data_SG
Subsystems (2)
PATCH 1/1 target: ->map_task_SG conversion to ->map_control_SG and ->map_data_SG
From: Nicholas Bellinger <[email protected]>
This patch breaks up the ->map_task_SG() backend call into two seperate ->map_control_SG() and ->map_data_SG() in order to better address IBLOCK and pSCSI. IBLOCK only allocates bios for ->map_data_SG(), and pSCSI will allocate a struct request for both cases.
This also drops following patch to target/iblock:
commit 338cdba84c710377aa94e60f33610cb293dd2e62
Author: Nicholas Bellinger <[email protected]> Date: Sat Jul 16 22:48:16 2011 -0700
target/iblock: Make iblock_map_task_SG only for SCF_SCSI_DATA_SG_IO_CDB
--- drivers/target/target_core_iblock.c | 9 ++------- drivers/target/target_core_pscsi.c | 14 +++++++++----- drivers/target/target_core_transport.c | 8 ++++---- 3 files changed, 15 insertions(+), 16 deletions(-)
drivers/target/target_core_iblock.c +2 -7
@@ -591,7 +591,7 @@ static struct bio *iblock_get_bio(return bio; } -static int iblock_map_task_SG (struct se_task *task) +static int iblock_map_data_SG (struct se_task *task) {struct se_cmd *cmd = task->task_se_cmd;struct se_device *dev = cmd->se_dev;
@@ -603,11 +603,6 @@ static int iblock_map_task_SG(struct se_task *task)u32 i, sg_num = task->task_sg_nents;sector_t block_lba;/* -* Only setup bios for SCF_SCSI_DATA_SG_IO_CDB type payloads -*/ -if (!(cmd->se_cmd_flags &SCF_SCSI_DATA_SG_IO_CDB )) -return 0 ; -/* * Do starting conversion up from non 512-byte blocksize with * struct se_task SCSI blocksize into Linux/Block 512 units for BIO. */
@@ -760,7 +755,7 @@ static struct se_subsystem_api iblock_template = { .name = "iblock", .owner = THIS_MODULE, .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, - .map_task_SG = iblock_map_task_SG, + .map_data_SG = iblock_map_data_SG, .attach_hba = iblock_attach_hba, .detach_hba = iblock_detach_hba, .allocate_virtdevice = iblock_allocate_virtdevice,
drivers/target/target_core_pscsi.c +9 -5
@@ -1049,7 +1049,7 @@ static inline struct bio *pscsi_get_bio(int sg_num)return bio; } -static int __pscsi_map_task_SG( +static int __pscsi_map_SG( struct se_task *task, struct scatterlist *task_sg, u32 task_sg_num,
@@ -1198,7 +1198,10 @@ fail:return ret; } -static int pscsi_map_task_SG (struct se_task *task) +/* +* pSCSI maps both ->map_control_SG() and ->map_data_SG() to a single call. +*/ +static int pscsi_map_SG (struct se_task *task) {int ret;
@@ -1206,13 +1209,13 @@ static int pscsi_map_task_SG(struct se_task *task)* Setup the main struct request for the task->task_sg[] payload */ - ret =__pscsi_map_task_SG (task, task->task_sg, task->task_sg_nents,0 ); + ret =__pscsi_map_SG (task, task->task_sg, task->task_sg_nents,0 );if (ret >=0 && task->task_sg_bidi) {/* * If present, set up the extra BIDI-COMMAND SCSI READ * struct request and payload. */ - ret =__pscsi_map_task_SG (task, task->task_sg_bidi, + ret =__pscsi_map_SG (task, task->task_sg_bidi, task->task_sg_nents,1 ); }
@@ -1340,7 +1343,8 @@ static struct se_subsystem_api pscsi_template = { .owner = THIS_MODULE, .transport_type = TRANSPORT_PLUGIN_PHBA_PDEV, .cdb_none = pscsi_CDB_none, - .map_task_SG = pscsi_map_task_SG, + .map_control_SG = pscsi_map_SG, + .map_data_SG = pscsi_map_SG, .attach_hba = pscsi_attach_hba, .detach_hba = pscsi_detach_hba, .pmode_enable_hba = pscsi_pmode_enable_hba,
drivers/target/target_core_transport.c +4 -4
@@ -4137,10 +4137,10 @@ static int transport_allocate_data_tasks(list_for_each_entry (task, &cmd->t_task_list, t_list) {if (atomic_read (&task->task_sent))continue ; -if (!dev->transport->map_task_SG) +if (!dev->transport->map_data_SG)continue ; - ret = dev->transport->map_task_SG (task); + ret = dev->transport->map_data_SG (task);if (ret <0 )return 0 ; }
@@ -4183,8 +4183,8 @@ transport_allocate_control_task(struct se_cmd *cmd)spin_unlock_irqrestore (&cmd->t_state_lock, flags);if (cmd->se_cmd_flags &SCF_SCSI_CONTROL_SG_IO_CDB ) { -if (dev->transport->map_task_SG) - ret = dev->transport->map_task_SG (task); +if (dev->transport->map_control_SG) + ret = dev->transport->map_control_SG (task); }else if (cmd->se_cmd_flags &SCF_SCSI_NON_DATA_CDB ) {if (dev->transport->cdb_none) ret = dev->transport->cdb_none (task);
Signature · 1 line
1.7.2.5
Quoted 6 lines · Nicholas A. Bellinger
From: Nicholas Bellinger <[email protected]>
This patch breaks up the ->map_task_SG() backend call into two seperate ->map_control_SG() and ->map_data_SG() in order to better address IBLOCK and pSCSI. IBLOCK only allocates bios for ->map_data_SG(), and pSCSI will allocate a struct request for both cases.
In my opnion we should just copy the ->do_task logical, .e.g
if ((TRANSPORT(dev)->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV) && (!(TASK_CMD(task)->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB))) error = transport_emulate_control_cdb(task); else error = TRANSPORT(dev)->do_task(task);
that is: don't even bother to call the backed unless we have to.
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Nicholas A. Bellinger
From: Nicholas Bellinger <[email protected]>
This patch breaks up the ->map_task_SG() backend call into two seperate ->map_control_SG() and ->map_data_SG() in order to better address IBLOCK and pSCSI. IBLOCK only allocates bios for ->map_data_SG(), and pSCSI will allocate a struct request for both cases.
In my opnion we should just copy the ->do_task logical, .e.g
Quoted 8 lines
if ((TRANSPORT(dev)->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV) && (!(TASK_CMD(task)->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB))) error = transport_emulate_control_cdb(task); else error = TRANSPORT(dev)->do_task(task);that is: don't even bother to call the backed unless we have to.
I thought about this, but think it's slightly cleaner to have ->map_control_SG() and ->map_data_SG() backend callers now that we have transport_allocate_control_task() and transport_allocate_data_tasks().
I'd like to avoid the TRANSPORT_PLUGIN_PHBA_PDEV usage, as that already looks kinda ugly.. ;)