From patchwork Thu Mar 19 21:33:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonthan Brassow X-Patchwork-Id: 13136 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 n2JLY0pZ023794 for ; Thu, 19 Mar 2009 21:34:00 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 A79CB619A9B; Thu, 19 Mar 2009 17:34:00 -0400 (EDT) Received: from int-mx2.corp.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n2JLXw1Y007503 for ; Thu, 19 Mar 2009 17:33:58 -0400 Received: from hydrogen.msp.redhat.com (hydrogen.msp.redhat.com [10.15.80.1]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2JLXtOx000584 for ; Thu, 19 Mar 2009 17:33:55 -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 n2JLXuFp006950 for ; Thu, 19 Mar 2009 16:33:56 -0500 Received: (from jbrassow@localhost) by hydrogen.msp.redhat.com (8.14.1/8.14.1/Submit) id n2JLXuF6006949 for dm-devel@redhat.com; Thu, 19 Mar 2009 16:33:56 -0500 Date: Thu, 19 Mar 2009 16:33:56 -0500 From: Jonathan Brassow Message-Id: <200903192133.n2JLXuF6006949@hydrogen.msp.redhat.com> To: dm-devel@redhat.com X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 8 of 30] DM Snapshot: exception function changes 3 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 Patch name: dm-snap-exception-function-changes-3.patch This patch adds the 'dm_exception_table_internal' structure. It is used to track the [de]allocation functions used for dm_exception's. This is necessary because some functions, like dm_insert_exception and dm_exception_table_destroy must access them to do the right thing when freeing exceptions. Signed-off-by: Jonathan Brassow --- 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 @@ -343,6 +343,16 @@ static void unregister_snapshot(struct d up_write(&_origins_lock); } +struct dm_exception_table_internal { + struct dm_exception_table et; + + struct dm_exception *(*alloc_exception)(void *context); + void *alloc_context; + + void (*free_exception)(struct dm_exception *e, void *context); + void *free_context; +}; + /* * Implementation of the exception hash tables. * The lowest hash_shift bits of the chunk number are ignored, allowing @@ -352,12 +362,15 @@ static struct dm_exception_table * dm_exception_table_create(uint32_t size, unsigned hash_shift) { unsigned int i; + struct dm_exception_table_internal *eti; struct dm_exception_table *et; - et = kmalloc(sizeof(*et), GFP_KERNEL); - if (!et) + eti = kmalloc(sizeof(*eti), GFP_KERNEL); + if (!eti) return NULL; + et = &eti->et; + et->hash_shift = hash_shift; et->hash_mask = size - 1; et->table = dm_vcalloc(size, sizeof(struct list_head)); @@ -375,10 +388,13 @@ dm_exception_table_create(uint32_t size, static void dm_exception_table_destroy(struct dm_exception_table *et, struct kmem_cache *mem) { + struct dm_exception_table_internal *eti; struct list_head *slot; struct dm_exception *ex, *next; int i, size; + eti = container_of(et, struct dm_exception_table_internal, et); + size = et->hash_mask + 1; for (i = 0; i < size; i++) { slot = et->table + i; @@ -388,7 +404,7 @@ static void dm_exception_table_destroy(s } vfree(et->table); - kfree(et); + kfree(eti); } static uint32_t exception_hash(struct dm_exception_table *et, chunk_t chunk)