summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>2018-01-18 00:32:48 +0000
committermrg <mrg@NetBSD.org>2018-01-18 00:32:48 +0000
commit0f609155b5041134ab7ed46dd9429ad04fac7270 (patch)
treec90944b6efd130dd5f8e966eb4f6ac1ea7ea2661 /sys/dev/raidframe
parent6c5d1a8bfac893a96bb3a6124a146080fcc3afbf (diff)
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 (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/files.raidframe4
-rw-r--r--sys/dev/raidframe/raidframeio.h14
-rw-r--r--sys/dev/raidframe/raidframevar.h32
-rw-r--r--sys/dev/raidframe/rf_compat32.c115
-rw-r--r--sys/dev/raidframe/rf_compat32.h41
-rw-r--r--sys/dev/raidframe/rf_compat50.c23
-rw-r--r--sys/dev/raidframe/rf_compat80.c148
-rw-r--r--sys/dev/raidframe/rf_compat80.h100
-rw-r--r--sys/dev/raidframe/rf_decluster.c7
-rw-r--r--sys/dev/raidframe/rf_decluster.h4
-rw-r--r--sys/dev/raidframe/rf_kintf.h11
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c327
-rw-r--r--sys/dev/raidframe/rf_reconutil.c6
13 files changed, 651 insertions, 181 deletions
diff --git a/sys/dev/raidframe/files.raidframe b/sys/dev/raidframe/files.raidframe
index 357a3dbee53..c0860d9917a 100644
--- a/sys/dev/raidframe/files.raidframe
+++ b/sys/dev/raidframe/files.raidframe
@@ -1,4 +1,4 @@
-# $NetBSD: files.raidframe,v 1.9 2013/04/27 21:19:19 christos Exp $
+# $NetBSD: files.raidframe,v 1.10 2018/01/18 00:32:49 mrg Exp $
defflag RAID_AUTOCONFIG
defflag RAID_DIAGNOSTIC
@@ -65,3 +65,5 @@ file dev/raidframe/rf_stripelocks.c raid
file dev/raidframe/rf_strutils.c raid
file dev/raidframe/rf_utils.c raid
file dev/raidframe/rf_compat50.c raid & compat_50
+file dev/raidframe/rf_compat80.c raid & compat_80
+file dev/raidframe/rf_compat32.c raid & compat_netbsd32
diff --git a/sys/dev/raidframe/raidframeio.h b/sys/dev/raidframe/raidframeio.h
index 27049b02be0..908fdff2b7c 100644
--- a/sys/dev/raidframe/raidframeio.h
+++ b/sys/dev/raidframe/raidframeio.h
@@ -1,4 +1,4 @@
-/* $NetBSD: raidframeio.h,v 1.7 2016/01/06 17:40:50 christos Exp $ */
+/* $NetBSD: raidframeio.h,v 1.8 2018/01/18 00:32:49 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -73,7 +73,6 @@
#define RAIDFRAME_SHUTDOWN _IO ('r', 2) /* shutdown the driver */
#define RAIDFRAME_TUR _IOW ('r', 3, dev_t) /* debug only: test unit
* ready */
-#define RAIDFRAME_TEST_ACC _IOWR('r', 4, struct rf_test_acc) /* run a test access */
#define RAIDFRAME_FAIL_DISK _IOW ('r', 5, struct rf_recon_req) /* fail a disk &
* optionally start
* recon */
@@ -106,7 +105,7 @@
* for device */
#define RAIDFRAME_KEEP_ACCTOTALS _IOW ('r', 18, int) /* turn AccTotals on or
* off for device */
-#define RAIDFRAME_GET_COMPONENT_LABEL _IOWR ('r', 19, RF_ComponentLabel_t *)
+#define RAIDFRAME_GET_COMPONENT_LABEL _IOWR ('r', 19, RF_ComponentLabel_t)
#define RAIDFRAME_SET_COMPONENT_LABEL _IOW ('r', 20, RF_ComponentLabel_t)
#define RAIDFRAME_INIT_LABELS _IOW ('r', 21, RF_ComponentLabel_t)
@@ -121,16 +120,17 @@
#define RAIDFRAME_DELETE_COMPONENT _IOW ('r', 30, RF_SingleComponent_t)
#define RAIDFRAME_INCORPORATE_HOT_SPARE _IOW ('r', 31, RF_SingleComponent_t)
/* 'Extended' status versions */
-#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_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 */
-#define RAIDFRAME_GET_INFO _IOWR('r', 36, RF_DeviceConfig_t *) /* get configuration */
+/* 36 was RAIDFRAME_GET_INFO */
#define RAIDFRAME_PARITYMAP_STATUS _IOR('r', 37, struct rf_pmstat)
#define RAIDFRAME_PARITYMAP_GET_DISABLE _IOR('r', 38, int)
#define RAIDFRAME_PARITYMAP_SET_DISABLE _IOW('r', 39, int)
#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 */
#endif /* !_RF_RAIDFRAMEIO_H_ */
diff --git a/sys/dev/raidframe/raidframevar.h b/sys/dev/raidframe/raidframevar.h
index 53d449883a6..22ae5a669bb 100644
--- a/sys/dev/raidframe/raidframevar.h
+++ b/sys/dev/raidframe/raidframevar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: raidframevar.h,v 1.17 2014/11/14 14:29:16 oster Exp $ */
+/* $NetBSD: raidframevar.h,v 1.18 2018/01/18 00:32:49 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -318,7 +318,7 @@ typedef union RF_GenericParam_u RF_CBParam_t;
* but it must be shut down first.
*/
struct RF_Config_s {
- RF_RowCol_t numRow, numCol, numSpare; /* number of rows, columns,
+ RF_RowCol_t numCol, numSpare; /* number of columns,
* and spare disks */
dev_t devs[RF_MAXROW][RF_MAXCOL]; /* device numbers for disks
* comprising array */
@@ -356,12 +356,8 @@ typedef RF_uint32 RF_ReconReqFlags_t;
#define RF_FDFLAGS_RECON 0x1 /* fail and initiate recon */
struct rf_recon_req { /* used to tell the kernel to fail a disk */
- RF_RowCol_t row, col;
+ RF_RowCol_t col;
RF_ReconReqFlags_t flags;
- void *raidPtr; /* used internally; need not be set at ioctl
- * time */
- struct rf_recon_req *next; /* used internally; need not be set at
- * ioctl time */
};
struct RF_SparetWait_s {
@@ -400,19 +396,18 @@ typedef enum RF_DiskStatus_e RF_DiskStatus_t;
struct RF_RaidDisk_s {
char devname[56]; /* name of device file */
RF_DiskStatus_t status; /* whether it is up or down */
- RF_RowCol_t spareRow; /* if in status "spared", this identifies the
- * spare disk */
RF_RowCol_t spareCol; /* if in status "spared", this identifies the
* spare disk */
+ int blockSize;
+ int auto_configured;/* 1 if this component was autoconfigured.
+ 0 otherwise. */
RF_SectorCount_t numBlocks; /* number of blocks, obtained via READ
* CAPACITY */
- int blockSize;
RF_SectorCount_t partitionSize; /* The *actual* and *full* size of
the partition, from the disklabel */
- int auto_configured;/* 1 if this component was autoconfigured.
- 0 otherwise. */
dev_t dev;
};
+#if 0
/* The per-component label information that the user can set */
typedef struct RF_ComponentInfo_s {
int row; /* the row number of this component */
@@ -420,6 +415,7 @@ typedef struct RF_ComponentInfo_s {
int serial_number; /* a user-specified serial number for this
RAID set */
} RF_ComponentInfo_t;
+#endif
/* The per-component label information */
typedef struct RF_ComponentLabel_s {
@@ -513,13 +509,12 @@ rf_component_label_set_partitionsize(RF_ComponentLabel_t *cl,
}
typedef struct RF_SingleComponent_s {
- int row;
+ int row; /* obsolete */
int column;
char component_name[50]; /* name of the component */
} RF_SingleComponent_t;
typedef struct RF_DeviceConfig_s {
- u_int rows;
u_int cols;
u_int maxqdepth;
int ndevs;
@@ -550,18 +545,18 @@ typedef struct RF_LayoutSW_s {
int (*Configure) (RF_ShutdownList_t ** shutdownListp,
RF_Raid_t * raidPtr, RF_Config_t * cfgPtr);
- /* routine to map RAID sector address -> physical (row, col, offset) */
+ /* routine to map RAID sector address -> physical (col, offset) */
void (*MapSector) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector,
RF_RowCol_t * col,
RF_SectorNum_t * diskSector, int remap);
- /* routine to map RAID sector address -> physical (r,c,o) of parity
+ /* routine to map RAID sector address -> physical (c,o) of parity
* unit */
void (*MapParity) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector,
RF_RowCol_t * col,
RF_SectorNum_t * diskSector, int remap);
- /* routine to map RAID sector address -> physical (r,c,o) of Q unit */
+ /* routine to map RAID sector address -> physical (c,o) of Q unit */
void (*MapQ) (RF_Raid_t * raidPtr, RF_RaidAddr_t raidSector,
RF_RowCol_t * col,
RF_SectorNum_t * diskSector, int remap);
@@ -592,8 +587,7 @@ typedef struct RF_LayoutSW_s {
RF_ReconUnitCount_t(*GetNumSpareRUs) (RF_Raid_t * raidPtr);
/* spare table installation (may be NULL) */
- int (*InstallSpareTable) (RF_Raid_t * raidPtr, RF_RowCol_t frow,
- RF_RowCol_t fcol);
+ int (*InstallSpareTable) (RF_Raid_t * raidPtr, RF_RowCol_t fcol);
/* recon buffer submission function */
int (*SubmitReconBuffer) (RF_ReconBuffer_t * rbuf, int keep_it,
diff --git a/sys/dev/raidframe/rf_compat32.c b/sys/dev/raidframe/rf_compat32.c
new file mode 100644
index 00000000000..b1c1ff7546d
--- /dev/null
+++ b/sys/dev/raidframe/rf_compat32.c
@@ -0,0 +1,115 @@
+/* $NetBSD: rf_compat32.c,v 1.1 2018/01/18 00:32:49 mrg Exp $ */
+
+/*
+ * Copyright (c) 2017 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <dev/raidframe/raidframeio.h>
+#include <dev/raidframe/raidframevar.h>
+
+#include "rf_raid.h"
+#include "rf_compat32.h"
+
+#include <compat/netbsd32/netbsd32.h>
+
+typedef netbsd32_int64 RF_SectorNum_t32;
+typedef netbsd32_int64 RF_StripeNum_t32;
+
+/* from <dev/raidframe/raidframevar.h> */
+typedef struct RF_Config_s32 {
+ RF_RowCol_t 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_t32 sectPerSU; /* sectors per stripe unit */
+ RF_StripeNum_t32 SUsPerPU;/* stripe units per parity unit */
+ RF_StripeNum_t32 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 */
+ netbsd32_pointer_t 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_t32 ;
+
+int
+rf_config_netbsd32(void *data, RF_Config_t *k_cfg)
+{
+ RF_Config_t32 *u_cfg = NETBSD32PTR64(*(netbsd32_pointer_t *)data);
+ struct RF_Config_s32 *cfg32;
+ int rv;
+
+ RF_Malloc(cfg32, sizeof(RF_Config_t), (RF_Config_t32 *));
+ if (cfg32 == NULL)
+ return (ENOMEM);
+
+ rv = copyin(u_cfg, cfg32, sizeof(RF_Config_t32));
+ if (rv)
+ goto out;
+
+ k_cfg->numCol = cfg32->numCol;
+ k_cfg->numSpare = cfg32->numSpare;
+ memcpy(k_cfg->devs, cfg32->devs, sizeof(k_cfg->devs));
+ memcpy(k_cfg->devnames, cfg32->devnames, sizeof(k_cfg->devnames));
+ memcpy(k_cfg->spare_devs, cfg32->spare_devs, sizeof(k_cfg->spare_devs));
+ memcpy(k_cfg->spare_names, cfg32->spare_names, sizeof(k_cfg->spare_names));
+ k_cfg->sectPerSU = cfg32->sectPerSU;
+ k_cfg->SUsPerPU = cfg32->SUsPerPU;
+ k_cfg->SUsPerRU = cfg32->SUsPerRU;
+ k_cfg->parityConfig = cfg32->parityConfig;
+ memcpy(k_cfg->diskQueueType, cfg32->diskQueueType, sizeof(k_cfg->diskQueueType));
+ k_cfg->maxOutstandingDiskReqs = cfg32->maxOutstandingDiskReqs;
+ memcpy(k_cfg->debugVars, cfg32->debugVars, sizeof(k_cfg->debugVars));
+ k_cfg->layoutSpecificSize = cfg32->layoutSpecificSize;
+ k_cfg->layoutSpecific = NETBSD32PTR64(cfg32->layoutSpecific);
+ k_cfg->force = cfg32->force;
+
+ out:
+ RF_Free(cfg32, sizeof(RF_Config_t32));
+ return rv;
+}
diff --git a/sys/dev/raidframe/rf_compat32.h b/sys/dev/raidframe/rf_compat32.h
new file mode 100644
index 00000000000..3cc430f3fb1
--- /dev/null
+++ b/sys/dev/raidframe/rf_compat32.h
@@ -0,0 +1,41 @@
+/* $NetBSD: rf_compat32.h,v 1.1 2018/01/18 00:32:49 mrg Exp $ */
+
+/*
+ * Copyright (c) 2017 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RF_NETBSD32_H_
+#define _RF_NETBSD32_H_
+
+#include <compat/netbsd32/netbsd32.h>
+
+#define RAIDFRAME_CONFIGURE32 _IOW ('r', 35, 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);
+
+#endif /* _RF_NETBSD32_H_ */
diff --git a/sys/dev/raidframe/rf_compat50.c b/sys/dev/raidframe/rf_compat50.c
index e6294d09437..e637ecb02eb 100644
--- a/sys/dev/raidframe/rf_compat50.c
+++ b/sys/dev/raidframe/rf_compat50.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_compat50.c,v 1.2 2009/05/02 21:11:26 oster Exp $ */
+/* $NetBSD: rf_compat50.c,v 1.3 2018/01/18 00:32:49 mrg Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -92,7 +92,7 @@ rf_disk_to_disk50(RF_RaidDisk50_t *d50, const RF_RaidDisk_t *d)
{
memcpy(d50->devname, d->devname, sizeof(d50->devname));
d50->status = d->status;
- d50->spareRow = d->spareRow;
+ d50->spareRow = 0;
d50->spareCol = d->spareCol;
d50->numBlocks = d->numBlocks;
d50->blockSize = d->blockSize;
@@ -134,7 +134,6 @@ rf_config50(RF_Raid_t *raidPtr, int unit, void *data, RF_Config_t **k_cfgp)
return ENOMEM;
}
- k_cfg->numRow = k50_cfg->numRow;
k_cfg->numCol = k50_cfg->numCol;
k_cfg->numSpare = k50_cfg->numSpare;
@@ -191,12 +190,16 @@ rf_get_info50(RF_Raid_t *raidPtr, void *data)
d_cfg->rows = 1; /* there is only 1 row now */
d_cfg->cols = raidPtr->numCol;
d_cfg->ndevs = raidPtr->numCol;
- if (d_cfg->ndevs >= RF_MAX_DISKS)
- goto nomem;
+ if (d_cfg->ndevs >= RF_MAX_DISKS) {
+ error = ENOMEM;
+ goto out;
+ }
d_cfg->nspares = raidPtr->numSpare;
- if (d_cfg->nspares >= RF_MAX_DISKS)
- goto nomem;
+ if (d_cfg->nspares >= RF_MAX_DISKS) {
+ error = ENOMEM;
+ goto out;
+ }
d_cfg->maxqdepth = raidPtr->maxQueueDepth;
for (j = 0; j < d_cfg->cols; j++)
@@ -206,10 +209,8 @@ rf_get_info50(RF_Raid_t *raidPtr, void *data)
rf_disk_to_disk50(&d_cfg->spares[i], &raidPtr->Disks[j]);
error = copyout(d_cfg, *ucfgp, sizeof(RF_DeviceConfig50_t));
- RF_Free(d_cfg, sizeof(RF_DeviceConfig50_t));
+out:
+ RF_Free(d_cfg, sizeof(RF_DeviceConfig50_t));
return error;
-nomem:
- RF_Free(d_cfg, sizeof(RF_DeviceConfig_t));
- return ENOMEM;
}
diff --git a/sys/dev/raidframe/rf_compat80.c b/sys/dev/raidframe/rf_compat80.c
new file mode 100644
index 00000000000..5c75f408106
--- /dev/null
+++ b/sys/dev/raidframe/rf_compat80.c
@@ -0,0 +1,148 @@
+/* $NetBSD: rf_compat80.c,v 1.1 2018/01/18 00:32:49 mrg Exp $ */
+
+/*
+ * Copyright (c) 2017 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <dev/raidframe/raidframeio.h>
+#include <dev/raidframe/raidframevar.h>
+
+#include "rf_raid.h"
+#include "rf_compat80.h"
+#include "rf_kintf.h"
+
+int
+rf_check_recon_status_ext80(RF_Raid_t *raidPtr, void *data)
+{
+ RF_ProgressInfo_t info, **infoPtr = data;
+
+ rf_check_recon_status_ext(raidPtr, &info);
+ return copyout(&info, *infoPtr, sizeof info);
+}
+
+int
+rf_check_parityrewrite_status_ext80(RF_Raid_t *raidPtr, void *data)
+{
+ RF_ProgressInfo_t info, **infoPtr = data;
+
+ rf_check_parityrewrite_status_ext(raidPtr, &info);
+ return copyout(&info, *infoPtr, sizeof info);
+}
+
+int
+rf_check_copyback_status_ext80(RF_Raid_t *raidPtr, void *data)
+{
+ RF_ProgressInfo_t info, **infoPtr = data;
+
+ rf_check_copyback_status_ext(raidPtr, &info);
+ return copyout(&info, *infoPtr, sizeof info);
+}
+
+static void
+rf_copy_raiddisk80(RF_RaidDisk_t *disk, RF_RaidDisk_t80 *disk80)
+{
+
+ /* Be sure the padding areas don't have kernel memory. */
+ memset(disk80, 0, sizeof *disk80);
+ memcpy(disk80->devname, disk->devname, sizeof(disk80->devname));
+ disk80->status = disk->status;
+ disk80->spareRow = 0;
+ disk80->spareCol = disk->spareCol;
+ disk80->numBlocks = disk->numBlocks;
+ disk80->blockSize = disk->blockSize;
+ disk80->partitionSize = disk->partitionSize;
+ disk80->auto_configured = disk->auto_configured;
+ disk80->dev = disk->dev;
+}
+
+int
+rf_get_info80(RF_Raid_t *raidPtr, void *data)
+{
+ RF_DeviceConfig_t *config;
+ RF_DeviceConfig_t80 *config80, **configPtr80 = data;
+ int rv;
+
+ RF_Malloc(config, sizeof *config, (RF_DeviceConfig_t *));
+ if (config == NULL)
+ return (ENOMEM);
+ RF_Malloc(config80, sizeof *config80, (RF_DeviceConfig_t80 *));
+ if (config80 == NULL) {
+ RF_Free(config, sizeof(RF_DeviceConfig_t))
+ return (ENOMEM);
+ }
+ rv = rf_get_info(raidPtr, config);
+ if (rv == 0) {
+ /* convert new to old */
+ config80->rows = 1;
+ config80->cols = config->cols;
+ config80->maxqdepth = config->maxqdepth;
+ config80->ndevs = config->ndevs;
+ config80->nspares = config->nspares;
+ for (size_t i = 0; i < RF_MAX_DISKS; i++) {
+ rf_copy_raiddisk80(&config->devs[i],
+ &config80->devs[i]);
+ rf_copy_raiddisk80(&config->spares[i],
+ &config80->spares[i]);
+ }
+ rv = copyout(&config, *configPtr80, sizeof *config80);
+ }
+ RF_Free(config, sizeof(RF_DeviceConfig_t));
+ RF_Free(config80, sizeof(RF_DeviceConfig_t80));
+
+ return rv;
+}
+
+int
+rf_get_component_label80(RF_Raid_t *raidPtr, void *data)
+{
+ RF_ComponentLabel_t **clabel_ptr = (RF_ComponentLabel_t **)data;
+ RF_ComponentLabel_t *clabel;
+ int retcode;
+
+ /*
+ * Perhaps there should be an option to skip the in-core
+ * copy and hit the disk, as with disklabel(8).
+ */
+ RF_Malloc(clabel, sizeof(*clabel), (RF_ComponentLabel_t *));
+ if (clabel == NULL)
+ return ENOMEM;
+ retcode = copyin(*clabel_ptr, clabel, sizeof(*clabel));
+ if (retcode) {
+ RF_Free(clabel, sizeof(*clabel));
+ return retcode;
+ }
+
+ rf_get_component_label(raidPtr, clabel);
+ retcode = copyout(clabel, *clabel_ptr, sizeof(**clabel_ptr));
+ RF_Free(clabel, sizeof(*clabel));
+
+ return retcode;
+}
diff --git a/sys/dev/raidframe/rf_compat80.h b/sys/dev/raidframe/rf_compat80.h
new file mode 100644
index 00000000000..2e1d4d65412
--- /dev/null
+++ b/sys/dev/raidframe/rf_compat80.h
@@ -0,0 +1,100 @@
+/* $NetBSD: rf_compat80.h,v 1.1 2018/01/18 00:32:49 mrg Exp $ */
+
+/*
+ * Copyright (c) 2017 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RF_COMPAT80_H_
+#define _RF_COMPAT80_H_
+
+#include <sys/ioccom.h>
+
+/* NetBSD 8.99.x removed the row, raidPtr and next members */
+struct rf_recon_req80 {
+ RF_RowCol_t row, col;
+ RF_ReconReqFlags_t flags;
+ void *raidPtr; /* used internally; need not be set at ioctl
+ * time */
+ struct rf_recon_req *next; /* used internally; need not be set at
+ * ioctl time */
+};
+
+/* NetBSD 8.99.x made this structure alignment neutral */
+typedef struct RF_RaidDisk_s80 {
+ char devname[56]; /* name of device file */
+ RF_DiskStatus_t status; /* whether it is up or down */
+ RF_RowCol_t spareRow; /* if in status "spared", this identifies the
+ * spare disk */
+ RF_RowCol_t spareCol; /* if in status "spared", this identifies the
+ * spare disk */
+ RF_SectorCount_t numBlocks; /* number of blocks, obtained via READ
+ * CAPACITY */
+ int blockSize;
+ RF_SectorCount_t partitionSize; /* The *actual* and *full* size of
+ the partition, from the disklabel */
+ int auto_configured;/* 1 if this component was autoconfigured.
+ 0 otherwise. */
+ dev_t dev;
+} RF_RaidDisk_t80;
+
+typedef struct RF_DeviceConfig_s80 {
+ u_int rows;
+ u_int cols;
+ u_int maxqdepth;
+ int ndevs;
+ RF_RaidDisk_t80 devs[RF_MAX_DISKS];
+ int nspares;
+ RF_RaidDisk_t80 spares[RF_MAX_DISKS];
+} RF_DeviceConfig_t80;
+
+/*
+ * These ioctls were versioned after NetBSD 8.x.
+ *
+ * RAIDFRAME_FAIL_DISK had unused pointers removed from the structure.
+ * RAIDFRAME_CHECK_*EXT and RAIDFRAME_GET_COMPONENT_LABEL were converted
+ * from pointers to full structures so that ioctl framework does the copyout.
+ * RAIDFRAME_GET_INFO80 had the containing structure reorganised so that
+ * the layout became bitsize neutral.
+ *
+ * These 6 changes enable COMPAT_NETBSD32 support to work sanely with
+ * these ioctls, leaving only RAIDFRAME_CONFIGURE needing extra help.
+ */
+
+#define RAIDFRAME_FAIL_DISK80 _IOW ('r', 5, struct rf_recon_req80)
+#define RAIDFRAME_GET_COMPONENT_LABEL80 _IOWR('r', 19, RF_ComponentLabel_t *)
+#define RAIDFRAME_CHECK_RECON_STATUS_EXT80 _IOWR('r', 32, RF_ProgressInfo_t *)
+#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 *)
+
+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 *);
+
+#endif /* _RF_COMPAT80_H_ */
diff --git a/sys/dev/raidframe/rf_decluster.c b/sys/dev/raidframe/rf_decluster.c
index 3f90534f566..ce1740e353d 100644
--- a/sys/dev/raidframe/rf_decluster.c
+++ b/sys/dev/raidframe/rf_decluster.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_decluster.c,v 1.24 2014/03/23 09:30:59 christos Exp $ */
+/* $NetBSD: rf_decluster.c,v 1.25 2018/01/18 00:32:49 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -48,7 +48,7 @@
*--------------------------------------------------------------------*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_decluster.c,v 1.24 2014/03/23 09:30:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_decluster.c,v 1.25 2018/01/18 00:32:49 mrg Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -608,8 +608,7 @@ rf_remap_to_spare_space(RF_RaidLayout_t *layoutPtr,
#if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0)
int
-rf_InstallSpareTable(RF_Raid_t *raidPtr, RF_RowCol_t frow,
- RF_RowCol_t fcol)
+rf_InstallSpareTable(RF_Raid_t *raidPtr, RF_RowCol_t fcol)
{
RF_DeclusteredConfigInfo_t *info = (RF_DeclusteredConfigInfo_t *) raidPtr->Layout.layoutSpecificInfo;
RF_SparetWait_t *req;
diff --git a/sys/dev/raidframe/rf_decluster.h b/sys/dev/raidframe/rf_decluster.h
index 02f1e67e560..dabfe010876 100644
--- a/sys/dev/raidframe/rf_decluster.h
+++ b/sys/dev/raidframe/rf_decluster.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_decluster.h,v 1.7 2006/04/26 17:08:48 oster Exp $ */
+/* $NetBSD: rf_decluster.h,v 1.8 2018/01/18 00:32:49 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -112,7 +112,7 @@ void
rf_MapSIDToPSIDDeclustered(RF_RaidLayout_t * layoutPtr,
RF_StripeNum_t stripeID, RF_StripeNum_t * psID,
RF_ReconUnitNum_t * which_ru);
-int rf_InstallSpareTable(RF_Raid_t * raidPtr, RF_RowCol_t frow, RF_RowCol_t fcol);
+int rf_InstallSpareTable(RF_Raid_t * raidPtr, RF_RowCol_t fcol);
void rf_FreeSpareTable(RF_Raid_t * raidPtr);
RF_HeadSepLimit_t rf_GetDefaultHeadSepLimitDeclustered(RF_Raid_t * raidPtr);
diff --git a/sys/dev/raidframe/rf_kintf.h b/sys/dev/raidframe/rf_kintf.h
index eeba4233bd3..3dea3fa4e1a 100644
--- a/sys/dev/raidframe/rf_kintf.h
+++ b/sys/dev/raidframe/rf_kintf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_kintf.h,v 1.24 2016/01/03 08:17:24 mlelstv Exp $ */
+/* $NetBSD: rf_kintf.h,v 1.25 2018/01/18 00:32:49 mrg Exp $ */
/*
* rf_kintf.h
*
@@ -61,6 +61,13 @@ void rf_print_component_label(RF_ComponentLabel_t *);
void rf_UnconfigureVnodes( RF_Raid_t * );
void rf_close_component( RF_Raid_t *, struct vnode *, int);
int rf_getdisksize(struct vnode *, RF_RaidDisk_t *);
-int rf_sync_component_caches(RF_Raid_t *raidPtr);
+int rf_sync_component_caches(RF_Raid_t *);
+
+void rf_check_recon_status_ext(RF_Raid_t *, RF_ProgressInfo_t *);
+void rf_check_parityrewrite_status_ext(RF_Raid_t *, RF_ProgressInfo_t *);
+void rf_check_copyback_status_ext(RF_Raid_t *, RF_ProgressInfo_t *);
+int rf_get_info(RF_Raid_t *, RF_DeviceConfig_t *);
+int rf_get_component_label(RF_Raid_t *, void *);
+
#endif /* _RF__RF_KINTF_H_ */
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index c5c719d3d3c..03174772114 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.352 2017/11/14 14:27:54 christos Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.353 2018/01/18 00:32:49 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,10 +101,11 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.352 2017/11/14 14:27:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.353 2018/01/18 00:32:49 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
+#include "opt_compat_netbsd32.h"
#include "opt_raid_autoconfig.h"
#endif
@@ -152,6 +153,14 @@ __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.352 2017/11/14 14:27:54 christo
#include "rf_compat50.h"
#endif
+#ifdef COMPAT_80
+#include "rf_compat80.h"
+#endif
+
+#ifdef COMPAT_NETBSD32
+#include "rf_compat32.h"
+#endif
+
#include "ioconf.h"
#ifdef DEBUG
@@ -281,6 +290,13 @@ CFATTACH_DECL3_NEW(raid, sizeof(struct raid_softc),
raid_match, raid_attach, raid_detach, NULL, NULL, NULL,
DVF_DETACH_SHUTDOWN);
+/* Internal representation of a rf_recon_req */
+struct rf_recon_req_internal {
+ RF_RowCol_t col;
+ RF_ReconReqFlags_t flags;
+ void *raidPtr;
+};
+
/*
* Allow RAIDOUTSTANDING number of simultaneous IO's to this RAID device.
* Be aware that large numbers can allow the driver to consume a lot of
@@ -315,10 +331,10 @@ static int raid_detach_unlocked(struct raid_softc *);
static void rf_markalldirty(RF_Raid_t *);
static void rf_set_geometry(struct raid_softc *, RF_Raid_t *);
-void rf_ReconThread(struct rf_recon_req *);
+void rf_ReconThread(struct rf_recon_req_internal *);
void rf_RewriteParityThread(RF_Raid_t *raidPtr);
void rf_CopybackThread(RF_Raid_t *raidPtr);
-void rf_ReconstructInPlaceThread(struct rf_recon_req *);
+void rf_ReconstructInPlaceThread(struct rf_recon_req_internal *);
int rf_autoconfig(device_t);
void rf_buildroothack(RF_ConfigSet_t *);
@@ -1036,19 +1052,18 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
RF_Raid_t *raidPtr;
RF_RaidDisk_t *diskPtr;
RF_AccTotals_t *totals;
- RF_DeviceConfig_t *d_cfg, **ucfgp;
+ RF_DeviceConfig_t *d_cfg, *ucfgp;
u_char *specific_buf;
int retcode = 0;
int column;
/* int raidid; */
- struct rf_recon_req *rrcopy, *rr;
+ struct rf_recon_req *rr;
+ struct rf_recon_req_internal *rrint;
RF_ComponentLabel_t *clabel;
RF_ComponentLabel_t *ci_label;
- RF_ComponentLabel_t **clabel_ptr;
RF_SingleComponent_t *sparePtr,*componentPtr;
RF_SingleComponent_t component;
- RF_ProgressInfo_t progressInfo, **progressInfoPtr;
- int i, j, d;
+ int d;
if ((rs = raidget(unit, false)) == NULL)
return ENXIO;
@@ -1089,6 +1104,19 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
case RAIDFRAME_PARITYMAP_GET_DISABLE:
case RAIDFRAME_PARITYMAP_SET_DISABLE:
case RAIDFRAME_PARITYMAP_SET_PARAMS:
+#ifdef COMPAT_50
+ case RAIDFRAME_GET_INFO50:
+#endif
+#ifdef COMPAT_80
+ case RAIDFRAME_CHECK_RECON_STATUS_EXT80:
+ case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT80:
+ case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT80:
+ case RAIDFRAME_GET_INFO80:
+ case RAIDFRAME_GET_COMPONENT_LABEL80:
+#endif
+#ifdef COMPAT_NETBSD32
+ case RAIDFRAME_GET_INFO32:
+#endif
if ((rs->sc_flags & RAIDF_INITED) == 0)
return (ENXIO);
}
@@ -1103,8 +1131,29 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
return retcode;
goto config;
#endif
+
+#ifdef COMPAT_80
+ case RAIDFRAME_CHECK_RECON_STATUS_EXT80:
+ return rf_check_recon_status_ext80(raidPtr, data);
+
+ case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT80:
+ return rf_check_parityrewrite_status_ext80(raidPtr, data);
+
+ case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT80:
+ return rf_check_copyback_status_ext80(raidPtr, data);
+
+ case RAIDFRAME_GET_INFO80:
+ return rf_get_info80(raidPtr, data);
+
+ case RAIDFRAME_GET_COMPONENT_LABEL80:
+ return rf_get_component_label80(raidPtr, data);
+#endif
+
/* configure the system */
case RAIDFRAME_CONFIGURE:
+#ifdef COMPAT_NETBSD32
+ case RAIDFRAME_CONFIGURE32:
+#endif
if (raidPtr->valid) {
/* There is a valid RAID set running on this unit! */
@@ -1115,12 +1164,20 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
/* copy-in the configuration information */
/* data points to a pointer to the configuration structure */
- u_cfg = *((RF_Config_t **) data);
RF_Malloc(k_cfg, sizeof(RF_Config_t), (RF_Config_t *));
if (k_cfg == NULL) {
return (ENOMEM);
}
- retcode = copyin(u_cfg, k_cfg, sizeof(RF_Config_t));
+#ifdef COMPAT_NETBSD32
+ if (cmd == RAIDFRAME_CONFIGURE32 &&
+ (l->l_proc->p_flag & PK_32) != 0)
+ retcode = rf_config_netbsd32(data, k_cfg);
+ else
+#endif
+ {
+ u_cfg = *((RF_Config_t **) data);
+ retcode = copyin(u_cfg, k_cfg, sizeof(RF_Config_t));
+ }
if (retcode) {
RF_Free(k_cfg, sizeof(RF_Config_t));
db1_printf(("rf_ioctl: retcode=%d copyin.1\n",
@@ -1226,38 +1283,7 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
return (retcode);
case RAIDFRAME_GET_COMPONENT_LABEL:
- clabel_ptr = (RF_ComponentLabel_t **) data;
- /* need to read the component label for the disk indicated
- by row,column in clabel */
-
- /*
- * Perhaps there should be an option to skip the in-core
- * copy and hit the disk, as with disklabel(8).
- */
- RF_Malloc(clabel, sizeof(*clabel), (RF_ComponentLabel_t *));
-
- retcode = copyin(*clabel_ptr, clabel, sizeof(*clabel));
-
- if (retcode) {
- RF_Free(clabel, sizeof(*clabel));
- return retcode;
- }
-
- clabel->row = 0; /* Don't allow looking at anything else.*/
-
- column = clabel->column;
-
- if ((column < 0) || (column >= raidPtr->numCol +
- raidPtr->numSpare)) {
- RF_Free(clabel, sizeof(*clabel));
- return EINVAL;
- }
-
- RF_Free(clabel, sizeof(*clabel));
-
- clabel = raidget_component_label(raidPtr, column);
-
- return copyout(clabel, *clabel_ptr, sizeof(**clabel_ptr));
+ return rf_get_component_label(raidPtr, data);
#if 0
case RAIDFRAME_SET_COMPONENT_LABEL:
@@ -1436,52 +1462,36 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
}
rf_unlock_mutex2(raidPtr->mutex);
- RF_Malloc(rrcopy, sizeof(*rrcopy), (struct rf_recon_req *));
- if (rrcopy == NULL)
+ RF_Malloc(rrint, sizeof(*rrint), (struct rf_recon_req_internal *));
+ if (rrint == NULL)
return(ENOMEM);
- rrcopy->raidPtr = (void *) raidPtr;
- rrcopy->col = column;
+ rrint->col = column;
+ rrint->raidPtr = raidPtr;
retcode = RF_CREATE_THREAD(raidPtr->recon_thread,
rf_ReconstructInPlaceThread,
- rrcopy,"raid_reconip");
+ rrint, "raid_reconip");
return(retcode);
case RAIDFRAME_GET_INFO:
- if (!raidPtr->valid)
- return (ENODEV);
- ucfgp = (RF_DeviceConfig_t **) data;
+#ifdef COMPAT_NETBSD32
+ case RAIDFRAME_GET_INFO32:
+#endif
RF_Malloc(d_cfg, sizeof(RF_DeviceConfig_t),
(RF_DeviceConfig_t *));
if (d_cfg == NULL)
return (ENOMEM);
- d_cfg->rows = 1; /* there is only 1 row now */
- d_cfg->cols = raidPtr->numCol;
- d_cfg->ndevs = raidPtr->numCol;
- if (d_cfg->ndevs >= RF_MAX_DISKS) {
- RF_Free(d_cfg, sizeof(RF_DeviceConfig_t));
- return (ENOMEM);
- }
- d_cfg->nspares = raidPtr->numSpare;
- if (d_cfg->nspares >= RF_MAX_DISKS) {
- RF_Free(d_cfg, sizeof(RF_DeviceConfig_t));
- return (ENOMEM);
- }
- d_cfg->maxqdepth = raidPtr->maxQueueDepth;
- d = 0;
- for (j = 0; j < d_cfg->cols; j++) {
- d_cfg->devs[d] = raidPtr->Disks[j];
- d++;
- }
- for (j = d_cfg->cols, i = 0; i < d_cfg->nspares; i++, j++) {
- d_cfg->spares[i] = raidPtr->Disks[j];
- if (d_cfg->spares[i].status == rf_ds_rebuilding_spare) {
- /* XXX: raidctl(8) expects to see this as a used spare */
- d_cfg->spares[i].status = rf_ds_used_spare;
- }
+ retcode = rf_get_info(raidPtr, d_cfg);
+ if (retcode == 0) {
+#ifdef COMPAT_NETBSD32
+ if (cmd == RAIDFRAME_GET_INFO32)
+ ucfgp = NETBSD32PTR64(*(netbsd32_pointer_t *)data);
+ else
+#endif
+ ucfgp = *(RF_DeviceConfig_t **)data;
+ retcode = copyout(d_cfg, ucfgp, sizeof(RF_DeviceConfig_t));
}
- retcode = copyout(d_cfg, *ucfgp, sizeof(RF_DeviceConfig_t));
RF_Free(d_cfg, sizeof(RF_DeviceConfig_t));
return (retcode);
@@ -1539,6 +1549,9 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
/* fail a disk & optionally start reconstruction */
case RAIDFRAME_FAIL_DISK:
+#ifdef COMPAT_80
+ case RAIDFRAME_FAIL_DISK80:
+#endif
if (raidPtr->Layout.map->faultsTolerated == 0) {
/* Can't do this on a RAID 0!! */
@@ -1546,11 +1559,9 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
}
rr = (struct rf_recon_req *) data;
- rr->row = 0;
if (rr->col < 0 || rr->col >= raidPtr->numCol)
return (EINVAL);
-
rf_lock_mutex2(raidPtr->mutex);
if (raidPtr->status == rf_rs_reconstructing) {
/* you can't fail a disk while we're reconstructing! */
@@ -1574,15 +1585,16 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
/* make a copy of the recon request so that we don't rely on
* the user's buffer */
- RF_Malloc(rrcopy, sizeof(*rrcopy), (struct rf_recon_req *));
- if (rrcopy == NULL)
+ RF_Malloc(rrint, sizeof(*rrint), (struct rf_recon_req_internal *));
+ if (rrint == NULL)
return(ENOMEM);
- memcpy(rrcopy, rr, sizeof(*rr));
- rrcopy->raidPtr = (void *) raidPtr;
+ rrint->col = rr->col;
+ rrint->flags = rr->flags;
+ rrint->raidPtr = raidPtr;
retcode = RF_CREATE_THREAD(raidPtr->recon_thread,
rf_ReconThread,
- rrcopy,"raid_recon");
+ rrint, "raid_recon");
return (0);
/* invoke a copyback operation after recon on whatever disk
@@ -1623,22 +1635,8 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
}
return (0);
case RAIDFRAME_CHECK_RECON_STATUS_EXT:
- progressInfoPtr = (RF_ProgressInfo_t **) data;
- if (raidPtr->status != rf_rs_reconstructing) {
- progressInfo.remaining = 0;
- progressInfo.completed = 100;
- progressInfo.total = 100;
- } else {
- progressInfo.total =
- raidPtr->reconControl->numRUsTotal;
- progressInfo.completed =
- raidPtr->reconControl->numRUsComplete;
- progressInfo.remaining = progressInfo.total -
- progressInfo.completed;
- }
- retcode = copyout(&progressInfo, *progressInfoPtr,
- sizeof(RF_ProgressInfo_t));
- return (retcode);
+ rf_check_recon_status_ext(raidPtr, data);
+ return (0);
case RAIDFRAME_CHECK_PARITYREWRITE_STATUS:
if (raidPtr->Layout.map->faultsTolerated == 0) {
@@ -1657,21 +1655,8 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
return (0);
case RAIDFRAME_CHECK_PARITYREWRITE_STATUS_EXT:
- progressInfoPtr = (RF_ProgressInfo_t **) data;
- if (raidPtr->parity_rewrite_in_progress == 1) {
- progressInfo.total = raidPtr->Layout.numStripe;
- progressInfo.completed =
- raidPtr->parity_rewrite_stripes_done;
- progressInfo.remaining = progressInfo.total -
- progressInfo.completed;
- } else {
- progressInfo.remaining = 0;
- progressInfo.completed = 100;
- progressInfo.total = 100;
- }
- retcode = copyout(&progressInfo, *progressInfoPtr,
- sizeof(RF_ProgressInfo_t));
- return (retcode);
+ rf_check_parityrewrite_status_ext(raidPtr, data);
+ return (0);
case RAIDFRAME_CHECK_COPYBACK_STATUS:
if (raidPtr->Layout.map->faultsTolerated == 0) {
@@ -1688,21 +1673,8 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
return (0);
case RAIDFRAME_CHECK_COPYBACK_STATUS_EXT:
- progressInfoPtr = (RF_ProgressInfo_t **) data;
- if (raidPtr->copyback_in_progress == 1) {
- progressInfo.total = raidPtr->Layout.numStripe;
- progressInfo.completed =
- raidPtr->copyback_stripes_done;
- progressInfo.remaining = progressInfo.total -
- progressInfo.completed;
- } else {
- progressInfo.remaining = 0;
- progressInfo.completed = 100;
- progressInfo.total = 100;
- }
- retcode = copyout(&progressInfo, *progressInfoPtr,
- sizeof(RF_ProgressInfo_t));
- return (retcode);
+ rf_check_copyback_status_ext(raidPtr, data);
+ return 0;
case RAIDFRAME_SET_LAST_UNIT:
for (column = 0; column < raidPtr->numCol; column++)
@@ -2651,7 +2623,7 @@ rf_UnconfigureVnodes(RF_Raid_t *raidPtr)
void
-rf_ReconThread(struct rf_recon_req *req)
+rf_ReconThread(struct rf_recon_req_internal *req)
{
int s;
RF_Raid_t *raidPtr;
@@ -2721,7 +2693,7 @@ rf_CopybackThread(RF_Raid_t *raidPtr)
void
-rf_ReconstructInPlaceThread(struct rf_recon_req *req)
+rf_ReconstructInPlaceThread(struct rf_recon_req_internal *req)
{
int s;
RF_Raid_t *raidPtr;
@@ -3336,7 +3308,6 @@ rf_create_configuration(RF_AutoConfig_t *ac, RF_Config_t *config,
clabel = ac->clabel;
/* 1. Fill in the common stuff */
- config->numRow = clabel->num_rows = 1;
config->numCol = clabel->num_columns;
config->numSpare = 0; /* XXX should this be set here? */
config->sectPerSU = clabel->sectPerSU;
@@ -3775,6 +3746,98 @@ rf_sync_component_caches(RF_Raid_t *raidPtr)
return error;
}
+/* Fill in info with the current status */
+void
+rf_check_recon_status_ext(RF_Raid_t *raidPtr, RF_ProgressInfo_t *info)
+{
+
+ if (raidPtr->status != rf_rs_reconstructing) {
+ info->total = 100;
+ info->completed = 100;
+ } else {
+ info->total = raidPtr->reconControl->numRUsTotal;
+ info->completed = raidPtr->reconControl->numRUsComplete;
+ }
+ info->remaining = info->total - info->completed;
+}
+
+/* Fill in info with the current status */
+void
+rf_check_parityrewrite_status_ext(RF_Raid_t *raidPtr, RF_ProgressInfo_t *info)
+{
+
+ if (raidPtr->parity_rewrite_in_progress == 1) {
+ info->total = raidPtr->Layout.numStripe;
+ info->completed = raidPtr->parity_rewrite_stripes_done;
+ } else {
+ info->completed = 100;
+ info->total = 100;
+ }
+ info->remaining = info->total - info->completed;
+}
+
+/* Fill in info with the current status */
+void
+rf_check_copyback_status_ext(RF_Raid_t *raidPtr, RF_ProgressInfo_t *info)
+{
+
+ if (raidPtr->copyback_in_progress == 1) {
+ info->total = raidPtr->Layout.numStripe;
+ info->completed = raidPtr->copyback_stripes_done;
+ info->remaining = info->total - info->completed;
+ } else {
+ info->remaining = 0;
+ info->completed = 100;
+ info->total = 100;
+ }
+}
+
+/* Fill in config with the current info */
+int
+rf_get_info(RF_Raid_t *raidPtr, RF_DeviceConfig_t *config)
+{
+ int d, i, j;
+
+ if (!raidPtr->valid)
+ return (ENODEV);
+ config->cols = raidPtr->numCol;
+ config->ndevs = raidPtr->numCol;
+ if (config->ndevs >= RF_MAX_DISKS)
+ return (ENOMEM);
+ config->nspares = raidPtr->numSpare;
+ if (config->nspares >= RF_MAX_DISKS)
+ return (ENOMEM);
+ config->maxqdepth = raidPtr->maxQueueDepth;
+ d = 0;
+ for (j = 0; j < config->cols; j++) {
+ config->devs[d] = raidPtr->Disks[j];
+ d++;
+ }
+ for (j = config->cols, i = 0; i < config->nspares; i++, j++) {
+ config->spares[i] = raidPtr->Disks[j];
+ if (config->spares[i].status == rf_ds_rebuilding_spare) {
+ /* XXX: raidctl(8) expects to see this as a used spare */
+ config->spares[i].status = rf_ds_used_spare;
+ }
+ }
+ return 0;
+}
+
+int
+rf_get_component_label(RF_Raid_t *raidPtr, void *data)
+{
+ RF_ComponentLabel_t *clabel = (RF_ComponentLabel_t *)data;
+ RF_ComponentLabel_t *raid_clabel;
+ int column = clabel->column;
+
+ if ((column < 0) || (column >= raidPtr->numCol + raidPtr->numSpare))
+ return EINVAL;
+ raid_clabel = raidget_component_label(raidPtr, column);
+ memcpy(clabel, raid_clabel, sizeof *clabel);
+
+ return 0;
+}
+
/*
* Module interface
*/
diff --git a/sys/dev/raidframe/rf_reconutil.c b/sys/dev/raidframe/rf_reconutil.c
index f23c0356b7f..e06e9b1940d 100644
--- a/sys/dev/raidframe/rf_reconutil.c
+++ b/sys/dev/raidframe/rf_reconutil.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_reconutil.c,v 1.35 2013/09/15 12:48:58 martin Exp $ */
+/* $NetBSD: rf_reconutil.c,v 1.36 2018/01/18 00:32:49 mrg Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -31,7 +31,7 @@
********************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.35 2013/09/15 12:48:58 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconutil.c,v 1.36 2018/01/18 00:32:49 mrg Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -109,7 +109,7 @@ rf_MakeReconControl(RF_RaidReconDesc_t *reconDesc,
* Not all distributed sparing archs need dynamic mappings
*/
if (lp->InstallSpareTable) {
- retcode = rf_InstallSpareTable(raidPtr, 0, fcol);
+ retcode = rf_InstallSpareTable(raidPtr, fcol);
if (retcode) {
RF_PANIC(); /* XXX fix this */
}