From patchwork Tue Mar 17 14:03:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonthan Brassow X-Patchwork-Id: 12610 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2HE3khx018501 for ; Tue, 17 Mar 2009 14:03:46 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 24F9E619ADB; Tue, 17 Mar 2009 10:03:47 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n2HE3iqu023145 for ; Tue, 17 Mar 2009 10:03:45 -0400 Received: from hydrogen.msp.redhat.com (hydrogen.msp.redhat.com [10.15.80.1]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2HE3hXx005892 for ; Tue, 17 Mar 2009 10:03:44 -0400 Received: from hydrogen.msp.redhat.com (localhost.localdomain [127.0.0.1]) by hydrogen.msp.redhat.com (8.14.1/8.14.1) with ESMTP id n2HE3f90017394 for ; Tue, 17 Mar 2009 09:03:41 -0500 Received: (from jbrassow@localhost) by hydrogen.msp.redhat.com (8.14.1/8.14.1/Submit) id n2HE3fiJ017392 for dm-devel@redhat.com; Tue, 17 Mar 2009 09:03:41 -0500 Date: Tue, 17 Mar 2009 09:03:41 -0500 From: Jonathan Brassow Message-Id: <200903171403.n2HE3fiJ017392@hydrogen.msp.redhat.com> To: dm-devel@redhat.com X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 9 of 29] dm-snap-exception-function-changes-4.patch X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-snap.c =================================================================== --- linux-2.6.orig/drivers/md/dm-snap.c +++ linux-2.6/drivers/md/dm-snap.c @@ -359,7 +359,11 @@ struct dm_exception_table_internal { * some consecutive chunks to be grouped together. */ static struct dm_exception_table * -dm_exception_table_create(uint32_t size, unsigned hash_shift) +dm_exception_table_create(uint32_t size, unsigned hash_shift, + struct dm_exception *(*alloc_exception)(void *), + void *alloc_context, + void (*free_exception)(struct dm_exception *e, void *), + void *free_context) { unsigned int i; struct dm_exception_table_internal *eti; @@ -379,14 +383,18 @@ dm_exception_table_create(uint32_t size, return NULL; } + eti->alloc_exception = alloc_exception; + eti->alloc_context = alloc_context; + eti->free_exception = free_exception; + eti->free_context = free_context; + for (i = 0; i < size; i++) INIT_LIST_HEAD(et->table + i); return et; } -static void dm_exception_table_destroy(struct dm_exception_table *et, - struct kmem_cache *mem) +static void dm_exception_table_destroy(struct dm_exception_table *et) { struct dm_exception_table_internal *eti; struct list_head *slot; @@ -400,7 +408,7 @@ static void dm_exception_table_destroy(s slot = et->table + i; list_for_each_entry_safe (ex, next, slot, hash_list) - kmem_cache_free(mem, ex); + eti->free_exception(ex, eti->free_context); } vfree(et->table); @@ -575,7 +583,9 @@ static int init_hash_tables(struct dm_sn hash_size = rounddown_pow_of_two(hash_size); s->complete = dm_exception_table_create(hash_size, - DM_CHUNK_CONSECUTIVE_BITS); + DM_CHUNK_CONSECUTIVE_BITS, + alloc_completed_exception, NULL, + free_completed_exception, NULL); if (!s->complete) return -ENOMEM; @@ -587,9 +597,11 @@ static int init_hash_tables(struct dm_sn if (hash_size < 64) hash_size = 64; - s->pending = dm_exception_table_create(hash_size, 0); + s->pending = dm_exception_table_create(hash_size, 0, + alloc_pending_exception, s, + free_pending_exception, NULL); if (!s->pending) { - dm_exception_table_destroy(s->complete, exception_cache); + dm_exception_table_destroy(s->complete); return -ENOMEM; } @@ -781,8 +793,8 @@ bad_pending_pool: dm_kcopyd_client_destroy(s->kcopyd_client); bad_kcopyd: - dm_exception_table_destroy(s->pending, pending_cache); - dm_exception_table_destroy(s->complete, exception_cache); + dm_exception_table_destroy(s->pending); + dm_exception_table_destroy(s->complete); bad_hash_tables: dm_put_device(ti, s->origin); @@ -801,8 +813,8 @@ static void __free_exceptions(struct dm_ dm_kcopyd_client_destroy(s->kcopyd_client); s->kcopyd_client = NULL; - dm_exception_table_destroy(s->pending, pending_cache); - dm_exception_table_destroy(s->complete, exception_cache); + dm_exception_table_destroy(s->pending); + dm_exception_table_destroy(s->complete); } static void snapshot_dtr(struct dm_target *ti)