Source-Changes-HG archive

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

[src/trunk]: src implement 32-bit compat support for raidframe.



details:   https://anonhg.NetBSD.org/src/rev/9b33ba3f89c3
branches:  trunk
changeset: 829121:9b33ba3f89c3
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Jan 18 00:32:48 2018 +0000

description:
implement 32-bit compat support for raidframe.

convert several raidframe ioctls to be bitsize idempotent so that
they work the same in 32 and 64 bit worlds, allowing netbsd32 to
configure and query raid properly.  remove useless 'row' in a few
places.  add COMPAT_80 and put the old ioctls there.

raidframeio.h:
  RAIDFRAME_TEST_ACC
  - remove, unused
  RAIDFRAME_GET_COMPONENT_LABEL
  - convert to label not pointer to label
  RAIDFRAME_CHECK_RECON_STATUS_EXT
  RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT
  RAIDFRAME_CHECK_COPYBACK_STATUS_EXT
  - convert to progress info not pointer to info
  RAIDFRAME_GET_INFO
  - version entirely.
raidframevar.h:
  - rf_recon_req{} has row, flags and raidPtr removed (they're
    not a useful part of this interface.)
  - RF_Config_s{} and RF_DeviceConfig_s{} have numRow/rows removed.
  - RF_RaidDisk_s{} is re-ordered slightly to fix alignment
    padding - the actual data was already OK.
  - InstallSpareTable() loses row argument

rf_compat32.c has code for RF_Config_s{} in 32 bit mode, used
by RAIDFRAME_CONFIGURE and RAIDFRAME_GET_INFO32.

rf_compat80.c has code for rf_recon_req{}, RF_RaidDisk_s{} and
RF_DeviceConfig_s{} to handle RAIDFRAME_FAIL_DISK,
RAIDFRAME_GET_COMPONENT_LABEL, RAIDFRAME_CHECK_RECON_STATUS_EXT,
RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT,
RAIDFRAME_CHECK_COPYBACK_STATUS_EXT, RAIDFRAME_GET_INFO.

move several of the per-ioctl code blocks into separate functions.

add rf_recon_req_internal{} to replace old usage of global
rf_recon_req{} that had unused void * in the structure, ruining
it's 32/64 bit ABI.

add missing case for RAIDFRAME_GET_INFO50.

adjust raid tests to use the new .conf format, and add a case to
test the old method as well.

raidctl:
deal with lack of 'row' members in a couple of places.
fail request no longer takes row.
handle "START array" sections with just "numCol numSpare", ie
no "numRow" specified.  for now, generate old-style configuration
but update raidctl.8 to specify the new style (keeping reference
to the old style.)

note that: RF_ComponentLabel_s::{row,num_rows} and
RF_SingleComponent_s::row are obsolete but not removed yet.

diffstat:

 sbin/raidctl/raidctl.8                 |   48 ++--
 sbin/raidctl/raidctl.c                 |   11 +-
 sbin/raidctl/rf_configure.c            |   68 +++---
 sys/conf/files                         |    5 +-
 sys/dev/raidframe/files.raidframe      |    4 +-
 sys/dev/raidframe/raidframeio.h        |   14 +-
 sys/dev/raidframe/raidframevar.h       |   32 +-
 sys/dev/raidframe/rf_compat32.c        |  115 +++++++++++
 sys/dev/raidframe/rf_compat32.h        |   41 ++++
 sys/dev/raidframe/rf_compat50.c        |   23 +-
 sys/dev/raidframe/rf_compat80.c        |  148 ++++++++++++++
 sys/dev/raidframe/rf_compat80.h        |  100 ++++++++++
 sys/dev/raidframe/rf_decluster.c       |    7 +-
 sys/dev/raidframe/rf_decluster.h       |    4 +-
 sys/dev/raidframe/rf_kintf.h           |   11 +-
 sys/dev/raidframe/rf_netbsdkintf.c     |  327 +++++++++++++++++++-------------
 sys/dev/raidframe/rf_reconutil.c       |    6 +-
 sys/modules/raid/Makefile              |   12 +-
 sys/rump/Makefile.rump                 |    4 +-
 sys/rump/dev/lib/libraidframe/Makefile |    6 +-
 tests/dev/raidframe/t_raid.sh          |   47 ++++-
 21 files changed, 786 insertions(+), 247 deletions(-)

diffs (truncated from 1737 to 300 lines):

diff -r 1209f8b98bfd -r 9b33ba3f89c3 sbin/raidctl/raidctl.8
--- a/sbin/raidctl/raidctl.8    Thu Jan 18 00:31:22 2018 +0000
+++ b/sbin/raidctl/raidctl.8    Thu Jan 18 00:32:48 2018 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: raidctl.8,v 1.73 2017/11/20 18:37:56 kardel Exp $
+.\"     $NetBSD: raidctl.8,v 1.74 2018/01/18 00:32:49 mrg Exp $
 .\"
 .\" Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -364,18 +364,22 @@
 The first section is the
 .Sq array
 section, and it specifies
-the number of rows, columns, and spare disks in the RAID set.
+the number of columns, and spare disks in the RAID set.
 For example:
 .Bd -literal -offset indent
 START array
+3 0
+.Ed
+.Pp
+indicates an array with 3 columns, and 0 spare disks.
+Old configurations specified a 3rd value in front of the
+number of columns and spare disks.
+This old value, if provided, must be specified as 1:
+.Bd -literal -offset indent
+START array
 1 3 0
 .Ed
 .Pp
-indicates an array with 1 row, 3 columns, and 0 spare disks.
-Note that although multi-dimensional arrays may be specified, they are
-.Em NOT
-supported in the driver.
-.Pp
 The second section, the
 .Sq disks
 section, specifies the actual components of the device.
@@ -551,7 +555,7 @@
 A
 .Sq component label
 contains important information about the component, including a
-user-specified serial number, the row and column of that component in
+user-specified serial number, the column of that component in
 the RAID set, the redundancy level of the RAID set, a
 .Sq modification counter ,
 and whether the parity information (if any) on that
@@ -567,7 +571,7 @@
 component labels in the set.
 For example, the serial number,
 .Sq modification counter ,
-number of rows and number of columns must all be in agreement.
+and number of columns must all be in agreement.
 If any of these are different, then the component is
 not considered to be part of the set.
 See
@@ -583,8 +587,8 @@
 To configure the device, a configuration file which looks something like:
 .Bd -literal -offset indent
 START array
-# numRow numCol numSpare
-1 3 1
+# numCol numSpare
+3 1
 
 START disks
 /dev/sd1e
@@ -617,8 +621,8 @@
 A RAID 0 set would be specified in a similar way:
 .Bd -literal -offset indent
 START array
-# numRow numCol numSpare
-1 4 0
+# numCol numSpare
+4 0
 
 START disks
 /dev/sd10e
@@ -647,8 +651,8 @@
 For a RAID 1 (mirror) set, the following configuration might be used:
 .Bd -literal -offset indent
 START array
-# numRow numCol numSpare
-1 2 0
+# numCol numSpare
+2 0
 
 START disks
 /dev/sd20e
@@ -774,8 +778,8 @@
 In the following:
 .Bd -literal -offset indent
 START array
-# numRow numCol numSpare
-1 2 0
+# numCol numSpare
+2 0
 
 START disks
 absent
@@ -1021,7 +1025,7 @@
 For example, the configuration file (in part) might now look like:
 .Bd -literal -offset indent
 START array
-1 3 0
+3 0
 
 START disks
 /dev/sd1e
@@ -1172,7 +1176,7 @@
 fail (in that order) in a RAID set of the following configuration:
 .Bd -literal -offset indent
 START array
-1 4 0
+4 0
 
 START disks
 /dev/sd1e
@@ -1192,7 +1196,7 @@
 then the following configuration (say "recover_raid0.conf")
 .Bd -literal -offset indent
 START array
-1 4 0
+4 0
 
 START disks
 absent
@@ -1232,8 +1236,8 @@
 The following configuration file shows such a setup:
 .Bd -literal -offset indent
 START array
-# numRow numCol numSpare
-1 4 0
+# numCol numSpare
+4 0
 
 START disks
 /dev/raid1e
diff -r 1209f8b98bfd -r 9b33ba3f89c3 sbin/raidctl/raidctl.c
--- a/sbin/raidctl/raidctl.c    Thu Jan 18 00:31:22 2018 +0000
+++ b/sbin/raidctl/raidctl.c    Thu Jan 18 00:32:48 2018 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: raidctl.c,v 1.65 2016/01/06 22:57:44 wiz Exp $   */
+/*      $NetBSD: raidctl.c,v 1.66 2018/01/18 00:32:49 mrg Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: raidctl.c,v 1.65 2016/01/06 22:57:44 wiz Exp $");
+__RCSID("$NetBSD: raidctl.c,v 1.66 2018/01/18 00:32:49 mrg Exp $");
 #endif
 
 
@@ -615,9 +615,13 @@
        printf("\n");
        do_ioctl(fd, RAIDFRAME_GET_INFO, &cfg_ptr, "RAIDFRAME_GET_INFO");
 
+       /*
+        * After NetBSD 9, convert this to not output the numRow's value,
+        * which is no longer required or ever used.
+        */
        printf("START array\n");
        printf("# numRow numCol numSpare\n");
-       printf("%d %d %d\n", device_config.rows, device_config.cols,
+       printf("%d %d %d\n", 1, device_config.cols,
            device_config.nspares);
        printf("\n");
 
@@ -719,7 +723,6 @@
 
        get_component_number(fd, component_to_fail, &component_num, &num_cols);
 
-       recon_request.row = component_num / num_cols;
        recon_request.col = component_num % num_cols;
        if (do_recon) {
                recon_request.flags = RF_FDFLAGS_RECON;
diff -r 1209f8b98bfd -r 9b33ba3f89c3 sbin/raidctl/rf_configure.c
--- a/sbin/raidctl/rf_configure.c       Thu Jan 18 00:31:22 2018 +0000
+++ b/sbin/raidctl/rf_configure.c       Thu Jan 18 00:32:48 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_configure.c,v 1.32 2017/11/22 00:31:31 kre Exp $ */
+/*     $NetBSD: rf_configure.c,v 1.33 2018/01/18 00:32:49 mrg Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -49,7 +49,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: rf_configure.c,v 1.32 2017/11/22 00:31:31 kre Exp $");
+__RCSID("$NetBSD: rf_configure.c,v 1.33 2018/01/18 00:32:49 mrg Exp $");
 #endif
 
 
@@ -140,7 +140,7 @@
 int
 rf_MakeConfig(char *configname, RF_Config_t *cfgPtr)
 {
-       int numscanned, val, r, c, retcode, aa, bb, cc;
+       int numscanned, val, c, retcode, aa, bb, cc;
        char buf[BUFSIZ], buf1[BUFSIZ], *cp;
        const RF_LayoutSW_t *lp;
        FILE *fp;
@@ -167,14 +167,22 @@
         * wackiness with aa, bb, cc to get around size problems on
         * different platforms
         */
+
+       /*
+        * Allow both "numCol numSpare" as well as old-style
+        * "numRow numCol numSpare".
+        * Note that numRow has always been ignored.
+        */
        numscanned = sscanf(buf, "%d %d %d", &aa, &bb, &cc);
        if (numscanned != 3) {
-               warnx("Config file error (\"array\" section): unable to get "
-                   "numRow, numCol, numSpare");
-               retcode = -1;
-               goto out;
+               numscanned = sscanf(buf, "%d %d", &bb, &cc);
+               if (numscanned != 2) {
+                       warnx("Config file error (\"array\" section): unable "
+                           "to get numCol, numSpare");
+                       retcode = -1;
+                       goto out;
+               }
        }
-       cfgPtr->numRow = (RF_RowCol_t) aa;
        cfgPtr->numCol = (RF_RowCol_t) bb;
        cfgPtr->numSpare = (RF_RowCol_t) cc;
 
@@ -236,30 +244,28 @@
                retcode = -1;
                goto out;
        }
-       for (r = 0; r < cfgPtr->numRow; r++) {
-               for (c = 0; c < cfgPtr->numCol; c++) {
-                       char b1[MAXPATHLEN];
-                       const char *b;
+       for (c = 0; c < cfgPtr->numCol; c++) {
+               char b1[MAXPATHLEN];
+               const char *b;
 
-                       if (rf_get_next_nonblank_line(
-                           buf, sizeof(buf), fp, NULL)) {
-                               warnx("Config file error: unable to get device "
-                                   "file for disk at row %d col %d", r, c);
-                               retcode = -1;
-                               goto out;
-                       }
+               if (rf_get_next_nonblank_line(
+                   buf, sizeof(buf), fp, NULL)) {
+                       warnx("Config file error: unable to get device "
+                           "file for disk at row %d col %d", 0, c);
+                       retcode = -1;
+                       goto out;
+               }
 
-                       b = getfsspecname(b1, sizeof(b1), buf);
-                       if (b == NULL) {
-                               warnx("Config file error: warning: unable to "
-                                   "get device file for disk at row %d col "
-                                   "%d: %s", r, c, b1);
-                               b = buf;
-                       }
+               b = getfsspecname(b1, sizeof(b1), buf);
+               if (b == NULL) {
+                       warnx("Config file error: warning: unable to "
+                           "get device file for disk at row %d col "
+                           "%d: %s", 0, c, b1);
+                       b = buf;
+               }
 
-                       strlcpy(cfgPtr->devnames[r][c], b,
-                           sizeof(cfgPtr->devnames[r][c]));
-               }
+               strlcpy(cfgPtr->devnames[0][c], b,
+                   sizeof(cfgPtr->devnames[0][c]));
        }
 
        /* "spare" section is optional */
@@ -284,8 +290,8 @@
                        b = buf;
                }
 
-               strlcpy(cfgPtr->spare_names[r], b,
-                   sizeof(cfgPtr->spare_names[r]));
+               strlcpy(cfgPtr->spare_names[c], b,
+                   sizeof(cfgPtr->spare_names[c]));
        }
 
        /* scan the file for the block related to layout */
diff -r 1209f8b98bfd -r 9b33ba3f89c3 sys/conf/files
--- a/sys/conf/files    Thu Jan 18 00:31:22 2018 +0000
+++ b/sys/conf/files    Thu Jan 18 00:32:48 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1191 2018/01/10 10:56:30 knakahara Exp $



Home | Main Index | Thread Index | Old Index