CN104035883A - Method and device for writing and detecting data - Google Patents

Method and device for writing and detecting data Download PDF

Info

Publication number
CN104035883A
CN104035883A CN201410283450.6A CN201410283450A CN104035883A CN 104035883 A CN104035883 A CN 104035883A CN 201410283450 A CN201410283450 A CN 201410283450A CN 104035883 A CN104035883 A CN 104035883A
Authority
CN
China
Prior art keywords
data
storage unit
page
memory cell
current memory
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
CN201410283450.6A
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 Ingenic Semiconductor Co Ltd
Original Assignee
Beijing Ingenic Semiconductor 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 Ingenic Semiconductor Co Ltd filed Critical Beijing Ingenic Semiconductor Co Ltd
Priority to CN201410283450.6A priority Critical patent/CN104035883A/en
Publication of CN104035883A publication Critical patent/CN104035883A/en
Pending legal-status Critical Current

Links

Abstract

The invention relates to the technical field of communication electronics, particularly to a method and a device for writing and detecting data. By the method and the device, file corruption due to writing wrong data is avoided in case of power failure or system error. The method includes writing start address information of a next storage cell on a start page of a current storage cell if in the first write operation; otherwise writing the start address information of the next storage cell and start address information of a last storage cell; if data in the current storage cell are wrong in detection, finding the start page of the current storage cell in which the current page stays, then extracting the start address information of the current storage cell from the start page of the current storage cell and abandoning the data of the current storage cell; and abandoning the data of the last storage cell, when data indicated by the start address information of the last storage cell are wrong, and employing an above storage cell of the last storage cell as the current storage cell. By the method, the problem of the prior art is solved.

Description

A kind of method and device that writes and detect data
Technical field
The present invention relates to communications electronics technical field, relate in particular to a kind of method and device that writes and detect data.
Background technology
NandFlash memory technology has been widely used in smart machine at present, and it has occupied certain market advantage with convenient, fast and jumbo memory space.NandFlash comprises Four types, and wherein three types is as follows:
The first, multi-layered unit flash memory (MLC NandFlash), is characterized in storing in each hardware cell 2 bit data;
The second, TLC NandFlash, is characterized in each hardware unit stores 3 bit data;
The third, QLC NandFlash, is characterized in each hardware unit stores 4 bit data.
NandFlash comprises a plurality of (Block), has stored one group of page (Page) in each Block, and data are stored in NandFLash by SharedPage mode, take MLC NandFlash as example data storage method as follows, with reference to figure 1:
Because each hardware cell of MLC can be stored two bits, wherein store the LSBPage that is called as of low data, store the MSBPage that is called as of high position data, suppose that in Fig. 1, Page0 is used for storing the corresponding data of LSBPage, in Page6 for the corresponding data of store M SBpage, Page0 and Page6 share one group of hardware cell in NandFlash, after the corrupted data in Page6, can directly affect the data in Page0, are SharedPage mode.User can be by file system to the data writing in order of the Page in NandFlash.
But the inventor finds owing to there being the interrelational form between corresponding Page in SharedPage mode, if caused when carrying out some atomic write operation, while running into the situation of unexpected power-off, can cause the current Page loss of data of writing, and directly loss of data or the mistake of the impact Page corresponding with this Page, and atomic write operates to be interrupted also and can not occur mistake.As shown in Figure 2, for example, when file system is being carried out two atomic write operations continuously, first atomic write operation writes, and write in Page0 ~ Page5, second atomic write action need write Page6 ~ Page11, but when writing Page8, the situation that has occurred abnormal power-down, Page8 damages, and according to the characteristic of SharedPage, Page3 also may be damaged.When again starting shooting, if when file system need in service read the data of Page3, if Page3 data are damaged, file system will be taken wrong data.This problem gently causes the file corruption having write, heavy cause file system normally to move.
Summary of the invention
The invention provides a kind of method and device that writes and detect data, for solve in the situation that power-off or system are made mistakes, avoid using before write error data and cause the situation that file corruption system can not normally be moved to occur.
A method for data writing, described method comprises:
Determine whether write operation for the first time, if so, in the start page in current memory cell, write the initial address message (IAM) of next storage unit; If not, in described start page, write next storage unit initial address message (IAM) and on the initial address message (IAM) of a storage unit; Described current memory cell is corresponding with the data in described next storage unit.
Detect a method for data, described method comprises:
Steps A, judges that whether the data in current memory cell are correct, if incorrect, finds the start page of the current memory cell at current page place, extracts the initial address message (IAM) of a upper storage unit, and abandon the data in current memory cell from this start page;
Step B, judge that whether the initial address message (IAM) of upper storage unit data pointed are correct, if incorrect, the data in a described upper storage unit are abandoned, and using the upper level storage unit of a described upper storage unit as current memory cell and perform step A.
A device for data writing, described device comprises:
Write judging unit, for determining whether write operation for the first time;
Operating unit, is for the first time during write operation for determining when said write judging unit, in the start page in current memory cell, writes the initial address message (IAM) of next storage unit; When said write judging unit, determine it is not for the first time during write operation, in described start page, write next storage unit initial address message (IAM) and on the initial address message (IAM) of a storage unit.
Detect a device for data, described device comprises:
Detect judging unit, whether correct for judging the data of current memory cell; And, judge that whether the initial address message (IAM) of upper storage unit data pointed are correct;
Processing unit, when correct for the data of determining described current memory cell when described detection judging unit, find the start page of the current memory cell at current page place, from this start page, extract the initial address message (IAM) of a upper storage unit, and abandon the data in current memory cell; When the initial address message (IAM) of the definite upper storage unit of described detection judging unit data pointed are incorrect, the data in a described upper storage unit are abandoned, and using the upper level storage unit of a described upper storage unit as current memory cell.
A kind of wiring method that the visible employing embodiment of the present invention provides, if write operation only need write once the initial address message (IAM) of the required storage unit of write operation in the required storage unit of this write operation for the first time, if not write operation for the first time, need in the required storage unit of this write operation, write once the initial address message (IAM) of the required storage unit of write operation, and the initial address message (IAM) of the required storage unit of last write operation, a kind of detection method is provided on the basis of wiring method provided by the invention, when detecting current data when wrong, the initial address message (IAM) that finds the required storage unit of write operation last time preserved in the start page of current memory cell abandons the data in current memory cell simultaneously, whether the corresponding data of initial address message (IAM) that then detect the required storage unit of write operation last time are correct, if incorrect, proceed to search the address information of upper level storage unit again, abandon the data of current memory cell, until find correct data, visible the method can be abandoned misdata to leave correct data, the problem that has retained misdata in the situation that can avoid makeing mistakes due to suddenly power-off or system exists, and because the system file that uses this misdata to cause damages situation about can not normally move, occur when system recovers normal.The method is more applicable for atomic write operation etc., and this type of can not occur in the situation of misdata.
Accompanying drawing explanation
In order to be illustrated more clearly in the present invention or technical scheme of the prior art, will the accompanying drawing of required use in embodiment or description of the Prior Art be briefly described below.
Fig. 1 is the storage node composition that in prior art, data are deposited in MLC NandFlash mode;
Fig. 2 is the storage node composition of storing the data of atomic write operation in prior art;
The method flow diagram of the data writing that Fig. 3 provides for the embodiment of the present invention;
The method flow diagram of the detection data that Fig. 4 provides for the embodiment of the present invention;
Fig. 5 for the embodiment of the present invention provide by atomic write, operate after data store organisation figure;
The structure drawing of device of the data writing that Fig. 6 embodiment of the present invention provides;
The structure drawing of device of the detection data that Fig. 7 embodiment of the present invention provides.
Embodiment
In order to make those skilled in the art person understand better the technical scheme in the embodiment of the present invention, and above-mentioned purpose of the present invention, feature and advantage can be become apparent more, below in conjunction with accompanying drawing, technical scheme in the present invention is described in further detail.
A kind of wiring method that the embodiment of the present invention provides, if write operation only need write once the initial address message (IAM) of the required storage unit of write operation in the required storage unit of this write operation for the first time, if not write operation for the first time, need in the required storage unit of this write operation, write once the initial address message (IAM) of the required storage unit of write operation, and the initial address message (IAM) of the required storage unit of last write operation, a kind of detection method is provided on the basis of wiring method provided by the invention, when detecting current data when wrong, the initial address message (IAM) that finds the required storage unit of write operation last time preserved in the start page of current memory cell abandons the data in current memory cell simultaneously, whether the corresponding data of initial address message (IAM) that then detect the required storage unit of write operation last time are correct, if incorrect, proceed to search the address information of upper level storage unit again, abandon the data of current memory cell, until find correct data, visible the method can be abandoned misdata to leave correct data, the problem that has retained misdata in the situation that can avoid makeing mistakes due to suddenly power-off or system exists, and because the system file that uses this misdata to cause damages situation about can not normally move, occur when system recovers normal.The method is more applicable for atomic write operation etc. can not there is the situation of misdata in this type of.
As shown in Figure 3, the detailed process of data writing is as follows:
Step 31, step determines whether write operation for the first time, if execution step 32; If not, execution step 33;
Step 32, writes the initial address message (IAM) of next storage unit in the start page in current memory cell;
Step 33, in described start page, write next storage unit initial address message (IAM) and on the initial address message (IAM) of a storage unit;
Wherein current memory cell is corresponding with the data in described next storage unit.
Wherein said current memory cell comprises a plurality of continuous pages; Described next storage unit comprises a plurality of continuous pages; And the page in described current memory cell is corresponding one by one with the data that the page in described next storage unit is stored.
As shown in Figure 4, the detailed process of detection data is as follows:
Step 41, judges that whether the data in current memory cell are correct, if correctly, determines that file is not damaged; If incorrect, execution step 42,
Step 42, finds the start page of the current memory cell at current page place, extracts the initial address message (IAM) of a upper storage unit, and abandon the data in current memory cell from this start page;
Step 43, judges that whether the initial address message (IAM) of upper storage unit data pointed are correct, if correctly, stops checking; If incorrect, execution step 44;
Step 44, abandons the data in a described upper storage unit, and using the upper level storage unit of a described upper storage unit as current memory cell and perform step 41.
Concrete, judge whether the data in current memory cell correctly comprise:
Judge that whether the data that the every one page in current memory cell stores are correct, and be faulty page by the page marker that has misdata.
Concrete, judge whether the initial address message (IAM) data pointed of a upper storage unit correctly comprise:
Judge that whether the data in the page corresponding with described faulty page in the initial address message (IAM) of a upper storage unit continuous page pointed are correct.
With specific embodiment, be introduced below:
Embodiment mono-:
With reference to figure 5, the embodiment of the present invention provides a kind of method of data writing, and the method use that combines with a kind of follow-up method that detects data can be avoided makeing mistakes and causing the problems such as the file that writes is destroyed to produce due to power-off suddenly or system; Atomic write operation is a kind of operation that can not be interrupted, this operation or success, failure, so will produce fatal destruction to atomic write operation when System Sudden power-off or while makeing mistakes, and the data writing method that the embodiment of the present invention provides and the method that detects data, to be similar to the operation of atomic write operation can avoid well file because of bursting problem destroyed; Concrete in order conveniently to introduce this, sentence and in MLC NandFlash, carry out atomic write and be operating as example, the detailed process of data writing method is as follows:
Step 1, determines whether write operation for the first time, if execution step two; Otherwise execution step three;
In this step, when starting to carry out atomic write operation, whether this atomic write operation of file system automatic decision is write operation for the first time;
Step 2, writes the initial address message (IAM) of next storage unit in the start page in current memory cell;
Now current memory cell comprises Page0 to Page6, and wherein Page0 is used for depositing the initial address message (IAM) of next storage unit as start page;
Now next storage unit comprises Page7 to Page13, the address information ID7 that initial address message (IAM) is Page7;
Step 3, in the start page of current memory cell, write next storage unit initial address message (IAM) and on the initial address message (IAM) of a storage unit;
In Page0, write ID7 and on the initial address message (IAM) IDN of a storage unit;
Step 4, judges whether to write all data, if not continuing execution step three until complete write operation;
In the present embodiment, current memory cell comprises a plurality of continuous pages; In next storage unit, also comprise a plurality of continuous pages; And the page in described current memory cell is corresponding one by one with the data that the page in described next storage unit is stored.Be that data in Page1 to Page8 are corresponding, the data in Page2 to Page9 are by that analogy corresponding.
Embodiment bis-:
The embodiment of the present invention provides a kind of method that detects data, on the method basis of the data writing that the method provides at embodiment mono-, carry out the detection of data correctness, the method is especially applicable to being similar to the operation of atomic write operation, can avoid well file because of bursting problem destroyed; Concrete in order conveniently to introduce this, sentence and in MLC NandFlash, carry out atomic write and be operating as example, the detailed process that detects data method is as follows:
Steps A, while detecting according to the order of sequence once write operation interruption when system starts or again recovers normal, in residing MLC NandFlash, whether the data of every one page are correct; Judge that whether the data in current memory cell are correct, if incorrect execution step B; Otherwise execution step C; The storage unit at place when now current memory cell is last write operation interruption;
Judge whether the data in current memory cell correctly specifically comprise:
Judge that whether the data that the every one page in current memory cell stores are correct, and be faulty page by the page marker that has misdata; In this step, take that to detect the storage unit that last write operation interrupts at Page9 place be example, system checks the data in Page7 to Page13 successively, now finds to have preserved misdata in Page9, performs step D;
Page7 comprises the initial address message (IAM) ID0 of upper level storage unit and the initial address message (IAM) IDS of next stage storage unit;
Step C, thinks that the file that the operation of atomic write hereto writes is not destroyed;
Step D, finds the start page of the current memory cell at current page place, extracts the initial address message (IAM) of a upper storage unit, and abandon the data in current memory cell from this start page;
In this step, owing to finding that the data in Page9 are wrong, using Page9 as faulty page, and to find the start page of the storage unit at Page9 place be Page7, and therefrom extract ID0, and the data in Page7 to Page13 are abandoned;
Step e, judges that whether the initial address message (IAM) of upper storage unit data pointed are correct, if correctly perform step C, otherwise execution step F;
Judge that successively whether take the data of ID0 in the Page0 to Page6 of start page correct, correctly perform step C, otherwise execution step F;
Step F, abandons the data in a upper storage unit, and the data that are about in Page0 to Page6 abandon; And be that PageN place storage unit is as current memory cell and perform step E, until check the data that do not make mistake using the upper level storage unit of a storage unit on this.
In the present embodiment, in described judgement, whether the initial address message (IAM) of storage unit data pointed correctly comprise:
Judge that whether the data in the page corresponding with described faulty page in the initial address message (IAM) of a upper storage unit continuous page pointed are correct, whether the data that the judgement Page2 corresponding with Page9 comprises are correct.
As shown in Figure 6, the data writing device of the embodiment of the present invention is as follows:
A device for data writing, described device comprises:
Write judging unit 61, for determining whether write operation for the first time;
Operating unit 62, is for the first time during write operation for determining when said write judging unit 61, in the start page in current memory cell, writes the initial address message (IAM) of next storage unit; When said write judging unit 61, determine it is not for the first time during write operation, in described start page, write next storage unit initial address message (IAM) and on the initial address message (IAM) of a storage unit.
Described current memory cell comprises a plurality of continuous pages;
Described next storage unit comprises a plurality of continuous pages;
And the page in described current memory cell is corresponding one by one with the data that the page in described next storage unit is stored.
The device of the detection data that as shown in Figure 7, the embodiment of the present invention provides is as follows:
Detect a device for data, described device comprises:
Detect judging unit 71, whether correct for judging the data of current memory cell; And, judge that whether the initial address message (IAM) of upper storage unit data pointed are correct;
Processing unit 72, when correct for the data when described detection judging unit 71 definite described current memory cells, find the start page of the current memory cell at current page place, from this start page, extract the initial address message (IAM) of a upper storage unit, and abandon the data in current memory cell; When the initial address message (IAM) of described detection judging unit 71 definite upper storage unit data pointed are incorrect, the data in a described upper storage unit are abandoned, and using the upper level storage unit of a described upper storage unit as current memory cell.
Described detection judging unit 71 specifically for:
Judge that whether the data that the every one page in current memory cell stores are correct, and be faulty page by the page marker that has misdata.
Described detection judging unit 71 specifically for: judge that whether the data in the page corresponding with described faulty page in the initial address message (IAM) of a upper storage unit continuous page pointed correct.
In sum, beneficial effect:
A kind of wiring method that adopts the embodiment of the present invention to provide, if write operation only need write once the initial address message (IAM) of the required storage unit of write operation in the required storage unit of this write operation for the first time, if not write operation for the first time, need in the required storage unit of this write operation, write once the initial address message (IAM) of the required storage unit of write operation, and the initial address message (IAM) of the required storage unit of last write operation, a kind of detection method is provided on the basis of wiring method provided by the invention, when detecting current data when wrong, the initial address message (IAM) that finds the required storage unit of write operation last time preserved in the start page of current memory cell abandons the data in current memory cell simultaneously, whether the corresponding data of initial address message (IAM) that then detect the required storage unit of write operation last time are correct, if incorrect, proceed to search the address information of upper level storage unit again, abandon the data of current memory cell, until find correct data, visible the method can be abandoned misdata to leave correct data, the problem that has retained misdata in the situation that can avoid makeing mistakes due to suddenly power-off or system exists, and because the system file that uses this misdata to cause damages situation about can not normally move, occur when system recovers normal.The method is more applicable for atomic write operation etc. can not there is the situation of misdata in this type of.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any modifications of doing within the spirit and principles in the present invention, be equal to and replace and improvement etc., within all should being included in protection scope of the present invention.

Claims (10)

1. a method for data writing, is characterized in that, described method comprises:
Determine whether write operation for the first time, if so, in the start page in current memory cell, write the initial address message (IAM) of next storage unit; If not, in described start page, write next storage unit initial address message (IAM) and on the initial address message (IAM) of a storage unit.
2. method as described in claim 1, is characterized in that, described current memory cell comprises a plurality of continuous pages;
Described next storage unit comprises a plurality of continuous pages;
And the page in described current memory cell is corresponding one by one with the data that the page in described next storage unit is stored.
3. a method that detects data, is characterized in that, described method comprises:
Steps A, judges that whether the data in current memory cell are correct, if incorrect, finds the start page of the current memory cell at current page place, extracts the initial address message (IAM) of a upper storage unit, and abandon the data in current memory cell from this start page;
Step B, judge that whether the initial address message (IAM) of upper storage unit data pointed are correct, if incorrect, the data in a described upper storage unit are abandoned, and using the upper level storage unit of a described upper storage unit as current memory cell and perform step A.
4. method as claimed in claim 3, is characterized in that, describedly judges whether the data in current memory cell correctly comprise:
Judge that whether the data that the every one page in current memory cell stores are correct, and be faulty page by the page marker that has misdata.
5. method as claimed in claim 4, is characterized in that, in described judgement, whether the initial address message (IAM) of storage unit data pointed correctly comprise:
Judge that whether the data in the page corresponding with described faulty page in the initial address message (IAM) of a upper storage unit continuous page pointed are correct.
6. a device for data writing, is characterized in that, described device comprises:
Write judging unit, for determining whether write operation for the first time;
Operating unit, is for the first time during write operation for determining when said write judging unit, in the start page in current memory cell, writes the initial address message (IAM) of next storage unit; When said write judging unit, determine it is not for the first time during write operation, in described start page, write next storage unit initial address message (IAM) and on the initial address message (IAM) of a storage unit.
7. install as described in claim 6, it is characterized in that, described current memory cell comprises a plurality of continuous pages;
Described next storage unit comprises a plurality of continuous pages;
And the page in described current memory cell is corresponding one by one with the data that the page in described next storage unit is stored.
8. a device that detects data, is characterized in that, described device comprises:
Detect judging unit, whether correct for judging the data of current memory cell; And, judge that whether the initial address message (IAM) of upper storage unit data pointed are correct;
Processing unit, when correct for the data of determining described current memory cell when described detection judging unit, find the start page of the current memory cell at current page place, from this start page, extract the initial address message (IAM) of a upper storage unit, and abandon the data in current memory cell; When the initial address message (IAM) of the definite upper storage unit of described detection judging unit data pointed are incorrect, the data in a described upper storage unit are abandoned, and using the upper level storage unit of a described upper storage unit as current memory cell.
9. device as claimed in claim 8, is characterized in that, described detection judging unit specifically for:
Judge that whether the data that the every one page in current memory cell stores are correct, and be faulty page by the page marker that has misdata.
10. device as claimed in claim 9, is characterized in that, described detection judging unit specifically for: judge that whether the data in the page corresponding with described faulty page in the initial address message (IAM) of a upper storage unit continuous page pointed correct.
CN201410283450.6A 2014-06-23 2014-06-23 Method and device for writing and detecting data Pending CN104035883A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410283450.6A CN104035883A (en) 2014-06-23 2014-06-23 Method and device for writing and detecting data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410283450.6A CN104035883A (en) 2014-06-23 2014-06-23 Method and device for writing and detecting data

Publications (1)

Publication Number Publication Date
CN104035883A true CN104035883A (en) 2014-09-10

Family

ID=51466655

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410283450.6A Pending CN104035883A (en) 2014-06-23 2014-06-23 Method and device for writing and detecting data

Country Status (1)

Country Link
CN (1) CN104035883A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026676A (en) * 2019-12-27 2020-04-17 中煤科工集团重庆研究院有限公司 Storage method and storage system for carrying time information by using storage unit address

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026676A (en) * 2019-12-27 2020-04-17 中煤科工集团重庆研究院有限公司 Storage method and storage system for carrying time information by using storage unit address
CN111026676B (en) * 2019-12-27 2023-08-01 中煤科工集团重庆研究院有限公司 Storage method and storage system for carrying time information by using storage unit address

Similar Documents

Publication Publication Date Title
CN103745753A (en) Error correction method and system based on flash memory
CN103473098A (en) Starting method of boot program and relevant device
KR101885228B1 (en) Power drop protection for a data storage device
CN106910528B (en) Optimization method and device for data inspection of solid state disk
CN105723344A (en) Method and apparatus for non-volatile ram error re-mapping
CN105808371A (en) Data backup and recovery method, control chip and storage device
CN101681281A (en) Emerging bad block detection
CN105681134A (en) General multiple serial port communication protocol detection and identification method
CN103955431A (en) Data management method and apparatus in flash memory storage device
CN103823642A (en) Method and system used for Flash balance storage
CN102200937A (en) Method, device and television system for reading data in not-and (NAND) flash memory
CN100437504C (en) Hard disc data backup system and method
CN104133740A (en) Method for recovering abnormal power failure data
CN104063477A (en) Processing method and processing device for startup abnormalities of embedded system
CN103984506A (en) Method and system for data writing of flash memory storage equipment
CN109144754A (en) A kind of method for testing reliability and device
US11068201B2 (en) Flash memory controller, method for managing flash memory module and associated electronic device
US20150067443A1 (en) Method and Device for Recovering Erroneous Data
US20130151886A1 (en) Computing device and method for switching physical links of a sas expander of the computing device
CN105302679A (en) Detection method and system for intelligent terminal storage stability
CN104035883A (en) Method and device for writing and detecting data
CN104461379A (en) Method for improving stability of NAND and NAND
CN111324549B (en) Memory and control method and device thereof
CN105260133A (en) Data writing method and system for EMMC (Embedded Multi Media Card) of mobile terminal
CN112083891B (en) Method for detecting data block in memory and related equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20140910

WD01 Invention patent application deemed withdrawn after publication