An intelligent write command routine improves the operational efficiency
of a data storage device (DSD) by avoiding media access of the disk when
a logical block address (LBA) and the physical sector are unaligned, thus
reducing write time. When a write command is received by the DSD from the
host, the intelligent write command routine maintains the read data of
the read buffer, instead of clearing the read buffer and performing a
read of the target sector on the disk per standard protocol. The
intelligent write command copies the necessary adjacent sector data from
the read buffer as a data patch to the write buffer to splice around the
write data received with the write command. Following each write command,
the data written to the disk in the write buffer is copied to the read
buffer. The read buffer is maintained with the most current data on the
disk and does not need to be flushed unless the LBA of the write command
is beyond the data ranges stored in the read buffer.