Add an endio method to targets.
--- diff/drivers/md/dm.c	2002-12-10 10:44:14.000000000 +0000
+++ source/drivers/md/dm.c	2002-12-12 17:22:27.000000000 +0000
@@ -28,6 +28,7 @@
 struct dm_io {
 	struct mapped_device *md;
 
+	struct dm_target *ti;
 	void (*end_io) (struct buffer_head * bh, int uptodate);
 	void *context;
 };
@@ -315,10 +316,14 @@
 {
 	struct dm_io *io = bh->b_private;
 
-	if (atomic_dec_and_test(&io->md->pending))
+	if (atomic_dec_and_test(&io->md->pending)) {
 		/* nudge anyone waiting on suspend queue */
 		wake_up(&io->md->wait);
 
+		if (io->ti->type->end_io)
+			io->ti->type->end_io(io->ti, bh, uptodate ? 0 : -EIO);
+	}
+
 	bh->b_end_io = io->end_io;
 	bh->b_private = io->context;
 	free_io(io->md, io);
@@ -346,6 +351,7 @@
 		/* hook the end io request fn */
 		atomic_inc(&md->pending);
 		io->md = md;
+		io->ti = ti;
 		io->end_io = bh->b_end_io;
 		io->context = bh->b_private;
 		bh->b_end_io = dec_pending;
--- diff/include/linux/device-mapper.h	2002-11-13 17:21:58.000000000 +0000
+++ source/include/linux/device-mapper.h	2002-12-12 17:17:48.000000000 +0000
@@ -34,6 +34,8 @@
  * > 0: simple remap complete
  */
 typedef int (*dm_map_fn) (struct dm_target *ti, struct buffer_head *bh, int rw);
+typedef int (*dm_endio_fn) (struct dm_target *ti,
+			    struct buffer_head *bh, int error);
 typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,
 			     char *result, int maxlen);
 
@@ -57,6 +59,7 @@
 	dm_ctr_fn ctr;
 	dm_dtr_fn dtr;
 	dm_map_fn map;
+	dm_endio_fn end_io;
 	dm_status_fn status;
 };