In a disk drive having an intelligent interface for communicating with a host, a magnetic disk, host side programs, disk side programs, and a cache wherein the cache is divisible into a number of segments wherein the number of segments may be varied, wherein the cache employs a cache control structure including a cache entry table, a buffer counter, a host pointer and a disk pointer, a method for processing commands from the host comprising:
- (a) receiving a plurality of commands from the host including a read command;
- (b) selecting the read command from the plurality of commands;
- (c) initializing a task control block data structure for the read command;
- (d) deciding whether to scan the cache first or start a seek first;
- (e) if scanning the cache first, performing a scan of the cache entry table to assign a cache segment to the read command to determine a full cache hit or a partial cache hit by checking whether data requested in the read command is in the cache, obtaining the disk pointer if there was not a full cache hit, starting a seek if there was no cache hit, computing a prefetch if there was not a full cache hit, setting the buffer counter and starting the disk side programs if there was not a full cache hit, setting the host pointer and starting the host side programs, and setting the cache control structure to a state that represents a condition the cache will be in after the read command has completed;
- and
- (f) if starting a seek first, obtaining the disk pointer, starting a seek, adjusting a size of each segment and number of segments in the cache to adapt to commands being processed, performing a scan of the cache entry table to assign a cache segment to the read command to determine a full cache hit or a partial cache hit by checking whether data requested in the read command is in the cache, performing a seek if there was a partial cache hit, computing a prefetch for the read command if there was not a full cache hit, setting the buffer counter and starting a read of the magnetic disk if there was not a full cache hit, setting the host pointer and starting the host, and setting the cache control structure to a state that represents a condition the cache will be in after the read command has completed.