Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/dm Add support for DM_QUERY_INACTIVE_TABLE_FLAG to d...



details:   https://anonhg.NetBSD.org/src/rev/4e675f0b632a
branches:  trunk
changeset: 749720:4e675f0b632a
user:      haad <haad%NetBSD.org@localhost>
date:      Sun Dec 06 14:33:46 2009 +0000

description:
Add support for DM_QUERY_INACTIVE_TABLE_FLAG to dm_table_status and dm_table_deps
this flag was introduced to dm->lvm protocol in 4.16.0 version of it. Restore
vrsion check functionality and sent back actual kernel driver version.

diffstat:

 sys/dev/dm/device-mapper.c |   9 ++++++---
 sys/dev/dm/dm_ioctl.c      |  35 +++++++++++++++++++++++++----------
 2 files changed, 31 insertions(+), 13 deletions(-)

diffs (127 lines):

diff -r 276100ecb6fe -r 4e675f0b632a sys/dev/dm/device-mapper.c
--- a/sys/dev/dm/device-mapper.c        Sun Dec 06 14:31:16 2009 +0000
+++ b/sys/dev/dm/device-mapper.c        Sun Dec 06 14:33:46 2009 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: device-mapper.c,v 1.9 2009/10/16 21:23:08 joerg Exp $ */
+/*        $NetBSD: device-mapper.c,v 1.10 2009/12/06 14:33:46 haad Exp $ */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -228,14 +228,17 @@
                if((r = prop_dictionary_copyin_ioctl(pref, cmd, &dm_dict_in)) != 0)
                        return r;
 
-               dm_check_version(dm_dict_in);
+               if ((r = dm_check_version(dm_dict_in)) != 0) {
+                           prop_object_release(dm_dict_in);
+                           return r;
+               }
 
                /* call cmd selected function */
                if ((r = dm_ioctl_switch(cmd)) != 0) {
                        prop_object_release(dm_dict_in);
                        return r;
                }
-               
+                   
                /* run ioctl routine */
                if ((r = dm_cmd_to_fun(dm_dict_in)) != 0) {
                        prop_object_release(dm_dict_in);
diff -r 276100ecb6fe -r 4e675f0b632a sys/dev/dm/dm_ioctl.c
--- a/sys/dev/dm/dm_ioctl.c     Sun Dec 06 14:31:16 2009 +0000
+++ b/sys/dev/dm/dm_ioctl.c     Sun Dec 06 14:33:46 2009 +0000
@@ -1,4 +1,5 @@
-/*        $NetBSD: dm_ioctl.c,v 1.16 2009/12/05 01:21:41 haad Exp $      */
+
+/*        $NetBSD: dm_ioctl.c,v 1.17 2009/12/06 14:33:46 haad Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -619,7 +620,8 @@
        prop_array_t cmd_array;
        const char *name, *uuid;
        uint32_t flags, minor;
-       
+
+       int table_type;
        size_t i;
 
        name = NULL;
@@ -648,12 +650,18 @@
        
        aprint_debug("Getting table deps for device: %s\n", dmv->name);
 
-       tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE);
+       /* if DM_QUERY_INACTIVE_TABLE_FLAG is passed we need to query INACTIVE TABLE */
+       if (flags & DM_QUERY_INACTIVE_TABLE_FLAG)
+               table_type = DM_TABLE_INACTIVE;
+       else
+               table_type = DM_TABLE_ACTIVE;
+       
+       tbl = dm_table_get_entry(&dmv->table_head, table_type);
 
        SLIST_FOREACH(table_en, tbl, next)
                        table_en->target->deps(table_en, cmd_array);
 
-       dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE);
+       dm_table_release(&dmv->table_head, table_type);
        dm_dev_unbusy(dmv);
                
        prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array);
@@ -848,6 +856,7 @@
        const char *name, *uuid;
        char *params;
        int flags;
+       int table_type;
        
        dmv = NULL;
        uuid = NULL;
@@ -868,6 +877,12 @@
                return ENOENT;
        }
 
+       /* if DM_QUERY_INACTIVE_TABLE_FLAG is passed we need to query INACTIVE TABLE */
+       if (flags & DM_QUERY_INACTIVE_TABLE_FLAG)
+               table_type = DM_TABLE_INACTIVE;
+       else
+               table_type = DM_TABLE_ACTIVE;
+               
        if (dm_table_get_target_count(&dmv->table_head, DM_TABLE_ACTIVE))
                DM_ADD_FLAG(flags, DM_ACTIVE_PRESENT_FLAG);
        else {
@@ -885,13 +900,10 @@
        
        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
        
-       /* I should use mutex here and not rwlock there can be IO operation
-          during this ioctl on device. */
-
        aprint_debug("Status of device tables: %s--%d\n",
            name, dmv->table_head.cur_active_table);
        
-       tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_ACTIVE);
+       tbl = dm_table_get_entry(&dmv->table_head, table_type);
        
        SLIST_FOREACH(table_en, tbl, next)
        {
@@ -928,9 +940,10 @@
                prop_object_release(target_dict);
        }
 
-       dm_table_release(&dmv->table_head, DM_TABLE_ACTIVE);
+       dm_table_release(&dmv->table_head, table_type);
        dm_dev_unbusy(dmv);
-       
+
+       prop_dictionary_set_uint32(dm_dict, DM_IOCTL_FLAGS, flags);
        prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array);
        prop_object_release(cmd_array);
        
@@ -969,5 +982,7 @@
        prop_array_set_uint32(ver, 1, DM_VERSION_MINOR);
        prop_array_set_uint32(ver, 2, DM_VERSION_PATCHLEVEL);
 
+       prop_dictionary_set(dm_dict, DM_IOCTL_VERSION, ver);
+       
        return 0;
 }



Home | Main Index | Thread Index | Old Index