Managing RAID on Linux - Derek Vadala [126]
16.7
64
udma1
25
65
udma2
33.3
66
udma3
44.4
67
udma4
66.7
68
udma5
100
69
You generally want to use the fastest mode available. The asterisk next to udma4 indicates that UltraATA/66 is currently selected. To change the transfer mode from udma4 to udma5, use the following command:
# hdparm -d1 -X69 /dev/hda
/dev/hda:
setting xfermode to 69 (UltraDMA mode5)
The -X option uses a somewhat confusing syntax, so I've included Table 7-2 as an easy reference for all the integer and mode correlations. Each data transfer mode has a base numeric value: PIO (8), multi-word DMA (32), and UltraDMA (64). Single-word DMA is not used, because multi-word DMA has replaced it. (hdparm will allow the use of the base value 16 for single-word DMA, but I have not successfully used it, and it is undocumented.) To determine the correct value for the -X option, add a mode's base numeric value to the specific transfer mode within that particular type. For example, udma4 uses the numeric value 68 because the base value for UltraDMA (64) and the value for udma4 (4) equal 68.
The -d1 option ensures that DMA mode is enabled. Even though I just set my disk to UltraDMA mode 5, generic support for DMA is also required. Otherwise, the disk will operate in its default, archaic PIO mode. If you look back at the hdparm /dev/hda output that I showed earlier in the section Tuning ATA Disks with hdparm, you'll notice that using_dma was already turned on. So I wasn't required to include it again with this command. However, I find that it's good practice to combine the -d and -X commands to be certain the transfer mode is properly set.
Most new disks ship with the best (fastest) mode enabled, but it's always a good idea to double-check. A lot of older disks typically shipped with PIO as their default transfer mode, even though they were capable of some level of DMA functionality. Therefore, it's especially recommended that you check the transfer mode if you are working with older disks.
32-bit I/O support
32-bit I/O describes the amount of data per cycle (remember my coverage of bus-width and bus-speed in Chapter 2) that the ATA controller sends over the data bus. It might seem obvious that hard disks should ship with 32-bit support enabled, but this isn't the case at all. I've found that while most manufacturers now have the good sense to enable the best transfer mode, few of them actually ship drives with 32-bit mode activated. If you look at the drive parameters I listed earlier in the section Tuning ATA Disks with hdparm, you'll see that my Ultra ATA/100 disk was actually set to use 16-bit I/O:
I/O support = 0 (default 16-bit)
Add the -c option to hdparm to enable 32-bit I/O:
# hdparm -c3 /dev/hda
/dev/hda:
setting 32-bit I/O support flag to 3
I/O support = 3 (32-bit w/sync)
I've used I/O mode 3, which supports 32-bit data transfers and also implements a synchronization sequence that provides computability with the largest number of ATA controllers. Using mode 2 (hdparm -c2 /dev/hda) also enables 32-bit transfers, but doesn't provide the extra synchronization steps. This improves performance a little bit, but sacrifices some computability. If you do try using mode 2, please do adequate testing before putting the system into production. Use hdparm -c0 /dev/hda if you need to set the disk back into 16-bit mode.
Increasing multiple sector I/O
Multiple sector I/O (also called Block Mode IDE) allows the system to read/write more than one sector per interrupt. This tremendously increases the overall throughput of ATA disks and greatly reduces the CPU overhead required to perform I/O on ATA devices. My disk has a multiple sector I/O value of 16, as indicated by multcount = 16 (on) in the hdparm output I showed earlier in this chapter. That means that I/O occurs in 8 KB chunks (16 * 512 bytes per sector = 8 KB). This is actually a reasonably decent default value and the maximum value my disk will allow. You'll notice that in the output of hdparm -i, there is a maximum multiple sector I/O listed:
BuffType=unknown, BuffSize=2048kB,