1. Field of the Invention
The present invention relates to a flash memory, and more particularly, to a flash memory management method for use in a flash memory-based system. The present application is based on Korean Patent Application No. 2001-31124 filed Jun. 4, 2001.
2. Description of the Related Art
Flash memories are a special type of a nonvolatile memory capable of electrically erasing and programming data. Flash memory based storage devices have low power consumption and small size compared to magnetic disc memory based devices. Thus, since flash memories can be substituted for magnetic disk memories, much research and development is actively in progress. Flash memories are expected to receive considerable attention as storage devices for mobile computing devices such as digital cameras, mobile phones, or personal digital assistants (PDAs).
In magnetic disc drives, new data can be written over previous old data. However, in flash memories, a block needs to be erased before it is rewritten with new data; that is, memory cells are returned to an original state in which data can be written. This operation is called “erase”. An erase operation typically requires much more time than a write operation. Furthermore, since the erase operation is performed in blocks whose size is much larger than what the write operation requires, even a portion requested not to be written to may be erased. In this case, the unnecessarily erased portion needs to be reclaimed through a write operation. In the worst scenario, a request to write (overwrite) data requires one erase operation and write operations to recover the portion erased by the erase operation. Due to inconsistency between units on which erase and write commands are executed, write performance is significantly lower than read performance. Furthermore, the write performance of a flash memory is lower than that of a magnetic disc based storage device that inevitably involves a delay due to mechanical operation. Thus, improving write performance is essential in designing a flash memory based device.
U.S. Pat. No. 5,388,083 proposes a content addressable memory (CAM) system for converting a logical address requested by a user to a physical address in a flash memory while avoiding an erase cycle by writing altered data into an empty block in order to prevent a delay due to erase-before-write. However, implementation of the CAM system requires additional costly circuits. U.S. Pat. No. 5,485,595 proposes an approach which involves writing a logical address into an extra region of each page and sequentially comparing each of the logical addresses while avoiding an erase cycle by writing altered data into an empty space upon a write request. However, if a unit of read operation is large like in a NAND-type flash memory, the address conversion mechanism requires a large amount of time in reading address conversion information scattered around the flash memory, thereby degrading system performance.
U.S. Pat. No. 5,845,313 proposes a flash memory storage architecture in which a linear address conversion table for performing a direct address conversion is constructed in a special RAM by scanning a logical address stored in a flash memory during a system reset. However, a RAM of a large storage capacity is required to store the address conversion table. For example, to store an address conversion table of a flash memory based storage device having a storage capacity of 32 MB and a page size of 512 bytes, 128 KB of RAM is required assuming that 2 bytes are provided for each of 65,536 pages. The storage capacity is too large for a small-scale system having few resources such as mobile equipment.
U.S. Pat. No. 5,404,485 proposes an approach for allocating a new block (replacement block) for write operation and writing data to the allocated block. However, since a new block continues to be allocated for write operation, a plurality of different versions of blocks to which the same page is written exist. That is, at least one replacement block needs to be provided for every block, thereby significantly reducing the capacity of a flash memory. A page to be written to a new block must be written at the same position as the position at which the page was written to the previous block. When the page is frequently updated but the remaining pages are rarely updated, only the content of the specific page is changed while the remaining pages contain a plurality of the same replacement blocks, thereby wasting a lot of storage space in a flash memory. Thus, this approach is not suitable for small-scale systems such as mobile equipment.
To solve the above problems, it is an object of the present invention to provide a flash memory based system and management method therefor capable of improving the performance of a flash memory.
It is another object of the present invention to provide a flash memory based system and management method therefor, which allow for consistent data recovery in an emergency such as power cut-off.
It is still another object of the present invention to provide a flash memory based system and management method therefor, which prevent degradation of system performance in an environment where data updates to a specific page are frequently made such as a DOS file system based on a file allocation table (FAT).
Accordingly, to achieve the above objects, the present invention provides a method for writing predetermined data to a flash memory. The method includes the steps of: (a) receiving a request to write the predetermined data to a page to which data has been written; (b) writing the predetermined data to a log block corresponding to a data block containing the page; (c) receiving a request to write the predetermined data to the page again; and (d) writing the predetermined data to an empty free page in the log block.
Preferably, step (b) may include the step (b11) of writing the predetermined data to an empty free page or the steps of (b21) allocating the log block; and (b22) writing the predetermined data to an empty page at the same position as the requested page in the data block.
In another embodiment, a method for writing predetermined data to a flash memory includes the steps of: (a) receiving a request to write the predetermined data to a page; (b) allocating a log block 1-1 corresponding to a first data block containing the page; (c) writing the predetermined data to an empty page in the log block 1-1; (d) receiving a request to write the predetermined data to the page again; and (e) writing the predetermined data to an empty free page in the log block 1-1.
Preferably, step (b) comprises the steps of: (b1) performing a block merge to create a third data block based on a second data block and a second log block corresponding to the second data block; and (b2) allocating a free block obtained by performing an erase operation on the second data block as the log block 1-1.
Preferably, step (b1) is performed when a free block to be allocated as the log block 1-1 does not exist or when all pages of the existing log block corresponding to the first data block have been used.
More preferably, step (b1) may include the step of (b11) performing a switch merge to change the second log block to the third data block when pages of the second log block are arranged in the same order that pages of the second data block are arranged, and the pages of the second log block correspond one-to-one to the pages of the second data block. Step (b1) may include the step of (b12) performing a copy merge to copy corresponding pages of the second data block to free pages in the second log block and create the third data block when the pages in the second log block are requested to be written only once. Step (b1) may include the step of (13) performing a simple merge to copy the latest pages in the second log block to free pages of a free block to which data has not been written and copy a corresponding page of the second data block to the remaining free pages thereof, thereby creating the third data block.
Most preferably, step (e) includes the steps of: (e1) allocating a new log block 1-2 if a free page does not exist in the log block 1-1; and (e2) writing the predetermined data to a free page in the log block 1-2. Step (e1) may include the steps of: (e11) performing a switch merge to change the log block to a second data block when pages of the log block 1-1 are arranged in the order in which pages of the first data block are arranged and the pages of the log block 1-1 correspond one-to-one to the pages of the first data block, and (e12) allocating a free block obtained by performing an erase operation on the first data block as the log block 1-2. Step (e1) may include the steps of (e21) performing a copy merge to copy corresponding pages in the first data block to a free page in the log block 1-1 when pages in the log block 1-1 are requested to be written only once; and (e22) allocating a free block obtained by performing an erase operation on the first data block as the log block 1-2. Step (e1) may include the steps of: (e31) performing a simple merge to copy the latest pages in the log block 1-1 to free pages of a free block and copy a corresponding page of the first data block to the remaining free pages thereof, thereby creating a second data block; and (e32) allocating a free block obtained by performing an erase operation on the first data block or the log block 1-1 as the log block 1-2.
Preferably, step (e2) may include the step of (e21) writing the predetermined data to a free page at the same position as the requested page in the data block.
The present invention also provides a method for reading predetermined data from a flash memory. The method includes the steps of: (a) searching a log pointer table for an entry in which a block address portion of a logical address of a requested page is recorded; (b) checking whether the logical address of the requested page exists in the found entry; and (c) referring to a physical address of a corresponding log block recorded in the found entry and a position at which the logical address of the requested page is written to the found entry and accessing a corresponding page of the log block. Preferably, in step (c), the corresponding page in the log block is accessed at the same position as the position to which the logical address of the requested page is written to the found entry.
The present invention also provides a method for managing a flash memory including a data block and a log block for writing data for updating the data block. The method includes the steps of (a) when pages of a first data block are arranged in the same order in which pages of a first log block corresponding to the first data block are arranged and all the pages of the first data block map one-to-one with the pages of the first log block, changing the first log block to a second data block; and (b) updating address conversion information.
In another embodiment, a method for managing a flash memory including a data block and a log block for writing data for updating the data blocks includes the steps of: (a) when pages in a first log block are requested to be written only once, copying a corresponding page of a first data block to a free page of the first log block in order to create a second data block; and (b) updating address conversion information.
In another embodiment, a method for managing a flash memory including a data block and a log block for writing data for updating the data block includes the steps of: (a) copying the latest pages in a first log block to a free block to which data has not been written and copying a corresponding page of a first data block corresponding to the first log block to a remaining free page to create a second data block; and (b) updating address conversion information.
Preferably, prior to step (a), the flash memory management method further includes the step of (a0) writing recovery information for recovering data in the event of a system failure during the step (a) or (b).
Preferably, the flash memory management method further includes the step of (c) recovering data referring to the recovery information in the event of a system failure during the step (a) or (b).
The recovery information includes a list of free blocks, a list of log blocks, and a log pointer table which is the data structure for managing the log blocks. The log pointer table contains log pointer table entries corresponding one-to-one to the log blocks, each entry mapping a physical address of a log block to a logical address of a corresponding data block and storing logical addresses of requested pages of a data block in the order in which pages of a corresponding log block are physically arranged.
In another embodiment, a method for managing a flash memory including a data block and a log block for writing data for updating the data blocks includes the steps of: (a) allocating a predetermined region to a flash memory and writing lists of data blocks and log blocks and a data structure for managing the log blocks to the predetermined region as recovery information; (b) checking states currently being written to the flash memory based on the recovery information in the event of a system failure to determine whether an error occurs; and (c) if the error occurs, recovering data based on the recovery information.
The above objects and advantages of the present invention will become more apparent by describing in detail preferred embodiments thereof with reference to the attached drawings in which:
Referring to
Referring to
Referring to
The log pointer table refers to a data structure for managing log blocks. The log pointer table contains a logical address of a data block, a physical address of a corresponding log block, and offset values (a logical address of a requested page) of updated pages in the corresponding data block arranged in the same order in which pages in the log block are physically arranged. According to the present invention, the processor 4 scans a log block region to construct the log pointer table in the RAM 3. Referring to
For example, assuming that a block contains sixteen pages and a logical address is 02FF (hexadecimal number), the first three digits “02F” denote a block address and the last digit “F” denotes an offset value of a requested page in a log block. Thus, a check is made as to whether 02F exists among logical addresses log_blk stored in the logical pointer table to confirm the presence of a corresponding log block. If the corresponding log block exists, it is checked whether the logical address 02FF of the requested page or the offset value F is recorded in the corresponding entry to locate an updated page in the log block. For example, if page #0 is F, the requested page is recorded in the first physical page in the log block.
In this way, a portion of a requested logical address, that is, a block address portion thereof, is used to check whether a log block exists and access the block. This technique is called “block addressing”. Then, the entire logical address being requested or an offset value is used to access a page in the corresponding log block, which is called “page addressing”. Thus, the present invention adopts both block addressing and page addressing to enable the same page updated many times to be recorded in one log block.
Basically, updated pages are written to the log block at the same positions as those at which the corresponding pages are located in the data block. Actually, if an updated page is first written to the log block, the updated page may be written at the same position as the corresponding page of the data block. However, if the updated page is to be updated again, it is not always possible to be written at the same position as the corresponding page of the data block. That is, if the predetermined page in the corresponding data block is updated once again before updating the remaining pages in the data block once, the predetermined page is written to an empty space of the log block.
Meanwhile, the present invention involves performing a block merge. The block merge is performed when a write operation is repeated so that a page that can be written does not exist in the log block. In this case, the log block and the corresponding data block are merged to create a new data block while erasing the previous log block to be a free block. In particular, a block merge performed when all pages in a data block are updated only once to arrange the pages in the data block in the order in which pages are located in the log block is called a “switch merge”.
In contrast, if the page arrangement in a log block is not the same as that in a corresponding data block, a simple merge is performed. Furthermore, the simple merge is performed when all pages of the log block are currently written or read so a new log block needs to be allocated for a newly requested write operation. In this case, the log block to be merged may have a free page.
If all the pages in a log block are updated only once, empty pages are filled with corresponding pages of a data block to change the log block to the data block. This is called a “copy merge”. That is to say, there are three types of block merges; a switch merge, a simple merge, and a copy merge.
As described above with reference to
As shown in
As shown in
To perform a block merge, lists for free blocks and erasable blocks residing in the flash memory 1 are required. The lists for free blocks and erasable blocks refer to a data structure recorded in the RAM 3 along with a log pointer table. The lists may be recorded in the map region and the check point region of the flash memory 1.
A list of free blocks, a list of erasable blocks, and a log pointer table must be reconstructed in the RAM 3 during a system reset. The check point region is allocated according to an embodiment of the present invention for recording recovery information required for quick and thorough recovery of these data structures. If the check point region is provided, the list of free blocks, the list of erasable blocks, and the list of log blocks described above are stored in the check point region as recovery information. In particular, the check point region also stores a plan log that lists which type of block merge is to be performed and changes in blocks as a result of the block merge in order to prevent loss of information due to an overwhelmed system, unexpected power outage and the like, which may occur during the block merge. More specifically, the plan log contains the type of block merge to be performed, and physical addresses of a block changed from a free block to a data block, of a block changed from a data block to a free block, and of a block changed from a log block to a free block.
Furthermore, the check point region stores information necessary for construction of the address conversion information such as a location where address conversion information is stored. The location of the check point region itself is recorded in a predefined block in the flash memory 1.
Based on the above configurations, a method for flash memory management according to a preferred embodiment of the present invention will now be described. For ease of understanding, the flash memory management method is divided into a method of constructing and reconstructing a data structure upon a system startup, a method for reading data from the flash memory 1, and a method for writing data to the flash memory 1.
First, a flash memory management method used during a system startup means a method for constructing or reconstructing a data structure. That is, the method involves constructing address conversion information as well as data structures including a list of free blocks, a list of erasable blocks, a list of log blocks, and a log pointer table for write and read operations, and examining the integrity of the constructed information to reconstruct the data structures based on recovery information if reconstruction is needed. When the system of
The log pointer table is constructed by scanning all pages of each log block designated in the recovery information to read a logical address stored in a logical block address portion for each page. Since the map region also sequentially stores address conversion information, a lastly written page (the page immediately before a first free page) is considered to be changed most recently, and address conversion information can be constructed based on the lastly written page. The free block list and the erasable block list can also be readily reconstructed based on the recovery information.
Next, the constructed information including the log pointer table and the lists of free blocks, erasable blocks and log blocks is verified by referring to a plan log. That is, it should be verified whether the constructed information is the same as real conditions when the operation of the system is stopped during a block merge. More specifically, if the system ceases to operate upon writing recovery information to the check point region, upon performing a block merge, upon updating address conversion information in the map region, and upon performing an erase operation, verification is needed. For each case, it is checked whether the constructed information is consistent with real conditions, and if not, the constructed information is reconstructed as follows:
1. When the system ceases to operate upon writing recovery information to the check point region, a first free page from the recovery information written in the check point region is located to check whether the found page is actually an empty page by reading data stored therein. If the free page is not empty, it is determined that the system ceased to operate while writing recovery information to the check point region. Since this occurs before actually writing data, it is not necessary to perform a recovery procedure, and finally recorded recovery information is ignored.
2. When the system ceases to operate during a block merge, it is checked whether data has been properly written to all pages of a block listed in the plan log as a block to be changed to a data block. If a page, if any, is not valid, it is determined that the system ceased to operate during a block merge. In this case, a block merge is performed again to recover data appropriately.
3. When the system ceases to operate while updating address conversion information, a logical address is read from a block listed in the plan log as a block to be changed to a data block to check whether the logical address is consistent with the information stored in the map region. If not, it can be determined that the system ceased to operate while updating the address conversion information. In this case, data can be appropriately recovered by modifying the address conversion information based on the logical address read from the data block and a corresponding physical address.
4. When the system ceases to operate during an erase operation, it is checked whether blocks listed in the plan log as a block to be changed to a free block are actually empty blocks. If a block is a not free block (if all pages in the block are not empty), an erase operation is performed on the written block again.
When required data structures are constructed and then integrity verification is completed in the manner previously described through a flash memory management method used upon system startup, read and write operations can be performed.
More specifically, the processor 4 searches a log pointer table for an entry based on a logical address of a page being requested (step 1401). If the entry is found (step 1402), which means that a log block corresponding to the logical address exists, an entry is searched to check whether a page having the same offset value as the requested page is usable (step 1403). If the page is usable, a write operation is performed on the corresponding page (step 1404). Here, the usable page refers to an empty page (free page) that has not been written to. The presence of a free page can be determined by whether a page is valid (the page is firstly referred to or data is written to the page). Next, a physical address of the page on which the write operation has been performed corresponding to the logical address is written to the corresponding entry of the log pointer table. In this case, the write request by the user is completed by one write operation in the flash memory 1.
If the corresponding log block is found, but the page having the same offset has been used (step 1403), it is checked whether another free page in the log block can be allocated (step 1406), and a write operation is performed on the allocated free page (step 1407). If two or more free pages exist, the log block is sequentially searched from the start to allocate a page closest to the page corresponding to the requested page to which data have been already written. Then, a physical address of the allocated page corresponding to the logical address of the requested page is written to the corresponding entry of the log pointer table (step 1405).
If an entry corresponding to the requested page is not found as a result of searching the log pointer table, it is checked whether a new log block can be allocated (step 1408). If free blocks to be allocated as the new log block exist, one of the free blocks is allocated as the new log block (step 1408). If a free block does not exist, the free block is created by performing a block merge and then allocated as the new log block (step 1409). A write operation is performed on a page in the allocated log block having the same offset value as the requested page (step 1410). Then, a corresponding entry is created in the log pointer table (step 1405).
If any pages in the log block are not arranged at the same position as a corresponding page of the data block, a simple merge is performed. Similarly, the processor 4 writes recovery information to the check point region before performing a simple merge (step 1506). The step 1506 may be omitted according to the choice of the system designer. Then, free blocks are allocated to copy valid pages of the log block to some of the free blocks (step 1507). Corresponding pages of the data block are copied to the remaining free blocks (step 1508). Address conversion information in the map region is updated so that the free blocks are new data blocks (step 1509). The allocation of free blocks is made in the manner described with reference to
If all pages of the log block are arranged in the same manner in which those of the data block are arranged but some of the pages in the data block do not exist in the log block, a copy merge is performed. Similarly, the processor 4 writes recovery information to the check point region before performing a copy merge (step 1511).
The step 1511 may be omitted according to the choice of the system designer. Then, valid pages of the data block are read to copy them to the log block (step 1512). Address conversion information stored in the map region is updated so that the log block is a new data block (step 1504), and then the data block is erased and a free block list stored in the check point region is updated (step 1505).
In this way, if the log block for updating data is not found, a free block is allocated, the free block is changed to a log block, and writing to the log block is performed. If only one free block remains so it is not allocated as a log block, one of the existing log blocks is arbitrarily selected to perform a block merge, thereby creating a new free block. Then, the free block is allocated as a log block. In this invention, costs required for a block merge and usability of blocks should be appropriately considered. The usability of blocks may vary depending on the type of application program to be executed. Replacement algorithms may not be specified in this invention. Thus, the present invention may be implemented using common replacement algorithms such as least recently used (LRU).
As described above, the present invention provides a method for flash memory management for improving the performance of a flash memory. Conventionally, in order to update a part of one data block, the remaining parts are also copied or a large amount of address conversion information is needed. However, the present invention allows the same page to be continuously updated within one log block, thereby improving the effectiveness of flash memory resources. Furthermore, the present invention allows data to be recovered consistently in the event that a system malfunctions due to power outage during a block merge.
Number | Date | Country | Kind |
---|---|---|---|
2001-31124 | Jun 2001 | KR | national |
This application is a divisional reissue application of U.S. Pat. No. 6,938,116, issued on Aug. 30, 2005, and filed on Dec. 31, 2001 as U.S. patent application Ser. No. 10/029,966. Notice: More than one reissue application has been filed for the reissue of U.S. Pat. No. 6,938,116. The reissue applications are application Ser. No. 11/848,005, filed on Aug. 30, 2007 (issued as U.S. Pat. No. Re. 44,052 on Mar. 5, 2013), application Ser. No. 13/134,225 filed Jun. 2, 2011 (the present divisional reissue application of which the Ser. No. 11/848,005 application is the parent); and application Ser. No. 13/151,735 filed Jun. 2, 2011 (a divisional reissue application filed concurrently herewith and also of which the Ser. No. 11/848,005 application is the parent).
Number | Name | Date | Kind |
---|---|---|---|
5226133 | Taylor et al. | Jul 1993 | A |
5388083 | Assar et al. | Feb 1995 | A |
5404485 | Ban | Apr 1995 | A |
5479638 | Assar et al. | Dec 1995 | A |
5485595 | Assar et al. | Jan 1996 | A |
5528764 | Heil | Jun 1996 | A |
5530828 | Kaki et al. | Jun 1996 | A |
5696929 | Hasbun et al. | Dec 1997 | A |
5717886 | Miyauchi | Feb 1998 | A |
5745418 | Ma et al. | Apr 1998 | A |
5778427 | Hagersten et al. | Jul 1998 | A |
5802554 | Caceres et al. | Sep 1998 | A |
5845313 | Estakhri et al. | Dec 1998 | A |
5860083 | Sukegawa | Jan 1999 | A |
5933368 | Ma et al. | Aug 1999 | A |
5937425 | Ban | Aug 1999 | A |
5956473 | Ma et al. | Sep 1999 | A |
5999446 | Harari et al. | Dec 1999 | A |
6000006 | Bruce et al. | Dec 1999 | A |
6263398 | Taylor et al. | Jul 2001 | B1 |
6298428 | Munroe et al. | Oct 2001 | B1 |
6327638 | Kirby | Dec 2001 | B1 |
6327639 | Asnaashari | Dec 2001 | B1 |
6418506 | Pashley et al. | Jul 2002 | B1 |
6564286 | DaCosta | May 2003 | B2 |
6587915 | Kim | Jul 2003 | B1 |
6704835 | Garner | Mar 2004 | B1 |
6760805 | Lasser | Jul 2004 | B2 |
6836816 | Kendall | Dec 2004 | B2 |
20010040827 | Dosaka et al. | Nov 2001 | A1 |
20020002652 | Takahashi | Jan 2002 | A1 |
20020002654 | Tomohiro | Jan 2002 | A1 |
20020144059 | Kendall | Oct 2002 | A1 |
20020166022 | Suzuki | Nov 2002 | A1 |
20050144358 | Conley et al. | Jun 2005 | A1 |
Number | Date | Country |
---|---|---|
05-241741 | Sep 1993 | JP |
05-282889 | Oct 1993 | JP |
07-154870 | Jun 1995 | JP |
09-097205 | Apr 1997 | JP |
10-040175 | Feb 1998 | JP |
2001-521220 | Nov 2001 | JP |
WO 9921093 | Apr 1999 | WO |
Entry |
---|
Jim Handy, The Cache Memory Book, Academic Press, 1993, pp. 1-107 and 240-269. |
Number | Date | Country | |
---|---|---|---|
Parent | 11848005 | Aug 2007 | US |
Child | 10029966 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 10029966 | Dec 2001 | US |
Child | 13134225 | US | |
Parent | 10029966 | Dec 2001 | US |
Child | 11848005 | US |