FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 07-01-2011, 07:05 PM
Mikulas Patocka
 
Default dm-ioctl: introduce __get_dev_cell

dm-ioctl: introduce __get_dev_cell

Move logic to find device based on major/minor number to a separate
function __get_dev_cell (similar to __get_uuid_cell and __get_name_cell).
As a result, function __find_device_hash_cell is more straightforward.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
drivers/md/dm-ioctl.c | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)

Index: linux-2.6.39-fast/drivers/md/dm-ioctl.c
================================================== =================
--- linux-2.6.39-fast.orig/drivers/md/dm-ioctl.c 2011-06-30 20:31:15.000000000 +0200
+++ linux-2.6.39-fast/drivers/md/dm-ioctl.c 2011-06-30 20:43:22.000000000 +0200
@@ -128,6 +128,24 @@ static struct hash_cell *__get_uuid_cell
return NULL;
}

+static struct hash_cell *__get_dev_cell(__u64 dev)
+{
+ struct mapped_device *md;
+ struct hash_cell *hc;
+
+ md = dm_get_md(huge_decode_dev(dev));
+ if (!md)
+ return NULL;
+
+ hc = dm_get_mdptr(md);
+ if (!hc) {
+ dm_put(md);
+ return NULL;
+ }
+
+ return hc;
+}
+
/*-----------------------------------------------------------------
* Inserting, removing and renaming a device.
*---------------------------------------------------------------*/
@@ -718,34 +736,24 @@ static int dev_create(struct dm_ioctl *p
*/
static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
{
- struct mapped_device *md;
struct hash_cell *hc = NULL;

if (*param->uuid) {
hc = __get_uuid_cell(param->uuid);
if (!hc)
return NULL;
- goto fill_params;
- }
-
- if (*param->name) {
+ } else if (*param->name) {
hc = __get_name_cell(param->name);
if (!hc)
return NULL;
- goto fill_params;
- }
-
- md = dm_get_md(huge_decode_dev(param->dev));
- if (!md)
- return NULL;
-
- hc = dm_get_mdptr(md);
- if (!hc) {
- dm_put(md);
+ } else if (param->dev) {
+ hc = __get_dev_cell(param->dev);
+ if (!hc)
+ return NULL;
+ } else {
return NULL;
}

-fill_params:
/*
* Sneakily write in both the name and the uuid
* while we have the cell.

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 

Thread Tools




All times are GMT. The time now is 11:31 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org