Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Darwin disk I/O question



Rob Braun <email@hidden> wrote:

After taking a recent EE course from a guy from Quantum, there is no
such thing as CHS anymore from the disk's perspective.

Of course there is such a thing -- there are still cylinders, heads and sectors, after all. The disk hides the structure, but it is still there.

The disk really
just makes those up and hands them to the OS/BIOS/Firmware as the normal
interface to the disk. The disk really just takes these and maps them
to it's internal structure that is almost always totally different.

In fact, CHS addressing on the interface has had no meaning for many years. This is not a new thing at all.

Most modern operating systems don't have to use CHS addressing, either. Modern IDE supports an alternate mode called LBA for Logical Block Addressing. In other words, it does just what SCSI has always done -- the disk is addressed as a linear array of blocks (sectors).

I'm pretty sure Macintosh systmes never use anything but LBA. Darwin on Intel might need to use CHS in some circumstances (I have no idea what they might be, but I'm guessing it might be needed sometimes to deal with silly legacy BIOS issues).

These days, the old CHS system is merely an interface to the disk that
bears no resemblance to reality. One should not try to optimize
disk requests on the assumption that these things match the physical
layout of the disk. It is far better to just barrage the disk with
requests and let it sort them out.

I believe the current disk queue is not sorted with respect to data
location, or with respect to the process' priority.

Then it is wrong, and should be fixed. Elevator sorting is still good for the following reasons:

1. The disks may be somewhat limited in the scope of their reordering. They typically do not allow an extremely large number of outstanding requests.

2. IDE cannot be relied upon to do this right, if at all. SCSI has been able to for a long time, due to widespread support in both host adapters and drives for the key features: disconnect/reconnect and tagged command queueing (TCQ). Unlike SCSI, up until relatively recently there was no support at all for TCQ in IDE. There is now, but it is implemented in few drives. Plus, from what I hear the implementation requires the low level driver to *poll* each drive's command queue to find out when a command completes, because there still is no real disconnect/reconnect capability. If that doesn't make your skin crawl...

3. A lack of direct knowledge about the disk layout doesn't imply that you cannot rely on locality. The mapping between linear addresses and disk block locations is not chosen randomly. Even though you might not know exactly how the logical block address gets translated, you do know that the real physical distance between two logical block addresses is proportional to the difference of the addresses. So elevator seeking still has value.

It is of course necessary to use an elevator algorithm which never attempts to sort requests in descending order, since you do need to know actual disk layout to do that without destroying performance.

Tim Seufert




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.