A kind of formation of mapping table, update and restoration methods and electronic equipment
Technical field
The present invention relates to electronic technology more particularly to a kind of formation of mapping table, update and restoration methods and electronic equipments.
Background technique
The performance of solid-state memory (SSD, Solid-State Memory) is apparently higher than traditional magnetic disk storage, close several
Nian Lai is had increasingly been used in personal computer (PC) and notebook due to the decline of solid-state memory cost.
The storage medium of solid-state memory itself is usually nand flash memory (flash), and metadata mainly includes hard disk note
Essential information of record, such as logical-physical mapping table, other hard disk management information etc.;After solid-state memory powers on, first from
Metadata about load is to RAM in nand flash memory;During the work time, metadata can be related to simultaneously to the data read-write operation of hard disk
The change of (especially mapping table), in view of rate request, what these changes directly operated on RAM, it is therefore desirable to it is in due course general
These metadata updates are to NAND flash, and otherwise, once there is abnormal power-down, metadata is inconsistent with data, may cause
SSD can not work normally after re-powering.
There are no provide one kind to recover automatically the scheme of metadata in abnormal power-down in the prior art.
Summary of the invention
In view of this, the embodiment of the present invention be solve the problems, such as it is existing in the prior art at least one and a kind of mapping is provided
Formation, update and the restoration methods and electronic equipment of table can be to recover metadata automatically in abnormal power-down, to promote number
According to safety.
The technical solution of the embodiment of the present invention is achieved in that
In a first aspect, the embodiment of the present invention provides a kind of forming method of mapping table, the mapping table includes level-one mapping
Table and second level mapping table, which comprises
The Physical Page that all logical page (LPAGE)s on host are mapped as to NAND on solid-state memory, shape are mapped using page grade
At second level mapping table;
The first physical address is obtained, first physical address is the physical store of the first block in the second level mapping table
Address,
First physical address and corresponding first identifier information are formed in the map unit in level-one mapping table
Mapping relations, wherein the first identifier information is the identification information of the first block.
Second aspect, the embodiment of the present invention provide a kind of update method of mapping table, which comprises
Obtain the parameter for updating mapping table;
Judge whether the parameter meets preset condition;
When meeting the preset condition, by the map information in the second level mapping table from the random of solid-state memory
On memory updating to the NAND;
The second physical address and corresponding second identifier information are obtained, second physical address is updated described
The physical storage address of the upper map information as unit of block of NAND;
Second physical address is updated to the level-one mapping table according to the second identifier information.
The third aspect, the embodiment of the present invention provide a kind of restoration methods of mapping table, when the second level mapping table damage and
When the level-one mapping table is complete, second level mapping table is restored according to level-one mapping table, is specifically included:
Third physical address is obtained from the level-one mapping table, the third physical address is in the level-one mapping table
The physical address stored in one map unit, the third physical address are the physical address of third block;
The second level map information of third block is obtained according to the third physical address;
Third identification information is obtained from the level-one mapping table, the third identification information is corresponding to third physical address
The identification information of block;
The 4th identification information is obtained from the second level map information of the third block according to third physical address;
Judge whether the third identification information with the 4th identification information indicates same block;
When being, the second level map information of the third block is read into solid-state storage from the NAND of solid-state memory
In the random access memory of device.
Fourth aspect, the embodiment of the present invention provide a kind of restoration methods of mapping table, when second level mapping table has been updated
It finishes, and when level-one mapping table is not updated, the level-one mapping table is restored according to the updated second level mapping table, specifically
Include:
The physical address of corresponding block is obtained according to the identification information of block in the level-one mapping table;
When the number of the physical address of the block is equal to 1, level-one mapping table is written into the physical address of the block
In corresponding block identification information in map unit in;
When the number of the physical address of the block is greater than 1, the time corresponding to the physical address of each block is obtained
Stab information;
By the identification information of corresponding block in the physical address write-in level-one mapping table of the nearest block of timestamp information
In interior map unit.
5th aspect, the embodiment of the present invention provide a kind of electronic equipment, and the mapping table includes level-one mapping table and second level
Mapping table, the electronic equipment include the first formation unit, first acquisition unit and the second formation unit, in which:
Described first forms unit, deposits for all logical page (LPAGE)s on host to be mapped as solid-state using the mapping of page grade
The Physical Page of NAND on reservoir forms second level mapping table;
The first acquisition unit, for obtaining the first physical address, first physical address is second level mapping
The physical storage address of first block in table,
Described second forms unit, for mapping first physical address and corresponding first identifier information in level-one
Mapping relations are formed in map unit in table, wherein the first identifier information is the identification information of the first block.
6th aspect, the embodiment of the present invention provide a kind of electronic equipment, and the electronic equipment includes second acquisition unit, the
One judging unit, the first updating unit, third acquiring unit and the second updating unit, in which:
The second acquisition unit, for obtaining the parameter for updating mapping table;
First judging unit, for judging whether the parameter meets preset condition;
First updating unit, for when meeting the preset condition, by the mapping in the second level mapping table
Information is updated from the random access memory of solid-state memory onto the NAND;
The third acquiring unit, for obtaining the second physical address and corresponding second identifier information, second object
Manage the physical storage address that address is the map information on the updated NAND as unit of block;
Second updating unit, for being updated second physical address to described according to the second identifier information
Level-one mapping table.
7th aspect, the embodiment of the present invention provide a kind of electronic equipment, and the electronic equipment includes the 5th acquiring unit, the
Six acquiring units, the first reading unit, the 7th acquiring unit, the 8th acquiring unit, third judging unit and the second reading unit,
Wherein:
5th acquiring unit, for obtaining third physical address, the third physics from the level-one mapping table
Address is by the physical address that stores in a map unit in the level-one mapping table;
6th acquiring unit, for obtaining second level map information according to the third physical address;
First reading unit, it is solid for reading the second level map information from the NAND of solid-state memory
In the random access memory of state memory;
7th acquiring unit, for obtaining third identification information, the third mark letter from the level-one mapping table
Breath is the identification information of block corresponding to third physical address;
8th acquiring unit, for obtaining the 4th mark from the second level map information according to third physical address
Know information;
The third judging unit, for judging whether the third identification information is same with the 4th identification information expression
One block;When being, second reading unit is triggered;
Second reading unit, it is solid for reading the second level map information from the NAND of solid-state memory
In the random access memory of state memory.
Eighth aspect, the embodiment of the present invention provide a kind of electronic equipment, and the electronic equipment includes the 9th acquiring unit, the
One writing unit, the tenth acquiring unit and the second writing unit, in which:
9th acquiring unit, for obtaining corresponding block according to the identification information of block in the level-one mapping table
Physical address;
First writing unit, for when the number of the physical address of the block be equal to 1 when, by the object of the block
It manages in the map unit in address write-in level-one mapping table in the identification information of corresponding block;
Tenth acquiring unit, for obtaining each block when the number of the physical address of the block is greater than 1
Timestamp information corresponding to physical address;
Second writing unit, in the physical address write-in level-one mapping table by the nearest block of timestamp information
In map unit in the identification information of corresponding block.
9th aspect, the embodiment of the present invention provide a kind of electronic equipment, and the electronic equipment includes solid-state memory SSD,
The solid-state memory includes NAND and SSD controller, wherein
All logical page (LPAGE)s on host are mapped as solid-state storage for mapping using page grade by the SSD controller
The Physical Page of NAND on device forms second level mapping table;The first physical address is obtained, first physical address is that the second level is reflected
The physical storage address of first block in firing table maps first physical address and corresponding first identifier information in level-one
Mapping relations are formed in map unit in table, wherein the first identifier information is the identification information of the first block.
Tenth aspect, the embodiment of the present invention provide a kind of electronic equipment, and the electronic equipment includes solid-state memory SSD,
The solid-state memory includes NAND and SSD controller, wherein
The SSD controller, for obtaining the parameter for updating mapping table;Judge whether the parameter meets preset item
Part;When meeting the preset condition, by the map information in the second level mapping table from the random storage of solid-state memory
Device is updated onto the NAND;The second physical address and corresponding second identifier information are obtained, second physical address is more
The physical storage address of map information on the NAND after new as unit of block;According to the second identifier information by institute
The second physical address is stated to update to the level-one mapping table.
Tenth on the one hand, and the embodiment of the present invention provides a kind of electronic equipment, and the electronic equipment includes solid-state memory
SSD, the solid-state memory include NAND and SSD controller, wherein
The SSD controller, for obtaining third physical address, the third physical address from the level-one mapping table
By the physical address stored in a map unit in the level-one mapping table, the third physical address is third block
Physical address;The second level map information of third block is obtained according to the third physical address;It is obtained from the level-one mapping table
Third identification information is taken, the third identification information is the identification information of block corresponding to third physical address;According to third object
Reason address obtains the 4th identification information from the second level map information of the third block;Judging the third identification information is
It is no to indicate same block with the 4th identification information;When being, the second level map information of the third block is deposited from solid-state
It is read in the random access memory of solid-state memory on the NAND of reservoir.
12nd aspect, the embodiment of the present invention provide a kind of electronic equipment, and the electronic equipment includes solid-state memory
SSD, the solid-state memory include NAND and SSD controller, wherein
The SSD controller, for obtaining corresponding block according to the identification information of block in the level-one mapping table
Physical address;When the number of the physical address of the block is equal to 1, level-one mapping table is written into the physical address of the block
In corresponding block identification information in map unit in;When the number of the physical address of the block is greater than 1, obtain each
Timestamp information corresponding to the physical address of a block;The physical address write-in level-one of the nearest block of timestamp information is reflected
In map unit in firing table in the identification information of corresponding block.
Formation, update and the restoration methods and electronic equipment of mapping table provided in an embodiment of the present invention, wherein use page grade
All logical page (LPAGE)s on host are mapped as the Physical Page of NAND on solid-state memory by mapping, form second level mapping table;It obtains
The first physical address is taken, first physical address is that the physical storage address of the first block in the second level mapping table will be described
First physical address and corresponding first identifier information form mapping relations in the map unit in level-one mapping table, wherein institute
State the identification information that first identifier information is the first block;So, it is possible be in abnormal power-down recover metadata automatically, thus
Promote the safety of data.
Detailed description of the invention
Fig. 1 is the implementation process schematic diagram of the forming method of one mapping table of the embodiment of the present invention;
Fig. 2 is the implementation process schematic diagram of the update method of three mapping table of the embodiment of the present invention;
Fig. 3-1 is the implementation process schematic diagram of the restoration methods of four mapping table of the embodiment of the present invention;
Fig. 3-2 is the correspondence diagram in the embodiment of the present invention four between level-one mapping table and second level mapping table;
Fig. 4 is six electronic equipment composed structure schematic diagram of the embodiment of the present invention;
Fig. 5 is seven electronic equipment composed structure schematic diagram of the embodiment of the present invention;
Fig. 6 is the composed structure schematic diagram of solid-state memory in the embodiment of the present invention.
Specific embodiment
Only one page of grade mapping table of SSD in the prior art is first introduced in SSD before lobby page grade mapping table
Basic conception:
1) physical block and Physical Page
Because the institutional framework of nand flash memory cell limits, it is impossible for individually reading and writing a flash cell.NAND dodges
Memory cell is to carry out tissue with physical block.The minimum unit that can be read and write in physical block is known as Physical Page.Physical Page cannot be independent
Erasing, can only monolith erasing.The physical page size of nand flash memory may be it is different, the physical page size of most hard disks is
2KB, 4KB, 8KB or 16KB.The block of most of SSD has 128 or 256 Physical Page, this indicates that the size of physical block is also likely to be
Different value between 256KB and 4MB.Such as the physics block size of 840 EVO of Samsung SSD is 2048KB, and each physics
Block has the Physical Page of 256 8KB.
Reading and writing is aligned with physical page size;Primary reading is impossible less than the content of a Physical Page.Operation
System can of course simply request a byte, but SSD can access entire Physical Page, force to read remote super required data.It will count
When according to write-in SSD, the increment of write-in is also physical page size.Even if a therefore write operation affects only a word
Section, entire Physical Page can all be written anyway.The behavior than required more data is written and is referred to as write-in amplification.
Physical Page cannot be replicated;In nand flash memory Physical Page only its " free time " when could be written.Work as number
After change, the content of this Physical Page is copied into an internal register, and data update at this time and the data of new version store
In the Physical Page of one " free time ", this is referred to as " read-modify-write " operation.Data not update on the spot, because of the object of " free time "
The Physical Page for managing page and original storing data is not the same Physical Page.Once data are saved by hard disk, original Physical Page quilt
Labeled as " stale (corrupt or stale) ", until it is wiped free of.
Erasing is aligned with physical block;Physical Page cannot be replicated, once and its become stale, allow its again the free time get off
Unique method be to wipe them.But to single physical page carry out erasing be it is impossible, can only once wipe entire physics
Block.From the user's point of view, there was only reading and write order when accessing data.Erasing order is then when SSD controller needs to recycle
Stale Physical Page is come when obtaining free space, by its garbage reclamation process triggers.
The small write-in of cachingization;For maximize handling capacity, small data is written in RAM caching as far as possible, when caching is full
After execute a big write-in merging all small write-ins.
2) wear leveling;
Nand flash memory cell has P/E circulation limitation that it is caused to have life limitation because of it.There is a SSD, data are always same
It is written on one physical block.This physical block will quickly reach the limitation of its P/E circulation, exhaust.And SSD controller well marks it to be
Unavailable, the capacity of such hard disk will reduce.Therefore, a main target of SSD controller be realize wear leveling, be by
P/E circulates between physical block mean allocation as far as possible.Ideally, all physical blocks can reach P/E circulation in the same time
The upper limit simultaneously exhausts.In order to reach best global wear leveling, SSD controller needs the wise selection physical block to be written,
And may need to move between several physical blocks, internal process will lead to the increase of write-in amplification.Therefore, physical block
Management is to maximize the tradeoff between wear leveling and minimum words write-in amplification.
3) flash translation layer (FTL) (FTL)
Flash translation layer (FTL) is a component of SSD controller, its effect is for will be from host logically
Location is mapped as the physical address on hard disk, and FTL is garbage reclamation there are one effect.
4) page grade maps
Logical page (LPAGE) (LBA) from hosting space is converted to the Physical Page in physics nand flash memory space by page grade mapping
(PBA).For access speed, this page of grade mapping table is stored in the RAM of SSD, and is saved in a flash memory with power fail-safe.
After SSD starting, this page of grade mapping table is rebuild from reading in flash memory and in the RAM of SSD.
Page grade mapping method provides great flexibility, however primary disadvantage is that mapping table needs a large amount of memory,
This can increase production cost significantly.To prevent the workload of a large amount of small updates, no matter whether Physical Page is full, whole flash memories
Physical block can all be written.
As described above, page grade mapping table in the prior art is very huge, during the work time, generally require all to add
It carries, not only needs a large amount of memory in this way, but also error rate is relatively high.In order to solve aforementioned technical problem, the present invention is implemented
Example first provides a kind of second level mapping table mechanism, and the second level mapping table mechanism using page grade mapping table above-mentioned as second level in addition to mapping
Except table, a level-one mapping table is extracted also according to second level mapping table, each map unit in the level-one mapping table
In be stored with mapping relations in second level mapping table between the physical address of each block and the identification information of the block.It is simple next
It says, is exactly then to be divided using second level mapping table as data according to block, simultaneously using second level mapping table as a kind of data
Identification information is put on to ready-portioned block, it is then that the identification information filling mapping of the physical address of block and corresponding block is single
In member, then these map units just constitute level-one mapping table.
The technical solution of the present invention is further elaborated in the following with reference to the drawings and specific embodiments.
Embodiment one
The embodiment of the present invention provides a kind of forming method of mapping table, is applied to electronic equipment, the formation side of the mapping table
The function that method is realized can realize that certain program code can by the SSD controller caller code in electronic equipment
To be stored in computer storage medium, it is seen then that the electronic equipment includes at least SSD controller and storage medium.
Fig. 1 is the implementation process schematic diagram of the forming method of one mapping table of the embodiment of the present invention, as shown in Figure 1, this method
Include:
Step S101 is mapped using page grade all logical page (LPAGE)s on host being mapped as NAND on solid-state memory
Physical Page forms second level mapping table;
Here, the mapping table includes level-one mapping table and second level mapping table;The host refers to relative to solid-state storage
Electronic equipment for device generally forms page grade mapping table using page grade mapping method, in the embodiment of the present invention in the prior art
In, using this page of grade mapping table as the second level mapping table in the embodiment of the present invention in second level mapping mechanism.
Step S102, obtains the first physical address, and first physical address is the first block in the second level mapping table
Physical storage address;
Here, it needs to divide the second level mapping table in step S101, the unit of division is block, i.e., according to block
Second level mapping table is divided, the second level mapping table after being divided.During specific implementation, the block can be
Physical Page perhaps physical block or be less than Physical Page.As long as the physical address for representing the block can be found.Described first
Block is any one block in the second level mapping table after dividing, and in other words, first block is second level mapping
Any one block when map information in table is stored as unit of block.
Step S103, by the mapping list of first physical address and corresponding first identifier information in level-one mapping table
Mapping relations are formed in member, wherein the first identifier information is the identification information of the first block;
Here, for the second level mapping table after being divided according to block, to all blocks all allocation identification information, then will
Physical address (i.e. the first physical address) and the mark of corresponding block of first block in the second level mapping table that step S102 is obtained
Know information (first identifier information) to be mapped, to form mapping relations in every map unit of level-one mapping table.
In the embodiment of the present invention, the method also includes: step S111 will be used to indicate single in the second level mapping table
The map information of position block is stored on NAND as a whole;
It is smaller to existing SSD improvement in this way using Physical Page as the block as preferred embodiment, existing
Read and write in technology all is with physics page alignment.
In the embodiment of the present invention, the method also includes: step S112 deposits the level-one mapping table as a whole
It is stored on NAND.In embodiments of the present invention due to level-one mapping table be extracted according to second level mapping table, so, level-one mapping
The occupied space of table is very small, therefore during the loading process, level-one mapping table can be carried out as a whole read and
It writes.
It should be noted that the embodiment of the present invention is also needed in the prior art as second level mapping in the embodiment of the present invention
The page grade mapping table of table makes certain improvement, i.e., after being divided with block to second level mapping table, maps in the second level of each block
In the map information of table, retain the identification information that a storage unit out is used to store the block, therefore, in the embodiment of the present invention
Second level mapping table in the first block map information in further include first identifier information.
In the embodiment of the present invention, if the system normal shutdown of electronic equipment, when powering on next time, operating system can be first
Level-one mapping table is loaded, the mode of second level mapping table is then loaded.
Embodiment two
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of forming method of mapping table, is applied to electronic equipment,
The function that the forming method of the mapping table is realized can be by the SSD controller caller code in electronic equipment come real
Existing, certain program code can be stored in computer storage medium, it is seen then that the electronic equipment include at least SSD controller and
Storage medium.
This method comprises:
Step S201 is mapped using page grade all logical page (LPAGE)s on host being mapped as NAND on solid-state memory
Physical Page forms second level mapping table;
Here, the mapping table includes level-one mapping table and second level mapping table;The host refers to relative to solid-state storage
Electronic equipment for device generally forms page grade mapping table using page grade mapping method, in the embodiment of the present invention in the prior art
In, using this page of grade mapping table as the second level mapping table in the embodiment of the present invention in second level mapping mechanism.
Step S202, obtains the first physical address, and first physical address is the first block in the second level mapping table
Physical storage address;
Here, it needs to divide the second level mapping table in step S201, the unit of division is block, i.e., according to block
Second level mapping table is divided, the second level mapping table after being divided.During specific implementation, the block can be
Physical Page perhaps physical block or be less than Physical Page.As long as the physical address for representing the block can be found.Described first
Block is any one block in the second level mapping table after dividing, and in other words, first block is second level mapping
Any one block when map information in table is stored as unit of block.
Step S203, by the mapping list of first physical address and corresponding first identifier information in level-one mapping table
Mapping relations are formed in member;
Here, the first identifier information is the identification information of the first block;
Step S204, the NAND timestamp that the map information flush of the first block of record enters the solid-state memory are believed
The information such as breath and version flag;
Step S205 obtains the first identifier information of the first block from second level mapping mark;
Step S206 obtains the first map unit according to level-one mapping table described in the first identifier information searching;
The timestamp information and version stamp information are recorded in the first map unit by step S207.
It can be seen that in each of level-one mapping table map unit according to the method that above embodiments two provide and also wrap
Include the timestamp information and version for entering the NAND of the solid-state memory for recording the map information flush as unit of block
The information such as this label.It is further to note that equally recording the time for having the block in each block of second level mapping table
Stab information and version information.
In the prior art, after SSD is powered on, loaded page grade mapping table is to RAM from nand flash memory;During the work time,
The change of page grade mapping table can be related to simultaneously to the data read-write operation of hard disk, after when one section, in order to guarantee page in RAM
The synchronism of grade mapping table and page grade mapping table on NAND, generally just synchronizes the page grade mapping table on NAND, works as synchronization
After the completion, will timestamp information to the block and version information record, and by the timestamp information and version of block
Information is documented in level-one mapping table, in this way to be retained in level-one mapping table.
Why the timestamp information and version information for having block all recorded in level-one mapping table and second level mapping table,
The reason is that: in abnormal power-down, level-one mapping table can be restored according to the second level mapping table in flush to NAND,
If necessary to restore the level-one mapping table of latest edition, version information and timestamp in second level mapping table can use
(timestamp) information, then recover newest level-one mapping table.Below in an example, will be described in how basis
Level-one mapping table restores second level mapping table, and how to restore level-one mapping table according to second level mapping table, in the mistake of recovery
Cheng Zhong requires to use above-mentioned version information and timestamp information.
Embodiment three
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of update method of mapping table, is applied to electronic equipment,
The function that the forming method of the mapping table is realized can be by the SSD controller caller code in electronic equipment come real
Existing, certain program code can be stored in computer storage medium, it is seen then that the electronic equipment include at least SSD controller and
Storage medium.
Fig. 2 is the implementation process schematic diagram of the update method of three mapping table of the embodiment of the present invention, as shown in Fig. 2, the mapping
The update method of table includes:
Step S301 obtains the parameter for updating mapping table;
Here, the mapping table includes level-one mapping table and second level mapping table, wherein level-one mapping table and second level mapping table
Relationship referring to embodiment one above-mentioned and embodiment two, the parameter for updating mapping table may include a variety of, for example, rewriting
Ratio, rewriting number or time cycle etc..It wherein rewrites ratio and refers to that the part being written in mapping table accounts for sum
Ratio.
Step S302, judges whether the parameter meets preset condition;
Here, continue to accept the example in above-mentioned steps S301, for rewriting ratio, it is assumed that preset condition is
20%, the rewriting ratio of current mapping table is obtained, judges to rewrite whether ratio is greater than 20%, when being greater than, is determined as meeting pre-
If condition, when be less than when, determine be less than preset condition.
Step S303 deposits the map information in the second level mapping table from solid-state when meeting the preset condition
The random access memory of reservoir is updated onto the NAND;
Step S304, obtains the second physical address and corresponding second identifier information, and second physical address is to update
The physical storage address of map information on the NAND afterwards as unit of block;
Here, it should be noted that the write-in of cover type is unable in SSD, so for the first block, if updated
The physical address of preceding first block is the first physical address, then the physical address of updated first block is no longer just first
Physical address, in other words, the second physical address in step S304 are different from the first physical address.In general, block
Identification information will not generally become, and in other words, the identification information of block only will increase, disappear, and increase i.e. as according to original mark
Know information and divide out new identification information, then the identification information for only needing newly to classify and corresponding physical address insert level-one
New map unit in mapping table, if original block is deleted, block will be set to stale, that
This goes the identification information of block that can be reused or directly disappear, accordingly, in level-one mapping table, if should
The identification information of block is reused, then new physical address will be received in corresponding map unit, if by this
If the identification information of block is not enabled, then original corresponding map unit should be deleted.
Step S305 updates second physical address to the level-one mapping table according to the second identifier information.
Here, judge that second identifier information whether there is in level-one mapping table;If it is present being believed according to second identifier
Breath searches level-one mapping table, obtains the second map unit, and second map unit then is written in the second physical address.If
Second identifier information is not present in the level-one mapping table, then second identifier information and the write-in of the second physical address is new
In map unit, to form the mapping relations of the block of update in the new map unit.
In the embodiment of the present invention, the method also includes:
Step S306, judges whether the second level mapping table all updates from the random access memory of solid-state memory to described
On NAND;
Step S307 when being, then obtains second physical address and second identifier information.
Step S308, when no, continue to update by the second level mapping table from the random access memory of solid-state memory update to
On the NAND.
Example IV
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of restoration methods of mapping table, is applied to electronic equipment,
The function that the forming method of the mapping table is realized can be by the SSD controller caller code in electronic equipment come real
Existing, certain program code can be stored in computer storage medium, it is seen then that the electronic equipment include at least SSD controller and
Storage medium.
Restoration methods provided in an embodiment of the present invention, when second level mapping table damage, the level-one mapping table is complete
When, second level mapping table can be restored according to level-one mapping table, such as power off in system exception, just will do it after powering on next time extensive
Multiple, this is just to directly acquire newest level-one mapping table in NAND to be loaded.It at this time can be in two kinds of situation: situation one, when being
System power-off occurred in the non-metadata updates stage, and such case is fairly simple, directly loaded second level mapping table from level-one mapping table
?;Situation two is needed to push away level-one mapping table by second level mapping table is counter, be walked below if occurring during metadata updates
Suddenly will be used to give information on the situation the restoration methods of two lower mapping tables, and the restoration methods of the mapping table include:
Fig. 3-1 is the implementation process schematic diagram of the restoration methods of four mapping table of the embodiment of the present invention, as shown in figure 3-1, should
Method includes:
Step S401 obtains third physical address from the level-one mapping table;
Here, the third physical address in a map unit in the level-one mapping table by storing physically
Location;The third physical address is the physical address of third block.
Step S402 obtains the second level map information on third block according to the third physical address;
Here, what second level mapping table actually stored is some metadata informations, if according to block to second level mapping table
After being divided, then the information stored on each block is known as second level map information.
Step S403 reads the second level map information on the third block solid from the NAND of solid-state memory
In the random access memory of state memory;
Step S404 obtains third identification information from the level-one mapping table, and the third identification information is third physics
The identification information of block corresponding to address;
Step S405 obtains the 4th mark according to third physical address from the second level map information of the third block
Information;
Step S406 judges whether the third identification information is identical as the 4th identification information;
Here, when identical, whether third identification information with the 4th identification information indicates same block;
When being, the second level map information of the third block is read from the NAND of solid-state memory by step S407
Onto the random access memory of solid-state memory.
When no, the physical address of corresponding block is obtained according to the third identification information by step S407;
The physical address of the block is written one when the number of the physical address of the block is equal to 1 by step S408
In map unit in grade mapping table in third identification information;
Step S409, when the number of the physical address of the block is greater than 1, the physical address institute for obtaining each block is right
The timestamp information answered;
Step S410, by third identification information in the physical address write-in level-one mapping table of the nearest block of timestamp information
In interior map unit.
It represents block below with Physical Page to be illustrated, technical method provided in an embodiment of the present invention includes:
Second level mapping table is divided into as shown in figure 3-2 with 1 Physical Page (mapping table by step S421
Page it) is stored for several units of unit, forms the new mapping table of a physical address index to the storage of second level mapping table,
That is level-one mapping table;
Step S422 distributes an identification information to Physical Page in each second level mapping table, at the same record this page of flush into
Enter the timestamp information of NAND;
Step S423 is complete after to be done using first local updating second level mapping table when more new strategy sets out primary update
Office updates level-one mapping table, then updates miscdata key metadata;
Step S424 can restore second level according to the level-one mapping table in flush to NAND when powering off generation
Mapping table, even if new modification can also carry out two with the second level mapping table of legacy version since power-off does not update in NAND also
The reconstruct of grade mapping table;
Step S425 can use the mark letter of second level mapping table if necessary to restore the level-one mapping table of latest edition
Breath and timestamp information scan entire second level mapping table section, by updated second level mapping table reconstruct and other
Legacy version mapping table combines, and generates the level-one mapping table of special version, to reduce power down loss;
It from the above, it can be seen that when need to restore the level-one mapping table of latest edition, can use each and grade is reflected
The identification information (coding index) of Physical Page, timestamp (timestamp) information in firing table, then recover newest level-one and reflect
Firing table.The map information for managing SSD with second level mapping mechanism in embodiments of the present invention, in this way in abnormal power-down,
It can restore level-one mapping table according to the second level mapping table in flush to NAND, if necessary to restore latest edition
Level-one mapping table, can use coding index, timestamp (timestamp) information of each level-one mapping table page, then restore
Newest mapping table out.
Embodiment five
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of restoration methods of mapping table, is applied to electronic equipment,
The function that the forming method of the mapping table is realized can be by the SSD controller caller code in electronic equipment come real
Existing, certain program code can be stored in computer storage medium, it is seen then that the electronic equipment include at least SSD controller and
Storage medium.
Restoration methods provided in an embodiment of the present invention are finished when second level mapping table has been updated, and level-one mapping table is not
When being updated, the level-one mapping table is restored according to the updated second level mapping table, the restoration methods of the mapping table, specifically
Include:
Step S501 obtains the physical address of corresponding block according to the identification information of block in the level-one mapping table;
The physical address of the block is written one when the number of the physical address of the block is equal to 1 by step S502
In map unit in grade mapping table in the identification information of corresponding block;
Step S503, when the number of the physical address of the block is greater than 1, the physical address institute for obtaining each block is right
The timestamp information answered;
Step S504, by corresponding block in the physical address write-in level-one mapping table of the nearest block of timestamp information
In map unit in identification information.
Embodiment six
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of electronic equipment, included the in the electronic equipment
One formation unit, first acquisition unit and second, which form unit, to be realized by the SSD controller in electronic equipment, when
It can also so be realized by specific logic circuit;During specific embodiment, processor can be central processing unit
(CPU), microprocessor (MPU), digital signal processor (DSP) or field programmable gate array (FPGA) etc..
Fig. 4 is six electronic equipment composed structure schematic diagram of the embodiment of the present invention, as shown in figure 4, the electronic equipment 400 includes
First forms unit 401, first acquisition unit 402 and second forms unit 403, in which:
Described first forms unit 401, solid for being mapped as all logical page (LPAGE)s on host using the mapping of page grade
The Physical Page of NAND on state memory forms second level mapping table;
The first acquisition unit 402, for obtaining the first physical address, first physical address is that the second level is reflected
The physical storage address of first block in firing table;
Described second forms unit 403, is used for first physical address and corresponding first identifier information in level-one
Mapping relations are formed in map unit in mapping table, wherein the first identifier information is the identification information of the first block.
It further include first identifier letter in the map information of the first block in the second level mapping table in the embodiment of the present invention
Breath.
In the embodiment of the present invention, the electronic equipment further includes the first storage unit and the second storage unit, in which:
First storage unit, for making the map information for being used to indicate unit block in the second level mapping table
It is entirely stored on NAND for one;
Second storage unit, for the level-one mapping table to be stored in NAND as a whole.
In the embodiment of the present invention, the electronic equipment further includes the first recording unit, the 12nd acquiring unit, searching unit
With the second recording unit, in which:
First recording unit, the map information flush for recording the first block enter the solid-state memory
The information such as NAND timestamp information and version flag;
11st acquiring unit, for obtaining the first identifier information of the first block from second level mapping mark;
The searching unit is used for the level-one mapping table according to the first identifier information searching, obtains the first mapping
Unit;
Second recording unit, for the timestamp information and version stamp information to be recorded in the first map unit
In.
From the above, it can be seen that further including for recording the mapping letter as unit of block in each described map unit
Cease timestamp information and version flag that flush enters the NAND of the solid-state memory.
It need to be noted that: the above electronic equipment implements the description of item, is similar, tool with above method description
There is the identical beneficial effect of same embodiment of the method, therefore does not repeat them here.For undisclosed in electronic equipment embodiment of the present invention
Technical detail, those skilled in the art please refer to the description of embodiment of the present invention method and understand, to save length, here not
It repeats again.
Embodiment seven
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of electronic equipment, included the in the electronic equipment
The units such as two acquiring units, the first judging unit, the first updating unit, third acquiring unit and the second updating unit, are ok
It is realized by the SSD controller in electronic equipment, can also be realized certainly by specific logic circuit;In specific embodiment
In the process, processor can for central processing unit (CPU), microprocessor (MPU), digital signal processor (DSP) or scene
Program gate array (FPGA) etc..
Fig. 5 is seven electronic equipment composed structure schematic diagram of the embodiment of the present invention, as shown in figure 5, the electronic equipment 500 includes
Second acquisition unit 501, the first judging unit 502, the first updating unit 503, third acquiring unit 504 and the second updating unit
505, in which:
The second acquisition unit 501, for obtaining the parameter for updating mapping table;
First judging unit 502, for judging whether the parameter meets preset condition;
First updating unit 503, for when meeting the preset condition, by reflecting in the second level mapping table
Information is penetrated to update from the random access memory of solid-state memory onto the NAND;
The third acquiring unit 504, for obtaining the second physical address and corresponding second identifier information, described second
Physical address is the physical storage address of the map information on the updated NAND as unit of block;
Second updating unit 505, for being arrived second physical address update according to the second identifier information
The level-one mapping table.
In the embodiment of the present invention, the electronic equipment further includes that second judgment unit, the 4th acquiring unit and third update
Unit, wherein
The second judgment unit, for judging the second level mapping table whether all from the random storage of solid-state memory
Device is updated onto the NAND;When being, the 4th acquiring unit is triggered, when no, triggers the third updating unit;
4th acquiring unit, for obtaining second physical address and second identifier information again.
The third updating unit, for continuing to update the random access memory by the second level mapping table from solid-state memory
It updates on the NAND.
It need to be noted that: the above electronic equipment implements the description of item, is similar, tool with above method description
There is the identical beneficial effect of same embodiment of the method, therefore does not repeat them here.For undisclosed in electronic equipment embodiment of the present invention
Technical detail, those skilled in the art please refer to the description of embodiment of the present invention method and understand, to save length, here not
It repeats again.
Embodiment seven
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of electronic equipment, included the in the electronic equipment
Five acquiring units, the 6th acquiring unit, the first reading unit, the 7th acquiring unit, the 8th acquiring unit, third judging unit and
The units such as the second reading unit can be realized by the SSD controller in electronic equipment, certainly can also be by specifically patrolling
Circuit is collected to realize;During specific embodiment, processor can be central processing unit (CPU), microprocessor (MPU), number
Word signal processor (DSP) or field programmable gate array (FPGA) etc..
The electronic equipment include the 5th acquiring unit, the 6th acquiring unit, the first reading unit, the 7th acquiring unit,
8th acquiring unit, third judging unit and the second reading unit, in which:
5th acquiring unit, for obtaining third physical address, the third physics from the level-one mapping table
Address is by the physical address that stores in a map unit in the level-one mapping table;The third physical address is third area
The physical address of block;
6th acquiring unit, the second level mapping table for obtaining third block according to the third physical address are believed
Breath;
First reading unit, for the NAND by the second level map information of the third block from solid-state memory
On read in the random access memory of solid-state memory;
7th acquiring unit, for obtaining third identification information, the third mark letter from the level-one mapping table
Breath is the identification information of block corresponding to third physical address;
8th acquiring unit, for according to third physical address from the second level map information of the third block
Obtain the 4th identification information;
The third judging unit, for judging whether the third identification information is same with the 4th identification information expression
One block;When being, second reading unit is triggered;
Second reading unit, it is solid for reading the second level map information from the NAND of solid-state memory
In the random access memory of state memory.
In the embodiment of the present invention, the electronic equipment further includes the 9th acquiring unit, the first writing unit, the tenth acquisition list
Member and the second writing unit, in which:
9th acquiring unit, for obtaining corresponding block according to third identification information in the level-one mapping table
Physical address;
First writing unit, for when the number of the physical address of the block be equal to 1 when, by the object of the block
It manages in the map unit in address write-in level-one mapping table in third identification information;
Tenth acquiring unit, for obtaining each block when the number of the physical address of the block is greater than 1
Timestamp information corresponding to physical address;
Second writing unit, in the physical address write-in level-one mapping table by the nearest block of timestamp information
In map unit in third identification information.
It need to be noted that: the above electronic equipment implements the description of item, is similar, tool with above method description
There is the identical beneficial effect of same embodiment of the method, therefore does not repeat them here.For undisclosed in electronic equipment embodiment of the present invention
Technical detail, those skilled in the art please refer to the description of embodiment of the present invention method and understand, to save length, here not
It repeats again.
Embodiment eight
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of electronic equipment, included the in the electronic equipment
The units such as nine acquiring units, the first writing unit, the tenth acquiring unit and the second writing unit, can be by electronic equipment
SSD controller realize, certainly can also be realized by specific logic circuit;During specific embodiment, processor
It can be central processing unit (CPU), microprocessor (MPU), digital signal processor (DSP) or field programmable gate array
(FPGA) etc..
The electronic equipment includes the 9th acquiring unit, the first writing unit, the tenth acquiring unit and the second writing unit,
Wherein:
9th acquiring unit, for obtaining corresponding block according to the identification information of block in the level-one mapping table
Physical address;
First writing unit, for when the number of the physical address of the block be equal to 1 when, by the object of the block
It manages in the map unit in address write-in level-one mapping table in the identification information of corresponding block;
Tenth acquiring unit, for obtaining each block when the number of the physical address of the block is greater than 1
Timestamp information corresponding to physical address;
Second writing unit, in the physical address write-in level-one mapping table by the nearest block of timestamp information
In map unit in the identification information of corresponding block.
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of electronic equipment, and the electronic equipment includes that solid-state is deposited
Reservoir SSD, Fig. 6 is the composed structure schematic diagram of solid-state memory in the embodiment of the present invention, as shown in fig. 6, the solid-state storage
Device 600 includes NAND 601 and SSD controller 602, wherein
All logical page (LPAGE)s on host are mapped as solid-state storage for mapping using page grade by the SSD controller
The Physical Page of NAND on device forms second level mapping table;The first physical address is obtained, first physical address is that the second level is reflected
The physical storage address of first block in firing table maps first physical address and corresponding first identifier information in level-one
Mapping relations are formed in map unit in table, wherein the first identifier information is the identification information of the first block.
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of electronic equipment again, and the electronic equipment includes solid-state
Memory SSD, the solid-state memory include NAND and SSD controller, wherein
The SSD controller, for obtaining the parameter for updating mapping table;Judge whether the parameter meets preset item
Part;When meeting the preset condition, by the map information in the second level mapping table from the random storage of solid-state memory
Device is updated onto the NAND;The second physical address and corresponding second identifier information are obtained, second physical address is more
The physical storage address of map information on the NAND after new as unit of block;According to the second identifier information by institute
The second physical address is stated to update to the level-one mapping table.
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of electronic equipment again, and the electronic equipment includes solid-state
Memory SSD, the solid-state memory include NAND and SSD controller, wherein
The SSD controller, for obtaining third physical address, the third physical address from the level-one mapping table
By the physical address stored in a map unit in the level-one mapping table, the third physical address is third block
Physical address;The second level map information of third block is obtained according to the third physical address;It is obtained from the level-one mapping table
Third identification information is taken, the third identification information is the identification information of block corresponding to third physical address;According to third object
Reason address obtains the 4th identification information from the second level map information of the third block;Judging the third identification information is
It is no to indicate same block with the 4th identification information;When being, the second level map information of the third block is deposited from solid-state
It is read in the random access memory of solid-state memory on the NAND of reservoir.
Based on embodiment above-mentioned, the embodiment of the present invention provides a kind of electronic equipment again, and the electronic equipment includes solid-state
Memory SSD, the solid-state memory include NAND and SSD controller, wherein
The SSD controller, for obtaining corresponding block according to the identification information of block in the level-one mapping table
Physical address;When the number of the physical address of the block is equal to 1, level-one mapping table is written into the physical address of the block
In corresponding block identification information in map unit in;When the number of the physical address of the block is greater than 1, obtain each
Timestamp information corresponding to the physical address of a block;The physical address write-in level-one of the nearest block of timestamp information is reflected
In map unit in firing table in the identification information of corresponding block.
It need to be noted that: the above electronic equipment implements the description of item, is similar, tool with above method description
There is the identical beneficial effect of same embodiment of the method, therefore does not repeat them here.For undisclosed in electronic equipment embodiment of the present invention
Technical detail, those skilled in the art please refer to the description of embodiment of the present invention method and understand, to save length, here not
It repeats again.
It should be understood that " one embodiment " or " embodiment " that specification is mentioned in the whole text mean it is related with embodiment
A particular feature, structure, or characteristic is included at least one embodiment of the present invention.Therefore, occur everywhere in the whole instruction
" in one embodiment " or " in one embodiment " not necessarily refer to identical embodiment.In addition, these specific features, knot
Structure or characteristic can combine in any suitable manner in one or more embodiments.It should be understood that in various implementations of the invention
In example, magnitude of the sequence numbers of the above procedures are not meant that the order of the execution order, and the execution sequence of each process should be with its function
It can determine that the implementation process of the embodiments of the invention shall not be constituted with any limitation with internal logic.The embodiments of the present invention
Serial number is for illustration only, does not represent the advantages or disadvantages of the embodiments.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row
His property includes, so that the process, method, article or the device that include a series of elements not only include those elements, and
And further include other elements that are not explicitly listed, or further include for this process, method, article or device institute it is intrinsic
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do
There is also other identical elements in the process, method of element, article or device.
In several embodiments provided herein, it should be understood that disclosed device and method can pass through it
Its mode is realized.Apparatus embodiments described above are merely indicative, for example, the division of the unit, only
A kind of logical function partition, there may be another division manner in actual implementation, such as: multiple units or components can combine, or
It is desirably integrated into another system, or some features can be ignored or not executed.In addition, shown or discussed each composition portion
Mutual coupling or direct-coupling or communication connection is divided to can be through some interfaces, the INDIRECT COUPLING of equipment or unit
Or communication connection, it can be electrical, mechanical or other forms.
Above-mentioned unit as illustrated by the separation member, which can be or may not be, to be physically separated, aobvious as unit
The component shown can be or may not be physical unit;Both it can be located in one place, and may be distributed over multiple network lists
In member;Some or all of units can be selected to achieve the purpose of the solution of this embodiment according to the actual needs.
In addition, each functional unit in various embodiments of the present invention can be fully integrated in one processing unit, it can also
To be each unit individually as a unit, can also be integrated in one unit with two or more units;It is above-mentioned
Integrated unit both can take the form of hardware realization, can also realize in the form of hardware adds SFU software functional unit.
Those of ordinary skill in the art will appreciate that: realize that all or part of the steps of above method embodiment can pass through
The relevant hardware of program instruction is completed, and program above-mentioned can store in computer-readable storage medium, which exists
When execution, step including the steps of the foregoing method embodiments is executed;And storage medium above-mentioned includes: movable storage device, read-only deposits
The various media that can store program code such as reservoir (Read Only Memory, ROM), magnetic or disk.
If alternatively, the above-mentioned integrated unit of the present invention is realized in the form of software function module and as independent product
When selling or using, it also can store in a computer readable storage medium.Based on this understanding, the present invention is implemented
Substantially the part that contributes to existing technology can be embodied in the form of software products the technical solution of example in other words,
The computer software product is stored in a storage medium, including some instructions are used so that computer equipment (can be with
It is personal computer, server or network equipment etc.) execute all or part of each embodiment the method for the present invention.
And storage medium above-mentioned includes: various Jie that can store program code such as movable storage device, ROM, magnetic or disk
Matter.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.