All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: dm-devel@redhat.com
Subject: [PATCH 10/18] dm-snapshot-exception-function-changes-3
Date: Tue, 29 Sep 2009 18:53:35 -0400	[thread overview]
Message-ID: <1254264823-11538-11-git-send-email-snitzer@redhat.com> (raw)
In-Reply-To: <1254264823-11538-1-git-send-email-snitzer@redhat.com>

From: Jon Brassow <jbrassow@redhat.com>

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 <jbrassow@redhat.com>
---
 drivers/md/dm-snap.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index df8cb32..1a664ec 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -342,6 +342,16 @@ static void unregister_snapshot(struct dm_snapshot *s)
 	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
@@ -351,12 +361,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));
@@ -374,10 +387,13 @@ dm_exception_table_create(uint32_t size, unsigned hash_shift)
 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;
@@ -387,7 +403,7 @@ static void dm_exception_table_destroy(struct dm_exception_table *et,
 	}
 
 	vfree(et->table);
-	kfree(et);
+	kfree(eti);
 }
 
 static uint32_t exception_hash(struct dm_exception_table *et, chunk_t chunk)
-- 
1.6.2.5

  parent reply	other threads:[~2009-09-29 22:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-29 22:53 [PATCH 00/18] Clusterized exception store preparation Mike Snitzer
2009-09-29 22:53 ` [PATCH 01/18] dm-snap-consolidate-insert_exception-functions Mike Snitzer
2009-09-29 22:53 ` [PATCH 02/18] dm-exception-store-generalize-table-args Mike Snitzer
2009-09-30 14:44   ` [PATCH v2 " Mike Snitzer
2009-09-29 22:53 ` [PATCH 03/18] dm-snapshot-new-ctr-table-format Mike Snitzer
2009-09-29 22:53 ` [PATCH 04/18] dm-snapshot-rename-dm_snap_exception-to-dm_exception Mike Snitzer
2009-09-29 22:53 ` [PATCH 05/18] dm-snapshot-rename-exception_table-to-dm_exception_table Mike Snitzer
2009-09-29 22:53 ` [PATCH 06/18] dm-snapshot-rename-exception-functions Mike Snitzer
2009-09-29 22:53 ` [PATCH 07/18] dm-snapshot-use-allocated-exception-tables Mike Snitzer
2009-09-29 22:53 ` [PATCH 08/18] dm-snapshot-exception-function-changes-1 Mike Snitzer
2009-09-29 22:53 ` [PATCH 09/18] dm-snapshot-exception-function-changes-2 Mike Snitzer
2009-09-29 22:53 ` Mike Snitzer [this message]
2009-09-29 22:53 ` [PATCH 11/18] dm-snapshot-exception-function-changes-4 Mike Snitzer
2009-09-29 22:53 ` [PATCH 12/18] dm-snapshot-exception-function-changes-5 Mike Snitzer
2009-09-29 22:53 ` [PATCH 13/18] dm-snapshot-exception-function-changes-6 Mike Snitzer
2009-09-29 22:53 ` [PATCH 14/18] dm-snapshot-move-exception-code-to-new-file Mike Snitzer
2009-09-29 22:53 ` [PATCH 15/18] dm-exception-store-create-local-exception-caches Mike Snitzer
2009-09-29 22:53 ` [PATCH 16/18] dm-exception-store-add-lookup_exception-to-API Mike Snitzer
2009-09-29 22:53 ` [PATCH 17/18] dm-snapshot-remove-completed-exception-cache Mike Snitzer
2009-09-29 22:53 ` [PATCH 18/18] dm-exstore-persistent-allow-metadata-reread Mike Snitzer
2009-09-30 14:46   ` [PATCH v2 " Mike Snitzer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1254264823-11538-11-git-send-email-snitzer@redhat.com \
    --to=snitzer@redhat.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.