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.
This commit is contained in:
mrg 2018-01-18 00:32:48 +00:00
parent c26692bda9
commit f2b04ca083
21 changed files with 788 additions and 249 deletions

View File

@ -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 @@ and the configuration parameters associated with that section.
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 @@ each component will be given a
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 @@ particular component label must be in agreement with the other
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 @@ device.
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 @@ in case one of the three main drives should fail.
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 @@ since there is no way to recover data if any of the components fail.
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 @@ to indicate that a particular component is not present.
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 @@ in the configuration file.
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 @@ and
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 @@ fifo 100
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 @@ A RAID 0 set, for example, could be constructed from four RAID 5 sets.
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

View File

@ -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 @@ rf_output_configuration(int fd, const char *name)
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 @@ rf_fail_disk(int fd, char *component_to_fail, int do_recon)
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;

View File

@ -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 @@ rf_GetLayout(RF_ParityConfig_t parityConfig)
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 @@ rf_MakeConfig(char *configname, RF_Config_t *cfgPtr)
* 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 @@ rf_MakeConfig(char *configname, RF_Config_t *cfgPtr)
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;
}
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;
}
strlcpy(cfgPtr->devnames[r][c], b,
sizeof(cfgPtr->devnames[r][c]));
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", 0, c, b1);
b = buf;
}
strlcpy(cfgPtr->devnames[0][c], b,
sizeof(cfgPtr->devnames[0][c]));
}
/* "spare" section is optional */
@ -284,8 +290,8 @@ rf_MakeConfig(char *configname, RF_Config_t *cfgPtr)
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 */

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.1191 2018/01/10 10:56:30 knakahara Exp $
# $NetBSD: files,v 1.1192 2018/01/18 00:32:48 mrg Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
version 20171118
@ -132,7 +132,8 @@ defflag opt_todr.h TODR_DEBUG
# compatibility options
#
defflag opt_compat_netbsd.h COMPAT_NETBSD
defflag opt_compat_netbsd.h COMPAT_70: COMPAT_NETBSD
defflag opt_compat_netbsd.h COMPAT_80: COMPAT_NETBSD
defflag opt_compat_netbsd.h COMPAT_70: COMPAT_80, COMPAT_NETBSD
defflag opt_compat_netbsd.h COMPAT_60: COMPAT_70, COMPAT_NETBSD
defflag opt_compat_netbsd.h COMPAT_50: COMPAT_60, COMPAT_NETBSD
defflag opt_compat_netbsd.h COMPAT_40: COMPAT_50, COMPAT_NETBSD

View File

@ -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

View File

@ -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_ */

View File

@ -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 */
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. */
RF_SectorCount_t numBlocks; /* number of blocks, obtained via READ
* CAPACITY */
RF_SectorCount_t partitionSize; /* The *actual* and *full* size of
the partition, from the disklabel */
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,

View File

@ -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;
}

View File

@ -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_ */

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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_ */

View File

@ -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;

View File

@ -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);

View File

@ -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_ */

View File

@ -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);
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));
}
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 = 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
*/

View File

@ -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 */
}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.1 2015/12/23 08:14:06 pgoyette Exp $
# $NetBSD: Makefile,v 1.2 2018/01/18 00:32:48 mrg Exp $
.include "../Makefile.inc"
@ -28,6 +28,7 @@ SRCS+= rf_reconbuffer.c rf_reconmap.c rf_reconstruct.c
SRCS+= rf_reconutil.c rf_revent.c rf_shutdown.c
SRCS+= rf_sstf.c rf_states.c rf_stripelocks.c
SRCS+= rf_strutils.c rf_utils.c rf_compat50.c
SRCS+= rf_compat80.c
CPPFLAGS+= -DRAID_AUTOCONFIG=1
@ -42,5 +43,14 @@ CPPFLAGS+= -DRF_INCLUDE_PARITY_DECLUSTERING=1
CPPFLAGS+= -DRF_INCLUDE_PARITY_DECLUSTERING_DS=1
CPPFLAGS+= -DCOMPAT_50
CPPFLAGS+= -DCOMPAT_80
.if ${MACHINE_CPU} == "sparc64" || \
${MACHINE_CPU} == "x86_64" || \
${MACHINE_CPU} == "mips64"
SRCS+= rf_compat32.c
CPPFLAGS+= -DCOMPAT_NETBSD32
.endif
.include <bsd.kmodule.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.rump,v 1.122 2017/10/08 18:46:10 joerg Exp $
# $NetBSD: Makefile.rump,v 1.123 2018/01/18 00:32:49 mrg Exp $
#
.if !defined(_RUMP_MK)
@ -32,7 +32,7 @@ CPPFLAGS+= -DMIPS1=1
# which NetBSD compat to build
RUMP_NBCOMPAT?=default
.if ${RUMP_NBCOMPAT} == "all" || ${RUMP_NBCOMPAT} == "default"
RUMP_NBCOMPAT= 50 60 70
RUMP_NBCOMPAT= 50 60 70 80
.endif
.if ${RUMP_NBCOMPAT} == "none"
RUMP_NBCOMPAT=

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.10 2016/01/26 23:12:16 pooka Exp $
# $NetBSD: Makefile,v 1.11 2018/01/18 00:32:49 mrg Exp $
#
.PATH: ${.CURDIR}/../../../../dev/raidframe
@ -31,5 +31,9 @@ SRCS+= raidframe_component.c
SRCS+= rf_compat50.c
.endif
.if !empty(RUMP_NBCOMPAT:M80)
SRCS+= rf_compat80.c
.endif
.include <bsd.lib.mk>
.include <bsd.klinks.mk>

View File

@ -1,5 +1,5 @@
#! /usr/bin/atf-sh
# $NetBSD: t_raid.sh,v 1.12 2013/02/19 21:08:24 joerg Exp $
# $NetBSD: t_raid.sh,v 1.13 2018/01/18 00:32:49 mrg Exp $
#
# Copyright (c) 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@ -35,6 +35,22 @@ makecfg()
level=${1}
ncol=${2}
printf "START array\n${ncol} 0\nSTART disks\n" > raid.conf
diskn=0
while [ ${ncol} -gt ${diskn} ] ; do
echo "/disk${diskn}" >> raid.conf
diskn=$((diskn+1))
done
printf "START layout\n32 1 1 ${level}\nSTART queue\nfifo 100\n" \
>> raid.conf
}
makecfg_old()
{
level=${1}
ncol=${2}
printf "START array\n1 ${ncol} 0\nSTART disks\n" > raid.conf
diskn=0
while [ ${ncol} -gt ${diskn} ] ; do
@ -54,9 +70,8 @@ smalldisk_head()
atf_set "require.progs" "rump_server"
}
smalldisk_body()
smalldisk_body_backend()
{
makecfg 1 2
export RUMP_SERVER=unix://sock
atf_check -s exit:0 ${raidserver} \
-d key=/disk0,hostpath=disk0.img,size=1m \
@ -66,12 +81,37 @@ smalldisk_body()
atf_check -s exit:0 rump.raidctl -C raid.conf raid0
}
smalldisk_body()
{
makecfg 1 2
smalldisk_body_backend
}
smalldisk_cleanup()
{
export RUMP_SERVER=unix://sock
rump.halt
}
# The old configuration test case uses the smalldisk backend
atf_test_case old_numrows_config cleanup
old_numrows_config_head()
{
atf_set "descr" "Checks the old numRows configuration works"
atf_set "require.progs" "rump_server"
}
old_numrows_config_body()
{
makecfg_old 1 2
smalldisk_body_backend
}
old_numrows_config_cleanup()
{
export RUMP_SERVER=unix://sock
rump.halt
}
# make this smaller once 44239 is fixed
export RAID_MEDIASIZE=32m
@ -315,6 +355,7 @@ raid5_normal_cleanup()
atf_init_test_cases()
{
atf_add_test_case smalldisk
atf_add_test_case old_numrows_config
atf_add_test_case raid1_normal
atf_add_test_case raid1_comp0fail
atf_add_test_case raid1_compfail