Store the uuid argument in "struct dm_snapshot" structure. Signed-off-by: Mikulas Patocka --- drivers/md/dm-snap.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) Index: linux-2.6.31-fast/drivers/md/dm-snap.c =================================================================== --- linux-2.6.31-fast.orig/drivers/md/dm-snap.c 2009-10-19 12:07:40.000000000 +0200 +++ linux-2.6.31-fast/drivers/md/dm-snap.c 2009-10-19 12:50:23.000000000 +0200 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "dm-exception-store.h" @@ -150,6 +151,8 @@ struct dm_snapshot { * of racing with merge */ struct bio_list merge_write_list; + + char lockid[DM_UUID_LEN]; }; struct dm_dev *dm_snap_cow(struct dm_snapshot *s) @@ -180,6 +183,8 @@ static int snapshot_merge_map(struct dm_ #define is_merge(ti) ((ti)->type->map == snapshot_merge_map) +#define is_clustered(s) ((s)->lockid[0]) + struct dm_snap_pending_exception { struct dm_exception e; @@ -894,8 +899,8 @@ static int snapshot_ctr(struct dm_target char *origin_path, *cow_path; unsigned args_used; - if (argc != 4) { - ti->error = "requires exactly 4 arguments"; + if (argc < 4) { + ti->error = "requires at least 4 arguments"; r = -EINVAL; goto bad; } @@ -923,6 +928,28 @@ static int snapshot_ctr(struct dm_target goto bad_cow; } + s->lockid[0] = 0; + if (argc >= 2 && !strcmp(argv[0], "cluster-lock")) { + + /* prevent concurrent creation of lockspace handle */ + down_write(&_origins_lock); + if (!lockspace_handle) { + lockspace_handle = dm_cluster_lock_init("dm-snap"); + if (IS_ERR(lockspace_handle)) + lockspace_handle = NULL; + } + up_write(&_origins_lock); + + if (!lockspace_handle || is_merge(ti)) { + ti->error = "Clustering not supported"; + r = -EINVAL; + goto bad_clustering; + } + strlcpy(s->lockid, argv[1], sizeof s->lockid); + argv += 2; + argc -= 2; + } + r = dm_exception_store_create(ti, argc, argv, s, &args_used, &s->store); if (r) { ti->error = "Couldn't create exception store"; @@ -1069,6 +1096,7 @@ bad_hash_tables: bad_origin: dm_exception_store_destroy(s->store); +bad_clustering: bad_store: dm_put_device(ti, s->cow); @@ -1675,6 +1703,9 @@ static int snapshot_status(struct dm_tar DMEMIT("%s %s", snap->origin->name, snap->cow->name); snap->store->type->status(snap->store, type, result + sz, maxlen - sz); + sz = strlen(result); + if (is_clustered(snap)) + snprintf(result + sz, maxlen - sz, " %s", snap->lockid); break; }