Hook the io before we call the targets map function, this allows us to implement little things like the zero target. --- diff/drivers/md/dm.c 2003-01-16 11:15:19.000000000 +0000 +++ source/drivers/md/dm.c 2003-02-13 10:42:13.000000000 +0000 @@ -349,28 +349,23 @@ int rw, struct buffer_head *bh, struct dm_io *io) { - int r; struct dm_target *ti; ti = dm_table_find_target(md->map, bh->b_rsector); if (!ti) return -EINVAL; - r = ti->type->map(ti, bh, rw, &io->map_context); - - if (r >= 0) { - /* hook the end io request fn */ - atomic_inc(&md->pending); - io->md = md; - io->ti = ti; - io->rw = rw; - io->end_io = bh->b_end_io; - io->context = bh->b_private; - bh->b_end_io = dec_pending; - bh->b_private = io; - } + /* hook the end io request fn */ + atomic_inc(&md->pending); + io->md = md; + io->ti = ti; + io->rw = rw; + io->end_io = bh->b_end_io; + io->context = bh->b_private; + bh->b_end_io = dec_pending; + bh->b_private = io; - return r; + return ti->type->map(ti, bh, rw, &io->map_context); } /* @@ -443,7 +438,6 @@ return r; bad: - free_io(md, io); buffer_IO_error(bh); up_read(&md->lock); dm_put(md);