[PATCH] device-mapper: add dm_find_md

From: Alasdair G Kergon
Date: Fri Nov 18 2005 - 09:58:17 EST


Abstract dm_find_md() from dm_get_mdptr() to allow use elsewhere.

From: David Teigland <teigland@xxxxxxxxxx>
Signed-Off-By: Alasdair G Kergon <agk@xxxxxxxxxx>

Index: linux-2.6.14/drivers/md/dm.c
===================================================================
--- linux-2.6.14.orig/drivers/md/dm.c 2005-11-18 14:40:40.000000000 +0000
+++ linux-2.6.14/drivers/md/dm.c 2005-11-18 14:40:48.000000000 +0000
@@ -913,10 +913,9 @@ int dm_create_with_minor(unsigned int mi
return create_aux(minor, 1, result);
}

-void *dm_get_mdptr(dev_t dev)
+static struct mapped_device *dm_find_md(dev_t dev)
{
struct mapped_device *md;
- void *mdptr = NULL;
unsigned minor = MINOR(dev);

if (MAJOR(dev) != _major || minor >= (1 << MINORBITS))
@@ -925,12 +924,22 @@ void *dm_get_mdptr(dev_t dev)
down(&_minor_lock);

md = idr_find(&_minor_idr, minor);
-
- if (md && (dm_disk(md)->first_minor == minor))
- mdptr = md->interface_ptr;
+ if (!md || (dm_disk(md)->first_minor != minor))
+ md = NULL;

up(&_minor_lock);

+ return md;
+}
+
+void *dm_get_mdptr(dev_t dev)
+{
+ struct mapped_device *md;
+ void *mdptr = NULL;
+
+ md = dm_find_md(dev);
+ if (md)
+ mdptr = md->interface_ptr;
return mdptr;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/