diff options
author | Tejun Heo <tj@kernel.org> | 2009-05-07 09:24:42 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-05-11 03:50:55 -0400 |
commit | b0790410300abaaf4f25f702803beff701baebf1 (patch) | |
tree | 63d8fcd38e4cd5927fd83e482e306480bb68a689 /drivers/scsi | |
parent | 2e46e8b27aa57c6bd34b3102b40ee4d0144b4fab (diff) |
block: cleanup rq->data_len usages
With recent unification of fields, it's now guaranteed that
rq->data_len always equals blk_rq_bytes(). Convert all non-IDE direct
users to accessors. IDE will be converted in a separate patch.
Boaz: spotted incorrect data_len/resid_len conversion in osd.
[ Impact: convert direct rq->data_len usages to blk_rq_bytes() ]
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Cc: Eric Moore <Eric.Moore@lsi.com>
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Cc: Darrick J. Wong <djwong@us.ibm.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Eric Moore <Eric.Moore@lsi.com>
Cc: Boaz Harrosh <bharrosh@panasas.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/libsas/sas_expander.c | 8 | ||||
-rw-r--r-- | drivers/scsi/libsas/sas_host_smp.c | 18 | ||||
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_transport.c | 21 | ||||
-rw-r--r-- | drivers/scsi/osd/osd_initiator.c | 4 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 13 | ||||
-rw-r--r-- | drivers/scsi/scsi_tgt_lib.c | 2 |
6 files changed, 33 insertions, 33 deletions
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 6605ec905cc0..531af9ed7199 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c | |||
@@ -1927,13 +1927,13 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1927 | /* do we need to support multiple segments? */ | 1927 | /* do we need to support multiple segments? */ |
1928 | if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { | 1928 | if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { |
1929 | printk("%s: multiple segments req %u %u, rsp %u %u\n", | 1929 | printk("%s: multiple segments req %u %u, rsp %u %u\n", |
1930 | __func__, req->bio->bi_vcnt, req->data_len, | 1930 | __func__, req->bio->bi_vcnt, blk_rq_bytes(req), |
1931 | rsp->bio->bi_vcnt, rsp->data_len); | 1931 | rsp->bio->bi_vcnt, blk_rq_bytes(rsp)); |
1932 | return -EINVAL; | 1932 | return -EINVAL; |
1933 | } | 1933 | } |
1934 | 1934 | ||
1935 | ret = smp_execute_task(dev, bio_data(req->bio), req->data_len, | 1935 | ret = smp_execute_task(dev, bio_data(req->bio), blk_rq_bytes(req), |
1936 | bio_data(rsp->bio), rsp->data_len); | 1936 | bio_data(rsp->bio), blk_rq_bytes(rsp)); |
1937 | if (ret > 0) { | 1937 | if (ret > 0) { |
1938 | /* positive number is the untransferred residual */ | 1938 | /* positive number is the untransferred residual */ |
1939 | rsp->resid_len = ret; | 1939 | rsp->resid_len = ret; |
diff --git a/drivers/scsi/libsas/sas_host_smp.c b/drivers/scsi/libsas/sas_host_smp.c index 89952edd0be3..be9a951b977d 100644 --- a/drivers/scsi/libsas/sas_host_smp.c +++ b/drivers/scsi/libsas/sas_host_smp.c | |||
@@ -137,21 +137,21 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req, | |||
137 | int error = -EINVAL; | 137 | int error = -EINVAL; |
138 | 138 | ||
139 | /* eight is the minimum size for request and response frames */ | 139 | /* eight is the minimum size for request and response frames */ |
140 | if (req->data_len < 8 || rsp->data_len < 8) | 140 | if (blk_rq_bytes(req) < 8 || blk_rq_bytes(rsp) < 8) |
141 | goto out; | 141 | goto out; |
142 | 142 | ||
143 | if (bio_offset(req->bio) + req->data_len > PAGE_SIZE || | 143 | if (bio_offset(req->bio) + blk_rq_bytes(req) > PAGE_SIZE || |
144 | bio_offset(rsp->bio) + rsp->data_len > PAGE_SIZE) { | 144 | bio_offset(rsp->bio) + blk_rq_bytes(rsp) > PAGE_SIZE) { |
145 | shost_printk(KERN_ERR, shost, | 145 | shost_printk(KERN_ERR, shost, |
146 | "SMP request/response frame crosses page boundary"); | 146 | "SMP request/response frame crosses page boundary"); |
147 | goto out; | 147 | goto out; |
148 | } | 148 | } |
149 | 149 | ||
150 | req_data = kzalloc(req->data_len, GFP_KERNEL); | 150 | req_data = kzalloc(blk_rq_bytes(req), GFP_KERNEL); |
151 | 151 | ||
152 | /* make sure frame can always be built ... we copy | 152 | /* make sure frame can always be built ... we copy |
153 | * back only the requested length */ | 153 | * back only the requested length */ |
154 | resp_data = kzalloc(max(rsp->data_len, 128U), GFP_KERNEL); | 154 | resp_data = kzalloc(max(blk_rq_bytes(rsp), 128U), GFP_KERNEL); |
155 | 155 | ||
156 | if (!req_data || !resp_data) { | 156 | if (!req_data || !resp_data) { |
157 | error = -ENOMEM; | 157 | error = -ENOMEM; |
@@ -160,7 +160,7 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req, | |||
160 | 160 | ||
161 | local_irq_disable(); | 161 | local_irq_disable(); |
162 | buf = kmap_atomic(bio_page(req->bio), KM_USER0) + bio_offset(req->bio); | 162 | buf = kmap_atomic(bio_page(req->bio), KM_USER0) + bio_offset(req->bio); |
163 | memcpy(req_data, buf, req->data_len); | 163 | memcpy(req_data, buf, blk_rq_bytes(req)); |
164 | kunmap_atomic(buf - bio_offset(req->bio), KM_USER0); | 164 | kunmap_atomic(buf - bio_offset(req->bio), KM_USER0); |
165 | local_irq_enable(); | 165 | local_irq_enable(); |
166 | 166 | ||
@@ -176,8 +176,8 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req, | |||
176 | resp_data[1] = req_data[1]; | 176 | resp_data[1] = req_data[1]; |
177 | resp_data[2] = SMP_RESP_FUNC_UNK; | 177 | resp_data[2] = SMP_RESP_FUNC_UNK; |
178 | 178 | ||
179 | req->resid_len = req->data_len; | 179 | req->resid_len = blk_rq_bytes(req); |
180 | rsp->resid_len = rsp->data_len; | 180 | rsp->resid_len = blk_rq_bytes(rsp); |
181 | 181 | ||
182 | switch (req_data[1]) { | 182 | switch (req_data[1]) { |
183 | case SMP_REPORT_GENERAL: | 183 | case SMP_REPORT_GENERAL: |
@@ -264,7 +264,7 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req, | |||
264 | 264 | ||
265 | local_irq_disable(); | 265 | local_irq_disable(); |
266 | buf = kmap_atomic(bio_page(rsp->bio), KM_USER0) + bio_offset(rsp->bio); | 266 | buf = kmap_atomic(bio_page(rsp->bio), KM_USER0) + bio_offset(rsp->bio); |
267 | memcpy(buf, resp_data, rsp->data_len); | 267 | memcpy(buf, resp_data, blk_rq_bytes(rsp)); |
268 | flush_kernel_dcache_page(bio_page(rsp->bio)); | 268 | flush_kernel_dcache_page(bio_page(rsp->bio)); |
269 | kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0); | 269 | kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0); |
270 | local_irq_enable(); | 270 | local_irq_enable(); |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c index 53759c566bfe..af95a449930e 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_transport.c +++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c | |||
@@ -1041,7 +1041,7 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1041 | if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { | 1041 | if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) { |
1042 | printk(MPT2SAS_ERR_FMT "%s: multiple segments req %u %u, " | 1042 | printk(MPT2SAS_ERR_FMT "%s: multiple segments req %u %u, " |
1043 | "rsp %u %u\n", ioc->name, __func__, req->bio->bi_vcnt, | 1043 | "rsp %u %u\n", ioc->name, __func__, req->bio->bi_vcnt, |
1044 | req->data_len, rsp->bio->bi_vcnt, rsp->data_len); | 1044 | blk_rq_bytes(req), rsp->bio->bi_vcnt, blk_rq_bytes(rsp)); |
1045 | return -EINVAL; | 1045 | return -EINVAL; |
1046 | } | 1046 | } |
1047 | 1047 | ||
@@ -1104,7 +1104,7 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1104 | *((u64 *)&mpi_request->SASAddress) = (rphy) ? | 1104 | *((u64 *)&mpi_request->SASAddress) = (rphy) ? |
1105 | cpu_to_le64(rphy->identify.sas_address) : | 1105 | cpu_to_le64(rphy->identify.sas_address) : |
1106 | cpu_to_le64(ioc->sas_hba.sas_address); | 1106 | cpu_to_le64(ioc->sas_hba.sas_address); |
1107 | mpi_request->RequestDataLength = cpu_to_le16(req->data_len - 4); | 1107 | mpi_request->RequestDataLength = cpu_to_le16(blk_rq_bytes(req) - 4); |
1108 | psge = &mpi_request->SGL; | 1108 | psge = &mpi_request->SGL; |
1109 | 1109 | ||
1110 | /* WRITE sgel first */ | 1110 | /* WRITE sgel first */ |
@@ -1112,13 +1112,13 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1112 | MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC); | 1112 | MPI2_SGE_FLAGS_END_OF_BUFFER | MPI2_SGE_FLAGS_HOST_TO_IOC); |
1113 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; | 1113 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
1114 | dma_addr_out = pci_map_single(ioc->pdev, bio_data(req->bio), | 1114 | dma_addr_out = pci_map_single(ioc->pdev, bio_data(req->bio), |
1115 | req->data_len, PCI_DMA_BIDIRECTIONAL); | 1115 | blk_rq_bytes(req), PCI_DMA_BIDIRECTIONAL); |
1116 | if (!dma_addr_out) { | 1116 | if (!dma_addr_out) { |
1117 | mpt2sas_base_free_smid(ioc, le16_to_cpu(smid)); | 1117 | mpt2sas_base_free_smid(ioc, le16_to_cpu(smid)); |
1118 | goto unmap; | 1118 | goto unmap; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | ioc->base_add_sg_single(psge, sgl_flags | (req->data_len - 4), | 1121 | ioc->base_add_sg_single(psge, sgl_flags | (blk_rq_bytes(req) - 4), |
1122 | dma_addr_out); | 1122 | dma_addr_out); |
1123 | 1123 | ||
1124 | /* incr sgel */ | 1124 | /* incr sgel */ |
@@ -1129,14 +1129,14 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1129 | MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER | | 1129 | MPI2_SGE_FLAGS_LAST_ELEMENT | MPI2_SGE_FLAGS_END_OF_BUFFER | |
1130 | MPI2_SGE_FLAGS_END_OF_LIST); | 1130 | MPI2_SGE_FLAGS_END_OF_LIST); |
1131 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; | 1131 | sgl_flags = sgl_flags << MPI2_SGE_FLAGS_SHIFT; |
1132 | dma_addr_in = pci_map_single(ioc->pdev, bio_data(rsp->bio), | 1132 | dma_addr_in = pci_map_single(ioc->pdev, bio_data(rsp->bio), |
1133 | rsp->data_len, PCI_DMA_BIDIRECTIONAL); | 1133 | blk_rq_bytes(rsp), PCI_DMA_BIDIRECTIONAL); |
1134 | if (!dma_addr_in) { | 1134 | if (!dma_addr_in) { |
1135 | mpt2sas_base_free_smid(ioc, le16_to_cpu(smid)); | 1135 | mpt2sas_base_free_smid(ioc, le16_to_cpu(smid)); |
1136 | goto unmap; | 1136 | goto unmap; |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | ioc->base_add_sg_single(psge, sgl_flags | (rsp->data_len + 4), | 1139 | ioc->base_add_sg_single(psge, sgl_flags | (blk_rq_bytes(rsp) + 4), |
1140 | dma_addr_in); | 1140 | dma_addr_in); |
1141 | 1141 | ||
1142 | dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s - " | 1142 | dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s - " |
@@ -1170,7 +1170,8 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1170 | 1170 | ||
1171 | memcpy(req->sense, mpi_reply, sizeof(*mpi_reply)); | 1171 | memcpy(req->sense, mpi_reply, sizeof(*mpi_reply)); |
1172 | req->sense_len = sizeof(*mpi_reply); | 1172 | req->sense_len = sizeof(*mpi_reply); |
1173 | rsp->resid_len = rsp->data_len - mpi_reply->ResponseDataLength; | 1173 | rsp->resid_len = blk_rq_bytes(rsp) - |
1174 | mpi_reply->ResponseDataLength; | ||
1174 | } else { | 1175 | } else { |
1175 | dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT | 1176 | dtransportprintk(ioc, printk(MPT2SAS_DEBUG_FMT |
1176 | "%s - no reply\n", ioc->name, __func__)); | 1177 | "%s - no reply\n", ioc->name, __func__)); |
@@ -1186,10 +1187,10 @@ transport_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, | |||
1186 | 1187 | ||
1187 | unmap: | 1188 | unmap: |
1188 | if (dma_addr_out) | 1189 | if (dma_addr_out) |
1189 | pci_unmap_single(ioc->pdev, dma_addr_out, req->data_len, | 1190 | pci_unmap_single(ioc->pdev, dma_addr_out, blk_rq_bytes(req), |
1190 | PCI_DMA_BIDIRECTIONAL); | 1191 | PCI_DMA_BIDIRECTIONAL); |
1191 | if (dma_addr_in) | 1192 | if (dma_addr_in) |
1192 | pci_unmap_single(ioc->pdev, dma_addr_in, rsp->data_len, | 1193 | pci_unmap_single(ioc->pdev, dma_addr_in, blk_rq_bytes(rsp), |
1193 | PCI_DMA_BIDIRECTIONAL); | 1194 | PCI_DMA_BIDIRECTIONAL); |
1194 | 1195 | ||
1195 | out: | 1196 | out: |
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c index 2a5f0777148d..d178a8b799ec 100644 --- a/drivers/scsi/osd/osd_initiator.c +++ b/drivers/scsi/osd/osd_initiator.c | |||
@@ -1299,7 +1299,7 @@ int osd_finalize_request(struct osd_request *or, | |||
1299 | return ret; | 1299 | return ret; |
1300 | } | 1300 | } |
1301 | OSD_DEBUG("out bytes=%llu (bytes_req=%u)\n", | 1301 | OSD_DEBUG("out bytes=%llu (bytes_req=%u)\n", |
1302 | _LLU(or->out.total_bytes), or->out.req->data_len); | 1302 | _LLU(or->out.total_bytes), blk_rq_bytes(or->out.req)); |
1303 | } | 1303 | } |
1304 | if (or->in.bio) { | 1304 | if (or->in.bio) { |
1305 | ret = blk_rq_append_bio(or->request->q, or->in.req, or->in.bio); | 1305 | ret = blk_rq_append_bio(or->request->q, or->in.req, or->in.bio); |
@@ -1308,7 +1308,7 @@ int osd_finalize_request(struct osd_request *or, | |||
1308 | return ret; | 1308 | return ret; |
1309 | } | 1309 | } |
1310 | OSD_DEBUG("in bytes=%llu (bytes_req=%u)\n", | 1310 | OSD_DEBUG("in bytes=%llu (bytes_req=%u)\n", |
1311 | _LLU(or->in.total_bytes), or->in.req->data_len); | 1311 | _LLU(or->in.total_bytes), blk_rq_bytes(or->in.req)); |
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | or->out.pad_buff = sg_out_pad_buffer; | 1314 | or->out.pad_buff = sg_out_pad_buffer; |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 39b3acfc0ddf..3d16c70fbde0 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -682,14 +682,13 @@ EXPORT_SYMBOL(scsi_release_buffers); | |||
682 | static void scsi_end_bidi_request(struct scsi_cmnd *cmd) | 682 | static void scsi_end_bidi_request(struct scsi_cmnd *cmd) |
683 | { | 683 | { |
684 | struct request *req = cmd->request; | 684 | struct request *req = cmd->request; |
685 | unsigned int dlen = req->data_len; | ||
686 | unsigned int next_dlen = req->next_rq->data_len; | ||
687 | 685 | ||
688 | req->resid_len = scsi_out(cmd)->resid; | 686 | req->resid_len = scsi_out(cmd)->resid; |
689 | req->next_rq->resid_len = scsi_in(cmd)->resid; | 687 | req->next_rq->resid_len = scsi_in(cmd)->resid; |
690 | 688 | ||
691 | /* The req and req->next_rq have not been completed */ | 689 | /* The req and req->next_rq have not been completed */ |
692 | BUG_ON(blk_end_bidi_request(req, 0, dlen, next_dlen)); | 690 | BUG_ON(blk_end_bidi_request(req, 0, blk_rq_bytes(req), |
691 | blk_rq_bytes(req->next_rq))); | ||
693 | 692 | ||
694 | scsi_release_buffers(cmd); | 693 | scsi_release_buffers(cmd); |
695 | 694 | ||
@@ -966,7 +965,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, | |||
966 | BUG_ON(count > sdb->table.nents); | 965 | BUG_ON(count > sdb->table.nents); |
967 | sdb->table.nents = count; | 966 | sdb->table.nents = count; |
968 | if (blk_pc_request(req)) | 967 | if (blk_pc_request(req)) |
969 | sdb->length = req->data_len; | 968 | sdb->length = blk_rq_bytes(req); |
970 | else | 969 | else |
971 | sdb->length = blk_rq_sectors(req) << 9; | 970 | sdb->length = blk_rq_sectors(req) << 9; |
972 | return BLKPREP_OK; | 971 | return BLKPREP_OK; |
@@ -1087,21 +1086,21 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) | |||
1087 | if (unlikely(ret)) | 1086 | if (unlikely(ret)) |
1088 | return ret; | 1087 | return ret; |
1089 | } else { | 1088 | } else { |
1090 | BUG_ON(req->data_len); | 1089 | BUG_ON(blk_rq_bytes(req)); |
1091 | 1090 | ||
1092 | memset(&cmd->sdb, 0, sizeof(cmd->sdb)); | 1091 | memset(&cmd->sdb, 0, sizeof(cmd->sdb)); |
1093 | req->buffer = NULL; | 1092 | req->buffer = NULL; |
1094 | } | 1093 | } |
1095 | 1094 | ||
1096 | cmd->cmd_len = req->cmd_len; | 1095 | cmd->cmd_len = req->cmd_len; |
1097 | if (!req->data_len) | 1096 | if (!blk_rq_bytes(req)) |
1098 | cmd->sc_data_direction = DMA_NONE; | 1097 | cmd->sc_data_direction = DMA_NONE; |
1099 | else if (rq_data_dir(req) == WRITE) | 1098 | else if (rq_data_dir(req) == WRITE) |
1100 | cmd->sc_data_direction = DMA_TO_DEVICE; | 1099 | cmd->sc_data_direction = DMA_TO_DEVICE; |
1101 | else | 1100 | else |
1102 | cmd->sc_data_direction = DMA_FROM_DEVICE; | 1101 | cmd->sc_data_direction = DMA_FROM_DEVICE; |
1103 | 1102 | ||
1104 | cmd->transfersize = req->data_len; | 1103 | cmd->transfersize = blk_rq_bytes(req); |
1105 | cmd->allowed = req->retries; | 1104 | cmd->allowed = req->retries; |
1106 | return BLKPREP_OK; | 1105 | return BLKPREP_OK; |
1107 | } | 1106 | } |
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c index 48ba413f7f6a..10303272ba45 100644 --- a/drivers/scsi/scsi_tgt_lib.c +++ b/drivers/scsi/scsi_tgt_lib.c | |||
@@ -387,7 +387,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd, | |||
387 | * we use REQ_TYPE_BLOCK_PC so scsi_init_io doesn't set the | 387 | * we use REQ_TYPE_BLOCK_PC so scsi_init_io doesn't set the |
388 | * length for us. | 388 | * length for us. |
389 | */ | 389 | */ |
390 | cmd->sdb.length = rq->data_len; | 390 | cmd->sdb.length = blk_rq_bytes(rq); |
391 | 391 | ||
392 | return 0; | 392 | return 0; |
393 | 393 | ||