CN100533406C - Method for recovering invalid data block of data files - Google Patents
Method for recovering invalid data block of data files Download PDFInfo
- Publication number
- CN100533406C CN100533406C CNB2005100375376A CN200510037537A CN100533406C CN 100533406 C CN100533406 C CN 100533406C CN B2005100375376 A CNB2005100375376 A CN B2005100375376A CN 200510037537 A CN200510037537 A CN 200510037537A CN 100533406 C CN100533406 C CN 100533406C
- Authority
- CN
- China
- Prior art keywords
- data block
- address
- invalid data
- invalid
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 23
- 230000009471 action Effects 0.000 claims abstract description 12
- 238000010586 diagram Methods 0.000 description 10
- 230000008569 process Effects 0.000 description 6
- 230000037430 deletion Effects 0.000 description 3
- 238000012217 deletion Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000011084 recovery Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Memory System (AREA)
Abstract
This invention discloses a reclaim method for invalid data clot in data files. It includes the following steps: application copy the last valid clot to the first invalid clot address; delete the valid clot; update the addresses of the first invalid clot and the last valid clot; repeat the action until the address of the first invalid clot is larger than the last valid clot; cut off the space after the last valid clot. The method could reduce the write in operation to enhance reclaiming speed and system efficiency.
Description
Technical field
The present invention relates to a kind of method for recovering invalid data block of data file, promptly discharge the method for the unnecessary file system free space that invalid data takies.
Background technology
Application program can be preserved user data hereof usually, for easy to operate, data file can be divided into the identical data block of size, and data file can form some invalid data blocks when the interpolation of carrying out user data, modification, deletion action.
In some cases, can there be a lot of invalid data blocks in the data file, wasted the free space of file system, made overall system efficiency descend, the shared file system space of these invalid data blocks need be in due course to discharge to other application program and use.
In the present similar technology, the recovery of not considering invalid data block that has, the employing that has run into the simple algorithm that invalid data block is just moved forward, unnecessary written document action is arranged in the removal process, so recovery speed are low.
Summary of the invention
Technical matters to be solved by this invention is to provide a kind of method for recovering invalid data block that reclaims fireballing data file, and it discharges the shared file system space of invalid data block, has improved system effectiveness.
For solving the problems of the technologies described above, the technical solution adopted in the present invention is: the method for recovering invalid data block that a kind of data file is provided, it may further comprise the steps: whether the address of judging first invalid data is less than the address of last valid data, if application program copies to last valid data piece the address of first invalid data block; Delete this valid data piece; Upgrade the address of first invalid data block and the address of last valid data piece; Repeat above-mentioned action up to the address of first invalid data block the address greater than last valid data piece; Block last valid data piece file space afterwards at last.
Further improvement in the technical proposal is: further comprising the steps of before reclaiming: the address of the address of first invalid data block and last valid data piece in the application records data file, and set and cause the condition that reclaims the invalid data block action: promptly the absolute quantity of invalid data block greater than a threshold values or relatively valid data number of blocks ratio greater than a threshold values.
The invention has the beneficial effects as follows: because the method for recovering invalid data block of data file of the present invention is the position that last valid data piece is moved to first invalid data block, block all invalid data blocks of end of file at last, therefore in removal process, carry out operating writing-file as few as possible, thereby improved recovery speed.
Description of drawings
Fig. 1 is the data block synoptic diagram of data file.
Fig. 2 is the process flow diagram of the method for recovering invalid data block of data file of the present invention.
Fig. 3 is the data block synoptic diagram in the invalid data block removal process.
Fig. 4 is that invalid data block reclaims the data block synoptic diagram after finishing.
Fig. 5 is the data block synoptic diagram that blocks behind the invalid data block of end.
Embodiment
The method for recovering invalid data block of data file of the present invention may further comprise the steps:
A. the address of the address of first invalid data block and last valid data piece in the application records data file, and set and cause the condition that reclaims the invalid data block action: promptly the absolute quantity of invalid data block greater than a threshold values or relatively valid data number of blocks ratio greater than a threshold values.When the deleted data piece, judge whether to satisfy above-mentioned recovering condition,, then begin to reclaim the invalid data block operations as satisfying; Definite concrete condition by application program of threshold values is provided with voluntarily, and at all events value all belongs to content of the present invention.
B. the step that reclaims action comprises at least: application program copies to last valid data piece the address of first invalid data block; Delete this valid data piece; Upgrade the address of first invalid data block and the address of last valid data piece; Repeat above-mentioned action up to the address of first invalid data block the address greater than last valid data piece; Block last valid data piece file space afterwards.
See also the data block synoptic diagram of data file shown in Figure 1, always have 9 data blocks, 5 valid data pieces are wherein arranged, 4 invalid data blocks.First_Dirty points to the address of second data block, because this is first invalid data block; Last_Clean points to the address of the 9th data block E, because this is last valid data piece.Two variablees will safeguarding during data file operation are: First_Dirty and Last_Clean, and wherein First_Dirty writes down the address of first invalid data block, and Last_Clean writes down the address of last valid data piece; Upgrade Last_Clean during the write data piece immediately, upgrade First_Dirty during the deletion invalid data block immediately.
See also the process flow diagram of the method for recovering invalid data block of data file shown in Figure 2.When reclaiming the action beginning, earlier judge that whether First_Dirty is less than Last_Clean, if, valid data piece then that Last_Clean is pointed copies to the address of First_Dirty indication, delete Last_Clean data block pointed then, upgrade Last_Clean and First_Dirty subsequently, next turn back to again and judge that First_Dirty is whether less than the step of Last_Clean; If First_Dirty, then calls file system functions greater than Last_Clean and blocks Last_Clean data block pointed invalid data block afterwards, reclaim and finish.According to the characteristics of application program, when moving last valid data piece, may be influential to other data block that is associated, need to rewrite other data block contents.
At the data block of data file shown in Figure 1, the process that reclaims invalid data block is described below:
Earlier judge that whether First_Dirty is less than Last_Clean, as shown in Figure 1, First_Dirty is less than Last_Clean, valid data piece E then that Last_Clean is pointed copies to the address of First_Dirty indication, deletion Last_Clean data block pointed is upgraded First_Dirty and Last_Clean; The data block synoptic diagram as shown in Figure 3 at this moment.
Repeat aforesaid operations, First_Dirty is still less than Last_Clean, and after the mobile data piece D, the data block synoptic diagram as shown in Figure 4.
At this moment, First_Dirty then blocks Last_Clean data block pointed invalid data block afterwards greater than Last_Clean, reclaims and finishes, and the data block synoptic diagram as shown in Figure 5.
Foregoing description is just realized a specific implementation method of the object of the invention, the strategy that core of the present invention is to reclaim invalid data block is the position that last valid data piece is moved to first invalid data block, blocks all invalid data blocks of end of file at last.
Claims (4)
1. the method for recovering invalid data block of a data file, it is characterized in that may further comprise the steps: whether the address of judging first invalid data is less than the address of last valid data, if application program copies to last valid data piece the address of first invalid data block; Delete this valid data piece; Upgrade the address of first invalid data block and the address of last valid data piece; Repeat above-mentioned action up to the address of first invalid data block the address greater than last valid data piece; Block last valid data piece file space afterwards at last.
2. the method for recovering invalid data block of data file as claimed in claim 1, it is characterized in that: further comprising the steps of before reclaiming: the address of the address of first invalid data block and last valid data piece in the application records data file, and set and cause the condition that reclaims the invalid data block action: promptly the absolute quantity of invalid data block greater than a threshold values or relatively valid data number of blocks ratio greater than a threshold values.
3. the method for recovering invalid data block of data file as claimed in claim 2, it is characterized in that: further comprising the steps of: when the deleted data piece, judge whether to satisfy one of above-mentioned setting and cause the condition that reclaims the invalid data block action, as satisfying, then begin to reclaim the invalid data block operations.
4. the method for recovering invalid data block of data file as claimed in claim 2 is characterized in that: the determining of threshold values is provided with voluntarily by the concrete condition of application program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2005100375376A CN100533406C (en) | 2005-09-22 | 2005-09-22 | Method for recovering invalid data block of data files |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2005100375376A CN100533406C (en) | 2005-09-22 | 2005-09-22 | Method for recovering invalid data block of data files |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1936865A CN1936865A (en) | 2007-03-28 |
CN100533406C true CN100533406C (en) | 2009-08-26 |
Family
ID=37954376
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2005100375376A Expired - Fee Related CN100533406C (en) | 2005-09-22 | 2005-09-22 | Method for recovering invalid data block of data files |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100533406C (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106503260B (en) * | 2016-11-18 | 2020-04-28 | 北京奇虎科技有限公司 | Method and device for improving effective storage space of database |
CN113568581B (en) * | 2021-07-29 | 2023-08-01 | 武汉天喻信息产业股份有限公司 | Multi-application resource recovery method and system for embedded equipment |
-
2005
- 2005-09-22 CN CNB2005100375376A patent/CN100533406C/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
CN1936865A (en) | 2007-03-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106598878B (en) | Solid state disk cold and hot data separation method | |
CN106484323A (en) | A kind of loss equalizing method of solid-state storage and system | |
CN102768644B (en) | Flash memory system and management method and recovery method of invalid data page information of flash memory | |
CN107391774B (en) | The rubbish recovering method of log file system based on data de-duplication | |
CN102163175B (en) | Hybrid address mapping method based on locality analysis | |
CN109542358A (en) | Solid state disk cold and hot data separation method, device and equipment | |
CN103473150A (en) | Fragment rewriting method for data repetition removing system | |
CN101673243B (en) | Data storage device and method | |
CN100389406C (en) | Method for operating data in non-volatile storage in embedded system | |
CN102779080B (en) | Method for generating snapshot, method and device for data recovery by using snapshot | |
CN106469120A (en) | Scrap cleaning method, device and equipment | |
CN107844432B (en) | Method for recovering dynamic garbage of solid state disk and solid state disk | |
CN103455433B (en) | EMS memory management process and system | |
CN111880731B (en) | Data processing method and device and related components | |
CN105630834A (en) | Method and device for realizing deletion of repeated data | |
CN109558335A (en) | A kind of file memory format of the embedded system based on Nor flash storage | |
CN100533406C (en) | Method for recovering invalid data block of data files | |
CN1162782C (en) | Processing method of rapid memory file | |
CN116225334A (en) | Cold and hot data storage method, device and medium | |
CN105653466B (en) | data storage device and flash memory control method | |
CN106648457A (en) | Method of updating reverse mapping metadata and device | |
CN101968724B (en) | Method for storing and deleting data of SD card by using embedded ARM processor | |
CN105740098A (en) | Determination method and system for stale data among backup data | |
CN103077118A (en) | Method and system for recovering invalid data | |
CN102999427B (en) | Memory hole detection and clearing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20090826 Termination date: 20180922 |
|
CF01 | Termination of patent right due to non-payment of annual fee |