Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/raidframe fix the function pointer and callback mess:
details: https://anonhg.NetBSD.org/src/rev/e8d86d6f706c
branches: trunk
changeset: 1004052:e8d86d6f706c
user: christos <christos%NetBSD.org@localhost>
date: Thu Oct 10 03:43:59 2019 +0000
description:
fix the function pointer and callback mess:
- callback functions return 0 and their result is not checked; make them void.
- there are two types of callbacks and they used to overload their parameters
and the callback structure; separate them into "function" and "value"
callbacks.
- make the wait function signature consistent.
diffstat:
sys/dev/raidframe/raidframevar.h | 5 +-
sys/dev/raidframe/rf_callback.c | 35 +++++++--
sys/dev/raidframe/rf_callback.h | 23 ++++--
sys/dev/raidframe/rf_copyback.c | 26 +++---
sys/dev/raidframe/rf_dag.h | 10 +-
sys/dev/raidframe/rf_dagdegrd.c | 6 +-
sys/dev/raidframe/rf_dagdegrd.h | 4 +-
sys/dev/raidframe/rf_dagdegwr.c | 8 +-
sys/dev/raidframe/rf_dagdegwr.h | 6 +-
sys/dev/raidframe/rf_dagffrd.c | 8 +-
sys/dev/raidframe/rf_dagffwr.c | 10 +-
sys/dev/raidframe/rf_dagffwr.h | 38 +++++-----
sys/dev/raidframe/rf_dagfuncs.c | 110 +++++++++++++-----------------
sys/dev/raidframe/rf_dagfuncs.h | 52 +++++++-------
sys/dev/raidframe/rf_dagutils.c | 10 +-
sys/dev/raidframe/rf_dagutils.h | 12 +-
sys/dev/raidframe/rf_desc.h | 4 +-
sys/dev/raidframe/rf_diskqueue.c | 6 +-
sys/dev/raidframe/rf_diskqueue.h | 6 +-
sys/dev/raidframe/rf_driver.c | 8 +-
sys/dev/raidframe/rf_engine.c | 9 +-
sys/dev/raidframe/rf_engine.h | 4 +-
sys/dev/raidframe/rf_evenodd_dagfuncs.c | 50 ++++---------
sys/dev/raidframe/rf_evenodd_dagfuncs.h | 20 ++--
sys/dev/raidframe/rf_evenodd_dags.c | 8 +-
sys/dev/raidframe/rf_netbsd.h | 5 +-
sys/dev/raidframe/rf_paritylog.c | 8 +-
sys/dev/raidframe/rf_paritylog.h | 7 +-
sys/dev/raidframe/rf_paritylogDiskMgr.c | 9 +-
sys/dev/raidframe/rf_paritylogDiskMgr.h | 4 +-
sys/dev/raidframe/rf_parityloggingdags.c | 10 +-
sys/dev/raidframe/rf_parityloggingdags.h | 6 +-
sys/dev/raidframe/rf_parityscan.c | 8 +-
sys/dev/raidframe/rf_parityscan.h | 4 +-
sys/dev/raidframe/rf_pq.c | 20 ++--
sys/dev/raidframe/rf_pq.h | 22 +++---
sys/dev/raidframe/rf_psstatus.c | 17 ++--
sys/dev/raidframe/rf_psstatus.h | 8 +-
sys/dev/raidframe/rf_raid.h | 4 +-
sys/dev/raidframe/rf_raid1.c | 10 +-
sys/dev/raidframe/rf_reconbuffer.c | 14 +-
sys/dev/raidframe/rf_reconstruct.c | 67 +++++++++---------
sys/dev/raidframe/rf_reconstruct.h | 9 +-
sys/dev/raidframe/rf_states.c | 27 +++---
sys/dev/raidframe/rf_states.h | 4 +-
sys/dev/raidframe/rf_stripelocks.h | 4 +-
46 files changed, 363 insertions(+), 382 deletions(-)
diffs (truncated from 2338 to 300 lines):
diff -r 02c0ef9913d8 -r e8d86d6f706c sys/dev/raidframe/raidframevar.h
--- a/sys/dev/raidframe/raidframevar.h Thu Oct 10 02:39:07 2019 +0000
+++ b/sys/dev/raidframe/raidframevar.h Thu Oct 10 03:43:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: raidframevar.h,v 1.20 2019/09/26 01:36:10 christos Exp $ */
+/* $NetBSD: raidframevar.h,v 1.21 2019/10/10 03:43:59 christos Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -210,7 +210,8 @@
typedef struct RF_AccessStripeMap_s RF_AccessStripeMap_t;
typedef struct RF_AccessStripeMapHeader_s RF_AccessStripeMapHeader_t;
typedef struct RF_AllocListElem_s RF_AllocListElem_t;
-typedef struct RF_CallbackDesc_s RF_CallbackDesc_t;
+typedef struct RF_CallbackFuncDesc_s RF_CallbackFuncDesc_t;
+typedef struct RF_CallbackValueDesc_s RF_CallbackValueDesc_t;
typedef struct RF_ChunkDesc_s RF_ChunkDesc_t;
typedef struct RF_CommonLogData_s RF_CommonLogData_t;
typedef struct RF_Config_s RF_Config_t;
diff -r 02c0ef9913d8 -r e8d86d6f706c sys/dev/raidframe/rf_callback.c
--- a/sys/dev/raidframe/rf_callback.c Thu Oct 10 02:39:07 2019 +0000
+++ b/sys/dev/raidframe/rf_callback.c Thu Oct 10 03:43:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_callback.c,v 1.23 2019/02/10 17:13:33 christos Exp $ */
+/* $NetBSD: rf_callback.c,v 1.24 2019/10/10 03:43:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_callback.c,v 1.23 2019/02/10 17:13:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_callback.c,v 1.24 2019/10/10 03:43:59 christos Exp $");
#include <dev/raidframe/raidframevar.h>
#include <sys/pool.h>
@@ -54,28 +54,43 @@
static void
rf_ShutdownCallback(void *ignored)
{
- pool_destroy(&rf_pools.callback);
+ pool_destroy(&rf_pools.callbackf);
+ pool_destroy(&rf_pools.callbackv);
}
int
rf_ConfigureCallback(RF_ShutdownList_t **listp)
{
- rf_pool_init(&rf_pools.callback, sizeof(RF_CallbackDesc_t),
- "rf_callbackpl", RF_MIN_FREE_CALLBACK, RF_MAX_FREE_CALLBACK);
+ rf_pool_init(&rf_pools.callbackf, sizeof(RF_CallbackFuncDesc_t),
+ "rf_callbackfpl", RF_MIN_FREE_CALLBACK, RF_MAX_FREE_CALLBACK);
+ rf_pool_init(&rf_pools.callbackv, sizeof(RF_CallbackValueDesc_t),
+ "rf_callbackvpl", RF_MIN_FREE_CALLBACK, RF_MAX_FREE_CALLBACK);
rf_ShutdownCreate(listp, rf_ShutdownCallback, NULL);
return (0);
}
-RF_CallbackDesc_t *
-rf_AllocCallbackDesc(void)
+RF_CallbackFuncDesc_t *
+rf_AllocCallbackFuncDesc(void)
{
- return pool_get(&rf_pools.callback, PR_WAITOK);
+ return pool_get(&rf_pools.callbackf, PR_WAITOK);
}
void
-rf_FreeCallbackDesc(RF_CallbackDesc_t *p)
+rf_FreeCallbackFuncDesc(RF_CallbackFuncDesc_t *p)
+{
+ pool_put(&rf_pools.callbackf, p);
+}
+
+RF_CallbackValueDesc_t *
+rf_AllocCallbackValueDesc(void)
{
- pool_put(&rf_pools.callback, p);
+ return pool_get(&rf_pools.callbackv, PR_WAITOK);
}
+
+void
+rf_FreeCallbackValueDesc(RF_CallbackValueDesc_t *p)
+{
+ pool_put(&rf_pools.callbackv, p);
+}
diff -r 02c0ef9913d8 -r e8d86d6f706c sys/dev/raidframe/rf_callback.h
--- a/sys/dev/raidframe/rf_callback.h Thu Oct 10 02:39:07 2019 +0000
+++ b/sys/dev/raidframe/rf_callback.h Thu Oct 10 03:43:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_callback.h,v 1.6 2005/12/11 12:23:37 christos Exp $ */
+/* $NetBSD: rf_callback.h,v 1.7 2019/10/10 03:43:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -46,16 +46,23 @@
#include <dev/raidframe/raidframevar.h>
-struct RF_CallbackDesc_s {
- void (*callbackFunc) (RF_CBParam_t); /* function to call */
- RF_CBParam_t callbackArg; /* args to give to function, or just
- * info about this callback */
+struct RF_CallbackFuncDesc_s {
+ void (*callbackFunc) (void *); /* function to call */
+ void *callbackArg; /* args to give to function, or just
+ * info about this callback */
+ RF_CallbackFuncDesc_t *next;/* next entry in list */
+};
+
+struct RF_CallbackValueDesc_s {
+ RF_uint64 v;
RF_RowCol_t col; /* column IDs to give to the callback func */
- RF_CallbackDesc_t *next;/* next entry in list */
+ RF_CallbackValueDesc_t *next;/* next entry in list */
};
int rf_ConfigureCallback(RF_ShutdownList_t ** listp);
-RF_CallbackDesc_t *rf_AllocCallbackDesc(void);
-void rf_FreeCallbackDesc(RF_CallbackDesc_t * p);
+RF_CallbackFuncDesc_t *rf_AllocCallbackFuncDesc(void);
+void rf_FreeCallbackFuncDesc(RF_CallbackFuncDesc_t * p);
+RF_CallbackValueDesc_t *rf_AllocCallbackValueDesc(void);
+void rf_FreeCallbackValueDesc(RF_CallbackValueDesc_t * p);
#endif /* !_RF__RF_CALLBACK_H_ */
diff -r 02c0ef9913d8 -r e8d86d6f706c sys/dev/raidframe/rf_copyback.c
--- a/sys/dev/raidframe/rf_copyback.c Thu Oct 10 02:39:07 2019 +0000
+++ b/sys/dev/raidframe/rf_copyback.c Thu Oct 10 03:43:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_copyback.c,v 1.51 2019/02/09 03:33:59 christos Exp $ */
+/* $NetBSD: rf_copyback.c,v 1.52 2019/10/10 03:43:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -38,7 +38,7 @@
****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.51 2019/02/09 03:33:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.52 2019/10/10 03:43:59 christos Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -61,8 +61,8 @@
int rf_copyback_in_progress;
-static int rf_CopybackReadDoneProc(RF_CopybackDesc_t * desc, int status);
-static int rf_CopybackWriteDoneProc(RF_CopybackDesc_t * desc, int status);
+static void rf_CopybackReadDoneProc(void *, int);
+static void rf_CopybackWriteDoneProc(void *, int);
static void rf_CopybackOne(RF_CopybackDesc_t * desc, int typ,
RF_RaidAddr_t addr, RF_RowCol_t testCol,
RF_SectorNum_t testOffs);
@@ -334,13 +334,11 @@
/* create reqs to read the old location & write the new */
desc->readreq = rf_CreateDiskQueueData(RF_IO_TYPE_READ, spOffs,
- sectPerSU, desc->databuf, 0L, 0,
- (int (*) (void *, int)) rf_CopybackReadDoneProc, desc,
+ sectPerSU, desc->databuf, 0L, 0, rf_CopybackReadDoneProc, desc,
NULL, (void *) raidPtr, RF_DISKQUEUE_DATA_FLAGS_NONE, NULL,
PR_WAITOK);
desc->writereq = rf_CreateDiskQueueData(RF_IO_TYPE_WRITE, testOffs,
- sectPerSU, desc->databuf, 0L, 0,
- (int (*) (void *, int)) rf_CopybackWriteDoneProc, desc,
+ sectPerSU, desc->databuf, 0L, 0, rf_CopybackWriteDoneProc, desc,
NULL, (void *) raidPtr, RF_DISKQUEUE_DATA_FLAGS_NONE, NULL,
PR_WAITOK);
desc->fcol = testCol;
@@ -368,9 +366,10 @@
/* called at interrupt context when the read has completed. just send out the write */
-static int
-rf_CopybackReadDoneProc(RF_CopybackDesc_t *desc, int status)
+static void
+rf_CopybackReadDoneProc(void *v, int status)
{
+ RF_CopybackDesc_t *desc = v;
if (status) { /* invoke the callback with bad status */
printf("raid%d: copyback read failed. Aborting.\n",
desc->raidPtr->raidid);
@@ -378,23 +377,22 @@
} else {
rf_DiskIOEnqueue(&(desc->raidPtr->Queues[desc->fcol]), desc->writereq, RF_IO_NORMAL_PRIORITY);
}
- return (0);
}
/* called at interrupt context when the write has completed.
* at user level & in the kernel, wake up the copyback thread.
* in the simulator, invoke the next copyback directly.
* can't free diskqueuedata structs in the kernel b/c we're at interrupt context.
*/
-static int
-rf_CopybackWriteDoneProc(RF_CopybackDesc_t *desc, int status)
+static void
+rf_CopybackWriteDoneProc(void *v, int status)
{
+ RF_CopybackDesc_t *desc = v;
if (status && status != -100) {
printf("raid%d: copyback write failed. Aborting.\n",
desc->raidPtr->raidid);
}
desc->status = status;
rf_MCPairWakeupFunc(desc->mcpair);
- return (0);
}
/* invoked when the copyback has completed */
static void
diff -r 02c0ef9913d8 -r e8d86d6f706c sys/dev/raidframe/rf_dag.h
--- a/sys/dev/raidframe/rf_dag.h Thu Oct 10 02:39:07 2019 +0000
+++ b/sys/dev/raidframe/rf_dag.h Thu Oct 10 03:43:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dag.h,v 1.19 2005/12/11 12:23:37 christos Exp $ */
+/* $NetBSD: rf_dag.h,v 1.20 2019/10/10 03:43:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -89,11 +89,11 @@
struct RF_DagNode_s {
RF_NodeStatus_t status; /* current status of this node */
- int (*doFunc) (RF_DagNode_t *); /* normal function */
- int (*undoFunc) (RF_DagNode_t *); /* func to remove effect of
+ void (*doFunc) (RF_DagNode_t *); /* normal function */
+ void (*undoFunc) (RF_DagNode_t *); /* func to remove effect of
* doFunc */
- int (*wakeFunc) (RF_DagNode_t *, int status); /* func called when the
- * node completes an I/O */
+ void (*wakeFunc) (void *, int); /* func called when the
+ * node completes an I/O */
int numParams; /* number of parameters required by *funcPtr */
int numResults; /* number of results produced by *funcPtr */
int numAntecedents; /* number of antecedents */
diff -r 02c0ef9913d8 -r e8d86d6f706c sys/dev/raidframe/rf_dagdegrd.c
--- a/sys/dev/raidframe/rf_dagdegrd.c Thu Oct 10 02:39:07 2019 +0000
+++ b/sys/dev/raidframe/rf_dagdegrd.c Thu Oct 10 03:43:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dagdegrd.c,v 1.30 2019/02/09 03:34:00 christos Exp $ */
+/* $NetBSD: rf_dagdegrd.c,v 1.31 2019/10/10 03:43:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.30 2019/02/09 03:34:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagdegrd.c,v 1.31 2019/10/10 03:43:59 christos Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -1040,7 +1040,7 @@
RF_AllocListElem_t *allocList,
const char *redundantReadNodeName,
const char *recoveryNodeName,
- int (*recovFunc) (RF_DagNode_t *))
+ void (*recovFunc) (RF_DagNode_t *))
{
RF_RaidLayout_t *layoutPtr = &(raidPtr->Layout);
RF_DagNode_t *nodes, *rudNodes, *rrdNodes, *recoveryNode, *blockNode,
diff -r 02c0ef9913d8 -r e8d86d6f706c sys/dev/raidframe/rf_dagdegrd.h
--- a/sys/dev/raidframe/rf_dagdegrd.h Thu Oct 10 02:39:07 2019 +0000
+++ b/sys/dev/raidframe/rf_dagdegrd.h Thu Oct 10 03:43:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dagdegrd.h,v 1.8 2006/04/26 17:08:48 oster Exp $ */
+/* $NetBSD: rf_dagdegrd.h,v 1.9 2019/10/10 03:43:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -58,6 +58,6 @@
rf_DoubleDegRead(RF_Raid_t * raidPtr, RF_AccessStripeMap_t * asmap,
RF_DagHeader_t * dag_h, void *bp, RF_RaidAccessFlags_t flags,
RF_AllocListElem_t * allocList, const char *redundantReadNodeName,
- const char *recoveryNodeName, int (*recovFunc) (RF_DagNode_t *));
+ const char *recoveryNodeName, void (*recovFunc) (RF_DagNode_t *));
#endif /* !_RF__RF_DAGDEGRD_H_ */
diff -r 02c0ef9913d8 -r e8d86d6f706c sys/dev/raidframe/rf_dagdegwr.c
--- a/sys/dev/raidframe/rf_dagdegwr.c Thu Oct 10 02:39:07 2019 +0000
+++ b/sys/dev/raidframe/rf_dagdegwr.c Thu Oct 10 03:43:59 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_dagdegwr.c,v 1.34 2019/02/09 03:34:00 christos Exp $ */
+/* $NetBSD: rf_dagdegwr.c,v 1.35 2019/10/10 03:43:59 christos Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.34 2019/02/09 03:34:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagdegwr.c,v 1.35 2019/10/10 03:43:59 christos Exp $");
#include <dev/raidframe/raidframevar.h>
Home |
Main Index |
Thread Index |
Old Index