Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl2/lvm2 Switch libdevmapper library to use libdm ...



details:   https://anonhg.NetBSD.org/src/rev/d5850c723c13
branches:  trunk
changeset: 761800:d5850c723c13
user:      haad <haad%NetBSD.org@localhost>
date:      Tue Feb 08 03:26:12 2011 +0000

description:
Switch libdevmapper library to use libdm as it;s backend lib and do not
communicate with device-mapper directly. Our lvm stack now looks like this
lvm<->libdevmapper<->libdm<->dm where only libdm knows how our dm protocol
looks like.

No objections on tech-userlevel@.

diffstat:

 external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c |  189 ++----
 external/gpl2/lvm2/dist/libdm/ioctl/libdm_netbsd.c     |  476 +++++++---------
 external/gpl2/lvm2/lib/libdevmapper/libdm-netbsd.h     |   11 +-
 external/gpl2/lvm2/sbin/dmsetup/Makefile               |    7 +-
 external/gpl2/lvm2/sbin/lvm/Makefile                   |    4 +-
 5 files changed, 293 insertions(+), 394 deletions(-)

diffs (truncated from 1135 to 300 lines):

diff -r 1ccdd69e20ed -r d5850c723c13 external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c
--- a/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c    Tue Feb 08 03:20:13 2011 +0000
+++ b/external/gpl2/lvm2/dist/libdm/ioctl/libdm-nbsd-iface.c    Tue Feb 08 03:26:12 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: libdm-nbsd-iface.c,v 1.10 2011/01/12 08:16:23 haad Exp $        */
+/*      $NetBSD: libdm-nbsd-iface.c,v 1.11 2011/02/08 03:26:12 haad Exp $        */
 
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
@@ -28,6 +28,7 @@
 #include <dirent.h>
 #include <limits.h>
 
+#include <dm.h>
 #include <dev/dm/netbsd-dm.h>
 
 #include <dm-ioctl.h>
@@ -38,8 +39,8 @@
 #endif
 
 /*
- * Ensure build compatibility.  
- * The hard-coded versions here are the highest present 
+ * Ensure build compatibility.
+ * The hard-coded versions here are the highest present
  * in the _cmd_data arrays.
  */
 
@@ -104,9 +105,9 @@
 {
 
        nbsd_get_dm_major(major, DM_CHAR_MAJOR);
-       
+
        *minor = 0;
-       
+
        return 1;
 }
 
@@ -185,7 +186,7 @@
        uint32_t dm_major;
 
        nbsd_get_dm_major(&dm_major, DM_BLOCK_MAJOR);
-       
+
        if (major == dm_major)
                return 1;
 
@@ -201,7 +202,7 @@
        if (_control_fd != -1)
                return 1;
 
-#ifdef RUMP_ACTION     
+#ifdef RUMP_ACTION
        rump_init();
 #endif
        snprintf(control, sizeof(control), "%s/control", dm_dir());
@@ -297,7 +298,7 @@
 }
 
 /*
- * Find out device-mapper's major version number the first time 
+ * Find out device-mapper's major version number the first time
  * this is called and whether or not we support it.
  */
 int dm_check_version(void)
@@ -422,14 +423,14 @@
        dev_t dev;
        size_t val_len,i;
        struct kinfo_drivers *kd;
-       
+
        mode = 0;
-       
+
        nbsd_get_dm_major(&dm_major, DM_BLOCK_MAJOR);
 
        if (bufsize < 8)
                return 0;
-       
+
        if (sysctlbyname("kern.drivers",NULL,&val_len,NULL,0) < 0) {
                printf("sysctlbyname failed");
                return 0;
@@ -451,7 +452,7 @@
                        break;
                }
        }
-       
+
        dev = MKDEV(major,dev_minor);
 
        mode |= S_IFBLK;
@@ -489,10 +490,10 @@
        info->target_count = dmt->dmi.v4->target_count;
        info->open_count = dmt->dmi.v4->open_count;
        info->event_nr = dmt->dmi.v4->event_nr;
-       
+
        nbsd_get_dm_major(&info->major, DM_BLOCK_MAJOR); /* get netbsd dm device major number */
        info->minor = MINOR(dmt->dmi.v4->dev);
-       
+
        return 1;
 }
 
@@ -657,44 +658,39 @@
 }
 
 /* Parse given dm task structure to proplib dictionary.  */
-static int _flatten(struct dm_task *dmt, prop_dictionary_t dm_dict)
+static int _flatten(struct dm_task *dmt, libdm_task_t task)
 {
-       prop_array_t cmd_array;
-       prop_dictionary_t target_spec;
-       
+       libdm_cmd_t cmd;
+       libdm_table_t table;
+
        struct target *t;
-       
+
        size_t len;
        char type[DM_MAX_TYPE_NAME];
-       
+
        uint32_t major, flags;
        int count = 0;
-       const int (*version)[3];
-       
+
        flags = 0;
-       version = &_cmd_data_v4[dmt->type].version;
 
-       cmd_array = prop_array_create();
+       cmd = libdm_cmd_create();
 
        for (t = dmt->head; t; t = t->next) {
-               target_spec = prop_dictionary_create();
-
-               prop_dictionary_set_uint64(target_spec,DM_TABLE_START,t->start);
-               prop_dictionary_set_uint64(target_spec,DM_TABLE_LENGTH,t->length);
-
                strlcpy(type,t->type,DM_MAX_TYPE_NAME);
 
-               prop_dictionary_set_cstring(target_spec,DM_TABLE_TYPE,type);
-               prop_dictionary_set_cstring(target_spec,DM_TABLE_PARAMS,t->params);
+               table = libdm_table_create();
 
-               prop_array_set(cmd_array,count,target_spec);
+               libdm_table_set_start(t->start, table);
+               libdm_table_set_length(t->length, table);
+               libdm_table_set_target(type, table);
+               libdm_table_set_params(t->params, table);
+               libdm_cmd_set_table(table, cmd);
 
-               prop_object_release(target_spec);
-               
+               libdm_table_destroy(table);
+
                count++;
        }
 
-       
        if (count && (dmt->sector || dmt->message)) {
                log_error("targets and message are incompatible");
                return -1;
@@ -739,29 +735,26 @@
        if (dmt->geometry)
                len += strlen(dmt->geometry) + 1;
 
-       nbsd_dmi_add_version((*version), dm_dict);
-           
        nbsd_get_dm_major(&major, DM_BLOCK_MAJOR);
-       /* 
-        * Only devices with major which is equal to netbsd dm major 
+       /*
+        * Only devices with major which is equal to netbsd dm major
         * dm devices in NetBSD can't have more majors then one assigned to dm.
         */
        if (dmt->major != major && dmt->major != -1)
                return -1;
-               
+
        if (dmt->minor >= 0) {
                flags |= DM_PERSISTENT_DEV_FLAG;
-               
-               prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmt->minor);
+               libdm_task_set_minor(dmt->minor, task);
        }
 
        /* Set values to dictionary. */
        if (dmt->dev_name)
-               prop_dictionary_set_cstring(dm_dict, DM_IOCTL_NAME, dmt->dev_name);
+               libdm_task_set_name(dmt->dev_name, task);
 
        if (dmt->uuid)
-               prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmt->uuid);
-       
+               libdm_task_set_uuid(dmt->uuid, task);
+
        if (dmt->type == DM_DEVICE_SUSPEND)
                flags |= DM_SUSPEND_FLAG;
        if (dmt->no_flush)
@@ -777,18 +770,18 @@
                                 "by kernel.  It will use live table.");
                flags |= DM_QUERY_INACTIVE_TABLE_FLAG;
        }
-       
-       prop_dictionary_set_uint32(dm_dict, DM_IOCTL_FLAGS, flags);
 
-       prop_dictionary_set_uint32(dm_dict, DM_IOCTL_EVENT, dmt->event_nr);
+       libdm_task_set_flags(task, flags);
+
+//     prop_dictionary_set_uint32(dm_dict, DM_IOCTL_EVENT, dmt->event_nr);
 
        if (dmt->newname)
-               prop_array_set_cstring(cmd_array, 0, dmt->newname);
-       
+               libdm_dev_set_newname(dmt->newname, cmd);
+
        /* Add array for all COMMAND specific data. */
-       prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array);
-       prop_object_release(cmd_array);
-       
+       libdm_task_set_cmd(cmd, task);
+       libdm_cmd_destroy(cmd);
+
        return 0;
 }
 
@@ -874,7 +867,7 @@
        int r;
 
        printf("create and load called \n");
-       
+
        /* Use new task struct to create the device */
        if (!(task = dm_task_create(DM_DEVICE_CREATE))) {
                log_error("Failed to create device-mapper task struct");
@@ -958,7 +951,7 @@
        struct dm_task *task;
        struct target *t1, *t2;
        int r;
-       
+
        /* New task to get existing table information */
        if (!(task = dm_task_create(DM_DEVICE_TABLE))) {
                log_error("Failed to create device-mapper task struct");
@@ -991,7 +984,7 @@
        while (t2 && t2->next)
                t2 = t2->next;
        dmt->existing_table_size = t2 ? t2->start + t2->length : 0;
-       
+
        if ((task->dmi.v4->flags & DM_READONLY_FLAG) ? 1 : 0 != dmt->read_only)
                goto no_match;
 
@@ -1009,7 +1002,7 @@
                t1 = t1->next;
                t2 = t2->next;
        }
-       
+
        if (!t1 && !t2) {
                dmt->dmi.v4 = task->dmi.v4;
                task->dmi.v4 = NULL;
@@ -1037,54 +1030,22 @@
 static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command)
 {
        struct dm_ioctl *dmi;
-       prop_dictionary_t dm_dict_in, dm_dict_out;
-       
-       uint32_t flags;
+       libdm_task_t task;
 
-       dm_dict_in = NULL;
-       
-       dm_dict_in = prop_dictionary_create(); /* Dictionary send to kernel */
-       dm_dict_out = prop_dictionary_create(); /* Dictionary received from kernel */
-
-       /* Set command name to dictionary */
-       prop_dictionary_set_cstring(dm_dict_in, DM_IOCTL_COMMAND,
-           _cmd_data_v4[dmt->type].name);
+       task = libdm_task_create(_cmd_data_v4[dmt->type].name);
 
        /* Parse dmi from libdevmapper to dictionary */
-       if (_flatten(dmt, dm_dict_in) < 0)
+       if (_flatten(dmt, task) < 0)
                goto bad;
 
-       prop_dictionary_get_uint32(dm_dict_in, DM_IOCTL_FLAGS, &flags);
-               
        if (dmt->type == DM_DEVICE_TABLE)
-               flags |= DM_STATUS_TABLE_FLAG;
-
-       if (dmt->no_open_count)
-               flags |= DM_SKIP_BDGET_FLAG;
+               libdm_task_set_status_flag(task);



Home | Main Index | Thread Index | Old Index