Introduce "lockspace_handle" variable. Unload the handle when unloading the module. The handle will be loaded when clustered arguments are supplied, in some of the next patches. Signed-off-by: Mikulas Patocka --- drivers/md/dm-exception-store.h | 4 ++++ drivers/md/dm-snap.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) Index: linux-2.6.31-fast/drivers/md/dm-snap.c =================================================================== --- linux-2.6.31-fast.orig/drivers/md/dm-snap.c 2009-10-16 21:52:48.000000000 +0200 +++ linux-2.6.31-fast/drivers/md/dm-snap.c 2009-10-19 12:07:40.000000000 +0200 @@ -23,6 +23,10 @@ #include "dm-exception-store.h" +#ifdef CLUSTER_SNAPSHOTS +#include "dm-cluster-locking.h" +#endif + #define DM_MSG_PREFIX "snapshots" /* @@ -49,6 +53,10 @@ #define DM_TRACKED_CHUNK_HASH(x) ((unsigned long)(x) & \ (DM_TRACKED_CHUNK_HASH_SIZE - 1)) +#ifdef CLUSTER_SNAPSHOTS +static void *lockspace_handle = NULL; +#endif + struct dm_exception_table { uint32_t hash_mask; unsigned hash_shift; @@ -2023,6 +2031,11 @@ bad_register_snapshot_target: static void __exit dm_snapshot_exit(void) { +#ifdef CLUSTER_SNAPSHOTS + if (lockspace_handle) + dm_cluster_lock_exit(lockspace_handle); +#endif + dm_unregister_target(&snapshot_target); dm_unregister_target(&origin_target); dm_unregister_target(&merge_target); Index: linux-2.6.31-fast/drivers/md/dm-exception-store.h =================================================================== --- linux-2.6.31-fast.orig/drivers/md/dm-exception-store.h 2009-10-16 21:51:55.000000000 +0200 +++ linux-2.6.31-fast/drivers/md/dm-exception-store.h 2009-10-19 12:05:53.000000000 +0200 @@ -13,6 +13,10 @@ #include #include +#if defined(CONFIG_DM_CLUSTER_LOCKING) || (defined(CONFIG_DM_SNAPSHOT_MODULE) && defined(CONFIG_DM_CLUSTER_LOCKING_MODULE)) +#define CLUSTER_SNAPSHOTS +#endif + /* * The snapshot code deals with largish chunks of the disk at a * time. Typically 32k - 512k.