# Slow SATA

## Trejkaz

So I needed more disk space, and I was out of space on IDE so I had to move to SATA.  The new drive is a Western Digital 300GB drive with 8MB cache (model number WDC WD3000JD-00KLB0 .)

Things initially looked pretty happy:

```
raven ~ # hdparm -tT /dev/sda

/dev/sda:

 Timing cached reads:   1332 MB in  2.00 seconds = 665.96 MB/sec

 Timing buffered disk reads:  156 MB in  3.02 seconds =  51.65 MB/sec

```

However, writes are another story.  The best speed I can get on a real file copy is about 10MB/sec, but typically the speed sits at around 6MB/sec and doesn't budge.

My best guess would have to be that DMA isn't enabled because hdparm can't do it, but a cursory search of Google brings up several opinions that DMA should be on by default.  I can't instantly find any solutions on these forums, either... though a few questions, certainly.

Edited to add some more diagnostics:

I already hunted through the kernel source to see if this drive was on the blacklist and I couldn't find it there.  DMA does indeed seem to be on.

```
raven ~ # hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media

        Model Number:       WDC WD3000JD-00KLB0

        Serial Number:      WD-WMAMR1660299

        Firmware Revision:  08.05J08

Standards:

        Supported: 6 5 4 3

        Likely used: 6

Configuration:

        Logical         max     current

        cylinders       16383   16383

        heads           16      16

        sectors/track   63      63

        --

        CHS current addressable sectors:   16514064

        LBA    user addressable sectors:  268435455

        LBA48  user addressable sectors:  586072368

        device size with M = 1024*1024:      286168 MBytes

        device size with M = 1000*1000:      300069 MBytes (300 GB)

Capabilities:

        LBA, IORDY(can be disabled)

        bytes avail on r/w long: 4      Queue depth: 1

        Standby timer values: spec'd by Standard, with device specific minimum

        R/W multiple sector transfer: Max = 16  Current = 16

        Recommended acoustic management value: 128, current value: 254

        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5

             Cycle time: min=120ns recommended=120ns

        PIO: pio0 pio1 pio2 pio3 pio4

             Cycle time: no flow control=120ns  IORDY flow control=120ns

Commands/features:

        Enabled Supported:

           *    READ BUFFER cmd

           *    WRITE BUFFER cmd

           *    Host Protected Area feature set

           *    Look-ahead

           *    Write cache

           *    Power Management feature set

                Security Mode feature set

           *    SMART feature set

           *    FLUSH CACHE EXT command

           *    Mandatory FLUSH CACHE command

           *    Device Configuration Overlay feature set

           *    48-bit Address feature set

                Automatic Acoustic Management feature set

                SET MAX security extension

           *    DOWNLOAD MICROCODE cmd

           *    SMART self-test

           *    SMART error logging

Security:

        Master password revision code = 65534

                supported

        not     enabled

        not     locked

        not     frozen

        not     expired: security count

        not     supported: enhanced erase

Checksum: correct

```

----------

## NeddySeagoon

Trejkaz,

A few things.  DMA is on on SATA by default. You can't get 50Mb/sec reads any other way.

hdparm does not work on SATA drives. libsata needs command pass through, which is only just comming.

The speed test, is a read and throw the data away. A copy is read from one place and write to another.

How fast can you read from the copy source?

If the source is CD, then 6Mb/sec is 40x CD, so its likely the CD read speed thats the limit, if its IDE HDD, is DMA on there?

You could also have a SATA drive and chipset pair thats blacklisted becase of hardware/firmware bugs. Some speed features get turned off to prevent data corruption. What SATA chipset do you have.

----------

## Trejkaz

A speed test on the drive it's copying from:

```
raven ~ # hdparm -tT /dev/hda

/dev/hda:

 Timing cached reads:   1188 MB in  2.00 seconds = 592.78 MB/sec

 Timing buffered disk reads:   42 MB in  3.32 seconds =  12.67 MB/sec

```

As a real life benchmark, I copied one of the large files on the SATA drive back to the original PATA drive the file was on.  This gives around 30MB/s.

The SATA controller in question is the VIA VT6420.

----------

## NeddySeagoon

Trejkaz,

12 Mb/sec is slow for a modern IDE drive.

What does

```
hdparm /dev/hda
```

return?

SATA to SATA copy at 30Mb/sec looks OK. Thats 30Mb/sec reading and 30 MB/sec writing. Since you get 50MB/sec in the speed test, it looks OK

----------

## Trejkaz

```
raven ~ # hdparm /dev/hda

/dev/hda:

 multcount    = 16 (on)

 IO_support   =  1 (32-bit)

 unmaskirq    =  1 (on)

 using_dma    =  1 (on)

 keepsettings =  0 (off)

 readonly     =  0 (off)

 readahead    = 256 (on)

 geometry     = 16383/255/63, sectors = 120034123776, start = 0

```

But this drive has been performing more than adequately in the past (and my tests showed 30MB/s *writing* to this drive.)

I just tested copying a file to itself on the old drive and got around 20MB/s, which is slow but not as unbearable.  Maybe this is just some quirky issue I have which only exhibits itself when copying from the old drive to the new drive.

----------

## NeddySeagoon

Trejkaz,

Those settings look good for your IDE drive.

The speed that /hdparm -tT /dev/...  returns de[ends on what else is accessing the drive.

It does not get exclusive use while the test runs.

----------

## femtotech

I'm having a bit of a problem also.  I just performed a fresh 2005.1 install and I'm getting quite slow disk rates:

hdparm -t /dev/hda /dev/hdb /dev/sda /dev/sdb

/dev/hda:

 Timing buffered disk reads:   94 MB in  3.05 seconds =  30.85 MB/sec

/dev/hdb:

 Timing buffered disk reads:   82 MB in  3.00 seconds =  27.31 MB/sec

/dev/sda:

 Timing buffered disk reads:   88 MB in  3.02 seconds =  29.11 MB/sec

HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl for device

/dev/sdb:

 Timing buffered disk reads:   88 MB in  3.07 seconds =  28.63 MB/sec

HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate ioctl for device

The IDE drives are WD 160GB 8MB 7200k drives and the SATA are WD Raptor 10k drives on the nforce 4's nvsata chip.  I'm running the 2.6.14-archck-r1 kernel on an AMD64 SMP system.  Any ideas?

Thanks!

----------

## Trejkaz

Search the forums, I've seen a few solutions for the problem where the test itself shows slow reads.

----------

## femtotech

I just wanted to post what I found for anyone else having this issue.

First, I emerged -e system and world to get rid of -ffast-math CFLAG, and then I compiled the 2.6.14-archck-r5 kernel (I was running archck-r1).  At first, it looked like of my problems were solved as I was getting around 45MB/s on my IDE drives and 69MB/s one my SATA.  However, after testing hdparm a few more times the results aren't constant:

/dev/sdb:

 Timing buffered disk reads:  142 MB in  3.02 seconds =  47.03 MB/sec

/dev/sdb:

 Timing buffered disk reads:  204 MB in  3.01 seconds =  67.83 MB/sec

/dev/sdb:

 Timing buffered disk reads:  166 MB in  3.00 seconds =  55.25 MB/sec

/dev/hda:

 Timing buffered disk reads:   78 MB in  3.07 seconds =  25.39 MB/sec

So now I have a feeling that it's the AMD64 timing issue and that the 3 seconds it's using for that calculation is not really 3 seconds.  Anyway, if I get it totally ironed out I'll post that here also.

----------

## #pfo

 *femtotech wrote:*   

> I just wanted to post what I found for anyone else having this issue.
> 
> First, I emerged -e system and world to get rid of -ffast-math CFLAG, and then I compiled the 2.6.14-archck-r5 kernel (I was running archck-r1).  At first, it looked like of my problems were solved as I was getting around 45MB/s on my IDE drives and 69MB/s one my SATA.  However, after testing hdparm a few more times the results aren't constant:
> 
> /dev/sdb:
> ...

 

My Raptor brings in to 72MB/s (nearly constant!).

----------

