diff options
Diffstat (limited to 'drivers/target/target_core_pscsi.c')
-rw-r--r-- | drivers/target/target_core_pscsi.c | 81 |
1 files changed, 21 insertions, 60 deletions
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 331d423fd0e0..44a79a5c6d32 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c | |||
@@ -55,24 +55,6 @@ static struct se_subsystem_api pscsi_template; | |||
55 | 55 | ||
56 | static void pscsi_req_done(struct request *, int); | 56 | static void pscsi_req_done(struct request *, int); |
57 | 57 | ||
58 | /* pscsi_get_sh(): | ||
59 | * | ||
60 | * | ||
61 | */ | ||
62 | static struct Scsi_Host *pscsi_get_sh(u32 host_no) | ||
63 | { | ||
64 | struct Scsi_Host *sh = NULL; | ||
65 | |||
66 | sh = scsi_host_lookup(host_no); | ||
67 | if (IS_ERR(sh)) { | ||
68 | printk(KERN_ERR "Unable to locate SCSI HBA with Host ID:" | ||
69 | " %u\n", host_no); | ||
70 | return NULL; | ||
71 | } | ||
72 | |||
73 | return sh; | ||
74 | } | ||
75 | |||
76 | /* pscsi_attach_hba(): | 58 | /* pscsi_attach_hba(): |
77 | * | 59 | * |
78 | * pscsi_get_sh() used scsi_host_lookup() to locate struct Scsi_Host. | 60 | * pscsi_get_sh() used scsi_host_lookup() to locate struct Scsi_Host. |
@@ -80,28 +62,23 @@ static struct Scsi_Host *pscsi_get_sh(u32 host_no) | |||
80 | */ | 62 | */ |
81 | static int pscsi_attach_hba(struct se_hba *hba, u32 host_id) | 63 | static int pscsi_attach_hba(struct se_hba *hba, u32 host_id) |
82 | { | 64 | { |
83 | int hba_depth; | ||
84 | struct pscsi_hba_virt *phv; | 65 | struct pscsi_hba_virt *phv; |
85 | 66 | ||
86 | phv = kzalloc(sizeof(struct pscsi_hba_virt), GFP_KERNEL); | 67 | phv = kzalloc(sizeof(struct pscsi_hba_virt), GFP_KERNEL); |
87 | if (!(phv)) { | 68 | if (!(phv)) { |
88 | printk(KERN_ERR "Unable to allocate struct pscsi_hba_virt\n"); | 69 | printk(KERN_ERR "Unable to allocate struct pscsi_hba_virt\n"); |
89 | return -1; | 70 | return -ENOMEM; |
90 | } | 71 | } |
91 | phv->phv_host_id = host_id; | 72 | phv->phv_host_id = host_id; |
92 | phv->phv_mode = PHV_VIRUTAL_HOST_ID; | 73 | phv->phv_mode = PHV_VIRUTAL_HOST_ID; |
93 | hba_depth = PSCSI_VIRTUAL_HBA_DEPTH; | ||
94 | atomic_set(&hba->left_queue_depth, hba_depth); | ||
95 | atomic_set(&hba->max_queue_depth, hba_depth); | ||
96 | 74 | ||
97 | hba->hba_ptr = (void *)phv; | 75 | hba->hba_ptr = (void *)phv; |
98 | 76 | ||
99 | printk(KERN_INFO "CORE_HBA[%d] - TCM SCSI HBA Driver %s on" | 77 | printk(KERN_INFO "CORE_HBA[%d] - TCM SCSI HBA Driver %s on" |
100 | " Generic Target Core Stack %s\n", hba->hba_id, | 78 | " Generic Target Core Stack %s\n", hba->hba_id, |
101 | PSCSI_VERSION, TARGET_CORE_MOD_VERSION); | 79 | PSCSI_VERSION, TARGET_CORE_MOD_VERSION); |
102 | printk(KERN_INFO "CORE_HBA[%d] - Attached SCSI HBA to Generic" | 80 | printk(KERN_INFO "CORE_HBA[%d] - Attached SCSI HBA to Generic\n", |
103 | " Target Core with TCQ Depth: %d\n", hba->hba_id, | 81 | hba->hba_id); |
104 | atomic_read(&hba->max_queue_depth)); | ||
105 | 82 | ||
106 | return 0; | 83 | return 0; |
107 | } | 84 | } |
@@ -130,7 +107,6 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) | |||
130 | { | 107 | { |
131 | struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr; | 108 | struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr; |
132 | struct Scsi_Host *sh = phv->phv_lld_host; | 109 | struct Scsi_Host *sh = phv->phv_lld_host; |
133 | int hba_depth = PSCSI_VIRTUAL_HBA_DEPTH; | ||
134 | /* | 110 | /* |
135 | * Release the struct Scsi_Host | 111 | * Release the struct Scsi_Host |
136 | */ | 112 | */ |
@@ -140,8 +116,6 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) | |||
140 | 116 | ||
141 | phv->phv_lld_host = NULL; | 117 | phv->phv_lld_host = NULL; |
142 | phv->phv_mode = PHV_VIRUTAL_HOST_ID; | 118 | phv->phv_mode = PHV_VIRUTAL_HOST_ID; |
143 | atomic_set(&hba->left_queue_depth, hba_depth); | ||
144 | atomic_set(&hba->max_queue_depth, hba_depth); | ||
145 | 119 | ||
146 | printk(KERN_INFO "CORE_HBA[%d] - Disabled pSCSI HBA Passthrough" | 120 | printk(KERN_INFO "CORE_HBA[%d] - Disabled pSCSI HBA Passthrough" |
147 | " %s\n", hba->hba_id, (sh->hostt->name) ? | 121 | " %s\n", hba->hba_id, (sh->hostt->name) ? |
@@ -154,22 +128,12 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) | |||
154 | * Otherwise, locate struct Scsi_Host from the original passed | 128 | * Otherwise, locate struct Scsi_Host from the original passed |
155 | * pSCSI Host ID and enable for phba mode | 129 | * pSCSI Host ID and enable for phba mode |
156 | */ | 130 | */ |
157 | sh = pscsi_get_sh(phv->phv_host_id); | 131 | sh = scsi_host_lookup(phv->phv_host_id); |
158 | if (!(sh)) { | 132 | if (IS_ERR(sh)) { |
159 | printk(KERN_ERR "pSCSI: Unable to locate SCSI Host for" | 133 | printk(KERN_ERR "pSCSI: Unable to locate SCSI Host for" |
160 | " phv_host_id: %d\n", phv->phv_host_id); | 134 | " phv_host_id: %d\n", phv->phv_host_id); |
161 | return -1; | 135 | return PTR_ERR(sh); |
162 | } | 136 | } |
163 | /* | ||
164 | * Usually the SCSI LLD will use the hostt->can_queue value to define | ||
165 | * its HBA TCQ depth. Some other drivers (like 2.6 megaraid) don't set | ||
166 | * this at all and set sh->can_queue at runtime. | ||
167 | */ | ||
168 | hba_depth = (sh->hostt->can_queue > sh->can_queue) ? | ||
169 | sh->hostt->can_queue : sh->can_queue; | ||
170 | |||
171 | atomic_set(&hba->left_queue_depth, hba_depth); | ||
172 | atomic_set(&hba->max_queue_depth, hba_depth); | ||
173 | 137 | ||
174 | phv->phv_lld_host = sh; | 138 | phv->phv_lld_host = sh; |
175 | phv->phv_mode = PHV_LLD_SCSI_HOST_NO; | 139 | phv->phv_mode = PHV_LLD_SCSI_HOST_NO; |
@@ -236,7 +200,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn) | |||
236 | 200 | ||
237 | buf = kzalloc(INQUIRY_VPD_SERIAL_LEN, GFP_KERNEL); | 201 | buf = kzalloc(INQUIRY_VPD_SERIAL_LEN, GFP_KERNEL); |
238 | if (!buf) | 202 | if (!buf) |
239 | return -1; | 203 | return -ENOMEM; |
240 | 204 | ||
241 | memset(cdb, 0, MAX_COMMAND_SIZE); | 205 | memset(cdb, 0, MAX_COMMAND_SIZE); |
242 | cdb[0] = INQUIRY; | 206 | cdb[0] = INQUIRY; |
@@ -259,7 +223,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn) | |||
259 | 223 | ||
260 | out_free: | 224 | out_free: |
261 | kfree(buf); | 225 | kfree(buf); |
262 | return -1; | 226 | return -EPERM; |
263 | } | 227 | } |
264 | 228 | ||
265 | static void | 229 | static void |
@@ -601,11 +565,11 @@ static struct se_device *pscsi_create_virtdevice( | |||
601 | hba->hba_flags |= HBA_FLAGS_PSCSI_MODE; | 565 | hba->hba_flags |= HBA_FLAGS_PSCSI_MODE; |
602 | sh = phv->phv_lld_host; | 566 | sh = phv->phv_lld_host; |
603 | } else { | 567 | } else { |
604 | sh = pscsi_get_sh(pdv->pdv_host_id); | 568 | sh = scsi_host_lookup(pdv->pdv_host_id); |
605 | if (!(sh)) { | 569 | if (IS_ERR(sh)) { |
606 | printk(KERN_ERR "pSCSI: Unable to locate" | 570 | printk(KERN_ERR "pSCSI: Unable to locate" |
607 | " pdv_host_id: %d\n", pdv->pdv_host_id); | 571 | " pdv_host_id: %d\n", pdv->pdv_host_id); |
608 | return ERR_PTR(-ENODEV); | 572 | return (struct se_device *) sh; |
609 | } | 573 | } |
610 | } | 574 | } |
611 | } else { | 575 | } else { |
@@ -728,13 +692,12 @@ static int pscsi_transport_complete(struct se_task *task) | |||
728 | */ | 692 | */ |
729 | if (((cdb[0] == MODE_SENSE) || (cdb[0] == MODE_SENSE_10)) && | 693 | if (((cdb[0] == MODE_SENSE) || (cdb[0] == MODE_SENSE_10)) && |
730 | (status_byte(result) << 1) == SAM_STAT_GOOD) { | 694 | (status_byte(result) << 1) == SAM_STAT_GOOD) { |
731 | if (!TASK_CMD(task)->se_deve) | 695 | if (!task->task_se_cmd->se_deve) |
732 | goto after_mode_sense; | 696 | goto after_mode_sense; |
733 | 697 | ||
734 | if (TASK_CMD(task)->se_deve->lun_flags & | 698 | if (task->task_se_cmd->se_deve->lun_flags & |
735 | TRANSPORT_LUNFLAGS_READ_ONLY) { | 699 | TRANSPORT_LUNFLAGS_READ_ONLY) { |
736 | unsigned char *buf = (unsigned char *) | 700 | unsigned char *buf = task->task_se_cmd->t_task->t_task_buf; |
737 | T_TASK(task->task_se_cmd)->t_task_buf; | ||
738 | 701 | ||
739 | if (cdb[0] == MODE_SENSE_10) { | 702 | if (cdb[0] == MODE_SENSE_10) { |
740 | if (!(buf[3] & 0x80)) | 703 | if (!(buf[3] & 0x80)) |
@@ -800,7 +763,7 @@ static struct se_task * | |||
800 | pscsi_alloc_task(struct se_cmd *cmd) | 763 | pscsi_alloc_task(struct se_cmd *cmd) |
801 | { | 764 | { |
802 | struct pscsi_plugin_task *pt; | 765 | struct pscsi_plugin_task *pt; |
803 | unsigned char *cdb = T_TASK(cmd)->t_task_cdb; | 766 | unsigned char *cdb = cmd->t_task->t_task_cdb; |
804 | 767 | ||
805 | pt = kzalloc(sizeof(struct pscsi_plugin_task), GFP_KERNEL); | 768 | pt = kzalloc(sizeof(struct pscsi_plugin_task), GFP_KERNEL); |
806 | if (!pt) { | 769 | if (!pt) { |
@@ -813,7 +776,7 @@ pscsi_alloc_task(struct se_cmd *cmd) | |||
813 | * allocate the extended CDB buffer for per struct se_task context | 776 | * allocate the extended CDB buffer for per struct se_task context |
814 | * pt->pscsi_cdb now. | 777 | * pt->pscsi_cdb now. |
815 | */ | 778 | */ |
816 | if (T_TASK(cmd)->t_task_cdb != T_TASK(cmd)->__t_task_cdb) { | 779 | if (cmd->t_task->t_task_cdb != cmd->t_task->__t_task_cdb) { |
817 | 780 | ||
818 | pt->pscsi_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL); | 781 | pt->pscsi_cdb = kzalloc(scsi_command_size(cdb), GFP_KERNEL); |
819 | if (!(pt->pscsi_cdb)) { | 782 | if (!(pt->pscsi_cdb)) { |
@@ -926,7 +889,7 @@ static void pscsi_free_task(struct se_task *task) | |||
926 | * Release the extended CDB allocation from pscsi_alloc_task() | 889 | * Release the extended CDB allocation from pscsi_alloc_task() |
927 | * if one exists. | 890 | * if one exists. |
928 | */ | 891 | */ |
929 | if (T_TASK(cmd)->t_task_cdb != T_TASK(cmd)->__t_task_cdb) | 892 | if (cmd->t_task->t_task_cdb != cmd->t_task->__t_task_cdb) |
930 | kfree(pt->pscsi_cdb); | 893 | kfree(pt->pscsi_cdb); |
931 | /* | 894 | /* |
932 | * We do not release the bio(s) here associated with this task, as | 895 | * We do not release the bio(s) here associated with this task, as |
@@ -1030,7 +993,7 @@ static ssize_t pscsi_check_configfs_dev_params( | |||
1030 | !(pdv->pdv_flags & PDF_HAS_LUN_ID)) { | 993 | !(pdv->pdv_flags & PDF_HAS_LUN_ID)) { |
1031 | printk(KERN_ERR "Missing scsi_channel_id=, scsi_target_id= and" | 994 | printk(KERN_ERR "Missing scsi_channel_id=, scsi_target_id= and" |
1032 | " scsi_lun_id= parameters\n"); | 995 | " scsi_lun_id= parameters\n"); |
1033 | return -1; | 996 | return -EINVAL; |
1034 | } | 997 | } |
1035 | 998 | ||
1036 | return 0; | 999 | return 0; |
@@ -1291,7 +1254,7 @@ static int pscsi_map_task_SG(struct se_task *task) | |||
1291 | */ | 1254 | */ |
1292 | static int pscsi_map_task_non_SG(struct se_task *task) | 1255 | static int pscsi_map_task_non_SG(struct se_task *task) |
1293 | { | 1256 | { |
1294 | struct se_cmd *cmd = TASK_CMD(task); | 1257 | struct se_cmd *cmd = task->task_se_cmd; |
1295 | struct pscsi_plugin_task *pt = PSCSI_TASK(task); | 1258 | struct pscsi_plugin_task *pt = PSCSI_TASK(task); |
1296 | struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; | 1259 | struct pscsi_dev_virt *pdv = task->se_dev->dev_ptr; |
1297 | int ret = 0; | 1260 | int ret = 0; |
@@ -1303,7 +1266,7 @@ static int pscsi_map_task_non_SG(struct se_task *task) | |||
1303 | return 0; | 1266 | return 0; |
1304 | 1267 | ||
1305 | ret = blk_rq_map_kern(pdv->pdv_sd->request_queue, | 1268 | ret = blk_rq_map_kern(pdv->pdv_sd->request_queue, |
1306 | pt->pscsi_req, T_TASK(cmd)->t_task_buf, | 1269 | pt->pscsi_req, cmd->t_task->t_task_buf, |
1307 | task->task_size, GFP_KERNEL); | 1270 | task->task_size, GFP_KERNEL); |
1308 | if (ret < 0) { | 1271 | if (ret < 0) { |
1309 | printk(KERN_ERR "PSCSI: blk_rq_map_kern() failed: %d\n", ret); | 1272 | printk(KERN_ERR "PSCSI: blk_rq_map_kern() failed: %d\n", ret); |
@@ -1400,13 +1363,11 @@ static inline void pscsi_process_SAM_status( | |||
1400 | pt->pscsi_result); | 1363 | pt->pscsi_result); |
1401 | task->task_scsi_status = SAM_STAT_CHECK_CONDITION; | 1364 | task->task_scsi_status = SAM_STAT_CHECK_CONDITION; |
1402 | task->task_error_status = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 1365 | task->task_error_status = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; |
1403 | TASK_CMD(task)->transport_error_status = | 1366 | task->task_se_cmd->transport_error_status = |
1404 | PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 1367 | PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; |
1405 | transport_complete_task(task, 0); | 1368 | transport_complete_task(task, 0); |
1406 | break; | 1369 | break; |
1407 | } | 1370 | } |
1408 | |||
1409 | return; | ||
1410 | } | 1371 | } |
1411 | 1372 | ||
1412 | static void pscsi_req_done(struct request *req, int uptodate) | 1373 | static void pscsi_req_done(struct request *req, int uptodate) |