Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of method of write data, the method and the memory device of read data, to improve data-handling capacity in the memory device, reduces the memory size in the memory device.
The embodiment of the invention provides a kind of method of write data, comprising:
Receive the write data requests that main frame sends, comprise the LBA (Logical Block Addressing) address in the write data request, and the page number that obtains according to described LBA (Logical Block Addressing) address;
According to described page number, in the page table that memory device presets, search first physical block number that whether exists in first physical address corresponding with described page number, comprise the corresponding relation of page number and physical block number in the described page table;
If there be first physical block number corresponding, then the data to be written in the write data request are write in first physical block of described first physical block number sign with described page number.
The embodiment of the invention also provides a kind of method of read data, comprising:
Receive the read data request that main frame sends, comprise the LBA (Logical Block Addressing) address in the described read data request, and the page number that obtains according to described LBA (Logical Block Addressing) address;
According to described page number, in the fast table that memory device presets, search whether exist with described page number physical address corresponding in physical block number, comprise the corresponding relation of page number and physical block number in the described fast table;
If in described fast table, exist and described page number corresponding physical piece number, then data read on the described main frame from the physical block of described physical block number sign;
If in described fast table, there be not the described physical block number corresponding, then in the page table that memory device presets, search whether there be the described physical block number corresponding with described page number according to described page number with described page number; If in described page table, there be the described physical block number corresponding, then data are read on the described main frame from the described physical block of described physical block number sign with described page number.
The embodiment of the invention also provides a kind of memory device, comprising:
First receiving element is used to receive the write data requests that main frame sends, and comprises the LBA (Logical Block Addressing) address in the write data request, and the page number that obtains according to described LBA (Logical Block Addressing) address;
First internal storage location is used to store the page table that presets, and comprises the corresponding relation of page number and physical block number in the described page table;
First firmware unit, the described page number that is used for the write data request that receives according to described first receiving element is searched first physical block number that whether exists in first physical address corresponding with described page number in the described page table of described first internal storage location storage;
The first data-moving unit is used for if described first firmware unit finds first physical block number corresponding with described page number, then the data to be written in the write data request is write in first physical block of described first physical block number sign.
The embodiment of the invention also provides a kind of memory device, comprising:
Second receiving element is used to receive the read data request that main frame sends, and comprises the LBA (Logical Block Addressing) address in the described read data request, and the page number that obtains according to described LBA (Logical Block Addressing) address;
Central control unit is used to store the fast table that presets, and comprises the corresponding relation of page number and physical block number in the described fast table;
Second internal storage location is used to store the page table that presets, and comprises the corresponding relation of page number and physical block number in the described page table;
Second firmware unit is used for the described page number of the described read data request that receives according to described second receiving element, in the fast table of described central control unit storage, search whether exist with described page number physical address corresponding in physical block number; If in described fast table, there be not the described physical block number corresponding, then in the described page table of described second internal storage location storage, search whether there be the described physical block number corresponding with described page number with described page number;
The second data-moving unit is used for then data being read on the described main frame from the physical block of described physical block number sign if exist and described page number corresponding physical piece number at described fast table; Perhaps, if in described page table, there be the described physical block number corresponding, then data are read on the described main frame from the described physical block of described physical block number sign with described page number.
By above technical scheme as can be known, the method of the write data of the embodiment of the invention, the method for read data and memory device, because memory device directly receives page number information, therefore need not again LBA to be resolved, can in page table, find actual physical piece physical address corresponding according to the page number that obtains, write data in the memory device; And when write data, only need in the internal memory of memory device to preserve a page table, saved the capacity of the internal memory of memory device.Thereby can improve data throughout and equipment performance, promote the data-handling capacity of memory device.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
Fig. 1 is the schematic flow sheet of method first embodiment of write data of the present invention.As shown in Figure 1, comprising:
Step 101, receive the write data requests that main frame sends, comprise LBA (Logical Block Addressing) address (LBA) in the write data request, and the page number that obtains according to described LBA (Logical Block Addressing) address.
After main frame issues write data requests, by the driver of host side the LBA address resolution that comprises in the write data requests is become a kind of internal memory virtual address, i.e. described page number in the embodiment of the invention; The write data requests that will have this page number then is sent to memory device.
Step 102, according to described page number, in the page table that memory device presets, search first physical block number that whether exists in first physical address corresponding with described page number, comprise the corresponding relation of page number and physical block number in the described page table;
Safeguarding in the internal memory of memory device has a page table, and the list item of this page table comprises the corresponding relation between page number and the physical block number.Wherein page or leaf is the data unit division unit, and size can be set to 4KB, and as the minimum unit of data transmission.
Comprise first physical block number and first bias internal amount in this first physical address.First physical block number in this first physical address identifies a physical block on the FLASH chip in this memory device, and first bias internal amount in this first physical address indicates in this physical block existing what pages or leaves to be write completely.
Step 103, if there be first physical block number corresponding with described page number, then the data to be written in the write data request are write in first physical block that described first physical block number identifies.
Data to be written in the above-mentioned write data requests according to above-mentioned search procedure, promptly can be written in first physical block of described first physical block number sign in the memory device.
Write the method for data in the memory device that present embodiment provides, because memory device directly receives page number information, therefore need not again LBA to be resolved, can in page table, find actual physical piece physical address corresponding, write data in the memory device according to the page number that obtains; And in the internal memory of memory device, only need to preserve a page table, saved the capacity of the internal memory of memory device.Thereby can improve data throughout and equipment performance, promote the data-handling capacity of memory device.
Fig. 2 is the schematic flow sheet of method second embodiment of write data of the present invention.As shown in Figure 2, comprising:
Step 201, receive the write data requests that main frame sends, comprise the LBA (Logical Block Addressing) address in the write data request, and the page number that obtains according to described LBA (Logical Block Addressing) address.
Step 202, according to described page number, in the page table that memory device presets, search first physical block number that whether exists in first physical address corresponding, if exist with described page number, execution in step 203, otherwise execution in step 205 comprises the corresponding relation of page number and physical block number in the described page table.
Wherein, this first physical block number is included in first physical address, also includes first bias internal amount in this first physical address, also comprises corresponding physical piece number and piece bias internal amount in other physical addresss in the present embodiment;
Step 203, that whether first physical block of judging the indication of first bias internal amount is write is full, if write fullly, then execution in step 204, otherwise, execution in step 207;
Step 204, the data to be written in the write data request are write in first physical block of described first physical block number sign, finish;
Step 205, from the blank block table, transfer second physical address of the first blank physical block correspondence of preserving in the blank block table, and the corresponding relation of second physical block number in second physical address and page number is saved in the page table;
In memory device, can safeguard a blank block table, the physical block number and the piece bias internal amount information of preserving the physical block of the blank on this memory device in this blank block table.Each list item of this blank block table takies 3 bytes, and wherein high 2 bytes are used for depositing physical block number, and low 1 byte is used for depositing piece bias internal amount.Be provided with vernier in this blank block table, a back list item of the physical address information of blank physical block has been deposited in this vernier indication.In the time will from this blank block table, taking out a blank physical block physical address corresponding information, can be to put taking-up from the first place of this table, slider position subtracts 1 then, perhaps also can subtract 1 from slider position and directly take out blank physical block physical address corresponding information.
Step 206, the data to be written in the write data request are write in second physical block of described second physical block number sign, finish;
Step 207, from the blank block table, transfer the 3rd physical address of the second blank physical block correspondence of preserving in the blank block table, and the 3rd physical block number in the 3rd physical address replaced with page number corresponding physical piece number be saved in the page table;
Because the indicated physical block of first physical block number of original page number correspondence has been write full, at this moment, first physical block of this page number correspondence can not write data again, therefore, need from the blank block table, transfer a new blank physical block again and store the data of this page number correspondence, also need first physical block number of first physical block of original page number correspondence is replaced with the 3rd physical block number.
Step 208, the data to be written in the write data request are write in the 3rd physical block of described the 3rd physical block number sign.
The data that step 209, deletion are preserved in described first physical block, as the 3rd blank physical block, and described first physical address that will identify described the 3rd blank physical block is saved in the described blank block table end with described first physical block behind the deleted data.
For step 209, or the information of the blank physical block of preserving in the blank block table of safeguarding in this memory device according to the physical characteristics of FLASH chip, must be carried out garbage reclamation during less than a certain preset threshold value.Also safeguarding in the internal memory of this memory device has a garbage reclamation table, this garbage reclamation table to be used in reference to which page or leaf is invalid page or leaf in physical block, and which page or leaf is an active page.Fig. 3 is the synoptic diagram of a list item in the garbage reclamation table in the embodiment of the invention.As shown in Figure 3, the number of all pages and wherein invalid page or leaf in physical block of each list item storage in this garbage reclamation table.A list item takies (64/8n+1) individual byte, wherein n is the number of page or leaf, with a page or leaf is example, then a list item takies 9 bytes, whether 64 pages or leaves in wherein high 8 bytes (64bits altogether) physical block of expression are effective, can be made as 1 for effective, 0 is invalid, low 7bits in low 1 byte stores the contained quantity that invalid page or leaf is arranged in this physical block, whether the highest 1bit represents to store this physical block and has been added in the to be recycled table (dirty table) in low 1 byte, if entered into dirty table, this position 1 then, otherwise put 0.This garbage reclamation table is when each write operation, if invalid page or leaf will corresponding corresponding physical block number put 0 with correspondence position in the garbage reclamation table.
Write the method for data in the memory device that present embodiment provides, because memory device directly receives page number information, therefore need not again LBA to be resolved, can in page table, find actual physical piece physical address corresponding, write data in the memory device according to the page number that obtains; And in the internal memory of memory device, only need to preserve a page table, saved the capacity of the internal memory of memory device.Thereby can improve data throughout and equipment performance, promote the data-handling capacity of memory device.
Fig. 4 is the schematic flow sheet of the method embodiment of read data of the present invention.As shown in Figure 4, comprising:
Step 401, receive the read data request that main frame sends, comprise the LBA (Logical Block Addressing) address in the described read data request, and the page number that obtains according to described LBA (Logical Block Addressing) address.
Step 402, according to described page number, in the fast table that memory device presets, search whether exist with described page number physical address corresponding in physical block number, if exist, execution in step 403, otherwise execution in step 404 comprises the corresponding relation of page number and physical block number in the described fast table.
Page number is gone out by the LBA address resolution of the driver element in the main frame according to data.During the searching number of times and surpass a preset value (for example above 5 times) of the page number corresponding physical piece in searching page table number, the corresponding relation that just will surpass the page number of preset value and physical block number be saved in during another shows, in promptly showing soon.Should be stored in the central control unit (AMR) of memory device, by fast table so that can be searched fast.
Step 403, data are read on the described main frame from the physical block of described physical block number sign, finish;
Step 404, in the page table that memory device presets, search whether there be the described physical block number corresponding with described page number according to described page number, if exist, execution in step 405, otherwise, end operation;
Step 405, data are read on the described main frame from the described physical block of described physical block number sign.
The method of reading of data in the memory device that present embodiment provides, because memory device directly receives page number information, therefore need not again LBA to be resolved, can in fast table or page table, find actual physical piece physical address corresponding according to the page number that obtains, data are read from memory device, and the speed that reads information from the fast watch that is kept at central control unit is fast, also can improve the speed of data read; And, saved the capacity of the internal memory of memory device.Thereby can improve data throughout and equipment performance, promote the data-handling capacity of memory device.
Fig. 5 is the structural representation of memory device first embodiment of the present invention.As shown in Figure 5, comprising: first receiving element 51, first internal storage location 52, first firmware unit 53 and the first data-moving unit 54.Wherein, first receiving element 51 is used to receive the write data requests that main frame sends, and comprises the LBA (Logical Block Addressing) address in the write data request, and the page number that obtains according to described LBA (Logical Block Addressing) address; First internal storage location 52 is used to store the page table that presets, and comprises the corresponding relation of page number and physical block number in the described page table; First firmware unit 53, the described page number that is used for the write data request that receives according to described first receiving element 51 is searched first physical block number that whether exists in first physical address corresponding with described page number in the described page table of described first internal storage location 52 storages; The first data-moving unit 54 is used for having first physical block number corresponding with described page number if described first firmware unit 53 finds, and then the data to be written in the write data request is write in first physical block of described first physical block number sign.
The memory device that present embodiment provides, because memory device directly receives page number information, therefore need not again LBA to be resolved, can in page table, find actual physical piece physical address corresponding, write data in the memory device according to the page number that obtains; And in the internal memory of memory device, only need to preserve a page table, saved the capacity of the internal memory of memory device.Thereby can improve data throughout and equipment performance, promote the data-handling capacity of memory device.
On the described memory device of the foregoing description basis, described first firmware unit 53 can also be used for if there is not described first physical block number of described page number correspondence at described page table, then from the blank block table, transfer second physical address of the sign first blank physical block, and the corresponding relation of second physical block number in described second physical address and described page number is saved in the described page table of described first internal storage location 52 storages.Like this, the described first data-moving unit 54 also is used for the data to be written of write data request are write in second physical block of described second physical block number sign.
On the described memory device of the foregoing description basis, described first firmware unit 53 can also be used for if described first bias internal amount indicates described first physical block to be write full, then from the blank block table, transfer the 3rd physical address of the sign second blank physical block, and the 3rd physical block number in described the 3rd physical address replaced with and described page number corresponding physical piece number, be saved in the described page table of described first internal storage location 52 storages.So, the described first data-moving unit 54 also is used for the data to be written of write data request are write in the 3rd physical block of described the 3rd physical block number sign.
On the described memory device of the foregoing description basis, indicate described first physical block to be write when full in described first bias internal amount, described first firmware unit 53 can also be used for deleting the data that described first physical block is preserved; As the 3rd blank physical block, and described first physical address that will identify described the 3rd blank physical block is saved in the described blank block table with described first physical block behind the deleted data.
Fig. 6 is the structural representation of memory device second embodiment of the present invention.As shown in Figure 6, this memory device comprises: second receiving element 61, central control unit 62, second internal storage location 63, second firmware unit 64, the second data-moving unit 65.Second receiving element 61 is used to receive the read data request that main frame sends, and comprises the LBA (Logical Block Addressing) address in the described read data request, and the page number that obtains according to described LBA (Logical Block Addressing) address.Central control unit 62 is used to store the fast table that presets, and comprises the corresponding relation of page number and physical block number in the described fast table.Second internal storage location 63 is used to store the page table that presets, and comprises the corresponding relation of page number and physical block number in the described page table.Second firmware unit 64 is used for the described page number of the described read data request that receives according to described second receiving element 61, in the fast table of described central control unit 62 storages, search whether exist with described page number physical address corresponding in physical block number; If in described fast table, there be not the described physical block number corresponding, then in the described page table of described second internal storage location 63 storages, search whether there be the described physical block number corresponding with described page number with described page number.The second data-moving unit 65 is used for then data being read on the described main frame from the physical block of described physical block number sign if exist and described page number corresponding physical piece number at described fast table; Perhaps, if in described page table, there be the described physical block number corresponding, then data are read on the described main frame from the described physical block of described physical block number sign with described page number.
Wherein, search number of times in the described central control unit 62 in the described page table of the described fast table of storage by storage in described second internal storage location 63 and surpass that the page number of a preset value and corresponding physical piece thereof number form.
The memory device that present embodiment provides, because memory device directly receives page number information, therefore need not again LBA to be resolved, can in fast table or page table, find actual physical piece physical address corresponding according to the page number that obtains, data are read from memory device, and the speed that reads information from the fast watch that is kept at central control unit is fast, also can improve the speed of data read; And, saved the capacity of the internal memory of memory device.Thereby can improve data throughout and equipment performance, promote the data-handling capacity of memory device.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in the foregoing description method, be to instruct relevant hardware to finish by computer program, described program can be stored in a computing machine and can obtain in the storage medium, this program can comprise the flow process as the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only storage memory body (Read-OnlyMemory, ROM) or at random store memory body (Random Access Memory, RAM) etc.
It should be noted that at last: above embodiment only in order to technical scheme of the present invention to be described, is not intended to limit; Although with reference to previous embodiment the present invention is had been described in detail, those of ordinary skill in the art is to be understood that: it still can be made amendment to the technical scheme that aforementioned each embodiment put down in writing, and perhaps part technical characterictic wherein is equal to replacement; And these modifications or replacement do not make the essence of appropriate technical solution break away from the spirit and scope of various embodiments of the present invention technical scheme.