Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/raidframe fixes for the previous, noted by nakayama@.



details:   https://anonhg.NetBSD.org/src/rev/76716e17419c
branches:  trunk
changeset: 829156:76716e17419c
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Jan 20 01:32:45 2018 +0000

description:
fixes for the previous, noted by nakayama@.

- RAIDFRAME_CONFIGURE needs to be versioned as the rows was removed,
  adding RAIDFRAME_CONFIGURE80, rf_config80() etc.
- RAIDFRAME_CONFIGURE32 changes to match
- rf_get_info80() passed the wrong source to copyout()

some fixes to my original change were independantly made by nakayama@
who confirmed the changes work properly now.

diffstat:

 sys/dev/raidframe/raidframeio.h    |   5 +-
 sys/dev/raidframe/rf_compat32.h    |   4 +-
 sys/dev/raidframe/rf_compat80.c    |  75 ++++++++++++++++++++++++++++++++++++-
 sys/dev/raidframe/rf_compat80.h    |  37 ++++++++++++++++++-
 sys/dev/raidframe/rf_netbsdkintf.c |   9 +++-
 5 files changed, 121 insertions(+), 9 deletions(-)

diffs (229 lines):

diff -r 2eb1d5a3bcbe -r 76716e17419c sys/dev/raidframe/raidframeio.h
--- a/sys/dev/raidframe/raidframeio.h   Fri Jan 19 23:38:56 2018 +0000
+++ b/sys/dev/raidframe/raidframeio.h   Sat Jan 20 01:32:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raidframeio.h,v 1.8 2018/01/18 00:32:49 mrg Exp $ */
+/*     $NetBSD: raidframeio.h,v 1.9 2018/01/20 01:32:45 mrg Exp $ */
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -123,7 +123,7 @@
 #define RAIDFRAME_CHECK_RECON_STATUS_EXT _IOWR('r',  32, RF_ProgressInfo_t)
 #define RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT _IOWR ('r', 33, RF_ProgressInfo_t)
 #define RAIDFRAME_CHECK_COPYBACK_STATUS_EXT _IOWR ('r', 34, RF_ProgressInfo_t)
-#define RAIDFRAME_CONFIGURE         _IOW ('r',  35, void *)    /* configure the driver */
+/* 35 was RAIDFRAME_CONFIGURE */
 /* 36 was RAIDFRAME_GET_INFO */
 
 #define RAIDFRAME_PARITYMAP_STATUS  _IOR('r', 37, struct rf_pmstat)
@@ -132,5 +132,6 @@
 #define RAIDFRAME_PARITYMAP_SET_PARAMS _IOW('r', 40, struct rf_pmparams)
 #define RAIDFRAME_SET_LAST_UNIT _IOW('r', 41, int)
 #define RAIDFRAME_GET_INFO          _IOWR('r', 42, RF_DeviceConfig_t *)        /* get configuration */
+#define RAIDFRAME_CONFIGURE         _IOW ('r',  43, void *)    /* configure the driver */
 
 #endif                         /* !_RF_RAIDFRAMEIO_H_ */
diff -r 2eb1d5a3bcbe -r 76716e17419c sys/dev/raidframe/rf_compat32.h
--- a/sys/dev/raidframe/rf_compat32.h   Fri Jan 19 23:38:56 2018 +0000
+++ b/sys/dev/raidframe/rf_compat32.h   Sat Jan 20 01:32:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_compat32.h,v 1.1 2018/01/18 00:32:49 mrg Exp $      */
+/*     $NetBSD: rf_compat32.h,v 1.2 2018/01/20 01:32:45 mrg Exp $      */
 
 /*
  * Copyright (c) 2017 Matthew R. Green
@@ -33,7 +33,7 @@
 
 #include <compat/netbsd32/netbsd32.h>
 
-#define RAIDFRAME_CONFIGURE32         _IOW ('r',  35, netbsd32_pointer_t)      /* configure the driver */
+#define RAIDFRAME_CONFIGURE32         _IOW ('r',  43, netbsd32_pointer_t)      /* configure the driver */
 #define RAIDFRAME_GET_INFO32          _IOWR('r', 42, netbsd32_pointer_t)       /* get configuration */
 
 int rf_config_netbsd32(void *data, RF_Config_t *k_cfg);
diff -r 2eb1d5a3bcbe -r 76716e17419c sys/dev/raidframe/rf_compat80.c
--- a/sys/dev/raidframe/rf_compat80.c   Fri Jan 19 23:38:56 2018 +0000
+++ b/sys/dev/raidframe/rf_compat80.c   Sat Jan 20 01:32:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_compat80.c,v 1.1 2018/01/18 00:32:49 mrg Exp $      */
+/*     $NetBSD: rf_compat80.c,v 1.2 2018/01/20 01:32:45 mrg Exp $      */
 
 /*
  * Copyright (c) 2017 Matthew R. Green
@@ -112,7 +112,7 @@
                        rf_copy_raiddisk80(&config->spares[i],
                                           &config80->spares[i]);
                }
-               rv = copyout(&config, *configPtr80, sizeof *config80);
+               rv = copyout(config80, *configPtr80, sizeof *config80);
        }
        RF_Free(config, sizeof(RF_DeviceConfig_t));
        RF_Free(config80, sizeof(RF_DeviceConfig_t80));
@@ -146,3 +146,74 @@
 
        return retcode;
 }
+
+int
+rf_config80(RF_Raid_t *raidPtr, int unit, void *data, RF_Config_t **k_cfgp)
+{
+       RF_Config_t80 *u80_cfg, *k80_cfg;
+       RF_Config_t *k_cfg;
+       size_t i, j;
+       int error;
+
+       if (raidPtr->valid) {
+               /* There is a valid RAID set running on this unit! */
+               printf("raid%d: Device already configured!\n", unit);
+               return EINVAL;
+       }
+
+       /* copy-in the configuration information */
+       /* data points to a pointer to the configuration structure */
+
+       u80_cfg = *((RF_Config_t80 **) data);
+       RF_Malloc(k80_cfg, sizeof(RF_Config_t80), (RF_Config_t80 *));
+       if (k80_cfg == NULL)
+               return ENOMEM;
+
+       error = copyin(u80_cfg, k80_cfg, sizeof(RF_Config_t80));
+       if (error) {
+               RF_Free(k80_cfg, sizeof(RF_Config_t80));
+               return error;
+       }
+       RF_Malloc(k_cfg, sizeof(RF_Config_t), (RF_Config_t *));
+       if (k_cfg == NULL) {
+               RF_Free(k80_cfg, sizeof(RF_Config_t80));
+               return ENOMEM;
+       }
+
+       k_cfg->numCol = k80_cfg->numCol;
+       k_cfg->numSpare = k80_cfg->numSpare;
+
+       for (i = 0; i < RF_MAXROW; i++)
+               for (j = 0; j < RF_MAXCOL; j++)
+                       k_cfg->devs[i][j] = k80_cfg->devs[i][j];
+
+       memcpy(k_cfg->devnames, k80_cfg->devnames,
+           sizeof(k_cfg->devnames));
+
+       for (i = 0; i < RF_MAXSPARE; i++)
+               k_cfg->spare_devs[i] = k80_cfg->spare_devs[i];
+
+       memcpy(k_cfg->spare_names, k80_cfg->spare_names,
+           sizeof(k_cfg->spare_names));
+
+       k_cfg->sectPerSU = k80_cfg->sectPerSU;
+       k_cfg->SUsPerPU = k80_cfg->SUsPerPU;
+       k_cfg->SUsPerRU = k80_cfg->SUsPerRU;
+       k_cfg->parityConfig = k80_cfg->parityConfig;
+
+       memcpy(k_cfg->diskQueueType, k80_cfg->diskQueueType,
+           sizeof(k_cfg->diskQueueType));
+
+       k_cfg->maxOutstandingDiskReqs = k80_cfg->maxOutstandingDiskReqs;
+
+       memcpy(k_cfg->debugVars, k80_cfg->debugVars,
+           sizeof(k_cfg->debugVars));
+
+       k_cfg->layoutSpecificSize = k80_cfg->layoutSpecificSize;
+       k_cfg->layoutSpecific = k80_cfg->layoutSpecific;
+       k_cfg->force = k80_cfg->force;
+
+       RF_Free(k80_cfg, sizeof(RF_Config_t80));
+       *k_cfgp = k_cfg;
+       return 0;
+}
diff -r 2eb1d5a3bcbe -r 76716e17419c sys/dev/raidframe/rf_compat80.h
--- a/sys/dev/raidframe/rf_compat80.h   Fri Jan 19 23:38:56 2018 +0000
+++ b/sys/dev/raidframe/rf_compat80.h   Sat Jan 20 01:32:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_compat80.h,v 1.1 2018/01/18 00:32:49 mrg Exp $      */
+/*     $NetBSD: rf_compat80.h,v 1.2 2018/01/20 01:32:45 mrg Exp $      */
 
 /*
  * Copyright (c) 2017 Matthew R. Green
@@ -71,6 +71,39 @@
        RF_RaidDisk_t80 spares[RF_MAX_DISKS];
 } RF_DeviceConfig_t80;
 
+typedef struct RF_Config_s80 {
+       RF_RowCol_t numRow, numCol, numSpare;   /* number of rows, columns,
+                                                * and spare disks */
+       dev_t   devs[RF_MAXROW][RF_MAXCOL];     /* device numbers for disks
+                                                * comprising array */
+       char    devnames[RF_MAXROW][RF_MAXCOL][50];     /* device names */
+       dev_t   spare_devs[RF_MAXSPARE];        /* device numbers for spare
+                                                * disks */
+       char    spare_names[RF_MAXSPARE][50];   /* device names */
+       RF_SectorNum_t sectPerSU;       /* sectors per stripe unit */
+       RF_StripeNum_t SUsPerPU;/* stripe units per parity unit */
+       RF_StripeNum_t SUsPerRU;/* stripe units per reconstruction unit */
+       RF_ParityConfig_t parityConfig; /* identifies the RAID architecture to
+                                        * be used */
+       RF_DiskQueueType_t diskQueueType;       /* 'f' = fifo, 'c' = cvscan,
+                                                * not used in kernel */
+       char    maxOutstandingDiskReqs; /* # concurrent reqs to be sent to a
+                                        * disk.  not used in kernel. */
+       char    debugVars[RF_MAXDBGV][50];      /* space for specifying debug
+                                                * variables & their values */
+       unsigned int layoutSpecificSize;        /* size in bytes of
+                                                * layout-specific info */
+       void   *layoutSpecific; /* a pointer to a layout-specific structure to
+                                * be copied in */
+       int     force;                          /* if !0, ignore many fatal
+                                                  configuration conditions */
+       /*
+          "force" is used to override cases where the component labels would
+          indicate that configuration should not proceed without user
+          intervention
+        */
+} RF_Config_t80;
+
 /*
  * These ioctls were versioned after NetBSD 8.x.
  *
@@ -90,11 +123,13 @@
 #define RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT80     _IOWR('r', 33, RF_ProgressInfo_t *)
 #define RAIDFRAME_CHECK_COPYBACK_STATUS_EXT80          _IOWR('r', 34, RF_ProgressInfo_t *)
 #define RAIDFRAME_GET_INFO80                           _IOWR('r', 36, RF_DeviceConfig_t80 *)
+#define RAIDFRAME_CONFIGURE80                          _IOW ('r', 35, void *)
 
 int rf_check_recon_status_ext80(RF_Raid_t *, void *);
 int rf_check_parityrewrite_status_ext80(RF_Raid_t *, void *);
 int rf_check_copyback_status_ext80(RF_Raid_t *, void *);
 int rf_get_info80(RF_Raid_t *, void *);
 int rf_get_component_label80(RF_Raid_t *, void *);
+int rf_config80(RF_Raid_t *, int, void *, RF_Config_t **);
 
 #endif /* _RF_COMPAT80_H_ */
diff -r 2eb1d5a3bcbe -r 76716e17419c sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Fri Jan 19 23:38:56 2018 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Sat Jan 20 01:32:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.354 2018/01/19 09:04:23 skrll Exp $       */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.355 2018/01/20 01:32:45 mrg Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.354 2018/01/19 09:04:23 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.355 2018/01/20 01:32:45 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1149,6 +1149,11 @@
 
        case RAIDFRAME_GET_COMPONENT_LABEL80:
                return rf_get_component_label80(raidPtr, data);
+
+       case RAIDFRAME_CONFIGURE80:
+               if ((retcode = rf_config80(raidPtr, unit, data, &k_cfg)) != 0)
+                       return retcode;
+               goto config;
 #endif
 
                /* configure the system */



Home | Main Index | Thread Index | Old Index