Allow the map method to pass some context to the endio method. --- diff/drivers/md/dm-linear.c 2002-11-29 09:44:59.000000000 +0000 +++ source/drivers/md/dm-linear.c 2003-01-10 11:49:27.000000000 +0000 @@ -64,7 +64,8 @@ kfree(lc); } -static int linear_map(struct dm_target *ti, struct buffer_head *bh, int rw) +static int linear_map(struct dm_target *ti, struct buffer_head *bh, int rw, + void **map_context) { struct linear_c *lc = (struct linear_c *) ti->private; --- diff/drivers/md/dm-snapshot.c 2003-01-10 10:47:54.000000000 +0000 +++ source/drivers/md/dm-snapshot.c 2003-01-10 11:49:27.000000000 +0000 @@ -785,7 +785,8 @@ (bh->b_rsector & s->chunk_mask); } -static int snapshot_map(struct dm_target *ti, struct buffer_head *bh, int rw) +static int snapshot_map(struct dm_target *ti, struct buffer_head *bh, int rw, + void **map_context) { struct exception *e; struct dm_snapshot *s = (struct dm_snapshot *) ti->private; @@ -1028,7 +1029,8 @@ dm_put_device(ti, dev); } -static int origin_map(struct dm_target *ti, struct buffer_head *bh, int rw) +static int origin_map(struct dm_target *ti, struct buffer_head *bh, int rw, + void **map_context) { struct dm_dev *dev = (struct dm_dev *) ti->private; bh->b_rdev = dev->dev; --- diff/drivers/md/dm-stripe.c 2002-11-29 09:46:30.000000000 +0000 +++ source/drivers/md/dm-stripe.c 2003-01-10 11:49:27.000000000 +0000 @@ -186,7 +186,8 @@ kfree(sc); } -static int stripe_map(struct dm_target *ti, struct buffer_head *bh, int rw) +static int stripe_map(struct dm_target *ti, struct buffer_head *bh, int rw, + void **context) { struct stripe_c *sc = (struct stripe_c *) ti->private; --- diff/drivers/md/dm-target.c 2003-01-10 10:20:03.000000000 +0000 +++ source/drivers/md/dm-target.c 2003-01-10 11:49:27.000000000 +0000 @@ -159,7 +159,8 @@ /* empty */ } -static int io_err_map(struct dm_target *ti, struct buffer_head *bh, int rw) +static int io_err_map(struct dm_target *ti, struct buffer_head *bh, int rw, + void **map_context) { return -EIO; } --- diff/drivers/md/dm.c 2003-01-10 11:43:50.000000000 +0000 +++ source/drivers/md/dm.c 2003-01-10 11:49:27.000000000 +0000 @@ -30,6 +30,7 @@ struct dm_target *ti; int rw; + void *map_context; void (*end_io) (struct buffer_head * bh, int uptodate); void *context; }; @@ -320,7 +321,8 @@ dm_endio_fn endio = io->ti->type->end_io; if (endio) { - r = endio(io->ti, bh, io->rw, uptodate ? 0 : -EIO); + r = endio(io->ti, bh, io->rw, uptodate ? 0 : -EIO, + io->map_context); if (r < 0) uptodate = 0; @@ -354,7 +356,7 @@ if (!ti) return -EINVAL; - r = ti->type->map(ti, bh, rw); + r = ti->type->map(ti, bh, rw, &io->map_context); if (r >= 0) { /* hook the end io request fn */ @@ -469,6 +471,7 @@ { struct buffer_head bh; struct dm_target *ti; + void *map_context; int r; if (test_bit(DMF_BLOCK_IO, &md->flags)) { @@ -490,7 +493,8 @@ ti = dm_table_find_target(md->map, bh.b_rsector); /* do the mapping */ - r = ti->type->map(ti, &bh, READ); + r = ti->type->map(ti, &bh, READ, &map_context); + ti->type->end_io(ti, &bh, READ, 0, map_context); if (!r) { *r_dev = bh.b_rdev; --- diff/include/linux/device-mapper.h 2003-01-10 11:36:08.000000000 +0000 +++ source/include/linux/device-mapper.h 2003-01-10 11:49:27.000000000 +0000 @@ -33,7 +33,8 @@ * = 0: The target will handle the io by resubmitting it later * > 0: simple remap complete */ -typedef int (*dm_map_fn) (struct dm_target *ti, struct buffer_head *bh, int rw); +typedef int (*dm_map_fn) (struct dm_target *ti, struct buffer_head *bh, int rw, + void **map_context); /* * Returns: @@ -43,7 +44,8 @@ * multipath target might want to requeue a failed io). */ typedef int (*dm_endio_fn) (struct dm_target *ti, - struct buffer_head *bh, int rw, int error); + struct buffer_head *bh, int rw, int error, + void *map_context); typedef int (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, char *result, int maxlen);