A kind of data recovery method and device
Technical field
The present invention relates to field of data storage more particularly to a kind of data recovery methods and device.
Background technique
The data record of solid state hard disk (Solid State Disk, SSD) memory space refers to, will be in data storage cell
After effective data storage to other spaces, the data of the data storage cell are wiped.The method of the prior art is read wait count
According to each data page of storage unit, the physical address of this page is obtained, by the physical address and object corresponding in address mapping table
Reason address is compared, to judge whether the data that the data page includes are effective, if it is valid, by the data storage cell
Valid data move other data storage cells after, so that it may by the data storage cell carry out erasing operation, complete recycling.
When the data of recycling be related to the page it is more when, there are it is many read invalid datas operations, this will cause whole
Data record process takes a long time.In addition, for some solid state hard disks, such as dynamic random access memory (Dynamic
Random Access Memory, DRAM), limited random access memory (random access but will be occupied for a long time
Memory, RAM) resource, input/output (Input/Output, I/O) performance is extremely influenced, phenomena such as video frame losing occurs.
In fact, data collection only needs to read valid data, but the method for the prior art needs to read data page one by one
It takes and judges, cost recovery is higher.It would therefore be highly desirable to find a kind of method for only reading valid data, cost recovery is reduced.
Summary of the invention
For this problem, the invention proposes a kind of data recovery methods, are needed in the prior art for solving to data
Page is read one by one, the higher problem of cost recovery.
The embodiment of the present invention provides a kind of data recovery method, this method comprises:
Store the data page list that equipment reads data record unit;
The storage equipment determines in data record unit corresponding with the data page list according to the data page list
Data are N number of data page of valid data;Each data page in the data page list records data record unit
Whether data are valid data;N is the integer more than or equal to 0;
When N is greater than 0, the storage equipment backs up the data of N number of data page, and wipes the data record
All data of unit.
Optionally, the storage equipment reads the data page list of data record unit, comprising:
The storage equipment determines the data page list according to inquiry table;The inquiry table has recorded the data and returns
Receive unit and the mapping relations of the data page list and the physical storage locations of the data page list;
The storage equipment reads the data page list from the physical storage locations.
Optionally, which comprises
The data record unit includes M data page;M is the integer more than or equal to N;
The data page list includes M element, for either element in the M element, the element and the M number
Uniquely corresponded to according to a data page in page, the element be used to indicate the element uniquely corresponding data page data effectively or nothing
Effect;
When the data page list creating, for any data page in the M data page, the storage equipment is by the number
According to page, the value of corresponding element is taken as the first preset value in the data page list, and first preset value is used to indicate the data
The data of page are invalid.
Optionally, which comprises
For any data page in the M data page, write for the first time after the data page is in the data page list creating
When entering data, the corresponding element value of the data page is taken as the second preset value by the storage equipment, and second preset value is used for
Indicate that the data of the data page are effective.
Optionally, after the corresponding element value of the data page is taken as the second preset value by the storage equipment, the method
Further include:
If the data of data page storage need to update, the storage equipment stores the more new data of the data page to the
One data page;First data page is any data page in the storage equipment;
The corresponding element value of first data page described in the data page list is taken as described second by the storage equipment
Preset value;
The corresponding element value of the data page in the data page list is taken as first preset value by the storage equipment.
Optionally, after all data of data record unit described in the storage device erasing, the method also includes:
The storage equipment re-creates the data page list.
In the embodiment of the present invention, the N that data in record data record unit are valid data has been stored in advance in storage equipment
The data page for being stored with effect data is only read in the data page list of a data page according to data page list, it is not necessary to which waste operation is read
The data page for taking storage invalid data, reduces the cost of data record.
The embodiment of the present invention further provides a kind of storage medium, including program or instruction, described program or instruction quilt
It executes and realizes a kind of data recovery method provided in an embodiment of the present invention and any optional method.
The embodiment of the present invention further provides a kind of computer, including program or instruction, and described program or instruction are held
Row realizes a kind of data recovery method provided in an embodiment of the present invention and any optional method.
Based on same inventive concept, the embodiment of the present invention further provides a kind of data record device, this is device
Include:
Processing unit, storage unit, the storage unit obtain program and processing routine, the processing unit for storing
Program and processing routine are obtained for executing,
Obtain program: for reading the data page list of data record unit;
Processing routine: for determining data record unit corresponding with the data page list according to the data page list
Middle data are N number of data page of valid data;Each data page in the data page list records data record unit
Data whether be valid data;N is the integer more than or equal to 0;
And be used for, when N is greater than 0, the data of N number of data page are backed up, and wipe the data record list
All data of member.
Optionally, the acquisition program, is specifically used for:
According to inquiry table, the data page list is determined;The inquiry table have recorded the data record unit with it is described
The mapping relations of data page list and the physical storage locations of the data page list;
The data page list is read from the physical storage locations.
Optionally, the processing routine, is specifically used for:
The data record unit includes M data page;M is the integer more than or equal to N;
The data page list includes M element, for either element in the M element, the element and the M number
Uniquely corresponded to according to a data page in page, the element be used to indicate the element uniquely corresponding data page data effectively or nothing
Effect;
When the data page list creating, for any data page in the M data page, by the data page in the number
It is taken as the first preset value according to the value of corresponding element in page list, the data that first preset value is used to indicate the data page are nothing
Effect.
Optionally, the processing routine, is specifically used for:
For any data page in the M data page, write for the first time after the data page is in the data page list creating
When entering data, the corresponding element value of the data page is taken as the second preset value, second preset value is used to indicate the data page
Data be effective.
Optionally, the processing routine, is also used to:
If the data of data page storage need to update, the more new data of the data page is stored to the first data page;Institute
Stating the first data page is any data page in described device;
The corresponding element value of first data page described in the data page list is taken as second preset value;
The corresponding element value of the data page in the data page list is taken as first preset value.
Optionally, the processing routine, is also used to:
Re-create the data page list.
Detailed description of the invention
Fig. 1 is that a kind of structure of the corresponding solid state hard disk storage array of data recovery method provided in an embodiment of the present invention is shown
It is intended to;
Fig. 2 is a kind of structural schematic diagram of the corresponding data page list of data recovery method provided in an embodiment of the present invention;
Fig. 3 is a kind of step flow chart of data recovery method provided in an embodiment of the present invention;
The detail flowchart for the step of Fig. 4 is a kind of data recovery method provided in an embodiment of the present invention;
Fig. 5 is a kind of schematic diagram of the concrete methods of realizing of data recovery method provided in an embodiment of the present invention;
Fig. 6 is a kind of structural schematic diagram of data record device provided in an embodiment of the present invention.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention clearer, below in conjunction with Figure of description to this hair
It is bright to be described in further detail, it is clear that the described embodiments are only some of the embodiments of the present invention, rather than whole
Embodiment.Based on the embodiments of the present invention, those of ordinary skill in the art are obtained without making creative work
The all other embodiment obtained, shall fall within the protection scope of the present invention.
The embodiment of the present invention is described in further detail with reference to the accompanying drawings of the specification.
Hard disk is one of the storage medium of the storage equipment such as computer, server, and solid state hard disk is stored with solid-state electronic
Array and manufactured hard disk.Wherein storage array is made of a large amount of storage unit, and each storage unit can store 1 two-value number
According to (0,1).Unit is commonly stored to be arranged in rows × column matrix formation.It is that multiple disks are formed an array, as single
Disk uses, and data are stored in different disks by it in segmented fashion, the associative disk one when accessing data, in array
Movement is played, the access time of data is substantially lowered, while having more preferably space utilization rate.
The structure of the storage array of solid state hard disk is as shown in Figure 1 in the embodiment of the present invention.
The storage array is numbered from can laterally be divided into L horizontal stripe band from 1 to L;P taeniae band can be divided into from longitudinal point, compiled
Number from 1 to P.One taeniae band is made of K subband, and a subband is made of L data block, is numbered from 1 to L.In addition, each
There are multiple data pages in data block, the data page number of each data block is set as S in the embodiment of the present invention, then a horizontal stripe
Band includes PKS data page, and L, P, K, S are the integer greater than 0.
Each data page has a redundant area, and the physical address and the physical address for saving the data page are corresponding
Logical address.In computer there are also an address mapping table, for storing physical address and its mapping of each data page
Logical address when to each data access to web page, can only be connected to the object of the data page by operating the logical address of the data page
Reason address accesses the data page.After the data of former data page update, the logical address of the data page will reflect in mapping table
Penetrate the physical address of the data page of storage new data.At this point, the physical address of former data page is lost, cannot be accessed again, at this time
The data of legacy data page storage are known as invalid data, and the data of new data page storage are known as valid data.One data page will not
Not only valid data, but also storage invalid data are stored.In the embodiment of the present invention, if the logical address of a data page, reflected in address
Corresponding physical address is identical as the physical address that the data page records in firing table, then referred to as valid data page, conversely, being then known as
Invalid data page.Data in invalid data page cannot be accessed, and occupy memory space, this is undoubtedly a kind of storage resource
Waste.
Therefore, in order to make full use of storage resource, the valid data for storing valid data page in certain memory block are needed
After storing other memory blocks, which is wiped, which is known as data record.Carry out the smallest storage of data record
Unit is known as data record unit, that is to say, that cannot carry out data record to local data in data recovery unit.It needs
Bright, in the embodiment of the present invention, data record unit is horizontal stripe band.
In the embodiment of the present invention, storing is that each horizontal stripe band saves a global record valid data in the RAM of equipment
The table of page, referred to as data page list.Data page list completely records all data pages in a horizontal stripe band using bit
The validity of storing data sets 1 if the storing data of the data page is effective;Otherwise, it is set to 0.
As shown in Fig. 2, being a kind of structure of the corresponding data page list of data recovery method provided in an embodiment of the present invention
Schematic diagram.If data page shares T+1, the validity of 1 data page of every 1 expression.Therefore, every 4 byte representations, 32 numbers
According to the validity of page.In figure, the first row 0~31 indicates the serial number of each row of data page;Data page 0, data page 32 ..., data page
T-31 etc. is the number of every a line first left data page.The T integers greater than 0.Corresponding one of each data page is effectively
Position, significance bit is taken as example with binary system, and being worth is 0 or 1, and the value of the significance bit of each data page is only as an example in figure.Data page
List is after every data for having recorded certain data volume, and as unit of the data volume, the single layer cell of storage to storage equipment is dodged
It deposits in (Single-LevelCell, SLC), for example, 64 Mbytes (MByte, MB).It distinguishingly, is that data page list is deposited
Chu Manhou is stored in SLC that is, as unit of the size of data page list memory space.It should be noted that working as solid state hard disk
It, can be in hard disk power down phase of regeneration by reading horizontal stripe band when leading to data page without being stored in SLC in time when powered-off fault
In the physical address of each data page redundant area record carry out reconstruction list item, by the physical address and address of cache of the data page
In table the data page physical address carry out comparison of coherence, it is identical be then it is effective, it is different then be it is invalid, comparison procedure is shifted to an earlier date
To phase of regeneration is powered on, avoid influencing IO readwrite performance, and at most only need to restore effective corresponding to 64MB data every time
Property mark.
Storage equipment managed with a table data page list in a flash memory physical location and data page list with it is corresponding
The mapping relations of horizontal stripe band, referred to as inquiry table.For above-mentioned horizontal stripe band, a horizontal stripe band includes PKS data page,
If every 1 can indicate 1 data page, the size of the corresponding data page list of a horizontal stripe band is (P*K*S/ (8*1024))
Kilobytes (Kilobyte, KB).
Data recovery method provided in an embodiment of the present invention is described in detail below.It is the embodiment of the present invention with reference to Fig. 3
The step flow chart of the data recovery method of offer.
Step 301: storage equipment reads the data page list of data record unit.
Step 302: the storage equipment determines that data corresponding with the data page list are returned according to the data page list
Receive N number of data page that data in unit are valid data.
Whether the data of each data page are valid data in the data page list records data record unit;
N is the integer more than or equal to 0.
When step 303:N is greater than 0, the storage equipment backs up the data of N number of data page, and described in erasing
All data of data record unit.
In step 301, storage equipment loads inquiry table first, by according to the data record unit and number recorded in inquiry table
According to the relationship of page list, the data page list of the data record unit is determined, and from the storage location of data page list, reading should
The data page list of data record unit, data page list is loaded into memory.
Before step 302, the value of T significance bit is all pre-processed in data page list.In T significance bit, each
Significance bit is all uniquely corresponding with a data page in data record unit.For example, significance bit is binary value, if data
The significance bit of page is 1, then the data page is valid data page;If the significance bit of data page is 0, which is invalid data
Page.In the storage array of one solid state hard disk, when for wherein any one not stored data or erasing carries out the cross after data
Band, after first powering on, the data page list of this horizontal stripe band is created.When data page list creating, to data page list
The value of middle M element, is all pre-processed.For each data page, the storage equipment is by the data page in the data
The value of corresponding element is set as the first preset value in page list, and the data that first preset value is used to indicate the data page are nothing
Effect.For any data page in the M data page, data are written for the first time after the data page is in the data page list creating
When, the corresponding element value of the data page is taken as the second preset value by the storage equipment, and second preset value is used to indicate this
The data of data page are effective.
For example, when data page list creating, for binary system significance bit, the storage equipment is by each data page
It is invalid that significance bit, which is set as the data that 0,0 is used to indicate the data page,.For each data page, when the data page is in the data
When data being written for the first time after page list creating, the corresponding element value of the data page is taken as 1,1 and is used to indicate by the storage equipment
The data of the data page are effective.
After the corresponding element value of the data page is taken as the second preset value by storage equipment, the value of the element is it is possible to again
It is taken as the first preset value, a kind of possible implementation are as follows:
When the data of data page storage need to update, specifically, storage equipment deposits the more new data of the data page
It stores up to the first data page;First data page is any data page in the storage equipment;Equipment is stored by the data page
The physical address that logical address maps in address mapping table is updated to the physical address of the first data page;Equipment is stored by the number
According to page, the respective value of element is updated to the first preset value in data page list;It stores equipment and arranges the first data page in data page
The respective value of element is updated to the first preset value in table.
For example, the entitled data page 1 of the data page, physical address PAdr1, logical address LAdr1, storage
Data are text documents 1.When text document 1 is modified, updated, updated file is known as text document 2.Storage is set
It is standby that data page 2 is arrived into the storage of text document 2, and the physical address that LAdr1 is mapped in address mapping table is updated to text text
The physical address PAdr2 of shelves 2.Later, value of the data page 1 in data page list is revised as 0 by storage equipment, data page 2
Value in the corresponding data page list of data page 2 is revised as 1.
In step 302, the data of the current each data page storage of data page list records are effectively or invalid.According to default
Condition, if significance bit is that 1 representative is effective, significance bit is that 0 representative is invalid, will be recorded in data page list in data record unit
N number of valid data page screen.
If the data record unit is without valid data page, i.e. when N is 0, directly that the data record unit is all numbers
According to erasing.
In the step, storage equipment directly and quickly determines valid data page, highly shortened the time of garbage reclamation,
RAM resource can be discharged in time to use for IO, improve the garbage reclamation efficiency and readwrite performance of solid state hard disk.
In step 303, when N is greater than 0, the storage equipment backs up the data of N number of data page, and wipes institute
State all data of data record unit.
A kind of feasible implementation is that after the storage equipment directly reads the data of N number of data page, storage is arrived
After the other positions for storing equipment, all data of the data record unit are wiped, are unlikely to loss of effective data in this way.
Optionally, after all data of data record unit described in the storage device erasing, further includes: the storage
Equipment re-creates the data page list.Finger is re-created, after the data of data page list are wiped, by the value of each element
It is taken as the first preset value.
In the embodiment of the present invention, storage equipment is that each horizontal stripe band saves a global data page list in RAM, is used
In the validity for recording each data page in the horizontal stripe band.After a data page list storage is full, storage equipment is in a flash memory
A part of region is individually divided to save the data page list, when data page list is stored in flash memory, even if storage equipment is fallen
Electricity will not influence the record and IO performance of data page list.In addition, storage equipment provides inquiry table to save data page
The physical storage locations of list in a flash memory.Storage equipment quickly and efficiently determines valid data page according to data page list
Quantity and physical location.
In the embodiment of the present invention, the N that data in record data record unit are valid data has been stored in advance in storage equipment
The data page for being stored with effect data is only read in the data page list of a data page according to data page list, it is not necessary to which waste operation is read
The data page for taking storage invalid data, reduces the cost of data record.
As shown in figure 4, the detail flowchart for the step of being data processing method provided in an embodiment of the present invention.
Specific steps are as follows:
Step 401: storage equipment determines data record unit.
Step 402: storage equipment determines the corresponding data page list of data record unit.
Step 403: whether storage equipment judges the corresponding data page list of data record unit in RAM.
If so, thening follow the steps 406;If it is not, thening follow the steps 404.
Step 404: storage equipment determines the physical storage locations of data page list according to inquiry table.
Step 405: storage equipment loads data page list.
Step 406: storage equipment determines the valid data page of data record unit according to data page list.
Step 407: storage equipment reads the valid data page in data record unit.
Step 408: the data of storage device backup valid data page.
Step 409: all data of the storage device erasing data record unit, and re-create the data record unit
Data page list.
As shown in figure 5, being the schematic diagram of the corresponding concrete methods of realizing of data recovery method provided in an embodiment of the present invention.
Fig. 5 illustrates the horizontal stripe comprising T data page with all data page effective statuses in b, and position is the 1 expression data page
Effectively, 5 valid data pages are shared in figure, valid data page is more dispersed, shows very strong randomness.With magnesium light storage three
For grade unit (Triple-Level Cell, TLC), the time for reading a data is 80 microsecond us, and a data page size is
16KB, it is assumed that T=147456, hard disk read rate is 500MB/s, and in the case where not considering to write IO, traversal reads all data
The time of page is 4.608 seconds.
The way of the prior art is that successively traversal reads the physical address of each data page, by the physical address and the number
According to page, corresponding physical address is compared in address mapping table, if identical, then it represents that data page is effective;If it is different, then
Indicate that data have been updated, the data page is invalid.Horizontal stripe band b only exists 5 effective data pages, but this method consumes T-5
The read access time of a invalid data page.
Specific steps are as follows:
Step (1): according to inquiry table, determine horizontal stripe with data page list x corresponding to b;
Step (2): according to inquiry table, the corresponding physical location A1 of data page list x is determined;
Step (3): it is read in data page list x to RAM from A1;
Step (4): inquiry data page list x primary data page 33, data page 98, data page T-59, data page T-60 sum number
According to page T-38, corresponding bit is 1, in total 5 valid data pages;
Step (5): the data of this 5 data pages are directly read into memory;
Step (6): other memory blocks are arrived into the data storage of 5 data pages, erasing horizontal stripe band b is recycled, and again
Create data page list x.
Compared to traditional method, the present processes do not need traversal and read all data pages, it is only necessary to read 5 data
Page saves the time for reading T-5 data page.
The embodiment of the present invention further provides a kind of storage medium, including program or instruction, described program or instruction quilt
It executes and realizes a kind of data recovery method provided in an embodiment of the present invention and any optional method.
The embodiment of the present invention further provides a kind of computer, including program or instruction, and described program or instruction are held
Row realizes a kind of data recovery method provided in an embodiment of the present invention and any optional method.
As shown in fig. 6, being a kind of structural schematic diagram of data record device provided in an embodiment of the present invention.
A kind of data record device, comprising:
Processing unit 601, storage unit 602, the storage unit 602 obtain program and processing routine, institute for storing
State processing unit 601 for execute acquisition program and processing routine,
Obtain program: for reading the data page list of data record unit;
Processing routine: for determining data record unit corresponding with the data page list according to the data page list
Middle data are N number of data page of valid data;Each data page in the data page list records data record unit
Data whether be valid data;N is the integer more than or equal to 0;
And be used for, when N is greater than 0, the data of N number of data page are backed up, and wipe the data record list
All data of member.
Optionally, the acquisition program, is specifically used for:
According to inquiry table, the data page list is determined;The inquiry table have recorded the data record unit with it is described
The mapping relations of data page list and the physical storage locations of the data page list;
The data page list is read from the physical storage locations.
Optionally, the processing routine, is specifically used for:
The data record unit includes M data page;M is the integer more than or equal to N;
The data page list includes M element, for either element in the M element, the element and the M number
Uniquely corresponded to according to a data page in page, the element be used to indicate the element uniquely corresponding data page data effectively or nothing
Effect;
When the data page list creating, for any data page in the M data page, by the data page in the number
It is taken as the first preset value according to the value of corresponding element in page list, the data that first preset value is used to indicate the data page are nothing
Effect.
Optionally, the processing routine, is specifically used for:
For any data page in the M data page, write for the first time after the data page is in the data page list creating
When entering data, the corresponding element value of the data page is taken as the second preset value, second preset value is used to indicate the data page
Data be effective.
Optionally, the processing routine, is also used to:
If the data of data page storage need to update, the more new data of the data page is stored to the first data page;Institute
Stating the first data page is any data page in described device;
The corresponding element value of first data page described in the data page list is taken as second preset value;
The corresponding element value of the data page in the data page list is taken as first preset value.
Optionally, the processing routine, is also used to:
Re-create the data page list.
The application is referring to method, the process of equipment (system) and computer program product according to the embodiment of the present application
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
Although the preferred embodiment of the application has been described, it is created once a person skilled in the art knows basic
Property concept, then additional changes and modifications may be made to these embodiments.So it includes excellent that the following claims are intended to be interpreted as
It selects embodiment and falls into all change and modification of the application range.