aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/dm.c13
-rw-r--r--drivers/md/dm.h11
-rw-r--r--include/linux/device-mapper.h2
3 files changed, 22 insertions, 4 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b42e71bb9e67..d8544e1a4c1f 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -482,9 +482,13 @@ static int clone_endio(struct bio *bio, unsigned int done, int error)
482 r = endio(tio->ti, bio, error, &tio->info); 482 r = endio(tio->ti, bio, error, &tio->info);
483 if (r < 0) 483 if (r < 0)
484 error = r; 484 error = r;
485 else if (r > 0) 485 else if (r == DM_ENDIO_INCOMPLETE)
486 /* the target wants another shot at the io */ 486 /* The target will handle the io */
487 return 1; 487 return 1;
488 else if (r) {
489 DMWARN("unimplemented target endio return value: %d", r);
490 BUG();
491 }
488 } 492 }
489 493
490 dec_pending(tio->io, error); 494 dec_pending(tio->io, error);
@@ -542,7 +546,7 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
542 atomic_inc(&tio->io->io_count); 546 atomic_inc(&tio->io->io_count);
543 sector = clone->bi_sector; 547 sector = clone->bi_sector;
544 r = ti->type->map(ti, clone, &tio->info); 548 r = ti->type->map(ti, clone, &tio->info);
545 if (r > 0) { 549 if (r == DM_MAPIO_REMAPPED) {
546 /* the bio has been remapped so dispatch it */ 550 /* the bio has been remapped so dispatch it */
547 551
548 blk_add_trace_remap(bdev_get_queue(clone->bi_bdev), clone, 552 blk_add_trace_remap(bdev_get_queue(clone->bi_bdev), clone,
@@ -560,6 +564,9 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
560 clone->bi_private = md->bs; 564 clone->bi_private = md->bs;
561 bio_put(clone); 565 bio_put(clone);
562 free_tio(md, tio); 566 free_tio(md, tio);
567 } else if (r) {
568 DMWARN("unimplemented target map return value: %d", r);
569 BUG();
563 } 570 }
564} 571}
565 572
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index 81c98d6e35e9..293d5ce62a21 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -33,6 +33,17 @@
33#define SECTOR_SHIFT 9 33#define SECTOR_SHIFT 9
34 34
35/* 35/*
36 * Definitions of return values from target end_io function.
37 */
38#define DM_ENDIO_INCOMPLETE 1
39
40/*
41 * Definitions of return values from target map function.
42 */
43#define DM_MAPIO_SUBMITTED 0
44#define DM_MAPIO_REMAPPED 1
45
46/*
36 * Suspend feature flags 47 * Suspend feature flags
37 */ 48 */
38#define DM_SUSPEND_LOCKFS_FLAG (1 << 0) 49#define DM_SUSPEND_LOCKFS_FLAG (1 << 0)
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 9194ff2d08c0..2e5c42346c38 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -39,7 +39,7 @@ typedef void (*dm_dtr_fn) (struct dm_target *ti);
39 * The map function must return: 39 * The map function must return:
40 * < 0: error 40 * < 0: error
41 * = 0: The target will handle the io by resubmitting it later 41 * = 0: The target will handle the io by resubmitting it later
42 * > 0: simple remap complete 42 * = 1: simple remap complete
43 */ 43 */
44typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio, 44typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
45 union map_info *map_context); 45 union map_info *map_context);