Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/raidframe apply my patch to support non-512K sector ...
details: https://anonhg.NetBSD.org/src/rev/a037323170ef
branches: trunk
changeset: 759254:a037323170ef
user: mrg <mrg%NetBSD.org@localhost>
date: Sat Dec 04 10:01:16 2010 +0000
description:
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.
diffstat:
sys/dev/raidframe/rf_disks.c | 20 +++-
sys/dev/raidframe/rf_netbsdkintf.c | 149 ++++++++++++++++++++++++++----------
2 files changed, 121 insertions(+), 48 deletions(-)
diffs (truncated from 327 to 300 lines):
diff -r 4aea7941840a -r a037323170ef sys/dev/raidframe/rf_disks.c
--- a/sys/dev/raidframe/rf_disks.c Fri Dec 03 23:07:49 2010 +0000
+++ b/sys/dev/raidframe/rf_disks.c Sat Dec 04 10:01:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_disks.c,v 1.75 2010/11/19 06:44:40 dholland Exp $ */
+/* $NetBSD: rf_disks.c,v 1.76 2010/12/04 10:01:16 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.75 2010/11/19 06:44:40 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.76 2010/12/04 10:01:16 mrg Exp $");
#include <dev/raidframe/raidframevar.h>
@@ -608,16 +608,26 @@
if (error == ENXIO) {
/* the component isn't there... must be dead :-( */
diskPtr->status = rf_ds_failed;
+ return 0;
} else {
return (error);
}
}
+
+ 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;
diff -r 4aea7941840a -r a037323170ef sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c Fri Dec 03 23:07:49 2010 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c Sat Dec 04 10:01:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.275 2010/11/01 02:35:25 mrg Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.276 2010/12/04 10:01:16 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.275 2010/11/01 02:35:25 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.276 2010/12/04 10:01:16 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -227,10 +227,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);
@@ -1033,8 +1033,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) {
@@ -2441,10 +2441,57 @@
#define RF_COMPONENT_INFO_OFFSET 16384 /* bytes */
#define RF_COMPONENT_INFO_SIZE 1024 /* bytes */
-#define RF_PARITY_MAP_OFFSET \
- (RF_COMPONENT_INFO_OFFSET + RF_COMPONENT_INFO_SIZE)
#define RF_PARITY_MAP_SIZE RF_PARITYMAP_NBYTE
+static daddr_t
+rf_component_info_offset(void)
+{
+
+ return RF_COMPONENT_INFO_OFFSET;
+}
+
+static daddr_t
+rf_component_info_size(unsigned secsize)
+{
+ daddr_t info_size;
+
+ KASSERT(secsize);
+ if (secsize > RF_COMPONENT_INFO_SIZE)
+ info_size = secsize;
+ else
+ info_size = RF_COMPONENT_INFO_SIZE;
+
+ return info_size;
+}
+
+static daddr_t
+rf_parity_map_offset(RF_Raid_t *raidPtr)
+{
+ daddr_t map_offset;
+
+ KASSERT(raidPtr->bytesPerSector);
+ if (raidPtr->bytesPerSector > RF_COMPONENT_INFO_SIZE)
+ map_offset = raidPtr->bytesPerSector;
+ else
+ map_offset = RF_COMPONENT_INFO_SIZE;
+ map_offset += rf_component_info_offset();
+
+ return map_offset;
+}
+
+static daddr_t
+rf_parity_map_size(RF_Raid_t *raidPtr)
+{
+ daddr_t map_size;
+
+ if (raidPtr->bytesPerSector > RF_PARITY_MAP_SIZE)
+ map_size = raidPtr->bytesPerSector;
+ else
+ map_size = RF_PARITY_MAP_SIZE;
+
+ return map_size;
+}
+
int
raidmarkclean(RF_Raid_t *raidPtr, RF_RowCol_t col)
{
@@ -2471,7 +2518,9 @@
int
raidfetch_component_label(RF_Raid_t *raidPtr, RF_RowCol_t col)
{
- return raidread_component_label(raidPtr->Disks[col].dev,
+ KASSERT(raidPtr->bytesPerSector);
+ return raidread_component_label(raidPtr->bytesPerSector,
+ raidPtr->Disks[col].dev,
raidPtr->raid_cinfo[col].ci_vp,
&raidPtr->raid_cinfo[col].ci_label);
}
@@ -2492,18 +2541,20 @@
#ifndef RF_NO_PARITY_MAP
label->parity_map_modcount = label->mod_counter;
#endif
- return raidwrite_component_label(raidPtr->Disks[col].dev,
+ return raidwrite_component_label(raidPtr->bytesPerSector,
+ raidPtr->Disks[col].dev,
raidPtr->raid_cinfo[col].ci_vp, label);
}
static int
-raidread_component_label(dev_t dev, struct vnode *b_vp,
+raidread_component_label(unsigned secsize, dev_t dev, struct vnode *b_vp,
RF_ComponentLabel_t *clabel)
{
return raidread_component_area(dev, b_vp, clabel,
sizeof(RF_ComponentLabel_t),
- RF_COMPONENT_INFO_OFFSET, RF_COMPONENT_INFO_SIZE);
+ rf_component_info_offset(),
+ rf_component_info_size(secsize));
}
/* ARGSUSED */
@@ -2551,12 +2602,13 @@
static int
-raidwrite_component_label(dev_t dev, struct vnode *b_vp,
- RF_ComponentLabel_t *clabel)
+raidwrite_component_label(unsigned secsize, dev_t dev, struct vnode *b_vp,
+ RF_ComponentLabel_t *clabel)
{
return raidwrite_component_area(dev, b_vp, clabel,
sizeof(RF_ComponentLabel_t),
- RF_COMPONENT_INFO_OFFSET, RF_COMPONENT_INFO_SIZE, 0);
+ rf_component_info_offset(),
+ rf_component_info_size(secsize), 0);
}
/* ARGSUSED */
@@ -2611,7 +2663,8 @@
raidwrite_component_area(raidPtr->Disks[c].dev,
raidPtr->raid_cinfo[c].ci_vp, map,
RF_PARITYMAP_NBYTE,
- RF_PARITY_MAP_OFFSET, RF_PARITY_MAP_SIZE, 0);
+ rf_parity_map_offset(raidPtr),
+ rf_parity_map_size(raidPtr), 0);
}
}
@@ -2629,7 +2682,8 @@
raidread_component_area(raidPtr->Disks[c].dev,
raidPtr->raid_cinfo[c].ci_vp, &tmp,
RF_PARITYMAP_NBYTE,
- RF_PARITY_MAP_OFFSET, RF_PARITY_MAP_SIZE);
+ rf_parity_map_offset(raidPtr),
+ rf_parity_map_size(raidPtr));
if (first) {
memcpy(map, &tmp, sizeof(*map));
first = 0;
@@ -2909,7 +2963,8 @@
static RF_AutoConfig_t *
rf_get_component(RF_AutoConfig_t *ac_list, dev_t dev, struct vnode *vp,
- const char *cname, RF_SectorCount_t size)
+ const char *cname, RF_SectorCount_t size, uint64_t numsecs,
+ unsigned secsize)
{
int good_one = 0;
RF_ComponentLabel_t *clabel;
@@ -2929,30 +2984,30 @@
return NULL; /* XXX probably should panic? */
}
- if (!raidread_component_label(dev, vp, clabel)) {
- /* Got the label. Does it look reasonable? */
- if (rf_reasonable_label(clabel) &&
- (clabel->partitionSize <= size)) {
+ if (!raidread_component_label(secsize, dev, vp, clabel)) {
+ /* Got the label. Does it look reasonable? */
+ if (rf_reasonable_label(clabel) &&
+ (clabel->partitionSize <= size)) {
#ifdef DEBUG
- printf("Component on: %s: %llu\n",
+ printf("Component on: %s: %llu\n",
cname, (unsigned long long)size);
- rf_print_component_label(clabel);
+ rf_print_component_label(clabel);
#endif
- /* if it's reasonable, add it, else ignore it. */
- ac = malloc(sizeof(RF_AutoConfig_t), M_RAIDFRAME,
+ /* if it's reasonable, add it, else ignore it. */
+ ac = malloc(sizeof(RF_AutoConfig_t), M_RAIDFRAME,
M_NOWAIT);
- if (ac == NULL) {
- free(clabel, M_RAIDFRAME);
- goto oomem;
- }
- strlcpy(ac->devname, cname, sizeof(ac->devname));
- ac->dev = dev;
- ac->vp = vp;
- ac->clabel = clabel;
- ac->next = ac_list;
- ac_list = ac;
- good_one = 1;
- }
+ if (ac == NULL) {
+ free(clabel, M_RAIDFRAME);
+ goto oomem;
+ }
+ strlcpy(ac->devname, cname, sizeof(ac->devname));
+ ac->dev = dev;
+ ac->vp = vp;
+ ac->clabel = clabel;
+ ac->next = ac_list;
+ ac_list = ac;
+ good_one = 1;
+ }
}
if (!good_one) {
/* cleanup */
@@ -2976,7 +3031,10 @@
int error;
int i;
RF_AutoConfig_t *ac_list;
-
+ uint64_t numsecs;
+ unsigned secsize;
+
+ RF_ASSERT(raidPtr->bytesPerSector < rf_component_info_offset());
/* initialize the AutoConfig list */
ac_list = NULL;
@@ -3036,6 +3094,11 @@
continue;
}
Home |
Main Index |
Thread Index |
Old Index