Commit b7e9e1fb7a9227be34ad4a5e778022c3164494cf
Committed by
Jens Axboe
1 parent
226b4fc75c
scsi: implement .cleanup_rq callback
Implement .cleanup_rq() callback for freeing driver private part of the request. Then we can avoid to leak this part if the request isn't completed by SCSI, and freed by blk-mq or upper layer(such as dm-rq) finally. Cc: Ewan D. Milne <emilne@redhat.com> Cc: Bart Van Assche <bvanassche@acm.org> Cc: Hannes Reinecke <hare@suse.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Mike Snitzer <snitzer@redhat.com> Cc: dm-devel@redhat.com Cc: <stable@vger.kernel.org> Fixes: 396eaf21ee17 ("blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback") Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Showing 1 changed file with 13 additions and 0 deletions Side-by-side Diff
drivers/scsi/scsi_lib.c
... | ... | @@ -1089,6 +1089,18 @@ |
1089 | 1089 | cmd->retries = 0; |
1090 | 1090 | } |
1091 | 1091 | |
1092 | +/* | |
1093 | + * Only called when the request isn't completed by SCSI, and not freed by | |
1094 | + * SCSI | |
1095 | + */ | |
1096 | +static void scsi_cleanup_rq(struct request *rq) | |
1097 | +{ | |
1098 | + if (rq->rq_flags & RQF_DONTPREP) { | |
1099 | + scsi_mq_uninit_cmd(blk_mq_rq_to_pdu(rq)); | |
1100 | + rq->rq_flags &= ~RQF_DONTPREP; | |
1101 | + } | |
1102 | +} | |
1103 | + | |
1092 | 1104 | /* Add a command to the list used by the aacraid and dpt_i2o drivers */ |
1093 | 1105 | void scsi_add_cmd_to_list(struct scsi_cmnd *cmd) |
1094 | 1106 | { |
... | ... | @@ -1821,6 +1833,7 @@ |
1821 | 1833 | .init_request = scsi_mq_init_request, |
1822 | 1834 | .exit_request = scsi_mq_exit_request, |
1823 | 1835 | .initialize_rq_fn = scsi_initialize_rq, |
1836 | + .cleanup_rq = scsi_cleanup_rq, | |
1824 | 1837 | .busy = scsi_mq_lld_busy, |
1825 | 1838 | .map_queues = scsi_map_queues, |
1826 | 1839 | }; |