Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/dm dm: Make target's ->table() optional



details:   https://anonhg.NetBSD.org/src/rev/349468a8c246
branches:  trunk
changeset: 847464:349468a8c246
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Mon Dec 23 16:17:35 2019 +0000

description:
dm: Make target's ->table() optional

Since ->info() (counter part of ->table() in the original dm design
in Linux kernel in .status where both INFO and TABLE are optional)
is an optional handler, make ->table() optional as well. Some
targets don't have anything to do in ->table() just as in ->info().

taken-from: DragonFlyBSD

diffstat:

 sys/dev/dm/dm.h              |  16 +++++++---------
 sys/dev/dm/dm_ioctl.c        |  10 ++++++----
 sys/dev/dm/dm_target.c       |  10 ++--------
 sys/dev/dm/dm_target_error.c |  13 ++-----------
 sys/dev/dm/dm_target_zero.c  |  13 ++-----------
 5 files changed, 19 insertions(+), 43 deletions(-)

diffs (217 lines):

diff -r 2065c3005f18 -r 349468a8c246 sys/dev/dm/dm.h
--- a/sys/dev/dm/dm.h   Mon Dec 23 15:51:50 2019 +0000
+++ b/sys/dev/dm/dm.h   Mon Dec 23 16:17:35 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm.h,v 1.51 2019/12/21 16:00:29 tkusumi Exp $      */
+/*        $NetBSD: dm.h,v 1.52 2019/12/23 16:17:35 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -181,19 +181,19 @@
        /* Destroy target_config area */
        int (*destroy)(dm_table_entry_t *);
 
-       /*
-        * Info/table routine are called to get params string, which is target
-        * specific. When dm_table_status_ioctl is called with flag
-        * DM_STATUS_TABLE_FLAG I have to sent params string back.
-        */
-       char *(*table)(void *);
        int (*strategy)(dm_table_entry_t *, struct buf *);
        int (*upcall)(dm_table_entry_t *, struct buf *);
 
        /*
         * Optional routines.
         */
+       /*
+        * Info/table routine are called to get params string, which is target
+        * specific. When dm_table_status_ioctl is called with flag
+        * DM_STATUS_TABLE_FLAG I have to sent params string back.
+        */
        char *(*info)(void *);
+       char *(*table)(void *);
        int (*sync)(dm_table_entry_t *);
        int (*secsize)(dm_table_entry_t *, unsigned int *);
 
@@ -262,14 +262,12 @@
 
 /* dm_target_error.c */
 int dm_target_error_init(dm_table_entry_t*, int, char **);
-char *dm_target_error_table(void *);
 int dm_target_error_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_error_destroy(dm_table_entry_t *);
 int dm_target_error_upcall(dm_table_entry_t *, struct buf *);
 
 /* dm_target_zero.c */
 int dm_target_zero_init(dm_table_entry_t *, int, char **);
-char *dm_target_zero_table(void *);
 int dm_target_zero_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_zero_destroy(dm_table_entry_t *);
 int dm_target_zero_upcall(dm_table_entry_t *, struct buf *);
diff -r 2065c3005f18 -r 349468a8c246 sys/dev/dm/dm_ioctl.c
--- a/sys/dev/dm/dm_ioctl.c     Mon Dec 23 15:51:50 2019 +0000
+++ b/sys/dev/dm/dm_ioctl.c     Mon Dec 23 16:17:35 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.48 2019/12/21 11:59:03 tkusumi Exp $      */
+/* $NetBSD: dm_ioctl.c,v 1.49 2019/12/23 16:17:35 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.48 2019/12/21 11:59:03 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.49 2019/12/23 16:17:35 tkusumi Exp $");
 
 /*
  * Locking is used to synchronise between ioctl calls and between dm_table's
@@ -936,6 +936,7 @@
 
        SLIST_FOREACH(table_en, tbl, next) {
                char *params;
+               int is_table;
 
                target_dict = prop_dictionary_create();
                aprint_debug("%016" PRIu64 ", length %016" PRIu64
@@ -960,10 +961,11 @@
                 */
                prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, "");
 
-               if (flags & DM_STATUS_TABLE_FLAG)
+               is_table = (flags & DM_STATUS_TABLE_FLAG) ? 1 : 0;
+               if (is_table && table_en->target->table)
                        params = table_en->target->table(
                            table_en->target_config);
-               else if (table_en->target->info)
+               else if (!is_table && table_en->target->info)
                        params = table_en->target->info(
                            table_en->target_config);
                else
diff -r 2065c3005f18 -r 349468a8c246 sys/dev/dm/dm_target.c
--- a/sys/dev/dm/dm_target.c    Mon Dec 23 15:51:50 2019 +0000
+++ b/sys/dev/dm/dm_target.c    Mon Dec 23 16:17:35 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $      */
+/*        $NetBSD: dm_target.c,v 1.37 2019/12/23 16:17:35 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.37 2019/12/23 16:17:35 tkusumi Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -160,10 +160,6 @@
                printf("%s missing init\n", dm_target->name);
                return EINVAL;
        }
-       if (dm_target->table == NULL) {
-               printf("%s missing table\n", dm_target->name);
-               return EINVAL;
-       }
        if (dm_target->strategy == NULL) {
                printf("%s missing strategy\n", dm_target->name);
                return EINVAL;
@@ -346,7 +342,6 @@
        dmt->version[1] = 0;
        dmt->version[2] = 0;
        dmt->init = &dm_target_error_init;
-       dmt->table = &dm_target_error_table;
        dmt->strategy = &dm_target_error_strategy;
        dmt->destroy = &dm_target_error_destroy;
        dmt->upcall = &dm_target_error_upcall;
@@ -358,7 +353,6 @@
        dmt->version[1] = 0;
        dmt->version[2] = 0;
        dmt->init = &dm_target_zero_init;
-       dmt->table = &dm_target_zero_table;
        dmt->strategy = &dm_target_zero_strategy;
        dmt->destroy = &dm_target_zero_destroy;
        dmt->upcall = &dm_target_zero_upcall;
diff -r 2065c3005f18 -r 349468a8c246 sys/dev/dm/dm_target_error.c
--- a/sys/dev/dm/dm_target_error.c      Mon Dec 23 15:51:50 2019 +0000
+++ b/sys/dev/dm/dm_target_error.c      Mon Dec 23 16:17:35 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_error.c,v 1.27 2019/12/21 11:59:03 tkusumi Exp $      */
+/*        $NetBSD: dm_target_error.c,v 1.28 2019/12/23 16:17:35 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.27 2019/12/21 11:59:03 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.28 2019/12/23 16:17:35 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper error target.
@@ -71,7 +71,6 @@
                dmt->version[1] = 0;
                dmt->version[2] = 0;
                dmt->init = &dm_target_error_init;
-               dmt->table = &dm_target_error_table;
                dmt->strategy = &dm_target_error_strategy;
                dmt->destroy = &dm_target_error_destroy;
                dmt->upcall = &dm_target_error_upcall;
@@ -112,14 +111,6 @@
        return 0;
 }
 
-/* Table routine called to get params string. */
-char *
-dm_target_error_table(void *target_config)
-{
-
-       return NULL;
-}
-
 /* Strategy routine called from dm_strategy. */
 int
 dm_target_error_strategy(dm_table_entry_t *table_en, struct buf *bp)
diff -r 2065c3005f18 -r 349468a8c246 sys/dev/dm/dm_target_zero.c
--- a/sys/dev/dm/dm_target_zero.c       Mon Dec 23 15:51:50 2019 +0000
+++ b/sys/dev/dm/dm_target_zero.c       Mon Dec 23 16:17:35 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_zero.c,v 1.29 2019/12/21 11:59:03 tkusumi Exp $      */
+/*        $NetBSD: dm_target_zero.c,v 1.30 2019/12/23 16:17:35 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.29 2019/12/21 11:59:03 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.30 2019/12/23 16:17:35 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper zero target.
@@ -71,7 +71,6 @@
                dmt->version[1] = 0;
                dmt->version[2] = 0;
                dmt->init = &dm_target_zero_init;
-               dmt->table = &dm_target_zero_table;
                dmt->strategy = &dm_target_zero_strategy;
                dmt->destroy = &dm_target_zero_destroy;
                dmt->upcall = &dm_target_zero_upcall;
@@ -115,14 +114,6 @@
        return 0;
 }
 
-/* Table routine called to get params string. */
-char *
-dm_target_zero_table(void *target_config)
-{
-
-       return NULL;
-}
-
 /*
  * This routine does IO operations.
  */



Home | Main Index | Thread Index | Old Index