A kind of method improving solid state disk data transmission efficiency
Technical field
The present invention relates to a kind of method improving solid state disk data transmission efficiency, for solving the problem that solid state hard disc address does not line up, belonging to technical field of computer data storage.
Background technology
Solid state hard disc (Solid State Disk, SSD), is a kind of hard disk adopting solid-state electronic storage chip array to make, is made up of control module and storage unit.With traditional mechanical hard disk (Hard DiskDrive, HDD) compare, solid state hard disc reading speed, power consumption, noise, shock resistance, volume, operating temperature range, appearance valency than etc. in all there is clear superiority, be widely used in the fields such as military affairs, vehicle-mounted, industry control, video monitoring, network monitoring, the network terminal, electric power, medical treatment, aviation, navigator.
According to the difference of storage medium, solid state hard disc is divided into two kinds, a kind of flash memory (FLASH chip) that adopts is as storage medium, and another adopts dynamic RAM (Dynamic RandomAccess Memory, DRAM) as storage medium.Wherein, the maximum advantage of the solid state hard disc based on flash memory is removable, and data protection is not by Energy control, can be adapted to various environment.Its internal structure of solid state hard disc based on flash memory is simple, in solid state hard disc, main body is one piece of printed circuit board (Printed Circuit Board, PCB), and on this block pcb board the most basic accessory be control chip, memory chip and the flash chip for storing data.Wherein, control chip is the brain of solid state hard disc, its effect one is the loads of rational allocation data on each flash chip, is second the transfer bearing whole data, connects flash chip and outside SATA (Serial Advanced TechnologyAttachment) interface; Memory chip is used for auxiliary main control chip and carries out data processing.
Compared with traditional mechanical hard disk, the shortcoming of solid state hard disc is: 1. owing to being subject to the restriction of flash memory wiping/writing number of times, its serviceable life is relatively short.Traditional mechanical hard disk is in units of sector, and solid state hard disc stores data usually in units of page.In order to extend solid state hard disc serviceable life, most solid state hard discs has the process of abrasion equilibration, the i.e. double write operation to same logical address, and the actual physical location of carrying out write operation at flash memory is different.2. when carrying out write operation to solid state hard disc, if the logical address of write operation is not alignd with the base unit (page) of solid state hard disc, may occur that data move phenomenon from a Hash memory pages to another Hash memory pages, that is: when carrying out write operation to solid state hard disc, if when the base unit of the logical address of write operation and solid state hard disc (page) does not line up, first the write operation page in flash memory is needed to read in the internal memory of solid state hard disc, then in the internal memory of solid state hard disc, part replacement is carried out to this write operation page, again this write operation page in internal memory is write back in solid state hard disc.Operation like this, a large amount of time has been wasted in simple and consuming time flash data and has moved in operation, affects transfer efficiency and the serviceable life of solid state hard disc.3. the data of main frame all will through SDRAM (Synchronous Dynamic Random Access Memory before write flash memory, synchronous DRAM) layer, but current solid state hard disc does not consider the secondary Utilizing question of these data, causes useful data to waste.
Summary of the invention
The object of the invention is to have solid state hard disc at present when the logical address of write operation and the base unit (page) of solid state hard disc do not line up to solve, cause the problem that transfer efficiency is not high, propose a kind of method improving solid state disk data transmission efficiency.The inventive method imitates stacked-type LRU (Least Recently Used by adopting a kind of data Caching Mechanism based on double-linked circular list realization and one, least recently used algorithm) skip leaf dispatching algorithm, efficiently solve the problem that solid state hard disc address does not line up, thus improve data transmission efficiency.
The object of the invention is to be achieved through the following technical solutions.
Improve a method for solid state disk data transmission efficiency, for the data transmission between main frame and solid state hard disc, described solid state hard disc comprises control chip, memory chip and flash chip; Its concrete implementation step is:
Step 1: create 1 free page double-linked circular list, 1 whole page double-linked circular list, 1 scrappy page double-linked circular list and 1 buffer zone in the internal memory of solid state hard disc.
Described free page double-linked circular list has N number of node, and N is positive integer.Each node in described free page double-linked circular list comprises 1 pointer.
Described whole page double-linked circular list and scrappy page double-linked circular list are sky.
Each node in described whole page double-linked circular list and scrappy page double-linked circular list has a mark amount (representing with symbol Flag), for representing whether the page in the buffer area that this node points to was revised, and arranged Flag=0.
Each node in described whole page double-linked circular list comprises 1 pointer.
Each node in described scrappy page double-linked circular list comprises 2 pointers, is called head pointer and tail pointer.
The size of described buffer zone is N times of the page size of described solid state hard disc.
Step 2: the buffer zone created in step 1 is divided into N number of page, and the size of each buffer zone page is identical with the page size of described solid state hard disc; Then the start address of the 1st page in pointed buffer zone of described free page double-linked circular list the 1st node is made successively, make the start address of the 2nd page in pointed buffer zone in described free page double-linked circular list the 2nd node, by that analogy, the start address of the N number of page in pointed buffer zone in the N number of node of described free page double-linked circular list is made.
Whether step 3: when host requests carries out read/write operation to described solid state hard disc, search read/write operation page according to the read/write address of request and be buffered in the buffer area of solid state hard disc.
If there is the buffer memory of this read/write operation page in the buffer zone of solid state hard disc, then directly on the buffer memory of this read/write operation page, carry out read/write operation, and after write operation, the mark amount Flag=1 of this node is set.
If the buffer memory of not this read/write operation page in the buffer zone of solid state hard disc, then judge whether free page double-linked circular list is empty, if free page double-linked circular list be empty, then adopt the dispatching algorithm that skips leaf to carry out skipping leaf scheduling operation, then the operation of execution step 4.If free page double-linked circular list is not empty, then perform the operation of step 4.
The described dispatching algorithm that skips leaf is specially:
A walks: judge whether whole page double-linked circular list is empty, if not being empty, then selecting the node of a mark amount Flag=1 from the afterbody of whole page double-linked circular list, is called by this node and waits to write back whole page node; This is waited in the flash memory of the page content write solid state hard disc write back in the buffer zone of whole page node pointer sensing; Then for free page double-linked circular list increases a new node, and the pointed of this new node is made to wait to write back the address of whole page node pointer sensing; From whole page double-linked circular list, delete this again wait to write back whole page node.If whole page double-linked circular list is empty, then perform the operation of b step.
B walks: the node selecting a mark amount Flag=1 from the afterbody of scrappy page double-linked circular list, is called the broken page node of back to zero to be written by this node; In the flash memory of the page content write solid state hard disc in the buffer zone that this back to zero to be written broken page node pointer is pointed to; Then for free page double-linked circular list increases a new node, and the address that the pointed of this new node back to zero to be written broken page node pointer points to is made; The broken page node of this back to zero to be written is deleted again from scrappy page double-linked circular list.
The described dispatching algorithm that skips leaf, when carrying out skipping leaf scheduling, is followed stacked-type LRU and is replaced principle, namely from the afterbody of whole page double-linked circular list and scrappy page double-linked circular list, selects forward a node to carry out skipping leaf replacement operation.
Step 4: be whole page operations to this page or part operation to the operation of read/write operation page described in determining step 3, if to whole page operations, from free page double-linked circular list, then extract a node city to whole page double-linked circular list, this node is called newly-increased whole page node; Then according to main frame described in step 3, solid state hard disc is carried out to the address of read/write operation, the content of this read/write operation page is read into from flash memory the core buffer page of the pointed in newly-increased whole page node; The buffer memory of this read/write operation page carries out read/write operation, and after write operation, the mark amount Flag=1 of this node is set.If what carry out is part operation, then from free page double-linked circular list, extract a node, and increase a node for scrappy page double-linked circular list, this node is called newly-increased scrappy page node, the start address of the page that the node pointer head pointer of newly-increased scrappy page node being pointed to extract from free page double-linked circular list points to; Then according to main frame described in step 3, solid state hard disc is carried out to the address of read/write operation, the content of this read/write operation page is read into from flash memory the core buffer page that in newly-increased scrappy page node, head pointer points to; The buffer memory of this read/write operation page carries out read/write operation, and after write operation, the mark amount Flag=1 of this node is set; Finally, make the head pointer of newly-increased scrappy page node point to the address of the non-NULL first character joint of this read/write operation page in buffer zone, make the tail pointer of newly-increased scrappy page node point to the address of last byte of non-NULL of this read/write operation page.
A kind of described method improving solid state disk data transmission efficiency, also comprises: solid state hard disc be in idle condition time, by buffer area data write flash memory operation, its concrete steps are:
Step a: check scrappy page double-linked circular list, judge wherein whether there is whole page node to be transferred, if there is whole page node to be transferred, then increase a new node at the head of whole page double-linked circular list, and make the address that the pointed of this new node whole page node head pointer to be transferred points to, then from scrappy page double-linked circular list, delete whole page node to be transferred.
Described whole page node to be transferred is the start address that in scrappy page double-linked circular list, head pointer points to the corresponding buffer area page, and tail pointer points to the node of the end address of the corresponding buffer area page.
Step b: the node selecting a mark amount Flag=1 from the afterbody of whole page double-linked circular list, in the flash memory of the page data pointed to by this node write solid state hard disc, and arranges mark amount Flag=0.When the node of whole page double-linked circular list not mark amount Flag=1, the node of a mark amount Flag=1 is chosen at the afterbody of scrappy page double-linked circular list, in the flash memory of the page data write solid state hard disc that this node is pointed to, juxtaposition mark amount Flag=0.Like this, when the unexpected power-off of solid state hard disc, the page data only having the node of a small amount of Flag=1 to point in whole page double-linked circular list and scrappy page double-linked circular list is not stored in the flash memory of solid state hard disc, at short notice by the data of buffer memory write solid state hard disc, can avoid loss of data.
Beneficial effect
A kind of method improving solid state disk data transmission efficiency that the present invention proposes is imitated stacked-type LRU based on the data Caching Mechanism of double-linked circular list realization and one to skip leaf dispatching algorithm by being adopted, efficiently solve the problem that solid state hard disc address does not line up, thus improve data transmission efficiency.
Embodiment
In order to technical scheme of the present invention is better described, below by 1 embodiment, the present invention will be further described.
Between main frame and solid state hard disc, carry out data transmission, solid state hard disc comprises control chip, memory chip and flash chip.Wherein, flash chip adopts Samsung K9LCG08U1M cake core; The page size of solid state hard disc is 32KB.Its concrete implementation step is:
Step 1: create 1 free page double-linked circular list, 1 whole page double-linked circular list, 1 scrappy page double-linked circular list and 1 buffer zone in the internal memory of solid state hard disc.
Described free page double-linked circular list has 128 nodes.Each node in described free page double-linked circular list comprises 1 pointer.
Described whole page double-linked circular list and scrappy page double-linked circular list are sky.
Each node in described whole page double-linked circular list and scrappy page double-linked circular list has a mark amount Flag, for representing whether the page in the buffer area that this node points to was revised, and arranged Flag=0.
Each node in described whole page double-linked circular list comprises 1 pointer.
Each node in described scrappy page double-linked circular list comprises 2 pointers, is called head pointer and tail pointer.
The size of described buffer zone is 128 times of the page size of described solid state hard disc, i.e. 4M.
Step 2: the buffer zone created in step 1 is divided into 128 pages, and the size of each buffer zone page is identical with the page size of described solid state hard disc; Then the start address of the 1st page in pointed buffer zone of described free page double-linked circular list the 1st node is made successively, make the start address of the 2nd page in pointed buffer zone in described free page double-linked circular list the 2nd node, by that analogy, the start address of the 128th page in pointed buffer zone in described free page double-linked circular list the 128th node is made.
Whether step 3: when host requests carries out read/write operation to described solid state hard disc, search read/write operation page according to the read/write address of request and be buffered in the buffer area of solid state hard disc.
If there is the buffer memory of this read/write operation page in the buffer zone of solid state hard disc, then directly on the buffer memory of this read/write operation page, carry out read/write operation, and after write operation, the mark amount Flag=1 of this node is set.
If the buffer memory of not this read/write operation page in the buffer zone of solid state hard disc, then judge whether free page double-linked circular list is empty, if free page double-linked circular list be empty, then adopt the dispatching algorithm that skips leaf to carry out skipping leaf scheduling operation, then the operation of execution step 4.If free page double-linked circular list is not empty, then perform the operation of step 4.
The described dispatching algorithm that skips leaf is specially:
A walks: judge whether whole page double-linked circular list is empty, if not being empty, then selecting the node of a mark amount Flag=1 from the afterbody of whole page double-linked circular list, is called by this node and waits to write back whole page node; This is waited in the flash memory of the page content write solid state hard disc write back in the buffer zone of whole page node pointer sensing; Then for free page double-linked circular list increases a new node, and the pointed of this new node is made to wait to write back the address of whole page node pointer sensing; From whole page double-linked circular list, delete this again wait to write back whole page node.If whole page double-linked circular list is empty, then perform the operation of b step.
B walks: the node selecting a mark amount Flag=1 from the afterbody of scrappy page double-linked circular list, is called the broken page node of back to zero to be written by this node; In the flash memory of the page content write solid state hard disc in the buffer zone that this back to zero to be written broken page node pointer is pointed to; Then for free page double-linked circular list increases a new node, and the address that the pointed of this new node back to zero to be written broken page node pointer points to is made; The broken page node of this back to zero to be written is deleted again from scrappy page double-linked circular list.
The described dispatching algorithm that skips leaf, when carrying out skipping leaf scheduling, is followed stacked-type LRU and is replaced principle, namely from the afterbody of whole page double-linked circular list and scrappy page double-linked circular list, selects forward a node to carry out skipping leaf replacement operation.
Step 4: be whole page operations to this page or part operation to the operation of read/write operation page described in determining step 3, if to whole page operations, from free page double-linked circular list, then extract a node city to whole page double-linked circular list, this node is called newly-increased whole page node; Then according to main frame described in step 3, solid state hard disc is carried out to the address of read/write operation, the content of this read/write operation page is read into from flash memory the core buffer page of the pointed in newly-increased whole page node; The buffer memory of this read/write operation page carries out read/write operation, and after write operation, the mark amount Flag=1 of this node is set.If what carry out is part operation, then from free page double-linked circular list, extract a node, and increase a node for scrappy page double-linked circular list, this node is called newly-increased scrappy page node, the start address of the page that the node pointer head pointer of newly-increased scrappy page node being pointed to extract from free page double-linked circular list points to; Then according to main frame described in step 3, solid state hard disc is carried out to the address of read/write operation, the content of this read/write operation page is read into from flash memory the core buffer page that in newly-increased scrappy page node, head pointer points to; The buffer memory of this read/write operation page carries out read/write operation, and after write operation, the mark amount Flag=1 of this node is set; Finally, make the head pointer of newly-increased scrappy page node point to the address of the non-NULL first character joint of this read/write operation page in buffer zone, make the tail pointer of newly-increased scrappy page node point to the address of last byte of non-NULL of this read/write operation page.
When solid state hard disc be in idle condition time, by buffer area data write flash memory operation, its concrete steps are:
Step a: check scrappy page double-linked circular list, judge wherein whether there is whole page node to be transferred, if there is whole page node to be transferred, then increase a new node at the head of whole page double-linked circular list, and make the address that the pointed of this new node whole page node head pointer to be transferred points to, then from scrappy page double-linked circular list, delete whole page node to be transferred.
Described whole page node to be transferred is the start address that in scrappy page double-linked circular list, head pointer points to the corresponding buffer area page, and tail pointer points to the node of the end address of the corresponding buffer area page.
Step b: the node selecting a mark amount Flag=1 from the afterbody of whole page double-linked circular list, in the flash memory of the page data pointed to by this node write solid state hard disc, and arranges mark amount Flag=0.When the node of whole page double-linked circular list not mark amount Flag=1, the node of a mark amount Flag=1 is chosen at the afterbody of scrappy page double-linked circular list, in the flash memory of the page data write solid state hard disc that this node is pointed to, juxtaposition mark amount Flag=0.Like this, when the unexpected power-off of solid state hard disc, the page data only having the node of a small amount of Flag=1 to point in whole page double-linked circular list and scrappy page double-linked circular list is not stored in the flash memory of solid state hard disc, at short notice by the data of buffer memory write solid state hard disc, can avoid loss of data.