Method of assuring data write integrity on a data storage device
FIELD OF THE INVENTION 
     This invention relates to computer systems and more particularly, to data storage systems. 
     BACKGROUND OF THE INVENTION 
     Data storage devices such as disk drives are generally considered acceptable and usable even though they include one or more defective data storage locations. Such defective data storage locations, normally referred to as defective blocks, are usually identified during a disk format operation, wherein the defective blocks are identified and set aside not to be utilized, and an index or pointer is provided to the next good block of data storage locations. 
     A problem arises, however, when one or more data storage locations within a good block become defective after disk formatting. Most importantly, this problem will not manifest itself until a data read operation is attempted. At that time, the corrupt data is discovered, and generally, the uncorrupted data is irretrievably lost. 
     SUMMARY OF THE INVENTION 
     Accordingly, the present invention features a method for assuring integrity of data written to a data storage medium and includes the steps of receiving a quantity of data to be written to a storage device and storing the data in at least one temporary memory storage medium. The data is then written to at least one data storage device while the data is also retained in at least one temporary memory storage medium. 
     The same data, an error checking and correction (ECC) code generated from the data, or other chosen criteria is then read from the data storage device and compared to the data stored in the memory storage medium or to the data&#39;s error checking and correction code. If the data or the ECC code previously written and now read from the data storage device is equivalent to the data&#39;s ECC code or to the data stored in the temporary memory storage medium, the system returns to the step of receiving new data to be written to a storage device thus assuring data write integrity. 
     If the data, data ECC code, or other chosen criteria read from the data storage device is not equivalent to the corresponding original data, ECC code, or chosen criteria which was stored in the temporary memory storage medium, the method determines that at least one selected storage location on the data storage device is defective and writes the data to a new storage location on the at least one data storage device. Alternatively, the method may attempt to re-write the data to the same data storage locations. Subsequently, the method of the present invention returns to the step of reading the data written to the data storage device and comparing the data which has been read with the data or the data&#39;s ECC code stored in the temporary memory storage medium. 
    
    
     DESCRIPTION OF THE DRAWINGS 
     These, and other features of the present invention will be better understood by reading the following detailed description taken together with the drawings wherein: 
     FIG. 1 is a flow chart illustrating the method for assuring data integrity after writing data to a data storage device; and 
     FIG. 2 is a schematic block diagram of an exemplary system for performing the method of the present invention. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The method of assuring data write integrity is illustrated in conjunction with flow chart 10, FIG. 1, wherein at step 12, the method includes receiving data which is to be written to a data storage device. The data may be received directly from a host computer or other communication device, or may be received from a host interface and controller as described in greater detail in Applicants&#39;co-pending U.S. patent application Ser. No. 07/587,253, entitled &#34;Reconfigurable, Multi-Function Disk Controller&#34; incorporated herein by reference. After the data is received, the data is stored in a memory storage medium such as a high-speed semiconductor memory commonly referred to as cache memory. 
     After the data has been received and stored in a temporary memory storage medium, the method of the present invention proceeds to write the data to the data storage device, step 14. The data that has just been written to disk is retained in at least one memory storage medium for possible future use. In a preferred embodiment, the data which awaits writing to the data storage device is retained in the high-speed semiconductor cache memory along with an associated indicator, referred to as a write pending indicator. Such a system for storing data along with an associated write pending indicator is described in greater detail in Applicants&#39; co-pending U.S. patent application Ser. No. 07/586,254, entitled &#34;Disk Storage System With Write Preservation During Power Failure&#34; which is incorporated herein by reference. 
     Alternatively, the data may be retained within the storage device itself such as a small temporary semiconductor memory buffer within the data storage device. Additionally, the storage device controller or the storage device itself may compute an error checking and correction (ECC) code associated with each block of data. Thus, a feature of the present invention is that the data is retained in the temporary storage buffer after being written to disk until the integrity of the data which has been written to disk is verified by performing a subsequent read and compare operation with a chosen criteria as will be described below. 
     In the preferred embodiment, the data storage device includes a rotating data storage device such as a disk drive, CD-ROM or optical disk. Additionally, each rotating data storage device may have a backup or &#34;mirror&#34; device which generally contains substantially the same information as the &#34;primary&#34; data storage device, although the &#34;primary&#34; and &#34;mirror&#34; devices may be rotationally out of phase with each other. 
     In such an embodiment, the method of the present invention then proceeds to compute data access times for accessing the data which has just been previously written to both the &#34;primary&#34; data storage device and the &#34;mirror&#34; data storage device, step 16. Since the two rotational data storage device are out of phase with one another, one of the &#34;primary&#34; or &#34;mirror&#34; data storage devices will have an access time which is shorter than the other. Accordingly, the data will be read from the data storage device with the shortest computed access time, step 18. Such a system utilizing a &#34;primary&#34; and &#34;mirror&#34; rotating data storage medium with computed shortest data access time is described in greater detail in Applicants&#39; co-pending U.S. patent application Ser. No. 07/587,026, entitled &#34;Disk Storage System With Data Mirroring and Reduced Access Time Data Retrieval&#34; which is incorporated herein by reference. 
     In one embodiment utilizing both &#34;primary&#34; and &#34;mirror&#34; data storage devices which have both been updated, the system may direct the &#34;primary&#34; and &#34;mirror&#34; device to perform a data comparison among one another on one or more blocks of data. Utilizing this method frees up the system data bus for other data transfers. If an error is detected, either the &#34;primary&#34; or &#34;mirror&#34; disk reports the error to the system. Since the original data is still stored in the temporary memory storage medium, the data is available to be re-written to either the &#34;primary&#34; or the &#34;mirror&#34; storage device as necessary. 
     After the data which has been previously written is read from the data storage device, the method of the present invention next proceeds to compare the data which has been read to the same data which was previously retained in at least one temporary memory storage medium, step 20. If the data which has just been read is equivalent to the data which was retained in the temporary memory storage medium, no error is encountered as shown in step 22. If, as previously described with regard to the preferred embodiment, the data was stored in the temporary memory storage medium with a write pending indicator, the method of the present invention next clears or resets this write pending indicator now that the data has been written to disk and its integrity confirmed, step 24, prior to returning to step 12 to receive and store a quantity of second data to be written to the data storage device. 
     If, however, the comparison performed in step 20 indicates that the data which was previously written to and most recently read from data storage device is not equivalent to the same data which was retained in a temporary memory storage medium as shown at step 26, one embodiment of the method of the present invention assumes that one or more data storage locations on the data storage device being read is defective and reassigns the data to be written to one or more new locations on the data storage device, step 28. In another embodiment of the present invention wherein the data storage device includes one or more disk drives, an entire group or block of data storage locations are considered defective if one or more of the individual data storage locations are defective and thus, this embodiment method of the present invention determines at step 28 that an entire block is defective and generates a pointer or other index from the defective block to a new physical block on the disk drive at which the data would be stored as is well known to those skilled in the art. 
     Subsequently, the method proceeds to write the data which is stored in the one or more temporary memory storage mediums to the new, reassigned, location on the data storage device, step 30. The data is then read from the new location on the data storage device, step 32, prior to returning to the step of comparing the data which as just been read to the data retained in at least one temporary memory storage medium, step 20. Alternatively, after detecting an error between the data which has been read and the data retained in at least one memory storage medium, step 26, one embodiment of the method of the present invention proceeds directly to step 30 wherein the data is again written to the same location on the data storage device prior to being re-read at step 32 and compared at step 20. 
     Thus, in accordance with one feature of the present invention, data is retained in a temporary memory storage medium after being written to a data storage device until a data write integrity verification has been performed to ensure that the data written to the data storage device does not contain any errors prior to releasing the retaining data or clearing a write pending indicator. 
     In yet another embodiment of the present invention, the step of comparing the data read with the chosen criteria, step 20, includes comparing an error checking and correction (ECC) code. In one implementation of this embodiment, the storage device controller may generate the ECC code and transmit it along with the data to the storage device. The storage device then writes the data on the storage device and retains the ECC code in its internal memory. To perform data verification, the storage device then reads the data previously stored on the device and computes the ECC code for the newly read data. The data storage device then compares the ECC code it has generated on the read data with the ECC code generated by the storage device controller and now stored in the storage device memory. Any errors may then be reported to the storage device controller which can retrieve the data from the temporary memory storage unit thus providing full data write integrity. This implementation frees up the system data bus to perform other data transfers by imposing upon the storage device itself the task of verifying data write integrity. 
     In a modified implementation of the embodiment utilizing the ECC code, the storage controller may transfer the data without an ECC code to the storage device. Upon receiving the data, the storage device computes a first ECC code on the data and stores this ECC code in its internal memory. The storage device then writes the data on the storage device medium. To perform data write integrity verification, the storage device then reads the previously written data and generates a second ECC code. The storage device then compares the first ECC code generated when the data was received with the second ECC code generated when the data was read from the storage medium. Although this implementation provides somewhat less protection than the previous implementation described above, it assures that what was received by the storage device is properly written to disk and increases the throughput of the system by reducing the burden on the storage device controller. 
     The method of the present invention may be practiced in conjunction with the system illustrated in block diagram 100, FIG. 2, wherein data 102 is received from a host computer or a host computer interface and controller. The data is then stored in a temporary memory storage medium 104 such as a high-speed semiconductor cache memory. In one embodiment, the data portion 106 is stored with an associated write pending portion 108 to indicate that the associated data is awaiting being written to the storage device. 
     At the appropriate time, such as when a storage device controller 110 is not receiving requests for access to one or more connected storage devices, the storage device controller 110 searches temporary memory storage medium 104 for data 106 with an associated write pending indicator 108. The storage device controller then performs a write command to one or more storage devices 112. The storage devices may include a &#34;primary&#34; storage device 114 and a &#34;mirror&#34; storage device 116. Additionally, storage devices 112 may include a small temporary memory buffer 118,120 within which data which has been written to the storage device is stored. 
     The storage device controller 110 then performs a &#34;read&#34; operation from one or more storage devices 112 after having computed the shortest data access time in the case where the optional &#34;mirror&#34; storage device 116 is utilized. Storage device controller 110 then compares the data which has been read with either the identical data stored in memory 104 or with the two ECC codes which are generated for the data, the first ECC code having been generated prior to writing the data to a storage device, and the second ECC code having been generated when the data was read from the data storage device. 
     If no error is detected, the next data or quantity of data is transferred from memory 104 to one or more storage devices 112 during a subsequent write operation. If an error is detected, storage device controller 110 directs one or more storage devices 112 to either rewrite data stored in memory 104 or storage device buffers 118,120 to the same location on the storage device, or determines that one or more storage device locations are defective, and reassigns defective locations to new locations prior to rewriting, re-reading and re-comparing the data as previously described. 
     Modifications and substitutions to the present invention by one of ordinary skill in the art are considered to be within the scope of the present invention, which is not to be limited except by the claims which follow.