- s->pending = dm_exception_table_create(hash_size, 0,
- alloc_pending_exception, s,
- free_pending_exception, NULL);
- if (!s->pending) {
- ti->error = "Unable to allocate hash table space";
+ /*
+ * Allocate the snapshot
+ */
+ s = alloc_snapshot(hash_size);
+ if (!s) {
r = -ENOMEM;
- goto bad_hash_table;
- }
-
- r = dm_kcopyd_client_create(SNAPSHOT_PAGES, &s->kcopyd_client);
- if (r) {
- ti->error = "Could not create kcopyd client";
- goto bad_kcopyd;
- }
-
- s->pending_pool = mempool_create_slab_pool(MIN_IOS, pending_cache);
- if (!s->pending_pool) {
- ti->error = "Could not allocate mempool for pending exceptions";
- goto bad_pending_pool;
- }
-
- s->tracked_chunk_pool = mempool_create_slab_pool(MIN_IOS,
- tracked_chunk_cache);
- if (!s->tracked_chunk_pool) {
- ti->error = "Could not allocate tracked_chunk mempool for "
- "tracking reads";
- goto bad_tracked_chunk_pool;
+ ti->error = "Failed to create snapshot structure";
+ goto bad_alloc_snapshot;
}
- for (i = 0; i < DM_TRACKED_CHUNK_HASH_SIZE; i++)
- INIT_HLIST_HEAD(&s->tracked_chunk_hash[i]);
-
- spin_lock_init(&s->tracked_chunk_lock);
- bio_list_init(&s->queued_bios);
- INIT_WORK(&s->queued_bios_work, flush_queued_bios);
+ s->origin = origin;
+ s->store = store;
/* Add snapshot to the list of snapshots for this origin */
/* Exceptions aren't triggered till snapshot_resume() is called */
if (register_snapshot(s)) {
r = -EINVAL;
- ti->error = "Cannot register snapshot origin";
+ ti->error = "Cannot register snapshot with origin";
goto bad_load_and_register;
}
@@ -555,24 +604,12 @@ static int snapshot_ctr(struct dm_target
return 0;