aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libsas
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-05-07 09:24:37 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-05-11 03:50:53 -0400
commitc3a4d78c580de4edc9ef0f7c59812fb02ceb037f (patch)
tree916ca44287100707508678e2cc0eff0c43b9ca39 /drivers/scsi/libsas
parent9720aef2539c10e3a872e9a92beec225030d99db (diff)
block: add rq->resid_len
rq->data_len served two purposes - the length of data buffer on issue and the residual count on completion. This duality creates some headaches. First of all, block layer and low level drivers can't really determine what rq->data_len contains while a request is executing. It could be the total request length or it coulde be anything else one of the lower layers is using to keep track of residual count. This complicates things because blk_rq_bytes() and thus [__]blk_end_request_all() relies on rq->data_len for PC commands. Drivers which want to report residual count should first cache the total request length, update rq->data_len and then complete the request with the cached data length. Secondly, it makes requests default to reporting full residual count, ie. reporting that no data transfer occurred. The residual count is an exception not the norm; however, the driver should clear rq->data_len to zero to signify the normal cases while leaving it alone means no data transfer occurred at all. This reverse default behavior complicates code unnecessarily and renders block PC on some drivers (ide-tape/floppy) unuseable. This patch adds rq->resid_len which is used only for residual count. While at it, remove now unnecessasry blk_rq_bytes() caching in ide_pc_intr() as rq->data_len is not changed anymore. Boaz : spotted missing conversion in osd Sergei : spotted too early conversion to blk_rq_bytes() in ide-tape [ Impact: cleanup residual count handling, report 0 resid by default ] Signed-off-by: Tejun Heo <tj@kernel.org> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Cc: Borislav Petkov <petkovbb@googlemail.com> Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: Mike Miller <mike.miller@hp.com> Cc: Eric Moore <Eric.Moore@lsi.com> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Doug Gilbert <dgilbert@interlog.com> Cc: Mike Miller <mike.miller@hp.com> Cc: Eric Moore <Eric.Moore@lsi.com> Cc: Darrick J. Wong <djwong@us.ibm.com> Cc: Pete Zaitcev <zaitcev@redhat.com> Cc: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/scsi/libsas')
-rw-r--r--drivers/scsi/libsas/sas_expander.c6
-rw-r--r--drivers/scsi/libsas/sas_host_smp.c38
2 files changed, 21 insertions, 23 deletions
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 3da02e436788..6605ec905cc0 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1936,12 +1936,8 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1936 bio_data(rsp->bio), rsp->data_len); 1936 bio_data(rsp->bio), rsp->data_len);
1937 if (ret > 0) { 1937 if (ret > 0) {
1938 /* positive number is the untransferred residual */ 1938 /* positive number is the untransferred residual */
1939 rsp->data_len = ret; 1939 rsp->resid_len = ret;
1940 req->data_len = 0;
1941 ret = 0; 1940 ret = 0;
1942 } else if (ret == 0) {
1943 rsp->data_len = 0;
1944 req->data_len = 0;
1945 } 1941 }
1946 1942
1947 return ret; 1943 return ret;
diff --git a/drivers/scsi/libsas/sas_host_smp.c b/drivers/scsi/libsas/sas_host_smp.c
index d110a366c48a..89952edd0be3 100644
--- a/drivers/scsi/libsas/sas_host_smp.c
+++ b/drivers/scsi/libsas/sas_host_smp.c
@@ -134,7 +134,7 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
134{ 134{
135 u8 *req_data = NULL, *resp_data = NULL, *buf; 135 u8 *req_data = NULL, *resp_data = NULL, *buf;
136 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); 136 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
137 int error = -EINVAL, resp_data_len = rsp->data_len; 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 (req->data_len < 8 || rsp->data_len < 8)
@@ -176,17 +176,20 @@ 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;
180 rsp->resid_len = rsp->data_len;
181
179 switch (req_data[1]) { 182 switch (req_data[1]) {
180 case SMP_REPORT_GENERAL: 183 case SMP_REPORT_GENERAL:
181 req->data_len -= 8; 184 req->resid_len -= 8;
182 resp_data_len -= 32; 185 rsp->resid_len -= 32;
183 resp_data[2] = SMP_RESP_FUNC_ACC; 186 resp_data[2] = SMP_RESP_FUNC_ACC;
184 resp_data[9] = sas_ha->num_phys; 187 resp_data[9] = sas_ha->num_phys;
185 break; 188 break;
186 189
187 case SMP_REPORT_MANUF_INFO: 190 case SMP_REPORT_MANUF_INFO:
188 req->data_len -= 8; 191 req->resid_len -= 8;
189 resp_data_len -= 64; 192 rsp->resid_len -= 64;
190 resp_data[2] = SMP_RESP_FUNC_ACC; 193 resp_data[2] = SMP_RESP_FUNC_ACC;
191 memcpy(resp_data + 12, shost->hostt->name, 194 memcpy(resp_data + 12, shost->hostt->name,
192 SAS_EXPANDER_VENDOR_ID_LEN); 195 SAS_EXPANDER_VENDOR_ID_LEN);
@@ -199,13 +202,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
199 break; 202 break;
200 203
201 case SMP_DISCOVER: 204 case SMP_DISCOVER:
202 req->data_len -= 16; 205 req->resid_len -= 16;
203 if ((int)req->data_len < 0) { 206 if ((int)req->resid_len < 0) {
204 req->data_len = 0; 207 req->resid_len = 0;
205 error = -EINVAL; 208 error = -EINVAL;
206 goto out; 209 goto out;
207 } 210 }
208 resp_data_len -= 56; 211 rsp->resid_len -= 56;
209 sas_host_smp_discover(sas_ha, resp_data, req_data[9]); 212 sas_host_smp_discover(sas_ha, resp_data, req_data[9]);
210 break; 213 break;
211 214
@@ -215,13 +218,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
215 break; 218 break;
216 219
217 case SMP_REPORT_PHY_SATA: 220 case SMP_REPORT_PHY_SATA:
218 req->data_len -= 16; 221 req->resid_len -= 16;
219 if ((int)req->data_len < 0) { 222 if ((int)req->resid_len < 0) {
220 req->data_len = 0; 223 req->resid_len = 0;
221 error = -EINVAL; 224 error = -EINVAL;
222 goto out; 225 goto out;
223 } 226 }
224 resp_data_len -= 60; 227 rsp->resid_len -= 60;
225 sas_report_phy_sata(sas_ha, resp_data, req_data[9]); 228 sas_report_phy_sata(sas_ha, resp_data, req_data[9]);
226 break; 229 break;
227 230
@@ -238,13 +241,13 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
238 break; 241 break;
239 242
240 case SMP_PHY_CONTROL: 243 case SMP_PHY_CONTROL:
241 req->data_len -= 44; 244 req->resid_len -= 44;
242 if ((int)req->data_len < 0) { 245 if ((int)req->resid_len < 0) {
243 req->data_len = 0; 246 req->resid_len = 0;
244 error = -EINVAL; 247 error = -EINVAL;
245 goto out; 248 goto out;
246 } 249 }
247 resp_data_len -= 8; 250 rsp->resid_len -= 8;
248 sas_phy_control(sas_ha, req_data[9], req_data[10], 251 sas_phy_control(sas_ha, req_data[9], req_data[10],
249 req_data[32] >> 4, req_data[33] >> 4, 252 req_data[32] >> 4, req_data[33] >> 4,
250 resp_data); 253 resp_data);
@@ -265,7 +268,6 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
265 flush_kernel_dcache_page(bio_page(rsp->bio)); 268 flush_kernel_dcache_page(bio_page(rsp->bio));
266 kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0); 269 kunmap_atomic(buf - bio_offset(rsp->bio), KM_USER0);
267 local_irq_enable(); 270 local_irq_enable();
268 rsp->data_len = resp_data_len;
269 271
270 out: 272 out:
271 kfree(req_data); 273 kfree(req_data);