Re: atacontrol not reflecting disabled write cache (or rogue hdd?)

From: John Polstra <jdp_at_polstra.com>
Date: Tue, 13 May 2003 16:57:56 -0700 (PDT)
In article <200304240156.25990.michaelnottebrock_at_gmx.net>,
Michael Nottebrock  <michaelnottebrock_at_gmx.net> wrote:
> 
> I've recently changed hw.ata.wc to 0 (via loader.conf.local) on two systems=
> =20
> and on both systems atacontrol cap still says write cache supported & enabl=
> ed=20
> (sysctl confirms the setting being 0). One system is 5.0-RELEASE, the other=
> =20
> 4.8-RC.
> 
> Is atacontrol lying or do the drives insist on write caching?

Atacontrol is lying.  I sent Soren a patch that fixes it a few days
ago (see below).  The driver is getting the status information from
the drives before it has actually attached them and turned off write
caching.  The driver keeps that stale information and returns it
when atacontrol asks for it.  If you use "atacontrol reinit" on the
appropriate channel, it will cause the drive status to be re-fetched
and you'll then see that write caching is in fact turned off.

I'll append my patch below.  Be advised that it probably needs some
tweaking by Soren before it's really 100% correct.  The patch is
relative to -stable.

John

Index: ata-all.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/ata-all.c,v
retrieving revision 1.50.2.45
diff -u -r1.50.2.45 ata-all.c
--- ata-all.c	12 Mar 2003 14:47:12 -0000	1.50.2.45
+++ ata-all.c	11 May 2003 17:51:24 -0000
_at__at_ -506,6 +506,8 _at__at_
     bswap(ata_parm->serial, sizeof(ata_parm->serial));
     btrim(ata_parm->serial, sizeof(ata_parm->serial));
     bpack(ata_parm->serial, ata_parm->serial, sizeof(ata_parm->serial));
+    if (atadev->param != NULL)
+	free(atadev->param, M_ATA);
     atadev->param = ata_parm;
     return 0;
 }
_at__at_ -550,10 +552,14 _at__at_
     for (ctlr=0; ctlr<devclass_get_maxunit(ata_devclass); ctlr++) {
 	if (!(ch = devclass_get_softc(ata_devclass, ctlr)))
 	    continue;
-	if (ch->devices & ATA_ATA_MASTER)
+	if (ch->devices & ATA_ATA_MASTER) {
 	    ad_attach(&ch->device[MASTER]);
-	if (ch->devices & ATA_ATA_SLAVE)
+	    ata_getparam(&ch->device[MASTER], ATA_C_ATA_IDENTIFY);
+	}
+	if (ch->devices & ATA_ATA_SLAVE) {
 	    ad_attach(&ch->device[SLAVE]);
+	    ata_getparam(&ch->device[SLAVE], ATA_C_ATA_IDENTIFY);
+	}
     }
     ata_raid_attach();
 #endif
Received on Tue May 13 2003 - 14:58:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:07 UTC