A kind of management method of Nand-Flash storage system
Technical field
The present invention relates to the management method of computer memory system, relate in particular to the management method of computing machine Nand-Flash (nonvolatile flash memory) storage system.
Background technology
The Nand-Flash storage system is a kind of nonvolatile flash memory storage system, the Nand-Flash storage system has very fast writing and erasing speed, major function is a data on file, and it has obtained using widely in hand-held moving devices such as U-dish, digital camera, MP3, MP4, mobile phone, GPS receiving trap.
Traditional Nand-Flash storage system is mainly based on single layer cell (SLC, be Single LayerCell) storage system of Flash device, but the improvement along with the Flash device technology in nearly 2 years, not only original Nand-Flash storage system based on single layer cell (SLC) Flash device has had variation in access control, also occurred novel based on multilevel-cell (MLC, be Multiple Layer Cell) the Nand-Flash storage system of Flash device, and, will substitute Nand-Flash storage system based on single layer cell (SLC) Flash device because the latter has the capacity advantage of twice under identical cost.Conventional monolayers unit F lash device with based on multilevel-cell (MLC) Flash device a great difference is arranged all on physical interface and bulk properties, so the memory management method of traditional flash device stores system all can not adapt with novel Flash device on speed and stability.For example, prior art is about in the management method based on the Nand-Flash storage system of single layer cell (SLC) Flash device, used forward direction chained list and page or leaf to replace the technology that writes, realize the logical physical address translation of flash memory, the weak point of this technology is: wherein use the part that physical page just must take place the forward direction chained list to write and write once more, can not make the physical page one-time write; And the technology that use therein page or leaf replacement writes can cause the non-order of the page in the same physical block to write.In novel Nand-Flash memory management method based on multilevel-cell (MLC) Flash device, the non-order of the page that the part of the above-mentioned page writes and writes once more and same physical block is interior writes such visit and is subjected to strict restriction, because it can't guarantee the integrality of data.
Summary of the invention
The present invention is directed to deficiency of the prior art, a kind of management method of the Nand-Flash storage system based on multilevel-cell (MLC) Flash device is provided, it can satisfy the requirement of physical page one-time write, can guarantee that again the page in the same physical block writes in order, thereby when realizing the logical physical address translation of flash memory, can guarantee the integrality of data.
The present invention is achieved by the following technical solutions:
A kind of management method of Nand-Flash storage system, dynamically a plurality of physical blocks are corresponded to a logical block, each physical block is regarded as a node, the sequence number of node is exactly the piece number of this physical block, N physical block or N node of corresponding same logical block connect into a doubly linked list---logical block chained list according to sequencing; At the extended area of first Physical Page of each physical block, deposit the piece number of the pairing logical block number (LBN) of this physical block and this physical block pairing physical block of previous node in the logical block chained list respectively; When system initialization,, reconstruct described logical block chained list by the above-mentioned information of depositing; When the module operate as normal, carry out the data write operation according to described doubly linked list: when this Nand-Flash storage system is carried out write operation, the logical block chained list is carried out forward lookup; When this Nand-Flash storage system is carried out read operation and reclaimer operation, the logical block chained list is carried out reverse search; When described read operation, write operation and reclaimer operation, logical page number (LPN) is identical with physical page number, does not do other mapping; It is full that each physical block can be write entirely, also can be write by the part, and be physical page number order from small to large but must satisfy the order that the part writes page or leaf;
Described logical block number (LBN) be meant module faces as the upper strata call the virtual piece that comes out number, wherein module is meant that whole Nand-Flash management system is the block device of a standard at upper system, promptly be unit with the piece, the memory device of each unit for reading and writing separately; Described logical page number (LPN) is meant the page number of logical address correspondence in logical block; Described physical page number is meant the page number in the Nand-Flash storer physical block, belongs to the numbering that is used for addressing in the memory block of Nand-Flash management system.
Further, according to described doubly linked list when carrying out the write operation of data, described that the logical block chained list is carried out the concrete steps of forward lookup is as follows:
(1), the physical page number that each logical page (LPAGE) is write is consistent with logical page number (LPN);
(2), each physical block in the logical block chained list can write fullly entirely, also can be written into the part, but all pages or leaves that must satisfy last page or leaf front that is written into of each physical block also is written into, all pages or leaves of its back all are free page.
When (3), carrying out the write operation of data according to described doubly linked list, search from front to back in the logical block chained list of described doubly linked list correspondence, as long as find on this logical block chained list maximum first physical block that has used the logical page number (LPN) that physical page number ask less than institute and write, to write data with the logical page number (LPN) of asking to write be the Physical Page of identical page number with regard to direct; If the logical page number (LPN) that request writes has used physical page number less than the maximum of last physical block of this logical block chained list, then on the logical block chained list, newly add an idle physical block, all active page data before the logical page (LPAGE) that writes of ask are copied in the current new idle physical block corresponding physical page, on the identical Physical Page of the logical page (LPAGE) page number that writes of ask, write data again.
More particularly, when carrying out the write operation of data according to described doubly linked list, search from front to back in the logical block chained list of described doubly linked list correspondence, when on this logical block chained list, finding maximum first physical block that has used physical page number less than the page number of ask to write logical page (LPAGE), directly data are write this physical block as follows: the above maximum of this physical block used physical page number and ask to write all page space between the page number of logical page (LPAGE), duplicate and insert this physical block data on the respective physical page in the pairing physical block of previous node in the logical block chained list, and then write data on the pairing Physical Page of logical page number (LPN) asking to write; Perhaps, when carrying out the write operation of data according to described doubly linked list, search from front to back in the logical block chained list of described doubly linked list correspondence, if all physical block maximums used physical page number all greater than ask the logical page number (LPN) that writes, then in the logical block chained list, newly add an idle physical block, as follows data are write this free time physical block: all page space before asking to write logical page (LPAGE), duplicate and insert this free time physical block data on the respective physical page in the pairing physical block of previous node in the logical block chained list, and then write data on the pairing Physical Page of logical page number (LPN) asking to write.
Further, according to described doubly linked list when carrying out the read operation of data, described that the logical block chained list is carried out the concrete steps of reverse search is as follows:
In the logical block chained list of described doubly linked list correspondence, search for forward after oneself, find first maximum to use physical page number to be not less than the physical block of the read operation logical page number (LPN) of current request, be and effectively read the target physical piece, on this target physical piece, read the physical page number identical, promptly obtain desired data with the read operation logical page number (LPN) of current request.
When the length of a logic surpasses the threshold value set or system and needs how available idle physical block, carry out reclaimer operation, it is described that the logical block chained list is carried out the concrete steps of reverse search is as follows:
At first in doubly linked list, find last physical block on the logical block chained list, again the penult physical block from this logical block chained list begin from after block-by-block reverse search forward, and by following copy data: suppose that last physical block uses the N page or leaf, first free page of penult physical block is M page or leaf (M>N+1), the N+1~M-1 page or leaf correspondence of penult physical block is copied to the N+1~M-1 page or leaf of last physical block; Seek previous maximum then successively and used the physical block of physical page number more than or equal to M, continuation is duplicated the corresponding page or leaf of its data to last physical block at the corresponding page or leaf of this physical block as stated above again, copies to till first free page of this physical block; Draw analogous conclusions, till the maximum of first physical block on the logical block chained list has used Physical Page to be copied to the corresponding page or leaf of last physical block, at last, discharge all physical blocks that remove last physical block of former logical block chained list.
In the technique scheme:
Described physical block number is meant the piece number (belonging to the numbering that is used for addressing in the memory block of Nand-Flash management system) of the Nand-Flash physical equipment that this module is managed;
The logical block chain is meant that same logical block is corresponding with it by a plurality of physical blocks, the virtual from front to back chain structure that connects into of these physical blocks;
Described doubly linked list is meant the physical block number mapping table of depositing in internal memory, this table is to be rebuild by the logical block number (LBN) of the extended area that is stored in each page of Nand-Flash and forward substitution physical block number information to draw;
Described logical page number (LPN) is meant the page number of logical address correspondence in logical block; Such as, needing the logical address of visit is 0x00201000, the physical block size of supposing this Nand-Flash is 256KB, the page or leaf size is 2KB, then that logical address 0x00201000 correspondence is the 8th the 2nd page (0x00201000=256K*8+2K*2), we claim that the logical block number (LBN) of this logical address correspondence is 8, and logical page number (LPN) is 2.This logical block number (LBN) 8, but when read-write, may correspond to different physical blocks, so-called logical page number (LPN) is consistent with physical page number to be meant, and no matter this logical address corresponds to that physical block, and its corresponding physical page number is always 2, and is consistent with logical page number (LPN).
Described first Physical Page is meant: the storage area of each Nand-flash management system is divided into the N physical block, each piece is divided into the X page or leaf again, and each page or leaf is divided into two parts zone, and a part is common data field, the block of information that another part is, but two zones store data all.First page of each physical block that first Physical Page just is meant.
The described target physical piece that effectively reads is meant in a logical block chained list, stored that physical block of certain target logic page or leaf valid data; The target logic page number is meant that the upper strata sends the page number of read-write requests, the just whole logical page number (LPN) that fictionalizes to the upper strata, but not the real physical page number of bottom, because the mapping one by one that this algorithm uses in logical page (LPAGE) and Physical Page mapping, so logical page number (LPN) and physical page number equate;
Described idle physical block is meant the available physical block that does not participate in certain logical block chained list;
Described active page data are meant the data in that Physical Page of these logical page (LPAGE)s correspondence when reading.
The invention has the advantages that:
When carrying out write operation with the present invention, it can satisfy the requirement of physical page one-time write, can guarantee that again the page in the same physical block writes in order, thereby when realizing the physical address translations of flash memory, can guarantee the integrality of data.
When carrying out read operation, all in internal memory, finish,, reduced the time delay that reads so significantly reduced the time of search because the position is read in search with the present invention.For the MLC-Flash device chip, under (SuSE) Linux OS, behind the adding RS-ECC algorithm (reed-solomon algorithm), read file speed in application layer and can reach 3MB/s~5MB/s.Though the present invention seems that to writing at random efficient is not high, writing for generally order to have fast speeds, and the file writing speed that has added the RS-ECC algorithm in application layer can reach 0.8MB/s~1.5MB/s equally.
Utilize the advantage of above-mentioned doubly linked list and " bidirectional research " technology to be to satisfy the requirement of physical page one-time write, if, take place 2 times and write same physical page only with the forwarding pointer search.Why adopting " directly reproduction technology ", is because only in this way could neither influence speed, guarantees that simultaneously the order that satisfies page or leaf in same writes.Above-mentioned two kinds of technology combine the requirement that could satisfy data integrity.
Description of drawings
Fig. 1 makes up the synoptic diagram of the reverse chained list embodiment 1 of internal memory for the present invention;
Fig. 2 is the synoptic diagram by the internal memory doubly linked list of embodiment 1 structure;
Fig. 3 makes up the synoptic diagram of the reverse chained list embodiment 2 of internal memory for the present invention;
Fig. 4 is the synoptic diagram by the internal memory doubly linked list of embodiment 2 structures;
Fig. 5 is the synoptic diagram of write operation embodiment 1 of the present invention;
Fig. 6 is the synoptic diagram of write operation embodiment 2 of the present invention;
Fig. 7 is a read operation embodiment synoptic diagram of the present invention;
Fig. 8 is the synoptic diagram of page or leaf reclaimer operation among the present invention.
Embodiment
Below in conjunction with description of drawings the specific embodiment of the present invention.
(1), make up doubly linked list:
The synoptic diagram of Fig. 1 reverse chained list embodiment 1 for the present invention makes up.See Fig. 1, the inventive method with physical block 7 and logical block number (LBN) M of physical block 9 common corresponding expressions, forms one by physical block 7 and physical block 9 virtual logical block chained list (the LBC)-M that connect and compose dynamically.Two districts about physical block 7 is divided into by vertical line among Fig. 1, left side district is the normal storage district of data, right district is extended area; Physical block 7 is divided into two districts up and down by horizontal line among Fig. 1, and last district is the storage area of first Physical Page in the physical block 7, and inferior segment is the storage area of all the other Physical Page, and white area is idle storage area.The diagram of physical block 9 is identical.Deposit the pairing logical block number (LBN) M of this physical block respectively and the piece numbers 7 of its previous physical block (claiming the forward substitution physical block again) in the logical block chained list at the extended area 10 of first Physical Page of physical block 9, reverse strand additional information (M, 7) as physical block 9; The extended area 10 of first Physical Page of physical block 7 also deposited it the logical block number (LBN) M of corresponding expression, because physical block 7 is first of logical block M, so his forward substitution physical block number is a special marking HEAD, to represent that this piece is first on the logical block M, thus the reverse strand additional information of physical block 7 be (M, HEAD).Among Fig. 1 to Fig. 8, the curved arrow of top is represented the orientation of forward substitution physical block between the physical block.
Why will be in the Nand-Flash storage system extended area 10 of first Physical Page of each physical block, deposit the forward substitution physical block number respectively, be because have only the forward substitution of use physical block number, could satisfy requirement based on the physical page one-time write of the Nand-Flash storage system of novel multi-layer unit (MLC) Flash device, if use the back to replacing physical block number, which piece the back of current block that then do not know for sure when writing data is to replacing physical block actually, must wait until that next piece just writes the back to the information of replacing physical block when distributing, therefore the situation that just unavoidable generation writes once more, this has brought bigger risk to the data integrity that guarantees Nand-Flash.The inventive method has been avoided such risk fully.
When system initialization, the above-mentioned reverse strand additional information (M that deposits on physical block 9 and the physical block 7 in the complete search Nand-Flash storer, 7) and (M HEAD), can reconstruct the complete reverse chained list corresponding with described logical block chained list (LBC)-M.
Embodiment 1, see Fig. 1, when system initialization, at first search physical block 9, obtaining its represented logical block number (LBN) is M, its forward physical piece number is 7, when reading the forward substitution physical block number of physical block 7, be found to be the HEAD mark, then the search to logic M piece chain finishes, and obtains the reverse chained list of internal memory of logic M piece chain (LBC)-M: 9-〉7, construct the internal memory forward chained list of logic M piece chain (LBC)-M: 7-again according to the reverse chained list of this internal memory〉9, and then constitute the internal memory doubly linked list of complete logic M piece chain (LBC)-M: 7<-9, as shown in Figure 2, Fig. 2 is the synoptic diagram of the internal memory doubly linked list that made up by the foregoing description 1.
Embodiment 2, and Fig. 3 makes up the synoptic diagram of the reverse chained list embodiment 2 of internal memory for the present invention.See Fig. 3, when system initialization, at first search physical block 4, obtaining its represented logical block number (LBN) is K, its forward substitution physical block number is 8, then physical block 8 is being searched for, the forward substitution physical block number that obtains it is 5, be found to be the HEAD mark when reading 5 forward substitution physical block number again, then the search to logic K piece chain finishes, obtain the reverse chained list of internal memory of logic K piece chain (LBC)-K: 4-〉8-〉5, construct the internal memory forward chained list [K] of logic K piece chain (LBC)-K: 5-again according to reverse chained list〉8-〉4, and then constitute the internal memory doubly linked list [K] of complete logic K piece chain (LBC)-K: 5<-8<-4, as shown in Figure 4, Fig. 4 is the synoptic diagram of the internal memory doubly linked list that made up by the foregoing description 2.
(2), carry out the data write operation according to described internal memory doubly linked list:
When the module operate as normal, carry out the data write operation according to the internal memory doubly linked list.
1, write operation
When carrying out the write operation of data by doubly linked list, concrete steps are as follows:
(1), the physical page number that writes of each logical page (LPAGE) is consistent with logical page number (LPN).Fig. 5 is the synoptic diagram of the write operation embodiment 1 of page or leaf mapping of the present invention, and the pairing doubly linked list of being made up of physical block 7, physical block 5 and physical block 13 shown in Fig. 5 of virtual logical block chained list (LBC) is 7<-5<-13.The Physical Page of oblique line district among Fig. 5 for having used or write, the Physical Page of clear area for not using or do not write, vertical separatrix in the oblique line district is the separatrix in general memory area (left part) and extension storage district (right part), the UsedPage[7 of physical block 7 belows among Fig. 5]=first free page of 128 expression volume physical blocks 7, page number is 128, UsedPage[5]=111 and UsedPage[13]=46 roughly the same.See Fig. 5, logical page number (LPN) is 110, then writes the position of the 110th page of physical page number (black region) in corresponding physical block 5.The physical page number that each logical page (LPAGE) writes is consistent with logical page number (LPN), is to make reading speed reach the design of the fastest a kind of direct mapping, can save the time of search page position like this.
(2), in the logical block chained list among Fig. 5, each physical block can be write full entirely, also can be written into the part, but all pages or leaves of front that must satisfy last page or leaf that is written into of each physical block were written into, all pages or leaves of its back all are free page, as the 127th page of physical block among Fig. 57,70 pages of physical block 5 and all pages or leaves of 45 pages front of physical block 13 were written into, all pages or leaves of its back all are free page, this is the novel regulation of Nand-Flash storage system to writing based on multilevel-cell MLC-Flash device, must write in order in a certain, otherwise can make mistakes when writing data.
(3), write operation (forward lookup):
When a write request takes place, comprise that (logical block number (LBN) shown in Fig. 5 is 2 to the logical block number (LBN) that writes of request, physical block 7, physical block 5 and physical block 13 are jointly corresponding to logical block number (LBN) 2), the data that logical page number (LPN) (being 110 among Fig. 5) that request writes and request write, the logical block chained list of the logical block number (LBN) 2 that writes according to request and the logical page number (LPN) 110 that request writes, on the logical block chained list corresponding with doubly linked list 7<-5<-13, successively according to 7-〉5-〉13 order each physical block of forward lookup (logical physical piece 7 among Fig. 5 for example from front to back, logical physical piece 5 and logical physical piece 13) employed number of physical pages, find use number of physical pages less than first physical block of asking to write logic number of pages 110 be physical block 5, just directly data are write as follows this physical block 5 ask to write logical page (LPAGE) 110: at this physical block 5 the above used physical page number 70 and all the page space 71-109 page numbers between the logical page number (LPN) 110 asking to write, duplicate the data on the Physical Page of respective page space 71-109 page number in the forward physical piece 7 of inserting this physical block, and then write the data of current request on the logical page number (LPN) 110 asking to write.
If the logical page number (LPN) that request writes is less than the use physical page number of last physical block of this logical block chained list, replace physical block for then newly-built again one, in all page space between 0 logical page number (LPN) that writes to this request on the newly-built replacement physical block, duplicate the valid data of corresponding page or leaf in the forward physical piece of inserting this newly-built replacement physical block, the page number that writes in request writes the data of current request then; Fig. 6 is the synoptic diagram of write operation embodiment 2 of the present invention, see Fig. 6, the page number of asking to write is 31 (black regions), it is less than the use number of pages 45 of last physical block 13 of this logical block chained list, replace physical block 1 for then newly-built one, add in this logical block chained list (LBC), at all page space 0-30 pages or leaves between 0 page number 31 that writes to this request on the newly-built replacement physical block 1, duplicate the data of inserting 0-30 page or leaf in its forward physical piece 13, shown in the stain district on blank arrow among Fig. 6 and the replacement physical block 1.The last page number 31 that writes in request again writes the data that current request writes.32 pages of physical block 1 are the free area.
2, read operation (reverse search):
When carrying out the read operation of data by doubly linked list, concrete steps are as follows:
The employed number of physical pages of each physical block of reverse search from back to front in the logical block chained list of described doubly linked list correspondence, find first (because the data in last are the valid data, in the past all be invalid data) write the physical block that number of pages is not less than current request read operation logical page number (LPN), be and effectively read the target physical piece, the logical page number (LPN) of physical page number that reads on the target physical piece and current request read operation is identical (because be the technology of directly duplicating in the page or leaf that adopts, so physical page number is identical with logical page number (LPN), one to one).
Fig. 7 is a read operation embodiment synoptic diagram of the present invention, see Fig. 7 embodiment, when the read operation logical page number (LPN) of being asked is the 52nd page, at first find the logical block chained list [2] corresponding: 7<-5<-13<-1 with logical block 2 doubly linked lists, each physical block of reverse search (physical block among Fig. 71 for example from back to front, physical block 13, physical block 5 and physical block 7) employed logic number of pages, finding first to write number of pages is 61 (62 expression free page), be not less than the physical block 13 of 52 pages of current request read operation logical page number (LPN)s (second arrow line shown in), it is and effectively reads the target physical piece, read the 52nd Physical Page (identical) of physical block 13, promptly obtain required reading of data with current request read operation logical page number (LPN) 52.In like manner, from Fig. 7 as seen, first has write number of pages 45, has been not less than the physical block 1 of current request read operation logical page number (LPN) 30, and it is and effectively reads the target physical piece, reads the 30th Physical Page of physical block 1, promptly obtains required reading of data; First has write number of pages 70, has been not less than the physical block 5 of current request read operation logical page number (LPN) 70, and it is and effectively reads the target physical piece, reads the 70th Physical Page of physical block 5, promptly obtains required reading of data; First has write number of pages 127, has been not less than the physical block 7 of current request read operation logical page number (LPN) 120, and it is and effectively reads the target physical piece, reads the 120th Physical Page of physical block 7, promptly obtains required reading of data.
3, reclaimer operation (reverse search)
Oversize when a logical block chained list (LBC), as surpass to set threshold value when perhaps system needs how available idle logical block, is carried out reclaimer operation, and concrete steps are as follows:
Fig. 8 is the synoptic diagram of page or leaf reclaimer operation among the present invention, see Fig. 8, at first in doubly linked list, find last physical block 1 on the logical block chained list (LBC), suppose that existing 18 pages of Physical Page write data on the physical block 1, penult physical block from this logical block chained list (LBC) again, from after block-by-block reverse search forward, and by following copy data: 19 pages by penult physical block 13 begin to be copied to physical block 1, copy to (promptly till the page or leaf 45) till first free page (UsedPage) of this physical block because page or leaf 46 is a free page; Seeking previous maximum has then used physical page number greater than the current physical block that has duplicated number of pages, found previous physical block 5, its use number of pages is 70, greater than the current number of pages 45 of having duplicated, so the 46th page from physical block 5 begins to continue copy data to physical block 1, till before first free page 71 of physical block 5, promptly copy to page or leaf 70, to the last all pages or leaves of one all are filled (promptly copied to last page to a certain physical block---for example the physical block of front has copied to last page 127), shown in the data that the arrow on the physical block among Fig. 81 and each zone write, just finished the replication work of recovery this moment.At last, discharge (wiping) former logical block chained list (LBC) all physical blocks except last physical block 1, i.e. physical block among Fig. 87, physical block 5, physical block 13.
The inventive method had both satisfied the requirement that novel Nand-Flash memory management method based on multilevel-cell (MLC) Flash device must write in proper order to the page or leaf of all physical blocks, on to greatest extent, reduced the loss of Flash device again, because under this structure, the number of times of copy data has reached minimum, duplicating each time all only is the restriction that is subjected to physical device, and there is not artificial waste, the fastest reading speed and writing speed have faster also been guaranteed simultaneously, when realizing the logical physical address translation of flash memory, can guarantee the integrality of data.