The content of the invention
In view of this, it is an object of the invention to provide a kind of physical block wiring method and system, said write method exists
Judge while write whether buffer stopper belongs to invalid buffer stopper, and invalid buffer stopper is deleted.
For achieving the above object, the present invention has following technical scheme:
, there are mapping relations between logical block and multiple physical blocks in methods described in a kind of physical block wiring method, described
Multiple physical blocks include data block and certain amount of buffer stopper;The data block includes former data block and new data block, described
The specific quantity of buffer stopper is n, and n is the integer more than 1, and methods described is comprised the following steps that:
A, the mapping relations for setting up logical block and physical block;
B, sequentially to buffer stopper write data, complete the write of n buffer stopper;
C, kth buffer stopper is compareed with all buffer stoppers for writing after which, write after judging kth buffer stopper
The corresponding Sector Range of buffer stopper whether cover the corresponding Sector Range of kth buffer stopper, if covering judge kth buffer stopper
For invalid buffer stopper, otherwise it is judged to effective buffer stopper;Release the mapping relations of invalid buffer stopper and logical block;
D, chosen with the physical block of invalid buffer stopper equal amount again as buffer stopper, set up the new buffer stopper chosen and patrol
The mapping relations of block are collected, and completes the write of the buffer stopper of new selection;
E, step c-d is repeated, until n buffer stopper is effective buffer stopper, then buffered from former data block and effectively
Valid data are searched in block;The valid data are copied to into new data block;
K is more than 0 and less than the integer of n.
The physical block includes multiple Physical Page, and the logical block includes multiple sectors, and the thing that a physical block includes
The quantity of reason page is equal to the quantity of the sector that a logical block includes, then the logical block of setting up is had with the mapping relations of physical block
Body is:
Physical Page in physical block is corresponded on the sector in logical block.
The corresponding Sector Range of buffer stopper write after the kth buffer stopper covers the corresponding sector model of kth buffer stopper
Enclose specially:
When any one sector corresponding with Physical Page in kth buffer stopper, the buffer stopper for writing after kth buffer stopper
In there is corresponding Physical Page, then it is assumed that the corresponding Sector Range of buffer stopper write after kth buffer stopper covers kth buffer stopper
Corresponding Sector Range.
The valid data of searching from each physical block are specially:
Data are ultimately written into as the valid data of the sector.
Methods described also includes:
Again to successively to each buffer stopper write data when, sequentially in time for each buffer stopper labelling it is incremented by successively write meter
Number.
The valid data of searching from each physical block also include:
When it is described valid data are copied to during new data block break and restart when, compare machine according to default
Make more former data block and effective buffer stopper and write countings, to write the larger data of counting be the data that are ultimately written so as to find, and
As valid data.
Methods described also includes:
After valid data are copied in new data block, the mapping for cancelling buffer stopper and former data block with logical block is closed
System.
Randomly select physical block to set up mapping relations with logical block and write in methods described.
The physical block includes multiple Physical Page, then described to write counting for buffer stopper labelling and be specially:
Count tag will be write in each Physical Page, when in Same Physical block different Physical Page to write counting different, then with
In the physical block, writing for the 0th Physical Page is counted as effectively writing counting.
, there are mapping relations between logical block and multiple physical blocks in the system in a kind of physical block writing system, described
Multiple physical blocks include data block and certain amount of buffer stopper;The data block includes former data block and new data block, described
The specific quantity of buffer stopper is n, and n is the integer more than 1, and the system is specifically included:
Mapping block, the mapping relations for setting up logical block and physical block;
Writing module, for sequentially to buffer stopper write data, complete the write of n buffer stopper;And complete complementary module
The write of the new buffer stopper chosen;
Invalid judge module, for kth buffer stopper is compareed with all buffer stoppers for writing after which, judge
Whether the corresponding Sector Range of buffer stopper write after k buffer stoppers covers the corresponding Sector Range of kth buffer stopper, if covered
Then judge that kth buffer stopper is invalid buffer stopper, be otherwise judged to effective buffer stopper;Invalid buffer stopper is released with logical block
Mapping relations;K is more than 0 and less than the integer of n;
Complementary module, for being chosen with the physical block of invalid buffer stopper equal amount again as buffer stopper;
Effectively judge module, for when n buffer stopper is effective buffer stopper, from former data block and effective buffer stopper
Search valid data;
Copy module, for the valid data are copied to new data block.
According to above technical scheme, the beneficial effect that the present invention is present is:By the sector for contrasting each buffer stopper
Scope, so as to find invalid buffer stopper, and releases the corresponding relation of invalid buffer stopper and logical block, is achieved in integration process
In all of buffer stopper be effective buffer stopper, farthest reduce the number of times of Data Integration, extend making for NAND chip
Use the life-span.
Specific embodiment
To make purpose, technical scheme and the advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
The a part of embodiment of the present invention, rather than the embodiment of whole.Based on the embodiment in the present invention, those of ordinary skill in the art
The every other embodiment obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.
The present invention provides a kind of wiring method of physical block, is mainly used in the middle of NAND chip.Write of the present invention
In method, it is optimized on existing wiring method so that methods described can be found that invalid buffer stopper, and releases
Mapping relations between invalid buffer stopper and logical block.For the ease of being explained and illustrated to the method for the invention, herein
A kind of wiring method of NAND chip physical block of brief description first:
In the ablation process that the method is related to, between logical block and multiple physical blocks, there are mapping relations;One logical block
Include multiple sectors, and a physical block includes multiple Physical Page;Generally speaking a logical block includes number of sectors
Include the quantity of Physical Page equal to a physical block.Described logical block and sector are logically virtually built for file system
Memory element;And the physical block and Physical Page are actual storage medium, the data preserved in storage medium are by mapping
Relation reflects on virtual logical block or sector, and sets up the mapping relations of logical block and physical block, that is, by physical block
In Physical Page correspond to the sector in logical block.
The physical block is divided into data block and buffer stopper according to the difference of purposes in ablation process;Each thing in data block
The data that reason page is preserved are the data that each sector of logical block is presented, and in data block, each Physical Page is with each sector in logical block one by one
Mapping.In general in ablation process, data block corresponding with logical block has two;One is former data block, data in former data block
The data that namely each sector of the logical block is presented originally;It is another for new data block, will the data of ablation process newly write be
The data block obtained after reintegrating to a part of legacy data, the data in new data block are exactly that each sector of the logical block is being write
Enter to complete the data for presenting afterwards.In addition, generally during write-not, when the data stabilization of logical block presentation is constant, patrolling
Collect block and only there are mapping relations with a data block.
It is described to map in namely data block each Physical Page each sector in counterlogic block in order one by one.Referring to figure
1 show the schematic diagram for mapping one by one, assumes that a physical block includes 4 Physical Page in Fig. 1, and a logical block includes 4 fans
Area.In Fig. 1, four square frames represent 4 Physical Page in physical block respectively, according to order from left to right be page 0 respectively, the 1st
Page, page 2 and page 3.Label in figure on each Physical Page represents the corresponding sector of the Physical Page, is page 0 corresponding in Fig. 1
4th sector, the 5th sector of page 1 correspondence, the rest may be inferred.Each Physical Page corresponds to reflecting for a sector in order as shown in Figure 1
Penetrate and i.e. so-called map one by one.Mapping one by one generally means that certain ablation process has finished, it is also possible to think to map one by one
It is a kind of mapping relations under logical block steady statue.
And buffer stopper needs presence at least one in ablation process.For from physical layer, need to write in ablation process
It is the buffer stopper that writes direct to enter the data in logical block sector, after a buffer stopper is fully written, can again to others
Buffer stopper writes.The mapping relations of buffer stopper and logical block are random right of each Physical Page in Random Maps, that is, buffer stopper
The sector in logical block is answered, both not necessarily in order and the correspondence for repeating was also possible to, with specific reference to concrete during write
Depending on situation.
Schematic diagram for Random Maps shown in Figure 2, also assumes that in Fig. 2 that a physical block includes 4 Physical Page, one
Individual logical block includes 4 sectors.In Fig. 2, four square frames represent 4 Physical Page in physical block respectively, according to order from left to right
It is page 0, page 1, page 2 and page 3 respectively.Label in figure on each Physical Page represents the corresponding sector of the Physical Page;
It can be seen that the 0th, 1,2 three Physical Page correspond to the 7th sector, and the 3rd Physical Page corresponds to the 6th sector.This be due to first write three
The data of individual Physical Page need to write the 7th sector, and then page of data need to write the 6th sector, Physical Page and sector
Corresponding relation is depending on write situation.The presence of buffer stopper represents that ablation process is carried out, so Random Maps can consider
It is unstabilized a kind of mapping relations between logical block and physical block.
Schematic diagram for physical block integration process shown in Figure 3, that is, using data block shown in Fig. 1 as former data block
With the concrete steps of Data Integration in buffer stopper shown in Fig. 2.Data are completed to after the write of buffer stopper, is also needed empty to one
White physical block integrates former data block and the data in buffer stopper, and the blank physical block also just will be used as new data block.With reference to Fig. 3
Shown in data block and buffer stopper from the point of view of, the corresponding Physical Page in sector may more than one, then it is corresponding in the sector
So in Physical Page, it is valid data to take the data in the Physical Page for finally being write.Will be 4 sectors corresponding effectively
Data are incorporated in a new data block according to the mode for mapping one by one, so as to replace former data block.
It is a kind of physical block wiring method related to the method for the invention above.According to the method described above in actual motion
It is central, it is found that often to there is problem below:There are multiple buffer stoppers in the middle of write-once process, and according to the rule of write
Then it is generally acknowledged that the data write after the time is upper are valid data;So in most cases, most number in new data block
According to both being from last one or several buffer stoppers.Data in the buffer stopper and former data block of relatively early write are often coated to
Lid, is considered invalid buffer stopper because valid data are not included in some buffer stoppers, rises during the arrangement of valid data
Less than effect.
It is shown in Figure 4, it is a specific embodiment of physical block wiring method of the present invention, pin in the present embodiment
To there is invalid buffer stopper in ablation process.Exist between logical block and multiple physical blocks in the present embodiment methods described
Mapping relations, the plurality of physical block include data block and certain amount of buffer stopper;The data block include former data block and
New data block, the specific quantity of the buffer stopper is n, and n is the integer more than 1, is comprised steps that:
Step 401, the mapping relations for setting up logical block and physical block;
The step is the initialization step of write.
Step 402, sequentially to buffer stopper write data, complete the write of n buffer stopper;
It is basically identical with physical block wiring method in aforementioned prior art for the write of buffer stopper described in this step.
It is the buffer stopper that writes direct that the data in logical block sector need to be write, after a buffer stopper is fully written, can again to which
His buffer stopper write.
It is n that buffering number of blocks corresponding with logical block is pre-set in the present embodiment, and n is the integer more than 1.
Need to complete the write of n buffer stopper first in ablation process, and then start follow-up flow process.
Step 403, kth buffer stopper is compareed with all buffer stoppers for writing after which, judge kth buffer stopper it
Whether the corresponding Sector Range of buffer stopper for writing afterwards covers the corresponding Sector Range of kth buffer stopper, and kth is judged if covering
Buffer stopper is invalid buffer stopper, is otherwise judged to effective buffer stopper;Release the mapping relations of invalid buffer stopper and logical block;
K is more than 0 and less than the integer of n.
In general, after the buffer stopper for completing to write reaches specific quantity n, that is, starting from buffer stopper and former data block
It is middle to search valid data and carry out arrangement and the copy of valid data.But increase number to solve invalid buffer stopper in the present embodiment
According to the problem for arranging copy number of times, the technical characteristic in step 403 is added.
Whether in this step, it is to judge certain buffer stopper as invalid buffer stopper to be substantially.Due to writing in time later
The data for entering are valid data, so the n-th buffer stopper being ultimately written in n buffer stopper necessarily valid data block, and the 1st delays
It is probably invalid buffer stopper to rush the-the (n-1)th buffer stopper of block.So in the present embodiment, taking in the 1st the-the (n-1)th buffer stopper of buffer stopper
Arbitrarily buffer stopper, i.e. kth buffer stopper, judge that the buffer stopper whether its Sector Range is write thereafter is covered.The fan of kth buffer stopper
Some buffer stopper that area's scope may be write thereafter is fully contemplated by, it is also possible to the Sector Range of the several buffer stoppers of thereafter certain
Union covers the Sector Range of kth buffer stopper.In a word, as long as inevitable in kth buffer stopper do not have valid data, then it is assumed that the
K buffer stoppers are invalid buffer stopper.
The corresponding Sector Range of buffer stopper write after the kth buffer stopper covers the corresponding sector model of kth buffer stopper
The criterion enclosed is specially:When any one sector corresponding with Physical Page in kth buffer stopper, after kth buffer stopper
There is corresponding Physical Page in the buffer stopper of write, then it is assumed that the corresponding Sector Range of buffer stopper write after kth buffer stopper
Cover the corresponding Sector Range of kth buffer stopper.
If there is no invalid buffer stopper in n buffer stopper, directly start the lookup of the valid data described in step 405
With the process of copy.
With reference to shown in Fig. 5, it is the concrete case of logical block three buffer stoppers of correspondence, that is to say, that in the present embodiment
Shown in Fig. 5, the specific quantity of buffer stopper is three, writes full three buffer stoppers when data and proceeds by subsequent process.
Visible by observing Fig. 5, in the first buffer stopper, the corresponding sector of 4 Physical Page includes the 4th, 6,7 three sectors, then
Think that the above-mentioned 4th, 6,7 three sectors are the Sector Range of the first buffer stopper;Second buffer stopper and the 3rd buffer stopper in the same manner
Sector Range is the 5th, 6,7 three sectors.
The Sector Range of contrast three can find, as the 4th sector is not in the second buffer stopper and the 3rd buffer stopper sector model
Within enclosing, so the Sector Range of the first buffer stopper is not included beyond the Sector Range of follow-up all buffer stoppers;Namely
The corresponding sector of one Physical Page of presence in first buffer stopper(4th sector), the sector is in the second buffer stopper or the 3rd buffer stopper
In no corresponding Physical Page.The valid data of the 4th sector come from the first buffer stopper.It is determined that the first buffer stopper is effective
Buffer stopper.
But only contrast the second buffer stopper to find with the 3rd buffer stopper, Sector Range >=the second buffer stopper of the 3rd buffer stopper
Sector Range, as the write time of the 3rd buffer stopper is rear, so the valid data of the 5th, 6,7 three sectors are impossible
Come from the second buffer stopper.That is in this case, when any one institute corresponding with Physical Page in the second buffer stopper
There is sector(I.e. the 5th, 6,7 three sectors)Corresponding Physical Page is equally existed in the 3rd buffer stopper, then the 3rd buffer stopper pair
The Sector Range answered covers the corresponding Sector Range of the second buffer stopper.Valid data are not included in second buffer stopper, then it is assumed that
Second buffer stopper is actually an invalid buffer stopper.
In this case, judge in the present embodiment that the second buffer stopper is invalid buffer stopper, the first buffer stopper and the 3rd delays
It is effective buffer stopper to rush block, releases the mapping relations of invalid buffer stopper and logical block.
Step 404, chosen with the physical block of invalid buffer stopper equal amount again as buffer stopper, set up the new buffering chosen
The mapping relations of block and logical block, and complete the write of the buffer stopper of new selection;
As invalid buffer stopper is found that in above-mentioned steps, and relieve the mapping pass of invalid buffer stopper and logical block
System, so the corresponding buffer stopper of logical block is no longer able to reach specific quantity n, cannot carry out valid data in this case
Integration.Some physical blocks are then now filled up again and sets up Random Maps relation with logical block, proceed as buffer stopper
Write.The quantity of the buffer stopper filled up is equal to the quantity of invalid buffer stopper in step 403, can so keep logical block corresponding
Buffering number of blocks still meets specific quantity n.For the new buffer stopper chosen is also carried out same write operation.
Step 405, step 403- step 404 is repeated, until n buffer stopper is effective buffer stopper, then from former number
According to searching valid data in block and effective buffer stopper;The valid data are copied to into new data block.
After the new buffer stopper chosen completes write in step 404, there is n buffering corresponding with logical block again
Block.For this n buffer stopper, the judge process of the invalid buffer stopper in same execution step 403 is also needed.If it is invalid still to exist
Buffer stopper, then also need to release the mapping relations of invalid buffer stopper and logical block, and fill up new again by scheme in step 404
Buffer stopper.
What is so circulated repeats step 403- step 404, until n buffer stopper is effective buffer stopper, just starts
The lookup of valid data is carried out, the process for arranging and copying.
After increasing by the 4th buffer stopper in Fig. 5, each buffer stopper is valid data block, and buffer stopper reaches certain number
Amount three.Can start to perform follow-up process.In the present embodiment, integration process and the said physical block write side of valid data
Method is consistent.
In aforesaid wiring method, as long as completing the write of specific quantity buffer stopper, then start the copy of valid data, but
Invalid buffer stopper be will likely include ones which in its multiple buffer stopper for including, thus integrate number of times do not drop to it is minimum.This enforcement
In example, only when effective buffer stopper reaches specific quantity, the copy of valid data is just carried out, actually accomplish the buffer stopper of write
Quantity is likely larger than specific quantity, so reduces the number of times of valid data integration, extends the service life of NAND chip.
The beneficial effect that the present embodiment is present is to realize that all of buffer stopper is effective buffer stopper in integration process,
The number of times of Data Integration is farthest reduced, the service life of NAND chip is extended.
It is shown in Figure 6, it is another specific embodiment of physical block wiring method of the present invention.The present embodiment institute
There are mapping relations in stating method between logical block and multiple physical blocks, the plurality of physical block includes data block and specific quantity
Buffer stopper;The data block includes former data block and new data block, and the specific quantity of the buffer stopper is n, and n is more than 1
Integer, described in the present embodiment, method specifically includes following:
Step 601, the mapping relations for setting up logical block and physical block;
The step is the initialization step of write.
Step 602, sequentially to buffer stopper write data, complete the write of n buffer stopper;Again to writing to each buffer stopper successively
When entering data, sequentially in time for each buffer stopper labelling it is incremented by successively write counting.
Step 603, kth buffer stopper is compareed with all buffer stoppers for writing after which, judge kth buffer stopper it
Whether the corresponding Sector Range of buffer stopper for writing afterwards covers the corresponding Sector Range of kth buffer stopper, and kth is judged if covering
Buffer stopper is invalid buffer stopper, is otherwise judged to effective buffer stopper;Release the mapping relations of invalid buffer stopper and logical block;
K is more than 0 and less than the integer of n.
Step 604, chosen with the physical block of invalid buffer stopper equal amount again as buffer stopper, set up the new buffering chosen
The mapping relations of block and logical block, and complete the write of the buffer stopper of new selection;
Step 605, step 603- step 604 is repeated, until n buffer stopper is effective buffer stopper;
Step 606, when it is described valid data are copied to during new data block break and restart when, according to default
The more former data block of comparison mechanism and effective buffer stopper write counting, count larger data and be ultimately written so as to find to write
Data, and as valid data.
Step 607, the valid data are copied to into new data block.
Step 608, the mapping relations for cancelling buffer stopper and former data block and logical block.
After the copy for completing valid data, cancel the mapping relations of buffer stopper and former data block and logical block, can be with
The internal memory and memory space of computer system are saved, is easy to the re-using of physical block.
If the write of whole data and integration process are to be normally carried out, period does not have any interruption, then can be in write
The Physical Page that automatic storing is ultimately written for each sector simultaneously, and valid data therein are integrated.But if write
And there is interruption and recovers again in the process integrated, then need by ad hoc approach to find out again the data being ultimately written, and
As valid data.At this stage after interrupting and recovering, to search the method for valid data mainly by labelling
And compare and write counting.It is by default mechanism to write the labelling of counting and compares.
A kind of technical scheme that counting is write with regard to local of following discloses, concrete principle are as follows:
When data are write to the first buffer stopper, write counting by the first of former data block and be incremented by and be labeled as the first buffer stopper
First writes counting;
To m buffer stoppers write data when, relative to m-1 buffer stoppers retain m write count before it is all write counting,
The numerical value that the m of m-1 buffer stoppers writes counting is incremented by, the m that the numeric indicia after described being incremented by is m buffer stoppers is write into meter
Number;M is the positive integer more than 1.
Correspondence is above-mentioned to write count tag method, enters row write for effective buffer stopper and counts the integration compared with valid data;
Method is specific as follows:
Counting is write by the first of each physical block to be compared, if first write counting it is identical if sequentially continue meter more afterwards
Number, until occurring writing, counting is different then stops comparing;The data that write in big physical block are counted as being ultimately written depending on writing
Data.In same buffer stopper all Physical Page write counting it is identical, but write order be according to Physical Page put in order into
Capable.
The present embodiment methods described further combines one kind with regard to writing meter on the basis of embodiment illustrated in fig. 4
Several technical scheme, so the beneficial effect that the present embodiment is further present is:The method of counting of writing is in Different Logic block pair
The buffer stopper answered each independently enters the labelling of row write counting, unrelated;And described level is write count tag method and is only existed
Labelling and be incremented by and write countings when buffer stopper writes, and during valid data integration valid data no longer occur it is any
Change;So the present embodiment methods described realizes the support hardware-accelerated for COPYBACK, it is possible to achieve pass through
The speed of service of the hardware-accelerated raising NAND of COPYBACK;In addition, the count tag method of writing of level described in the present embodiment drops
Low writing counts the speed being incremented by, and re-flags when logical block sets up mapping relations with physical block again and write counting, it is to avoid
Write counting constantly it is accumulative be incremented by caused by write count value increasing, so as to save whole computer system memory and
Memory space;Method and technology scheme described in the present embodiment is more perfect, open more abundant.
Furthermore it is also possible on the basis of the embodiment of the method shown in Fig. 4 or Fig. 6, further combined with following optimization side
Case:
When physical block is chosen and logical block sets up mapping relations, set up with logical block using physical block is randomly selected
Mapping relations, and the method for starting follow-up write.It is achieved from probability according to the method described above and reaches writing for all physical blocks
Balance so that the erasable number of times of all physical blocks is of substantially equal in NAND chip, extends the service life of NAND chip.
It is shown in Figure 7, it is a specific embodiment of physical block writing system of the present invention.Described in the present embodiment
System is the system that embodiment of the method shown in correspondence Fig. 4 is set up, so specifically, described in the present embodiment, system is as follows:
There are mapping relations in the system between logical block and multiple physical blocks, the plurality of physical block includes data block
With certain amount of buffer stopper;The data block includes former data block and new data block, and the specific quantity of the buffer stopper is n, n
It is the integer more than 1, the system is specifically included:
Mapping block, the mapping relations for setting up logical block and physical block;
Writing module, for sequentially to buffer stopper write data, complete the write of n buffer stopper;And complete complementary module
The write of the new buffer stopper chosen;
Invalid judge module, for kth buffer stopper is compareed with all buffer stoppers for writing after which, judge
Whether the corresponding Sector Range of buffer stopper write after k buffer stoppers covers the corresponding Sector Range of kth buffer stopper, if covered
Then judge that kth buffer stopper is invalid buffer stopper, be otherwise judged to effective buffer stopper;Invalid buffer stopper is released with logical block
Mapping relations;K is more than 0 and less than the integer of n;
Complementary module, for being chosen with the physical block of invalid buffer stopper equal amount again as buffer stopper;
Effectively judge module, for when n buffer stopper is effective buffer stopper, from former data block and effective buffer stopper
Search valid data;
Copy module, for the valid data are copied to new data block.
The present embodiment exist beneficial effect be:Realize that all of buffer stopper is effective buffer stopper in integration process,
The number of times of Data Integration is farthest reduced, the service life of NAND chip is extended.
The above is only the preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art
For member, under the premise without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications also should
It is considered as protection scope of the present invention.