Source-Changes-HG archive

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

[src/trunk]: src Revert my commit which have added knowledge about dm targets...



details:   https://anonhg.NetBSD.org/src/rev/8e5465ac3bca
branches:  trunk
changeset: 749527:8e5465ac3bca
user:      haad <haad%NetBSD.org@localhost>
date:      Tue Dec 01 23:12:09 2009 +0000

description:
Revert my commit which have added knowledge about dm targets to libdevmapper,
this breaks abstraction. Because only lvmtools/lvmlib and device-mapper can
have knowledge about target mapping and libdevmapper only passes requests
from lvmtools to kernel and back. Bump major library and driver version.

Requested by: yamt@

diffstat:

 external/gpl2/lvm2/lib/libdevmapper/netbsd-dm.h |   4 +-
 sys/dev/dm/dm.h                                 |  22 +++---
 sys/dev/dm/dm_ioctl.c                           |  19 ++++--
 sys/dev/dm/dm_target_error.c                    |   4 +-
 sys/dev/dm/dm_target_linear.c                   |  51 +++++++++--------
 sys/dev/dm/dm_target_mirror.c                   |   4 +-
 sys/dev/dm/dm_target_snapshot.c                 |   4 +-
 sys/dev/dm/dm_target_stripe.c                   |  71 ++++++++++--------------
 sys/dev/dm/dm_target_zero.c                     |   4 +-
 sys/dev/dm/netbsd-dm.h                          |  17 +-----
 10 files changed, 93 insertions(+), 107 deletions(-)

diffs (truncated from 513 to 300 lines):

diff -r c0abc57d6fbc -r 8e5465ac3bca external/gpl2/lvm2/lib/libdevmapper/netbsd-dm.h
--- a/external/gpl2/lvm2/lib/libdevmapper/netbsd-dm.h   Tue Dec 01 23:11:17 2009 +0000
+++ b/external/gpl2/lvm2/lib/libdevmapper/netbsd-dm.h   Tue Dec 01 23:12:09 2009 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: netbsd-dm.h,v 1.3 2009/06/09 18:24:02 haad Exp $      */
+/*        $NetBSD: netbsd-dm.h,v 1.4 2009/12/01 23:12:09 haad Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -287,8 +287,6 @@
 int nbsd_dm_add_uint(const char *, uint64_t, prop_dictionary_t);
 int nbsd_dm_add_str(const char *, char *, prop_dictionary_t );
 
-prop_dictionary_t nbsd_dm_parse_param(const char *, const char *);
-
 struct dm_ioctl* nbsd_dm_dict_to_dmi(prop_dictionary_t, const int);
 
 #endif /* __LIB_DEVMAPPER__ */
diff -r c0abc57d6fbc -r 8e5465ac3bca sys/dev/dm/dm.h
--- a/sys/dev/dm/dm.h   Tue Dec 01 23:11:17 2009 +0000
+++ b/sys/dev/dm/dm.h   Tue Dec 01 23:12:09 2009 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm.h,v 1.14 2009/06/05 21:52:31 haad Exp $      */
+/*        $NetBSD: dm.h,v 1.15 2009/12/01 23:12:09 haad Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -51,8 +51,8 @@
 #define DM_NAME_LEN 128
 #define DM_UUID_LEN 129
 
-#define DM_VERSION_MAJOR       5
-#define DM_VERSION_MINOR       13
+#define DM_VERSION_MAJOR       6
+#define DM_VERSION_MINOR       15
 #define DM_VERSION_PATCHLEVEL  0
 
 /*** Internal device-mapper structures ***/
@@ -209,7 +209,7 @@
 typedef struct dm_target {
        char name[DM_MAX_TYPE_NAME];
        /* Initialize target_config area */
-       int (*init)(dm_dev_t *, void **, prop_dictionary_t);
+       int (*init)(dm_dev_t *, void **, char *);
 
        /* Destroy target_config area */
        int (*destroy)(dm_table_entry_t *);
@@ -281,7 +281,7 @@
 #define DM_MAX_PARAMS_SIZE 1024
 
 /* dm_target_zero.c */
-int dm_target_zero_init(dm_dev_t *, void**, prop_dictionary_t);
+int dm_target_zero_init(dm_dev_t *, void**,  char *);
 char * dm_target_zero_status(void *);
 int dm_target_zero_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_zero_destroy(dm_table_entry_t *);
@@ -289,7 +289,7 @@
 int dm_target_zero_upcall(dm_table_entry_t *, struct buf *);
 
 /* dm_target_error.c */
-int dm_target_error_init(dm_dev_t *, void**, prop_dictionary_t);
+int dm_target_error_init(dm_dev_t *, void**, char *);
 char * dm_target_error_status(void *);
 int dm_target_error_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_error_deps(dm_table_entry_t *, prop_array_t);
@@ -297,7 +297,7 @@
 int dm_target_error_upcall(dm_table_entry_t *, struct buf *);
 
 /* dm_target_linear.c */
-int dm_target_linear_init(dm_dev_t *, void**, prop_dictionary_t);
+int dm_target_linear_init(dm_dev_t *, void**, char *);
 char * dm_target_linear_status(void *);
 int dm_target_linear_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_linear_deps(dm_table_entry_t *, prop_array_t);
@@ -308,7 +308,7 @@
 uint64_t atoi(const char *); 
 
 /* dm_target_mirror.c */
-int dm_target_mirror_init(dm_dev_t *, void**, prop_dictionary_t);
+int dm_target_mirror_init(dm_dev_t *, void**, char *);
 char * dm_target_mirror_status(void *);
 int dm_target_mirror_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_mirror_deps(dm_table_entry_t *, prop_array_t);
@@ -316,7 +316,7 @@
 int dm_target_mirror_upcall(dm_table_entry_t *, struct buf *);
 
 /* dm_target_stripe.c */
-int dm_target_stripe_init(dm_dev_t *, void**, prop_dictionary_t);
+int dm_target_stripe_init(dm_dev_t *, void**, char *);
 char * dm_target_stripe_status(void *);
 int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_stripe_deps(dm_table_entry_t *, prop_array_t);
@@ -324,7 +324,7 @@
 int dm_target_stripe_upcall(dm_table_entry_t *, struct buf *);
 
 /* dm_target_snapshot.c */
-int dm_target_snapshot_init(dm_dev_t *, void**, prop_dictionary_t);
+int dm_target_snapshot_init(dm_dev_t *, void**, char *);
 char * dm_target_snapshot_status(void *);
 int dm_target_snapshot_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_snapshot_deps(dm_table_entry_t *, prop_array_t);
@@ -332,7 +332,7 @@
 int dm_target_snapshot_upcall(dm_table_entry_t *, struct buf *);
 
 /* dm snapshot origin driver */
-int dm_target_snapshot_orig_init(dm_dev_t *, void**, prop_dictionary_t);
+int dm_target_snapshot_orig_init(dm_dev_t *, void**, char *);
 char * dm_target_snapshot_orig_status(void *);
 int dm_target_snapshot_orig_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_snapshot_orig_deps(dm_table_entry_t *, prop_array_t);
diff -r c0abc57d6fbc -r 8e5465ac3bca sys/dev/dm/dm_ioctl.c
--- a/sys/dev/dm/dm_ioctl.c     Tue Dec 01 23:11:17 2009 +0000
+++ b/sys/dev/dm/dm_ioctl.c     Tue Dec 01 23:12:09 2009 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_ioctl.c,v 1.14 2009/09/09 22:38:49 haad Exp $      */
+/*        $NetBSD: dm_ioctl.c,v 1.15 2009/12/01 23:12:10 haad Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -682,20 +682,23 @@
 
        prop_object_iterator_t iter;
        prop_array_t cmd_array;
-       prop_dictionary_t target_dict, param_dict;
+       prop_dictionary_t target_dict;
        
        const char *name, *uuid, *type;
 
        uint32_t flags, ret, minor;
 
+       char *str;
+
        ret = 0;
        flags = 0;
        name = NULL;
        uuid = NULL;
        dmv = NULL;
        last_table = NULL;
+       str = NULL;
 
-/*     char *xml;
+       /* char *xml;
        xml = prop_dictionary_externalize(dm_dict);
        printf("%s\n",xml);*/
                
@@ -768,7 +771,8 @@
                 * null and therefore it should be checked before we try to
                 * use it.
                 */
-               param_dict = prop_dictionary_get(target_dict, DM_TABLE_PARAMS);
+               prop_dictionary_get_cstring(target_dict,
+                   DM_TABLE_PARAMS, (char**)&str);
                
                if (SLIST_EMPTY(tbl))
                        /* insert this table to head */
@@ -781,16 +785,19 @@
                 * therfore I have to pass it to target init
                 * routine and parse parameters there.
                 */
+               
                if ((ret = target->init(dmv, &table_en->target_config,
-                       param_dict)) != 0) {
+                           str)) != 0) {
 
                        dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE);
                        dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);
-                       
+                       free(str, M_TEMP);
+
                        dm_dev_unbusy(dmv);
                        return ret;
                }
                last_table = table_en;
+               free(str, M_TEMP);
        }
        prop_object_iterator_release(iter);
        
diff -r c0abc57d6fbc -r 8e5465ac3bca sys/dev/dm/dm_target_error.c
--- a/sys/dev/dm/dm_target_error.c      Tue Dec 01 23:11:17 2009 +0000
+++ b/sys/dev/dm/dm_target_error.c      Tue Dec 01 23:12:09 2009 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_error.c,v 1.8 2009/06/05 19:56:40 haad Exp $      */
+/*        $NetBSD: dm_target_error.c,v 1.9 2009/12/01 23:12:10 haad Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
 
 /* Init function called from dm_table_load_ioctl. */
 int
-dm_target_error_init(dm_dev_t *dmv, void **target_config, prop_dictionary_t dict)
+dm_target_error_init(dm_dev_t *dmv, void **target_config, char *argv)
 {
 
        printf("Error target init function called!!\n");
diff -r c0abc57d6fbc -r 8e5465ac3bca sys/dev/dm/dm_target_linear.c
--- a/sys/dev/dm/dm_target_linear.c     Tue Dec 01 23:11:17 2009 +0000
+++ b/sys/dev/dm/dm_target_linear.c     Tue Dec 01 23:12:09 2009 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_linear.c,v 1.7 2009/09/09 22:38:49 haad Exp $      */
+/*        $NetBSD: dm_target_linear.c,v 1.8 2009/12/01 23:12:10 haad Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,6 @@
 
 #include <machine/int_fmtio.h>
 
-#include "netbsd-dm.h"
 #include "dm.h"
 
 /*
@@ -55,38 +54,42 @@
  * @argv[1] is physical data offset.
  */
 int
-dm_target_linear_init(dm_dev_t *dmv, void **target_config, prop_dictionary_t dict)
+dm_target_linear_init(dm_dev_t *dmv, void **target_config, char *params)
 {
        dm_target_linear_config_t *tlc;
        dm_pdev_t *dmp;
 
-       const char *device;
-       uint64_t offset;
-       
-       if (prop_dictionary_get_cstring_nocopy(dict, DM_TARGET_LINEAR_DEVICE,
-               &device) == false)
+       char **ap, *argv[3];
+
+       if(params == NULL)
                return EINVAL;
-               
-       if (prop_dictionary_get_uint64(dict, DM_TARGET_LINEAR_OFFSET,
-               &offset) == false)
-               return EINVAL;
+       
+       /*
+        * Parse a string, containing tokens delimited by white space,
+        * into an argument vector
+        */
+       for (ap = argv; ap < &argv[2] &&
+                (*ap = strsep(&params, " \t")) != NULL;) {
+               if (**ap != '\0')
+                       ap++;
+       }
 
+       aprint_debug("Linear target init function called %s--%s!!\n",
+           argv[0], argv[1]);
+       
        /* Insert dmp to global pdev list */
-       if ((dmp = dm_pdev_insert(device)) == NULL)
+       if ((dmp = dm_pdev_insert(argv[0])) == NULL)
                return ENOENT;
        
-       aprint_debug("Linear target init function called %s--%"PRIu64"!!\n",
-           device, offset);
-       
        if ((tlc = kmem_alloc(sizeof(dm_target_linear_config_t), KM_SLEEP))
            == NULL)
-               return 1;
+               return ENOMEM;
 
        tlc->pdev = dmp;
        tlc->offset = 0;        /* default settings */
        
        /* Check user input if it is not leave offset as 0. */
-       tlc->offset = offset;
+       tlc->offset = atoi(argv[1]);
 
        *target_config = tlc;    
 
@@ -105,17 +108,17 @@
 {
        dm_target_linear_config_t *tlc;
        char *params;
-       tlc = target_config;    
-               
+       tlc = target_config;
+
        aprint_debug("Linear target status function called\n");
 
-       if ((params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_SLEEP)) == NULL)
+       if ((params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_NOSLEEP)) == NULL)
                return NULL;
 
        aprint_normal("%s %"PRIu64, tlc->pdev->name, tlc->offset);
-       snprintf(params, DM_MAX_PARAMS_SIZE,"%s %"PRIu64, 
-               tlc->pdev->name, tlc->offset);
-       
+       snprintf(params, DM_MAX_PARAMS_SIZE,"%s %"PRIu64,
+           tlc->pdev->name, tlc->offset);
+
        return params;
 }
 
diff -r c0abc57d6fbc -r 8e5465ac3bca sys/dev/dm/dm_target_mirror.c
--- a/sys/dev/dm/dm_target_mirror.c     Tue Dec 01 23:11:17 2009 +0000
+++ b/sys/dev/dm/dm_target_mirror.c     Tue Dec 01 23:12:09 2009 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_mirror.c,v 1.6 2009/06/05 19:56:40 haad Exp $*/



Home | Main Index | Thread Index | Old Index