aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/osd/osd_initiator.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/osd/osd_initiator.c')
-rw-r--r--drivers/scsi/osd/osd_initiator.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index 552f58b655d1..2a5f0777148d 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -338,20 +338,6 @@ struct osd_request *osd_start_request(struct osd_dev *dev, gfp_t gfp)
338} 338}
339EXPORT_SYMBOL(osd_start_request); 339EXPORT_SYMBOL(osd_start_request);
340 340
341/*
342 * If osd_finalize_request() was called but the request was not executed through
343 * the block layer, then we must release BIOs.
344 */
345static void _abort_unexecuted_bios(struct request *rq)
346{
347 struct bio *bio;
348
349 while ((bio = rq->bio) != NULL) {
350 rq->bio = bio->bi_next;
351 bio_endio(bio, 0);
352 }
353}
354
355static void _osd_free_seg(struct osd_request *or __unused, 341static void _osd_free_seg(struct osd_request *or __unused,
356 struct _osd_req_data_segment *seg) 342 struct _osd_req_data_segment *seg)
357{ 343{
@@ -363,9 +349,30 @@ static void _osd_free_seg(struct osd_request *or __unused,
363 seg->alloc_size = 0; 349 seg->alloc_size = 0;
364} 350}
365 351
352static void _put_request(struct request *rq , bool is_async)
353{
354 if (is_async) {
355 WARN_ON(rq->bio);
356 __blk_put_request(rq->q, rq);
357 } else {
358 /*
359 * If osd_finalize_request() was called but the request was not
360 * executed through the block layer, then we must release BIOs.
361 * TODO: Keep error code in or->async_error. Need to audit all
362 * code paths.
363 */
364 if (unlikely(rq->bio))
365 blk_end_request(rq, -ENOMEM, blk_rq_bytes(rq));
366 else
367 blk_put_request(rq);
368 }
369}
370
366void osd_end_request(struct osd_request *or) 371void osd_end_request(struct osd_request *or)
367{ 372{
368 struct request *rq = or->request; 373 struct request *rq = or->request;
374 /* IMPORTANT: make sure this agrees with osd_execute_request_async */
375 bool is_async = (or->request->end_io_data == or);
369 376
370 _osd_free_seg(or, &or->set_attr); 377 _osd_free_seg(or, &or->set_attr);
371 _osd_free_seg(or, &or->enc_get_attr); 378 _osd_free_seg(or, &or->enc_get_attr);
@@ -373,12 +380,11 @@ void osd_end_request(struct osd_request *or)
373 380
374 if (rq) { 381 if (rq) {
375 if (rq->next_rq) { 382 if (rq->next_rq) {
376 _abort_unexecuted_bios(rq->next_rq); 383 _put_request(rq->next_rq, is_async);
377 blk_put_request(rq->next_rq); 384 rq->next_rq = NULL;
378 } 385 }
379 386
380 _abort_unexecuted_bios(rq); 387 _put_request(rq, is_async);
381 blk_put_request(rq);
382 } 388 }
383 _osd_request_free(or); 389 _osd_request_free(or);
384} 390}