提交 3510cb94 编写于 作者: J Jon Brassow 提交者: Alasdair G Kergon

dm snapshot: rename exception functions

Rename exception functions.  Preparing to pull them out of
dm-snap.c for broader use.
Signed-off-by: NJonathan Brassow <jbrassow@redhat.com>
Reviewed-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
上级 191437a5
...@@ -351,8 +351,8 @@ static void unregister_snapshot(struct dm_snapshot *s) ...@@ -351,8 +351,8 @@ static void unregister_snapshot(struct dm_snapshot *s)
* The lowest hash_shift bits of the chunk number are ignored, allowing * The lowest hash_shift bits of the chunk number are ignored, allowing
* some consecutive chunks to be grouped together. * some consecutive chunks to be grouped together.
*/ */
static int init_exception_table(struct dm_exception_table *et, uint32_t size, static int dm_exception_table_init(struct dm_exception_table *et,
unsigned hash_shift) uint32_t size, unsigned hash_shift)
{ {
unsigned int i; unsigned int i;
...@@ -368,7 +368,7 @@ static int init_exception_table(struct dm_exception_table *et, uint32_t size, ...@@ -368,7 +368,7 @@ static int init_exception_table(struct dm_exception_table *et, uint32_t size,
return 0; return 0;
} }
static void exit_exception_table(struct dm_exception_table *et, static void dm_exception_table_exit(struct dm_exception_table *et,
struct kmem_cache *mem) struct kmem_cache *mem)
{ {
struct list_head *slot; struct list_head *slot;
...@@ -391,7 +391,7 @@ static uint32_t exception_hash(struct dm_exception_table *et, chunk_t chunk) ...@@ -391,7 +391,7 @@ static uint32_t exception_hash(struct dm_exception_table *et, chunk_t chunk)
return (chunk >> et->hash_shift) & et->hash_mask; return (chunk >> et->hash_shift) & et->hash_mask;
} }
static void remove_exception(struct dm_exception *e) static void dm_remove_exception(struct dm_exception *e)
{ {
list_del(&e->hash_list); list_del(&e->hash_list);
} }
...@@ -400,7 +400,7 @@ static void remove_exception(struct dm_exception *e) ...@@ -400,7 +400,7 @@ static void remove_exception(struct dm_exception *e)
* Return the exception data for a sector, or NULL if not * Return the exception data for a sector, or NULL if not
* remapped. * remapped.
*/ */
static struct dm_exception *lookup_exception(struct dm_exception_table *et, static struct dm_exception *dm_lookup_exception(struct dm_exception_table *et,
chunk_t chunk) chunk_t chunk)
{ {
struct list_head *slot; struct list_head *slot;
...@@ -415,7 +415,7 @@ static struct dm_exception *lookup_exception(struct dm_exception_table *et, ...@@ -415,7 +415,7 @@ static struct dm_exception *lookup_exception(struct dm_exception_table *et,
return NULL; return NULL;
} }
static struct dm_exception *alloc_exception(void) static struct dm_exception *alloc_completed_exception(void)
{ {
struct dm_exception *e; struct dm_exception *e;
...@@ -426,7 +426,7 @@ static struct dm_exception *alloc_exception(void) ...@@ -426,7 +426,7 @@ static struct dm_exception *alloc_exception(void)
return e; return e;
} }
static void free_exception(struct dm_exception *e) static void free_completed_exception(struct dm_exception *e)
{ {
kmem_cache_free(exception_cache, e); kmem_cache_free(exception_cache, e);
} }
...@@ -451,7 +451,7 @@ static void free_pending_exception(struct dm_snap_pending_exception *pe) ...@@ -451,7 +451,7 @@ static void free_pending_exception(struct dm_snap_pending_exception *pe)
atomic_dec(&s->pending_exceptions_count); atomic_dec(&s->pending_exceptions_count);
} }
static void insert_exception(struct dm_exception_table *eh, static void dm_insert_exception(struct dm_exception_table *eh,
struct dm_exception *new_e) struct dm_exception *new_e)
{ {
struct list_head *l; struct list_head *l;
...@@ -471,7 +471,7 @@ static void insert_exception(struct dm_exception_table *eh, ...@@ -471,7 +471,7 @@ static void insert_exception(struct dm_exception_table *eh,
new_e->new_chunk == (dm_chunk_number(e->new_chunk) + new_e->new_chunk == (dm_chunk_number(e->new_chunk) +
dm_consecutive_chunk_count(e) + 1)) { dm_consecutive_chunk_count(e) + 1)) {
dm_consecutive_chunk_count_inc(e); dm_consecutive_chunk_count_inc(e);
free_exception(new_e); free_completed_exception(new_e);
return; return;
} }
...@@ -481,7 +481,7 @@ static void insert_exception(struct dm_exception_table *eh, ...@@ -481,7 +481,7 @@ static void insert_exception(struct dm_exception_table *eh,
dm_consecutive_chunk_count_inc(e); dm_consecutive_chunk_count_inc(e);
e->old_chunk--; e->old_chunk--;
e->new_chunk--; e->new_chunk--;
free_exception(new_e); free_completed_exception(new_e);
return; return;
} }
...@@ -502,7 +502,7 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new) ...@@ -502,7 +502,7 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new)
struct dm_snapshot *s = context; struct dm_snapshot *s = context;
struct dm_exception *e; struct dm_exception *e;
e = alloc_exception(); e = alloc_completed_exception();
if (!e) if (!e)
return -ENOMEM; return -ENOMEM;
...@@ -511,7 +511,7 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new) ...@@ -511,7 +511,7 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new)
/* Consecutive_count is implicitly initialised to zero */ /* Consecutive_count is implicitly initialised to zero */
e->new_chunk = new; e->new_chunk = new;
insert_exception(&s->complete, e); dm_insert_exception(&s->complete, e);
return 0; return 0;
} }
...@@ -568,7 +568,7 @@ static int init_hash_tables(struct dm_snapshot *s) ...@@ -568,7 +568,7 @@ static int init_hash_tables(struct dm_snapshot *s)
if (hash_size < 64) if (hash_size < 64)
hash_size = 64; hash_size = 64;
hash_size = rounddown_pow_of_two(hash_size); hash_size = rounddown_pow_of_two(hash_size);
if (init_exception_table(&s->complete, hash_size, if (dm_exception_table_init(&s->complete, hash_size,
DM_CHUNK_CONSECUTIVE_BITS)) DM_CHUNK_CONSECUTIVE_BITS))
return -ENOMEM; return -ENOMEM;
...@@ -580,8 +580,8 @@ static int init_hash_tables(struct dm_snapshot *s) ...@@ -580,8 +580,8 @@ static int init_hash_tables(struct dm_snapshot *s)
if (hash_size < 64) if (hash_size < 64)
hash_size = 64; hash_size = 64;
if (init_exception_table(&s->pending, hash_size, 0)) { if (dm_exception_table_init(&s->pending, hash_size, 0)) {
exit_exception_table(&s->complete, exception_cache); dm_exception_table_exit(&s->complete, exception_cache);
return -ENOMEM; return -ENOMEM;
} }
...@@ -716,8 +716,8 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -716,8 +716,8 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
dm_kcopyd_client_destroy(s->kcopyd_client); dm_kcopyd_client_destroy(s->kcopyd_client);
bad_kcopyd: bad_kcopyd:
exit_exception_table(&s->pending, pending_cache); dm_exception_table_exit(&s->pending, pending_cache);
exit_exception_table(&s->complete, exception_cache); dm_exception_table_exit(&s->complete, exception_cache);
bad_hash_tables: bad_hash_tables:
dm_put_device(ti, s->origin); dm_put_device(ti, s->origin);
...@@ -737,8 +737,8 @@ static void __free_exceptions(struct dm_snapshot *s) ...@@ -737,8 +737,8 @@ static void __free_exceptions(struct dm_snapshot *s)
dm_kcopyd_client_destroy(s->kcopyd_client); dm_kcopyd_client_destroy(s->kcopyd_client);
s->kcopyd_client = NULL; s->kcopyd_client = NULL;
exit_exception_table(&s->pending, pending_cache); dm_exception_table_exit(&s->pending, pending_cache);
exit_exception_table(&s->complete, exception_cache); dm_exception_table_exit(&s->complete, exception_cache);
} }
static void snapshot_dtr(struct dm_target *ti) static void snapshot_dtr(struct dm_target *ti)
...@@ -891,7 +891,7 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success) ...@@ -891,7 +891,7 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
goto out; goto out;
} }
e = alloc_exception(); e = alloc_completed_exception();
if (!e) { if (!e) {
down_write(&s->lock); down_write(&s->lock);
__invalidate_snapshot(s, -ENOMEM); __invalidate_snapshot(s, -ENOMEM);
...@@ -902,7 +902,7 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success) ...@@ -902,7 +902,7 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
down_write(&s->lock); down_write(&s->lock);
if (!s->valid) { if (!s->valid) {
free_exception(e); free_completed_exception(e);
error = 1; error = 1;
goto out; goto out;
} }
...@@ -918,10 +918,10 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success) ...@@ -918,10 +918,10 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
* Add a proper exception, and remove the * Add a proper exception, and remove the
* in-flight exception from the list. * in-flight exception from the list.
*/ */
insert_exception(&s->complete, e); dm_insert_exception(&s->complete, e);
out: out:
remove_exception(&pe->e); dm_remove_exception(&pe->e);
snapshot_bios = bio_list_get(&pe->snapshot_bios); snapshot_bios = bio_list_get(&pe->snapshot_bios);
origin_bios = put_pending_exception(pe); origin_bios = put_pending_exception(pe);
...@@ -989,7 +989,7 @@ static void start_copy(struct dm_snap_pending_exception *pe) ...@@ -989,7 +989,7 @@ static void start_copy(struct dm_snap_pending_exception *pe)
static struct dm_snap_pending_exception * static struct dm_snap_pending_exception *
__lookup_pending_exception(struct dm_snapshot *s, chunk_t chunk) __lookup_pending_exception(struct dm_snapshot *s, chunk_t chunk)
{ {
struct dm_exception *e = lookup_exception(&s->pending, chunk); struct dm_exception *e = dm_lookup_exception(&s->pending, chunk);
if (!e) if (!e)
return NULL; return NULL;
...@@ -1030,7 +1030,7 @@ __find_pending_exception(struct dm_snapshot *s, ...@@ -1030,7 +1030,7 @@ __find_pending_exception(struct dm_snapshot *s,
} }
get_pending_exception(pe); get_pending_exception(pe);
insert_exception(&s->pending, &pe->e); dm_insert_exception(&s->pending, &pe->e);
return pe; return pe;
} }
...@@ -1077,7 +1077,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio, ...@@ -1077,7 +1077,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
} }
/* If the block is already remapped - use that, else remap it */ /* If the block is already remapped - use that, else remap it */
e = lookup_exception(&s->complete, chunk); e = dm_lookup_exception(&s->complete, chunk);
if (e) { if (e) {
remap_exception(s, e, bio, chunk); remap_exception(s, e, bio, chunk);
goto out_unlock; goto out_unlock;
...@@ -1101,7 +1101,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio, ...@@ -1101,7 +1101,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
goto out_unlock; goto out_unlock;
} }
e = lookup_exception(&s->complete, chunk); e = dm_lookup_exception(&s->complete, chunk);
if (e) { if (e) {
free_pending_exception(pe); free_pending_exception(pe);
remap_exception(s, e, bio, chunk); remap_exception(s, e, bio, chunk);
...@@ -1254,7 +1254,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio) ...@@ -1254,7 +1254,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
* ref_count is initialised to 1 so pending_complete() * ref_count is initialised to 1 so pending_complete()
* won't destroy the primary_pe while we're inside this loop. * won't destroy the primary_pe while we're inside this loop.
*/ */
e = lookup_exception(&snap->complete, chunk); e = dm_lookup_exception(&snap->complete, chunk);
if (e) if (e)
goto next_snapshot; goto next_snapshot;
...@@ -1269,7 +1269,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio) ...@@ -1269,7 +1269,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
goto next_snapshot; goto next_snapshot;
} }
e = lookup_exception(&snap->complete, chunk); e = dm_lookup_exception(&snap->complete, chunk);
if (e) { if (e) {
free_pending_exception(pe); free_pending_exception(pe);
goto next_snapshot; goto next_snapshot;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册