aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/skd_main.c4
-rw-r--r--drivers/scsi/sd.c7
2 files changed, 5 insertions, 6 deletions
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 36bcedfd930c..c48d9084c965 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -743,6 +743,7 @@ static void skd_request_fn(struct request_queue *q)
743 break; 743 break;
744 } 744 }
745 skreq->discard_page = 1; 745 skreq->discard_page = 1;
746 req->completion_data = page;
746 skd_prep_discard_cdb(scsi_req, skreq, page, lba, count); 747 skd_prep_discard_cdb(scsi_req, skreq, page, lba, count);
747 748
748 } else if (flush == SKD_FLUSH_ZERO_SIZE_FIRST) { 749 } else if (flush == SKD_FLUSH_ZERO_SIZE_FIRST) {
@@ -855,10 +856,9 @@ static void skd_end_request(struct skd_device *skdev,
855 856
856 if ((io_flags & REQ_DISCARD) && 857 if ((io_flags & REQ_DISCARD) &&
857 (skreq->discard_page == 1)) { 858 (skreq->discard_page == 1)) {
858 struct bio *bio = req->bio;
859 pr_debug("%s:%s:%d, free the page!", 859 pr_debug("%s:%s:%d, free the page!",
860 skdev->name, __func__, __LINE__); 860 skdev->name, __func__, __LINE__);
861 __free_page(bio->bi_io_vec->bv_page); 861 __free_page(req->completion_data);
862 } 862 }
863 863
864 if (unlikely(error)) { 864 if (unlikely(error)) {
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;