aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-04-16 23:37:30 -0400
committerJens Axboe <axboe@fb.com>2014-04-16 23:37:30 -0400
commitdc4a93078b8a6a10d2dcaba76ab488d6dbe73922 (patch)
treecee24991c2d4fa7d6ad6e2be790fde880c0223ed /drivers/scsi
parentfb1be43301ce045b5e563416e701573464a2ed96 (diff)
sd/skd: stuff discard page in request->completion_data
Store the pointer to the page there, so we can always safely reference it from end_io context where ->bio may have been cleared. Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/sd.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 06d154d20faa..96af195224f2 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -737,6 +737,7 @@ static int sd_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq)
737 goto out; 737 goto out;
738 } 738 }
739 739
740 rq->completion_data = page;
740 blk_add_request_payload(rq, page, len); 741 blk_add_request_payload(rq, page, len);
741 ret = scsi_setup_blk_pc_cmnd(sdp, rq); 742 ret = scsi_setup_blk_pc_cmnd(sdp, rq);
742 rq->__data_len = nr_bytes; 743 rq->__data_len = nr_bytes;
@@ -839,11 +840,9 @@ static void sd_unprep_fn(struct request_queue *q, struct request *rq)
839{ 840{
840 struct scsi_cmnd *SCpnt = rq->special; 841 struct scsi_cmnd *SCpnt = rq->special;
841 842
842 if (rq->cmd_flags & REQ_DISCARD) { 843 if (rq->cmd_flags & REQ_DISCARD)
843 struct bio *bio = rq->bio; 844 __free_page(rq->completion_data);
844 845
845 __free_page(bio->bi_io_vec->bv_page);
846 }
847 if (SCpnt->cmnd != rq->cmd) { 846 if (SCpnt->cmnd != rq->cmd) {
848 mempool_free(SCpnt->cmnd, sd_cdb_pool); 847 mempool_free(SCpnt->cmnd, sd_cdb_pool);
849 SCpnt->cmnd = NULL; 848 SCpnt->cmnd = NULL;