From 44f1dacd9f544e7d6b24890c23b6750329738b9e Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Fri, 12 May 2006 20:51:26 +0000 Subject: Fix a misreporting bug after bioctl -H is used to create a hotspare. This was reported by several people. What happens is that the firmware sometimes misreports what SCSI type a device is. The driver was only allowing a create hotspare function when the type was set to hard disk. Since the firmware will, obviously, not allow the driver to create a hotspare on any other type of device the driver doesn't need these smarts and now will ignore the type. Tested by henning todd and Ben Lovett. ok dlg --- sys/dev/ic/ami.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c index 8008062c809..de0a387a03c 100644 --- a/sys/dev/ic/ami.c +++ b/sys/dev/ic/ami.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ami.c,v 1.155 2006/04/26 22:41:08 dlg Exp $ */ +/* $OpenBSD: ami.c,v 1.156 2006/05/12 20:51:25 marco Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -47,6 +47,8 @@ #include "bio.h" +/* #define AMI_DEBUG */ + #include #include #include @@ -71,8 +73,6 @@ #include #endif -/*#define AMI_DEBUG */ - #ifdef AMI_DEBUG #define AMI_DPRINTF(m,a) do { if (ami_debug & (m)) printf a; } while (0) #define AMI_D_CMD 0x0001 @@ -2095,12 +2095,19 @@ ami_disk(struct ami_softc *sc, struct bioc_disk *bd, sc->sc_rawsoftcs[ch].sc_procdev, sizeof(bd->bd_procdev)); - if (p->apd[i].adp_ostatus == AMI_PD_HOTSPARE - && p->apd[i].adp_type == 0) + if (p->apd[i].adp_ostatus == AMI_PD_HOTSPARE) bd->bd_status = BIOC_SDHOTSPARE; else bd->bd_status = BIOC_SDUNUSED; +#ifdef AMI_DEBUG + if (p->apd[i].adp_type != 0) + printf("invalid disk type: %d %d " + "%x inquiry type: %x\n", + ch, tg, p->apd[i].adp_type, + inqbuf.device); +#endif /* AMI_DEBUG */ + error = 0; goto bail; } @@ -2346,9 +2353,8 @@ int ami_ioctl_alarm(struct ami_softc *sc, struct bioc_alarm *ba) int ami_ioctl_setstate(struct ami_softc *sc, struct bioc_setstate *bs) { - int func; - struct ami_big_diskarray *p; struct scsi_inquiry_data inqbuf; + int func; int off; switch (bs->bs_status) { @@ -2361,20 +2367,11 @@ ami_ioctl_setstate(struct ami_softc *sc, struct bioc_setstate *bs) break; case BIOC_SSHOTSPARE: - p = malloc(sizeof *p, M_DEVBUF, M_NOWAIT); - if (!p) - return (ENOMEM); - - if (ami_mgmt(sc, AMI_FCOP, AMI_FC_RDCONF, 0, 0, sizeof *p, p)) - goto bail; - off = bs->bs_channel * AMI_MAX_TARGET + bs->bs_target; if (ami_drv_inq(sc, bs->bs_channel, bs->bs_target, 0, &inqbuf)) - goto bail; - - free(p, M_DEVBUF); + return (EINVAL); func = AMI_STATE_SPARE; break; @@ -2390,11 +2387,6 @@ ami_ioctl_setstate(struct ami_softc *sc, struct bioc_setstate *bs) return (EINVAL); return (0); - -bail: - free(p, M_DEVBUF); - - return (EINVAL); } void -- cgit v1.2.3