This application is based upon and claims the benefit of priority from Japanese Patent Application No. 2009-154376, filed on Jun. 29, 2009, the entire contents of which are incorporated herein by reference.
1. Field
Embodiments described herein relate generally to a magnetic disk device.
2. Description of the Related Art
As the recording density of recording media such as magnetic disks increases, a magnetic disk device generally scans a magnetic disk to detect flaws on the magnetic disk or a bad sector of the magnetic disk at an early stage to recover the magnetic disk (see, for example, Japanese Patent Application Publication (KOKAI) Nos. 2007-242207 and H4-310671). Specifically, while a magnetic disk device reads a recording area of a magnetic disk, when a sector in which an unrecoverable read error occurs is detected, the magnetic disk device records it as log data. When a sector in which a recoverable read error occurs is detected, the magnetic disk device rewrites data or recovers the bad sector by an alternate process. Among such functions of performing a scan is a pre-scan function. An application that realizes the pre-scan function is launched immediately after the magnetic disk device is turned on while the magnetic disk device receives no command from a host device as an upper device and is idle. After the launch, the magnetic disk device performs a scan all over the recording area of the magnetic disk by unit of read launching (for example, by one track). When the magnetic disk device receives a command instructing to write data to a recording area where a scan is not yet performed (hereinafter, “unscanned area”) from the host device while performing such a scan, the magnetic disk device performs a verify process to verify whether data is correctly written after writing the data according to the command to detect defects on a sector to be written at an early stage. Such a function increases the reliability of the magnetic disk.
As described above, the pre-scan function increases the reliability of the magnetic disk. On the other hand, when writing is performed on the unscanned area, the verify process intervenes. This verify process requires extra waiting time, generally one rotational delay. Because of this, a response that indicates the termination of the command to the host device is delayed.
With a conventional pre-scan function, scan is performed sequentially from a logical block at the head of a magnetic disk without consideration of the condition or order in which scan is performed. As a result, when the logical block does not match the pattern of the command from the host device, the verify process is performed every time writing is performed on the unscanned area. This may increase the delay of the response to the host device. Although the verify process after data writing is performed on only a recording area to be written, and a scan is performed on a sector from which reading is instructed by a command from the host device that instructs data reading, a recording area of the sector is not treated as a pre-scanned recording area, and the verify process is performed on the recording area. Accordingly, the pre-scan becomes extremely inefficient.
A general architecture that implements the various features of the invention will now be described with reference to the drawings. The drawings and the associated descriptions are provided to illustrate embodiments of the invention and not to limit the scope of the invention.
Various embodiments according to the invention will be described hereinafter with reference to the accompanying drawings. In general, according to one embodiment of the invention, a magnetic disk device comprises a receiver, a storage module, a determining module, and a prescanner. The receiver is configured to receive a command transmitted from a host device. The storage module is configured to store, with respect to each of divided areas formed by dividing the recording area of a recording medium into a plurality of areas, pre-scan control information that indicates at least one of the receiving time and the number of receiving times. The receiving time indicates a time at which a write command instructing to write data to all or part of the divided area is received. The number of receiving times indicates the number of times the write command is received within a predetermined period after the power is turned on. The determining module is configured to determine the order in which pre-scan is performed on the divided areas based on at least one of the receiving time and the number of receiving times referring to the pre-scan control information. The prescanner is configured to pre-scan the divided areas in the order determined by the determining module immediately after the power is turned on.
The host IF controller 101 communicates with a host device (not illustrated) through an interface bus 117, and receives a command issued by the host device. According to the command, the host IF controller 101 receives data (write data) instructed to be written to the magnetic disk 115 from the host device, or transmits data (read data) instructed to be read and transmitted from the magnetic disk 115 to the host device. In the embodiment, a command instructs to write data to the magnetic disk 115, to read and transmit data from the magnetic disk 115, or to perform a verify process. The execution of the command causes access to the magnetic disk 115. A command that instructs to write data is herein referred to as a write command, a command that instructs to read and transmit data is referred to as a read command, and a command that instructs to perform a verify process is referred to as a verify command. An area to be written (hereinafter, “write area”) is designated by the write command, an area to be read is designated by the read command, and an area to be subjected to a verify process is designated by the verify command. Data reading is performed in the verify process, and therefore, in the embodiment, the verify command is also treated as a command that instructs to read data as with the read command. However, the read command instructs to transmit the read data, while the verify command does not. The read command and the verify command may be referred to as “read type command”. For convenience of description, an area designated by the read type command may be referred to as “access area”.
The FROM 110 is a nonvolatile memory that stores various data or various computer programs to be executed by a central processing unit (CPU). The memory 109 temporarily stores various data such as work variables, and various computer programs. The MPU 108 is a processor functioning as amain controller that loads various computer programs from a read-only memory (ROM) into a random-access memory (RAM) to execute them, and controls the overall operation of the HDD 100. The MPU 108 has a clock (not illustrated) that count the time, and times a receiving time at which a command is received from the host device through the host IF controller 101. The servo controller 111 controls the VCM 112 and the SPM 113 under the control of the MPU 108. The SPM 113 rotates the magnetic disk 115 steadily under the control of the servo controller 111. The VCM 112 moves the magnetic head 114 to the target position under the control of the servo controller 111.
The buffer controller 102 controls memories in the buffer memory 103 and the nonvolatile memory 104, both of which are connected as subordinates of the buffer controller 102. The buffer memory 103 temporarily stores a command received from the host device, write data transmitted from the host device, and read data to be transmitted to the host device, under the control of the buffer controller 102. The nonvolatile memory 104 stores various data under the control of the buffer controller 102.
The format controller 105 functions as a control signal generating circuit that generates signals necessary for the control inside the HDD 100. The head IC 107 amplifies a signal (an analog read signal) read by the magnetic head 114 to output the signal to the read channel 106. The head IC 107 controls the magnetic head 114 to write a signal for writing output from the read channel 106 to the magnetic disk 115. The magnetic head 114 generates a magnetic field to magnetize a magnetic body to write the signal for writing to the magnetic disk 115, or to read data written to the magnetic disk 115 as a signal by detecting changes in the magnetic field. The read channel 106 performs analog/digital (A/D) conversion on a read signal amplified by the head IC 107 to encode the signal, and outputs it to a hard disk controller (HDC). Further, the read channel 106 pulses a read signal to output it to the format controller 105. The read channel 106 also converts data encoded according to each control signal from the format controller 105 into a write signal to output the signal to the head IC 107.
Data reading and data writing with respect to the magnetic disk 115 are performed along tracks arranged concentrically on the magnetic disk 115. A plurality of servo areas are radially formed, to be positioned on each track, on the magnetic disk 115 to pass through each concentric circle. The magnetic head 114 is moved to be positioned at a target track while reading information from the servo areas under the control of the servo controller 111 (on-track). According to the embodiment, a recording area on the magnetic disk 115 is divided into a plurality of areas (divided areas). The HDD 100 is provided with a pre-scan table that stores control information related to pre-scan (pre-scan control information) for each divided area. The pre-scan table is stored in a recording area of at least one of the nonvolatile memory 104 and the magnetic disk 115. Part of the pre-scan control information stored in the pre-scan table is updated on a regular basis.
The MPU 108 reads such a pre-scan table immediately after the power is turned on, and determines the order of pre-scan to perform the pre-scan on the divided areas in the order of the write command receiving time, and generates an order management table that indicates the determined order. The order management table is stored in the recording area of at least one of the nonvolatile memory 104 and the magnetic disk 115.
The MPU 108 performs the pre-scan on each divided area immediately after the power is turned on according to the order indicated by the order management table. When the pre-scan on the target divided area is completed, the MPU 108 updates a pre-scan completed logical block address in the pre-scan control information for the divided area stored in the pre-scan table. When the MPU 108 receives a command from the host device through the host IF controller 101 while performing the pre-scan, the MPU 108 immediately aborts the pre-scan being performed and starts a process according to the command. In this case, the MPU 108 updates the pre-scan completed logical block address in the pre-scan control information stored in the pre-scan table with the logical block address in which the pre-scan is normally completed in the divided area on which the pre-scan is being performed.
At this time, when the command received is a write command, the MPU 108 controls data to be written to the write area designated by the write command, and then judges which of the divided areas corresponds to the write area. The MPU 108 refers to the scan completed logical block address in the pre-scan control information on the judged divided area stored in the pre-scan table. When an area where the pre-scan is not yet performed (an unscanned area) remains, the MPU 108 performs a verify process on, besides the unscanned area, at least one of a logical block preceding the write area and the following logical block. In the verify process, the MPU 108 reads data from these areas and verifies whether the data is normally written. The MPU 108 updates the logical block address of the divided area where the verify process is normally completed as a pre-scan completed logical block address in the pre-scan control information stored in the pre-scan table. The MPU 108 increments the number of received write commands in the pre-scan control information stored for the divided area in the pre-scan table by one to update it. When the received write command is a command received first for the divided area to which the write area belongs after the power is turned on, the MPU 108 updates a write command receiving time in the pre-scan control information for the divided area stored in the pre-scan table with the receiving time of the write command.
When the command received from the host device is a read command or a verify command, the MPU 108 judges to which of the divided areas an access area designated by the command belongs, and refers to a pre-scan completed logical block address in the pre-scan control information on the judged divided area stored in the pre-scan table. When an unscanned area where the pre-scan is not yet performed for the divided area remains, data is read from, as an area to be read, besides the access area, a logical block preceding the access area and the following logical block. The MPU 108 updates the pre-scan completed logical block address in the pre-scan control information stored in the pre-scan table with the logical block address of the divided area where data reading is normally completed. In other words, for the divided areas corresponding to the logical block preceding the access area and the following logical block, a verify process is assumed to be performed by reading data. In the embodiment, the divided area is treated as an area where a pre-scan is completed, and thus an unnecessary verify process on the divided area is avoided.
Typically, the MPU 108 reads data from the magnetic disk 115 including the logical block following the access area designated by a read command, and stores the data as cache data in the buffer memory 103 and the nonvolatile memory 104. In such a manner, when the MPU 108 pre-reads the logical block following the designated access area, the pre-scan completed logical block address in the pre-scan control information on the divided area to which an area where reading can be normally performed at the completion of the pre-reading belongs, stored in the pre-scan table is updated as needed. Because of this, an unnecessary verify process can be efficiently avoided by utilizing a pre-reading function. When the pre-scan has been performed on all recording areas, i.e., all divided areas, on the magnetic disk 115, the MPU 108 stores the pre-scan completion information indicating it in the order management table.
The operation of the HDD 100 of the embodiment will be described. An order determination process to determine the order in which pre-scan is performed will be described referring to
A pre-scan process performed by the HDD 100 will be described referring to
The MPU 108 refers to a pre-scan completed logical block address in the pre-scan control information on the divided area determined at S22 stored in the pre-scan table, and judges whether an unscanned area where the pre-scan is not yet performed remains in the divided areas (S25). If an unscanned area remains (Yes at S25), the MPU 108 determines the unscanned area as a target for the pre-scan (S26), and performs the pre-scan on the unscanned area (S27). The MPU 108 updates the pre-scan completed logical block address in the pre-scan control information on the divided area stored in the pre-scan table with the address of the logical block in which the pre-scan is completed (S28). The MPU 108 judges whether the pre-scan is completed on all the divided areas (S29). If not (No at S29), the process moves to S30. If an unscanned area does not remain (No at S25), the process also moves to S30. The MPU 108 associates the current pointer with the pointer of a divided area next to the divided area determined at S22 in the order management table (S30), and the process moves to S31. If the judgment results at S21 and S29 are positive, the MPU 108 stores the pre-scan completion information indicating that the pre-scan is completed on all the divided areas in the order management table, and the process moves to S31.
On the other hand, if a command is received at S20, the MPU 108 performs a process according to the command received from the host device (S32), and then the process moves to S31. At S31, when the command received at S20 is a write command, the MPU 108 increments the number of received write commands in the pre-scan control information on the divided area, to which a write area designated by the write command belongs, stored in the pre-scan table by one to update it. Moreover, when the write command is a command received first for the divided area after the power is turned on, the MPU 108 updates the write command receiving time in the pre-scan control information on the divided area stored in the pre-scan table with the receiving time of the write command. Subsequently, the MPU 108 transmits a response message indicating that data writing by the write command is completed to the host device.
A process when the HDD 100 receives a write command while performing a pre-scan will be described referring to
The MPU 108 updates the pre-scan completed logical block address in the pre-scan control information stored in the pre-scan table with the address of the logical block in which the pre-scan is normally completed in the divided area on which the verify process is completed (S45). Moreover, the MPU 108 increments the number of received write commands in the pre-scan control information on the divided area stored in the pre-scan table by one to update it. When the received write command is a write command received first for the divided area after the power is turned on, the MPU 108 updates the write command receiving time in the pre-scan control information on the divided area stored in the pre-scan table with the receiving time of the write command. As a result of the judgment at S42, if no unscanned area remains (pre-scan completed at S42), the process ends.
A process when the HDD 100 receives a read command or a verify command during pre-scan will be described in detail. The process when a read command is received is described referring to
On the other hand, as a result of the judgment at S61, if no unscanned area remains, the MPU 108 designates, in addition to the access area designated by the read command, a logical block following the access area (pre-read area), as an area to be read to control data reading (S65). In this process, the MPU 108 stores data read from pre-read area in the buffer memory 103 or the nonvolatile memory 104 as cache data. After S64 or S65, when data reading by the read command is completed, the MPU 108 transmits a response message including data read from the access area to the host device. In the process when the HDD 100 receives a verify command, the operation to read data is basically the same as that when a read command is received, and thus the description is not repeated. In the case of the verify command, the HDD 100 does not transmit the read data.
As described above, an area to be accessed can be predicted effectively by dividing the recording area of the magnetic disk 115 into a plurality of divided areas, and by determining the order in which pre-scan is performed for the divided areas so that pre-scan is performed in the order of time when a write command is received from the host device. Thus, the pre-scan can be performed prior to writing by the write command. As a result, the delay of a response for the write command to the host device can be suppressed.
When an unscanned area remains in the write area designated by the write command, at least one of the logical blocks before and after the unscanned area is predicted to be accessed. For this reason, a verify process is performed on, besides the unscanned area, at least one of the logical blocks before and after the unscanned area, and thus the verify process can be performed efficiently.
Moreover, when an unscanned area remains in the access area where reading is instructed by a read command or a verify command, data is read from the logical blocks before and after the unscanned area. The area where the reading is normally completed is treated as an area where a verify process is normally completed, and thus an unnecessary verify process can be avoided.
In the embodiment described above, various computer programs executed by the HDD 100 may be stored in a computer connected via a network such as the Internet and downloaded therefrom through the network. The computer programs may also be provided as being stored in a computer-readable recording medium, such as a compact disk read only memory (CD-ROM), a flexible disk (FD), a compact disc-recordable (CD-R), and a digital versatile disc (DVD), as files in an installable or executable format.
In the embodiment described above, the MPU 108 of the HDD 100 may determine the order of pre-scan to perform the pre-scan in the descending order of the number of write commands received from the host device within a predetermined period of time after the power is turned on.
The various modules of the systems described herein can be implemented as software applications, hardware and/or software modules, or components on one or more computers, such as servers. While the various modules are illustrated separately, they may share some or all of the same underlying logic or code.
While certain embodiments of the inventions have been described, these embodiments have been presented by way of example only, and are not intended to limit the scope of the inventions. Indeed, the novel methods and systems described herein may be embodied in a variety of other forms; furthermore, various omissions, substitutions and changes in the form of the methods and systems described herein may be made without departing from the spirit of the inventions. The accompanying claims and their equivalents are intended to cover such forms or modifications as would fall within the scope and spirit of the inventions.
Number | Date | Country | Kind |
---|---|---|---|
2009-154376 | Jun 2009 | JP | national |