From: Hannes Reinecke <hare@suse.de>
To: dm-devel@redhat.com
Cc: Alasdair Kergon <agk@redhat.com>
Subject: [PATCH] dm-table: delayed cleanup for dm_table_destroy()
Date: Mon, 19 Mar 2012 16:53:48 +0100 [thread overview]
Message-ID: <1332172428-35948-4-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1332172428-35948-3-git-send-email-hare@suse.de>
We should be using a kref instead of the existing holders flag.
This enables us to use delayed cleanup and we'll get rid of the
msleep in dm_table_destroy().
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/md/dm-table.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index a3d1e18..97c01f7 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -41,7 +41,7 @@
struct dm_table {
struct mapped_device *md;
- atomic_t holders;
+ struct kref kref;
unsigned type;
/* btree table */
@@ -208,7 +208,7 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
INIT_LIST_HEAD(&t->devices);
INIT_LIST_HEAD(&t->target_callbacks);
- atomic_set(&t->holders, 0);
+ kref_init(&t->kref);
if (!num_targets)
num_targets = KEYS_PER_NODE;
@@ -240,17 +240,11 @@ static void free_devices(struct list_head *devices)
}
}
-void dm_table_destroy(struct dm_table *t)
+void __table_destroy(struct kref *kref)
{
+ struct dm_table *t = container_of(kref, struct dm_table, kref);
unsigned int i;
- if (!t)
- return;
-
- while (atomic_read(&t->holders))
- msleep(1);
- smp_mb();
-
/* free the indexes */
if (t->depth >= 2)
vfree(t->index[t->depth - 2]);
@@ -277,7 +271,8 @@ void dm_table_destroy(struct dm_table *t)
void dm_table_get(struct dm_table *t)
{
- atomic_inc(&t->holders);
+ if (t)
+ kref_get(&t->kref);
}
EXPORT_SYMBOL(dm_table_get);
@@ -286,11 +281,16 @@ void dm_table_put(struct dm_table *t)
if (!t)
return;
- smp_mb__before_atomic_dec();
- atomic_dec(&t->holders);
+ kref_put(&t->kref, __table_destroy);
}
EXPORT_SYMBOL(dm_table_put);
+void dm_table_destroy(struct dm_table *t)
+{
+ smp_mb__before_atomic_dec();
+ dm_table_put(t);
+}
+
/*
* Checks to see if we need to extend highs or targets.
*/
--
1.6.0.2
next prev parent reply other threads:[~2012-03-19 15:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-19 15:53 [PATCH] Device-mapper misc cleanup Hannes Reinecke
2012-03-19 15:53 ` [PATCH] dm: zero out bi_end_io on remapping failure Hannes Reinecke
2012-03-19 15:53 ` [PATCH] dm-table: simplify call to free_devices() Hannes Reinecke
2012-03-19 15:53 ` Hannes Reinecke [this message]
2012-03-19 21:45 ` [PATCH] dm-table: delayed cleanup for dm_table_destroy() Mikulas Patocka
2012-03-20 15:35 ` Hannes Reinecke
2012-03-20 19:43 ` Mike Snitzer
2012-03-21 1:20 ` Mikulas Patocka
2012-03-21 1:24 ` [PATCH] " Mikulas Patocka
2012-03-21 5:34 ` Jun'ichi Nomura
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=1332172428-35948-4-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=agk@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.