Summary of the invention
In view of the above-mentioned deficiencies in the prior art, the present invention announces a kind of buffer area pipe that displacement is adaptive with write-back
Reason method can not only improve buffer area read-write hit rate according to load read write attribute dynamic adjustment Replacement Strategy, and can be
Cluster write-back when retain dsc data page and according to flash translation layer (FTL) (FTL) garbage reclamation pressure adjust writeback policies reduce bottom dodge
The erasing times of counterfoil.
To achieve the purpose of the present invention, the present invention uses following technical scheme:
It is a kind of displacement and the adaptive buffer management method of write-back, the buffer area is divided into cache blocks record sheet, writes
Buffer area and reading buffer;The cache blocks record sheet is for recording the data page for belonging to a logic data block in buffer area
Location information, the data page that the writing buffer is modified for cache responses write request, the reading buffer is for delaying
Deposit the data page that do not modified only in response to read request;
The management method includes the following steps:
S1, when access request arrives, whether query caching block record sheet includes the corresponding caching block message of request, if depositing
S2 is being executed, otherwise, is executing S4;
S2, with the presence or absence of the position indicator pointer for being directed toward request data page in query caching block record sheet, and if it exists, then execute
Otherwise S3 executes S5;
Hiting data page migration to the MRU position of corresponding buffer area is updated the position in corresponding cache blocks record sheet by S3
Pointer list;S8 is executed later;
S4 adds corresponding record block message into cache blocks record sheet, while initializing all information of the record block,
S5 is executed later;
S5 determines whether current buffer is full;If full, S6 is executed, otherwise, executes S7;
S6 compares the size of reading buffer Yu targets threshold Tau;If more than then selecting the number of the LRU position of reading buffer
It is rejected according to page, otherwise, selects the data page of the LRU position of writing buffer as rejecting item and execute the write-back that adaptively clusters;More
It is new to reject the corresponding record block message of data page, S7 is executed later;
The request data page of missing is loaded into corresponding buffer area, while the position for being directed toward the data page being added by S7
Into the position indicator pointer list of corresponding cache blocks record sheet, and update corresponding record block message;S8 is executed later;
S8 starts Replacement Strategy adjusting thresholds mechanism, is adjusted to threshold value Tau;Finally, terminating the place of this request
Reason.
Further, the reading buffer and writing buffer are using LRU management queue, when buffer area hit requests and load
When new data page, by hit requests and load new data page migration to queue MRU position.
Further, in the cache blocks record sheet, the information of a record block includes:It caches block number BlkNum, delay
The clean page position pointer list C-list- for rushing in area and belonging to the data page number BlkSize of the record block, belong to the record block
Index, the containing dirty pages position indicator pointer list D-list-index for belonging to the record block.
Further, in the step S3, the position indicator pointer list updated in corresponding cache blocks record sheet is specially:
The old position indicator pointer for being directed toward the migrating data page is rejected from C-list-index or D-list-index list, it
Position is moved into judgement afterwards, if moving into reading buffer, position indicator pointer is stored in C-list-index in corresponding cache blocks;It is no
Then, by the D-list-index in the position indicator pointer deposit record block of data page.
Further, in the step S6, the corresponding record block message of data page is rejected in the update, specially:
Found from C-list-index or D-list-index list be directed toward the rejecting data page old position indicator pointer simultaneously
It rejects, and updates the BlkSize=BlkSize-1 of corresponding record block.
Further, described that the position for being directed toward the data page is added to corresponding cache blocks record in the step S7
In the position indicator pointer list of table, and corresponding record block message is updated, specially:
Judge request type, if read request, then the position indicator pointer of new addition data page is stored in corresponding caching record
C-list-index in block;Otherwise, by the D-list-index in the position indicator pointer deposit record block of data page, later update pair
The BlkSize=BlkSize+1 for the record block answered.
Further, in the step S6, the process for adaptively clustering write-back is:
S61 selects the data page of writing buffer LRU position as rejecting object, and inquires the corresponding caching of the data page
D-list-index information in record block, executes S62 later;
S62 is successively read the data page that the position indicator pointer of D-list-index is directed toward, and according to positioned at buffer queue first half
Part is the principle of dsc data, and the data page being directed toward to the position indicator pointer of the D-list-index judges, and will differentiate
Reservation set Ф is added for the data page of heat, executes S63 later;
S63 calculates presently written amplification coefficient
Current write-back threshold value is calculated according to presently written amplification coefficient W
Wherein, Bw is the statistical value of buffer area write-back number in the fixed cycle;Fw is flash memory write operation in the fixed cycle
Number statistical value;BlkMaxSize is the logical data block size, and t is constant coefficient;
S64 is executed later;
Number of pages E=BlkMaxSize-N is filled up in S64, calculating, and N is data page of the current record block in writing buffer
Number, compares the size of E and Th later;If E≤Th executes S65;Otherwise, S66 is executed;
The E entire data blocks time of containing dirty pages composition for filling up page and write-back are read in S65, enabling page filling from bottom flash memory
Bottom flash memory is written;S67 is executed later;
S66, does not enable page filling, and the containing dirty pages in D-list-index are all written back into bottom flash memory, execute S67;
Data page in set Ф is all moved into reading buffer by S67, while deleting the cache blocks record of former data block
The location information of D-list-index in table, while the new position indicator pointer after transfer is stored in C-list-index;Finally tie
Shu Benci clusters write back operations.
Further, in the step S8, the starting Replacement Strategy adjusting thresholds mechanism is adjusted threshold value Tau,
Specifically adjustment process is:
S81 judges whether current request is hit, if so, executing S82, otherwise, executes S83;
S82 judges request type and hit area, if reading buffer reads hit, CRH adds 1;If reading buffer writes life
In, then CWH adds 1;If writing buffer reads hit, DRH adds 1;If writing buffer writes hit, CRH adds 1;Finally execute S83;
S83 updates current TCount, i.e. TCount=TCount+1, while updating statistical value Bw and statistical value Fw, it
After execute S84;
S84, judges whether TCount reaches threshold value update cycle CycleTime, if so, executing S85, otherwise, terminates
This of threshold value Tau updates operation;
Wherein, CRH is that statistical variable is hit in the reading of reading buffer, and CWH writes hit statistical variable for reading buffer;DRH
Statistical variable is hit for the reading of writing buffer, DWH writes hit statistical variable for writing buffer;TCount is current request operation
It counts;CycleTime is the threshold value update cycle;
S85 calculates target writing buffer unit gain DR, target reading buffer unit gain CR:
Wherein BufSize is the size for reading and writing total buffer, and Tau ' is the threshold value before updating,
Cr, Cw are that read-write time delay cost coefficient is calculated in normalizing:
Wherein, ReadDelay and WriteDelay is respectively read latency and write delay in the period;S86 is executed later.
S86 updates threshold value Tau:
Update cycle buffer area write-back number statistical value Bw=0, period flash memory write number of operations statistical value Fw=0 simultaneously,
Cycle count value TCount=1 finally terminates this update operation of threshold value Tau.
Compared with prior art, the present invention beneficial effect is:
Displacement proposed by the present invention and the adaptive buffer management method of write-back, use when loading and rejecting data page
The way to manage of page grade, and reading buffer threshold value is adjusted by periodic time self-adapting, the special variation of load read-write can be perceived, so that
The management method can obtain higher cache hit rate under a variety of loading conditions.Secondly, the manager proposed in the present invention
Method can perceive the pressure of FTL layers of garbage reclamation, be adaptively adjusted writeback policies when containing dirty pages cluster write-back, can be effective
Reduction because FTL garbage reclamation cause additional blocks erasing times, promote the overall performance and service life of solid state hard disk.
Specific embodiment
In order to make those skilled in the art more fully understand technical solution of the present invention, below in conjunction with attached drawing and specifically
Embodiment, to the present invention carry out in detail introduce explanation.
In order to which invention is further described, it is necessary first to provide the definition of related notion of the present invention:
Data cached page:The basic read/write unit of caching, it is consistent with the physical page size of flash memory.
Caching data block:Division arithmetic is carried out to physics block size by request of data page address, obtains the consistent data of quotient
The set of page composition, the maximum of the data block include that number of pages is consistent comprising number of physical pages with bottom physical block.
Logical page address:Host I/O requests P to number (Logical according to the logical address of the mark of its file system
Page Number, LPN).
Logical block number (LBN):It is also the number (Block Number, BlkNum) of caching data block, specifies the BlkNum of request P
The quotient obtained for its LPN divided by data block maximum number of pages.
A kind of displacement proposed by the present invention and the adaptive buffer management method of write-back, are divided into three portions for caching
Point:Cache blocks record sheet, writing buffer (Write Buffer) and reading buffer (Read Buffer).
Cache blocks record sheet is used to record position and state of the different data page for belonging to a data block in buffer area.
Cache blocks record sheet accelerates the inquiry of request data page by the position indicator pointer of record different data page, updates, the behaviour of write-back
Make.
As shown in Figure 1, the information of record block specifically includes in cache blocks record sheet:Current caching block number BlkNum,
The data page number BlkSize that the record block is belonged in current buffer belongs to the clean page position pointer list of the record block
C-list-index belongs to the containing dirty pages position indicator pointer list D-list-index of the record block.The size of the cache blocks and
The physical block of practical bottom is in the same size, that is, the data page number for including is identical, sizes values BlkMaxSize.Corresponding data
The logical page address (Logical Page Number, LPN) of page removes BlkMaxSize, and acquired results are denoted as the caching belonging to it
The number of block, corresponding remainder are the offset of its cache blocks.
After being used for cache responses write request modified data page (containing dirty pages), the data page of the buffer area occur for writing buffer
Queue is formed according to LRU principle to be managed;The data page in the buffer area divides cold and hot again simultaneously, and the data page of first half is
Hot page, latter half of data page are cold page.
Reading buffer is for caching the data page (clean page) that do not modify only in response to read request, the data of the buffer area
Page equally uses LRU queue management.It will be moved to writing buffer after data page response write request in the buffer area, equally write slow
Write-back, which occurs, for the dsc data page for rushing area can also be moved in reading buffer.
As shown in Fig. 2, the queue size of two kinds of buffer areas can be because in replacement process in the queue structure of read-write buffer area
Middle dynamic select replaces object and changes.
To the hit situation of read-write buffer area, bottom read-write delay, buffer area write-back number, bottom data web update is write secondary
Number carries out the statistics in period.
The reading hit statistical variable of writing buffer in the Orientation observation period is denoted as DRH, writing buffer writes hit system
Meter variable is denoted as DWH;The reading hit statistical variable of reading buffer is denoted as CRH, and the hit statistical variable of writing of reading buffer is denoted as
CWH;Buffer area write-back number is denoted as Bw in the period, and flash memory write number of operations is denoted as Fw in the period;Write delay in the period
It is denoted as WriteDelay, read latency is denoted as ReadDelay.
When the data page for selecting writing buffer is as displacement object and is written back into flash memory, by the adaptive write-back that clusters of triggering
Mechanism.
As shown in figure 3, write-back buffer block is determined by replacement data page, by the caching in the write-back mechanism that adaptively clusters
The record information of D-list-index in block record, which determines the containing dirty pages set of write-back while identifying, retains hot containing dirty pages.It is clustering back
During writing, whether page is used to fill according to current write-in amplification coefficient dynamic select.Its operating process is as follows:
S61 selects the data page V of writing buffer LRU position as rejecting object, and inquires the corresponding caching of the data page
D-list-index information in record block, executes S62 later.
S62 is successively read the data page that the position indicator pointer of D-list-index is directed toward, and according to positioned at buffer queue first half
Part is the principle of dsc data, is judged these data pages, and the data page for being determined as heat is added and retains set Ф, it
After execute S63.
S63 calculates current write-back threshold valueWherein,S64 is executed later.
Number of pages E=BlkMaxSize-N is filled up in S64, calculating, and N is data page of the current record block in writing buffer
Number, compares the size of E and Th later;If E≤Th executes S65;Otherwise, S66 is executed.
The E entire data blocks time of containing dirty pages composition for filling up page and write-back are read in S65, enabling page filling from bottom flash memory
Bottom flash memory is written, executes S67 later.
S66, does not enable page filling, and the containing dirty pages in D-list-index are all written back into bottom flash memory, execute S67.
Data page in set Ф is all moved into reading buffer by S67, while deleting the cache blocks record of former data block
The location information of D-list-index in table, while the new position indicator pointer after transfer is stored in C-list-index, finally tie
Shu Benci clusters write back operations.
In management method proposed by the present invention, in replacement data page, by comparing threshold value Tau, (current goal reads buffering
Area's size) and current reading buffer size, selection displacement buffer object.Its threshold value Tau can integrate the life of current read-write buffer area
The read-write of middle situation and bottom postpones, and is periodically adjusted, adjusting thresholds mechanism is as shown in figure 4, process is as follows:
S81 judges whether current request is hit, if so, executing S82, otherwise, executes S83;
S82 judges request type and hit area, if reading buffer reads hit, CRH adds 1;If reading buffer writes life
In, then CWH adds 1;If writing buffer reads hit, DRH adds 1;If writing buffer writes hit, CRH adds 1;Finally execute S83;
S83 updates current TCount, i.e. TCount=TCount+1, while updating statistical value Bw and statistical value Fw, it
After execute S84;
S84, judges whether TCount reaches threshold value update cycle CycleTime, if so, executing S85, otherwise, terminates
This subthreshold updates operation;
Wherein, CRH is that statistical variable is hit in the reading of reading buffer, and CWH writes hit statistical variable for reading buffer;DRH
Statistical variable is hit for the reading of writing buffer, DWH writes hit statistical variable for writing buffer;TCount is current request operation
It counts;CycleTime is the threshold value update cycle;
S85 calculates target writing buffer unit gain DR, target reading buffer unit gain CR:
Wherein BufSize is the size for reading and writing total buffer, and Tau ' is the threshold value before updating,
Cr, Cw are that read-write time delay cost coefficient is calculated in normalizing:
Wherein, ReadDelay and WriteDelay is respectively read latency and write delay in the period;S86 is executed later.
S86 updates threshold value Tau:
Update cycle buffer area write-back number statistical value Bw=0, period flash memory write number of operations statistical value Fw=0 simultaneously,
Cycle count value TCount=1 finally terminates this update operation of threshold value Tau.
As shown in figure 5, request of the invention handles main-process stream, comprise the following steps:
S1 finds corresponding caching block number pBlkNum according to No. LPN conversion of request P when a request P is reached,
It whether there is the caching block number in query caching block record sheet, and if it exists, then execute S2, otherwise, execute S4;
S2 traverses the position indicator pointer in cache blocks record list item, and inquiry request P whether there is in buffer area, if so,
S3 is executed, otherwise, executes S5;
The data page of hit, is moved to the position MRU of corresponding buffering area by S3, buffer location where interpretation request data page
It sets, while updating the position indicator pointer list in corresponding cache blocks record list item, the old pointer for being directed toward the data page is rejected, it will
It is directed toward the new pointer deposit of the data page position;S8 is executed later;
S4 adds number pBlkNum cache blocks list item information into cache blocks record sheet, initializes the BlkNum of the list item
=pBlkNum, BlkSize=0, D-list-index and C-list-index are sky, execute S5 later;
S5 judges whether current buffer is full, if full, execute S6, otherwise executes S7;
S6, the size of more current reading buffer size and threshold value Tau, if more than the LRU bit of reading buffer is then selected
The data page set is rejected;Otherwise, it selects the data page of the LRU position of writing buffer as displacement buffer area, and executes certainly
Adaptation clusters write-back mechanism;The old position for being directed toward the rejecting data page is found from C-list-index or D-list-index list
It sets pointer and rejects, and update the BlkSize=BlkSize-1 of corresponding record block;Later, S7 is executed;
The request data page of missing is read in buffer area, while interpretation its request type from flash memory by S7;If read request,
Then data page is loaded into reading buffer, while the C- of the pointer deposit cache blocks record of the position of the data page will be directed toward
In list-index;Otherwise data page is loaded into writing buffer, while position indicator pointer is stored in the D- of corresponding cache blocks record
In list-index;The BlkSize=BlkSize+1 in caching record table is updated later, later, executes S8;
S8 starts Ct value Tau, carries out period modulation to threshold value Tau, finally, terminating the processing of this request.
In the step S3, the position indicator pointer list updated in corresponding cache blocks record sheet is specially:
S31, buffer location then executes S32 if writing buffer where interpretation request data page;If reading buffer,
Then execute S33;
The data page of hit, is moved to the MRU position of writing buffer by S32, while updating corresponding cache blocks record list item
In D-list-index, the pointer of the old direction data page is rejected, the new pointer deposit of the data page position will be directed toward
D-list-index;S8 is executed later;
The data page of hit, is moved to the MRU position of reading buffer by S33, while updating corresponding C-list-index, will
The old pointer for being directed toward the data page is rejected, and new position indicator pointer is stored in C-list-index;S8 is executed later.
In order to which the process flow to management method of the invention is further described, in conjunction with specific one group of actual request
Processing example is illustrated, and the instance processes process is as shown in Figure 6.
In this example, data block size is 4 data pages, and the size of buffer area is 10 data pages, when read-write postpones
Prolong than being fixed as W/R=4/1, constant write-in amplification coefficient is W=1.5, and the threshold value update cycle is 10, current cycle count value
TCount=1, threshold value Tau initial value are 5.
In this example, request sequence is as shown in Figure 6, is made of the logical address and request type requested, such as (R,
20) read request that an access data page LPN is 20, is indicated.
In this example, the process flow of (R, 20) is requested for first:
C1 is converted to obtain caching block number pBlkNum=20/4=5 according to LPN, be whether there is in query caching block record sheet
The record information of the caching block number.
C2, there is no the information of the cache blocks, load the record list item of pBlkNum=5 into cache blocks record sheet, simultaneously
The block number BlkNum=5, BlkSize=0, C-list-index and D-list-index for updating list item are sky.
C3, load request page enter buffer area, and discovery buffer area is full, compares reading buffer size RL (4) and present threshold value Tau
(5), select writing buffer LRU position LPN=13 as displacement object.
C4, displaced page (LPN=13) belong to cache blocks VBlkNum=13/4=3, belong to the containing dirty pages LPN=of the cache blocks
14 are retained for heat, current write-back threshold valueBeing rounded is 2, and filling up page is 2, and monolith is selected to return
It writes, and reading buffer includes remainder data page, does not need additional read operation, direct monolith write-back.
C5 empties the D-list-index in VBlkNum=3 cache blocks, and the data page of LPN=14 is moved into and reads buffering
The tail portion of sector's column, and will be directed toward in the position indicator pointer deposit C-list-index of the data page
Request is loaded into buffer area by C6, judges the request to read type, the data page of LPN=20 is loaded into reading buffering
The MRU position in area, and the position indicator pointer is deposited into the C-list-index of pBlkNum=20/4=5, while updating it
BlkSize=1
C7, starting Ct value Tau updates, because of miss request, therefore cycle count value TCount is cumulative becomes 2, sentences
Disconnected TCount is less than update cycle CycleTime, so directly terminating to update adjustment, terminates the operation of this request.
In this example, the process flow of (W, 1) is requested for second:
C8 is converted to obtain caching block number pBlkNum=1/4=0 according to LPN, be whether there is in query caching block record sheet
The record information of the caching block number.
C9, traversing cache blocks C-list-index discovery, there are the data pages of LPN=1 to be located in reading buffer
C10 judges that the data page for write request, is then moved into the MRU of writing buffer by the type of request from reading buffer
Position, while the position indicator pointer of C-list-index is removed, cache blocks note will be stored in relation to the new position indicator pointer of the data page
In the D-list-index for recording table
C11, starting Ct value Tau update, because being that reading buffer writes hit, therefore statistical value CWH adds up, period later
Count value TCount is cumulative to become 3, and the not up to update cycle terminates to adjust, and terminates the operation of this request.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field
For art personnel, the invention may be variously modified and varied.All within the spirits and principles of the present invention, made any to repair
Change, equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.