From yasuoka@yasuoka.net Sat Feb 7 21:50:51 2015 Delivered-To: david@gwynne.id.au Received: by 10.217.142.208 with SMTP id et58csp1301092web; Sat, 7 Feb 2015 03:50:53 -0800 (PST) X-Received: by 10.66.122.69 with SMTP id lq5mr13096042pab.52.1423309852151; Sat, 07 Feb 2015 03:50:52 -0800 (PST) Return-Path: Received: from cvs.openbsd.org (cvs.openbsd.org. [199.185.137.3]) by mx.google.com with ESMTPS id bf1si13870894pbb.88.2015.02.07.03.50.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Feb 2015 03:50:51 -0800 (PST) Received-SPF: fail (google.com: domain of yasuoka@yasuoka.net does not designate 199.185.137.3 as permitted sender) client-ip=199.185.137.3; Authentication-Results: mx.google.com; spf=fail (google.com: domain of yasuoka@yasuoka.net does not designate 199.185.137.3 as permitted sender) smtp.mail=yasuoka@yasuoka.net Received: from shear.ucar.edu (lists.openbsd.org [192.43.244.163]); by cvs.openbsd.org (OpenSMTPD) with ESMTPS id 420e6a36; TLS version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=FAIL; Sat, 7 Feb 2015 04:50:48 -0700 (MST) Received: from mail.2ndsoft.com (s247156.ppp.asahi-net.or.jp [220.157.247.156]) by shear.ucar.edu (8.14.8/8.14.8) with ESMTP id t17C4n49020291; Sat, 7 Feb 2015 05:04:51 -0700 (MST) Received: from localhost (fe80::20c:29ff:fe63:1e7c [IPv6:fe80::20c:29ff:fe63:1e7c]); by mail.2ndsoft.com (OpenSMTPD) with ESMTP id bc987e21; Sat, 7 Feb 2015 20:50:43 +0900 (JST) Date: Sat, 07 Feb 2015 21:50:35 +1000 (AEST) Message-Id: <20150207.215035.62133998759773703.yasuoka@yasuoka.net> To: dlg@openbsd.org Cc: jmatthew@openbsd.org, jsg@openbsd.org, uebayasi@gmail.com Subject: Re: Fix mfi to set drive state (offline, rebuild..) properly From: YASUOKA Masahiko In-Reply-To: <74E2EB61-F36A-4E37-BE7E-CD869815721C@openbsd.org> References: <20141129.112041.2165587335602150376.yasuoka@yasuoka.net> <74E2EB61-F36A-4E37-BE7E-CD869815721C@openbsd.org> X-Mailer: Mew version 6.6 on Emacs 24.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Status: RO Content-Length: 5330 Lines: 154 On Thu, 4 Dec 2014 11:53:59 +1000 David Gwynne wrote: >> On 29 Nov 2014, at 12:20, YASUOKA Masahiko wrote: >> >> I'm using NEC Express5800 with its optional RAID contoller, but I >> could not set the drive state into rebuild or offline by bioctl(8). >> >> Tsubai found mfi(4) needs to be fixed to operate the firmware >> interface properly. >> >> I'd like to commit below diff from him. >> >> test? ok? > > i tried bioctl -O 1:1 sd0 on the following: > > mfi0 at pci7 dev 0 function 0 "Symbios Logic SAS1078" rev 0x04: apic 8 int 16 > mfi0: "PERC 6/i Integrated", firmware 6.3.3.0002, 256MB cache > scsibus1 at mfi0: 64 targets > sd0 at scsibus1 targ 0 lun 0: SCSI3 0/direct fixed naa.6001e4f019170b000f2142c304adc67a > sd0: 69376MB, 512 bytes/sector, 142082048 sectors > > $ sudo bioctl sd0 > Volume Status Size Device > mfi0 0 Online 72746008576 sd0 RAID1 WB > 0 Online 73407820800 1:0.0 noencl > 1 Online 73407820800 1:1.0 noencl > > with and without your diff i get the following on SETSTATE ops: > > dlg@discomfit ic$ sudo bioctl -O 1:0 sd0 > bioctl: BIOCSETSTATE: Invalid argument > > is my test wrong? If the diff is applied correctly, the test seems right. Tsubai also checked by the following device, mfi0 at pci1 dev 0 function 0 "Symbios Logic SAS1078" rev 0x04: apic 2 int 16 mfi0: "PERC 6/i Adapter", firmware 6.2.0-0013, 256MB cache bioctl -O, -R works fine, # bioctl sd0 Volume Status Size Device mfi0 0 Online 79456894976 sd0 RAID1 WT 0 Online 80000000000 0:0.0 noencl 1 Online 80000000000 0:1.0 noencl # bioctl -O 0:0 sd0 # bioctl sd0 Volume Status Size Device mfi0 0 Degraded 79456894976 sd0 RAID1 WT 0 Offline 80000000000 0:0.0 noencl 1 Online 80000000000 0:1.0 noencl # # bioctl -R 0:0 sd0 # bioctl sd0 Volume Status Size Device mfi0 0 Degraded 79456894976 sd0 RAID1 WT 0 Rebuild 80000000000 0:0.0 noencl 1 Online 80000000000 0:1.0 noencl # On NEC, test by yasuoka # bioctl sd0 Volume Status Size Device mfi0 0 Online 499558383616 sd0 RAID1 WT 0 Online 500107862016 1:0.0 noencl 1 Online 500107862016 1:1.0 noencl # bioctl -O 1:0 sd0 # bioctl sd0 Volume Status Size Device mfi0 0 Degraded 499558383616 sd0 RAID1 WT 0 Offline 500107862016 1:0.0 noencl 1 Online 500107862016 1:1.0 noencl # bioctl -R 1:0 sd0 # bioctl sd0 Volume Status Size Device mfi0 0 Degraded 499558383616 sd0 RAID1 WT 0 Rebuild 500107862016 1:0.0 noencl 1 Online 500107862016 1:1.0 noencl # Can you try the diff again? Index: sys/dev/ic/mfi.c =================================================================== RCS file: /disk/cvs/openbsd/src/sys/dev/ic/mfi.c,v retrieving revision 1.157 diff -u -p -r1.157 mfi.c --- sys/dev/ic/mfi.c 14 Sep 2014 14:17:24 -0000 1.157 +++ sys/dev/ic/mfi.c 29 Nov 2014 02:01:18 -0000 @@ -1900,6 +1900,7 @@ int mfi_ioctl_setstate(struct mfi_softc *sc, struct bioc_setstate *bs) { struct mfi_pd_list *pd; + struct mfi_pd_details *info; int i, found, rv = EINVAL; uint8_t mbox[MFI_MBOX_SIZE]; @@ -1907,6 +1908,7 @@ mfi_ioctl_setstate(struct mfi_softc *sc, bs->bs_status); pd = malloc(sizeof(*pd), M_DEVBUF, M_WAITOK); + info = malloc(sizeof *info, M_DEVBUF, M_WAITOK); if (mfi_mgmt(sc, MR_DCMD_PD_GET_LIST, MFI_DATA_IN, sizeof(*pd), pd, NULL)) @@ -1925,23 +1927,30 @@ mfi_ioctl_setstate(struct mfi_softc *sc, memset(mbox, 0, sizeof mbox); *((uint16_t *)&mbox) = pd->mpl_address[i].mpa_pd_id; + if (mfi_mgmt(sc, MR_DCMD_PD_GET_INFO, MFI_DATA_IN, + sizeof *info, info, mbox)) + goto done; + + *((uint16_t *)&mbox[0]) = pd->mpl_address[i].mpa_pd_id; + *((uint16_t *)&mbox[2]) = info->mpd_pd.mfp_seq; switch (bs->bs_status) { case BIOC_SSONLINE: - mbox[2] = MFI_PD_ONLINE; + mbox[4] = MFI_PD_ONLINE; break; case BIOC_SSOFFLINE: - mbox[2] = MFI_PD_OFFLINE; + mbox[4] = MFI_PD_OFFLINE; break; case BIOC_SSHOTSPARE: - mbox[2] = MFI_PD_HOTSPARE; + mbox[4] = MFI_PD_HOTSPARE; break; -/* + case BIOC_SSREBUILD: + mbox[4] = MFI_PD_REBUILD; break; -*/ + default: DNPRINTF(MFI_D_IOCTL, "%s: mfi_ioctl_setstate invalid " "opcode %x\n", DEVNAME(sc), bs->bs_status); @@ -1955,6 +1964,7 @@ mfi_ioctl_setstate(struct mfi_softc *sc, rv = 0; done: free(pd, M_DEVBUF, 0); + free(info, M_DEVBUF, 0); return (rv); }