aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2011-07-21 00:41:48 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-07-22 05:37:48 -0400
commit1d20bb6147954d4fbd337a3d1b40c7eeae254cd7 (patch)
tree23dcdd9376c5e26acfd2817812e2d5ccfbf81149 /drivers/target
parent6708bb27bb2703da238f21f516034263348af5be (diff)
target: ->map_task_SG conversion to ->map_control_SG and ->map_data_SG
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 patch fixes incorrect usage of ->map_task_SG() for all se_cmd descriptors in transport_generic_new_cmd() by moving the call into it's proper location directly inside of transport_allocate_data_tasks() Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_iblock.c4
-rw-r--r--drivers/target/target_core_pscsi.c14
-rw-r--r--drivers/target/target_core_transport.c45
3 files changed, 36 insertions, 27 deletions
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 251fc66a8212..7e1234105442 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -591,7 +591,7 @@ static struct bio *iblock_get_bio(
591 return bio; 591 return bio;
592} 592}
593 593
594static int iblock_map_task_SG(struct se_task *task) 594static int iblock_map_data_SG(struct se_task *task)
595{ 595{
596 struct se_cmd *cmd = task->task_se_cmd; 596 struct se_cmd *cmd = task->task_se_cmd;
597 struct se_device *dev = cmd->se_dev; 597 struct se_device *dev = cmd->se_dev;
@@ -755,7 +755,7 @@ static struct se_subsystem_api iblock_template = {
755 .name = "iblock", 755 .name = "iblock",
756 .owner = THIS_MODULE, 756 .owner = THIS_MODULE,
757 .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, 757 .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV,
758 .map_task_SG = iblock_map_task_SG, 758 .map_data_SG = iblock_map_data_SG,
759 .attach_hba = iblock_attach_hba, 759 .attach_hba = iblock_attach_hba,
760 .detach_hba = iblock_detach_hba, 760 .detach_hba = iblock_detach_hba,
761 .allocate_virtdevice = iblock_allocate_virtdevice, 761 .allocate_virtdevice = iblock_allocate_virtdevice,
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index a2ce5998d318..2b7b0da9146d 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -1049,7 +1049,7 @@ static inline struct bio *pscsi_get_bio(int sg_num)
1049 return bio; 1049 return bio;
1050} 1050}
1051 1051
1052static int __pscsi_map_task_SG( 1052static int __pscsi_map_SG(
1053 struct se_task *task, 1053 struct se_task *task,
1054 struct scatterlist *task_sg, 1054 struct scatterlist *task_sg,
1055 u32 task_sg_num, 1055 u32 task_sg_num,
@@ -1198,7 +1198,10 @@ fail:
1198 return ret; 1198 return ret;
1199} 1199}
1200 1200
1201static int pscsi_map_task_SG(struct se_task *task) 1201/*
1202 * pSCSI maps both ->map_control_SG() and ->map_data_SG() to a single call.
1203 */
1204static int pscsi_map_SG(struct se_task *task)
1202{ 1205{
1203 int ret; 1206 int ret;
1204 1207
@@ -1206,13 +1209,13 @@ static int pscsi_map_task_SG(struct se_task *task)
1206 * Setup the main struct request for the task->task_sg[] payload 1209 * Setup the main struct request for the task->task_sg[] payload
1207 */ 1210 */
1208 1211
1209 ret = __pscsi_map_task_SG(task, task->task_sg, task->task_sg_nents, 0); 1212 ret = __pscsi_map_SG(task, task->task_sg, task->task_sg_nents, 0);
1210 if (ret >= 0 && task->task_sg_bidi) { 1213 if (ret >= 0 && task->task_sg_bidi) {
1211 /* 1214 /*
1212 * If present, set up the extra BIDI-COMMAND SCSI READ 1215 * If present, set up the extra BIDI-COMMAND SCSI READ
1213 * struct request and payload. 1216 * struct request and payload.
1214 */ 1217 */
1215 ret = __pscsi_map_task_SG(task, task->task_sg_bidi, 1218 ret = __pscsi_map_SG(task, task->task_sg_bidi,
1216 task->task_sg_nents, 1); 1219 task->task_sg_nents, 1);
1217 } 1220 }
1218 1221
@@ -1340,7 +1343,8 @@ static struct se_subsystem_api pscsi_template = {
1340 .owner = THIS_MODULE, 1343 .owner = THIS_MODULE,
1341 .transport_type = TRANSPORT_PLUGIN_PHBA_PDEV, 1344 .transport_type = TRANSPORT_PLUGIN_PHBA_PDEV,
1342 .cdb_none = pscsi_CDB_none, 1345 .cdb_none = pscsi_CDB_none,
1343 .map_task_SG = pscsi_map_task_SG, 1346 .map_control_SG = pscsi_map_SG,
1347 .map_data_SG = pscsi_map_SG,
1344 .attach_hba = pscsi_attach_hba, 1348 .attach_hba = pscsi_attach_hba,
1345 .detach_hba = pscsi_detach_hba, 1349 .detach_hba = pscsi_detach_hba,
1346 .pmode_enable_hba = pscsi_pmode_enable_hba, 1350 .pmode_enable_hba = pscsi_pmode_enable_hba,
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 55b6588904a4..007cfc164f5e 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -4081,8 +4081,7 @@ static int transport_allocate_data_tasks(
4081 struct se_device *dev = cmd->se_dev; 4081 struct se_device *dev = cmd->se_dev;
4082 unsigned long flags; 4082 unsigned long flags;
4083 sector_t sectors; 4083 sector_t sectors;
4084 int task_count; 4084 int task_count, i, ret;
4085 int i;
4086 sector_t dev_max_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors; 4085 sector_t dev_max_sectors = dev->se_sub_dev->se_dev_attrib.max_sectors;
4087 u32 sector_size = dev->se_sub_dev->se_dev_attrib.block_size; 4086 u32 sector_size = dev->se_sub_dev->se_dev_attrib.block_size;
4088 struct scatterlist *sg; 4087 struct scatterlist *sg;
@@ -4129,7 +4128,7 @@ static int transport_allocate_data_tasks(
4129 task->task_padded_sg = 1; 4128 task->task_padded_sg = 1;
4130 } 4129 }
4131 4130
4132 task->task_sg = kmalloc(sizeof(struct scatterlist) * \ 4131 task->task_sg = kmalloc(sizeof(struct scatterlist) *
4133 task->task_sg_nents, GFP_KERNEL); 4132 task->task_sg_nents, GFP_KERNEL);
4134 if (!task->task_sg) { 4133 if (!task->task_sg) {
4135 cmd->se_dev->transport->free_task(task); 4134 cmd->se_dev->transport->free_task(task);
@@ -4157,6 +4156,20 @@ static int transport_allocate_data_tasks(
4157 list_add_tail(&task->t_list, &cmd->t_task_list); 4156 list_add_tail(&task->t_list, &cmd->t_task_list);
4158 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 4157 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4159 } 4158 }
4159 /*
4160 * Now perform the memory map of task->task_sg[] into backend
4161 * subsystem memory..
4162 */
4163 list_for_each_entry(task, &cmd->t_task_list, t_list) {
4164 if (atomic_read(&task->task_sent))
4165 continue;
4166 if (!dev->transport->map_data_SG)
4167 continue;
4168
4169 ret = dev->transport->map_data_SG(task);
4170 if (ret < 0)
4171 return 0;
4172 }
4160 4173
4161 return task_count; 4174 return task_count;
4162} 4175}
@@ -4196,8 +4209,8 @@ transport_allocate_control_task(struct se_cmd *cmd)
4196 spin_unlock_irqrestore(&cmd->t_state_lock, flags); 4209 spin_unlock_irqrestore(&cmd->t_state_lock, flags);
4197 4210
4198 if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) { 4211 if (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) {
4199 if (dev->transport->map_task_SG) 4212 if (dev->transport->map_control_SG)
4200 ret = dev->transport->map_task_SG(task); 4213 ret = dev->transport->map_control_SG(task);
4201 } else if (cmd->se_cmd_flags & SCF_SCSI_NON_DATA_CDB) { 4214 } else if (cmd->se_cmd_flags & SCF_SCSI_NON_DATA_CDB) {
4202 if (dev->transport->cdb_none) 4215 if (dev->transport->cdb_none)
4203 ret = dev->transport->cdb_none(task); 4216 ret = dev->transport->cdb_none(task);
@@ -4239,8 +4252,6 @@ static u32 transport_allocate_tasks(
4239 */ 4252 */
4240int transport_generic_new_cmd(struct se_cmd *cmd) 4253int transport_generic_new_cmd(struct se_cmd *cmd)
4241{ 4254{
4242 struct se_task *task;
4243 struct se_device *dev = cmd->se_dev;
4244 int ret = 0; 4255 int ret = 0;
4245 4256
4246 /* 4257 /*
@@ -4254,22 +4265,16 @@ int transport_generic_new_cmd(struct se_cmd *cmd)
4254 if (ret < 0) 4265 if (ret < 0)
4255 return ret; 4266 return ret;
4256 } 4267 }
4257 4268 /*
4269 * Call transport_new_cmd_obj() to invoke transport_allocate_tasks() for
4270 * control or data CDB types, and perform the map to backend subsystem
4271 * code from SGL memory allocated here by transport_generic_get_mem(), or
4272 * via pre-existing SGL memory setup explictly by fabric module code with
4273 * transport_generic_map_mem_to_cmd().
4274 */
4258 ret = transport_new_cmd_obj(cmd); 4275 ret = transport_new_cmd_obj(cmd);
4259 if (ret < 0) 4276 if (ret < 0)
4260 return ret; 4277 return ret;
4261
4262 list_for_each_entry(task, &cmd->t_task_list, t_list) {
4263 if (atomic_read(&task->task_sent))
4264 continue;
4265 if (!dev->transport->map_task_SG)
4266 continue;
4267
4268 ret = dev->transport->map_task_SG(task);
4269 if (ret < 0)
4270 return ret;
4271 }
4272
4273 /* 4278 /*
4274 * For WRITEs, let the fabric know its buffer is ready.. 4279 * For WRITEs, let the fabric know its buffer is ready..
4275 * This WRITE struct se_cmd (and all of its associated struct se_task's) 4280 * This WRITE struct se_cmd (and all of its associated struct se_task's)