Module Name:    src
Committed By:   mrg
Date:           Mon Nov  1 02:35:25 UTC 2010

Modified Files:
        src/sys/dev/raidframe: raidframevar.h rf_copyback.c rf_disks.c
            rf_netbsdkintf.c rf_reconstruct.c

Log Message:
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.13 -r1.14 src/sys/dev/raidframe/raidframevar.h
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/raidframe/rf_copyback.c
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/raidframe/rf_disks.c
cvs rdiff -u -r1.274 -r1.275 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.108 -r1.109 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.13 src/sys/dev/raidframe/raidframevar.h:1.14
--- src/sys/dev/raidframe/raidframevar.h:1.13	Tue Nov 17 18:54:26 2009
+++ src/sys/dev/raidframe/raidframevar.h	Mon Nov  1 02:35:24 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: raidframevar.h,v 1.13 2009/11/17 18:54:26 jld Exp $ */
+/*	$NetBSD: raidframevar.h,v 1.14 2010/11/01 02:35:24 mrg 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.42 src/sys/dev/raidframe/rf_copyback.c:1.43
--- src/sys/dev/raidframe/rf_copyback.c:1.42	Tue Nov 17 18:54:26 2009
+++ src/sys/dev/raidframe/rf_copyback.c	Mon Nov  1 02:35:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_copyback.c,v 1.42 2009/11/17 18:54:26 jld Exp $	*/
+/*	$NetBSD: rf_copyback.c,v 1.43 2010/11/01 02:35:25 mrg 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.42 2009/11/17 18:54:26 jld Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.43 2010/11/01 02:35:25 mrg Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -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.73 src/sys/dev/raidframe/rf_disks.c:1.74
--- src/sys/dev/raidframe/rf_disks.c:1.73	Mon Mar  1 21:10:26 2010
+++ src/sys/dev/raidframe/rf_disks.c	Mon Nov  1 02:35:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_disks.c,v 1.73 2010/03/01 21:10:26 jld Exp $	*/
+/*	$NetBSD: rf_disks.c,v 1.74 2010/11/01 02:35:25 mrg Exp $	*/
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -60,7 +60,7 @@
  ***************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.73 2010/03/01 21:10:26 jld Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.74 2010/11/01 02:35:25 mrg Exp $");
 
 #include <dev/raidframe/raidframevar.h>
 
@@ -455,6 +455,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
 			   factored into numBlocks here */
 			raidPtr->raid_cinfo[c].ci_vp = ac->vp;

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.274 src/sys/dev/raidframe/rf_netbsdkintf.c:1.275
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.274	Sun Aug  8 18:25:14 2010
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Mon Nov  1 02:35:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.274 2010/08/08 18:25:14 chs Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.275 2010/11/01 02:35:25 mrg Exp $	*/
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -139,7 +139,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.274 2010/08/08 18:25:14 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.275 2010/11/01 02:35:25 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1936,6 +1936,7 @@
 
 	disk_init(&rs->sc_dkdev, rs->sc_xname, &rf_dkdriver);
 	disk_attach(&rs->sc_dkdev);
+	disk_blocksize(&rs->sc_dkdev, raidPtr->bytesPerSector);
 
 	/* XXX There may be a weird interaction here between this, and
 	 * protectedSectors, as used in RAIDframe.  */
@@ -2031,7 +2032,7 @@
 		 * partition.. Need to make it absolute to the underlying
 		 * device.. */
 
-		blocknum = bp->b_blkno;
+		blocknum = bp->b_blkno << DEV_BSHIFT >> raidPtr->logBytesPerSector;
 		if (DISKPART(bp->b_dev) != RAW_PART) {
 			pp = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)];
 			blocknum += pp->p_offset;
@@ -2283,7 +2284,7 @@
 	bp->b_error = 0;
 	bp->b_dev = dev;
 	bp->b_data = bf;
-	bp->b_blkno = startSect;
+	bp->b_blkno = startSect << logBytesPerSector >> DEV_BSHIFT;
 	bp->b_resid = bp->b_bcount;	/* XXX is this right!??!?!! */
 	if (bp->b_bcount == 0) {
 		panic("bp->b_bcount is zero in InitBP!!");
@@ -3136,6 +3137,10 @@
 void
 rf_print_component_label(RF_ComponentLabel_t *clabel)
 {
+	uint64_t numBlocks = clabel->numBlocks;
+
+	numBlocks |= (uint64_t)clabel->numBlocksHi << 32;
+
 	printf("   Row: %d Column: %d Num Rows: %d Num Columns: %d\n",
 	       clabel->row, clabel->column,
 	       clabel->num_rows, clabel->num_columns);
@@ -3146,9 +3151,8 @@
 	       clabel->clean ? "Yes" : "No", clabel->status);
 	printf("   sectPerSU: %d SUsPerPU: %d SUsPerRU: %d\n",
 	       clabel->sectPerSU, clabel->SUsPerPU, clabel->SUsPerRU);
-	printf("   RAID Level: %c  blocksize: %d numBlocks: %d\n",
-	       (char) clabel->parityConfig, clabel->blockSize,
-	       clabel->numBlocks);
+	printf("   RAID Level: %c  blocksize: %d numBlocks: %"PRIu64"\n",
+	       (char) clabel->parityConfig, clabel->blockSize, numBlocks);
 	printf("   Autoconfig: %s\n", clabel->autoconfigure ? "Yes" : "No");
 	printf("   Contains root partition: %s\n",
 	       clabel->root_partition ? "Yes" : "No");
@@ -3269,6 +3273,7 @@
 	    (clabel1->maxOutstanding == clabel2->maxOutstanding) &&
 	    (clabel1->blockSize == clabel2->blockSize) &&
 	    (clabel1->numBlocks == clabel2->numBlocks) &&
+	    (clabel1->numBlocksHi == clabel2->numBlocksHi) &&
 	    (clabel1->autoconfigure == clabel2->autoconfigure) &&
 	    (clabel1->root_partition == clabel2->root_partition) &&
 	    (clabel1->last_unit == clabel2->last_unit) &&
@@ -3533,6 +3538,7 @@
 
 	clabel->blockSize = raidPtr->bytesPerSector;
 	clabel->numBlocks = raidPtr->sectorsPerDisk;
+	clabel->numBlocksHi = raidPtr->sectorsPerDisk >> 32;
 
 	/* XXX not portable */
 	clabel->parityConfig = raidPtr->Layout.map->parityConfig;
@@ -3691,23 +3697,15 @@
 int
 rf_getdisksize(struct vnode *vp, struct lwp *l, RF_RaidDisk_t *diskPtr)
 {
-	struct partinfo dpart;
-	struct dkwedge_info dkw;
+	uint64_t numsecs;
+	unsigned secsize;
 	int error;
 
-	error = VOP_IOCTL(vp, DIOCGPART, &dpart, FREAD, l->l_cred);
-	if (error == 0) {
-		diskPtr->blockSize = dpart.disklab->d_secsize;
-		diskPtr->numBlocks = dpart.part->p_size - rf_protectedSectors;
-		diskPtr->partitionSize = dpart.part->p_size;
-		return 0;
-	}
-
-	error = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, l->l_cred);
+	error = getdisksize(vp, &numsecs, &secsize);
 	if (error == 0) {
-		diskPtr->blockSize = 512;	/* XXX */
-		diskPtr->numBlocks = dkw.dkw_size - rf_protectedSectors;
-		diskPtr->partitionSize = dkw.dkw_size;
+		diskPtr->blockSize = secsize;
+		diskPtr->numBlocks = numsecs - rf_protectedSectors;
+		diskPtr->partitionSize = numsecs;
 		return 0;
 	}
 	return error;

Index: src/sys/dev/raidframe/rf_reconstruct.c
diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.108 src/sys/dev/raidframe/rf_reconstruct.c:1.109
--- src/sys/dev/raidframe/rf_reconstruct.c:1.108	Tue Nov 17 18:54:26 2009
+++ src/sys/dev/raidframe/rf_reconstruct.c	Mon Nov  1 02:35:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconstruct.c,v 1.108 2009/11/17 18:54:26 jld Exp $	*/
+/*	$NetBSD: rf_reconstruct.c,v 1.109 2010/11/01 02:35:25 mrg Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  ************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.108 2009/11/17 18:54:26 jld Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.109 2010/11/01 02:35:25 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -297,6 +297,8 @@
 		c_label->clean = RF_RAID_DIRTY;
 		c_label->status = rf_ds_optimal;
 		c_label->partitionSize = raidPtr->Disks[scol].partitionSize;
+		c_label->partitionSizeHi =
+		   raidPtr->Disks[scol].partitionSize >> 32;
 
 		/* We've just done a rebuild based on all the other
 		   disks, so at this point the parity is known to be

Reply via email to