CVS commit: [netbsd-9] src/sys/dev/raidframe

2023-09-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 18 19:00:21 UTC 2023

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_netbsdkintf.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1733):

sys/dev/raidframe/rf_netbsdkintf.c: revision 1.413

A component that is in state rf_ds_reconstructing has failed, and should
not be consulted for DIOCGCACHE.

Fixes an observed panic when rf_get_component_caches() does an IOCTL to
a failed device while reconstruction is in progress.


To generate a diff of this commit:
cvs rdiff -u -r1.376.4.4 -r1.376.4.5 src/sys/dev/raidframe/rf_netbsdkintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.4 src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.5
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.4	Mon Aug 29 16:02:34 2022
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Mon Sep 18 19:00:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.376.4.4 2022/08/29 16:02:34 martin Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.376.4.5 2023/09/18 19:00:21 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.376.4.4 2022/08/29 16:02:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.376.4.5 2023/09/18 19:00:21 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_raid_autoconfig.h"
@@ -3702,8 +3702,7 @@ rf_get_component_caches(RF_Raid_t *raidP
 		 * Check any non-dead disk, even when currently being
 		 * reconstructed.
 		 */
-		if (!RF_DEAD_DISK(raidPtr->Disks[c].status)
-		|| raidPtr->Disks[c].status == rf_ds_reconstructing) {
+		if (!RF_DEAD_DISK(raidPtr->Disks[c].status)) {
 			error = VOP_IOCTL(raidPtr->raid_cinfo[c].ci_vp,
 			DIOCGCACHE, &dkpart, FREAD, NOCRED);
 			if (error) {



CVS commit: [netbsd-9] src/sys/dev/raidframe

2023-09-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 18 19:00:21 UTC 2023

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_netbsdkintf.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1733):

sys/dev/raidframe/rf_netbsdkintf.c: revision 1.413

A component that is in state rf_ds_reconstructing has failed, and should
not be consulted for DIOCGCACHE.

Fixes an observed panic when rf_get_component_caches() does an IOCTL to
a failed device while reconstruction is in progress.


To generate a diff of this commit:
cvs rdiff -u -r1.376.4.4 -r1.376.4.5 src/sys/dev/raidframe/rf_netbsdkintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/raidframe

2023-09-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep  9 14:56:10 UTC 2023

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_reconstruct.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1729):

sys/dev/raidframe/rf_reconstruct.c: revision 1.128

Revision 1.104 actually fixed the issues that were preventing
us from freeing the ReconControl structures.  So free them
and thus also prevent a panic on shutdown due to items not
being correctly returned to the pool.

Thanks to manu@ for report of the panic, and for initial testing
of the changes.


To generate a diff of this commit:
cvs rdiff -u -r1.122.4.1 -r1.122.4.2 src/sys/dev/raidframe/rf_reconstruct.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/raidframe/rf_reconstruct.c
diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.122.4.1 src/sys/dev/raidframe/rf_reconstruct.c:1.122.4.2
--- src/sys/dev/raidframe/rf_reconstruct.c:1.122.4.1	Wed Feb 17 09:34:20 2021
+++ src/sys/dev/raidframe/rf_reconstruct.c	Sat Sep  9 14:56:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconstruct.c,v 1.122.4.1 2021/02/17 09:34:20 martin Exp $	*/
+/*	$NetBSD: rf_reconstruct.c,v 1.122.4.2 2023/09/09 14:56:10 martin Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.122.4.1 2021/02/17 09:34:20 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.122.4.2 2023/09/09 14:56:10 martin Exp $");
 
 #include 
 #include 
@@ -892,24 +892,11 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 
 		rf_DrainReconEventQueue(reconDesc);
 
-		/* XXX  As much as we'd like to free the recon control structure
-		   and the reconDesc, we have no way of knowing if/when those will
-		   be touched by IO that has yet to occur.  It is rather poor to be
-		   basically causing a 'memory leak' here, but there doesn't seem to be
-		   a cleaner alternative at this time.  Perhaps when the reconstruct code
-		   gets a makeover this problem will go away.
-		*/
-#if 0
 		rf_FreeReconControl(raidPtr);
-#endif
-
 #if RF_ACC_TRACE > 0
 		RF_Free(raidPtr->recon_tracerecs, raidPtr->numCol * sizeof(RF_AccTraceEntry_t));
 #endif
-		/* XXX see comment above */
-#if 0
 		FreeReconDesc(reconDesc);
-#endif
 
 		return (1);
 	}



CVS commit: [netbsd-9] src/sys/dev/raidframe

2023-09-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep  9 14:56:10 UTC 2023

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_reconstruct.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1729):

sys/dev/raidframe/rf_reconstruct.c: revision 1.128

Revision 1.104 actually fixed the issues that were preventing
us from freeing the ReconControl structures.  So free them
and thus also prevent a panic on shutdown due to items not
being correctly returned to the pool.

Thanks to manu@ for report of the panic, and for initial testing
of the changes.


To generate a diff of this commit:
cvs rdiff -u -r1.122.4.1 -r1.122.4.2 src/sys/dev/raidframe/rf_reconstruct.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/raidframe

2022-08-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 29 16:02:34 UTC 2022

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_netbsdkintf.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1506):

sys/dev/raidframe/rf_netbsdkintf.c: revision 1.409

RAIDframe must be initialized for the RAIDFRAME_SET_LAST_UNIT
and RAIDFRAME_SHUTDOWN ioctls.


To generate a diff of this commit:
cvs rdiff -u -r1.376.4.3 -r1.376.4.4 src/sys/dev/raidframe/rf_netbsdkintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.3 src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.4
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.3	Fri Aug 12 15:18:13 2022
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Mon Aug 29 16:02:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.376.4.3 2022/08/12 15:18:13 martin Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.376.4.4 2022/08/29 16:02:34 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.376.4.3 2022/08/12 15:18:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.376.4.4 2022/08/29 16:02:34 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_raid_autoconfig.h"
@@ -1066,7 +1066,9 @@ rf_must_be_initialized(const struct raid
 	case RAIDFRAME_REWRITEPARITY:
 	case RAIDFRAME_SET_AUTOCONFIG:
 	case RAIDFRAME_SET_COMPONENT_LABEL:
+	case RAIDFRAME_SET_LAST_UNIT:
 	case RAIDFRAME_SET_ROOT:
+	case RAIDFRAME_SHUTDOWN:
 		return (rs->sc_flags & RAIDF_INITED) == 0;
 	}
 	return false;



CVS commit: [netbsd-9] src/sys/dev/raidframe

2022-08-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 29 16:02:34 UTC 2022

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_netbsdkintf.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1506):

sys/dev/raidframe/rf_netbsdkintf.c: revision 1.409

RAIDframe must be initialized for the RAIDFRAME_SET_LAST_UNIT
and RAIDFRAME_SHUTDOWN ioctls.


To generate a diff of this commit:
cvs rdiff -u -r1.376.4.3 -r1.376.4.4 src/sys/dev/raidframe/rf_netbsdkintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/raidframe

2022-08-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 12 15:18:13 UTC 2022

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_disks.c rf_driver.c
rf_netbsdkintf.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1500):

sys/dev/raidframe/rf_driver.c: revision 1.140 (patch)
sys/dev/raidframe/rf_disks.c: revision 1.93 (patch)
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.408 (patch)

raidframe: reject invalid values for numCol and numSpares

numCol and numSpares are "int" so they can be "-1" internally,
which means negative values need to be rejected, as well as
values higher than RF_MAXCOL/RF_MAXSPARES.
explicitly nul-terminate all strings coming from userland.

some minor CSE that avoids signed arith.

this fixes issues in the RAIDFRAME_ADD_HOT_SPARE,
RAIDFRAME_CONFIGURE, RAIDFRAME_DELETE_COMPONENT,
RAIDFRAME_INCORPORATE_HOT_SPARE, and RAIDFRAME_REBUILD_IN_PLACE
ioctl commands.

ok oster@ riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.91.4.1 src/sys/dev/raidframe/rf_disks.c
cvs rdiff -u -r1.135 -r1.135.4.1 src/sys/dev/raidframe/rf_driver.c
cvs rdiff -u -r1.376.4.2 -r1.376.4.3 src/sys/dev/raidframe/rf_netbsdkintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/raidframe

2022-08-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 12 15:18:13 UTC 2022

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_disks.c rf_driver.c
rf_netbsdkintf.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1500):

sys/dev/raidframe/rf_driver.c: revision 1.140 (patch)
sys/dev/raidframe/rf_disks.c: revision 1.93 (patch)
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.408 (patch)

raidframe: reject invalid values for numCol and numSpares

numCol and numSpares are "int" so they can be "-1" internally,
which means negative values need to be rejected, as well as
values higher than RF_MAXCOL/RF_MAXSPARES.
explicitly nul-terminate all strings coming from userland.

some minor CSE that avoids signed arith.

this fixes issues in the RAIDFRAME_ADD_HOT_SPARE,
RAIDFRAME_CONFIGURE, RAIDFRAME_DELETE_COMPONENT,
RAIDFRAME_INCORPORATE_HOT_SPARE, and RAIDFRAME_REBUILD_IN_PLACE
ioctl commands.

ok oster@ riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.91.4.1 src/sys/dev/raidframe/rf_disks.c
cvs rdiff -u -r1.135 -r1.135.4.1 src/sys/dev/raidframe/rf_driver.c
cvs rdiff -u -r1.376.4.2 -r1.376.4.3 src/sys/dev/raidframe/rf_netbsdkintf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/raidframe/rf_disks.c
diff -u src/sys/dev/raidframe/rf_disks.c:1.91 src/sys/dev/raidframe/rf_disks.c:1.91.4.1
--- src/sys/dev/raidframe/rf_disks.c:1.91	Sat Feb  9 03:34:00 2019
+++ src/sys/dev/raidframe/rf_disks.c	Fri Aug 12 15:18:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_disks.c,v 1.91 2019/02/09 03:34:00 christos Exp $	*/
+/*	$NetBSD: rf_disks.c,v 1.91.4.1 2022/08/12 15:18:13 martin Exp $	*/
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -60,7 +60,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.91 2019/02/09 03:34:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.91.4.1 2022/08/12 15:18:13 martin Exp $");
 
 #include 
 
@@ -318,11 +318,12 @@ static int
 rf_AllocDiskStructures(RF_Raid_t *raidPtr, RF_Config_t *cfgPtr)
 {
 	int ret;
+	size_t entries = raidPtr->numCol + RF_MAXSPARE;
 
 	/* We allocate RF_MAXSPARE on the first row so that we
 	   have room to do hot-swapping of spares */
-	raidPtr->Disks = RF_MallocAndAdd((raidPtr->numCol + RF_MAXSPARE) *
-	sizeof(*raidPtr->Disks), raidPtr->cleanupList);
+	raidPtr->Disks = RF_MallocAndAdd(
+	entries * sizeof(*raidPtr->Disks), raidPtr->cleanupList);
 	if (raidPtr->Disks == NULL) {
 		ret = ENOMEM;
 		goto fail;
@@ -330,9 +331,7 @@ rf_AllocDiskStructures(RF_Raid_t *raidPt
 
 	/* get space for device specific stuff.. */
 	raidPtr->raid_cinfo = RF_MallocAndAdd(
-	(raidPtr->numCol + RF_MAXSPARE) * sizeof(*raidPtr->raid_cinfo),
-	raidPtr->cleanupList);
-
+	entries * sizeof(*raidPtr->raid_cinfo), raidPtr->cleanupList);
 	if (raidPtr->raid_cinfo == NULL) {
 		ret = ENOMEM;
 		goto fail;
@@ -607,7 +606,8 @@ rf_ConfigureDisk(RF_Raid_t *raidPtr, cha
 	error = dk_lookup(pb, curlwp, &vp);
 	pathbuf_destroy(pb);
 	if (error) {
-		printf("dk_lookup on device: %s failed!\n", diskPtr->devname);
+		printf("dk_lookup on device: '%s' failed: %d\n",
+		diskPtr->devname, error);
 		if (error == ENXIO) {
 			/* the component isn't there... must be dead :-( */
 			diskPtr->status = rf_ds_failed;

Index: src/sys/dev/raidframe/rf_driver.c
diff -u src/sys/dev/raidframe/rf_driver.c:1.135 src/sys/dev/raidframe/rf_driver.c:1.135.4.1
--- src/sys/dev/raidframe/rf_driver.c:1.135	Sat Feb  9 03:34:00 2019
+++ src/sys/dev/raidframe/rf_driver.c	Fri Aug 12 15:18:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_driver.c,v 1.135 2019/02/09 03:34:00 christos Exp $	*/
+/*	$NetBSD: rf_driver.c,v 1.135.4.1 2022/08/12 15:18:13 martin Exp $	*/
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -66,7 +66,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.135 2019/02/09 03:34:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.135.4.1 2022/08/12 15:18:13 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_raid_diagnostic.h"
@@ -350,6 +350,11 @@ rf_Configure(RF_Raid_t *raidPtr, RF_Conf
 			  (void (*) (void *)) rf_FreeAllocList,
 			  raidPtr->cleanupList);
 
+	KASSERT(cfgPtr->numCol < RF_MAXCOL);
+	KASSERT(cfgPtr->numCol >= 0);
+	KASSERT(cfgPtr->numSpare < RF_MAXSPARE);
+	KASSERT(cfgPtr->numSpare >= 0);
+
 	raidPtr->numCol = cfgPtr->numCol;
 	raidPtr->numSpare = cfgPtr->numSpare;
 

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.2 src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.3
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.2	Wed Aug  3 10:55:45 2022
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Fri Aug 12 15:18:13 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.376.4.2 2022/08

CVS commit: [netbsd-9] src/sys/dev/raidframe

2021-12-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec 19 16:29:44 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_diskqueue.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1394):

sys/dev/raidframe/rf_diskqueue.c: revision 1.63 (patch)

call buf_destroy() after buf_init().  hopefully fixes the lockdebug
problem shown here:

   http://mail-index.netbsd.org/tech-kern/2021/12/10/msg027851.html

but seems unlikely to fix the original problem.

tested on i386/anita.  ok oster@

XXX: pullup-9 (netbsd-8 uses old APIs.)


To generate a diff of this commit:
cvs rdiff -u -r1.55.4.1 -r1.55.4.2 src/sys/dev/raidframe/rf_diskqueue.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/raidframe/rf_diskqueue.c
diff -u src/sys/dev/raidframe/rf_diskqueue.c:1.55.4.1 src/sys/dev/raidframe/rf_diskqueue.c:1.55.4.2
--- src/sys/dev/raidframe/rf_diskqueue.c:1.55.4.1	Tue Oct 19 10:55:15 2021
+++ src/sys/dev/raidframe/rf_diskqueue.c	Sun Dec 19 16:29:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_diskqueue.c,v 1.55.4.1 2021/10/19 10:55:15 martin Exp $	*/
+/*	$NetBSD: rf_diskqueue.c,v 1.55.4.2 2021/12/19 16:29:43 martin Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -66,7 +66,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55.4.1 2021/10/19 10:55:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55.4.2 2021/12/19 16:29:43 martin Exp $");
 
 #include 
 
@@ -413,6 +413,9 @@ rf_CreateDiskQueueData(RF_IoType_t typ, 
 void
 rf_FreeDiskQueueData(RF_DiskQueueData_t *p)
 {
+
+	buf_destroy(p->bp);
+
 	pool_put(&rf_pools.bufio, p->bp);
 	pool_put(&rf_pools.dqd, p);
 }



CVS commit: [netbsd-9] src/sys/dev/raidframe

2021-12-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec 19 16:29:44 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_diskqueue.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1394):

sys/dev/raidframe/rf_diskqueue.c: revision 1.63 (patch)

call buf_destroy() after buf_init().  hopefully fixes the lockdebug
problem shown here:

   http://mail-index.netbsd.org/tech-kern/2021/12/10/msg027851.html

but seems unlikely to fix the original problem.

tested on i386/anita.  ok oster@

XXX: pullup-9 (netbsd-8 uses old APIs.)


To generate a diff of this commit:
cvs rdiff -u -r1.55.4.1 -r1.55.4.2 src/sys/dev/raidframe/rf_diskqueue.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/sys/dev/raidframe

2021-10-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 19 10:55:15 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_diskqueue.c rf_netbsd.h

Log Message:
Pull up following revision(s) (requested by oster in ticket #1361):

sys/dev/raidframe/rf_netbsd.h: revision 1.36 (via patch)
sys/dev/raidframe/rf_diskqueue.c: revision 1.58
sys/dev/raidframe/rf_diskqueue.c: revision 1.59

remove unnnecessary splbio() in rf_FreeDiskQueueData()

getiobuf() can return NULL if there are no IO buffers available.
RAIDframe can't deal with that, so create a dedicated pool of buffers
to use for IO.  PR_WAITOK is fine here, as we pre-allocate more than
we need to guarantee IO can make progress.  Tuning of pool still to
come.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.4.1 src/sys/dev/raidframe/rf_diskqueue.c
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/dev/raidframe/rf_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/raidframe/rf_diskqueue.c
diff -u src/sys/dev/raidframe/rf_diskqueue.c:1.55 src/sys/dev/raidframe/rf_diskqueue.c:1.55.4.1
--- src/sys/dev/raidframe/rf_diskqueue.c:1.55	Sun Feb 10 17:13:33 2019
+++ src/sys/dev/raidframe/rf_diskqueue.c	Tue Oct 19 10:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_diskqueue.c,v 1.55 2019/02/10 17:13:33 christos Exp $	*/
+/*	$NetBSD: rf_diskqueue.c,v 1.55.4.1 2021/10/19 10:55:15 martin Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -66,7 +66,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55 2019/02/10 17:13:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.55.4.1 2021/10/19 10:55:15 martin Exp $");
 
 #include 
 
@@ -84,6 +84,8 @@ __KERNEL_RCSID(0, "$NetBSD: rf_diskqueue
 #include "rf_fifo.h"
 #include "rf_kintf.h"
 
+#include 
+
 static void rf_ShutdownDiskQueueSystem(void *);
 
 #ifndef RF_DEBUG_DISKQUEUE
@@ -147,10 +149,15 @@ static const RF_DiskQueueSW_t diskqueues
 };
 #define NUM_DISK_QUEUE_TYPES (sizeof(diskqueuesw)/sizeof(RF_DiskQueueSW_t))
 
+
 #define RF_MAX_FREE_DQD 256
 #define RF_MIN_FREE_DQD  64
 
-#include 
+/* XXX: scale these... */
+#define RF_MAX_FREE_BUFIO 256
+#define RF_MIN_FREE_BUFIO  64
+
+
 
 /* configures a single disk queue */
 
@@ -189,6 +196,7 @@ static void
 rf_ShutdownDiskQueueSystem(void *ignored)
 {
 	pool_destroy(&rf_pools.dqd);
+	pool_destroy(&rf_pools.bufio);
 }
 
 int
@@ -197,6 +205,8 @@ rf_ConfigureDiskQueueSystem(RF_ShutdownL
 
 	rf_pool_init(&rf_pools.dqd, sizeof(RF_DiskQueueData_t),
 		 "rf_dqd_pl", RF_MIN_FREE_DQD, RF_MAX_FREE_DQD);
+	rf_pool_init(&rf_pools.bufio, sizeof(buf_t),
+		 "rf_bufio_pl", RF_MIN_FREE_BUFIO, RF_MAX_FREE_BUFIO);
 	rf_ShutdownCreate(listp, rf_ShutdownDiskQueueSystem, NULL);
 
 	return (0);
@@ -367,19 +377,20 @@ rf_CreateDiskQueueData(RF_IoType_t typ, 
 {
 	RF_DiskQueueData_t *p;
 
-	p = pool_get(&rf_pools.dqd, waitflag | PR_ZERO);
-	if (p == NULL)
-		return (NULL);
+	p = pool_get(&rf_pools.dqd, PR_WAITOK | PR_ZERO);
+	KASSERT(p != NULL);
 
-	if (waitflag == PR_WAITOK) {
-		p->bp = getiobuf(NULL, true);
-	} else {
-		p->bp = getiobuf(NULL, false);
-	}
-	if (p->bp == NULL) {
-		pool_put(&rf_pools.dqd, p);
-		return (NULL);
-	}
+	/* Obtain a buffer from our own pool.  It is possible for the
+	   regular getiobuf() to run out of memory and return NULL.
+	   We need to guarantee that never happens, as RAIDframe
+	   doesn't have a good way to recover if memory allocation
+	   fails here.
+	*/
+	p->bp = pool_get(&rf_pools.bufio, PR_WAITOK | PR_ZERO);
+	KASSERT(p->bp != NULL);
+	
+	buf_init(p->bp);
+		
 	SET(p->bp->b_cflags, BC_BUSY);	/* mark buffer busy */
 
 	p->sectorOffset = ssect + rf_protectedSectors;
@@ -402,9 +413,6 @@ rf_CreateDiskQueueData(RF_IoType_t typ, 
 void
 rf_FreeDiskQueueData(RF_DiskQueueData_t *p)
 {
-	int s;
-	s = splbio();		/* XXX protect only pool_put, or neither? */
-	putiobuf(p->bp);
+	pool_put(&rf_pools.bufio, p->bp);
 	pool_put(&rf_pools.dqd, p);
-	splx(s);
 }

Index: src/sys/dev/raidframe/rf_netbsd.h
diff -u src/sys/dev/raidframe/rf_netbsd.h:1.33 src/sys/dev/raidframe/rf_netbsd.h:1.33.4.1
--- src/sys/dev/raidframe/rf_netbsd.h:1.33	Wed Feb  6 02:49:09 2019
+++ src/sys/dev/raidframe/rf_netbsd.h	Tue Oct 19 10:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsd.h,v 1.33 2019/02/06 02:49:09 oster Exp $	*/
+/*	$NetBSD: rf_netbsd.h,v 1.33.4.1 2021/10/19 10:55:15 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -61,6 +61,7 @@ struct RF_Pools_s {
 	struct pool asm_hdr; /* Access Stripe Map Header */
 	struct pool asmap;   /* Access Stripe Map */
 	struct pool asmhle;  /* Access Stripe Map Header List Elements */
+	struct pool bufio;   /* Buffer IO Pool */
 	struct pool callback;/* Callback descriptors */
 	struct poo

CVS commit: [netbsd-9] src/sys/dev/raidframe

2021-10-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 19 10:55:15 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-9]: rf_diskqueue.c rf_netbsd.h

Log Message:
Pull up following revision(s) (requested by oster in ticket #1361):

sys/dev/raidframe/rf_netbsd.h: revision 1.36 (via patch)
sys/dev/raidframe/rf_diskqueue.c: revision 1.58
sys/dev/raidframe/rf_diskqueue.c: revision 1.59

remove unnnecessary splbio() in rf_FreeDiskQueueData()

getiobuf() can return NULL if there are no IO buffers available.
RAIDframe can't deal with that, so create a dedicated pool of buffers
to use for IO.  PR_WAITOK is fine here, as we pre-allocate more than
we need to guarantee IO can make progress.  Tuning of pool still to
come.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.55.4.1 src/sys/dev/raidframe/rf_diskqueue.c
cvs rdiff -u -r1.33 -r1.33.4.1 src/sys/dev/raidframe/rf_netbsd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.