4
\$\begingroup\$

Is there a hard drive (protocol command, specific model, etc.) that, while writing new data over old data, it "read"/return the old data back to the controller/OS? (Analogous to a simultaneous read-write).

I've been looking up SATA/hard drisk protocol(s) in search of something that meets the criteria, but it's quite possible that I lack the vocabulary to search properly.

The closest I've found is an ATAPI command for Read-after-write - which resembles the opposite of what I'm looking for. I want to "read-just-before-write" or "read-as-i-write".

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Read-after-write is good for verifying the data. \$\endgroup\$ Commented Aug 7, 2012 at 19:22

6 Answers 6

6
\$\begingroup\$

I wouldn't expect that such a feature could be implemented in a fashion that would be more efficient than simply alternating read and write commands. If the drive has efficient buffering, the drive would likely respond to the first "read-sector" request by reading into a buffer the entire track containing that sector (the request would be reported as successful as soon as the requested sector was read, but the balance of the track would be available to honor future requests). The drive would buffer the write request and report it as having completed immediately. When the drive receives the request to read the second sector, the drive would either have finished reading the entire track or be in the process of doing so. It would then buffer the second write request and report that as completed. Depending upon the exact way the drive's buffering works, and the timing interactions between the drive and the host, the drive may or may not achieve the highest theoretically possible speed, but it should probably come pretty close. I don't see how using a "read then write" command would be better than using separate "read" and "write" commands, since the drive would not be able to physically write a sector to disk until significantly after it was read.

\$\endgroup\$
0
5
\$\begingroup\$

It is impossible to read and write simultaneously. Writing is performed using differential current sink into the same centre-tapped magnetic head coil. A Write Enable(-) logic signal disables the read path by design. Read Modify Write is an Application layer possibility not supported by default in the Command set.

However this is something that is performed within Flash drive emulation. Each OS may differ in implementation of Read Modify Write (RMW)

For example in Solaris, ZFS random write, 4K-aligned fs block size test shows 230x improvement compared to running RMW in f/w.

\$\endgroup\$
4
\$\begingroup\$

Usually if you write new data it means you don't need the old data any longer, therefore there's no command which does this for you. If you still need the old data you'll have to perform a separate read of it before overwriting it with the new data.

\$\endgroup\$
2
\$\begingroup\$

The ATAPI, SATA, and SCSI command sets do not support a single read then write command. You will have to write software that performs a read then a write in sequence to get the same effect.

If you tell us more about your application and what problem this feature would help solve, we might be able to help you solve your problem despite this feature not being present in the hardware you are trying to use.

\$\endgroup\$
2
\$\begingroup\$

One further point: the tracks are so small and the arm carrying the head follows a circular path so the read head is often over a different track to the write head. Thus reading any given track just before writing it is impossible without waiting for many disc revolutions and head movements.

\$\endgroup\$
1
\$\begingroup\$

As far as I understand you probably want the old data to be read before being overwritten... So its better to put a round robin scheduling while writing the data, where first a read operation is executed over the segment and soon the segment is overwritten.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.