1. Field of the Invention
The present invention relates to Redundant Array of Independent Disks (RAID) , and particularly to a method of performing automatic remapping in a RAID and related RAID with automatic remapping functionality.
2. Description of the Prior Art
RAID has the characteristic of being repairable. When a hard disk of the RAID is damaged, the RAID enters degrade mode. After the RAID enters degrade mode, the damaged hard disk can be changed out, and a repair procedure can be executed using a replacement hard disk.
Repair is performed by reading out correct data from a healthy hard disk of the RAID, then calculating lost data of the damaged hard disk according to the correct data, and finally writing the calculated data result to the replacement hard disk. One characteristic of RAID is that, when writing data to the RAID, data is simultaneously written to all hard disks in the RAID. The RAID establishes a data stripe having a number of columns that corresponds to the number of hard disks in the RAID. Data to be written is distributed into all columns of the stripe, then written into the hard disks corresponding thereto. In RAID levels 1 and above, one column of the stripe is reserved for storage of a parity bit. In RAID level 6 (RAID6) , two columns are reserved. According to this writing characteristic, if data in any column of the stripe is lost, the RAID may calculate lost data according to other data and the parity bit (s) on the stripe. If the lost data happens to be the parity bit, the RAID can recalculate the parity bit. Thus, when a member hard disk of the RAID is damaged, although data on the damaged disk is lost, the RAID can read out data of the stripes to calculate the lost data corresponding to the damaged disk on the stripe, and write the calculated data to the replacement hard disk to repair the degraded RAID.
If the number of lost columns on a stripe exceeds the allowed number, e.g. one column for RAID1 or two columns for RAID6, the RAID cannot calculate the lost data. When repairing the RAID, because one column is already lost (the column corresponding to the damaged hard disk), if a bad sector is encountered in the process of reading data from the healthy hard disk, causing data loss of a second column, the stripe will be unable to repair the lost data, and the RAID will go from degrade mode to crash mode.
Once the RAID enters crash mode, the user is unable to read data from the RAID, namely the user loses all files he/she has stored in the RAID. The user's purpose in repairing the RAID is to restore protection to the data, and to lower the risk of files being corrupted or lost. Prior to repair, the user has not yet encountered corruption or loss of files. However, in the process of repairing the RAID, the user faces risk that all files will be lost, which is a type of risk the user should not be forced to accept.
According to an embodiment, a method of performing automatic remapping in a redundant array of independent disks (RAID) includes issuing a read command for performing a read operation to read data from a hard disk of the RAID, and remapping a bad sector the data is located in to an unused good sector of the hard disk when the bad sector is encountered during the read operation.
According to another embodiment, a method of reporting a bad sector in a redundant array of independent disks (RAID) comprises issuing a read command for performing a read operation to read data from a hard disk of the RAID, and reporting location of a bad sector the data is located in when the bad sector is encountered during the read operation.
According to another embodiment, a redundant array of independent disks (RAID) with automatic remapping functionality comprises a plurality of hard disks in RAID configuration, and firmware for remapping a bad sector of a hard disk of the plurality of hard disks when the bad sector is encountered during a read operation of the hard disk.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
When a column of a data stripe cannot be repaired, only accuracy of a file to which the data stripe belongs is actually affected directly. In other words, a user should only lose one file, and should not lose all files when the repair process encounters a bad sector in a redundant array of independent disks (RAID). In the embodiments, the RAID function for repairing degrade mode is improved, so that the RAID is allowed not to enter crash mode even if a bad sector is read during the repair process, so as to eliminate unreasonable risk to the user. Additionally, a record is established indicating which sector the bad sector belongs to in a file system. After the RAID is repaired completely, the corrupted file is found according to the bad sector record, and the user is notified of the corrupted file. After completing repair, file system tools are used to check the file system for data and file system integrity.
Please refer to
As shown in
Please refer to
Step 200: Begin a RAID operation on a RAID;
Step 202: Perform a read operation on a hard disk of the RAID;
Step 204: Encounter a bad sector when performing the read operation;
Step 206: Remap the bad sector to a new good sector;
Step 208: Report location of the bad sector to the RAID controller; and
Step 210: Report a corrupted file that the bad sector belongs to.
In step 200, a RAID controller begins a RAID operation on the RAID. The RAID may be in degraded mode. The RAID operation may be repair, normal I/O, migration, or another operation that requires issuance of a read command to a hard disk of the RAID. In step 202, the read operation is performed on the hard disk of the RAID. As shown in
In step 206, remapping is performed to point the address of the bad sector to another location on the hard disk. Many remapping functions exist, and are well known in the art. For example, some remapping functions are performed by firmware of the hard disk.
Please note that, in the method shown in
The method described above is suitable for all RAID levels. As long as the RAID is in degrade mode, the method shown in
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.