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 address in the write data request, and the page number that obtains according to said LBA address by the driver of main frame;
According to said page number, in the page table that memory device presets, search first physical block number that whether exists in first physical address corresponding with said page number, comprise the corresponding relation of page number and physical block number in the said 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 said first physical block number sign with said page number;
If do not have said first physical block number corresponding in the said page table with said page number; Then from the blank block table, transfer second physical address of the sign first blank physical block, the corresponding relation of second physical block number in said second physical address and said page number is saved in the said page table; Data to be written in the write data request are write in second physical block of said second physical block number sign.
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 address in the said read data request, and the page number that obtains according to said LBA address by the driver of main frame;
According to said page number, in the fast table that memory device presets, search whether exist with said page number physical address corresponding in physical block number, comprise the corresponding relation of page number and physical block number in the said fast table;
If in said fast table, exist and said page number corresponding physical piece number, then data read on the said main frame from the physical block of said physical block number sign;
If in said fast table, there be not the said physical block number corresponding, then in the page table that memory device presets, search whether there be the said physical block number corresponding with said page number according to said page number with said page number; If in said page table, there be the said physical block number corresponding, then data are read on the said main frame from the said physical block of said physical block number sign with said 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 address in the write data request, and the page number that is obtained according to said LBA address by the driver of main frame;
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 said page table;
First firmware unit; The said page number of the write data request that is used for receiving according to said first receiving element; In the said page table of said first internal storage location storage, search first physical block number that whether exists in first physical address corresponding with said page number; And be used for if do not have corresponding said first physical block number of said page number at said 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 said second physical address and said page number is saved in the said page table of said first internal storage location storage;
The first data-moving unit; Be used for if said first firmware unit finds first physical block number corresponding with said page number; Then the data to be written in the write data request are write in first physical block of said first physical block number sign; And be used for if said first firmware unit is searched less than first physical block number corresponding with said page number, the data to be written in the write data request are write in second physical block of said second 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 address in the said read data request, and the page number that is obtained according to said LBA address by the driver of main frame;
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 said 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 said page table;
Second firmware unit, the said page number of the said read data request that is used for receiving according to said second receiving element, in the fast table of said central control unit storage, search whether exist with said page number physical address corresponding in physical block number; If in said fast table, there be not the said physical block number corresponding, then in the said page table of said second internal storage location storage, search whether there be the said physical block number corresponding with said page number with said page number;
The second data-moving unit is used for then data being read on the said main frame from the physical block of said physical block number sign if exist and said page number corresponding physical piece number at said fast table; Perhaps, if in said page table, there be the said physical block number corresponding, then data are read on the said main frame from the said physical block of said physical block number sign with said page number.
Can know by above technical scheme; 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, write data in the memory device according to the page number that obtains; 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
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, 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 are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
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 address (LBA) in the write data request, and the page number that obtains according to said LBA 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. said 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 said page number, in the page table that memory device presets, search first physical block number that whether exists in first physical address corresponding with said page number, comprise the corresponding relation of page number and physical block number in the said page table;
In the internal memory of memory device, safeguarding 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.A physical block on the FLASH chip in this memory device of first physical block number sign in this first physical address, existing what pages or leaves are write full in first this physical block of bias internal amount indication in this first physical address.
Step 103, if there be first physical block number corresponding with said page number, then the data to be written in the write data request are write in first physical block that said 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 said 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 address in the write data request, and the page number that obtains according to said LBA address.
Step 202, according to said 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 said page number; Execution in step 203; Otherwise execution in step 205 comprises the corresponding relation of page number and physical block number in the said 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 said first physical block number sign, finish;
Step 205, from the blank block table, transfer the second corresponding physical address of preserving in the blank block table of the first blank physical block, 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 said second physical block number sign, finish;
Step 207, from the blank block table, transfer the corresponding tertium quid reason address of the second blank physical block of preserving in the blank block table, and tertium quid is managed tertium quid reason piece in the address number replace with page number corresponding physical piece and number be saved in the page table;
Because the corresponding indicated physical block of first physical block number of original page number has been write full; At this moment; First physical block that this page number is corresponding can not write data again; Therefore, need from the blank block table, transfer a new blank physical block again and store the corresponding data of this page number, first physical block number of first physical block that also need original page number is corresponding replaces with tertium quid reason piece number.
Step 208, the data to be written in the write data request are write in the tertium quid reason piece of said tertium quid reason piece number sign.
The data that step 209, deletion are preserved in said first physical block, as the 3rd blank physical block, and said first physical address that will identify said the 3rd blank physical block is saved in the said blank block table end with said 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.In the internal memory of this memory device, also safeguarding 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, and wherein n is the number of page or leaf, is example with a page or leaf; Then a list item takies 9 bytes, and whether 64 pages or leaves in wherein high 8 bytes (64bits altogether) physical block of expression are effectively, can be made as 1 for effective; 0 is invalid; The contained quantity that invalid page or leaf is arranged in low this physical block of 7bits storage in low 1 byte, whether the highest 1bit representes to store this physical block and has been added in the to be recycled table (dirty table) in low 1 byte, as if having 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 address in the said read data request, and the page number that obtains according to said LBA address.
Step 402, according to said page number; In the fast table that memory device presets, search whether exist with said 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 said 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 page number and the physical block number of preset value 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 said main frame from the physical block of said physical block number sign, finish;
Step 404, in the page table that memory device presets, search whether there be the said physical block number corresponding with said page number according to said page number, if exist, execution in step 405, otherwise, end operation;
Step 405, data are read on the said main frame from the said physical block of said 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, data are read from memory device according to the page number that obtains; And the speed that from the fast watch that is kept at central control unit, reads information is fast, also can improve the speed that 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 address in the write data request, and the page number that obtains according to said LBA 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 said page table; First firmware unit 53; The said page number of the write data request that is used for receiving according to said first receiving element 51 is searched first physical block number that whether exists in first physical address corresponding with said page number in the said page table of said first internal storage location 52 storages; The first data-moving unit 54 is used for having first physical block number corresponding with said page number if said first firmware unit 53 finds, and then the data to be written in the write data request is write in first physical block of said 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; Said first firmware unit 53 can also be used for if do not have corresponding said first physical block number of said page number at said 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 said second physical address and said page number is saved in the said page table of said first internal storage location 52 storages.Like this, the said 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 said second physical block number sign.
On the described memory device of the foregoing description basis; Said first firmware unit 53 can also be used for if said first bias internal amount indicates said first physical block to be write full; Then from the blank block table, transfer the tertium quid reason address of the sign second blank physical block; And the tertium quid reason piece in the said tertium quid reason address number replaced with and said page number corresponding physical piece number, be saved in the said page table of said first internal storage location 52 storages.So, the said first data-moving unit 54 also is used for the data to be written of write data request are write in the tertium quid reason piece of said tertium quid reason piece number sign.
On the described memory device of the foregoing description basis, indicate said first physical block to be write when full in said first bias internal amount, said first firmware unit 53 can also be used for deleting the data that said first physical block is preserved; As the 3rd blank physical block, and said first physical address that will identify said the 3rd blank physical block is saved in the said blank block table with said 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 address in the said read data request, and the page number that obtains according to said LBA 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 said 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 said page table.Second firmware unit 64, the said page number of the said read data request that is used for receiving according to said second receiving element 61, in the fast table of said central control unit 62 storages, search whether exist with said page number physical address corresponding in physical block number; If in said fast table, there be not the said physical block number corresponding, then in the said page table of said second internal storage location 63 storages, search whether there be the said physical block number corresponding with said page number with said page number.The second data-moving unit 65 is used for then data being read on the said main frame from the physical block of said physical block number sign if exist and said page number corresponding physical piece number at said fast table; Perhaps, if in said page table, there be the said physical block number corresponding, then data are read on the said main frame from the said physical block of said physical block number sign with said page number.
Wherein, search in the said page table of the said fast table of storage by storage in said second internal storage location 63 in the said central control unit 62 that page number and corresponding physical piece thereof that number of times surpasses a preset value 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, data are read from memory device according to the page number that obtains; And the speed that from the fast watch that is kept at central control unit, reads information is fast, also can improve the speed that 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 accomplish through 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 like 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.
What should explain at last is: above embodiment is only in order to explaining technical scheme of the present invention, but not to its restriction; Although with reference to previous embodiment the present invention has been carried out detailed explanation, 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 are revised or replacement, do not make the spirit and the scope of the essence disengaging various embodiments of the present invention technical scheme of relevant art scheme.