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

2014-11-20 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Thu Nov 20 09:38:56 UTC 2014

Modified Files:
src/sys/dev/raidframe [netbsd-5]: raidframevar.h rf_netbsdkintf.c
rf_reconstruct.c

Log Message:
Pull up the following revisions(s) (requested by oster in ticket #1933):
sys/dev/raidframe/raidframevar.h:   revision 1.17
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.316
sys/dev/raidframe/rf_reconstruct.c: revision 1.121 via patch

Fix a long-standing bug related to rebooting while a reconstruct-to-spare
is underway but not yet complete. Fixes PR kern/49244.


To generate a diff of this commit:
cvs rdiff -u -r1.12.10.3 -r1.12.10.4 src/sys/dev/raidframe/raidframevar.h
cvs rdiff -u -r1.250.4.13 -r1.250.4.14 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.105.4.6 -r1.105.4.7 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/raidframevar.h
diff -u src/sys/dev/raidframe/raidframevar.h:1.12.10.3 src/sys/dev/raidframe/raidframevar.h:1.12.10.4
--- src/sys/dev/raidframe/raidframevar.h:1.12.10.3	Wed Jun 13 14:00:49 2012
+++ src/sys/dev/raidframe/raidframevar.h	Thu Nov 20 09:38:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: raidframevar.h,v 1.12.10.3 2012/06/13 14:00:49 sborrill Exp $ */
+/*	$NetBSD: raidframevar.h,v 1.12.10.4 2014/11/20 09:38:56 sborrill Exp $ */
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -384,17 +384,17 @@ struct RF_SparetWait_s {
  * IF YOU ADD A STATE, CHECK TO SEE IF YOU NEED TO MODIFY RF_DEAD_DISK().
  */
 enum RF_DiskStatus_e {
-rf_ds_optimal,  /* no problems */
-rf_ds_failed,   /* reconstruction ongoing */
-rf_ds_reconstructing,   /* reconstruction complete to spare, dead disk
- * not yet replaced */
-rf_ds_dist_spared,  /* reconstruction complete to distributed
+	rf_ds_optimal,  /* no problems */
+	rf_ds_failed,   /* disk has failed */
+	rf_ds_reconstructing,   /* reconstruction ongoing */
+	rf_ds_dist_spared,  /* reconstruction complete to distributed
  * spare space, dead disk not yet replaced */
-rf_ds_spared,   /* reconstruction complete to distributed
- * spare space, dead disk not yet replaced */
-rf_ds_spare,/* an available spare disk */
-rf_ds_used_spare/* a spare which has been used, and hence is
+	rf_ds_spared,   /* reconstruction complete, dead disk not 
+   yet replaced */
+	rf_ds_spare,/* an available spare disk */
+	rf_ds_used_spare,   /* a spare which has been used, and hence is
  * not available */
+	rf_ds_rebuilding_spare	/* a spare which is being rebuilt to */
 };
 typedef enum RF_DiskStatus_e RF_DiskStatus_t;
 

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.13 src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.14
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.13	Wed Oct 24 03:03:53 2012
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Thu Nov 20 09:38:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.13 2012/10/24 03:03:53 riz Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.14 2014/11/20 09:38:56 sborrill Exp $	*/
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -139,7 +139,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.13 2012/10/24 03:03:53 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.14 2014/11/20 09:38:56 sborrill Exp $");
 
 #include 
 #include 
@@ -1466,6 +1466,10 @@ raidioctl(dev_t dev, u_long cmd, void *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));

Index: src/sys/dev/raidframe/rf_reconstruct.c
diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.6 src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.7
--- src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.6	Wed Jun 13 14:00:49 2012
+++ src/sys/dev/raidframe/rf_reconstruct.c	Thu Nov 20 09:38:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconstruct.c,v 1.105.4.6 2012/06/13 14:00:49 sborrill Exp $	*/
+/*	$NetBSD: rf_reconstruct.c,v 1.105.4.7 2014/11/20 09:38:56 sborrill Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  

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

2013-01-13 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Jan 13 16:14:43 UTC 2013

Modified Files:
src/sys/dev/raidframe [netbsd-5]: rf_driver.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1827):
sys/dev/raidframe/rf_driver.c: revision 1.131
Fix off by one read.


To generate a diff of this commit:
cvs rdiff -u -r1.118.10.2 -r1.118.10.3 src/sys/dev/raidframe/rf_driver.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_driver.c
diff -u src/sys/dev/raidframe/rf_driver.c:1.118.10.2 src/sys/dev/raidframe/rf_driver.c:1.118.10.3
--- src/sys/dev/raidframe/rf_driver.c:1.118.10.2	Thu Dec 10 22:59:16 2009
+++ src/sys/dev/raidframe/rf_driver.c	Sun Jan 13 16:14:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_driver.c,v 1.118.10.2 2009/12/10 22:59:16 snj Exp $	*/
+/*	$NetBSD: rf_driver.c,v 1.118.10.3 2013/01/13 16:14:42 bouyer 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.118.10.2 2009/12/10 22:59:16 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_driver.c,v 1.118.10.3 2013/01/13 16:14:42 bouyer Exp $");
 
 #include "opt_raid_diagnostic.h"
 
@@ -868,7 +868,7 @@ rf_ConfigureDebug(RF_Config_t *cfgPtr)
 	int i;
 
 	rf_ResetDebugOptions();
-	for (i = 0; cfgPtr->debugVars[i][0] && i < RF_MAXDBGV; i++) {
+	for (i = 0; i < RF_MAXDBGV && cfgPtr->debugVars[i][0]; i++) {
 		name_p = rf_find_non_white(&cfgPtr->debugVars[i][0]);
 		white_p = rf_find_white(name_p);	/* skip to start of 2nd
 			 * word */



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

2012-10-23 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Wed Oct 24 03:03:53 UTC 2012

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

Log Message:
sys/dev/raidframe/rf_netbsdkintf.c  patch

Implement DIOCGSTRATEGY and DIOCSSTRATEGY for raidframe devices.
(The default strategy is not changed)
[buhrow, ticket #1788]


To generate a diff of this commit:
cvs rdiff -u -r1.250.4.12 -r1.250.4.13 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.250.4.12 src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.13
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.12	Wed Jun 13 14:00:49 2012
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Wed Oct 24 03:03:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.12 2012/06/13 14:00:49 sborrill Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.13 2012/10/24 03:03:53 riz Exp $	*/
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -139,7 +139,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.12 2012/06/13 14:00:49 sborrill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.13 2012/10/24 03:03:53 riz Exp $");
 
 #include 
 #include 
@@ -973,7 +973,7 @@ raidioctl(dev_t dev, u_long cmd, void *d
 {
 	int unit = raidunit(dev);
 	int error = 0;
-	int part, pmask;
+	int part, pmask, s;
 	struct cfdata *cf;
 	struct raid_softc *rs;
 	RF_Config_t *k_cfg, *u_cfg;
@@ -1026,6 +1026,7 @@ raidioctl(dev_t dev, u_long cmd, void *d
 	case DIOCWLABEL:
 	case DIOCAWEDGE:
 	case DIOCDWEDGE:
+	case DIOCSSTRATEGY:
 		if ((flag & FWRITE) == 0)
 			return (EBADF);
 	}
@@ -1078,6 +1079,8 @@ raidioctl(dev_t dev, u_long cmd, void *d
 	case RAIDFRAME_PARITYMAP_GET_DISABLE:
 	case RAIDFRAME_PARITYMAP_SET_DISABLE:
 	case RAIDFRAME_PARITYMAP_SET_PARAMS:
+	case DIOCGSTRATEGY:
+	case DIOCSSTRATEGY:
 		if ((rs->sc_flags & RAIDF_INITED) == 0)
 			return (ENXIO);
 	}
@@ -1840,6 +1843,45 @@ raidioctl(dev_t dev, u_long cmd, void *d
 		(struct dkwedge_list *)data, l);
 	case DIOCCACHESYNC:
 		return rf_sync_component_caches(raidPtr);
+
+	case DIOCGSTRATEGY:
+	{
+		struct disk_strategy *dks = (void *)data;
+
+		s = splbio();
+		strlcpy(dks->dks_name, bufq_getstrategyname(rs->buf_queue),
+		sizeof(dks->dks_name));
+		splx(s);
+		dks->dks_paramlen = 0;
+
+		return 0;
+	}
+	
+	case DIOCSSTRATEGY:
+	{
+		struct disk_strategy *dks = (void *)data;
+		struct bufq_state *new;
+		struct bufq_state *old;
+
+		if (dks->dks_param != NULL) {
+			return EINVAL;
+		}
+		dks->dks_name[sizeof(dks->dks_name) - 1] = 0; /* ensure term */
+		error = bufq_alloc(&new, dks->dks_name,
+		BUFQ_EXACT|BUFQ_SORT_RAWBLOCK);
+		if (error) {
+			return error;
+		}
+		s = splbio();
+		old = rs->buf_queue;
+		bufq_move(new, old);
+		rs->buf_queue = new;
+		splx(s);
+		bufq_free(old);
+
+		return 0;
+	}
+
 	default:
 		retcode = ENOTTY;
 	}



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

2012-02-24 Thread Stephen Borrill
Module Name:src
Committed By:   sborrill
Date:   Fri Feb 24 17:58:45 UTC 2012

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

Log Message:
Pull up the following revisions(s) (requested by oster in ticket #1728):
sys/dev/raidframe/rf_reconmap.c:revision 1.34
sys/dev/raidframe/rf_reconstruct.c: revision 1.118

Remove a DIAGNOSTIC check that is invalid for RAID5_RS.
Add logic to the main reconstruction loop to handle RAID5 with rotated
spares. Correct issue where we were doing one more stripe than necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.8.1 src/sys/dev/raidframe/rf_reconmap.c
cvs rdiff -u -r1.105.4.4 -r1.105.4.5 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_reconmap.c
diff -u src/sys/dev/raidframe/rf_reconmap.c:1.31 src/sys/dev/raidframe/rf_reconmap.c:1.31.8.1
--- src/sys/dev/raidframe/rf_reconmap.c:1.31	Mon May 19 19:49:54 2008
+++ src/sys/dev/raidframe/rf_reconmap.c	Fri Feb 24 17:58:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconmap.c,v 1.31 2008/05/19 19:49:54 oster Exp $	*/
+/*	$NetBSD: rf_reconmap.c,v 1.31.8.1 2012/02/24 17:58:44 sborrill Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.31 2008/05/19 19:49:54 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconmap.c,v 1.31.8.1 2012/02/24 17:58:44 sborrill Exp $");
 
 #include "rf_raid.h"
 #include 
@@ -156,7 +156,14 @@ rf_ReconMapUpdate(RF_Raid_t *raidPtr, RF
 
 		/* do we need to move the queue? */
 		while (i > mapPtr->high_ru) {
+#if 0
 #ifdef DIAGNOSTIC
+			/* XXX: The check below is not valid for
+			 * RAID5_RS.  It is valid for RAID 1 and RAID 5.
+			 * The issue is that we can easily have
+			 * RU_NOTHING entries here too, and those are
+			 * quite correct.
+			 */
 			if (mapPtr->status[mapPtr->head]!=RU_ALL) {
 printf("\nraid%d: reconmap incorrect -- working on i %" PRIu64 "\n",
    raidPtr->raidid, i);
@@ -169,6 +176,7 @@ rf_ReconMapUpdate(RF_Raid_t *raidPtr, RF
 panic("reconmap incorrect");
 			} 
 #endif
+#endif
 			mapPtr->low_ru++;
 			mapPtr->high_ru++;
 			/* initialize "highest" RU status entry, which

Index: src/sys/dev/raidframe/rf_reconstruct.c
diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.4 src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.5
--- src/sys/dev/raidframe/rf_reconstruct.c:1.105.4.4	Sun Nov 21 22:06:53 2010
+++ src/sys/dev/raidframe/rf_reconstruct.c	Fri Feb 24 17:58:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconstruct.c,v 1.105.4.4 2010/11/21 22:06:53 riz Exp $	*/
+/*	$NetBSD: rf_reconstruct.c,v 1.105.4.5 2012/02/24 17:58:44 sborrill Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.105.4.4 2010/11/21 22:06:53 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.105.4.5 2012/02/24 17:58:44 sborrill Exp $");
 
 #include 
 #include 
@@ -557,6 +557,9 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 	RF_ReconCtrl_t *tmp_reconctrl;
 	RF_ReconEvent_t *event;
 	RF_StripeCount_t incPSID,lastPSID,num_writes,pending_writes,prev;
+#if RF_INCLUDE_RAID5_RS > 0
+	RF_StripeCount_t startPSID,endPSID,aPSID,bPSID,offPSID;
+#endif
 	RF_ReconUnitCount_t RUsPerPU;
 	struct timeval etime, elpsd;
 	unsigned long xor_s, xor_resid_us;
@@ -609,7 +612,17 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 	recon_error = 0;
 	write_error = 0;
 	pending_writes = incPSID;
-	raidPtr->reconControl->lastPSID = incPSID;
+	raidPtr->reconControl->lastPSID = incPSID - 1;
+
+	/* bounds check raidPtr->reconControl->lastPSID and
+	   pending_writes so that we don't attempt to wait for more IO
+	   than can possibly happen */
+
+	if (raidPtr->reconControl->lastPSID > lastPSID)
+		raidPtr->reconControl->lastPSID = lastPSID;
+
+	if (pending_writes > lastPSID)
+		pending_writes = lastPSID;
 
 	/* start the actual reconstruction */
 
@@ -623,6 +636,49 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 		}
 
 		num_writes = 0;
+
+#if RF_INCLUDE_RAID5_RS > 0
+		/* For RAID5 with Rotated Spares we will be 'short'
+		   some number of writes since no writes will get
+		   issued for stripes where the spare is on the
+		   component being rebuilt.  Account for the shortage
+		   here so that we don't hang indefinitely below
+		   waiting for writes to complete that were never
+		   scheduled.
+
+		   XXX: Should be fixed for PARITY_DECLUSTERING and
+		   others too! 
+
+		*/
+
+		if (raidPtr->Layout.numDataCol < 
+		raidPtr->numCol - raidPtr->Layout.numParityCol) {
+			/* numDataCol is at least 2 less than numCol,

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

2011-05-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri May 20 19:24:54 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by buhrow in ticket #1615):
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.280 via patch
PR/44340: Brian Buhrow: Raid sets containing wedges cannot be unconfigured
and reconfigured without a reboot.


To generate a diff of this commit:
cvs rdiff -u -r1.250.4.10 -r1.250.4.11 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.250.4.10 src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.11
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.10	Fri Jan  7 23:27:51 2011
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Fri May 20 19:24:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.10 2011/01/07 23:27:51 riz Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.11 2011/05/20 19:24:54 bouyer Exp $	*/
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -139,7 +139,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.10 2011/01/07 23:27:51 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.11 2011/05/20 19:24:54 bouyer Exp $");
 
 #include 
 #include 
@@ -851,6 +851,7 @@
 			free(cf, M_RAIDFRAME);
 			
 			/* Detach the disk. */
+			dkwedge_delall(&rs->sc_dkdev);
 			disk_detach(&rs->sc_dkdev);
 			disk_destroy(&rs->sc_dkdev);
 		}
@@ -1201,6 +1202,7 @@
 		free(cf, M_RAIDFRAME);
 
 		/* Detach the disk. */
+		dkwedge_delall(&rs->sc_dkdev);
 		disk_detach(&rs->sc_dkdev);
 		disk_destroy(&rs->sc_dkdev);
 



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

2011-03-07 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Mon Mar  7 17:38:23 UTC 2011

Modified Files:
src/sys/dev/raidframe [netbsd-5]: rf_paritymap.c

Log Message:
Pull up following revision(s) (requested by riz in ticket #1569):
sys/dev/raidframe/rf_paritymap.c: revision 1.6
Always return at least one parity region.  Fixes PR#44239.
Fix from oster@, code (such as it is) by me.


To generate a diff of this commit:
cvs rdiff -u -r1.3.2.3 -r1.3.2.4 src/sys/dev/raidframe/rf_paritymap.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_paritymap.c
diff -u src/sys/dev/raidframe/rf_paritymap.c:1.3.2.3 src/sys/dev/raidframe/rf_paritymap.c:1.3.2.4
--- src/sys/dev/raidframe/rf_paritymap.c:1.3.2.3	Sat Mar  6 21:05:29 2010
+++ src/sys/dev/raidframe/rf_paritymap.c	Mon Mar  7 17:38:22 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_paritymap.c,v 1.3.2.3 2010/03/06 21:05:29 sborrill Exp $ */
+/* $NetBSD: rf_paritymap.c,v 1.3.2.4 2011/03/07 17:38:22 snj Exp $ */
 
 /*-
  * Copyright (c) 2009 Jed Davis.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.3.2.3 2010/03/06 21:05:29 sborrill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.3.2.4 2011/03/07 17:38:22 snj Exp $");
 
 #include 
 #include 
@@ -409,6 +409,8 @@
 	nreg = bytes_per_disk / REGION_MINSIZE;
 	if (nreg > RF_PARITYMAP_NREG)
 		nreg = RF_PARITYMAP_NREG;
+	if (nreg < 1)
+		nreg = 1;
 
 	return (u_int)nreg;
 }



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

2011-01-07 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Jan  7 23:27:52 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1511):
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.278
add a hack to fix up old labels that do not have zero's in numBlocksHi:
if the total sectors reported (via disklabel or otherwise) is smaller
than 2^32, but numBlocksHi is set, zero it out instead.
tested by myself and christos, should fix reports of weirdness seen.


To generate a diff of this commit:
cvs rdiff -u -r1.250.4.9 -r1.250.4.10 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.250.4.9 src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.10
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.9	Fri Jan  7 23:25:59 2011
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Fri Jan  7 23:27:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.9 2011/01/07 23:25:59 riz Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.10 2011/01/07 23:27:51 riz Exp $	*/
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -139,7 +139,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.9 2011/01/07 23:25:59 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.10 2011/01/07 23:27:51 riz Exp $");
 
 #include 
 #include 
@@ -329,6 +329,7 @@
 void rf_cleanup_config_set(RF_ConfigSet_t *);
 int rf_have_enough_components(RF_ConfigSet_t *);
 int rf_auto_config_set(RF_ConfigSet_t *, int *);
+static void rf_fix_old_label_size(RF_ComponentLabel_t *, uint64_t);
 
 static int raidautoconfig = 0; /* Debugging, mostly.  Set to 0 to not
   allow autoconfig to take place.
@@ -2947,6 +2948,7 @@
 		/* Got the label.  Does it look reasonable? */
 		if (rf_reasonable_label(clabel) && 
 		(clabel->partitionSize <= size)) {
+			rf_fix_old_label_size(clabel, numsecs);
 #ifdef DEBUG
 			printf("Component on: %s: %llu\n",
 cname, (unsigned long long)size);
@@ -3153,6 +3155,24 @@
 }
 
 
+/*
+ * For reasons yet unknown, some old component labels have garbage in
+ * the newer numBlocksHi region, and this causes lossage.  Since those
+ * disks will also have numsecs set to less than 32 bits of sectors,
+ * we can determine when this corruption has occured, and fix it.
+ */
+static void
+rf_fix_old_label_size(RF_ComponentLabel_t *clabel, uint64_t numsecs)
+{
+
+	if (clabel->numBlocksHi && numsecs < ((uint64_t)1 << 32)) {
+		printf("WARNING: total sectors < 32 bits, yet numBlocksHi set\n"
+		   "WARNING: resetting numBlocksHi to zero.\n");
+		clabel->numBlocksHi = 0;
+	}
+}
+
+
 #ifdef DEBUG
 void
 rf_print_component_label(RF_ComponentLabel_t *clabel)



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

2011-01-07 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Jan  7 23:25:59 UTC 2011

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

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1522):
sys/dev/raidframe/rf_disks.c: revision 1.76
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.276
apply my patch to support non-512K sector disks (at least, upto 16KB
sector disks..)  from my tech-kern post:
the following patch let's me access both 512 byte and 4K
sector disks at the same time, as long as they are in
separate raids.  the existing rf code assumes/enforces
this part, i just made it support other sets concurrently.
the main change is moving the parity bitmap to the sector
after the component label sector(s), instead of being
immediately after the label, which meant it was on the same
sector as the label for >1024 byte devices.
i'm a little annoyed at having to add a 2nd call to
getdisksize() to enable auto-configure to work, but i
don't see another way that wasn't much uglier.


To generate a diff of this commit:
cvs rdiff -u -r1.70.10.3 -r1.70.10.4 src/sys/dev/raidframe/rf_disks.c
cvs rdiff -u -r1.250.4.8 -r1.250.4.9 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.70.10.3 src/sys/dev/raidframe/rf_disks.c:1.70.10.4
--- src/sys/dev/raidframe/rf_disks.c:1.70.10.3	Sun Nov 21 22:06:53 2010
+++ src/sys/dev/raidframe/rf_disks.c	Fri Jan  7 23:25:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_disks.c,v 1.70.10.3 2010/11/21 22:06:53 riz Exp $	*/
+/*	$NetBSD: rf_disks.c,v 1.70.10.4 2011/01/07 23:25:59 riz 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.70.10.3 2010/11/21 22:06:53 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.70.10.4 2011/01/07 23:25:59 riz Exp $");
 
 #include 
 
@@ -597,16 +597,26 @@
 		if (error == ENXIO) {
 			/* the component isn't there... must be dead :-( */
 			diskPtr->status = rf_ds_failed;
+			return 0;
 		} else {
 			return (error);
 		}
 	}
-	if (diskPtr->status == rf_ds_optimal) {
 
+	if ((error = rf_getdisksize(vp, curlwp, diskPtr)) != 0)
+		return (error);
+
+	/*
+	 * If this raidPtr's bytesPerSector is zero, fill it in with this
+	 * components blockSize.  This will give us something to work with
+	 * initially, and if it is wrong, we'll get errors later.
+	 */
+	if (raidPtr->bytesPerSector == 0)
+		raidPtr->bytesPerSector = diskPtr->blockSize;
+
+	if (diskPtr->status == rf_ds_optimal) {
 		if ((error = VOP_GETATTR(vp, &va, curlwp->l_cred)) != 0) 
 			return (error);
-		if ((error = rf_getdisksize(vp, curlwp, diskPtr)) != 0)
-			return (error);
 
 		raidPtr->raid_cinfo[col].ci_vp = vp;
 		raidPtr->raid_cinfo[col].ci_dev = va.va_rdev;

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.8 src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.9
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.250.4.8	Sun Nov 21 22:06:53 2010
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Fri Jan  7 23:25:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.8 2010/11/21 22:06:53 riz Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.250.4.9 2011/01/07 23:25:59 riz Exp $	*/
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -139,7 +139,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.8 2010/11/21 22:06:53 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.250.4.9 2011/01/07 23:25:59 riz Exp $");
 
 #include 
 #include 
@@ -219,10 +219,10 @@
 static int raidwrite_component_area(dev_t, struct vnode *, void *, size_t,
 daddr_t, daddr_t, int);
 
-static int raidwrite_component_label(dev_t, struct vnode *,
-RF_ComponentLabel_t *);
-static int raidread_component_label(dev_t, struct vnode *,
-RF_ComponentLabel_t *);
+static int raidwrite_component_label(unsigned,
+dev_t, struct vnode *, RF_ComponentLabel_t *);
+static int raidread_component_label(unsigned,
+dev_t, struct vnode *, RF_ComponentLabel_t *);
 
 
 dev_type_open(raidopen);
@@ -1001,8 +1001,8 @@
 	rs = &raid_softc[unit];
 	raidPtr = raidPtrs[unit];
 
-	db1_printf(("raidioctl: %d %d %d %d\n", (int) dev,
-		(int) DISKPART(dev), (int) unit, (int) cmd));
+	db1_printf(("raidioctl: %d %d %d %lu\n", (int) dev,
+		(int) DISKPART(dev), (int) unit, cmd));
 
 	/* Must be open for writes for these commands... */
 	switch (cmd) {
@@ -2400,10 +2400,57 @@
 
 #define RF_COMPONENT_INFO_OFFSET  16384 /* bytes */
 #define RF_COMPONENT_INFO_SIZE 1024 /* bytes */
-#define RF_PARITY_MAP_OFFSET \
-	(RF_COMPO

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

2010-11-21 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Sun Nov 21 22:06:54 UTC 2010

Modified Files:
src/sys/dev/raidframe [netbsd-5]: raidframevar.h rf_copyback.c
rf_disks.c rf_netbsdkintf.c rf_reconstruct.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1468):
sys/dev/raidframe/rf_disks.c: revision 1.74
sys/dev/raidframe/raidframevar.h: revision 1.14
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.275
sys/dev/raidframe/rf_copyback.c: revision 1.43
sys/dev/raidframe/rf_reconstruct.c: revision 1.109
add support for >2TB raid devices.
- - add two new members to the component label:
 u_int numBlocksHi
 u_int partitionSizeHi
  and store the top 32 bits of the real number of blocks and
  partition size.  modify rf_print_component_label(),
  rf_does_it_fit(), rf_AutoConfigureDisks() and
  rf_ReconstructFailedDiskBasic().
- - call disk_blocksize() after disk_attach() [ from mlelstv ]
- - shift the block number relative to DEV_BSHIFT in raidstart()
  and InitBP() so that accesses work for non 512-byte devices.
  [ from mlelstv ]
- - update rf_getdisksize() to use the new getdisksize() [ from
  mlelstv.  this part needs a separate change for netbsd-5. ]
reviewed by: oster, christos and darrenr


To generate a diff of this commit:
cvs rdiff -u -r1.12.10.1 -r1.12.10.2 src/sys/dev/raidframe/raidframevar.h
cvs rdiff -u -r1.41.20.1 -r1.41.20.2 src/sys/dev/raidframe/rf_copyback.c
cvs rdiff -u -r1.70.10.2 -r1.70.10.3 src/sys/dev/raidframe/rf_disks.c
cvs rdiff -u -r1.250.4.7 -r1.250.4.8 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.105.4.3 -r1.105.4.4 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/raidframevar.h
diff -u src/sys/dev/raidframe/raidframevar.h:1.12.10.1 src/sys/dev/raidframe/raidframevar.h:1.12.10.2
--- src/sys/dev/raidframe/raidframevar.h:1.12.10.1	Thu Dec 10 22:59:16 2009
+++ src/sys/dev/raidframe/raidframevar.h	Sun Nov 21 22:06:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: raidframevar.h,v 1.12.10.1 2009/12/10 22:59:16 snj Exp $ */
+/*	$NetBSD: raidframevar.h,v 1.12.10.2 2010/11/21 22:06:53 riz Exp $ */
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -471,7 +471,9 @@
  done first, (and would become raid0).
  This may be in conflict with last_unit!!?! */
 	  /* Not currently used. */
-	int future_use2[44];  /* More future expansion */
+	u_int numBlocksHi;/* The top 32-bits of the numBlocks member. */
+	u_int partitionSizeHi;/* The top 32-bits of the partitionSize member. */
+	int future_use2[42];  /* More future expansion */
 } RF_ComponentLabel_t;
 
 typedef struct RF_SingleComponent_s {

Index: src/sys/dev/raidframe/rf_copyback.c
diff -u src/sys/dev/raidframe/rf_copyback.c:1.41.20.1 src/sys/dev/raidframe/rf_copyback.c:1.41.20.2
--- src/sys/dev/raidframe/rf_copyback.c:1.41.20.1	Thu Dec 10 22:59:16 2009
+++ src/sys/dev/raidframe/rf_copyback.c	Sun Nov 21 22:06:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_copyback.c,v 1.41.20.1 2009/12/10 22:59:16 snj Exp $	*/
+/*	$NetBSD: rf_copyback.c,v 1.41.20.2 2010/11/21 22:06:53 riz Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -38,7 +38,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.41.20.1 2009/12/10 22:59:16 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.41.20.2 2010/11/21 22:06:53 riz Exp $");
 
 #include 
 
@@ -213,6 +213,7 @@
 	c_label->row = 0;
 	c_label->column = fcol;
 	c_label->partitionSize = raidPtr->Disks[fcol].partitionSize;
+	c_label->partitionSizeHi = raidPtr->Disks[fcol].partitionSize >> 32;
 
 	raidflush_component_label(raidPtr, fcol);
 

Index: src/sys/dev/raidframe/rf_disks.c
diff -u src/sys/dev/raidframe/rf_disks.c:1.70.10.2 src/sys/dev/raidframe/rf_disks.c:1.70.10.3
--- src/sys/dev/raidframe/rf_disks.c:1.70.10.2	Thu Dec 10 22:59:16 2009
+++ src/sys/dev/raidframe/rf_disks.c	Sun Nov 21 22:06:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_disks.c,v 1.70.10.2 2009/12/10 22:59:16 snj Exp $	*/
+/*	$NetBSD: rf_disks.c,v 1.70.10.3 2010/11/21 22:06:53 riz 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.70.10.2 2009/12/10 22:59:16 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.70.10.3 2010/11/21 22:06:53 riz Exp $");
 
 #include 
 
@@ -453,6 +453,8 @@
 			/* Found it.  Configure it.. */
 			diskPtr->blockSize = ac->clabel->blockSize;
 			diskPtr->numBlocks = ac->clabel->numBlocks;
+			diskPtr->numBlocks |=
+			(uint64_t)ac->clabel->numBlocksHi << 32;
 			/* Note: rf_protectedSectors is already
 			   f

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

2009-12-10 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Thu Dec 10 23:01:44 UTC 2009

Added Files:
src/sys/dev/raidframe [netbsd-5]: rf_paritymap.c rf_paritymap.h

Log Message:
Pull up following revision(s) (requested by tron in ticket #1187):
sys/dev/raidframe/rf_paritymap.c: revision 1.1-1.3 via patch
sys/dev/raidframe/rf_paritymap.h: revision 1.1 via patch
Pull up the RAIDframe parity map Summer Of Code project.
Drastically reduces the amount of time spent rewriting parity after an
unclean shutdown by keeping better track of which regions might have had
outstanding writes.  Enabled by default; can be disabled on a per-set
basis, or tuned, with the new raidctl(8) commands.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.3.2.2 src/sys/dev/raidframe/rf_paritymap.c
cvs rdiff -u -r0 -r1.1.2.2 src/sys/dev/raidframe/rf_paritymap.h

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

Added files:

Index: src/sys/dev/raidframe/rf_paritymap.c
diff -u /dev/null src/sys/dev/raidframe/rf_paritymap.c:1.3.2.2
--- /dev/null	Thu Dec 10 23:01:44 2009
+++ src/sys/dev/raidframe/rf_paritymap.c	Thu Dec 10 23:01:44 2009
@@ -0,0 +1,750 @@
+/* $NetBSD: rf_paritymap.c,v 1.3.2.2 2009/12/10 23:01:44 snj Exp $ */
+
+/*-
+ * Copyright (c) 2009 Jed Davis.
+ * 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.
+ *
+ * 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.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.3.2.2 2009/12/10 23:01:44 snj Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Important parameters: */
+#define REGION_MINSIZE (25ULL << 20)
+#define DFL_TICKMS  4
+#define DFL_COOLDOWN8 /* 7-8 intervals of 40s = 5min +/- 20s */
+
+/* Internal-use flag bits. */
+#define TICKING 1
+#define TICKED 2
+
+/* Prototypes! */
+static void rf_paritymap_write_locked(struct rf_paritymap *);
+static void rf_paritymap_tick(void *);
+static u_int rf_paritymap_nreg(RF_Raid_t *);
+
+/* Extract the current status of the parity map. */
+void
+rf_paritymap_status(struct rf_paritymap *pm, struct rf_pmstat *ps)
+{
+	memset(ps, 0, sizeof(*ps));
+	if (pm == NULL)
+		ps->enabled = 0;
+	else {
+		ps->enabled = 1;
+		ps->region_size = pm->region_size;
+		mutex_enter(&pm->lock);
+		memcpy(&ps->params, &pm->params, sizeof(ps->params));
+		memcpy(ps->dirty, pm->disk_now, sizeof(ps->dirty));
+		memcpy(&ps->ctrs, &pm->ctrs, sizeof(ps->ctrs));
+		mutex_exit(&pm->lock);
+	}
+}
+
+/* 
+ * Test whether parity in a given sector is suspected of being inconsistent
+ * on disk (assuming that any pending I/O to it is allowed to complete).
+ * This may be of interest to future work on parity scrubbing.
+ */
+int
+rf_paritymap_test(struct rf_paritymap *pm, daddr_t sector)
+{
+	unsigned region = sector / pm->region_size;
+	int retval;
+
+	mutex_enter(&pm->lock);
+	retval = isset(pm->disk_boot->bits, region) ? 1 : 0;
+	mutex_exit(&pm->lock);
+	return retval;
+}
+
+/* To be called before a write to the RAID is submitted. */
+void
+rf_paritymap_begin(struct rf_paritymap *pm, daddr_t offset, daddr_t size)
+{
+	unsigned i, b, e;
+
+	b = offset / pm->region_size;
+	e = (offset + size - 1) / pm->region_size;
+
+	for (i = b; i <= e; i++)
+		rf_paritymap_begin_region(pm, i);
+}
+
+/* To be called after a write to the RAID completes. */
+void
+rf_paritymap_end(struct rf_paritymap *pm, daddr_t offset, daddr_t size)
+{
+	unsigned i, b, e;
+
+	b = offset / pm->region_size;
+	e = (offset + size - 1) / pm->region_size;
+
+	for (i = b; i <= e; i++)
+		rf_paritymap_end_region(pm, i);
+}
+
+void
+rf_paritymap_begin_region(struct r

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

2009-04-30 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri May  1 02:18:29 UTC 2009

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

Log Message:
Pull up following revision(s) (requested by oster in ticket #607):
sys/dev/raidframe/rf_dagfuncs.c: revision 1.30
sys/dev/raidframe/rf_diskqueue.c: revision 1.52
sys/dev/raidframe/rf_diskqueue.h: revision 1.23
Rework/simplify the disk queuing code.  A bunch of this was still
holdovers from the simulator and would never be seen/used in-kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.52.1 src/sys/dev/raidframe/rf_dagfuncs.c
cvs rdiff -u -r1.51 -r1.51.6.1 src/sys/dev/raidframe/rf_diskqueue.c
cvs rdiff -u -r1.22 -r1.22.52.1 src/sys/dev/raidframe/rf_diskqueue.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_dagfuncs.c
diff -u src/sys/dev/raidframe/rf_dagfuncs.c:1.29 src/sys/dev/raidframe/rf_dagfuncs.c:1.29.52.1
--- src/sys/dev/raidframe/rf_dagfuncs.c:1.29	Sun Mar  4 06:02:36 2007
+++ src/sys/dev/raidframe/rf_dagfuncs.c	Fri May  1 02:18:29 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_dagfuncs.c,v 1.29 2007/03/04 06:02:36 christos Exp $	*/
+/*	$NetBSD: rf_dagfuncs.c,v 1.29.52.1 2009/05/01 02:18:29 snj Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_dagfuncs.c,v 1.29 2007/03/04 06:02:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_dagfuncs.c,v 1.29.52.1 2009/05/01 02:18:29 snj Exp $");
 
 #include 
 #include 
@@ -366,7 +366,7 @@
 	 NULL,
 #endif
 	(void *) (node->dagHdr->raidPtr),
-	RF_UNLOCK_DISK_QUEUE, NULL, PR_NOWAIT);
+	0, NULL, PR_NOWAIT);
 	if (!req)
 		(node->wakeFunc) (node, ENOMEM);
 	else {

Index: src/sys/dev/raidframe/rf_diskqueue.c
diff -u src/sys/dev/raidframe/rf_diskqueue.c:1.51 src/sys/dev/raidframe/rf_diskqueue.c:1.51.6.1
--- src/sys/dev/raidframe/rf_diskqueue.c:1.51	Tue Jun 17 14:53:11 2008
+++ src/sys/dev/raidframe/rf_diskqueue.c	Fri May  1 02:18:29 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_diskqueue.c,v 1.51 2008/06/17 14:53:11 reinoud Exp $	*/
+/*	$NetBSD: rf_diskqueue.c,v 1.51.6.1 2009/05/01 02:18:29 snj Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -66,7 +66,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.51 2008/06/17 14:53:11 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_diskqueue.c,v 1.51.6.1 2009/05/01 02:18:29 snj Exp $");
 
 #include 
 
@@ -169,7 +169,6 @@
 	diskqueue->queueLength = 0;
 	diskqueue->maxOutstanding = maxOutstanding;
 	diskqueue->curPriority = RF_IO_NORMAL_PRIORITY;
-	diskqueue->nextLockingOp = NULL;
 	diskqueue->flags = 0;
 	diskqueue->raidPtr = raidPtr;
 	diskqueue->rf_cinfo = &raidPtr->raid_cinfo[c];
@@ -252,10 +251,6 @@
 }
 /* Enqueue a disk I/O
  *
- * Unfortunately, we have to do things differently in the different
- * environments (simulator, user-level, kernel).
- * At user level, all I/O is blocking, so we have 1 or more threads/disk
- * and the thread that enqueues is different from the thread that dequeues.
  * In the kernel, I/O is non-blocking and so we'd like to have multiple
  * I/Os outstanding on the physical disks when possible.
  *
@@ -264,20 +259,10 @@
  *queue it up
  *
  * kernel rules for when to do what:
- *locking request:  queue empty => dispatch and lock queue,
- *  else queue it
  *unlocking req  :  always dispatch it
  *normal req :  queue empty => dispatch it & set priority
  *  queue not full & priority is ok => dispatch it
  *  else queue it
- *
- * user-level rules:
- *always enqueue.  In the special case of an unlocking op, enqueue
- *in a special way that will cause the unlocking op to be the next
- *thing dequeued.
- *
- * simulator rules:
- *Do the same as at user level, with the sleeps and wakeups suppressed.
  */
 void
 rf_DiskIOEnqueue(RF_DiskQueue_t *queue, RF_DiskQueueData_t *req, int pri)
@@ -291,65 +276,27 @@
 		printf("Warning: Enqueueing zero-sector access\n");
 	}
 #endif
-	/*
- * kernel
- */
 	RF_LOCK_QUEUE_MUTEX(queue, "DiskIOEnqueue");
-	/* locking request */
-	if (RF_LOCKING_REQ(req)) {
-		if (RF_QUEUE_EMPTY(queue)) {
-			Dprintf2("Dispatching pri %d locking op to c %d (queue empty)\n", pri, queue->col);
-			RF_LOCK_QUEUE(queue);
-			rf_DispatchKernelIO(queue, req);
-		} else {
-			queue->queueLength++;	/* increment count of number
-		 * of requests waiting in this
-		 * queue */
-			Dprintf2("Enqueueing pri %d locking op to c %d (queue not empty)\n", pri, queue->col);
-			req->queue = (void *) queue;
-			(queue->qPtr->Enqueue) (queue->qHdr, req, pri);
-		}
+	if (RF_OK_TO_DIS

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

2009-04-04 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Apr  4 17:15:14 UTC 2009

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

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #652):
sys/dev/raidframe/rf_disks.c: revision 1.71
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.260
Switch various printfs from %ld and %d to PRIu64, etc. to be more consistent
about types (for instance uint32_t was being printed with %d).


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.70.10.1 src/sys/dev/raidframe/rf_disks.c
cvs rdiff -u -r1.250.4.3 -r1.250.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_disks.c
diff -u src/sys/dev/raidframe/rf_disks.c:1.70 src/sys/dev/raidframe/rf_disks.c:1.70.10.1
--- src/sys/dev/raidframe/rf_disks.c:1.70	Mon Apr 28 20:23:56 2008
+++ src/sys/dev/raidframe/rf_disks.c	Sat Apr  4 17:15:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_disks.c,v 1.70 2008/04/28 20:23:56 martin Exp $	*/
+/*	$NetBSD: rf_disks.c,v 1.70.10.1 2009/04/04 17:15:14 snj 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.70 2008/04/28 20:23:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.70.10.1 2009/04/04 17:15:14 snj Exp $");
 
 #include 
 
@@ -143,9 +143,9 @@
 		} else {
 			if (disks[c].numBlocks < min_numblks)
 min_numblks = disks[c].numBlocks;
-			DPRINTF6("Disk at col %d: dev %s numBlocks %ld blockSize %d (%ld MB)\n",
+			DPRINTF6("Disk at col %d: dev %s numBlocks %" PRIu64 " blockSize %d (%ld MB)\n",
  c, disks[c].devname,
- (long int) disks[c].numBlocks,
+ disks[c].numBlocks,
  disks[c].blockSize,
  (long int) disks[c].numBlocks *
  disks[c].blockSize / 1024 / 1024);
@@ -253,9 +253,9 @@
 		} else {
 			disks[i].status = rf_ds_spare;	/* change status to
 			 * spare */
-			DPRINTF6("Spare Disk %d: dev %s numBlocks %ld blockSize %d (%ld MB)\n", i,
+			DPRINTF6("Spare Disk %d: dev %s numBlocks %" PRIu64 " blockSize %d (%ld MB)\n", i,
 			disks[i].devname,
-			(long int) disks[i].numBlocks, disks[i].blockSize,
+			disks[i].numBlocks, disks[i].blockSize,
 			(long int) disks[i].numBlocks *
  disks[i].blockSize / 1024 / 1024);
 		}
@@ -271,17 +271,17 @@
 			goto fail;
 		}
 		if (disks[i].numBlocks < raidPtr->sectorsPerDisk) {
-			RF_ERRORMSG3("Spare disk %s (%d blocks) is too small to serve as a spare (need %ld blocks)\n",
+			RF_ERRORMSG3("Spare disk %s (%d blocks) is too small to serve as a spare (need %" PRIu64 " blocks)\n",
  disks[i].devname, disks[i].blockSize,
- (long int) raidPtr->sectorsPerDisk);
+ raidPtr->sectorsPerDisk);
 			ret = EINVAL;
 			goto fail;
 		} else
 			if (disks[i].numBlocks > raidPtr->sectorsPerDisk) {
-RF_ERRORMSG3("Warning: truncating spare disk %s to %ld blocks (from %ld)\n",
+RF_ERRORMSG3("Warning: truncating spare disk %s to %" PRIu64 " blocks (from %" PRIu64 ")\n",
 disks[i].devname,
-(long int) raidPtr->sectorsPerDisk,
-(long int) disks[i].numBlocks);
+raidPtr->sectorsPerDisk,
+disks[i].numBlocks);
 
 disks[i].numBlocks = raidPtr->sectorsPerDisk;
 			}
@@ -980,9 +980,10 @@
 		goto fail;
 	} else {
 		disks[spare_number].status = rf_ds_spare;
-		DPRINTF6("Spare Disk %d: dev %s numBlocks %ld blockSize %d (%ld MB)\n", spare_number,
+		DPRINTF6("Spare Disk %d: dev %s numBlocks %" PRIu64 " blockSize %d (%ld MB)\n",
+			 spare_number,
 			 disks[spare_number].devname,
-			 (long int) disks[spare_number].numBlocks,
+			 disks[spare_number].numBlocks,
 			 disks[spare_number].blockSize,
 			 (long int) disks[spare_number].numBlocks *
 			 disks[spare_number].blockSize / 1024 / 1024);
@@ -998,20 +999,20 @@
 		goto fail;
 	}
 	if (disks[spare_number].numBlocks < raidPtr->sectorsPerDisk) {
-		RF_ERRORMSG3("Spare disk %s (%d blocks) is too small to serve as a spare (need %ld blocks)\n",
+		RF_ERRORMSG3("Spare disk %s (%d blocks) is too small to serve as a spare (need %" PRIu64 " blocks)\n",
 			 disks[spare_number].devname,
 			 disks[spare_number].blockSize,
-			 (long int) raidPtr->sectorsPerDisk);
+			 raidPtr->sectorsPerDisk);
 		rf_close_component(raidPtr, raidPtr->raid_cinfo[raidPtr->numCol+spare_number].ci_vp, 0);
 		ret = EINVAL;
 		goto fail;
 	} else {
 		if (disks[spare_number].numBlocks >
 		raidPtr->sectorsPerDisk) {
-			RF_ERRORMSG3("Warning: truncating spare disk %s to %ld blocks (from %ld)\n",
+			RF_ERRORMSG3("Warning: truncating spare disk %s to %" PRIu64 " blocks (from %" PRIu64 ")\n",
 			disks[spare_number].devname,
-			(long int) raidPtr->sectorsPerDisk,
-			(long int) disks[spare_nu