]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Move parameter filling from find_device to __find_device_hash_cell.
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 1 Aug 2011 00:51:06 +0000 (10:51 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 1 Aug 2011 00:51:06 +0000 (10:51 +1000)
This patch causes ioctls using __find_device_hash_cell
(DM_DEV_REMOVE_CMD, DM_DEV_SUSPEND_CMD - resume, DM_TABLE_CLEAR_CMD)
to return device parameters, bringing them into line with the other
ioctls.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-ioctl.c
include/linux/dm-ioctl.h

index 4cacdad2270a345e1ef8455eddf5c2a2838a22e1..2b86d354c4618280ae125970c3f93cd59ddee3c9 100644 (file)
@@ -719,24 +719,49 @@ static int dev_create(struct dm_ioctl *param, size_t param_size)
 static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
 {
        struct mapped_device *md;
-       void *mdptr = NULL;
+       struct hash_cell *hc = NULL;
 
-       if (*param->uuid)
-               return __get_uuid_cell(param->uuid);
+       if (*param->uuid) {
+               hc = __get_uuid_cell(param->uuid);
+               if (!hc)
+                       return NULL;
+               goto fill_params;
+       }
 
-       if (*param->name)
-               return __get_name_cell(param->name);
+       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)
-               goto out;
+               return NULL;
 
-       mdptr = dm_get_mdptr(md);
-       if (!mdptr)
+       hc = dm_get_mdptr(md);
+       if (!hc) {
                dm_put(md);
+               return NULL;
+       }
 
-out:
-       return mdptr;
+fill_params:
+       /*
+        * Sneakily write in both the name and the uuid
+        * while we have the cell.
+        */
+       strlcpy(param->name, hc->name, sizeof(param->name));
+       if (hc->uuid)
+               strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
+       else
+               param->uuid[0] = '\0';
+
+       if (hc->new_map)
+               param->flags |= DM_INACTIVE_PRESENT_FLAG;
+       else
+               param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
+
+       return hc;
 }
 
 static struct mapped_device *find_device(struct dm_ioctl *param)
@@ -746,24 +771,8 @@ static struct mapped_device *find_device(struct dm_ioctl *param)
 
        down_read(&_hash_lock);
        hc = __find_device_hash_cell(param);
-       if (hc) {
+       if (hc)
                md = hc->md;
-
-               /*
-                * Sneakily write in both the name and the uuid
-                * while we have the cell.
-                */
-               strlcpy(param->name, hc->name, sizeof(param->name));
-               if (hc->uuid)
-                       strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
-               else
-                       param->uuid[0] = '\0';
-
-               if (hc->new_map)
-                       param->flags |= DM_INACTIVE_PRESENT_FLAG;
-               else
-                       param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
-       }
        up_read(&_hash_lock);
 
        return md;
index 3708455ee6c38f49cb8d7fd97b040f100a3379aa..0cb8eff76bd6e563999df6c081251c4f8a8ef292 100644 (file)
@@ -267,9 +267,9 @@ enum {
 #define DM_DEV_SET_GEOMETRY    _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
 
 #define DM_VERSION_MAJOR       4
-#define DM_VERSION_MINOR       20
+#define DM_VERSION_MINOR       21
 #define DM_VERSION_PATCHLEVEL  0
-#define DM_VERSION_EXTRA       "-ioctl (2011-02-02)"
+#define DM_VERSION_EXTRA       "-ioctl (2011-07-06)"
 
 /* Status bits */
 #define DM_READONLY_FLAG       (1 << 0) /* In/Out */