@@ -866,23 +866,13 @@ static void rq_completed(struct mapped_device *md, int rw, int run_queue)
dm_put(md);
}
-static void free_rq_clone(struct request *clone)
-{
- struct dm_rq_target_io *tio = clone->end_io_data;
-
- blk_rq_unprep_clone(clone);
- free_rq_tio(tio);
-}
-
/*
* Complete the clone and the original request.
* Must be called without queue lock.
*/
-static void dm_end_request(struct request *clone, int error)
+static void dm_end_request(struct request *clone, struct request *rq,
+ int error)
{
- struct dm_rq_target_io *tio = clone->end_io_data;
- struct request *rq = tio->orig;
-
if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
rq->errors = clone->errors;
rq->resid_len = clone->resid_len;
@@ -896,7 +886,6 @@ static void dm_end_request(struct request *clone, int error)
rq->sense_len = clone->sense_len;
}
- free_rq_clone(clone);
blk_end_request_all(rq, error);
}
@@ -967,14 +956,16 @@ static void dm_done(struct request *clone, struct dm_rq_target_io *tio,
r = rq_end_io(tio->ti, clone, tio->error, &tio->info);
}
+ free_rq_tio(tio);
if (r <= 0) {
/* The target wants to complete the I/O */
- dm_end_request(clone, r);
+ dm_end_request(clone, rq, r);
+ blk_rq_unprep_clone(clone);
rq_completed(md, rw, true);
} else if (r == DM_ENDIO_REQUEUE) {
/* The target wants to requeue the I/O */
- free_rq_clone(clone);
dm_requeue_unmapped_request(rq);
+ blk_rq_unprep_clone(clone);
rq_completed(md, rw, false);
} else {
DMWARN("unimplemented target endio return value: %d", r);
@@ -1601,7 +1592,8 @@ static int map_request(struct dm_target *ti, struct request *clone,
break;
case DM_MAPIO_REQUEUE:
/* The target wants to requeue the I/O */
- free_rq_clone(clone);
+ free_rq_tio(tio);
+ blk_rq_unprep_clone(clone);
dm_requeue_unmapped_request(rq);
rq_completed(md, rw, false);
requeued = 1;
Signed-off-by: Hannes Reinecke <hare@suse.de> --- drivers/md/dm.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)