Add a new target snapshot-merge. For now, the target is identical to snapshot. Signed-off-by: Mikulas Patocka --- drivers/md/dm-snap.c | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) Index: linux-2.6.26-devel/drivers/md/dm-snap.c =================================================================== --- linux-2.6.26-devel.orig/drivers/md/dm-snap.c 2008-07-14 20:16:55.000000000 +0200 +++ linux-2.6.26-devel/drivers/md/dm-snap.c 2008-07-14 20:21:36.000000000 +0200 @@ -1375,61 +1375,82 @@ static struct target_type snapshot_targe .status = snapshot_status, }; +static struct target_type snapshot_merge_target = { + .name = "snapshot-merge", + .version = {1, 6, 0}, + .module = THIS_MODULE, + .ctr = snapshot_ctr, + .dtr = snapshot_dtr, + .map = snapshot_map, + .end_io = snapshot_end_io, + .resume = snapshot_resume, + .status = snapshot_status, +}; + static int __init dm_snapshot_init(void) { int r; r = dm_register_target(&snapshot_target); - if (r) { + if (r < 0) { DMERR("snapshot target register failed %d", r); - return r; + goto bad_snapshot_target; } r = dm_register_target(&origin_target); if (r < 0) { DMERR("Origin target register failed %d", r); - goto bad1; + goto bad_origin_target; + } + + r = dm_register_target(&snapshot_merge_target); + if (r < 0) { + DMERR("snapshot_merge target register failed %d", r); + goto bad_snapshot_merge_target; } r = init_origin_hash(); if (r) { DMERR("init_origin_hash failed."); - goto bad2; + goto bad_origin_hash; } exception_cache = KMEM_CACHE(dm_snap_exception, 0); if (!exception_cache) { DMERR("Couldn't create exception cache."); r = -ENOMEM; - goto bad3; + goto bad_exception_cache; } pending_cache = KMEM_CACHE(dm_snap_pending_exception, 0); if (!pending_cache) { DMERR("Couldn't create pending cache."); r = -ENOMEM; - goto bad4; + goto bad_pending_cache; } tracked_chunk_cache = KMEM_CACHE(dm_snap_tracked_chunk, 0); if (!tracked_chunk_cache) { DMERR("Couldn't create cache to track chunks in use."); r = -ENOMEM; - goto bad5; + goto bad_tracked_chunk_cache; } return 0; - bad5: + bad_tracked_chunk_cache: kmem_cache_destroy(pending_cache); - bad4: + bad_pending_cache: kmem_cache_destroy(exception_cache); - bad3: + bad_exception_cache: exit_origin_hash(); - bad2: + bad_origin_hash: + dm_unregister_target(&snapshot_merge_target); + bad_snapshot_merge_target: dm_unregister_target(&origin_target); - bad1: + bad_origin_target: dm_unregister_target(&snapshot_target); + bad_snapshot_target: return r; } @@ -1445,6 +1466,10 @@ static void __exit dm_snapshot_exit(void if (r) DMERR("origin unregister failed %d", r); + r = dm_unregister_target(&snapshot_merge_target); + if (r) + DMERR("snapshot_merge unregister failed %d", r); + exit_origin_hash(); kmem_cache_destroy(pending_cache); kmem_cache_destroy(exception_cache);