Mon Nov 1 02:35:25 2010 UTC ()
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


(mrg)
diff -r1.13 -r1.14 src/sys/dev/raidframe/raidframevar.h
diff -r1.42 -r1.43 src/sys/dev/raidframe/rf_copyback.c
diff -r1.73 -r1.74 src/sys/dev/raidframe/rf_disks.c
diff -r1.274 -r1.275 src/sys/dev/raidframe/rf_netbsdkintf.c
diff -r1.108 -r1.109 src/sys/dev/raidframe/rf_reconstruct.c

cvs diff -r1.13 -r1.14 src/sys/dev/raidframe/raidframevar.h (expand / switch to unified diff)

--- src/sys/dev/raidframe/raidframevar.h 2009/11/17 18:54:26 1.13
+++ src/sys/dev/raidframe/raidframevar.h 2010/11/01 02:35:24 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: raidframevar.h,v 1.13 2009/11/17 18:54:26 jld Exp $ */ 1/* $NetBSD: raidframevar.h,v 1.14 2010/11/01 02:35:24 mrg Exp $ */
2/*- 2/*-
3 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 3 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Greg Oster 7 * by Greg Oster
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -461,27 +461,29 @@ typedef struct RF_ComponentLabel_s { @@ -461,27 +461,29 @@ typedef struct RF_ComponentLabel_s {
461 461
462 int autoconfigure; /* automatically configure this RAID set. 462 int autoconfigure; /* automatically configure this RAID set.
463 0 == no, 1 == yes */ 463 0 == no, 1 == yes */
464 int root_partition; /* Use this set as / 464 int root_partition; /* Use this set as /
465 0 == no, 1 == yes*/ 465 0 == no, 1 == yes*/
466 int last_unit; /* last unit number (e.g. 0 for /dev/raid0) 466 int last_unit; /* last unit number (e.g. 0 for /dev/raid0)
467 of this component. Used for autoconfigure 467 of this component. Used for autoconfigure
468 only. */ 468 only. */
469 int config_order; /* 0 .. n. The order in which the component 469 int config_order; /* 0 .. n. The order in which the component
470 should be auto-configured. E.g. 0 is will 470 should be auto-configured. E.g. 0 is will
471 done first, (and would become raid0). 471 done first, (and would become raid0).
472 This may be in conflict with last_unit!!?! */ 472 This may be in conflict with last_unit!!?! */
473 /* Not currently used. */ 473 /* Not currently used. */
474 int future_use2[44]; /* More future expansion */ 474 u_int numBlocksHi; /* The top 32-bits of the numBlocks member. */
 475 u_int partitionSizeHi;/* The top 32-bits of the partitionSize member. */
 476 int future_use2[42]; /* More future expansion */
475} RF_ComponentLabel_t; 477} RF_ComponentLabel_t;
476 478
477typedef struct RF_SingleComponent_s { 479typedef struct RF_SingleComponent_s {
478 int row; 480 int row;
479 int column; 481 int column;
480 char component_name[50]; /* name of the component */ 482 char component_name[50]; /* name of the component */
481} RF_SingleComponent_t; 483} RF_SingleComponent_t;
482 484
483typedef struct RF_DeviceConfig_s { 485typedef struct RF_DeviceConfig_s {
484 u_int rows; 486 u_int rows;
485 u_int cols; 487 u_int cols;
486 u_int maxqdepth; 488 u_int maxqdepth;
487 int ndevs; 489 int ndevs;

cvs diff -r1.42 -r1.43 src/sys/dev/raidframe/rf_copyback.c (expand / switch to unified diff)

--- src/sys/dev/raidframe/rf_copyback.c 2009/11/17 18:54:26 1.42
+++ src/sys/dev/raidframe/rf_copyback.c 2010/11/01 02:35:25 1.43
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rf_copyback.c,v 1.42 2009/11/17 18:54:26 jld Exp $ */ 1/* $NetBSD: rf_copyback.c,v 1.43 2010/11/01 02:35:25 mrg Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Carnegie-Mellon University. 3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Author: Mark Holland 6 * Author: Mark Holland
7 * 7 *
8 * Permission to use, copy, modify and distribute this software and 8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright 9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the 10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions 11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation. 12 * thereof, and that both notices appear in supporting documentation.
13 * 13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 28
29/***************************************************************************** 29/*****************************************************************************
30 * 30 *
31 * copyback.c -- code to copy reconstructed data back from spare space to 31 * copyback.c -- code to copy reconstructed data back from spare space to
32 * the replaced disk. 32 * the replaced disk.
33 * 33 *
34 * the code operates using callbacks on the I/Os to continue with the 34 * the code operates using callbacks on the I/Os to continue with the
35 * next unit to be copied back. We do this because a simple loop 35 * next unit to be copied back. We do this because a simple loop
36 * containing blocking I/Os will not work in the simulator. 36 * containing blocking I/Os will not work in the simulator.
37 * 37 *
38 ****************************************************************************/ 38 ****************************************************************************/
39 39
40#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.42 2009/11/17 18:54:26 jld Exp $"); 41__KERNEL_RCSID(0, "$NetBSD: rf_copyback.c,v 1.43 2010/11/01 02:35:25 mrg Exp $");
42 42
43#include <dev/raidframe/raidframevar.h> 43#include <dev/raidframe/raidframevar.h>
44 44
45#include <sys/time.h> 45#include <sys/time.h>
46#include <sys/buf.h> 46#include <sys/buf.h>
47#include "rf_raid.h" 47#include "rf_raid.h"
48#include "rf_mcpair.h" 48#include "rf_mcpair.h"
49#include "rf_acctrace.h" 49#include "rf_acctrace.h"
50#include "rf_etimer.h" 50#include "rf_etimer.h"
51#include "rf_general.h" 51#include "rf_general.h"
52#include "rf_utils.h" 52#include "rf_utils.h"
53#include "rf_copyback.h" 53#include "rf_copyback.h"
54#include "rf_decluster.h" 54#include "rf_decluster.h"
@@ -203,26 +203,27 @@ rf_CopybackReconstructedData(RF_Raid_t * @@ -203,26 +203,27 @@ rf_CopybackReconstructedData(RF_Raid_t *
203 203
204 RF_GETTIME(desc->starttime); 204 RF_GETTIME(desc->starttime);
205 rf_ContinueCopyback(desc); 205 rf_ContinueCopyback(desc);
206 206
207 /* Data has been restored. Fix up the component label. */ 207 /* Data has been restored. Fix up the component label. */
208 /* Don't actually need the read here.. */ 208 /* Don't actually need the read here.. */
209  209
210 c_label = raidget_component_label(raidPtr, fcol); 210 c_label = raidget_component_label(raidPtr, fcol);
211 raid_init_component_label(raidPtr, c_label); 211 raid_init_component_label(raidPtr, c_label);
212 212
213 c_label->row = 0; 213 c_label->row = 0;
214 c_label->column = fcol; 214 c_label->column = fcol;
215 c_label->partitionSize = raidPtr->Disks[fcol].partitionSize; 215 c_label->partitionSize = raidPtr->Disks[fcol].partitionSize;
 216 c_label->partitionSizeHi = raidPtr->Disks[fcol].partitionSize >> 32;
216 217
217 raidflush_component_label(raidPtr, fcol); 218 raidflush_component_label(raidPtr, fcol);
218 219
219 /* XXXjld why is this here? */ 220 /* XXXjld why is this here? */
220 rf_update_component_labels(raidPtr, RF_NORMAL_COMPONENT_UPDATE); 221 rf_update_component_labels(raidPtr, RF_NORMAL_COMPONENT_UPDATE);
221} 222}
222 223
223 224
224/* 225/*
225 * invoked via callback after a copyback I/O has completed to 226 * invoked via callback after a copyback I/O has completed to
226 * continue on with the next one 227 * continue on with the next one
227 */ 228 */
228void 229void

cvs diff -r1.73 -r1.74 src/sys/dev/raidframe/rf_disks.c (expand / switch to unified diff)

--- src/sys/dev/raidframe/rf_disks.c 2010/03/01 21:10:26 1.73
+++ src/sys/dev/raidframe/rf_disks.c 2010/11/01 02:35:25 1.74
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rf_disks.c,v 1.73 2010/03/01 21:10:26 jld Exp $ */ 1/* $NetBSD: rf_disks.c,v 1.74 2010/11/01 02:35:25 mrg Exp $ */
2/*- 2/*-
3 * Copyright (c) 1999 The NetBSD Foundation, Inc. 3 * Copyright (c) 1999 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Greg Oster 7 * by Greg Oster
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -50,27 +50,27 @@ @@ -50,27 +50,27 @@
50 * School of Computer Science 50 * School of Computer Science
51 * Carnegie Mellon University 51 * Carnegie Mellon University
52 * Pittsburgh PA 15213-3890 52 * Pittsburgh PA 15213-3890
53 * 53 *
54 * any improvements or extensions that they make and grant Carnegie the 54 * any improvements or extensions that they make and grant Carnegie the
55 * rights to redistribute these changes. 55 * rights to redistribute these changes.
56 */ 56 */
57 57
58/*************************************************************** 58/***************************************************************
59 * rf_disks.c -- code to perform operations on the actual disks 59 * rf_disks.c -- code to perform operations on the actual disks
60 ***************************************************************/ 60 ***************************************************************/
61 61
62#include <sys/cdefs.h> 62#include <sys/cdefs.h>
63__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.73 2010/03/01 21:10:26 jld Exp $"); 63__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.74 2010/11/01 02:35:25 mrg Exp $");
64 64
65#include <dev/raidframe/raidframevar.h> 65#include <dev/raidframe/raidframevar.h>
66 66
67#include "rf_raid.h" 67#include "rf_raid.h"
68#include "rf_alloclist.h" 68#include "rf_alloclist.h"
69#include "rf_utils.h" 69#include "rf_utils.h"
70#include "rf_general.h" 70#include "rf_general.h"
71#include "rf_options.h" 71#include "rf_options.h"
72#include "rf_kintf.h" 72#include "rf_kintf.h"
73#include "rf_netbsd.h" 73#include "rf_netbsd.h"
74 74
75#include <sys/param.h> 75#include <sys/param.h>
76#include <sys/systm.h> 76#include <sys/systm.h>
@@ -445,26 +445,28 @@ rf_AutoConfigureDisks(RF_Raid_t *raidPtr @@ -445,26 +445,28 @@ rf_AutoConfigureDisks(RF_Raid_t *raidPtr
445 445
446 break; 446 break;
447 } 447 }
448 ac=ac->next; 448 ac=ac->next;
449 } 449 }
450 } 450 }
451 451
452 452
453 453
454 if (ac!=NULL) { 454 if (ac!=NULL) {
455 /* Found it. Configure it.. */ 455 /* Found it. Configure it.. */
456 diskPtr->blockSize = ac->clabel->blockSize; 456 diskPtr->blockSize = ac->clabel->blockSize;
457 diskPtr->numBlocks = ac->clabel->numBlocks; 457 diskPtr->numBlocks = ac->clabel->numBlocks;
 458 diskPtr->numBlocks |=
 459 (uint64_t)ac->clabel->numBlocksHi << 32;
458 /* Note: rf_protectedSectors is already 460 /* Note: rf_protectedSectors is already
459 factored into numBlocks here */ 461 factored into numBlocks here */
460 raidPtr->raid_cinfo[c].ci_vp = ac->vp; 462 raidPtr->raid_cinfo[c].ci_vp = ac->vp;
461 raidPtr->raid_cinfo[c].ci_dev = ac->dev; 463 raidPtr->raid_cinfo[c].ci_dev = ac->dev;
462 464
463 memcpy(raidget_component_label(raidPtr, c), 465 memcpy(raidget_component_label(raidPtr, c),
464 ac->clabel, sizeof(*ac->clabel)); 466 ac->clabel, sizeof(*ac->clabel));
465 snprintf(diskPtr->devname, sizeof(diskPtr->devname), 467 snprintf(diskPtr->devname, sizeof(diskPtr->devname),
466 "/dev/%s", ac->devname); 468 "/dev/%s", ac->devname);
467 469
468 /* note the fact that this component was 470 /* note the fact that this component was
469 autoconfigured. You'll need this info 471 autoconfigured. You'll need this info
470 later. Trust me :) */ 472 later. Trust me :) */

cvs diff -r1.274 -r1.275 src/sys/dev/raidframe/rf_netbsdkintf.c (expand / switch to unified diff)

--- src/sys/dev/raidframe/rf_netbsdkintf.c 2010/08/08 18:25:14 1.274
+++ src/sys/dev/raidframe/rf_netbsdkintf.c 2010/11/01 02:35:25 1.275
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rf_netbsdkintf.c,v 1.274 2010/08/08 18:25:14 chs Exp $ */ 1/* $NetBSD: rf_netbsdkintf.c,v 1.275 2010/11/01 02:35:25 mrg Exp $ */
2/*- 2/*-
3 * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc. 3 * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Greg Oster; Jason R. Thorpe. 7 * by Greg Oster; Jason R. Thorpe.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -129,27 +129,27 @@ @@ -129,27 +129,27 @@
129 * Pittsburgh PA 15213-3890 129 * Pittsburgh PA 15213-3890
130 * 130 *
131 * any improvements or extensions that they make and grant Carnegie the 131 * any improvements or extensions that they make and grant Carnegie the
132 * rights to redistribute these changes. 132 * rights to redistribute these changes.
133 */ 133 */
134 134
135/*********************************************************** 135/***********************************************************
136 * 136 *
137 * rf_kintf.c -- the kernel interface routines for RAIDframe 137 * rf_kintf.c -- the kernel interface routines for RAIDframe
138 * 138 *
139 ***********************************************************/ 139 ***********************************************************/
140 140
141#include <sys/cdefs.h> 141#include <sys/cdefs.h>
142__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.274 2010/08/08 18:25:14 chs Exp $"); 142__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.275 2010/11/01 02:35:25 mrg Exp $");
143 143
144#ifdef _KERNEL_OPT 144#ifdef _KERNEL_OPT
145#include "opt_compat_netbsd.h" 145#include "opt_compat_netbsd.h"
146#include "opt_raid_autoconfig.h" 146#include "opt_raid_autoconfig.h"
147#include "raid.h" 147#include "raid.h"
148#endif 148#endif
149 149
150#include <sys/param.h> 150#include <sys/param.h>
151#include <sys/errno.h> 151#include <sys/errno.h>
152#include <sys/pool.h> 152#include <sys/pool.h>
153#include <sys/proc.h> 153#include <sys/proc.h>
154#include <sys/queue.h> 154#include <sys/queue.h>
155#include <sys/disk.h> 155#include <sys/disk.h>
@@ -1926,26 +1926,27 @@ raidinit(RF_Raid_t *raidPtr) @@ -1926,26 +1926,27 @@ raidinit(RF_Raid_t *raidPtr)
1926 printf("raid%d: config_attach_pseudo failed\n", 1926 printf("raid%d: config_attach_pseudo failed\n",
1927 raidPtr->raidid); 1927 raidPtr->raidid);
1928 rs->sc_flags &= ~RAIDF_INITED; 1928 rs->sc_flags &= ~RAIDF_INITED;
1929 free(cf, M_RAIDFRAME); 1929 free(cf, M_RAIDFRAME);
1930 return; 1930 return;
1931 } 1931 }
1932 1932
1933 /* disk_attach actually creates space for the CPU disklabel, among 1933 /* disk_attach actually creates space for the CPU disklabel, among
1934 * other things, so it's critical to call this *BEFORE* we try putzing 1934 * other things, so it's critical to call this *BEFORE* we try putzing
1935 * with disklabels. */ 1935 * with disklabels. */
1936 1936
1937 disk_init(&rs->sc_dkdev, rs->sc_xname, &rf_dkdriver); 1937 disk_init(&rs->sc_dkdev, rs->sc_xname, &rf_dkdriver);
1938 disk_attach(&rs->sc_dkdev); 1938 disk_attach(&rs->sc_dkdev);
 1939 disk_blocksize(&rs->sc_dkdev, raidPtr->bytesPerSector);
1939 1940
1940 /* XXX There may be a weird interaction here between this, and 1941 /* XXX There may be a weird interaction here between this, and
1941 * protectedSectors, as used in RAIDframe. */ 1942 * protectedSectors, as used in RAIDframe. */
1942 1943
1943 rs->sc_size = raidPtr->totalSectors; 1944 rs->sc_size = raidPtr->totalSectors;
1944 1945
1945 dkwedge_discover(&rs->sc_dkdev); 1946 dkwedge_discover(&rs->sc_dkdev);
1946 1947
1947 rf_set_properties(rs, raidPtr); 1948 rf_set_properties(rs, raidPtr);
1948 1949
1949} 1950}
1950#if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0) 1951#if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0)
1951/* wake up the daemon & tell it to get us a spare table 1952/* wake up the daemon & tell it to get us a spare table
@@ -2021,27 +2022,27 @@ raidstart(RF_Raid_t *raidPtr) @@ -2021,27 +2022,27 @@ raidstart(RF_Raid_t *raidPtr)
2021 while (raidPtr->openings > 0) { 2022 while (raidPtr->openings > 0) {
2022 RF_UNLOCK_MUTEX(raidPtr->mutex); 2023 RF_UNLOCK_MUTEX(raidPtr->mutex);
2023 2024
2024 /* get the next item, if any, from the queue */ 2025 /* get the next item, if any, from the queue */
2025 if ((bp = bufq_get(rs->buf_queue)) == NULL) { 2026 if ((bp = bufq_get(rs->buf_queue)) == NULL) {
2026 /* nothing more to do */ 2027 /* nothing more to do */
2027 return; 2028 return;
2028 } 2029 }
2029 2030
2030 /* Ok, for the bp we have here, bp->b_blkno is relative to the 2031 /* Ok, for the bp we have here, bp->b_blkno is relative to the
2031 * partition.. Need to make it absolute to the underlying 2032 * partition.. Need to make it absolute to the underlying
2032 * device.. */ 2033 * device.. */
2033 2034
2034 blocknum = bp->b_blkno; 2035 blocknum = bp->b_blkno << DEV_BSHIFT >> raidPtr->logBytesPerSector;
2035 if (DISKPART(bp->b_dev) != RAW_PART) { 2036 if (DISKPART(bp->b_dev) != RAW_PART) {
2036 pp = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)]; 2037 pp = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)];
2037 blocknum += pp->p_offset; 2038 blocknum += pp->p_offset;
2038 } 2039 }
2039 2040
2040 db1_printf(("Blocks: %d, %d\n", (int) bp->b_blkno, 2041 db1_printf(("Blocks: %d, %d\n", (int) bp->b_blkno,
2041 (int) blocknum)); 2042 (int) blocknum));
2042 2043
2043 db1_printf(("bp->b_bcount = %d\n", (int) bp->b_bcount)); 2044 db1_printf(("bp->b_bcount = %d\n", (int) bp->b_bcount));
2044 db1_printf(("bp->b_resid = %d\n", (int) bp->b_resid)); 2045 db1_printf(("bp->b_resid = %d\n", (int) bp->b_resid));
2045 2046
2046 /* *THIS* is where we adjust what block we're going to... 2047 /* *THIS* is where we adjust what block we're going to...
2047 * but DO NOT TOUCH bp->b_blkno!!! */ 2048 * but DO NOT TOUCH bp->b_blkno!!! */
@@ -2273,27 +2274,27 @@ InitBP(struct buf *bp, struct vnode *b_v @@ -2273,27 +2274,27 @@ InitBP(struct buf *bp, struct vnode *b_v
2273 RF_SectorNum_t startSect, RF_SectorCount_t numSect, void *bf, 2274 RF_SectorNum_t startSect, RF_SectorCount_t numSect, void *bf,
2274 void (*cbFunc) (struct buf *), void *cbArg, int logBytesPerSector, 2275 void (*cbFunc) (struct buf *), void *cbArg, int logBytesPerSector,
2275 struct proc *b_proc) 2276 struct proc *b_proc)
2276{ 2277{
2277 /* bp->b_flags = B_PHYS | rw_flag; */ 2278 /* bp->b_flags = B_PHYS | rw_flag; */
2278 bp->b_flags = rw_flag; /* XXX need B_PHYS here too??? */ 2279 bp->b_flags = rw_flag; /* XXX need B_PHYS here too??? */
2279 bp->b_oflags = 0; 2280 bp->b_oflags = 0;
2280 bp->b_cflags = 0; 2281 bp->b_cflags = 0;
2281 bp->b_bcount = numSect << logBytesPerSector; 2282 bp->b_bcount = numSect << logBytesPerSector;
2282 bp->b_bufsize = bp->b_bcount; 2283 bp->b_bufsize = bp->b_bcount;
2283 bp->b_error = 0; 2284 bp->b_error = 0;
2284 bp->b_dev = dev; 2285 bp->b_dev = dev;
2285 bp->b_data = bf; 2286 bp->b_data = bf;
2286 bp->b_blkno = startSect; 2287 bp->b_blkno = startSect << logBytesPerSector >> DEV_BSHIFT;
2287 bp->b_resid = bp->b_bcount; /* XXX is this right!??!?!! */ 2288 bp->b_resid = bp->b_bcount; /* XXX is this right!??!?!! */
2288 if (bp->b_bcount == 0) { 2289 if (bp->b_bcount == 0) {
2289 panic("bp->b_bcount is zero in InitBP!!"); 2290 panic("bp->b_bcount is zero in InitBP!!");
2290 } 2291 }
2291 bp->b_proc = b_proc; 2292 bp->b_proc = b_proc;
2292 bp->b_iodone = cbFunc; 2293 bp->b_iodone = cbFunc;
2293 bp->b_private = cbArg; 2294 bp->b_private = cbArg;
2294} 2295}
2295 2296
2296static void 2297static void
2297raidgetdefaultlabel(RF_Raid_t *raidPtr, struct raid_softc *rs, 2298raidgetdefaultlabel(RF_Raid_t *raidPtr, struct raid_softc *rs,
2298 struct disklabel *lp) 2299 struct disklabel *lp)
2299{ 2300{
@@ -3126,39 +3127,42 @@ rf_reasonable_label(RF_ComponentLabel_t  @@ -3126,39 +3127,42 @@ rf_reasonable_label(RF_ComponentLabel_t
3126 clabel->blockSize > 0 && 3127 clabel->blockSize > 0 &&
3127 clabel->numBlocks > 0) { 3128 clabel->numBlocks > 0) {
3128 /* label looks reasonable enough... */ 3129 /* label looks reasonable enough... */
3129 return(1); 3130 return(1);
3130 } 3131 }
3131 return(0); 3132 return(0);
3132} 3133}
3133 3134
3134 3135
3135#ifdef DEBUG 3136#ifdef DEBUG
3136void 3137void
3137rf_print_component_label(RF_ComponentLabel_t *clabel) 3138rf_print_component_label(RF_ComponentLabel_t *clabel)
3138{ 3139{
 3140 uint64_t numBlocks = clabel->numBlocks;
 3141
 3142 numBlocks |= (uint64_t)clabel->numBlocksHi << 32;
 3143
3139 printf(" Row: %d Column: %d Num Rows: %d Num Columns: %d\n", 3144 printf(" Row: %d Column: %d Num Rows: %d Num Columns: %d\n",
3140 clabel->row, clabel->column, 3145 clabel->row, clabel->column,
3141 clabel->num_rows, clabel->num_columns); 3146 clabel->num_rows, clabel->num_columns);
3142 printf(" Version: %d Serial Number: %d Mod Counter: %d\n", 3147 printf(" Version: %d Serial Number: %d Mod Counter: %d\n",
3143 clabel->version, clabel->serial_number, 3148 clabel->version, clabel->serial_number,
3144 clabel->mod_counter); 3149 clabel->mod_counter);
3145 printf(" Clean: %s Status: %d\n", 3150 printf(" Clean: %s Status: %d\n",
3146 clabel->clean ? "Yes" : "No", clabel->status); 3151 clabel->clean ? "Yes" : "No", clabel->status);
3147 printf(" sectPerSU: %d SUsPerPU: %d SUsPerRU: %d\n", 3152 printf(" sectPerSU: %d SUsPerPU: %d SUsPerRU: %d\n",
3148 clabel->sectPerSU, clabel->SUsPerPU, clabel->SUsPerRU); 3153 clabel->sectPerSU, clabel->SUsPerPU, clabel->SUsPerRU);
3149 printf(" RAID Level: %c blocksize: %d numBlocks: %d\n", 3154 printf(" RAID Level: %c blocksize: %d numBlocks: %"PRIu64"\n",
3150 (char) clabel->parityConfig, clabel->blockSize, 3155 (char) clabel->parityConfig, clabel->blockSize, numBlocks);
3151 clabel->numBlocks); 
3152 printf(" Autoconfig: %s\n", clabel->autoconfigure ? "Yes" : "No"); 3156 printf(" Autoconfig: %s\n", clabel->autoconfigure ? "Yes" : "No");
3153 printf(" Contains root partition: %s\n", 3157 printf(" Contains root partition: %s\n",
3154 clabel->root_partition ? "Yes" : "No"); 3158 clabel->root_partition ? "Yes" : "No");
3155 printf(" Last configured as: raid%d\n", clabel->last_unit); 3159 printf(" Last configured as: raid%d\n", clabel->last_unit);
3156#if 0 3160#if 0
3157 printf(" Config order: %d\n", clabel->config_order); 3161 printf(" Config order: %d\n", clabel->config_order);
3158#endif 3162#endif
3159 3163
3160} 3164}
3161#endif 3165#endif
3162 3166
3163RF_ConfigSet_t * 3167RF_ConfigSet_t *
3164rf_create_auto_sets(RF_AutoConfig_t *ac_list) 3168rf_create_auto_sets(RF_AutoConfig_t *ac_list)
@@ -3259,26 +3263,27 @@ rf_does_it_fit(RF_ConfigSet_t *cset, RF_ @@ -3259,26 +3263,27 @@ rf_does_it_fit(RF_ConfigSet_t *cset, RF_
3259 clabel1 = cset->ac->clabel; 3263 clabel1 = cset->ac->clabel;
3260 clabel2 = ac->clabel; 3264 clabel2 = ac->clabel;
3261 if ((clabel1->version == clabel2->version) && 3265 if ((clabel1->version == clabel2->version) &&
3262 (clabel1->serial_number == clabel2->serial_number) && 3266 (clabel1->serial_number == clabel2->serial_number) &&
3263 (clabel1->num_rows == clabel2->num_rows) && 3267 (clabel1->num_rows == clabel2->num_rows) &&
3264 (clabel1->num_columns == clabel2->num_columns) && 3268 (clabel1->num_columns == clabel2->num_columns) &&
3265 (clabel1->sectPerSU == clabel2->sectPerSU) && 3269 (clabel1->sectPerSU == clabel2->sectPerSU) &&
3266 (clabel1->SUsPerPU == clabel2->SUsPerPU) && 3270 (clabel1->SUsPerPU == clabel2->SUsPerPU) &&
3267 (clabel1->SUsPerRU == clabel2->SUsPerRU) && 3271 (clabel1->SUsPerRU == clabel2->SUsPerRU) &&
3268 (clabel1->parityConfig == clabel2->parityConfig) && 3272 (clabel1->parityConfig == clabel2->parityConfig) &&
3269 (clabel1->maxOutstanding == clabel2->maxOutstanding) && 3273 (clabel1->maxOutstanding == clabel2->maxOutstanding) &&
3270 (clabel1->blockSize == clabel2->blockSize) && 3274 (clabel1->blockSize == clabel2->blockSize) &&
3271 (clabel1->numBlocks == clabel2->numBlocks) && 3275 (clabel1->numBlocks == clabel2->numBlocks) &&
 3276 (clabel1->numBlocksHi == clabel2->numBlocksHi) &&
3272 (clabel1->autoconfigure == clabel2->autoconfigure) && 3277 (clabel1->autoconfigure == clabel2->autoconfigure) &&
3273 (clabel1->root_partition == clabel2->root_partition) && 3278 (clabel1->root_partition == clabel2->root_partition) &&
3274 (clabel1->last_unit == clabel2->last_unit) && 3279 (clabel1->last_unit == clabel2->last_unit) &&
3275 (clabel1->config_order == clabel2->config_order)) { 3280 (clabel1->config_order == clabel2->config_order)) {
3276 /* if it get's here, it almost *has* to be a match */ 3281 /* if it get's here, it almost *has* to be a match */
3277 } else { 3282 } else {
3278 /* it's not consistent with somebody in the set.. 3283 /* it's not consistent with somebody in the set..
3279 punt */ 3284 punt */
3280 return(0); 3285 return(0);
3281 } 3286 }
3282 /* all was fine.. it must fit... */ 3287 /* all was fine.. it must fit... */
3283 return(1); 3288 return(1);
3284} 3289}
@@ -3523,26 +3528,27 @@ raid_init_component_label(RF_Raid_t *rai @@ -3523,26 +3528,27 @@ raid_init_component_label(RF_Raid_t *rai
3523 clabel->mod_counter = raidPtr->mod_counter; 3528 clabel->mod_counter = raidPtr->mod_counter;
3524 3529
3525 clabel->num_rows = 1; 3530 clabel->num_rows = 1;
3526 clabel->num_columns = raidPtr->numCol; 3531 clabel->num_columns = raidPtr->numCol;
3527 clabel->clean = RF_RAID_DIRTY; /* not clean */ 3532 clabel->clean = RF_RAID_DIRTY; /* not clean */
3528 clabel->status = rf_ds_optimal; /* "It's good!" */ 3533 clabel->status = rf_ds_optimal; /* "It's good!" */
3529 3534
3530 clabel->sectPerSU = raidPtr->Layout.sectorsPerStripeUnit; 3535 clabel->sectPerSU = raidPtr->Layout.sectorsPerStripeUnit;
3531 clabel->SUsPerPU = raidPtr->Layout.SUsPerPU; 3536 clabel->SUsPerPU = raidPtr->Layout.SUsPerPU;
3532 clabel->SUsPerRU = raidPtr->Layout.SUsPerRU; 3537 clabel->SUsPerRU = raidPtr->Layout.SUsPerRU;
3533 3538
3534 clabel->blockSize = raidPtr->bytesPerSector; 3539 clabel->blockSize = raidPtr->bytesPerSector;
3535 clabel->numBlocks = raidPtr->sectorsPerDisk; 3540 clabel->numBlocks = raidPtr->sectorsPerDisk;
 3541 clabel->numBlocksHi = raidPtr->sectorsPerDisk >> 32;
3536 3542
3537 /* XXX not portable */ 3543 /* XXX not portable */
3538 clabel->parityConfig = raidPtr->Layout.map->parityConfig; 3544 clabel->parityConfig = raidPtr->Layout.map->parityConfig;
3539 clabel->maxOutstanding = raidPtr->maxOutstanding; 3545 clabel->maxOutstanding = raidPtr->maxOutstanding;
3540 clabel->autoconfigure = raidPtr->autoconfigure; 3546 clabel->autoconfigure = raidPtr->autoconfigure;
3541 clabel->root_partition = raidPtr->root_partition; 3547 clabel->root_partition = raidPtr->root_partition;
3542 clabel->last_unit = raidPtr->raidid; 3548 clabel->last_unit = raidPtr->raidid;
3543 clabel->config_order = raidPtr->config_order; 3549 clabel->config_order = raidPtr->config_order;
3544 3550
3545#ifndef RF_NO_PARITY_MAP 3551#ifndef RF_NO_PARITY_MAP
3546 rf_paritymap_init_label(raidPtr->parity_map, clabel); 3552 rf_paritymap_init_label(raidPtr->parity_map, clabel);
3547#endif 3553#endif
3548} 3554}
@@ -3681,43 +3687,35 @@ rf_buf_queue_check(int raidid) @@ -3681,43 +3687,35 @@ rf_buf_queue_check(int raidid)
3681{ 3687{
3682 if ((bufq_peek(raid_softc[raidid].buf_queue) != NULL) && 3688 if ((bufq_peek(raid_softc[raidid].buf_queue) != NULL) &&
3683 raidPtrs[raidid]->openings > 0) { 3689 raidPtrs[raidid]->openings > 0) {
3684 /* there is work to do */ 3690 /* there is work to do */
3685 return 0; 3691 return 0;
3686 }  3692 }
3687 /* default is nothing to do */ 3693 /* default is nothing to do */
3688 return 1; 3694 return 1;
3689} 3695}
3690 3696
3691int 3697int
3692rf_getdisksize(struct vnode *vp, struct lwp *l, RF_RaidDisk_t *diskPtr) 3698rf_getdisksize(struct vnode *vp, struct lwp *l, RF_RaidDisk_t *diskPtr)
3693{ 3699{
3694 struct partinfo dpart; 3700 uint64_t numsecs;
3695 struct dkwedge_info dkw; 3701 unsigned secsize;
3696 int error; 3702 int error;
3697 3703
3698 error = VOP_IOCTL(vp, DIOCGPART, &dpart, FREAD, l->l_cred); 3704 error = getdisksize(vp, &numsecs, &secsize);
3699 if (error == 0) { 
3700 diskPtr->blockSize = dpart.disklab->d_secsize; 
3701 diskPtr->numBlocks = dpart.part->p_size - rf_protectedSectors; 
3702 diskPtr->partitionSize = dpart.part->p_size; 
3703 return 0; 
3704 } 
3705 
3706 error = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, l->l_cred); 
3707 if (error == 0) { 3705 if (error == 0) {
3708 diskPtr->blockSize = 512; /* XXX */ 3706 diskPtr->blockSize = secsize;
3709 diskPtr->numBlocks = dkw.dkw_size - rf_protectedSectors; 3707 diskPtr->numBlocks = numsecs - rf_protectedSectors;
3710 diskPtr->partitionSize = dkw.dkw_size; 3708 diskPtr->partitionSize = numsecs;
3711 return 0; 3709 return 0;
3712 } 3710 }
3713 return error; 3711 return error;
3714} 3712}
3715 3713
3716static int 3714static int
3717raid_match(device_t self, cfdata_t cfdata, void *aux) 3715raid_match(device_t self, cfdata_t cfdata, void *aux)
3718{ 3716{
3719 return 1; 3717 return 1;
3720} 3718}
3721 3719
3722static void 3720static void
3723raid_attach(device_t parent, device_t self, void *aux) 3721raid_attach(device_t parent, device_t self, void *aux)

cvs diff -r1.108 -r1.109 src/sys/dev/raidframe/rf_reconstruct.c (expand / switch to unified diff)

--- src/sys/dev/raidframe/rf_reconstruct.c 2009/11/17 18:54:26 1.108
+++ src/sys/dev/raidframe/rf_reconstruct.c 2010/11/01 02:35:25 1.109
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rf_reconstruct.c,v 1.108 2009/11/17 18:54:26 jld Exp $ */ 1/* $NetBSD: rf_reconstruct.c,v 1.109 2010/11/01 02:35:25 mrg Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Carnegie-Mellon University. 3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Author: Mark Holland 6 * Author: Mark Holland
7 * 7 *
8 * Permission to use, copy, modify and distribute this software and 8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright 9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the 10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions 11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation. 12 * thereof, and that both notices appear in supporting documentation.
13 * 13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * Pittsburgh PA 15213-3890 23 * Pittsburgh PA 15213-3890
24 * 24 *
25 * any improvements or extensions that they make and grant Carnegie the 25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes. 26 * rights to redistribute these changes.
27 */ 27 */
28 28
29/************************************************************ 29/************************************************************
30 * 30 *
31 * rf_reconstruct.c -- code to perform on-line reconstruction 31 * rf_reconstruct.c -- code to perform on-line reconstruction
32 * 32 *
33 ************************************************************/ 33 ************************************************************/
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.108 2009/11/17 18:54:26 jld Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.109 2010/11/01 02:35:25 mrg Exp $");
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/time.h> 39#include <sys/time.h>
40#include <sys/buf.h> 40#include <sys/buf.h>
41#include <sys/errno.h> 41#include <sys/errno.h>
42#include <sys/systm.h> 42#include <sys/systm.h>
43#include <sys/proc.h> 43#include <sys/proc.h>
44#include <sys/ioctl.h> 44#include <sys/ioctl.h>
45#include <sys/fcntl.h> 45#include <sys/fcntl.h>
46#include <sys/vnode.h> 46#include <sys/vnode.h>
47#include <dev/raidframe/raidframevar.h> 47#include <dev/raidframe/raidframevar.h>
48 48
49#include "rf_raid.h" 49#include "rf_raid.h"
@@ -287,26 +287,28 @@ rf_ReconstructFailedDiskBasic(RF_Raid_t  @@ -287,26 +287,28 @@ rf_ReconstructFailedDiskBasic(RF_Raid_t
287 rc = rf_ContinueReconstructFailedDisk(reconDesc); 287 rc = rf_ContinueReconstructFailedDisk(reconDesc);
288 288
289 if (!rc) { 289 if (!rc) {
290 /* fix up the component label */ 290 /* fix up the component label */
291 /* Don't actually need the read here.. */ 291 /* Don't actually need the read here.. */
292 c_label = raidget_component_label(raidPtr, scol); 292 c_label = raidget_component_label(raidPtr, scol);
293 293
294 raid_init_component_label(raidPtr, c_label); 294 raid_init_component_label(raidPtr, c_label);
295 c_label->row = 0; 295 c_label->row = 0;
296 c_label->column = col; 296 c_label->column = col;
297 c_label->clean = RF_RAID_DIRTY; 297 c_label->clean = RF_RAID_DIRTY;
298 c_label->status = rf_ds_optimal; 298 c_label->status = rf_ds_optimal;
299 c_label->partitionSize = raidPtr->Disks[scol].partitionSize; 299 c_label->partitionSize = raidPtr->Disks[scol].partitionSize;
 300 c_label->partitionSizeHi =
 301 raidPtr->Disks[scol].partitionSize >> 32;
300 302
301 /* We've just done a rebuild based on all the other 303 /* We've just done a rebuild based on all the other
302 disks, so at this point the parity is known to be 304 disks, so at this point the parity is known to be
303 clean, even if it wasn't before. */ 305 clean, even if it wasn't before. */
304 306
305 /* XXX doesn't hold for RAID 6!!*/ 307 /* XXX doesn't hold for RAID 6!!*/
306 308
307 RF_LOCK_MUTEX(raidPtr->mutex); 309 RF_LOCK_MUTEX(raidPtr->mutex);
308 raidPtr->parity_good = RF_RAID_CLEAN; 310 raidPtr->parity_good = RF_RAID_CLEAN;
309 RF_UNLOCK_MUTEX(raidPtr->mutex); 311 RF_UNLOCK_MUTEX(raidPtr->mutex);
310 312
311 /* XXXX MORE NEEDED HERE */ 313 /* XXXX MORE NEEDED HERE */
312 314