Source-Changes-HG archive

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

[src/trunk]: src/sys dm: Enable dm-error and dm-zero target



details:   https://anonhg.NetBSD.org/src/rev/2c945d51aad3
branches:  trunk
changeset: 1005672:2c945d51aad3
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Mon Dec 16 14:26:23 2019 +0000

description:
dm: Enable dm-error and dm-zero target

Add these two targets to dm.kmod.
These are generally available in Linux and DragonFlyBSD,
so enable them in NetBSD as well.

diffstat:

 sys/dev/dm/dm.h              |  18 +++++++++++-
 sys/dev/dm/dm_target.c       |  64 ++++++++++++++++++++++++++++++-------------
 sys/dev/dm/dm_target_error.c |  12 +------
 sys/dev/dm/dm_target_zero.c  |  12 +------
 sys/modules/dm/Makefile      |   6 +--
 5 files changed, 67 insertions(+), 45 deletions(-)

diffs (223 lines):

diff -r 87146dc68651 -r 2c945d51aad3 sys/dev/dm/dm.h
--- a/sys/dev/dm/dm.h   Mon Dec 16 13:48:44 2019 +0000
+++ b/sys/dev/dm/dm.h   Mon Dec 16 14:26:23 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm.h,v 1.46 2019/12/15 16:14:27 tkusumi Exp $      */
+/*        $NetBSD: dm.h,v 1.47 2019/12/16 14:26:23 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -266,6 +266,22 @@
 int dm_target_stripe_upcall(dm_table_entry_t *, struct buf *);
 int dm_target_stripe_secsize(dm_table_entry_t *, unsigned int *);
 
+/* 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_deps(dm_table_entry_t *, prop_array_t);
+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_deps(dm_table_entry_t *, prop_array_t);
+int dm_target_zero_upcall(dm_table_entry_t *, struct buf *);
+
 /* dm_table.c  */
 #define DM_TABLE_ACTIVE 0
 #define DM_TABLE_INACTIVE 1
diff -r 87146dc68651 -r 2c945d51aad3 sys/dev/dm/dm_target.c
--- a/sys/dev/dm/dm_target.c    Mon Dec 16 13:48:44 2019 +0000
+++ b/sys/dev/dm/dm_target.c    Mon Dec 16 14:26:23 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target.c,v 1.32 2019/12/15 14:39:42 tkusumi Exp $      */
+/*        $NetBSD: dm_target.c,v 1.33 2019/12/16 14:26:23 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.32 2019/12/15 14:39:42 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.33 2019/12/16 14:26:23 tkusumi Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -312,14 +312,11 @@
 int
 dm_target_init(void)
 {
-       dm_target_t *dmt, *dmt3;
-       int r;
+       dm_target_t *dmt;
 
        mutex_init(&dm_target_mutex, MUTEX_DEFAULT, IPL_NONE);
 
        dmt = dm_target_alloc("linear");
-       dmt3 = dm_target_alloc("striped");
-
        dmt->version[0] = 1;
        dmt->version[1] = 0;
        dmt->version[2] = 2;
@@ -331,22 +328,49 @@
        dmt->destroy = &dm_target_linear_destroy;
        dmt->upcall = &dm_target_linear_upcall;
        dmt->secsize = &dm_target_linear_secsize;
+       if (dm_target_insert(dmt))
+               printf("Failed to insert linear\n");
 
-       r = dm_target_insert(dmt);
+       dmt = dm_target_alloc("striped");
+       dmt->version[0] = 1;
+       dmt->version[1] = 0;
+       dmt->version[2] = 3;
+       dmt->init = &dm_target_stripe_init;
+       dmt->table = &dm_target_stripe_table;
+       dmt->strategy = &dm_target_stripe_strategy;
+       dmt->sync = &dm_target_stripe_sync;
+       dmt->deps = &dm_target_stripe_deps;
+       dmt->destroy = &dm_target_stripe_destroy;
+       dmt->upcall = &dm_target_stripe_upcall;
+       dmt->secsize = &dm_target_stripe_secsize;
+       if (dm_target_insert(dmt))
+               printf("Failed to insert striped\n");
 
-       dmt3->version[0] = 1;
-       dmt3->version[1] = 0;
-       dmt3->version[2] = 3;
-       dmt3->init = &dm_target_stripe_init;
-       dmt3->table = &dm_target_stripe_table;
-       dmt3->strategy = &dm_target_stripe_strategy;
-       dmt3->sync = &dm_target_stripe_sync;
-       dmt3->deps = &dm_target_stripe_deps;
-       dmt3->destroy = &dm_target_stripe_destroy;
-       dmt3->upcall = &dm_target_stripe_upcall;
-       dmt3->secsize = &dm_target_stripe_secsize;
+       dmt = dm_target_alloc("error");
+       dmt->version[0] = 1;
+       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->deps = &dm_target_error_deps;
+       dmt->destroy = &dm_target_error_destroy;
+       dmt->upcall = &dm_target_error_upcall;
+       if (dm_target_insert(dmt))
+               printf("Failed to insert error\n");
 
-       r = dm_target_insert(dmt3);
+       dmt = dm_target_alloc("zero");
+       dmt->version[0] = 1;
+       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->deps = &dm_target_zero_deps;
+       dmt->destroy = &dm_target_zero_destroy;
+       dmt->upcall = &dm_target_zero_upcall;
+       if (dm_target_insert(dmt))
+               printf("Failed to insert zero\n");
 
-       return r;
+       return 0;
 }
diff -r 87146dc68651 -r 2c945d51aad3 sys/dev/dm/dm_target_error.c
--- a/sys/dev/dm/dm_target_error.c      Mon Dec 16 13:48:44 2019 +0000
+++ b/sys/dev/dm/dm_target_error.c      Mon Dec 16 14:26:23 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_error.c,v 1.24 2019/12/15 14:39:42 tkusumi Exp $      */
+/*        $NetBSD: dm_target_error.c,v 1.25 2019/12/16 14:26:23 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.24 2019/12/15 14:39:42 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_error.c,v 1.25 2019/12/16 14:26:23 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper error target.
@@ -40,14 +40,6 @@
 
 #include "dm.h"
 
-/* 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_deps(dm_table_entry_t *, prop_array_t);
-int dm_target_error_destroy(dm_table_entry_t *);
-int dm_target_error_upcall(dm_table_entry_t *, struct buf *);
-
 #ifdef DM_TARGET_MODULE
 /*
  * Every target can be compiled directly to dm driver or as a
diff -r 87146dc68651 -r 2c945d51aad3 sys/dev/dm/dm_target_zero.c
--- a/sys/dev/dm/dm_target_zero.c       Mon Dec 16 13:48:44 2019 +0000
+++ b/sys/dev/dm/dm_target_zero.c       Mon Dec 16 14:26:23 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target_zero.c,v 1.26 2019/12/15 14:39:42 tkusumi Exp $      */
+/*        $NetBSD: dm_target_zero.c,v 1.27 2019/12/16 14:26:23 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.26 2019/12/15 14:39:42 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_zero.c,v 1.27 2019/12/16 14:26:23 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper zero target.
@@ -40,14 +40,6 @@
 
 #include "dm.h"
 
-/* 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_deps(dm_table_entry_t *, prop_array_t);
-int dm_target_zero_upcall(dm_table_entry_t *, struct buf *);
-
 #ifdef DM_TARGET_MODULE
 /*
  * Every target can be compiled directly to dm driver or as a
diff -r 87146dc68651 -r 2c945d51aad3 sys/modules/dm/Makefile
--- a/sys/modules/dm/Makefile   Mon Dec 16 13:48:44 2019 +0000
+++ b/sys/modules/dm/Makefile   Mon Dec 16 14:26:23 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2019/02/17 04:05:47 rin Exp $
+# $NetBSD: Makefile,v 1.8 2019/12/16 14:26:23 tkusumi Exp $
 
 .include "../Makefile.inc"
 
@@ -7,16 +7,14 @@
 KMOD=  dm
 IOCONF=        dm.ioconf
 SRCS=  device-mapper.c dm_dev.c dm_ioctl.c dm_pdev.c dm_table.c dm_target.c \
-        dm_target_linear.c dm_target_stripe.c
+        dm_target_linear.c dm_target_stripe.c dm_target_error.c dm_target_zero.c
 
 # Do not build unneeded modules now.
 MK_DM_TARGETS= no
 
 .if (${MK_DM_TARGETS} != "no")
-SUBDIR+= dm_target_error
 SUBDIR+= dm_target_mirror
 SUBDIR+= dm_target_snapshot
-SUBDIR+= dm_target_zero
 .endif
 
 WARNS= 3



Home | Main Index | Thread Index | Old Index