CN103617101A - Power fail safeguard method and device - Google Patents

Power fail safeguard method and device Download PDF

Info

Publication number
CN103617101A
CN103617101A CN201310680713.2A CN201310680713A CN103617101A CN 103617101 A CN103617101 A CN 103617101A CN 201310680713 A CN201310680713 A CN 201310680713A CN 103617101 A CN103617101 A CN 103617101A
Authority
CN
China
Prior art keywords
page
data
sign
backed
destination address
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.)
Pending
Application number
CN201310680713.2A
Other languages
Chinese (zh)
Inventor
林建良
吴海亮
刘海蛟
肖洋
林琳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Watertek Information Technology Co Ltd
Original Assignee
Beijing Watertek Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Watertek Information Technology Co Ltd filed Critical Beijing Watertek Information Technology Co Ltd
Priority to CN201310680713.2A priority Critical patent/CN103617101A/en
Publication of CN103617101A publication Critical patent/CN103617101A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention discloses a power fail safeguard method and device. The power fail safeguard method includes the steps that global variables are initialized according to specified rules and comprise start page positions of specified backup areas; according to the start page positions, backup items are written in the backup areas; one page is selected from identification page areas to serve as a current effective identification page, and related information of the backup items is written in a data body part of the current effective identification page according to formats of identification pages; data recovery is carried out according to the current effective identification page and the backup items. The method and device are used for NVM media, characteristics of NOR FLASH are sufficiently considered, the power fail function is guaranteed, and meanwhile performance is improved to the greatest extent.

Description

A kind of power-off protection method and device
Technical field
The application relates to field of data storage, is specifically related to a kind of power-off protection method and device.
Background technology
Tax control encryption disc is that storage medium is encrypted in a kind of tax control of USB interface, guarantees the correctly generation of network invoice electronic information, reliable memory, inquiring and authenticating, unique safely.
Tax control encryption disc is comprised of hardware system and software systems, and hardware system comprises main control MCU chip module, tax-controlling memory module, condition indication circuit module and interface module; Software systems comprise usb communication administration module, command analysis module, application management module, WTCOS module, file system, central processing unit driver module, CDROM module, encrypt memory block module, key module and algorithm routine module, and wherein WTCOS module is comprised of memory module, power down protection module, FTL module, safe operation module and file operation module.
In COS, create in the processes such as file, updating file and have the renewal operation to nonvolatile memory (Non-volatile memory, NVM) storage medium, in renewal process, may occur power down, cause upgrading operation and failed.Existing power down preventing design, if there is power down phenomenon in renewal process, after re-powering so, after the operations such as power loss recovery, reexamine renewal result, can only be the old value before upgrading or upgrade after new value the two one of, can not there is the new value of part, the old value of part or random value.So-called disorderly value, neither be newly worth, neither oldly be worth.
In existing power down preventing design, one page region that hardware layer backed-up pages is special appointment.Backup area has the backed item address of 3~5 appointments.When the destination address that Backup Data size does not write for one page or Backup Data is not offset for start page, existing back mechanism operating process is:
1, the data that outside need is write backup to appointment backup area;
2, while recovering data, need to from backup area, read Backup Data, because Backup Data size is less than page size, need to from destination address, obtain padding data, fill; Populated data are written in second backup area, i.e. hardware layer backed-up pages, this hardware layer backed-up pages is fixed as one page size;
3, wipe destination address, from hardware layer backed-up pages, obtain data, be written in destination address.
From said process, can find out, in existing backup flow process, back up a secondary data at backup area, if the discontented one page of Backup Data need to write once again in hardware layer backed-up pages during recovery.Backed item of every interpolation, all will carry out once erasable operation to the backup of hardware layer page while recovering data.
In creating backup file process, can relate to the operation of a plurality of backed item of continuous adding, each backed item data actual target address is in same one page in the situation that: recover in data procedures, each all wanting first assembled the data in backup area and the data in destination address, be written in hardware layer backed-up pages, and then wipe page object address, from hardware layer reading out data, be written to page object address.Because this destination address is in same one page, this page object can repeatedly carry out erasable, causes the erasable waste of Flash page, reduces the life-span of this Flash page.
To sum up, the backup of hardware layer page overuses frequent, can cause too early this page of damage; While creating file, indivedual page objects can overuse frequently, can cause too early this page of damage.
Summary of the invention
The application's technical matters to be solved is to provide a kind of power-off protection method and device, and excessively erasable to hardware layer while avoiding data backup extends serviceable life of hardware.
In order to address the above problem, the application has disclosed a kind of power-off protection method, comprising: according to specified rule initialization global variable, comprise the start page position of specifying backup area; According to described start page position, backed item is write to described backup area; From sign page district, select one page as current effective sign page, according to sign page form, the relevant information of backed item is write to the data volume part of described current effective sign page; According to described current effective sign page and described backed item, carry out data recovery.
Further, according to described current effective sign page and described backed item, carry out data recovery, comprise: from sign page district, obtaining the maximum serial number page in sign page region is current effective sign page, from reading the relevant information of backed item in described current effective sign page, according to the relevant information of this backed item, backed item is written to and data are recovered, needs the destination address put into from backup area.
Further, the described one page of selecting from sign page district, as current effective sign page, also comprises: in current effective sign page, add set and identify, to indicate that by described set backed item adds successfully.
Further, the described one page of selecting from sign page district, as current effective sign page, comprising: in sign page district, read successively sign page address; If current sign page is not used, current sign page is current effective sign page; Otherwise continue to search, in sign page region, first does not use page as current effective sign page; If all sign pages are all used in sign page district, search the maximum page of serial number in sign page region, next page address of this maximum page is as current effective sign page.
Further, according to described current effective sign page and described backed item, carry out data recovery, also comprise: if the destination address of record has lap in sign page, only recover the up-to-date corresponding backed item of this destination address that once records.
Further, according to described start page position, backed item is write to described backup area, comprising: when the non-start page of data to be backed up destination address to be written address, or, when the length scale of data to be backed up is not the integral multiple of page size, described data to be backed up are filled.
Further, when the non-start page of data to be backed up destination address to be written address, described data to be backed up are filled and comprised: take the start page address of destination address to be written is first object address, reads all data of this place, first object address page; The page bias internal of destination address to be written of take is the second destination address, copies data to be backed up, and data length be extraneous input; By the data assembling to be backed up of all data of place, described first object address page and described the second destination address, it is backed item; Length according to the described backed item obtaining after described backup area start page position and filling, writes backup area successively by described backed item.
Further, when the length scale of data to be backed up is not the integral multiple of page size, described data to be backed up are filled and comprised: the lower page address of first object address of take is the 3rd destination address, reads all data of the 3rd destination address place page; The page bias internal of destination address to be written of take is the 4th destination address, copy residue data to be backed up; By the residue data assembling to be backed up of all data of described the 3rd destination address place page and described the 4th destination address, it is backed item; Length according to the described backed item obtaining after described backup area start page position and filling, writes backup area successively by described backed item.
Further, the method also comprises: if desired continue to add new backed item, return and specify the start page position of backup area, the step of sign-off sheet position continues to add.
In order to address the above problem, the application has disclosed a kind of power-down protection apparatus, comprising: initialization module, for according to specified rule initialization global variable, comprises the start page position of specifying backup area; Writing module, for writing described backup area according to described start page position by backed item; Sign page is selected module, for writing after backup area in described backed item, selects one page as current effective sign page from sign page district, according to sign page form, the relevant information of backed item is write to the data volume part of described current effective sign page; Recover module, for carrying out data recovery according to described current effective sign page and described backed item.
Compared with prior art, the application can obtain and comprise following technique effect:
The application, for NVM medium, takes into full account the characteristic of NOR FLASH, ensures that power down preventing function improves performance as far as possible in the time of correct.
With the difference of design before, the one, optimize the operation of Flash hardware layer web update, the frequent use of prevention page, avoids page to write too early bad, causes can not using of whole product, shortens the problem of this product life cycle; The 2nd, while recovering data, if there is repeatedly returning to the data manipulation of same target page, that is, there is destination address overlapping phenomenon, optimize and fall evitable erasable operation, reduce the access times of page object address, guaranteed the product life cycle.
In addition, the embodiment of the present invention changes single back mechanism into by original double copies mechanism, has shortened the storage time of file data, has promoted the response efficiency of product.
Certainly, arbitrary product of enforcement the application must not necessarily need to reach above-described all technique effects simultaneously.
Accompanying drawing explanation
Accompanying drawing described herein is used to provide further understanding of the present application, forms the application's a part, and the application's schematic description and description is used for explaining the application, does not form the improper restriction to the application.In the accompanying drawings:
Fig. 1 is the method flow diagram of the embodiment of the present application;
Fig. 2 is the process flow diagram of the first embodiment of the application's embodiment of the method;
Fig. 3 selects the process flow diagram of current effective sign page from sign page district in Fig. 2 example;
Fig. 4 a is the process flow diagram of the second embodiment of the application's embodiment of the method;
Fig. 4 b is another process flow diagram of the second embodiment of the application's embodiment of the method;
Fig. 5 is the process flow diagram of the 3rd embodiment of the application's embodiment of the method;
Fig. 6 is the structural representation of the application's device embodiment;
Fig. 7 is the another apparatus structure schematic diagram of the application's device embodiment;
Fig. 8 is the another apparatus structure schematic diagram of the application's device embodiment;
Fig. 9 is the another apparatus structure schematic diagram of the application's device embodiment.
Embodiment
To coordinate drawings and Examples to describe the application's embodiment in detail below, by this application's implementation procedure how application technology means solve technical matters and reach technology effect can be fully understood and be implemented according to this.
the concept that the embodiment of the present application relates to:
Specified rule: bring into use from the first page of the appointed area of backup area, use according to page number incremental order, if reached the end-page of backup area, return to backup area next time first page while using continues to recycle.
Backup area: by N(N>1) continuum that page forms, selects wherein one page as start page, to be used for backing up the data that write according to specified rule, writes backed item.
Sign page district: by N(N>1) continuum that page forms, selects wherein one page as active page, to be used for recording the effective information of current backed item according to specified rule.
Sign page form: whether effectively whether successfully identify+current sign page of backed item interpolation sign+serial number+backup area is used big or small (the TLV)+data volume of start page (TLV)+backup area residue, wherein, every page of logical address offset corresponding to destination address after filling, corresponding one by one with backup area start page, that is, the corresponding backup area address date starting from appointment start page position of the logical address of each record.TLV refers to data structure, wherein, and T:tag, a kind of Data Identification; L: length; V: data value.T represents data type; L determines desired data length, and V is the real data needing.
Data stuffing requires: destination address is start page address, and data length is the big or small multiple of page.
the application's main thought is:
According to specified rule, use backup area, sign page is set simultaneously, mark is carried out in the data backup during to power down, when data are recovered, record according to sign page recovers data, has avoided recovery data blindly repeatedly erasable to hardware, has extended the serviceable life of hardware.
As shown in Figure 1, the method comprises:
Step 101: when having external data input, back up external data, add backed item; If added successfully, perform step 102; Otherwise, perform step 106;
Step 102: judging whether needs to continue to add backed item, if so, returns to step 101, otherwise, perform step 103;
Step 103: set sign page, add backed item set sign, current sign page is current effective sign page; If set success, performs step 104, otherwise performs step 106;
Step 104: recover data, need the destination address of putting into after backed item being recovered from backup area to data writing; If write successfully, perform step 105, otherwise, perform step 106;
Step 105: by the clear position of active page flag in current effective sign page, make this page become invalid page, finish;
Step 106: return to mistake, process ends.
With three kinds of embodiment, the realization of the application's method is described further below.
1) the first embodiment:
As shown in Figure 2, comprising:
Step 210: there is data input outside, will back up external data,, adds backed item that is.According to the relevant global variable of specified rule initialization, comprise the start page position of specifying backup area.
In the present embodiment, specified rule for the start page position of backup area refers to: from the first page of the appointed area of backup area, bring into use, according to page number incremental order, use, if reached the end-page of backup area, return to backup area next time first page while using continues to recycle.
Above-mentioned relevant global variable refers to: the sign-off sheet address of the start page address of backup area, the number of pages that can use backup area, backup area.The first two global variable (SetFlag) when set all can be write in the header of corresponding sign page.When recovering data, can use relevant global variable.In the time of can preventing backed item to write described backup area, there is data from overflow in the sign-off sheet address of backup area.
Step 220: backed item is write to described backup area according to described start page position;
Above-mentioned steps 210, to step 220, is the Refinement operation to step 101.
Step 230: backed item successfully writes after backup area, selects one page as current effective sign page from sign page district, according to sign page form, the relevant information of backed item is write to the data volume part of described current effective sign page.
In the present embodiment, for sign page, district is used specified rule to refer to: to sign page district number of pages, be N(N>0), from first page, to N page, recycle successively.For example: sign page district has 3 pages, and while using for the first time, with the 1st page, serial number 1 writes in this sign page header; While using for the 2nd time, with the 2nd page, serial number 2 writes in this sign page header, and while using for the 3rd time, with the 3rd page, serial number 3 writes this sign page data head part; When the 4th is used, in sign page district, search maximum that one page of a serial number, the 3rd page, lower one page of this page, as current effective sign page of current backup information, is used the 1st page, and serial number 4 writes in this sign page header; The like, be equivalent to the concept of a circular linked list.
Described from a sign page district successfully selects one page as current effective sign page, in current effective sign page, add set and identify, to identify by set, indicate that backed item adds successfully.Above-mentioned steps 230 is the Refinement operations to step 103.
The flow process of selecting current effective sign page from sign page district, comprising:
In sign page district, read successively sign page address;
If current sign page is not used, current sign page is current effective sign page; Otherwise continuing to search the next one does not use page as current effective sign page;
If all sign pages are all used in sign page district, in sign page district, lower one page of the maximum page of serial number is current effective sign page.
Particularly, as shown in Figure 3, comprising:
Step 301: the first address that obtains sign page district;
Step 302: read M(L>M>0, L is the total page number in sign page district) sign page header, obtains serial number value N;
Step 303: obtain maximum serial number value N, and record R=N;
Step 304: judge whether R=0xFFFFFFFF sets up, 0xFFFFFFFF is the original value of wiping after Flash page, can set as required; If so, perform step 306, otherwise, perform step 305;
Step 305: obtain next sign page address, M=M+1, if M=L returns to step 309, otherwise, return to step 302;
Step 306: obtain a sign page address, and obtain this sign page data, judge this sign page, whether in unused state, judges whether this sign page data is all 0xFF, if so, performs step 307, otherwise, perform step 308;
Step 307: show it is to use for the first time this sign page, return to sign page district home address, finish.
Step 308: return to M sign page address, finish;
Step 309: if sign page sector scanning is complete, return to next page address of the maximum page of serial number.
Step 240: carry out data recovery according to described current effective sign page and described backed item.
Specifically, while recovering data, from a sign page district, obtain described current effective sign page, from reading the relevant information of backed item in described current effective sign page, according to the relevant information of this backed item, backed item is needed from backup area is written to data recovery to the destination address of putting into.Above-mentioned steps 240 is the Refinement operations to step 104.
Conventionally, according to the position of writing inlet identity page data body, the most forward logical address offset writes the earliest.In prior art the inside, when a plurality of destination addresses are repeated, will mechanically to these destination addresses, repeatedly recover.And the present embodiment is when recovering data, if the destination address of record has lap in sign page, only recover the up-to-date corresponding backup area page data of this destination address that once records, erasable to reduce unnecessary Flash.
Step 250: recovering after data success, is disarmed state current effective sign page marker.Above-mentioned steps 250 is the Refinement operations to step 105.
2) the second embodiment:
If the length scale of data to be backed up is not the integral multiple of sign page size, as shown in Fig. 4 a, step 220 also further comprises:
Step 2201: when the length scale of data to be backed up is not the integral multiple of page size, described data to be backed up are filled, making the data length size to be backed up after filling is the integral multiple of page size:
Take the start page address that writes destination address is first object address, reads this page data;
The page bias internal of destination address to be written of take is the second destination address, copies data to be backed up, and data length be extraneous input;
By the data assembling to be backed up of all data of place, first object address page and the second destination address, it is backed item;
If still do not meet " data stuffing requirement ", the lower page address of first object address of take is destination address, i.e. the 3rd destination address proceeds to be assembled into the backed item that meets " data stuffing requirement ":
Read all data of the 3rd destination address place page;
The page bias internal of destination address to be written of take is the 4th destination address, copy residue data to be backed up;
By the residue data assembling to be backed up of all data of described the 3rd destination address place page and described the 4th destination address, it is backed item.
Step 2203: the length according to the described backed item obtaining after described start page position and filling, writes backup area by described backed item.
Or if the data to be backed up non-start page of destination address address to be written, as shown in Figure 4 b, step 220 also further comprises:
Step 2202: when the non-start page of data to be backed up destination address to be written address, treat Backup Data and fill,
Take the start page address that writes destination address is first object address, reads this page data;
The page bias internal of destination address to be written of take is the second destination address, copies data to be backed up, and data length be extraneous input;
By the data assembling to be backed up of all data of place, first object address page and the second destination address, it is backed item; Using the data described to be backed up that meet " data stuffing requirement " after assembling as backed item;
Step 2204: the length according to the described backed item obtaining after described start page position and filling, writes backup area by described backed item.
For instance, backup area mainly adopts Flash medium, and according to prior art, the erasable general rule of Flash is: before the data of writing, this page must be wiped, wipe with Ye Huokuaiwei unit.For example: page size: 100Byte, start of Page position: 00, EOP position: 100.Outside has data to want writing address: 10, and ablation process: first, wipe this page, the position from 00~100 all will be wiped.This page of all original data all can disappear so; Secondly, write the data that in this page, start address is 10.
But the process of wiping may be lost significant data, for fear of this situation, being designed to of the present embodiment: before wiping, the data of this page are all read out, carry out front and back with data to be written and be assembled into new page data, as backed item, write backup area.To backup area, write after backed item success, wipe destination address: 10, wipe this page data.During recovery, from backup area, go to read Backup Data, be written in destination address.
For example: the big or small 0x100 of page, destination address: 0x1050, this start of Page page address: 0x1000.Outside has data to write destination address, and length is 0x10, needs as requested first these data to be filled:
From start page, read this page data, be placed on buffer zone P1,
The 0x50 place (relative position skew) that outer input data is copied to P1 region, length is 0x10, only revises the part that needs modification;
Then the data after filling write backup area as backed item.
This has prevented the loss of the data between 0x1050~0x1000 and 0x1060~0x1100 region.
Give one example again, for the situation of single backed item single page, the mode of padding data:
It is 0x0000 that outside has data will write destination address 0x0012(destination address start page address), length is 0x10.According to prior art, first wipe the page at destination address place, described in wipe and take 0x0000 as start address, the region that the page size (for example 256) of take is length is all erased to 0xFF.If now power-off, the data message of this page can all lose, and causes the system failure.In the present embodiment, first the data of destination address place page and data to be written are assembled,, data assembling after the skew of data+data to be written (length 0x10) before 0x0012+(0x0012+0x10), in step 220, the data that this is assembled write backup area as backed item, in step 240, while recovering data, the data (being aforementioned backed item) that backup to backup area from being written to data recovery, backup area are needed to the destination address of putting into.
For the situation of single backed item multipage, the mode of padding data:
It is 0x0000 that outside has data will write destination address 0x00F0(destination address start page address), length is 0x20.According to prior art, first wipe the page at destination address place, described in wipe and take 0x0000 as start address, the region that the page size (for example 256) of take is length is all erased to 0xFF.If now power-off, the data message of this page can all lose, and causes the system failure.In the present embodiment, first the data of destination address place page and data to be written are assembled,, data assembling after the skew of data+data to be written (length 0x20) before 0x00F0+(0x00F0+0x20), now the data length after assembling does not meet " data stuffing requirement ", should proceed to fill, take nextpage start address (0x0100)+page bias internal (0x00F0+0x20) %0x100 of this destination address) be destination address, read a page interior remaining data and be assembled into backed item.In step 220, the data that this is assembled write backup area as backed item, in step 240, while recovering data, the data (being aforementioned backed item) that backup to backup area are needed to the destination address of putting into from backup area is written to data recovery.
In the situation of a plurality of backed item, also to consider the source of padding data.The Data Source of filling comprises:
1) data of destination address, in the destination address of the new backed item of interpolation and backup area, the destination address of already present effective backup does not have overlappingly, and physical page address is no longer with in one page.
2) data of backup area, in the destination address of the new backed item of interpolation and backup area, the destination address of already present effective backup is in same one page.
For example: destination address start page address is 0x0000, page size is 256, and length is 0x10.External data will write destination address 0x0012, the page data at destination address place and the data that will write are assembled,, data assembling after the skew of data+data to be written (length 0x10) before 0x0012+(0x0012+0x10), the data that this is assembled write backup area as backed item, then the destination address of this page are write to the data volume part of current effective sign page.The external world has data will write destination address 0x30 for the second time, and length is 0x10.Now padding data will be considered the source problem that comes of data, first check that the destination address skew of the backed item backed up and the destination address of the backed item that will add are whether in same one page, if, from the backed item having backed up, obtaining data assembles, otherwise, in the page at destination address place, obtain data and assemble.Clearly, this time the logical address offset of the new backed item of adding the destination address of backed item and having backed up, in same one page, is obtained data and is assembled from the backed item having backed up, and padding data derives from backup area.When recovering data, if the logical address of record has lap in current effective sign page, only recover the logical address writing for the last time.
3) the 3rd embodiment:
Between step 220 and step 230, as shown in Figure 5, also comprise:
Step 221: add new backed item if continue, perform step 210, otherwise enter step 230.
Add new backed item, have continuously repeatedly extraneous data to back up, unified page set, the unified data of recovering of identifying.For example: the destination address 0x10 that has for the first time data to write, length is 0x02, assembling data write backup area n page; Have for the second time data will write 0x20, length is 0x02, and assembling data write backup area and write n+1 page, the like; Then identify page set, finally recover data.
Certainly, to whether newly adding the judgement of backed item, as long as before set effectively identifies page operations, can carry out this step.Above-mentioned steps 221 is the Refinement operations to step 102.
The embodiment of the present invention also provides corresponding device, as shown in Figure 6, comprising:
Initialization module 410, for according to specified rule initialization global variable, comprises the start page position of specifying backup area;
Writing module 420, for writing described backup area according to described start page position by backed item;
Sign page is selected module 430, for writing after backup area in described backed item, selects one page as current effective sign page from sign page district, according to sign page form, the relevant information of backed item is write to the data volume part of described current effective sign page;
Recover module 440, for carrying out data recovery according to described current effective sign page and described backed item, during recovery, current effective sign page is the maximum serial number page in sign page region.
In said apparatus:
Recover module 440, be further used for obtaining from sign page district described current effective sign page, from reading the relevant information of backed item in described current effective sign page, according to the relevant information of this backed item, backed item is written to and data are recovered, needs the destination address put into from backup area.
Described recovery module 440, for recovering after data success, is also disarmed state current effective sign page marker.
Described sign page is selected module 430, also for adding set at current effective sign page, identifies, to indicate that by described set backed item adds successfully.
In another embodiment, as shown in Figure 7, said apparatus also comprises: packing module 450, for when the data to be backed up non-start page of the destination address lattice address to be written or, when the length scale of data to be backed up is not the integral multiple of page size, described data to be backed up are filled:
First, take the start page address of destination address to be written is first object address, reads all data of this place, first object address page; Secondly, the page bias internal of destination address to be written of take is the second destination address, copies data to be backed up, and data length be extraneous input; Finally, by the data assembling to be backed up of all data of place, described first object address page and described the second destination address, be backed item; If still do not meet " data stuffing requirement ", the lower page address of first object address of take is destination address, the 3rd destination address, proceeds to be assembled into the backed item that meets " data stuffing requirement ": all data that read the 3rd destination address place page; The page bias internal of destination address to be written of take is the 4th destination address, copy residue data to be backed up; By the residue data assembling to be backed up of all data of described the 3rd destination address place page and described the 4th destination address, it is backed item; Length according to the described backed item obtaining after described backup area start page position and filling, writes backup area successively by described backed item;
Said write module 420, is further used for according to described start page position and the length of the described backed item obtaining after filling, and described backed item is write to backup area.
Described sign page is selected module 430, while selecting one page as current effective sign page from sign page district, is further used for, in sign page district, reading successively sign page address; If current sign page is not used, current sign page is current effective sign page; Otherwise continuing to search the next one does not use page as current effective sign page; If all sign pages are all used in sign page district, search lower one page of maximum one page of serial number in sign page district as current effective sign page.
Specifically comprise: the first address that obtains sign page district;
Read M(M>0) sign page header, obtains serial number value N;
Obtain maximum serial number value N, and record R=N;
During R=0xFFFFFFFF, 0xFFFFFFFF is the original value of wiping after Flash page, obtains next sign page address, and M=M+1, returns and read M(M>0) sign page header;
R is 0xFFFFFFFF, obtains a sign page address, and obtains this sign page data, judges that whether this sign page is in unused state, if so, returns to sign page district home address, finishes; Otherwise, return to this sign page address, finish.
R is not 0xFFFFFFFF, searches maximum one page of serial number in this sign page district, and next page address of this page is returned.
In another embodiment, as shown in Figure 8, said apparatus also comprises: judge module 460, for judging whether newly to add backed item, when needs newly add backed item, triggers described initialization module and starts 410.
In another embodiment, as shown in Figure 9, said apparatus also comprises simultaneously: packing module 450 and judge module 460.Packing module 450 example structure function is as shown in Figure 7 identical, and judge module 460 example structure function is as shown in Figure 8 identical.
Described device is corresponding with aforesaid method flow description, and weak point, with reference to the narration of said method flow process, repeats no longer one by one.
Above-mentioned explanation has illustrated and has described some preferred embodiments of the application, but as previously mentioned, be to be understood that the application is not limited to disclosed form herein, should not regard the eliminating to other embodiment as, and can be used for various other combinations, modification and environment, and can, in invention contemplated scope described herein, by technology or the knowledge of above-mentioned instruction or association area, change.And the spirit and scope that the change that those skilled in the art carry out and variation do not depart from the application, all should be in the protection domain of the application's claims.

Claims (10)

1. a power-off protection method, is characterized in that, the method comprises:
According to specified rule initialization global variable, comprise the start page position of specifying backup area;
According to described start page position, backed item is write to described backup area;
From sign page district, select one page as current effective sign page, according to sign page form, the relevant information of backed item is write to the data volume part of described current effective sign page;
According to described current effective sign page and described backed item, carry out data recovery.
2. the method for claim 1, is characterized in that, according to described current effective sign page and described backed item, carries out data recovery, further comprises:
From sign page district, obtaining the maximum serial number page in sign page region is current effective sign page, from reading the relevant information of backed item in described current effective sign page, according to the relevant information of this backed item, backed item is written to and data are recovered, needs the destination address put into from backup area.
3. the method for claim 1, is characterized in that, the described one page of selecting from sign page district, as current effective sign page, also comprises:
In current effective sign page, add set sign, to indicate that by described set backed item adds successfully.
4. the method for claim 1, is characterized in that, the described one page of selecting from sign page district, as current effective sign page, further comprises:
In sign page district, read successively sign page address;
If current sign page is not used, current sign page is current effective sign page; Otherwise continue to search, in sign page region, first does not use page as current effective sign page;
If all sign pages are all used in sign page district, search the maximum page of serial number in sign page region, next page address of this maximum page is as current effective sign page.
5. the method for claim 1, is characterized in that, according to described current effective sign page and described backed item, carries out data recovery, also comprises:
If the destination address of record has lap in sign page, only recover the up-to-date corresponding backed item of this destination address that once records.
6. the method for claim 1, is characterized in that, according to described start page position, backed item is write to described backup area, further comprises:
When the non-start page of data to be backed up destination address to be written address, or, when the length scale of data to be backed up is not the integral multiple of page size, described data to be backed up are filled.
7. method according to claim 6, is characterized in that, when the non-start page of data to be backed up destination address to be written address, described data to be backed up is filled and is comprised:
Take the start page address of destination address to be written is first object address, reads all data of this place, first object address page;
The page bias internal of destination address to be written of take is the second destination address, copies data to be backed up, and data length be extraneous input;
By the data assembling to be backed up of all data of place, described first object address page and described the second destination address, it is backed item;
Length according to the described backed item obtaining after described backup area start page position and filling, writes backup area successively by described backed item.
8. method according to claim 7, is characterized in that, when the length scale of data to be backed up is not the integral multiple of page size, described data to be backed up is filled and is comprised:
The lower page address of first object address of take is the 3rd destination address, reads all data of the 3rd destination address place page;
The page bias internal of destination address to be written of take is the 4th destination address, copy residue data to be backed up;
By the residue data assembling to be backed up of all data of described the 3rd destination address place page and described the 4th destination address, it is backed item;
Length according to the described backed item obtaining after described backup area start page position and filling, writes backup area successively by described backed item.
9. the method for claim 1, is characterized in that, the method also comprises:
If desired continue to add new backed item, return and specify the start page position of backup area, the step of sign-off sheet position continues to add.
10. a power-down protection apparatus, is characterized in that, this device comprises:
Initialization module, for according to specified rule initialization global variable, comprises the start page position of specifying backup area;
Writing module, for writing described backup area according to described start page position by backed item;
Sign page is selected module, for writing after backup area in described backed item, selects one page as current effective sign page from sign page district, according to sign page form, the relevant information of backed item is write to the data volume part of described current effective sign page;
Recover module, for carrying out data recovery according to described current effective sign page and described backed item.
CN201310680713.2A 2013-12-12 2013-12-12 Power fail safeguard method and device Pending CN103617101A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310680713.2A CN103617101A (en) 2013-12-12 2013-12-12 Power fail safeguard method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310680713.2A CN103617101A (en) 2013-12-12 2013-12-12 Power fail safeguard method and device

Publications (1)

Publication Number Publication Date
CN103617101A true CN103617101A (en) 2014-03-05

Family

ID=50167804

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310680713.2A Pending CN103617101A (en) 2013-12-12 2013-12-12 Power fail safeguard method and device

Country Status (1)

Country Link
CN (1) CN103617101A (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461770A (en) * 2014-10-31 2015-03-25 上海动联信息技术股份有限公司 Power-off protection method of Flash chip
CN104536847A (en) * 2014-12-18 2015-04-22 飞天诚信科技股份有限公司 Method for improving data writing integrity
CN105759679A (en) * 2015-12-12 2016-07-13 重庆川仪自动化股份有限公司 Power-failure protection controller and power-failure protection method thereof
CN106354662A (en) * 2015-07-17 2017-01-25 陕西千山航空电子有限责任公司 NAND FLASH data storage method
CN107257281A (en) * 2017-05-31 2017-10-17 百富计算机技术(深圳)有限公司 NOR FLASH store method, device and the computer-readable recording medium of key data record
CN108874318A (en) * 2018-06-22 2018-11-23 郑州云海信息技术有限公司 The data reconstruction method and solid state hard disk of solid state hard disk
CN112131040A (en) * 2020-09-30 2020-12-25 郑州信大捷安信息技术股份有限公司 Wear balance management method and system for power-down backup area of smart card
CN112925672A (en) * 2021-02-08 2021-06-08 重庆紫光华山智安科技有限公司 Data recovery method, device, equipment and storage medium
CN113785275A (en) * 2020-12-17 2021-12-10 深圳杰睿联科技有限公司 Flash data power-down protection method and device
CN116662075A (en) * 2023-07-28 2023-08-29 深圳市科力锐科技有限公司 Data protection method, system, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050144368A1 (en) * 2003-12-30 2005-06-30 Samsung Electronics Co., Ltd. Address mapping method and mapping information managing method for flash memory, and flash memory using the same
CN101344868A (en) * 2008-08-28 2009-01-14 北京握奇数据系统有限公司 Data backup and acquiring method and device
CN102591748A (en) * 2011-12-29 2012-07-18 记忆科技(深圳)有限公司 Solid state disc and power failure protection method and system thereof
US20120198128A1 (en) * 2011-02-02 2012-08-02 Van Aken Stephen P Control arrangements and methods for accessing block oriented nonvolatile memory
EP2492817A2 (en) * 2011-02-28 2012-08-29 Apple Inc. Efficient buffering for a system having non-volatile memory

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050144368A1 (en) * 2003-12-30 2005-06-30 Samsung Electronics Co., Ltd. Address mapping method and mapping information managing method for flash memory, and flash memory using the same
CN101344868A (en) * 2008-08-28 2009-01-14 北京握奇数据系统有限公司 Data backup and acquiring method and device
US20120198128A1 (en) * 2011-02-02 2012-08-02 Van Aken Stephen P Control arrangements and methods for accessing block oriented nonvolatile memory
EP2492817A2 (en) * 2011-02-28 2012-08-29 Apple Inc. Efficient buffering for a system having non-volatile memory
CN102591748A (en) * 2011-12-29 2012-07-18 记忆科技(深圳)有限公司 Solid state disc and power failure protection method and system thereof

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461770A (en) * 2014-10-31 2015-03-25 上海动联信息技术股份有限公司 Power-off protection method of Flash chip
CN104461770B (en) * 2014-10-31 2017-12-15 上海动联信息技术股份有限公司 A kind of power-off protection method of Flash chip
CN104536847A (en) * 2014-12-18 2015-04-22 飞天诚信科技股份有限公司 Method for improving data writing integrity
CN104536847B (en) * 2014-12-18 2017-10-31 飞天诚信科技股份有限公司 It is a kind of to improve the method that data write integrality
CN106354662B (en) * 2015-07-17 2019-03-01 陕西千山航空电子有限责任公司 A kind of NAND flash data storage method
CN106354662A (en) * 2015-07-17 2017-01-25 陕西千山航空电子有限责任公司 NAND FLASH data storage method
CN105759679A (en) * 2015-12-12 2016-07-13 重庆川仪自动化股份有限公司 Power-failure protection controller and power-failure protection method thereof
CN105759679B (en) * 2015-12-12 2019-07-23 重庆川仪自动化股份有限公司 Power down protection controller and its power-down retaining method
CN107257281B (en) * 2017-05-31 2020-07-28 百富计算机技术(深圳)有限公司 Method, apparatus and computer readable storage medium for NOR F L ASH storage key record
CN107257281A (en) * 2017-05-31 2017-10-17 百富计算机技术(深圳)有限公司 NOR FLASH store method, device and the computer-readable recording medium of key data record
CN108874318A (en) * 2018-06-22 2018-11-23 郑州云海信息技术有限公司 The data reconstruction method and solid state hard disk of solid state hard disk
CN108874318B (en) * 2018-06-22 2021-09-17 郑州云海信息技术有限公司 Data recovery method of solid state disk and solid state disk
CN112131040A (en) * 2020-09-30 2020-12-25 郑州信大捷安信息技术股份有限公司 Wear balance management method and system for power-down backup area of smart card
CN112131040B (en) * 2020-09-30 2022-02-11 郑州信大捷安信息技术股份有限公司 Wear balance management method and system for power-down backup area of smart card
CN113785275A (en) * 2020-12-17 2021-12-10 深圳杰睿联科技有限公司 Flash data power-down protection method and device
CN113785275B (en) * 2020-12-17 2024-03-05 深圳杰睿联科技有限公司 Flash data power-down protection method and device
CN112925672A (en) * 2021-02-08 2021-06-08 重庆紫光华山智安科技有限公司 Data recovery method, device, equipment and storage medium
CN112925672B (en) * 2021-02-08 2022-11-22 重庆紫光华山智安科技有限公司 Data recovery method, device, equipment and storage medium
CN116662075A (en) * 2023-07-28 2023-08-29 深圳市科力锐科技有限公司 Data protection method, system, equipment and storage medium
CN116662075B (en) * 2023-07-28 2024-03-22 深圳市科力锐科技有限公司 Data protection method, system, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN103617101A (en) Power fail safeguard method and device
CN103914393B (en) MCU-based (microprogrammed control unit-based) non-loss FLASH storage update method
CN105740157B (en) data storage device and flash memory control method
US8171257B2 (en) Determining an end of valid log in a log of write records using a next pointer and a far ahead pointer
CN101901189B (en) User data updating method and method for recovering user data
CN100498796C (en) Logic log generation method, database backup/ restoration method and system
US20100070729A1 (en) System and method of managing metadata
US7725646B2 (en) Method of using a flash memory for a circular buffer
CN103577121A (en) High-reliability linear file access method based on nand flash
CN102999564B (en) Write the method for data, device and equipment
CN103914407B (en) A kind of SD card power down protection, restoration methods and the SD card with power down protection
CN103577574A (en) High-reliability linear file system based on nand flash
CN102541690B (en) Intelligent card and method for recovering data
CN101231617B (en) Method for processing data of flash memory equipment
CN104516959A (en) Method and device for managing database logs
CN100382049C (en) Data processing apparatus and method for flash memory
CN103544110A (en) Block-level continuous data protection method based on solid-state disc
CN103778964B (en) Process, using method and the device of a kind of NAND Flash programming data, system
CN101216789A (en) Data update method, device and system
CN101699476A (en) Data processing method and device of smart cards
CN103531234B (en) Power-down protection method in write operation process of NandFlash memory
CN101246429A (en) Electronic systems using flash memory modules as main storage and related system booting methods
CN103593301B (en) Bad block management method and system
CN108431784A (en) Access request processing method, device and computer system
CN102207905A (en) System recovery method, storage media controller and storage system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20140305

RJ01 Rejection of invention patent application after publication