CN103092719B - A kind of power-off protection method of file system - Google Patents
A kind of power-off protection method of file system Download PDFInfo
- Publication number
- CN103092719B CN103092719B CN201110336102.7A CN201110336102A CN103092719B CN 103092719 B CN103092719 B CN 103092719B CN 201110336102 A CN201110336102 A CN 201110336102A CN 103092719 B CN103092719 B CN 103092719B
- Authority
- CN
- China
- Prior art keywords
- daily record
- data
- critical data
- district
- critical
- 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.)
- Active
Links
Landscapes
- Techniques For Improving Reliability Of Storages (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention relates to the power-off protection method of a kind of file system; including: 1. the power-off protection method of a file system; it is characterized in that; the method comprises the following steps: critical data file system may revised in running all preserves two parts, corresponds to critical data district one and critical data district two;Write daily record, including: critical data needing the address of data of amendment and the length records of data in daily record;Synchronous counting updates once;And calculating check code;Daily record is saved in log area one, corresponds to daily record one;Data are revised in critical data district one;Daily record is saved in log area two, corresponds to daily record two;Data are revised in critical data district two;And, after power-off restarting, the recovering step of data includes: reads daily record one and daily record two, verification daily record one and the integrity of daily record two, recovers critical data according to the information of daily record one and the log recording of the integrity of daily record two and daily record one and daily record two.
Description
Technical field
The present invention relates to technical field of information processing, particularly relate to the power-off protection method of file system.
Background technology
In digitized audio-video monitoring field, along with the development of embedded technology, embedded digital is hard
Dish videocorder (EDVR, Embedded Digital Video Recorder) performance, function,
The suitability, maintainability, stability each side have had the improvement of essence, therefore its application
Wider, develop into from initial financial field traffic, public security, electric power, vehicle-carried mobile,
The various application places such as mining.Along with variation, the complication of applied environment, to embedded digital
Reliability and the failover capability of DVR are had higher requirement.
Common built-in hard disk video tape recorder cannot normally record a video or lose video file mainly due to
File system key message that the reasons such as system exception power down cause is lost or the reason such as imperfect causes
Mistake.
Traditional file system, do at this block of abnormal power-down such as fat32, ext3 etc. is not very
Good, after repeatedly abnormal power-down, often occur that heap file is lost, or file system is destroyed
Cannot recover again.Its main cause is that file system occurs power-off, now when updating critical data
It is possible to cause file to lose, or file system critical data is imperfect causes the file system can not
Situation.For this problem, the most existing a kind of solution is exactly literary composition when formatting
Part system-critical data disposably writes, and the most no longer revises, and this method can make file system
Not there is versatility, it is impossible to be suitable for a lot of application scenarios.
Summary of the invention
For overcoming above-mentioned deficiency, the invention provides the power-off protection method of a kind of file system, should
Method comprises the following steps:
Critical data file system may revised in running all preserves two parts, corresponding
For critical data district one and critical data district two;
Writing daily record, the information of described log recording includes the ground needing the data of amendment in critical data
Location and the length of data;Synchronous counting, critical data often revises once, and synchronous counting updates one
Secondary;And check code, this check code is used for confirming that this daily record is the most complete;
The described step writing daily record includes: critical data needs amendment data address and
The length records of data is in daily record;Synchronous counting updates once;And calculating check code;
Daily record is saved in log area one, corresponds to daily record one;
Data are revised in critical data district one;
Daily record is saved in log area two, corresponds to daily record two;
Data are revised in critical data district two;
And, after power-off restarting, the recovering step of data includes:
Reading daily record one and daily record two, verification daily record one and the integrity of daily record two, according to daily record one
Recover to close bond number with the information of the integrity of daily record two and the log recording of daily record one and daily record two
According to.
Passing through the present invention, it is ensured that during abnormal power-down, file directory is complete, reduces the loss of file,
Prevent file system because abnormal power-down causes collapse.
Accompanying drawing explanation
Fig. 1 is the flow chart of amendment critical data according to an embodiment of the invention;
Fig. 2 is the flow chart of power interruption recovering according to an embodiment of the invention.
Detailed description of the invention
Below in conjunction with the accompanying drawings and example, the power-off that the present invention monitors storage device file system is protected
Maintaining method is further elaborated.
The technical solution adopted in the present invention include fdisk formatting, the amendment of critical data,
Three aspects of the recovery of critical data after power-off restarting.
Before being introduced, the daily record in the lower present invention of first explanation needs the information of record: 1,
Critical data needs address and the length of data of amendment, is used for recording in critical data amendment
Which is local, so has only to the portion in a copy of it critical data power interruption recovering when
Divided data is written to another part just, it is not necessary to whole part critical data is all copied over, Ke Yijie
Save the time of power interruption recovering;2, synchronous counting, critical data often revise once (here be once
One amendment process, is Liang Kuai critical data district and all revises), synchronous counting updates once, synchronizes
Counting updates critical data renewal corresponding to daily record once more, and (such as, synchronous counting adds 1, at this
In the case of, that block critical data corresponding to daily record that synchronous counting is big updates), it is also used for recovering simultaneously
Judge during critical data which number evidence is complete;3, check code, is used for whether confirming this daily record
Completely, because power-off is it can also happen that during writing daily record, portion may have only been write in now daily record
Divided data, then this part of daily record is not the most a complete daily record.
Fdisk formats and includes:
1.1), the critical data of file system all preserve two parts, be designated as critical data district one respectively, two.
1.2), distribute two pieces of regions for log, be designated as log area one, two respectively, every piece
Regional record portion daily record.
The amendment process of critical data is as follows, and corresponding flow chart is shown in Fig. 1:
2.1) before making an amendment, first in internal memory, daily record is finished writing.Critical data needs amendment
Address and the length records of data in daily record, synchronous counting adds 1, calculates check code.(this
Place uses the mode of CRC check to calculate check code).It is to be understood that, any may be used for realizes
The check code computational methods of the purpose of check code mentioned in the present invention can use.As above
Described, in the present invention, check code is the most complete for confirming a daily record.
2.2) daily record is saved in log area one.
2.3) data are revised in critical data district one.
2.4) daily record is saved in log area two.
2.5) data are revised in critical data district two.
After power-off restarting, the recovery process of critical data is as follows, and corresponding flow chart is shown in Fig. 2:
3.1) from log area one, two, read two parts of daily records respectively, be designated as daily record one, two.
3.2) first verifying the integrity of these two parts of daily records, the integrity of daily record has three kinds of situations: 1,
Power-off occurs writing log area one when, and daily record is only written with part and is not completely written, this
Situation daily record one is incomplete (corresponding to verifying unsuccessfully);2, send out writing log area two when
Raw power-off, daily record is only written with part and is not completely written, and this situation daily record two is incomplete
(corresponding to verifying unsuccessfully);3, power-off does not occur during writing log area, this situation
Lower two parts of daily records are all complete (corresponding to verifying successfully).
3.3) if daily record one is imperfect, i.e. there occurs 3.2) in the first situation.This situation
Illustrating not start to write critical data district, critical data is complete, the most last that part of amendment
Data are lost.Have only to a daily record two and write in log area one just.
3.4) if daily record two is imperfect, i.e. there occurs 3.2) in the second situation.This situation
Illustrate that critical data has been successfully written critical data district one, do not start to write critical data district two,
Need to update the data in critical data district two.According to the address recorded in daily record one and data length,
From critical data district one, read these data, write critical data district two.Then daily record one is write
Enter to log area two.
3.5) if two pieces of daily records are all complete (that is, the information of two pieces of daily records are the most correct), i.e. send out
Given birth to 3.2) in the third situation.The when that so power-off being likely to occur in and writes critical data district,
Light cannot analyze the write situation of critical data from the integrity of daily record, needs to compare two
In part daily record synchronous counting.Synchronous counting in two parts of daily records has three kinds of situations: 1, writing pass
Power-off occurs the when of key data district one, and now daily record is successfully written log area one, does not the most write
Log area two, the synchronous counting bigger than the synchronous counting in daily record two 1 in this situation daily record one;2、
Power-off occurs writing critical data district two, and now daily record is successfully written log area one, two, this
The synchronous counting of two parts of daily records of situation is identical;3, power-off does not occur writing critical data district and daily record
When, do not write daily record and do not write critical data, the synchrometer of this two parts of daily records of situation
Number is the most identical.
3.6) if the synchronous counting in daily record one bigger than the synchronous counting in daily record two 1, i.e. there occurs
3.5) the first situation in.This situation cannot conclude that critical data has been successfully written
Critical data district one, needs to recover the amendment in critical data district one.According to record in daily record one
Address and data length, read these data from critical data district two, writes critical data district
One.Then daily record two is written to log area one.
3.7) if synchronous counting is identical, it is impossible to explanation there occurs 3.5) in the second or
Three kinds of situations, unified process when the second situation, because if be the third situation be exactly nothing but many
The most useless data copy, does not affect the correctness of data.This situation cannot conclude key
Data have been successfully written critical data district two, need to update the data in critical data district two,
Now the data of two parts of daily records are identical.
According to the address recorded in daily record (daily record one or daily record two) and data length, from key
Data field one is read these data, writes critical data district two.
Claims (1)
1. the power-off protection method of a file system, it is characterised in that the method includes following step
Rapid:
Critical data file system may revised in running all preserves two parts, corresponding
For critical data district one and critical data district two;
Writing daily record, the information of described log recording includes the ground needing the data of amendment in critical data
Location and the length of data;Synchronous counting, critical data often revises once, and synchronous counting updates one
Secondary;And check code, this check code is used for confirming that this daily record is the most complete;
The described step writing daily record includes: critical data needs amendment data address and
The length records of data is in daily record;Synchronous counting updates once;And calculating check code;
Daily record is saved in log area one, corresponds to daily record one;
Data are revised in critical data district one;
Daily record is saved in log area two, corresponds to daily record two;
Data are revised in critical data district two;
And, after power-off restarting, the recovering step of data includes:
Reading daily record one and daily record two, verification daily record one and the integrity of daily record two, according to daily record one
Recover to close bond number with the information of the integrity of daily record two and the log recording of daily record one and daily record two
According to;
Wherein, if check results is that daily record one is imperfect, daily record two is complete, then daily record two copied
Shellfish is to daily record one;
If check results is that daily record one is complete, daily record two is imperfect, then according to record in daily record one
Address and data length, from critical data district one, read these data, write critical data
District two, is then written to log area two daily record one;
If it is all complete that check results is daily record one and daily record two, and the synchronous counting phase of daily record one
Have updated once for daily record two synchronous counting, then according to the address recorded in daily record one and number more
According to length, from critical data district two, read these data, write critical data district one, then
Daily record two is written to log area one;If it is all complete that comparative result is two pieces of daily records, and daily record is together
Step counting is identical with daily record two synchronous counting, then according to the address recorded in daily record one or two and number
According to length, from critical data district one, read these data, write critical data district two.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110336102.7A CN103092719B (en) | 2011-10-28 | 2011-10-28 | A kind of power-off protection method of file system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110336102.7A CN103092719B (en) | 2011-10-28 | 2011-10-28 | A kind of power-off protection method of file system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103092719A CN103092719A (en) | 2013-05-08 |
CN103092719B true CN103092719B (en) | 2016-09-07 |
Family
ID=48205324
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201110336102.7A Active CN103092719B (en) | 2011-10-28 | 2011-10-28 | A kind of power-off protection method of file system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103092719B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105426268B (en) * | 2015-11-16 | 2018-06-26 | 北京四方继保自动化股份有限公司 | A kind of method of file system corruption when preventing the protective relaying device from powering off |
CN109857708B (en) * | 2019-02-26 | 2022-12-23 | 上海仰歌电子科技有限公司 | Data access method of embedded system and computer readable storage medium |
CN111209132B (en) * | 2019-12-31 | 2023-07-28 | 航天信息股份有限公司 | Embedded system, power-down protection method, electronic device and storage medium |
CN111428260A (en) * | 2020-06-15 | 2020-07-17 | 广东电网有限责任公司佛山供电局 | File security access control method and system based on chip protection device |
CN113672572B (en) * | 2021-08-28 | 2024-02-09 | 芯河半导体科技(无锡)有限公司 | Log storage method of embedded linux system syslog |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1598777A (en) * | 2003-09-17 | 2005-03-23 | 三星电子株式会社 | Method and system for updating software |
CN1684041A (en) * | 2004-04-14 | 2005-10-19 | 华为技术有限公司 | Data preserving method for random storage |
CN1855059A (en) * | 2005-04-21 | 2006-11-01 | 中兴通讯股份有限公司 | Method for accessing data file of telecommunication apparatus |
CN101183322A (en) * | 2006-11-16 | 2008-05-21 | 三星电子株式会社 | Method for deferred logging and apparatus thereof |
CN101681312A (en) * | 2008-02-29 | 2010-03-24 | 株式会社东芝 | Memory system |
CN101706783A (en) * | 2009-11-16 | 2010-05-12 | 中兴通讯股份有限公司 | Method and device for checking and repairing files in embedded equipment |
CN102024022A (en) * | 2010-11-04 | 2011-04-20 | 曙光信息产业(北京)有限公司 | Method for copying metadata in distributed file system |
CN102043686A (en) * | 2009-10-20 | 2011-05-04 | 华为技术有限公司 | Disaster tolerance method, backup server and system of memory database |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7624129B2 (en) * | 2006-06-30 | 2009-11-24 | Microsoft Corporation | Dual logging of changes to a user preference in a computer device |
-
2011
- 2011-10-28 CN CN201110336102.7A patent/CN103092719B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1598777A (en) * | 2003-09-17 | 2005-03-23 | 三星电子株式会社 | Method and system for updating software |
CN1684041A (en) * | 2004-04-14 | 2005-10-19 | 华为技术有限公司 | Data preserving method for random storage |
CN1855059A (en) * | 2005-04-21 | 2006-11-01 | 中兴通讯股份有限公司 | Method for accessing data file of telecommunication apparatus |
CN101183322A (en) * | 2006-11-16 | 2008-05-21 | 三星电子株式会社 | Method for deferred logging and apparatus thereof |
CN101681312A (en) * | 2008-02-29 | 2010-03-24 | 株式会社东芝 | Memory system |
CN102043686A (en) * | 2009-10-20 | 2011-05-04 | 华为技术有限公司 | Disaster tolerance method, backup server and system of memory database |
CN101706783A (en) * | 2009-11-16 | 2010-05-12 | 中兴通讯股份有限公司 | Method and device for checking and repairing files in embedded equipment |
CN102024022A (en) * | 2010-11-04 | 2011-04-20 | 曙光信息产业(北京)有限公司 | Method for copying metadata in distributed file system |
Also Published As
Publication number | Publication date |
---|---|
CN103092719A (en) | 2013-05-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102955720B (en) | A kind of method improving ext file system stability | |
CN103092719B (en) | A kind of power-off protection method of file system | |
CN102207897B (en) | Incremental backup method | |
CN102323930B (en) | Mirroring data changes in a database system | |
CN104811645A (en) | Embedded video-recording data storage method | |
CN101815983A (en) | Method and system for preventing corruption of hard disk drive file system | |
CN103365766B (en) | A kind of method and system of file integrality protection | |
US20130332416A1 (en) | Reducing data transfers while eliminating data loss for asynchronous replication of databases | |
CN105224891A (en) | Magnetic disc optic disc fused data method for secure storing, system and device | |
CN104166605A (en) | Data backup method and system based on incremental data files | |
CN104750755A (en) | Method and system for recovering data after switching between main database and standby database | |
WO2017097233A1 (en) | Fault tolerance method for data storage load and iptv system | |
CN104572762A (en) | Method and device for deleting and recovering video files | |
CN203260027U (en) | Backup device and data backup system | |
JP2005050073A (en) | Data restoration method, and data recorder | |
US7600151B2 (en) | RAID capacity expansion interruption recovery handling method and system | |
CN105653385B (en) | A kind of vehicle-mounted kinescope method | |
CN101916234A (en) | Information maintenance method and system of storage equipment | |
CN103902227A (en) | Appending write and sharing read supporting file storage method | |
CN112925676B (en) | WAL-based method for realizing recovery of distributed database cluster at any time point | |
CN104239182B (en) | Cluster file system split-brain processing method and device | |
CN105993002A (en) | In-place disk unformatting | |
CN111460035A (en) | Database system and disaster tolerance method thereof | |
CN105489236A (en) | USB (Universal Serial Bus) flash disk capable of guaranteeing software reliability on the basis of partitioned storage, and use method | |
CN111858139A (en) | Method and device for detecting silent data errors |
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 |