Print the sequences of contructor/destructor, suspend/resume and exception handover. This is for checking that LVM performs the operations in right order, it is not meant for productivity. Signed-off-by: Mikulas Patocka --- drivers/md/dm-snap.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) Index: linux-2.6.27-rc3-devel/drivers/md/dm-snap.c =================================================================== --- linux-2.6.27-rc3-devel.orig/drivers/md/dm-snap.c 2008-08-15 15:55:17.000000000 +0200 +++ linux-2.6.27-rc3-devel/drivers/md/dm-snap.c 2008-08-15 15:57:03.000000000 +0200 @@ -791,6 +791,8 @@ static int snapshot_ctr(struct dm_target s->type = persistent; + printk("snapshot_ctr (%s, %s, m:%d)\n", s->origin->name, s->cow->name, is_merge(ti)); + s->valid = 1; s->active = 0; s->handover = 0; @@ -948,11 +950,14 @@ static void snapshot_dtr(struct dm_targe struct dm_snapshot *dup; + printk("snapshot_dtr (%s, %s, m:%d)\n", s->origin->name, s->cow->name, is_merge(ti)); + down_write(&_origins_lock); down_write(&s->lock); dup = find_duplicate(s); if (dup && dup->handover) { down_write_nested(&dup->lock, SINGLE_DEPTH_NESTING); + printk("handover 1\n"); handover_exceptions(s, dup); up_write(&dup->lock); } @@ -1365,10 +1370,25 @@ static int snapshot_end_io(struct dm_tar return 0; } +static void snapshot_presuspend(struct dm_target *ti) +{ + struct dm_snapshot *s = ti->private; + printk("snapshot_presuspend (%s, %s)\n", s->origin->name, s->cow->name); +} + +static void snapshot_postsuspend(struct dm_target *ti) +{ + struct dm_snapshot *s = ti->private; + printk("snapshot_postsuspend (%s, %s)\n", s->origin->name, s->cow->name); +} + static void snapshot_resume(struct dm_target *ti) { struct dm_snapshot *s = ti->private; + if (!is_merge(ti)) + printk("snapshot_resume (%s, %s)\n", s->origin->name, s->cow->name); + down_write(&_origins_lock); down_write(&s->lock); if (s->handover) { @@ -1380,6 +1400,7 @@ static void snapshot_resume(struct dm_ta goto ret; } down_write_nested(&dup->lock, SINGLE_DEPTH_NESTING); + printk("handover 2\n"); handover_exceptions(dup, s); up_write(&dup->lock); } @@ -1393,6 +1414,8 @@ static void snapshot_merge_resume(struct { struct dm_snapshot *s = ti->private; + printk("snapshot_merge_resume (%s, %s)\n", s->origin->name, s->cow->name); + snapshot_resume(ti); start_merge(s); } @@ -1401,9 +1424,17 @@ static void snapshot_merge_presuspend(st { struct dm_snapshot *s = ti->private; + printk("snapshot_merge_presuspend (%s, %s)\n", s->origin->name, s->cow->name); stop_merge(s); } +static void snapshot_merge_postsuspend(struct dm_target *ti) +{ + struct dm_snapshot *s = ti->private; + + printk("snapshot_merge_postsuspend (%s, %s)\n", s->origin->name, s->cow->name); +} + static int snapshot_status(struct dm_target *ti, status_type_t type, char *result, unsigned int maxlen) { @@ -1580,6 +1611,8 @@ static int origin_ctr(struct dm_target * return r; } + printk("origin_ctr (%s)\n", dev->name); + ti->private = dev; return 0; } @@ -1588,6 +1621,8 @@ static void origin_dtr(struct dm_target { struct dm_dev *dev = ti->private; + printk("origin_dtr (%s)\n", dev->name); + dm_put_device(ti, dev); } @@ -1601,6 +1636,18 @@ static int origin_map(struct dm_target * return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : DM_MAPIO_REMAPPED; } +static void origin_presuspend(struct dm_target *ti) +{ + struct dm_dev *dev = ti->private; + printk("origin_presuspend (%s)\n", dev->name); +} + +static void origin_postsuspend(struct dm_target *ti) +{ + struct dm_dev *dev = ti->private; + printk("origin_postsuspend (%s)\n", dev->name); +} + /* * Set the target "split_io" field to the minimum of all the snapshots' * chunk sizes. @@ -1610,6 +1657,8 @@ static void origin_resume(struct dm_targ struct dm_dev *dev = ti->private; struct origin *o; + printk("origin_resume (%s)\n", dev->name); + down_read(&_origins_lock); o = __lookup_origin(dev->bdev); ti->split_io = minimum_chunk_size(o); @@ -1641,6 +1690,8 @@ static struct target_type origin_target .ctr = origin_ctr, .dtr = origin_dtr, .map = origin_map, + .presuspend = origin_presuspend, + .postsuspend = origin_postsuspend, .resume = origin_resume, .status = origin_status, }; @@ -1653,6 +1704,8 @@ static struct target_type snapshot_targe .dtr = snapshot_dtr, .map = snapshot_map, .end_io = snapshot_end_io, + .presuspend = snapshot_presuspend, + .postsuspend = snapshot_postsuspend, .resume = snapshot_resume, .status = snapshot_status, }; @@ -1666,6 +1719,7 @@ static struct target_type snapshot_merge .map = snapshot_merge_map, .end_io = snapshot_end_io, .presuspend = snapshot_merge_presuspend, + .postsuspend = snapshot_merge_postsuspend, .resume = snapshot_merge_resume, .status = snapshot_status, };