This is the first step to replace 'read_metadata' with 'resume'.
'resume' will populate the exception store implementation's
exception cache - rather than loading the snapshot's exception
cache.
Relocating the 'resume' is more in line with the way device-mapper
targets (and device-mapper mirror logs) work. Additionally, with
future shared exception store types, we don't duplicate the cache.
@@ -496,6 +516,13 @@ static int persistent_read_metadata(stru
int r, uninitialized_var(new_snapshot);
struct pstore *ps = get_info(store);
+ if (ps->callbacks)
+ /*
+ * Temporary work around for having two different functions
+ * that get us going... 'read_metadata' and 'resume'.
+ */
+ goto read_metadata;
+
/*
* Read the snapshot header.
*/
@@ -507,7 +534,7 @@ static int persistent_read_metadata(stru
* Now we know correct chunk_size, complete the initialisation.
*/
ps->exceptions_per_area = (ps->store->chunk_size << SECTOR_SHIFT) /
- sizeof(struct disk_exception);
+ sizeof(struct disk_exception);
ps->callbacks = dm_vcalloc(ps->exceptions_per_area,
sizeof(*ps->callbacks));
if (!ps->callbacks)
@@ -548,11 +575,44 @@ static int persistent_read_metadata(stru
/*
* Read the metadata.
*/
+read_metadata:
r = read_exceptions(ps, callback, callback_context);
return r;
}
+/* This function is temporary for patch cleanliness */
+static int add_exception(void *context, chunk_t old, chunk_t new)
+{
+ struct dm_exception_store *store = context;
+ struct pstore *ps = get_info(store);
+ struct dm_exception *e;
+
+ e = dm_alloc_exception(ps->table);
+ if (!e)
+ return -ENOMEM;
+
+ e->old_chunk = old;
+ e->new_chunk = new;
+
+ dm_insert_exception(ps->table, e);
+
+ return 0;
+}
+
+/*
+ * persistent_resume
+ * @store
+ *
+ * Read metadata of the disk and store in our exception table cache.
+ *
+ * Returns: 0 on success, -Exxx on error
+ */
+static int persistent_resume(struct dm_exception_store *store)
+{
+ return persistent_read_metadata(store, add_exception, store);
+}
+
static int persistent_prepare_exception(struct dm_exception_store *store,
struct dm_exception *e)
{
@@ -655,6 +715,7 @@ static int persistent_ctr(struct dm_exce
unsigned argc, char **argv)
{
struct pstore *ps;
+ sector_t hash_size, cow_dev_size, max_buckets;
+ /*
+ * Target resumes cannot fail, which leaves us in a tight spot.
+ * We read the exception store, the snapshot may be invalid
+ * or we may have failed to resume for a different reason (EIO?).
+ * If invalid, mark the snapshot as such. However, if other,
+ * what can we do? Mark 'not active'?
+ */
+ r = s->store->type->resume(s->store);
+ if (r == -EINVAL)
+ r = s->valid = 0;
+
down_write(&s->lock);
- s->active = 1;
+ s->active = (r) ? 0 : 1;
up_write(&s->lock);
}
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
03-17-2009, 01:04 PM
Jonathan Brassow
dm-exception-store-add-resume-to-API.patch
Add 'resume' to exception store API.
This is the first step to replace 'read_metadata' with 'resume'.
'resume' will populate the exception store implementation's
exception cache - rather than loading the snapshot's exception
cache.
Relocating the 'resume' is more in line with the way device-mapper
targets (and device-mapper mirror logs) work. Additionally, with
future shared exception store types, we don't duplicate the cache.
/* Don't need to check these, because they are done in ctr */
destroy_workqueue(ps->metadata_wq);
+ dm_exception_table_destroy(ps->table);
kfree(ps);
}
@@ -506,6 +526,13 @@ static int persistent_read_metadata(stru
int r, uninitialized_var(new_snapshot);
struct pstore *ps = get_info(store);
+ if (ps->callbacks)
+ /*
+ * Temporary work around for having two different functions
+ * that get us going... 'read_metadata' and 'resume'.
+ */
+ goto read_metadata;
+
/*
* Read the snapshot header.
*/
@@ -517,7 +544,7 @@ static int persistent_read_metadata(stru
* Now we know correct chunk_size, complete the initialisation.
*/
ps->exceptions_per_area = (ps->store->chunk_size << SECTOR_SHIFT) /
- sizeof(struct disk_exception);
+ sizeof(struct disk_exception);
ps->callbacks = dm_vcalloc(ps->exceptions_per_area,
sizeof(*ps->callbacks));
if (!ps->callbacks)
@@ -558,11 +585,44 @@ static int persistent_read_metadata(stru
/*
* Read the metadata.
*/
+read_metadata:
r = read_exceptions(ps, callback, callback_context);
return r;
}
+/* This function is temporary for patch cleanliness */
+static int add_exception(void *context, chunk_t old, chunk_t new)
+{
+ struct dm_exception_store *store = context;
+ struct pstore *ps = get_info(store);
+ struct dm_exception *e;
+
+ e = dm_alloc_exception(ps->table);
+ if (!e)
+ return -ENOMEM;
+
+ e->old_chunk = old;
+ e->new_chunk = new;
+
+ dm_insert_exception(ps->table, e);
+
+ return 0;
+}
+
+/*
+ * persistent_resume
+ * @store
+ *
+ * Read metadata of the disk and store in our exception table cache.
+ *
+ * Returns: 0 on success, -Exxx on error
+ */
+static int persistent_resume(struct dm_exception_store *store)
+{
+ return persistent_read_metadata(store, add_exception, store);
+}
+
static int persistent_prepare_exception(struct dm_exception_store *store,
struct dm_exception *e)
{
@@ -665,6 +725,7 @@ static int persistent_ctr(struct dm_exce
unsigned argc, char **argv)
{
struct pstore *ps;
+ sector_t hash_size, cow_dev_size, max_buckets;
+ /*
+ * Target resumes cannot fail, which leaves us in a tight spot.
+ * We read the exception store, the snapshot may be invalid
+ * or we may have failed to resume for a different reason (EIO?).
+ * If invalid, mark the snapshot as such. However, if other,
+ * what can we do? Mark 'not active'?
+ */
+ r = s->store->type->resume(s->store);
+ if (r == -EINVAL)
+ r = s->valid = 0;
+
down_write(&s->lock);
- s->active = 1;
+ s->active = (r) ? 0 : 1;
up_write(&s->lock);
}
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel