diff options
author | Christoph Hellwig <hch@infradead.org> | 2011-10-12 11:09:11 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-10-23 23:21:11 -0400 |
commit | 6193f06e6fe27c9475e407cb3cf2b0d4cd2725b0 (patch) | |
tree | a876548f54088886ca0bbc084bb5c560175b5094 /drivers/target | |
parent | 3189b067eeae4646f3c7fa0ed0d14659a682baa8 (diff) |
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')
-rw-r--r-- | drivers/target/target_core_file.c | 12 | ||||
-rw-r--r-- | drivers/target/target_core_file.h | 4 | ||||
-rw-r--r-- | drivers/target/target_core_iblock.c | 6 | ||||
-rw-r--r-- | drivers/target/target_core_iblock.h | 1 | ||||
-rw-r--r-- | drivers/target/target_core_rd.c | 12 | ||||
-rw-r--r-- | drivers/target/target_core_rd.h | 2 | ||||
-rw-r--r-- | drivers/target/target_core_transport.c | 26 |
7 files changed, 15 insertions, 48 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 524f41afea48..98aa5836448b 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -609,17 +609,6 @@ static ssize_t fd_show_configfs_dev_params( | |||
609 | return bl; | 609 | return bl; |
610 | } | 610 | } |
611 | 611 | ||
612 | /* fd_get_cdb(): (Part of se_subsystem_api_t template) | ||
613 | * | ||
614 | * | ||
615 | */ | ||
616 | static unsigned char *fd_get_cdb(struct se_task *task) | ||
617 | { | ||
618 | struct fd_request *req = FILE_REQ(task); | ||
619 | |||
620 | return req->fd_scsi_cdb; | ||
621 | } | ||
622 | |||
623 | /* fd_get_device_rev(): (Part of se_subsystem_api_t template) | 612 | /* fd_get_device_rev(): (Part of se_subsystem_api_t template) |
624 | * | 613 | * |
625 | * | 614 | * |
@@ -667,7 +656,6 @@ static struct se_subsystem_api fileio_template = { | |||
667 | .check_configfs_dev_params = fd_check_configfs_dev_params, | 656 | .check_configfs_dev_params = fd_check_configfs_dev_params, |
668 | .set_configfs_dev_params = fd_set_configfs_dev_params, | 657 | .set_configfs_dev_params = fd_set_configfs_dev_params, |
669 | .show_configfs_dev_params = fd_show_configfs_dev_params, | 658 | .show_configfs_dev_params = fd_show_configfs_dev_params, |
670 | .get_cdb = fd_get_cdb, | ||
671 | .get_device_rev = fd_get_device_rev, | 659 | .get_device_rev = fd_get_device_rev, |
672 | .get_device_type = fd_get_device_type, | 660 | .get_device_type = fd_get_device_type, |
673 | .get_blocks = fd_get_blocks, | 661 | .get_blocks = fd_get_blocks, |
diff --git a/drivers/target/target_core_file.h b/drivers/target/target_core_file.h index daebd710b893..59e6e73106c2 100644 --- a/drivers/target/target_core_file.h +++ b/drivers/target/target_core_file.h | |||
@@ -14,9 +14,7 @@ | |||
14 | 14 | ||
15 | struct fd_request { | 15 | struct fd_request { |
16 | struct se_task fd_task; | 16 | struct se_task fd_task; |
17 | /* SCSI CDB from iSCSI Command PDU */ | 17 | }; |
18 | unsigned char fd_scsi_cdb[TCM_MAX_COMMAND_SIZE]; | ||
19 | } ____cacheline_aligned; | ||
20 | 18 | ||
21 | #define FBDF_HAS_PATH 0x01 | 19 | #define FBDF_HAS_PATH 0x01 |
22 | #define FBDF_HAS_SIZE 0x02 | 20 | #define FBDF_HAS_SIZE 0x02 |
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 21a3677984fb..bf074c4b7a36 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c | |||
@@ -618,11 +618,6 @@ fail: | |||
618 | return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES; | 618 | return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES; |
619 | } | 619 | } |
620 | 620 | ||
621 | static unsigned char *iblock_get_cdb(struct se_task *task) | ||
622 | { | ||
623 | return IBLOCK_REQ(task)->ib_scsi_cdb; | ||
624 | } | ||
625 | |||
626 | static u32 iblock_get_device_rev(struct se_device *dev) | 621 | static u32 iblock_get_device_rev(struct se_device *dev) |
627 | { | 622 | { |
628 | return SCSI_SPC_2; /* Returns SPC-3 in Initiator Data */ | 623 | return SCSI_SPC_2; /* Returns SPC-3 in Initiator Data */ |
@@ -696,7 +691,6 @@ static struct se_subsystem_api iblock_template = { | |||
696 | .check_configfs_dev_params = iblock_check_configfs_dev_params, | 691 | .check_configfs_dev_params = iblock_check_configfs_dev_params, |
697 | .set_configfs_dev_params = iblock_set_configfs_dev_params, | 692 | .set_configfs_dev_params = iblock_set_configfs_dev_params, |
698 | .show_configfs_dev_params = iblock_show_configfs_dev_params, | 693 | .show_configfs_dev_params = iblock_show_configfs_dev_params, |
699 | .get_cdb = iblock_get_cdb, | ||
700 | .get_device_rev = iblock_get_device_rev, | 694 | .get_device_rev = iblock_get_device_rev, |
701 | .get_device_type = iblock_get_device_type, | 695 | .get_device_type = iblock_get_device_type, |
702 | .get_blocks = iblock_get_blocks, | 696 | .get_blocks = iblock_get_blocks, |
diff --git a/drivers/target/target_core_iblock.h b/drivers/target/target_core_iblock.h index 7a76f663385c..5cf1860c10d0 100644 --- a/drivers/target/target_core_iblock.h +++ b/drivers/target/target_core_iblock.h | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | struct iblock_req { | 9 | struct iblock_req { |
10 | struct se_task ib_task; | 10 | struct se_task ib_task; |
11 | unsigned char ib_scsi_cdb[TCM_MAX_COMMAND_SIZE]; | ||
12 | atomic_t ib_bio_cnt; | 11 | atomic_t ib_bio_cnt; |
13 | atomic_t ib_bio_err_cnt; | 12 | atomic_t ib_bio_err_cnt; |
14 | } ____cacheline_aligned; | 13 | } ____cacheline_aligned; |
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index daf95dbe12ec..5158d3846f19 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c | |||
@@ -691,17 +691,6 @@ static ssize_t rd_show_configfs_dev_params( | |||
691 | return bl; | 691 | return bl; |
692 | } | 692 | } |
693 | 693 | ||
694 | /* rd_get_cdb(): (Part of se_subsystem_api_t template) | ||
695 | * | ||
696 | * | ||
697 | */ | ||
698 | static unsigned char *rd_get_cdb(struct se_task *task) | ||
699 | { | ||
700 | struct rd_request *req = RD_REQ(task); | ||
701 | |||
702 | return req->rd_scsi_cdb; | ||
703 | } | ||
704 | |||
705 | static u32 rd_get_device_rev(struct se_device *dev) | 694 | static u32 rd_get_device_rev(struct se_device *dev) |
706 | { | 695 | { |
707 | return SCSI_SPC_2; /* Returns SPC-3 in Initiator Data */ | 696 | return SCSI_SPC_2; /* Returns SPC-3 in Initiator Data */ |
@@ -735,7 +724,6 @@ static struct se_subsystem_api rd_mcp_template = { | |||
735 | .check_configfs_dev_params = rd_check_configfs_dev_params, | 724 | .check_configfs_dev_params = rd_check_configfs_dev_params, |
736 | .set_configfs_dev_params = rd_set_configfs_dev_params, | 725 | .set_configfs_dev_params = rd_set_configfs_dev_params, |
737 | .show_configfs_dev_params = rd_show_configfs_dev_params, | 726 | .show_configfs_dev_params = rd_show_configfs_dev_params, |
738 | .get_cdb = rd_get_cdb, | ||
739 | .get_device_rev = rd_get_device_rev, | 727 | .get_device_rev = rd_get_device_rev, |
740 | .get_device_type = rd_get_device_type, | 728 | .get_device_type = rd_get_device_type, |
741 | .get_blocks = rd_get_blocks, | 729 | .get_blocks = rd_get_blocks, |
diff --git a/drivers/target/target_core_rd.h b/drivers/target/target_core_rd.h index 0d027732cd00..784e56a04100 100644 --- a/drivers/target/target_core_rd.h +++ b/drivers/target/target_core_rd.h | |||
@@ -22,8 +22,6 @@ void rd_module_exit(void); | |||
22 | struct rd_request { | 22 | struct rd_request { |
23 | struct se_task rd_task; | 23 | struct se_task rd_task; |
24 | 24 | ||
25 | /* SCSI CDB from iSCSI Command PDU */ | ||
26 | unsigned char rd_scsi_cdb[TCM_MAX_COMMAND_SIZE]; | ||
27 | /* Offset from start of page */ | 25 | /* Offset from start of page */ |
28 | u32 rd_offset; | 26 | u32 rd_offset; |
29 | /* Starting page in Ramdisk for request */ | 27 | /* Starting page in Ramdisk for request */ |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 4a787a0ab068..895969650a27 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( | |||
3932 | struct scatterlist *sgl, | 3932 | struct scatterlist *sgl, |
3933 | unsigned int sgl_nents) | 3933 | unsigned int sgl_nents) |
3934 | { | 3934 | { |
3935 | unsigned char *cdb = NULL; | ||
3936 | struct se_task *task; | 3935 | struct se_task *task; |
3937 | struct se_device *dev = cmd->se_dev; | 3936 | struct se_device *dev = cmd->se_dev; |
3938 | unsigned long flags; | 3937 | unsigned long flags; |
@@ -3959,14 +3958,17 @@ static int transport_allocate_data_tasks( | |||
3959 | task->task_sectors = min(sectors, dev_max_sectors); | 3958 | task->task_sectors = min(sectors, dev_max_sectors); |
3960 | task->task_size = task->task_sectors * sector_size; | 3959 | task->task_size = task->task_sectors * sector_size; |
3961 | 3960 | ||
3962 | cdb = dev->transport->get_cdb(task); | 3961 | if (dev->transport->get_cdb) { |
3963 | BUG_ON(!cdb); | 3962 | unsigned char *cdb = dev->transport->get_cdb(task); |
3964 | 3963 | ||
3965 | memcpy(cdb, cmd->t_task_cdb, | 3964 | memcpy(cdb, cmd->t_task_cdb, |
3966 | scsi_command_size(cmd->t_task_cdb)); | 3965 | scsi_command_size(cmd->t_task_cdb)); |
3966 | |||
3967 | /* Update new cdb with updated lba/sectors */ | ||
3968 | cmd->transport_split_cdb(task->task_lba, | ||
3969 | task->task_sectors, cdb); | ||
3970 | } | ||
3967 | 3971 | ||
3968 | /* Update new cdb with updated lba/sectors */ | ||
3969 | cmd->transport_split_cdb(task->task_lba, task->task_sectors, cdb); | ||
3970 | /* | 3972 | /* |
3971 | * This now assumes that passed sg_ents are in PAGE_SIZE chunks | 3973 | * This now assumes that passed sg_ents are in PAGE_SIZE chunks |
3972 | * in order to calculate the number per task SGL entries | 3974 | * in order to calculate the number per task SGL entries |
@@ -4021,7 +4023,6 @@ static int | |||
4021 | transport_allocate_control_task(struct se_cmd *cmd) | 4023 | transport_allocate_control_task(struct se_cmd *cmd) |
4022 | { | 4024 | { |
4023 | struct se_device *dev = cmd->se_dev; | 4025 | struct se_device *dev = cmd->se_dev; |
4024 | unsigned char *cdb; | ||
4025 | struct se_task *task; | 4026 | struct se_task *task; |
4026 | unsigned long flags; | 4027 | unsigned long flags; |
4027 | 4028 | ||
@@ -4029,10 +4030,11 @@ transport_allocate_control_task(struct se_cmd *cmd) | |||
4029 | if (!task) | 4030 | if (!task) |
4030 | return -ENOMEM; | 4031 | return -ENOMEM; |
4031 | 4032 | ||
4032 | cdb = dev->transport->get_cdb(task); | 4033 | if (dev->transport->get_cdb) { |
4033 | BUG_ON(!cdb); | 4034 | unsigned char *cdb = dev->transport->get_cdb(task); |
4034 | memcpy(cdb, cmd->t_task_cdb, | 4035 | |
4035 | scsi_command_size(cmd->t_task_cdb)); | 4036 | memcpy(cdb, cmd->t_task_cdb, scsi_command_size(cmd->t_task_cdb)); |
4037 | } | ||
4036 | 4038 | ||
4037 | task->task_sg = kmalloc(sizeof(struct scatterlist) * cmd->t_data_nents, | 4039 | task->task_sg = kmalloc(sizeof(struct scatterlist) * cmd->t_data_nents, |
4038 | GFP_KERNEL); | 4040 | GFP_KERNEL); |