Source-Changes-HG archive

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

[src/trunk]: src/sys Don't include the raidframe compat code in the main raid...



details:   https://anonhg.NetBSD.org/src/rev/0f9787a27adf
branches:  trunk
changeset: 448436:0f9787a27adf
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Feb 03 08:02:24 2019 +0000

description:
Don't include the raidframe compat code in the main raid module, the
compat code lives in their own compat_raid_xx modules, which will now
be autoloaded if needed.

While here, extract the compat_netbsd32_raid code into its own module,
too.

Welcome to 8.99.34

diffstat:

 sys/dev/raidframe/rf_compat32.c           |  38 +++++++++++++++++++++++++++++-
 sys/dev/raidframe/rf_compat50.c           |   6 ++--
 sys/dev/raidframe/rf_compat50_mod.h       |   5 +---
 sys/dev/raidframe/rf_compat80.c           |   6 ++--
 sys/dev/raidframe/rf_compat80_mod.h       |   5 +---
 sys/dev/raidframe/rf_netbsdkintf.c        |  39 ++++++++++++------------------
 sys/kern/compat_stub.c                    |   3 +-
 sys/modules/Makefile                      |   3 +-
 sys/modules/compat_netbsd32_raid/Makefile |  13 ++++++++++
 sys/modules/raid/Makefile                 |  21 +++++++---------
 sys/sys/compat_stub.h                     |   6 +++-
 sys/sys/param.h                           |   4 +-
 12 files changed, 94 insertions(+), 55 deletions(-)

diffs (truncated from 421 to 300 lines):

diff -r 0244d4b54588 -r 0f9787a27adf sys/dev/raidframe/rf_compat32.c
--- a/sys/dev/raidframe/rf_compat32.c   Sun Feb 03 03:28:04 2019 +0000
+++ b/sys/dev/raidframe/rf_compat32.c   Sun Feb 03 08:02:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_compat32.c,v 1.1 2018/01/18 00:32:49 mrg Exp $      */
+/*     $NetBSD: rf_compat32.c,v 1.2 2019/02/03 08:02:24 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2017 Matthew R. Green
@@ -31,6 +31,8 @@
 #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>
@@ -113,3 +115,37 @@
        RF_Free(cfg32, sizeof(RF_Config_t32));
        return rv;
 }
+
+static void
+raidframe_netbsd32_init(void)
+{
+  
+       MODULE_SET_HOOK(raidframe_netbsd32_config_hook, "raid32",
+           rf_config_netbsd32);
+}
+ 
+static void
+raidframe_netbsd32_fini(void)
+{
+ 
+       MODULE_UNSET_HOOK(raidframe_netbsd32_config_hook);
+}
+
+MODULE(MODULE_CLASS_EXEC, compat_netbsd32_raid, "raid,compat_netbsd32");
+
+static int
+compat_netbsd32_raid_modcmd(modcmd_t cmd, void *arg)
+{
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+               raidframe_netbsd32_init();
+               return 0;
+       case MODULE_CMD_FINI:
+               raidframe_netbsd32_fini();
+               return 0;
+       default:
+               return ENOTTY;
+       }
+}
+
diff -r 0244d4b54588 -r 0f9787a27adf sys/dev/raidframe/rf_compat50.c
--- a/sys/dev/raidframe/rf_compat50.c   Sun Feb 03 03:28:04 2019 +0000
+++ b/sys/dev/raidframe/rf_compat50.c   Sun Feb 03 08:02:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_compat50.c,v 1.6 2019/01/31 12:31:50 christos Exp $ */
+/*     $NetBSD: rf_compat50.c,v 1.7 2019/02/03 08:02:24 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -240,14 +240,14 @@
        return EPASSTHROUGH;
 }
 
-void
+static void
 raidframe_50_init(void)
 {
 
        MODULE_SET_HOOK(raidframe_ioctl_50_hook, "raid50", raidframe_ioctl_50);
 }
 
-void
+static void
 raidframe_50_fini(void)
 {
 
diff -r 0244d4b54588 -r 0f9787a27adf sys/dev/raidframe/rf_compat50_mod.h
--- a/sys/dev/raidframe/rf_compat50_mod.h       Sun Feb 03 03:28:04 2019 +0000
+++ b/sys/dev/raidframe/rf_compat50_mod.h       Sun Feb 03 08:02:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_compat50_mod.h,v 1.3 2019/01/31 12:31:50 christos Exp $ */
+/* $NetBSD: rf_compat50_mod.h,v 1.4 2019/02/03 08:02:24 pgoyette Exp $ */
 
 
 /*-
@@ -33,9 +33,6 @@
 #ifndef _RF_COMPAT50_MOD_H_
 #define _RF_COMPAT50_MOD_H_
 
-void raidframe_50_fini(void);
-void raidframe_50_init(void);
-
 int raidframe_ioctl_50(u_long, int, RF_Raid_t *, int, void *, RF_Config_t **);
 
 #endif /* _RF_COMPAT50_MOD_H_ */
diff -r 0244d4b54588 -r 0f9787a27adf sys/dev/raidframe/rf_compat80.c
--- a/sys/dev/raidframe/rf_compat80.c   Sun Feb 03 03:28:04 2019 +0000
+++ b/sys/dev/raidframe/rf_compat80.c   Sun Feb 03 08:02:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_compat80.c,v 1.7 2019/01/31 12:31:50 christos Exp $ */
+/*     $NetBSD: rf_compat80.c,v 1.8 2019/02/03 08:02:24 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2017 Matthew R. Green
@@ -265,14 +265,14 @@
        return EPASSTHROUGH;
 }
  
-void
+static void
 raidframe_80_init(void)
 {
   
        MODULE_SET_HOOK(raidframe_ioctl_80_hook, "raid80", raidframe_ioctl_80);
 }
  
-void
+static void
 raidframe_80_fini(void)
 {
  
diff -r 0244d4b54588 -r 0f9787a27adf sys/dev/raidframe/rf_compat80_mod.h
--- a/sys/dev/raidframe/rf_compat80_mod.h       Sun Feb 03 03:28:04 2019 +0000
+++ b/sys/dev/raidframe/rf_compat80_mod.h       Sun Feb 03 08:02:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_compat80_mod.h,v 1.3 2019/01/31 12:31:50 christos Exp $ */
+/* $NetBSD: rf_compat80_mod.h,v 1.4 2019/02/03 08:02:24 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -38,7 +38,4 @@
 int raidframe_ioctl_80(u_long, 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 -r 0244d4b54588 -r 0f9787a27adf sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c        Sun Feb 03 03:28:04 2019 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c        Sun Feb 03 08:02:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rf_netbsdkintf.c,v 1.360 2019/01/29 09:28:50 pgoyette Exp $    */
+/*     $NetBSD: rf_netbsdkintf.c,v 1.361 2019/02/03 08:02:24 pgoyette Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,11 +101,9 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.360 2019/01/29 09:28:50 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.361 2019/02/03 08:02:24 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
-#include "opt_compat_netbsd.h"
-#include "opt_compat_netbsd32.h"
 #include "opt_raid_autoconfig.h"
 #endif
 
@@ -150,11 +148,12 @@
 #include "rf_parityscan.h"
 #include "rf_threadstuff.h"
 
-#include "rf_compat50.h"
-
 #include "rf_compat80.h"
 
-#ifdef COMPAT_NETBSD32
+#ifdef _LP64
+#ifndef COMPAT_NETBSD32
+#define COMPAT_NETBSD32
+#endif
 #include "rf_compat32.h"
 #endif
 
@@ -1113,11 +1112,9 @@
        case RAIDFRAME_PARITYMAP_GET_DISABLE:
        case RAIDFRAME_PARITYMAP_SET_DISABLE:
        case RAIDFRAME_PARITYMAP_SET_PARAMS:
-#ifdef COMPAT_NETBSD32
 #ifdef _LP64
        case RAIDFRAME_GET_INFO32:
 #endif
-#endif
                if ((rs->sc_flags & RAIDF_INITED) == 0)
                        return (ENXIO);
        }
@@ -1132,6 +1129,7 @@
         * * If compat code returns EAGAIN, we need to finish via config
         * * Otherwise the cmd has been handled and we just return
         */
+       module_autoload("compat_raid_50", MODULE_CLASS_EXEC);
        MODULE_CALL_HOOK(raidframe_ioctl_50_hook,
            (cmd, (rs->sc_flags & RAIDF_INITED),raidPtr, unit, data, &k_cfg),
            enosys(), retcode);
@@ -1142,6 +1140,7 @@
        else if (retcode != EPASSTHROUGH)
                return retcode;
 
+       module_autoload("compat_raid_80", MODULE_CLASS_EXEC);
        MODULE_CALL_HOOK(raidframe_ioctl_80_hook,
            (cmd, (rs->sc_flags & RAIDF_INITED),raidPtr, unit, data, &k_cfg),
            enosys(), retcode);
@@ -1163,11 +1162,9 @@
 
                /* configure the system */
        case RAIDFRAME_CONFIGURE:
-#ifdef COMPAT_NETBSD32
 #ifdef _LP64
        case RAIDFRAME_CONFIGURE32:
 #endif
-#endif
 
                if (raidPtr->valid) {
                        /* There is a valid RAID set running on this unit! */
@@ -1182,14 +1179,13 @@
                if (k_cfg == NULL) {
                        return (ENOMEM);
                }
-#ifdef COMPAT_NETBSD32
 #ifdef _LP64
                if (cmd == RAIDFRAME_CONFIGURE32 &&
                    (l->l_proc->p_flag & PK_32) != 0)
-                       retcode = rf_config_netbsd32(data, k_cfg);
+                       MODULE_CALL_HOOK(raidframe_netbsd32_config_hook,
+                           (data, k_cfg), enosys(), retcode);
                else
 #endif
-#endif
                {
                        u_cfg = *((RF_Config_t **) data);
                        retcode = copyin(u_cfg, k_cfg, sizeof(RF_Config_t));
@@ -1321,7 +1317,7 @@
                printf("raid%d: Num Columns: %d\n", raidid, clabel->num_columns);
                printf("raid%d: Clean: %d\n", raidid, clabel->clean);
                printf("raid%d: Status: %d\n", raidid, clabel->status);
-#endif
+#endif /* DEBUG */
                clabel->row = 0;
                column = clabel->column;
 
@@ -1337,7 +1333,7 @@
                    clabel, sizeof(*clabel));
                raidflush_component_label(raidPtr, column);
                return (0);
-#endif
+#endif /* 0 */
 
        case RAIDFRAME_INIT_LABELS:
                clabel = (RF_ComponentLabel_t *) data;
@@ -1491,24 +1487,21 @@
                return(retcode);
 
        case RAIDFRAME_GET_INFO:
-#ifdef COMPAT_NETBSD32
 #ifdef _LP64
        case RAIDFRAME_GET_INFO32:
-#endif
-#endif
+#endif /* LP64 */
                RF_Malloc(d_cfg, sizeof(RF_DeviceConfig_t),
                          (RF_DeviceConfig_t *));
                if (d_cfg == NULL)
                        return (ENOMEM);
                retcode = rf_get_info(raidPtr, d_cfg);
                if (retcode == 0) {
-#ifdef COMPAT_NETBSD32
 #ifdef _LP64
-                       if (cmd == RAIDFRAME_GET_INFO32)
+                       if (raidframe_netbsd32_config_hook.hooked &&
+                           cmd == RAIDFRAME_GET_INFO32)
                                ucfgp = NETBSD32PTR64(*(netbsd32_pointer_t *)data);
                        else
-#endif
-#endif
+#endif /* _LP64 */
                                ucfgp = *(RF_DeviceConfig_t **)data;
                        retcode = copyout(d_cfg, ucfgp, sizeof(RF_DeviceConfig_t));
                }
diff -r 0244d4b54588 -r 0f9787a27adf sys/kern/compat_stub.c
--- a/sys/kern/compat_stub.c    Sun Feb 03 03:28:04 2019 +0000
+++ b/sys/kern/compat_stub.c    Sun Feb 03 08:02:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_stub.c,v 1.6 2019/01/29 09:28:50 pgoyette Exp $     */
+/* $NetBSD: compat_stub.c,v 1.7 2019/02/03 08:02:24 pgoyette Exp $     */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -114,6 +114,7 @@
  */
 struct raidframe_ioctl_50_hook_t raidframe_ioctl_50_hook;
 struct raidframe_ioctl_80_hook_t raidframe_ioctl_80_hook;
+struct raidframe_netbsd32_config_hook_t raidframe_netbsd32_config_hook;



Home | Main Index | Thread Index | Old Index