(A) Field of the Invention
The present invention relates to a method for managing a memory and, more particularly, to a method of managing a multi-level cell (MLC) memory to avoid data corruption when power is unexpectedly interrupted.
(B) Description of Related Art
Multi-level cell flash memories are widely used for data storage nowadays. Flash memory is a form of EEPROM (electronically erasable programmable read-only memory) non-volatile memory. The operations that a controller performs on NAND flash media include read, write and erase operations. NAND Flash media typically are written in units called “pages,” each of which typically includes between 512 bytes and 2048 bytes, and typically are erased in units called “blocks,” each of which typically includes between 64 and 128 pages.
For non-volatile memory data storage, a major risk to the integrity of data storage is a sudden power failure in the middle of an operation. Such a power failure often causes the interrupted operation to have erratic or unpredictable results.
If the power failure occurs in an operation changing the contents of NAND flash media, for example in the middle of writing a page of data or in the middle of erasing a block, the contents of the interrupted page or block are unpredictable after being powered up again. This is because some of the affected bits may have gotten to the state assigned to them by the operation by the time power was interrupted, while other bits were lagging behind and not yet at their target values. For an MLC memory, one cell can store two pages, and these two pages form “a paired page.” Therefore, when programming one page of the paired page, the other page of the paired page would be influenced because the cell voltage level is changed. Consequently, if one page of a paired page has been written and power failure occurs while the other page is being written, the written page will be lost. Therefore, there is a demand to find an effective solution to resolve the page loss problems.
The present invention provides a management method for a memory of paired page structure to avoid data loss or damage due to power interruption.
In accordance with the present invention, a method is employed to manage a memory, e.g., a flash memory, including a plurality of paired pages. Each paired page includes a page and a respective risk zone. For each write command, at least one unwritten page is selected for writing new data. For each unwritten page whose risk zone includes at least one written page, each written page is copied, and the new data is written to the unwritten page. For each unwritten page whose risk zone lacks written pages, the new data is written to the unwritten page.
According to an embodiment of the present invention, the writing for the unwritten page whose risk zone includes at least one written page may be performed in accordance with sequential page address order, and the writing for the unwritten page whose risk zone has no written page may be performed in accordance with random page address order.
In an embodiment, the written page is copied only if the unwritten page and the written page are not operated by the same write command.
According to the present invention, the written page may be copied, or the unwritten page is written only if its risk zone has no written page. As a result, even if power failure occurs, the written page will not be corrupted.
Embodiments of the present invention will now be described with reference to the accompanying drawings.
Normally, the flash memory is controlled by a controller in sequential write or random write manner. For sequential write, data is written to pages according to incremental page address order. For random write, data is written to pages according to random address order. To facilitate the management of NAND flash media, the host assigns each page a status of “unwritten” or “written.” A page whose status is “unwritten” is a page that has not been written since the last time it was erased, and so is available for writing. A page whose status is “written” is a page to which data has been written and not yet erased.
Referring to
As shown in
The above-described embodiments of the present invention are intended to be illustrative only. Numerous alternative embodiments may be devised by those skilled in the art without departing from the scope of the following claims.