Embodiments described herein relate generally to a memory controller, a storage device, and a memory control method.
In a NAND flash memory, data access is performed at a high speed although the cost per unit capacity is high. In a hard disk (a magnetic disk), data access is performed at a low speed although the cost per unit capacity is low. In recent years, a hybrid storage device has been developed, which includes both a NAND flash memory and a hard disk, so that data requiring high-speed access is stored in the NAND flash memory and data not requiring high-speed access is stored in the hard disk. Meanwhile, in the NAND flash memory, it is general to add a parity for error correction to data to be stored, in order to maintain reliability. In order to enable correction of a burst error in which data is lost at once, such as block loss in which the entire block, which is a unit of erasure of the NAND flash memory, cannot be read, a code word needs to be constituted by data stored in a plurality of areas on the NAND flash memory. For example, in order to enable correction of data at the time of the block loss, the code word needs to be constituted by data stored in a plurality of blocks.
In general, according to one embodiment, a storage device includes an encoder, a nonvolatile memory that stores user data and a parity, a magnetic disk, and a management unit that holds correspondence between a logical address and a first physical address as first conversion information, and holds correspondence between the first physical address and a second physical address as second conversion information, with the second physical address including media information indicating a medium of a storage destination and information indicating a storage position. When the user data stored in the nonvolatile memory is to be moved to the magnetic disk, the management unit updates the second physical address of the user date in the second conversion information, to a value indicating a storage destination after the movement.
Exemplary embodiments of a storage device, and a memory control method will be explained below in detail with reference to the accompanying drawings. The present invention is not limited to the following embodiments.
The storage device 1 according to the present embodiment is a hybrid drive having the NAND memory 3 and the magnetic disk 4. In the hybrid drive, the NAND memory 3 is used as, for example, a write cache. That is, data from the host 5 is once written in the NAND memory 3 used as a cache memory. The data from the host 5 is then written in the magnetic disk 4.
The NAND memory 3 is a nonvolatile memory that stores data in a nonvolatile manner. Writing is performed to the NAND memory 3 in a unit of writing referred to as “page”. In the NAND memory 3, data is erased in a unit of data referred to as “block”. One block includes a plurality of pages. Furthermore, the NAND memory 3 can be constituted of a plurality of chips (memory chips). The chip includes one or more blocks.
The memory controller 2 includes a host I/F (Interface) 21, a management unit 22, a NAND control unit 23, and a disk control unit 24. The NAND control unit 23 controls the NAND memory 3 based on an instruction from the management unit 22. The NAND control unit 23 includes an encoding/decoding unit 231 and a memory I/F 234. The encoding/decoding unit 231 includes an encoder 232 and a decoder 233. The disk control unit 24 controls the magnetic disk 4 based on an instruction from the management unit 22. The disk control unit 24 includes an encoding/decoding unit 241 and a disk I/F 244. The encoding/decoding unit 241 includes an encoder 242 and a decoder 243.
The host I/F 21 outputs a command and user data (write data) and the like received from the host 5 to an internal bus 20. Furthermore, the host I/F 21 transmits user data read from the NAND memory 3 and the magnetic disk 4, a response from the management unit 22, and the like to the host 5.
The management unit 22 is a CPU (Central Processing Unit), an MPU (Micro Processing Unit), or the like and controls respective constituent elements of the storage device 1 in an integrated manner. The management unit 22 controls writing and reading operations according to a request from the host 5 received via the host I/F 21, and outputs a response to the host 5 to the host I/F 21. For example, the management unit 22 controls writing to the magnetic disk 4 and reading from the magnetic disk 4 via the disk control unit 24. Further, the management unit 22 controls writing to the NAND memory 3 and reading from the NAND memory 3 via the NAND control unit 23.
The user data received from the host 5 is input to the NAND control unit 23 via the internal bus 20. At this time, the controller 2 can store the user data received from the host 5 once in a data buffer (not shown), and then input the user data read from the data buffer to the NAND control unit 23. The management unit 22 determines a memory area of a storage destination of the user data with respect to data (page data) in a unit of page, which is a unit of writing. In the present specification, the user data stored in one page of the NAND memory 3 is defined as unit data. When encoding is performed for each page data and parity is added, the size of page data becomes a size obtained by adding the size of the unit data and the size of the parity. When encoding for each page data is not performed, the size of page data can be the same as the size of unit data.
In the present specification, a memory cell connected commonly to one word line is defined as a memory cell group. When the memory cell is a single-level cell, the memory cell group corresponds to one page. When the memory cell is a multi-level cell, the memory cell group corresponds to a plurality of pages. For example, when a multi-level cell capable of storing two bits is used, the memory cell group corresponds to two pages. A physical address is allocated to a memory area of the nonvolatile memory 3. The management unit 22 manages the memory area of a write destination of the unit data by using the physical address. The management unit 22 specifies the determined memory area (the physical address) and instructs the NAND control unit 23 to write the user data in the NAND memory 3. The management unit 22 manages correspondence between a logical address (a logical address managed by the host 5) and the physical address of the user data. In the present embodiment, correspondence between the logical address and the physical address on the NAND memory 3 is managed by using two tables described later.
Furthermore, in the storage device 1 according to the present embodiment, the NAND memory 3 is used as a cache, and when a certain condition is satisfied, the user data stored in the NAND memory 3 is copied to the magnetic disk 4 and erased from the NAND memory 3. When a parity is added to the user data, the parity is also copied to the magnetic disk 4 and is erased from the NAND memory 3. When having determined to copy the user data (or the user data and parity) from the NAND memory 3 to the magnetic disk 4, the management unit 22 determines a storage area on the magnetic disk 4, specifies a physical address indicating the storage area (a physical address on the magnetic disk 4), and instructs the disk control unit 24 to write the user data in the magnetic disk 4. The management unit 22 manages the correspondence between the logical address of the user data (the logical address managed by the host 5) and the physical address on the magnetic disk 4 by using two tables described later.
Upon reception of a read command including the logical address from the host 5, the management unit 22 identifies a storage medium (the NAND memory 3 or the magnetic disk 4) corresponding to the logical address and the physical address, specifies the physical address, and instructs reading of the user data to the NAND memory 3 or the magnetic disk 4.
The first physical address does not indicate an actual physical address on the NAND memory 3 or the magnetic disk 4, but indicates an intermediate physical address for identifying an actual physical address on the NAND memory 3 or the magnetic disk 4. The first physical address does not include information for discriminating a medium (the NAND memory 3 or the magnetic disk 4) as a storage destination of data. The first physical address is an intermediate physical address to be used in the controller 2 as described above, and can be determined by an arbitrary method. The second physical address includes information for discriminating the medium (the NAND memory 3 or the magnetic disk 4) as the storage destination of data and a physical address on the medium.
In
When the NAND memory 3 is full (Yes at Step S2), the management unit 22 copies data having a low access frequency, of the data (the user data and parity) stored in the NAND memory 3, to the magnetic disk 4 (Step S4). Data having a low access frequency is copied here to the magnetic disk 4. However, data to be copied can be determined, for example, by using a reference other than the access frequency, such as the order of the stored time (an order of storage).
At Step S4, specifically, the management unit 22 instructs the NAND control unit 23 to read data from the NAND memory 3, and to erase data at the physical address after reading of data. Furthermore, the management unit 22 determines a physical address on the magnetic disk 4 of the write destination of data read from the NAND memory 3. The management unit 22 instructs the disk control unit 24 to write the data read from the NAND memory 3 to the determined physical address on the magnetic disk 4. The NAND control unit 23 reads data stored at the instructed physical address based on the instruction from the management unit 22, outputs the data to the internal bus 20, and erases the memory area after the reading. The disk control unit 24 stores the data input from the internal bus 20 in an area on the magnetic disk 4 indicated by the physical address instructed from the management unit 22. At this time, when data to be written in the magnetic disk 4 is to be encoded and written, a code word after being encoded by the encoder 242 is written in the magnetic disk 4. After completion of copying at Step S4, the management unit 22 updates the second physical address corresponding to the first physical address of the source data in the media table to the second physical address corresponding to the copy destination (Step S5), and the process proceeds to Step S3.
As described above, in the present embodiment, all the pieces of user data requested to be written from the host 5 are initially stored in the NAND memory 3.
An encoding process performed by the NAND control unit 23 according to the present embodiment is explained next. The encoder 232 generates a parity by the encoding process with respect to user data to be written in the NAND memory 3. The method of the encoding process is not particularly limited thereto. At this time, various modes can be considered for a combination of user data constituting the code word (user data+parity). For example, as a first example, there is a mode in which user data in the same page is encoded to generate a parity, and the parity is stored in the same page together with the user data. In the following descriptions, the parity generated in this manner is referred to as “in-page parity”. In the NAND memory 3, because writing and reading are performed in a unit of page, if the code word is constituted by user data and a parity in the same page, another page does not need to be read when decoding is performed at the time of reading, and a reading process can be performed at a high speed.
As a second example, there is a mode in which the user data to be stored in a plurality of pages is encoded to generate a parity. In the following descriptions, the parity generated in this manner is referred to as “inter-page parity”. In this case, when reading cannot be performed in a unit of page, data of the page that cannot be read can be restored. If the code word is constituted by user data stored in a plurality of blocks, when reading cannot be performed in a unit of block, data of the block that cannot be read can be restored. Furthermore, if the code word is constituted by user data stored in a plurality of chips, when reading cannot be performed in a unit of chip, data of the chip that cannot be read can be restored.
When only the in-page parity is used, reading from the NAND memory 3 is performed in a unit of page. Therefore, when data is copied to the magnetic disk 4, the entire code word is copied, and thus one code word is not stored in two media in a distributed manner.
When the storage medium indicated by the second physical address is the NAND memory 3 (the NAND memory at Step S12), the management unit 22 instructs the NAND control unit 23 to read data corresponding to the second physical address from the NAND memory 3. The NAND control unit 23 reads data from the NAND memory 3 based on the instruction (Step S13). The data to be read at this time is user data when the parity is not added, or the user data and parity corresponding to the user data when the parity is added. When the parity is added, the decoder 233 performs an error correction process by using the user data and parity corresponding to the user data.
The management unit 22 transmits the user data read from the NAND memory 3 (when the parity is added, the user data after error correction) to the host 5 via the host I/F 21 (Step S15).
When the storage medium indicated by the second physical address is the magnetic disk 4 (the magnetic disk at Step S12), the management unit 22 instructs the disk control unit 24 to read data corresponding to the second physical address from the magnetic disk 4. The disk control unit 24 reads data from the magnetic disk 4 based on the instruction (Step S14) and the process proceeds to Step S15. The disk control unit 24 then transmits the read user data to the host 5. The data to be read at this time is user data copied from the NAND memory 3 (or the user data and parity) when encoding by the encoder 242 has not been performed at the time of writing. When encoding by the encoder 242 has been performed, the data to be read is a code word obtained by encoding the user data (or the user data and parity) copied from the NAND memory 3. When encoding by the encoder 242 has been performed at the time of write, the decoder 243 performs the error correction process by using the code word. When the parity has been added at the time of storage in the NAND memory 3, the decoder 233 of the NAND control unit 23 performs the error correction process by using the user data and parity read from the magnetic disk 4, and transmits the user data after the error correction process to the host 5.
In the NAND memory 3, erasure is performed in a unit of block. Therefore, it can be considered to designate a minimum unit of a copy to the magnetic disk 4 as one block. When the minimum unit of a copy is set to one block and the inter-page parity is to be generated within the same block, one code word is not stored in the magnetic disk 4 and the NAND memory 3 in a distributed manner. Accordingly, also in this case, the reading procedure shown in
On the other hand, when the inter-page parity is to be used, there is a possibility that a part of one code word is copied to the magnetic disk 4. In this case, one code word is stored in the NAND memory 3 and the magnetic disk 4 in a distributed manner.
It is assumed that information indicating which user data constitutes the code word is managed, for example, by a code-word configuration table shown in
A process at the time of reading when the inter-page parity is used is explained next.
First, Steps S31, S32, S33, and S36 are performed as the Steps S11, S12, S13, and S14 in
After Step S33 or Step S36, the management unit 22 determines whether there is an error based on the notification from the decoder 233 (Step S34). When there is no error (No at Step S34), the process returns to Step S31. When there is an error (Yes at Step S34), the management unit 22 reads the user data and parity constituting a group of the iterated codes to which the user data to be read belongs, based on the code-word configuration table and the media table, to perform the error correction process (Step S35), and the process returns to Step S31.
At Step S35, the management unit 22 refers to the code-word configuration table based on a first physical address corresponding to the logical address of the user data to be read, and extracts the first physical address of the user data in the same group as the user data to be read. The management unit 22 obtains a second physical address corresponding to the extracted first physical address by referring to the media table, and instructs any one or both of the NAND control unit 23 and the disk control unit 24 to read data based on the second physical address. When all the pieces of user data and parities constituting the iterated code group are on the NAND memory 3, the NAND control unit 23 reads the pieces of user data and parities based on the second physical address instructed by the management unit 22, to perform the error correction process by using the in-page parity. When all the pieces of user data and parities constituting the iterated code group are on the magnetic disk 4, the disk control unit 24 reads data (a code word when the data is encoded by the encoder 242) based on the second physical address instructed by the management unit 22, and transmits the read data to the NAND control unit 23. The NAND control unit 23 performs error correction by using the in-page parity received from the disk control unit 24, and then performs the error correction process by using the pieces of user data and parities constituting the iterated code.
When the pieces of user data and parities constituting the iterated code group are stored both in the NAND memory 3 and the magnetic disk 4, the disk control unit 24 reads the data (a code word when the data is encoded by the encoder 242) based on the second physical address instructed by the management unit 22, and transmits the read data to the NAND control unit 23. The NAND control unit 23 performs error correction by using the in-page parity received from the disk control unit 24, and reads the pieces of user data and parities based on the second physical address instructed by the management unit 22 to perform error correction using the in-page parity. Thereafter, the NAND control unit 23 performs the error correction process by using the pieces of user data and parities constituting the iterated code.
In the present embodiment, an example in which all the pieces of user data are once stored in the NAND memory 3 has been explained. However, user data to be written initially in the magnetic disk 4 can be present. In this case, a second physical address of the user data to be written initially in the magnetic disk 4 becomes a physical address on the magnetic disk 4 from the start.
As described above, in the present embodiment, address conversion of the logical address and the physical address is performed by two-stage conversion, that is, conversion between the logical address and the first physical address, and conversion between the first physical address and the second physical address. The second physical address includes information for identifying the write destination medium, and when copying from the magnetic disk 4 to the NAND memory 3 is performed, the second physical address is updated to the information indicating the storage destination after the copying. Accordingly, when the inter-page parity is added to the user data to be stored in the NAND memory 3, even if the code word is stored in the magnetic disk 4 and the NAND memory 3 in a distributed manner, reading of the code word can be performed promptly.
In the first embodiment, an example in which an iterated code is constituted by an in-page parity and one type of an inter-page parity has been explained. In a second embodiment, an example in which a plurality of types of inter-page parities is used to constitute an iterated code is explained. Configurations of the storage device 1 according to the present embodiment are identical to those of the first embodiment.
As described above, when the user data is protected by a plurality of inter-page parities, in the present embodiment, the inter-page parity to be used for error correction is selected based on the amount of user data and parities stored on the NAND memory 3, of the pieces of user data and parities constituting the code word. For the sake of simplicity, it is assumed here that the sizes of the code words in the group 200 and the group G0 are the same. In this case, for example, it is assumed that a read request of user data having the first physical address “A-0” is received. As in the first embodiment, the user data and a parity (an in-page parity) are read from the NAND memory 3, by using a second physical address corresponding to the first physical address “A-0”. It is assumed here that after the error correction process using the user data and the in-page parity has been performed, an error remains. In this case, as shown in
The rules held by the system are rules, for example, such that when a plurality of inter-page parities having the same size of the code word has been generated, the inter-page parity for which more pieces of user data and parities are stored on the NAND memory 3 is selected. The specific contents of the rules are not limited. When the size of the code word is different, the rules can be determined, taking the size of the code word into consideration, because comparison cannot be made simply based on only the amount of the user data and parity on the NAND memory 3.
As described above, in the present embodiment, when the user data is protected by the plurality of inter-page parities, the inter-page parity that can be corrected at a high speed is selected, a code word corresponding to the selected inter-page parity is read, and error correction is performed. Accordingly, the read speed at the time of performing error correction using the iterated code can be improved.
A third embodiment is explained next. Configurations of the storage device 1 according to the present embodiment are identical to those of the first embodiment. A writing procedure and a reading procedure according to the present embodiment are identical to those of the first embodiment or the second embodiment.
After the user data and parity are stored in the NAND memory 3, a part of the user data constituting the code word may become invalid. The management unit 22 ascertains the logical address of the invalid user data. When copying of data from the NAND memory 3 to the magnetic disk 4 is performed, if a copy source area includes invalid user data, the management unit 22 performs copying to the magnetic disk 4 excluding the invalid user data by recalculating the parity. Specifically, the management unit 22 reads the entire code word including the invalid user data and performs the error correction process with respect to the entire code word. The management unit 22 then copies the user data, which is not invalid (which is valid), of the user data after the error correction process, to the magnetic disk 4.
The invalid user data is user data on a medium (the NAND memory 3 or the magnetic disk 4) in which correspondence information between the logical address and the first physical address is not present in the L2P table, and correspondence information between the first physical address and the second physical address is present in the media table.
When a code word including many pieces of valid user data is to be copied to the magnetic disk 4, copying can be collectively performed including the invalid user data, and the entry of the invalid user data can be deleted from the media table. Accordingly, the first physical address used for the invalid user data can be reused. Furthermore, the physical address on the magnetic disk 4 of the invalid user data copied to the magnetic disk 4 is recognized as a free area, because it is not present in the media table, and new user data can be overwritten.
As described above, in the present embodiment, the invalid user data is not copied to the magnetic disk 4, or the entry thereof is deleted from the media table. Accordingly, wasteful consumption of capacity by the invalid data can be prevented.
While certain embodiments 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 embodiments described herein may be embodied in a variety of other forms; furthermore, various omissions, substitutions and changes in the form of the embodiments 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.
This application is based upon and claims the benefit of priority from U.S. Provisional Application No. 61/932,019, filed on Jan. 27, 2014; the entire contents of which are incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
61932019 | Jan 2014 | US |