From nobody@FreeBSD.org  Thu Nov 18 14:05:51 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B8CCD16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Nov 2004 14:05:51 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A901643D5E
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Nov 2004 14:05:51 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id iAIE5pmY053345
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 18 Nov 2004 14:05:51 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id iAIE5pqa053338;
	Thu, 18 Nov 2004 14:05:51 GMT
	(envelope-from nobody)
Message-Id: <200411181405.iAIE5pqa053338@www.freebsd.org>
Date: Thu, 18 Nov 2004 14:05:51 GMT
From: Arne Wrner <arne_woerner@yahoo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: hw.ata.wc=0 / but write cache still enabled
X-Send-Pr-Version: www-2.3

>Number:         74074
>Category:       i386
>Synopsis:       hw.ata.wc=0 / but write cache still enabled
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-i386
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 18 14:10:27 GMT 2004
>Closed-Date:    Thu Jan 05 00:29:16 GMT 2006
>Last-Modified:  Thu Jan 05 00:29:16 GMT 2006
>Originator:     Arne Wrner
>Release:        R5.3
>Organization:
>Environment:
FreeBSD neo.riddick.homeunix.org. 5.3-RELEASE FreeBSD 5.3-RELEASE #0: Thu Nov 11 17:27:53 UTC 2004     aw@neo.riddick.homeunix.org.:/usr/obj/usr/src/sys/RIDDICK  i386
>Description:
I wanted to turn of ATA disc write caching (by setting hw.ata.wc to zero):
but after a boot after power on atacontrol cap 0 0 still says, that the write cache feature is enabled:
       write cache                    yes      yes
while sysctl says, that hw.ata.wc is 0:
       # sysctl hw.ata.wc
       hw.ata.wc: 0

I think this is a bug, that can be security relevant in the case of a power failure or system crash (at least if one is using a filesystem with soft updates enabled).

After a reboot (warm) the write cache is sometimes disabled but sometimes enabled... :-(

>How-To-Repeat:
1. shutdown the box
2. turn off power
3. turn on power
4. look at hw.ata.wc
5. look ata atacontrol's output
>Fix:
      
>Release-Note:
>Audit-Trail:

From: =?utf-8?B?QmrDtnJuIEvDtm5pZw==?= <bkoenig@cs.tu-berlin.de>
To: <freebsd-gnats-submit@freebsd.org>
Cc: =?utf-8?Q?'Arne_W=C3=B6rner'?= <arne_woerner@yahoo.com>
Subject: RE: i386/74074: hw.ata.wc=0 / but write cache still enabled
Date: Mon, 29 Nov 2004 11:24:18 +0100

 Please tell more information about your hardware, i.e. controller and =
 hard disk.
 
 Regards Bjoern
 

From: Arne "Wrner" <arne_woerner@yahoo.com>
To: freebsd-gnats-submit@freebsd.org
Cc: "Bjrn" "Knig" <bkoenig@cs.tu-berlin.de>
Subject: RE: i386/74074: hw.ata.wc=0 / but write cache still enabled
Date: Mon, 29 Nov 2004 02:39:16 -0800 (PST)

 > Please tell more information about your hardware, i.e. controller and hard
 > disk.
 >
 ok. Let me know, if you need more information.
 
 from /var/log/messages (boot message):
 Nov 29 07:15:02 neo kernel: atapci0: <VIA 8235 UDMA133 controller> port
 0xfc00-0xfc0f,0x376,0x170-0x177,0x3f6,0x1f0-0x1f7 at device 17.1 on pci0
 Nov 29 07:15:02 neo kernel: ata0: channel #0 on atapci0
 Nov 29 07:15:02 neo kernel: ata1: channel #1 on atapci0
 Nov 29 07:15:02 neo kernel: ad0: 38166MB <ST340015A/3.01> [77545/16/63] at
 ata0-master UDMA100
 Nov 29 07:15:02 neo kernel: ad1: 152627MB <SAMSUNG SP1604N/TM100-24>
 [310101/16/63] at ata0-slave UDMA100
 Nov 29 07:15:02 neo kernel: acd0: DVDR <TOSHIBA DVD-ROM SD-R5112/1033> at
 ata1-master UDMA33
 Nov 29 07:15:02 neo kernel: acd1: CDROM <LTN526/YH0X> at ata1-slave UDMA33
 Nov 29 07:15:02 neo kernel: cd0 at ata1 bus 0 target 0 lun 0
 Nov 29 07:15:02 neo kernel: cd1 at ata1 bus 0 target 1 lun 0
 
 
 from atacontrol:
 neo# atacontrol cap 0 0
 ATA channel 0, Master, device ad0:
 
 Protocol              ATA/ATAPI revision 6
 device model          ST340015A
 serial number         5LA0T604
 firmware revision     3.01
 cylinders             16383
 heads                 16
 sectors/track         63
 lba supported         78165360 sectors
 lba48 not supported       
 dma supported
 overlap not supported
 
 Feature                      Support  Enable    Value   Vendor
 write cache                    yes      yes
 read ahead                     yes      yes
 dma queued                     no       no      0/0x00
 SMART                          yes      yes
 microcode download             yes      yes
 security                       yes      no
 power management               yes      yes
 advanced power management      no       no      0/0x00
 automatic acoustic management  no       no      128/0x80        128/0x80
 
 
 neo# atacontrol cap 0 1
 ATA channel 0, Slave, device ad1:
 
 Protocol              ATA/ATAPI revision 7
 device model          SAMSUNG SP1604N
 serial number         S013J10X766520
 firmware revision     TM100-24
 cylinders             16383
 heads                 16
 sectors/track         63
 lba supported         268435455 sectors
 lba48 supported       312581808 sectors
 dma supported
 overlap not supported
 
 Feature                      Support  Enable    Value   Vendor
 write cache                    yes      yes
 read ahead                     yes      yes
 dma queued                     no       no      0/0x00
 SMART                          yes      yes
 microcode download             yes      yes
 security                       yes      no
 power management               yes      yes
 advanced power management      no       no      0/0x00
 automatic acoustic management  yes      yes     254/0xFE        254/0xFE
 
 neo# sysctl hw.ata.wc
 hw.ata.wc: 0
 
 
 
 		
 __________________________________ 
 Do you Yahoo!? 
 Yahoo! Mail - Helps protect you from nasty viruses. 
 http://promotions.yahoo.com/new_mail

From: Arne "Wrner" <arne_woerner@yahoo.com>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: RE: i386/74074: hw.ata.wc=0 / but write cache still enabled
Date: Mon, 29 Nov 2004 04:38:37 -0800 (PST)

 --- Bjrn Knig <bkoenig@cs.tu-berlin.de> wrote:
 > Perform a small benchmark, e.g. with /usr/ports/benchmark/bonnie (bonnie -d
 > /usr -s <twice as much as your RAM>). Perhaps the write cache is turned off,
 > but it's not shown correctly. If your write transfer rates around 10 MB/s
 > then the write cache might be disabled. Show the complete result and tell
 > also your CPU model.
 > 
 I use an AMD Athlon(tm) XP 2400+ (2000MHz).
 
 Here are bonnie's results:
 
 AFTER my "dd if=/dev/ad1 bs=512k count=1000 of=/dev/null"-trick (somehow this
 trick seems to 
 change the write speed dramatically (factor 5; /opt/tmp is on /dev/ad1))
 WITH hw.ata.wc=0:
 neo# bonnie -d /opt/tmp -s 1024 -m Athlon2400
               -------Sequential Output-------- ---Sequential Input-- --Random--
               -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
 Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
 Athlon24 1024 47464 55.1 46720 24.9 17561  9.7 44685 56.0 43861 26.5 146.4  2.8
 
 WITHOUT the "trick"
 AFTER a fresh boot
 WITH hw.ata.wc=1:
 neo# bonnie -d /opt/tmp -s 1024 -m Athlon2400
               -------Sequential Output-------- ---Sequential Input-- --Random--
               -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
 Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
 Athlon24 1024  6540  7.3 47957 23.9 15591 11.6 46357 57.1 44280 23.3 142.4  3.6
 
 AFTER previous test
 WITH hw.ata.wc=1:
               -------Sequential Output-------- ---Sequential Input-- --Random--
               -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
 Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
 Athlon24 1024 46270 57.7 47708 24.4 17995  9.5 44864 55.5 43965 23.5 150.2  2.2
 
 
 AFTER fresh boot
 WITHOUT trick
 WITH hw.ata.wc=0
               -------Sequential Output-------- ---Sequential Input-- --Random--
               -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
 Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
 Athlon24 1024  6570 14.4 47726 24.0 15634 13.7 46413 57.1 43569 15.5 155.6  1.2
 
 AFTER previous test
 WITH hw.ata.wc=0
               -------Sequential Output-------- ---Sequential Input-- --Random--
               -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
 Machine    MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU  /sec %CPU
 Athlon24 1024 48619 54.4 46796 37.1 15268 19.7 45892 59.7 44151 16.0 159.8  1.2
 
 
 -Arne
 
 
 
 
 
 	
 		
 __________________________________ 
 Do you Yahoo!? 
 Yahoo! Mail - You care about security. So do we. 
 http://promotions.yahoo.com/new_mail
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Thu Jan 5 00:27:51 UTC 2006 
State-Changed-Why:  
The atacontrol cap settings was not updated in the kernel. fixed in -current. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74074 
>Unformatted:
