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: Fix dm-stripe's "status" output format



details:   https://anonhg.NetBSD.org/src/rev/9a03203be93c
branches:  trunk
changeset: 967770:9a03203be93c
user:      tkusumi <tkusumi%NetBSD.org@localhost>
date:      Sat Dec 21 16:00:29 2019 +0000

description:
dm: Fix dm-stripe's "status" output format

As mentioned in "dm: Don't try to implement "status" as subset of "table"",
dm-stripe in NetBSD doesn't have correct "status" output format.
Implement ->info() to sync with Linux kernel.

Note that num_error for stripe device isn't implemented yet.

taken-from: DragonFlyBSD

diffstat:

 sys/dev/dm/dm.h               |   6 +++-
 sys/dev/dm/dm_target.c        |   5 ++-
 sys/dev/dm/dm_target_stripe.c |  44 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 49 insertions(+), 6 deletions(-)

diffs (131 lines):

diff -r 6f0308524c32 -r 9a03203be93c sys/dev/dm/dm.h
--- a/sys/dev/dm/dm.h   Sat Dec 21 15:16:14 2019 +0000
+++ b/sys/dev/dm/dm.h   Sat Dec 21 16:00:29 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm.h,v 1.50 2019/12/21 11:59:03 tkusumi Exp $      */
+/*        $NetBSD: dm.h,v 1.51 2019/12/21 16:00:29 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -186,13 +186,14 @@
         * 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 (*strategy)(dm_table_entry_t *, struct buf *);
        int (*upcall)(dm_table_entry_t *, struct buf *);
+
        /*
         * Optional routines.
         */
+       char *(*info)(void *);
        int (*sync)(dm_table_entry_t *);
        int (*secsize)(dm_table_entry_t *, unsigned int *);
 
@@ -251,6 +252,7 @@
 
 /* dm_target_stripe.c */
 int dm_target_stripe_init(dm_table_entry_t *, int, char **);
+char *dm_target_stripe_info(void *);
 char *dm_target_stripe_table(void *);
 int dm_target_stripe_strategy(dm_table_entry_t *, struct buf *);
 int dm_target_stripe_sync(dm_table_entry_t *);
diff -r 6f0308524c32 -r 9a03203be93c sys/dev/dm/dm_target.c
--- a/sys/dev/dm/dm_target.c    Sat Dec 21 15:16:14 2019 +0000
+++ b/sys/dev/dm/dm_target.c    Sat Dec 21 16:00:29 2019 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target.c,v 1.35 2019/12/21 11:59:03 tkusumi Exp $      */
+/*        $NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 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.35 2019/12/21 11:59:03 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.36 2019/12/21 16:00:29 tkusumi Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -331,6 +331,7 @@
        dmt->version[1] = 0;
        dmt->version[2] = 3;
        dmt->init = &dm_target_stripe_init;
+       dmt->info = &dm_target_stripe_info;
        dmt->table = &dm_target_stripe_table;
        dmt->strategy = &dm_target_stripe_strategy;
        dmt->sync = &dm_target_stripe_sync;
diff -r 6f0308524c32 -r 9a03203be93c sys/dev/dm/dm_target_stripe.c
--- a/sys/dev/dm/dm_target_stripe.c     Sat Dec 21 15:16:14 2019 +0000
+++ b/sys/dev/dm/dm_target_stripe.c     Sat Dec 21 16:00:29 2019 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: dm_target_stripe.c,v 1.42 2019/12/21 11:59:03 tkusumi Exp $*/
+/*$NetBSD: dm_target_stripe.c,v 1.43 2019/12/21 16:00:29 tkusumi Exp $*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.42 2019/12/21 11:59:03 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.43 2019/12/21 16:00:29 tkusumi Exp $");
 
 /*
  * This file implements initial version of device-mapper stripe target.
@@ -80,6 +80,7 @@
                dmt->version[1] = 0;
                dmt->version[2] = 0;
                dmt->init = &dm_target_stripe_init;
+               dmt->info = &dm_target_stripe_info;
                dmt->table = &dm_target_stripe_table;
                dmt->strategy = &dm_target_stripe_strategy;
                dmt->sync = &dm_target_stripe_sync;
@@ -179,6 +180,45 @@
        return 0;
 }
 
+/* Info routine called to get params string. */
+char *
+dm_target_stripe_info(void *target_config)
+{
+       dm_target_linear_config_t *tlc;
+       dm_target_stripe_config_t *tsc;
+       char *params, *ptr, buf[256];
+       int ret, i = 0;
+       size_t len;
+
+       tsc = target_config;
+
+       len = DM_MAX_PARAMS_SIZE;
+       params = kmem_alloc(len, KM_SLEEP);
+       ptr = params;
+
+       ret = snprintf(ptr, len, "%d ", tsc->stripe_num);
+       ptr += ret;
+       len -= ret;
+
+       memset(buf, 0, sizeof(buf));
+       TAILQ_FOREACH(tlc, &tsc->stripe_devs, entries) {
+               ret = snprintf(ptr, len, "%s ", tlc->pdev->udev_name);
+               if (0 /*tlc->num_error*/)
+                       buf[i] = 'D';
+               else
+                       buf[i] = 'A';
+               i++;
+               ptr += ret;
+               len -= ret;
+       }
+
+       ret = snprintf(ptr, len, "1 %s", buf);
+       ptr += ret;
+       len -= ret;
+
+       return params;
+}
+
 /* Table routine called to get params string. */
 char *
 dm_target_stripe_table(void *target_config)



Home | Main Index | Thread Index | Old Index