Add a new target snapshot-merge. For now, the target is identical to snapshot. Signed-off-by: Mikulas Patocka --- drivers/md/dm-snap.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) Index: linux-2.6.26-rc8/drivers/md/dm-snap.c =================================================================== --- linux-2.6.26-rc8.orig/drivers/md/dm-snap.c 2008-07-01 18:52:52.000000000 +0200 +++ linux-2.6.26-rc8/drivers/md/dm-snap.c 2008-07-01 18:52:59.000000000 +0200 @@ -1370,14 +1370,26 @@ 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 bad0; } r = dm_register_target(&origin_target); @@ -1386,45 +1398,54 @@ static int __init dm_snapshot_init(void) goto bad1; } + r = dm_register_target(&snapshot_merge_target); + if (r < 0) { + DMERR("snapshot_merge target register failed %d", r); + goto bad2; + } + r = init_origin_hash(); if (r) { DMERR("init_origin_hash failed."); - goto bad2; + goto bad3; } exception_cache = KMEM_CACHE(dm_snap_exception, 0); if (!exception_cache) { DMERR("Couldn't create exception cache."); r = -ENOMEM; - goto bad3; + goto bad4; } pending_cache = KMEM_CACHE(dm_snap_pending_exception, 0); if (!pending_cache) { DMERR("Couldn't create pending cache."); r = -ENOMEM; - goto bad4; + goto bad5; } tracked_chunk_cache = KMEM_CACHE(dm_snap_tracked_chunk, 0); if (!tracked_chunk_cache) { DMERR("Couldn't create chunk in use cache."); r = -ENOMEM; - goto bad5; + goto bad6; } return 0; - bad5: + bad6: kmem_cache_destroy(pending_cache); - bad4: + bad5: kmem_cache_destroy(exception_cache); - bad3: + bad4: exit_origin_hash(); + bad3: + dm_unregister_target(&snapshot_merge_target); bad2: dm_unregister_target(&origin_target); bad1: dm_unregister_target(&snapshot_target); + bad0: return r; } @@ -1440,6 +1461,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);