From patchwork Thu Mar 19 21:34:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonthan Brassow X-Patchwork-Id: 13138 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 n2JLYMsL023858 for ; Thu, 19 Mar 2009 21:34:22 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 050036199FE; Thu, 19 Mar 2009 17:34:22 -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 n2JLYJN4007544 for ; Thu, 19 Mar 2009 17:34:19 -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 n2JLYFbC000641 for ; Thu, 19 Mar 2009 17:34:15 -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 n2JLYG6T007098 for ; Thu, 19 Mar 2009 16:34:16 -0500 Received: (from jbrassow@localhost) by hydrogen.msp.redhat.com (8.14.1/8.14.1/Submit) id n2JLYGbC007097 for dm-devel@redhat.com; Thu, 19 Mar 2009 16:34:16 -0500 Date: Thu, 19 Mar 2009 16:34:16 -0500 From: Jonathan Brassow Message-Id: <200903192134.n2JLYGbC007097@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 10 of 30] DM Snapshot: exception function changes 5 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-5.patch This patch introduces the dm_alloc_exception and dm_free_exception functions. They are now the official way to [de]allocate exceptions via the new interface. These functions call the [de]allocation functions specified during the creation of the exception table and use the context provided at that time. 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 @@ -444,6 +444,25 @@ static struct dm_exception *dm_lookup_ex return NULL; } +static struct dm_exception *dm_alloc_exception(struct dm_exception_table *et) +{ + struct dm_exception_table_internal *eti; + + eti = container_of(et, struct dm_exception_table_internal, et); + + return eti->alloc_exception(eti->alloc_context); +} + +static void dm_free_exception(struct dm_exception_table *et, + struct dm_exception *e) +{ + struct dm_exception_table_internal *eti; + + eti = container_of(et, struct dm_exception_table_internal, et); + + return eti->free_exception(e, eti->free_context); +} + static struct dm_exception *alloc_completed_exception(void *unused) { struct dm_exception *e; @@ -505,7 +524,7 @@ static void dm_insert_exception(struct d new_e->new_chunk == (dm_chunk_number(e->new_chunk) + dm_consecutive_chunk_count(e) + 1)) { dm_consecutive_chunk_count_inc(e); - free_completed_exception(new_e, NULL); + dm_free_exception(eh, new_e); return; } @@ -515,7 +534,7 @@ static void dm_insert_exception(struct d dm_consecutive_chunk_count_inc(e); e->old_chunk--; e->new_chunk--; - free_completed_exception(new_e, NULL); + dm_free_exception(eh, new_e); return; } @@ -536,7 +555,7 @@ static int dm_add_exception(void *contex struct dm_snapshot *s = context; struct dm_exception *e; - e = alloc_completed_exception(NULL); + e = dm_alloc_exception(s->complete); if (!e) return -ENOMEM; @@ -967,7 +986,7 @@ static void pending_complete(struct dm_s goto out; } - e = alloc_completed_exception(NULL); + e = dm_alloc_exception(s->complete); if (!e) { down_write(&s->lock); __invalidate_snapshot(s, -ENOMEM); @@ -978,7 +997,7 @@ static void pending_complete(struct dm_s down_write(&s->lock); if (!s->valid) { - free_completed_exception(e, NULL); + dm_free_exception(s->complete, e); error = 1; goto out; }