diff options
| author | pgoyette <pgoyette@NetBSD.org> | 2019-01-27 02:08:33 +0000 |
|---|---|---|
| committer | pgoyette <pgoyette@NetBSD.org> | 2019-01-27 02:08:33 +0000 |
| commit | cc17ee2ece085d7d746bcd8fa9be19170855aaac (patch) | |
| tree | 5be40613f405cb081b2c44410b1506781927f8e3 /sys/dev/raidframe | |
| parent | 10dd4cc92542aa04b0e59469a484a48e4c3cdd24 (diff) | |
Merge the [pgoyette-compat] branch
Diffstat (limited to 'sys/dev/raidframe')
| -rw-r--r-- | sys/dev/raidframe/rf_compat50.c | 59 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_compat50.h | 4 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_compat50_mod.h | 39 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_compat80.c | 81 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_compat80_mod.h | 44 | ||||
| -rw-r--r-- | sys/dev/raidframe/rf_netbsdkintf.c | 92 |
6 files changed, 267 insertions, 52 deletions
diff --git a/sys/dev/raidframe/rf_compat50.c b/sys/dev/raidframe/rf_compat50.c index e637ecb02eb..108385a5481 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.3 2018/01/18 00:32:49 mrg Exp $ */ +/* $NetBSD: rf_compat50.c,v 1.4 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -39,12 +39,16 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> +#include <sys/module.h> + +#include <sys/compat_stub.h> #include <dev/raidframe/raidframeio.h> #include <dev/raidframe/raidframevar.h> #include "rf_raid.h" #include "rf_compat50.h" +#include "rf_compat50_mod.h" #include "rf_debugMem.h" typedef struct RF_Config50_s { @@ -214,3 +218,56 @@ out: RF_Free(d_cfg, sizeof(RF_DeviceConfig50_t)); return error; } + +int +raidframe_ioctl_50(int cmd, int initted, RF_Raid_t *raidPtr, int unit, + void *data, RF_Config_t **k_cfg) +{ + int error; + + switch (cmd) { + case RAIDFRAME_GET_INFO50: + if (initted == 0) + return ENXIO; + return rf_get_info50(raidPtr, data); + + case RAIDFRAME_CONFIGURE50: + error = rf_config50(raidPtr, unit, data, k_cfg); + if (error != 0) + return error; + return EAGAIN; /* flag mainline to call generic config */ + } + return EPASSTHROUGH; +} + +void +raidframe_50_init(void) +{ + + MODULE_SET_HOOK(raidframe50_ioctl_hook, "raid50", raidframe_ioctl_50); +} + +void +raidframe_50_fini(void) +{ + + MODULE_UNSET_HOOK(raidframe50_ioctl_hook); +} + +MODULE(MODULE_CLASS_EXEC, compat_raid_50, "raid,compat_50,compat_raid_80"); + +static int +compat_raid_50_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + raidframe_50_init(); + return 0; + case MODULE_CMD_FINI: + raidframe_50_fini(); + return 0; + default: + return ENOTTY; + } +} diff --git a/sys/dev/raidframe/rf_compat50.h b/sys/dev/raidframe/rf_compat50.h index 29990c8f4dc..69d3aa82593 100644 --- a/sys/dev/raidframe/rf_compat50.h +++ b/sys/dev/raidframe/rf_compat50.h @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat50.h,v 1.2 2015/09/06 06:01:00 dholland Exp $ */ +/* $NetBSD: rf_compat50.h,v 1.3 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -47,4 +47,6 @@ int rf_config50(RF_Raid_t *, int, void *, RF_Config_t **); int rf_get_info50(RF_Raid_t *, void *); +int raidframe_ioctl_50(int, int, RF_Raid_t *, int, void *, RF_Config_t **); + #endif /* _RF_COMPAT50_H_ */ diff --git a/sys/dev/raidframe/rf_compat50_mod.h b/sys/dev/raidframe/rf_compat50_mod.h new file mode 100644 index 00000000000..a9447d00beb --- /dev/null +++ b/sys/dev/raidframe/rf_compat50_mod.h @@ -0,0 +1,39 @@ +/* $NetBSD: rf_compat50_mod.h,v 1.2 2019/01/27 02:08:42 pgoyette Exp $ */ + + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Goyette + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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_COMPAT50_MOD_H_ +#define _RF_COMPAT50_MOD_H_ + +void raidframe_50_fini(void); +void raidframe_50_init(void); + +#endif /* _RF_COMPAT50_MOD_H_ */ diff --git a/sys/dev/raidframe/rf_compat80.c b/sys/dev/raidframe/rf_compat80.c index 53b963da8a3..b6a204b41e4 100644 --- a/sys/dev/raidframe/rf_compat80.c +++ b/sys/dev/raidframe/rf_compat80.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_compat80.c,v 1.2 2018/01/20 01:32:45 mrg Exp $ */ +/* $NetBSD: rf_compat80.c,v 1.3 2019/01/27 02:08:42 pgoyette Exp $ */ /* * Copyright (c) 2017 Matthew R. Green @@ -31,12 +31,16 @@ #include <sys/types.h> #include <sys/param.h> #include <sys/systm.h> +#include <sys/module.h> + +#include <sys/compat_stub.h> #include <dev/raidframe/raidframeio.h> #include <dev/raidframe/raidframevar.h> #include "rf_raid.h" #include "rf_compat80.h" +#include "rf_compat80_mod.h" #include "rf_kintf.h" int @@ -217,3 +221,78 @@ rf_config80(RF_Raid_t *raidPtr, int unit, void *data, RF_Config_t **k_cfgp) *k_cfgp = k_cfg; return 0; } + +int +raidframe_ioctl_80(int cmd, int initted, RF_Raid_t *raidPtr, int unit, + void *data, RF_Config_t **k_cfg) +{ +int error; + + switch (cmd) { + 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: + if (initted == 0) + return ENXIO; + break; + case RAIDFRAME_CONFIGURE80: + break; + case RAIDFRAME_FAIL_DISK80: + return EPASSTHROUGH; + default: + return EINVAL; + } + + switch (cmd) { + 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); + case RAIDFRAME_CONFIGURE80: + error = rf_config80(raidPtr, unit, data, k_cfg); + if (error != 0) + return error; + return EAGAIN; /* flag mainline to call generic config */ + } + return EPASSTHROUGH; +} + +void +raidframe_80_init(void) +{ + + MODULE_SET_HOOK(raidframe80_ioctl_hook, "raid80", raidframe_ioctl_80); +} + +void +raidframe_80_fini(void) +{ + + MODULE_UNSET_HOOK(raidframe80_ioctl_hook); +} + +MODULE(MODULE_CLASS_EXEC, compat_raid_80, "raid,compat_80"); + +static int +compat_raid_80_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + raidframe_80_init(); + return 0; + case MODULE_CMD_FINI: + raidframe_80_fini(); + return 0; + default: + return ENOTTY; + } +} diff --git a/sys/dev/raidframe/rf_compat80_mod.h b/sys/dev/raidframe/rf_compat80_mod.h new file mode 100644 index 00000000000..9f0a627e5d8 --- /dev/null +++ b/sys/dev/raidframe/rf_compat80_mod.h @@ -0,0 +1,44 @@ +/* $NetBSD: rf_compat80_mod.h,v 1.2 2019/01/27 02:08:42 pgoyette Exp $ */ + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Goyette + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``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 FOUNDATION OR CONTRIBUTORS + * 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_MOD_H_ +#define _RF_COMPAT80_MOD_H_ + +struct RF_Raid_s; +struct RF_Config_s; + +int raidframe_ioctl_80(int, int, struct RF_Raid_s *, int, void *, + struct RF_Config_s **); + +void raidframe_80_init(void); +void raidframe_80_fini(void); + +#endif /* _RF_COMPAT80_MOD_H_ */ diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 67182036a93..f373aaf0397 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.357 2019/01/08 07:18:18 mrg Exp $ */ +/* $NetBSD: rf_netbsdkintf.c,v 1.358 2019/01/27 02:08:42 pgoyette Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. @@ -101,7 +101,7 @@ ***********************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.357 2019/01/08 07:18:18 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.358 2019/01/27 02:08:42 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -128,6 +128,7 @@ __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.357 2019/01/08 07:18:18 mrg Exp #include <sys/reboot.h> #include <sys/kauth.h> #include <sys/module.h> +#include <sys/compat_stub.h> #include <prop/proplib.h> @@ -149,13 +150,9 @@ __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.357 2019/01/08 07:18:18 mrg Exp #include "rf_parityscan.h" #include "rf_threadstuff.h" -#ifdef COMPAT_50 #include "rf_compat50.h" -#endif -#ifdef COMPAT_80 #include "rf_compat80.h" -#endif #ifdef COMPAT_NETBSD32 #include "rf_compat32.h" @@ -1104,16 +1101,6 @@ 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 #ifdef _LP64 case RAIDFRAME_GET_INFO32: @@ -1123,38 +1110,44 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) return (ENXIO); } - switch (cmd) { -#ifdef COMPAT_50 - case RAIDFRAME_GET_INFO50: - return rf_get_info50(raidPtr, data); - - case RAIDFRAME_CONFIGURE50: - if ((retcode = rf_config50(raidPtr, unit, data, &k_cfg)) != 0) - return retcode; + /* + * Handle compat ioctl calls + * + * * If compat code is not loaded, stub returns ENOSYS and we just + * check the "native" cmd's + * * If compat code is loaded but does not recognize the cmd, it + * returns EPASSTHROUGH, and we just check the "native" cmd's + * * If compat code returns EAGAIN, we need to finish via config + * * Otherwise the cmd has been handled and we just return + */ + MODULE_CALL_HOOK(raidframe50_ioctl_hook, + (cmd, (rs->sc_flags & RAIDF_INITED),raidPtr, unit, data, &k_cfg), + enosys(), retcode); + if (retcode == ENOSYS) + retcode = 0; + else if (retcode == EAGAIN) 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); + else if (retcode != EPASSTHROUGH) + return retcode; + + MODULE_CALL_HOOK(raidframe80_ioctl_hook, + (cmd, (rs->sc_flags & RAIDF_INITED),raidPtr, unit, data, &k_cfg), + enosys(), retcode); + if (retcode == ENOSYS) + retcode = 0; + else if (retcode == EAGAIN) + goto config; + else if (retcode != EPASSTHROUGH) + return retcode; - case RAIDFRAME_GET_COMPONENT_LABEL80: - return rf_get_component_label80(raidPtr, data); + /* + * XXX + * Handling of FAIL_DISK80 command requires us to retain retcode's + * value of EPASSTHROUGH. If you add more compat code later, make + * sure you don't overwrite retcode and break this! + */ - case RAIDFRAME_CONFIGURE80: - if ((retcode = rf_config80(raidPtr, unit, data, &k_cfg)) != 0) - return retcode; - goto config; -#endif + switch (cmd) { /* configure the system */ case RAIDFRAME_CONFIGURE: @@ -1563,11 +1556,12 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) return (0); /* fail a disk & optionally start reconstruction */ - case RAIDFRAME_FAIL_DISK: -#ifdef COMPAT_80 case RAIDFRAME_FAIL_DISK80: -#endif - + /* Check if we called compat code for this cmd */ + if (retcode != EPASSTHROUGH) + return EINVAL; + /* FALLTHRU */ + case RAIDFRAME_FAIL_DISK: if (raidPtr->Layout.map->faultsTolerated == 0) { /* Can't do this on a RAID 0!! */ return(EINVAL); |
