[PATCH] device-mapper: add dm_get_md

Add dm_get_dev() to get a mapped device given its dev_t.

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 27cd234..9e8c1ed 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -921,6 +921,16 @@
 	return md;
 }
 
+struct mapped_device *dm_get_md(dev_t dev)
+{
+	struct mapped_device *md = dm_find_md(dev);
+
+	if (md)
+		dm_get(md);
+
+	return md;
+}
+
 void *dm_get_mdptr(dev_t dev)
 {
 	struct mapped_device *md;
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index e38c3fc..ab078a2 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -58,6 +58,7 @@
 int dm_create_with_minor(unsigned int minor, struct mapped_device **md);
 void dm_set_mdptr(struct mapped_device *md, void *ptr);
 void *dm_get_mdptr(dev_t dev);
+struct mapped_device *dm_get_md(dev_t dev);
 
 /*
  * Reference counting for md.