summaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_transport.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2011-10-12 11:09:11 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-10-24 03:21:11 +0000
commit6193f06e6fe27c9475e407cb3cf2b0d4cd2725b0 (patch)
treea876548f54088886ca0bbc084bb5c560175b5094 /drivers/target/target_core_transport.c
parent3189b067eeae4646f3c7fa0ed0d14659a682baa8 (diff)
downloadop-kernel-dev-6193f06e6fe27c9475e407cb3cf2b0d4cd2725b0.zip
op-kernel-dev-6193f06e6fe27c9475e407cb3cf2b0d4cd2725b0.tar.gz
target: make the ->get_cdb method optional
The most commonly used file, iblock and rd backends have no use for a per-task CDB and thus don't need a method to copy it into their otherwise unused CDB fields. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_transport.c')
-rw-r--r--drivers/target/target_core_transport.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 4a787a0..8959696 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -3932,7 +3932,6 @@ static int transport_allocate_data_tasks(
struct scatterlist *sgl,
unsigned int sgl_nents)
{
- unsigned char *cdb = NULL;
struct se_task *task;
struct se_device *dev = cmd->se_dev;
unsigned long flags;
@@ -3959,14 +3958,17 @@ static int transport_allocate_data_tasks(
task->task_sectors = min(sectors, dev_max_sectors);
task->task_size = task->task_sectors * sector_size;
- cdb = dev->transport->get_cdb(task);
- BUG_ON(!cdb);
+ if (dev->transport->get_cdb) {
+ unsigned char *cdb = dev->transport->get_cdb(task);
- memcpy(cdb, cmd->t_task_cdb,
- scsi_command_size(cmd->t_task_cdb));
+ memcpy(cdb, cmd->t_task_cdb,
+ scsi_command_size(cmd->t_task_cdb));
+
+ /* Update new cdb with updated lba/sectors */
+ cmd->transport_split_cdb(task->task_lba,
+ task->task_sectors, cdb);
+ }
- /* Update new cdb with updated lba/sectors */
- cmd->transport_split_cdb(task->task_lba, task->task_sectors, cdb);
/*
* This now assumes that passed sg_ents are in PAGE_SIZE chunks
* in order to calculate the number per task SGL entries
@@ -4021,7 +4023,6 @@ static int
transport_allocate_control_task(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_dev;
- unsigned char *cdb;
struct se_task *task;
unsigned long flags;
@@ -4029,10 +4030,11 @@ transport_allocate_control_task(struct se_cmd *cmd)
if (!task)
return -ENOMEM;
- cdb = dev->transport->get_cdb(task);
- BUG_ON(!cdb);
- memcpy(cdb, cmd->t_task_cdb,
- scsi_command_size(cmd->t_task_cdb));
+ if (dev->transport->get_cdb) {
+ unsigned char *cdb = dev->transport->get_cdb(task);
+
+ memcpy(cdb, cmd->t_task_cdb, scsi_command_size(cmd->t_task_cdb));
+ }
task->task_sg = kmalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
GFP_KERNEL);
OpenPOWER on IntegriCloud