target: make the ->get_cdb method optional
authorChristoph Hellwig <hch@infradead.org>
Wed, 12 Oct 2011 15:09:11 +0000 (11:09 -0400)
committerNicholas Bellinger <nab@linux-iscsi.org>
Mon, 24 Oct 2011 03:21:11 +0000 (03:21 +0000)
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>
drivers/target/target_core_file.c
drivers/target/target_core_file.h
drivers/target/target_core_iblock.c
drivers/target/target_core_iblock.h
drivers/target/target_core_rd.c
drivers/target/target_core_rd.h
drivers/target/target_core_transport.c

index 524f41afea48185e0b176247f4879212c52d0628..98aa5836448bfd5439d0caef00c6fef19633d744 100644 (file)
@@ -609,17 +609,6 @@ static ssize_t fd_show_configfs_dev_params(
        return bl;
 }
 
-/*     fd_get_cdb(): (Part of se_subsystem_api_t template)
- *
- *
- */
-static unsigned char *fd_get_cdb(struct se_task *task)
-{
-       struct fd_request *req = FILE_REQ(task);
-
-       return req->fd_scsi_cdb;
-}
-
 /*     fd_get_device_rev(): (Part of se_subsystem_api_t template)
  *
  *
@@ -667,7 +656,6 @@ static struct se_subsystem_api fileio_template = {
        .check_configfs_dev_params = fd_check_configfs_dev_params,
        .set_configfs_dev_params = fd_set_configfs_dev_params,
        .show_configfs_dev_params = fd_show_configfs_dev_params,
-       .get_cdb                = fd_get_cdb,
        .get_device_rev         = fd_get_device_rev,
        .get_device_type        = fd_get_device_type,
        .get_blocks             = fd_get_blocks,
index daebd710b8939bcfc744f35d3a6c25ad872bbd35..59e6e73106c2e638d3785df676836c70c4b9a6b6 100644 (file)
@@ -14,9 +14,7 @@
 
 struct fd_request {
        struct se_task  fd_task;
-       /* SCSI CDB from iSCSI Command PDU */
-       unsigned char   fd_scsi_cdb[TCM_MAX_COMMAND_SIZE];
-} ____cacheline_aligned;
+};
 
 #define FBDF_HAS_PATH          0x01
 #define FBDF_HAS_SIZE          0x02
index 21a3677984fbea149ca9108562d9b5891ce9d89b..bf074c4b7a368374bcd7e71a2f84f82877e70f66 100644 (file)
@@ -618,11 +618,6 @@ fail:
        return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES;
 }
 
-static unsigned char *iblock_get_cdb(struct se_task *task)
-{
-       return IBLOCK_REQ(task)->ib_scsi_cdb;
-}
-
 static u32 iblock_get_device_rev(struct se_device *dev)
 {
        return SCSI_SPC_2; /* Returns SPC-3 in Initiator Data */
@@ -696,7 +691,6 @@ static struct se_subsystem_api iblock_template = {
        .check_configfs_dev_params = iblock_check_configfs_dev_params,
        .set_configfs_dev_params = iblock_set_configfs_dev_params,
        .show_configfs_dev_params = iblock_show_configfs_dev_params,
-       .get_cdb                = iblock_get_cdb,
        .get_device_rev         = iblock_get_device_rev,
        .get_device_type        = iblock_get_device_type,
        .get_blocks             = iblock_get_blocks,
index 7a76f663385c0af5a03538e68fcd88a9e90717d9..5cf1860c10d037b92a7a5b0a7c3933273e287856 100644 (file)
@@ -8,7 +8,6 @@
 
 struct iblock_req {
        struct se_task ib_task;
-       unsigned char ib_scsi_cdb[TCM_MAX_COMMAND_SIZE];
        atomic_t ib_bio_cnt;
        atomic_t ib_bio_err_cnt;
 } ____cacheline_aligned;
index daf95dbe12ec912298a89d3daaeba108e9a194d9..5158d3846f19cf8f79f69e7efe97f72558b0d413 100644 (file)
@@ -691,17 +691,6 @@ static ssize_t rd_show_configfs_dev_params(
        return bl;
 }
 
-/*     rd_get_cdb(): (Part of se_subsystem_api_t template)
- *
- *
- */
-static unsigned char *rd_get_cdb(struct se_task *task)
-{
-       struct rd_request *req = RD_REQ(task);
-
-       return req->rd_scsi_cdb;
-}
-
 static u32 rd_get_device_rev(struct se_device *dev)
 {
        return SCSI_SPC_2; /* Returns SPC-3 in Initiator Data */
@@ -735,7 +724,6 @@ static struct se_subsystem_api rd_mcp_template = {
        .check_configfs_dev_params = rd_check_configfs_dev_params,
        .set_configfs_dev_params = rd_set_configfs_dev_params,
        .show_configfs_dev_params = rd_show_configfs_dev_params,
-       .get_cdb                = rd_get_cdb,
        .get_device_rev         = rd_get_device_rev,
        .get_device_type        = rd_get_device_type,
        .get_blocks             = rd_get_blocks,
index 0d027732cd00215836bb4529d3726382c2baff48..784e56a041001008bdec29f2afd47f11b1d9d31f 100644 (file)
@@ -22,8 +22,6 @@ void rd_module_exit(void);
 struct rd_request {
        struct se_task  rd_task;
 
-       /* SCSI CDB from iSCSI Command PDU */
-       unsigned char   rd_scsi_cdb[TCM_MAX_COMMAND_SIZE];
        /* Offset from start of page */
        u32             rd_offset;
        /* Starting page in Ramdisk for request */
index 4a787a0ab068b64fb4bb92242cdbc7547cb0baa5..895969650a27767bcef1e91c4c9a34866e527922 100644 (file)
@@ -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);