[go: up one dir, main page]

CN114064596A - Log type embedded file system design method, system and storage medium - Google Patents

Log type embedded file system design method, system and storage medium Download PDF

Info

Publication number
CN114064596A
CN114064596A CN202111369778.6A CN202111369778A CN114064596A CN 114064596 A CN114064596 A CN 114064596A CN 202111369778 A CN202111369778 A CN 202111369778A CN 114064596 A CN114064596 A CN 114064596A
Authority
CN
China
Prior art keywords
sector
log
file system
data
log sector
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
CN202111369778.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.)
State Grid Corp of China SGCC
Xuji Group Co Ltd
Electric Power Research Institute of State Grid Hebei Electric Power Co Ltd
Original Assignee
State Grid Corp of China SGCC
Xuji Group Co Ltd
Electric Power Research Institute of State Grid Hebei Electric Power 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 State Grid Corp of China SGCC, Xuji Group Co Ltd, Electric Power Research Institute of State Grid Hebei Electric Power Co Ltd filed Critical State Grid Corp of China SGCC
Priority to CN202111369778.6A priority Critical patent/CN114064596A/en
Publication of CN114064596A publication Critical patent/CN114064596A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Debugging And Monitoring (AREA)

Abstract

一种日志型嵌入式文件系统设计方法、系统及存储介质,该文件系统包括保留扇区和数据区,该方法包括:在文件系统的保留扇区挑选目标扇区作为日志扇区;文件系统进行擦/读/写操作时,将每一个分步骤操作的操作细节实时记录到日志扇区;当新的分步骤操作完成后,将其替换掉日志扇区中旧的记录内容。该系统用于执行该方法,该存储介质用于存储执行该方法的计算机可执行指令。本发明在异常掉电后,文件系统再次上电后可以根据日志来做恢复操作,使其具备掉电安全的功效。

Figure 202111369778

A journal type embedded file system design method, system and storage medium, the file system includes a reserved sector and a data area, the method includes: selecting a target sector as a journal sector in the reserved sector of the file system; During erasing/reading/writing operations, the operation details of each step-by-step operation are recorded in the log sector in real time; when the new step-by-step operation is completed, it replaces the old record content in the log sector. The system is used to perform the method, and the storage medium is used to store computer-executable instructions for performing the method. After an abnormal power failure, the present invention can perform a recovery operation according to the log after the file system is powered on again, so that it has the effect of power failure safety.

Figure 202111369778

Description

Log type embedded file system design method, system and storage medium
Technical Field
The invention relates to the technical field of embedded system application, in particular to a log type embedded file system design method, a log type embedded file system design system and a storage medium.
Background
With the development of storage technology, mass storage media are widely used in embedded systems to store relatively large data such as pictures, videos, and recording data, and these storage media include various pluggable memory cards (TF card, SD card, etc.) and a mass storage chip with a storage management function (eMMC chip). After the large-capacity storage media appear, the storage capacity and the read-write speed are both greatly improved, and meanwhile, the management controller is integrated in the chip, so that the chip has the wear-leveling capability, the problem that one sector is written to be bad due to repeated writing is avoided, and the operation of any file system on the storage media is possible, and the special file system such as a YAFFS file system is not relied on.
At the same time, these mass storage media require a suitable file system to manage. Since these storage media are no longer subject to a special file system, the generic file system FatFs can run on these storage media. Because the FatFs code is open-source and easy to transplant, needs few system resources to run, is stable and reliable, and is a common file system in an embedded system, as shown in FIG. 1, the FatFs code is in a file format.
If the FatFs is directly used in an embedded system, a defect exists, because the FatFs is not a log-type file system, the file system is damaged by sudden power failure, and the whole file system is unusable in severe cases. This is because most of the write operations are completed step by step, and if power failure occurs when the write operations are not completely completed, the operations are incomplete, which causes data confusion and damages the file system. Fig. 2 is a schematic diagram of a power loss occurring when a file is deleted. The defects of the FatFs are determined by an operation mechanism of the FatFs, logs are not recorded during write operation of the FatFs, and therefore after abnormal power failure, a file system cannot be restored according to the logs after being electrified again, so that the FatFs is unsafe in power failure and cannot be directly used in occasions requiring power failure safety, such as the fields of electric power, military industry and the like.
Disclosure of Invention
Based on the above situation in the prior art, an object of the present invention is to provide a method, a system, and a storage medium for designing a log-type embedded file system, so as to solve the problem that after an abnormal power failure occurs, the file system can be restored to a power on state according to the log, and thus the file system has the efficacy of power failure safety.
A first aspect of the present invention provides a method for designing a journaled embedded file system, where the file system includes reserved sectors and data areas, the method including the steps of:
selecting a target sector from reserved sectors of a file system as a log sector;
when the file system performs erasing/reading/writing operation, recording the operation details of each step operation in a log sector in real time;
and after the new step operation is completed, replacing the old record content in the log sector with the operation details.
Further, the record content of the log sector includes the current step sequence number and the data information required for completing the current complete operation.
Further, the data information includes a target sector number, a directory entry location, a state machine, and a log sector CRC check value.
Furthermore, when power failure occurs in a certain substep, after the system is powered on, the information of the log sector is read, the state of the previous substep is recovered, and the next substep operation is continued.
Further, two target sectors are selected from the reserved sectors to serve as log sectors, and a log is recorded in each target sector, wherein one log sector serves as a main log sector, and the other log sector serves as a standby log sector.
Further, the step of reading the log sector includes:
reading a main log sector;
judging whether the check CRC value is correct:
if the data is correct, using the recorded data of the main log sector;
if not, read backup log sector: judging whether the check CRC value is correct: if the data is correct, using the recorded data of the backup log sector; if not, the system reports an error.
Further, a target sector is selected as a log sector in a data area of the file system.
A second aspect of the present invention provides a log-type embedded file system design system, including:
a memory and one or more processors;
wherein the memory is communicatively coupled to the one or more processors and has stored therein instructions executable by the one or more processors to cause the one or more processors to perform the method of any of claims 1-7.
A third aspect of the invention provides a computer-readable storage medium having stored thereon computer-executable instructions operable, when executed by a computing device, to perform a method as previously described.
In summary, the present invention provides a method, a system and a storage medium for designing a journal type embedded file system, where the file system includes reserved sectors and data areas, and the method includes: selecting a target sector from reserved sectors of a file system as a log sector; when the file system performs erasing/reading/writing operation, recording the operation details of each step operation in a log sector in real time; and after the new step operation is completed, replacing the old recorded content in the log sector with the new step operation. The system is configured to perform the method and the storage medium is configured to store computer-executable instructions for performing the method. After the abnormal power failure, the file system can be recovered according to the log after being electrified again, so that the file system has the power failure safety effect.
Drawings
FIG. 1 is a file format of a FatFs file system in the prior art;
FIG. 2 is a diagram illustrating a prior art power loss occurring when a file is deleted;
FIG. 3 is a schematic flow chart illustrating a method for designing a journal-type embedded file system according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a FatFs file system powered down after adding logs in the embodiment of the present invention;
fig. 5 is a schematic flowchart of reading a log sector after a file system is powered on in an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the accompanying drawings in conjunction with the following detailed description. It should be understood that the description is intended to be exemplary only, and is not intended to limit the scope of the present invention. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present invention.
A first aspect of the present invention provides a method for designing a journaled embedded file system, where the file system includes reserved sectors and data areas, and the method includes the following steps, as shown in fig. 3:
s100, selecting a target sector from reserved sectors of a file system as a log sector;
step S200, when the file system performs erasing/reading/writing operation, recording the operation details of each step operation into a log sector in real time;
step S300, after the new step operation is completed, the old record content in the log sector is replaced with the new step operation.
Specifically, the journal embedded file system takes the FatFs file system as an example for further description.
The FatFs has open source and good stability, needs to be transformed when used in an embedded occasion requiring power failure safety, and has the characteristic of power failure safety.
As can be seen from FIG. 1, there are reserved sectors in FatFs, and a target sector is selected in the reserved sectors in FatFs to record a write operation log, which is a log sector. And when the FatFs is in write operation, the operation details of each step operation are written into the log sector in real time, the content of the log sector always stores the latest operation details of the step, and the operation details of the historical steps are not reserved. When the new write operation is completed in steps, the old log sector record content is flushed by the new record content.
The log sector record content comprises the current step sequence number and the data information required for completing the current complete write operation, the log sector record content is shown in table 1, and the data information comprises a target sector number, a directory entry position, a state machine and a log sector CRC check value.
Table 1 log sector record content
Figure BDA0003358084330000041
Furthermore, when power failure occurs in a certain substep, after the system is powered on, the information of the log sector is read, the state of the previous substep is recovered, and the next substep operation is continued. Specifically, the power failure shown in fig. 2 occurs in the FatFs file system after the log is added, and the operation steps are shown in fig. 4. Since power failure occurs in the step of "modifying cluster records in the FAT table", the "flush log" preceding the step of "modifying cluster records in the FAT table" is recorded and stored in the log sector. After the system is powered on again, the information stored in the log sector is read, and according to the record information of the log sector, it is known that power failure occurs when the file is deleted and the substep 2 (modifying the cluster record in the FAT table) is performed, so that two remaining substeps of "modifying the cluster record in the FAT table" and "modifying the remaining cluster number of the FAT table" need to be continued, so that the operation of deleting the file is complete. When two remaining step operations are continued, logs are also recorded, so that incomplete operation caused by power failure in the repair process is prevented.
Further, two target sectors are selected from the reserved sectors to serve as log sectors, and a log is recorded in each target sector, wherein one log sector serves as a main log sector, and the other log sector serves as a standby log sector. In view of the fact that log sector data is important, in order to guarantee reliability of log record contents, a method of recording double logs is adopted, two sectors are found in a reserved sector of FatFs, each sector records one log, one sector is a main log sector, the other sector is a standby sector, when the logs are refreshed, contents of the two sectors are sequentially refreshed in real time, the contents are the same, and when the contents of one log sector are damaged, the contents of the other log sector can be used for recovery operation. Meanwhile, CRC is added to the log content, whether the CRC value is correct or not is checked before the log content is used, and the correctness of the log sector content is guaranteed.
FIG. 5 is a flow chart for reading log sectors after system power up. The step of reading the log sector includes:
reading a main log sector;
judging whether the check CRC value is correct:
if the data is correct, using the recorded data of the main log sector;
if not, read backup log sector: judging whether the check CRC value is correct: if the data is correct, using the recorded data of the backup log sector; if not, the system reports an error.
Because the log is recorded in the reserved sector, and the format of the original file system of the FatFs is not damaged, the FatFs file system added with the log can still be identified and read and written by the mainstream operating systems such as Windows and the like, and the compatibility of the FatFs is ensured.
Further, a target sector is selected as a log sector in a data area of the file system.
A second aspect of the present invention provides a log-type embedded file system design system, including:
a memory and one or more processors;
wherein the memory is communicatively coupled to the one or more processors and has stored therein instructions executable by the one or more processors to cause the one or more processors to perform the method as previously described.
A third aspect of the invention provides a computer-readable storage medium having stored thereon computer-executable instructions operable, when executed by a computing device, to perform a method as previously described.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In summary, the present invention provides a method, a system and a storage medium for designing a journal type embedded file system, where the file system includes reserved sectors and data areas, and the method includes: selecting a target sector from reserved sectors of a file system as a log sector; when the file system performs erasing/reading/writing operation, recording the operation details of each step operation in a log sector in real time; and after the new step operation is completed, replacing the old recorded content in the log sector with the new step operation. The system is configured to perform the method and the storage medium is configured to store computer-executable instructions for performing the method. After the abnormal power failure, the file system can be recovered according to the log after being electrified again, so that the file system has the power failure safety effect.
It is to be understood that the above-described embodiments of the present invention are merely illustrative of or explaining the principles of the invention and are not to be construed as limiting the invention. Therefore, any modification, equivalent replacement, improvement and the like made without departing from the spirit and scope of the present invention should be included in the protection scope of the present invention. Further, it is intended that the appended claims cover all such variations and modifications as fall within the scope and boundaries of the appended claims or the equivalents of such scope and boundaries.

Claims (9)

1. A design method of a log type embedded file system is characterized in that the file system comprises a reserved sector and a data area, and the method comprises the following steps:
selecting a target sector from reserved sectors of a file system as a log sector;
when the file system performs erasing/reading/writing operation, recording the operation details of each step operation in a log sector in real time;
and after the new step operation is completed, replacing the old record content in the log sector with the operation details.
2. The method according to claim 1, wherein the log sector records a sequence number of a current sub-step and data information required for completing a current complete operation.
3. The method of claim 2, wherein the data information comprises a target sector number, a directory entry location, a state machine, and a log sector CRC check value.
4. The design method of a log-type embedded file system according to any one of claims 1 to 3, wherein when power failure occurs in a certain substep, and after the system is powered on, the information of the log sector is read, and the system is restored to the state of the previous substep, and the following substep operations are continued.
5. The method according to any of claims 1-4, wherein two target sectors are selected as log sectors in the reserved sector, each of which records a log, wherein one log sector is a main log sector and the other log sector is a spare log sector.
6. The log type embedded file system design method as claimed in claim 5, wherein the step of reading the log sector comprises:
reading a main log sector;
judging whether the check CRC value is correct:
if the data is correct, using the recorded data of the main log sector;
if not, read backup log sector: judging whether the check CRC value is correct: if the data is correct, using the recorded data of the backup log sector; if not, the system reports an error.
7. The method of any one of claims 1 to 6, wherein the target sector is selected as the journaling sector in a data area of the file system.
8. A journaling embedded file system design system, the system comprising:
a memory and one or more processors;
wherein the memory is communicatively coupled to the one or more processors and has stored therein instructions executable by the one or more processors to cause the one or more processors to perform the method of any of claims 1-7.
9. A computer-readable storage medium having stored thereon computer-executable instructions operable, when executed by a computing device, to perform the method of any of claims 1-7.
CN202111369778.6A 2021-11-16 2021-11-16 Log type embedded file system design method, system and storage medium Pending CN114064596A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111369778.6A CN114064596A (en) 2021-11-16 2021-11-16 Log type embedded file system design method, system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111369778.6A CN114064596A (en) 2021-11-16 2021-11-16 Log type embedded file system design method, system and storage medium

Publications (1)

Publication Number Publication Date
CN114064596A true CN114064596A (en) 2022-02-18

Family

ID=80277994

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111369778.6A Pending CN114064596A (en) 2021-11-16 2021-11-16 Log type embedded file system design method, system and storage medium

Country Status (1)

Country Link
CN (1) CN114064596A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117743266A (en) * 2023-11-13 2024-03-22 中国电力工程顾问集团有限公司 Data storage method and device of edge controller

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515276A (en) * 2008-12-29 2009-08-26 北京握奇数据系统有限公司 Method for write operation of file data, and recovery method and recovery system for file data
KR20110002603A (en) * 2009-07-02 2011-01-10 한국외국어대학교 연구산학협력단 How to save log data in a FAT file system with journaling
CN107870926A (en) * 2016-09-26 2018-04-03 北京信威通信技术股份有限公司 A kind of method and device of real-time storage

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515276A (en) * 2008-12-29 2009-08-26 北京握奇数据系统有限公司 Method for write operation of file data, and recovery method and recovery system for file data
KR20110002603A (en) * 2009-07-02 2011-01-10 한국외국어대학교 연구산학협력단 How to save log data in a FAT file system with journaling
CN107870926A (en) * 2016-09-26 2018-04-03 北京信威通信技术股份有限公司 A kind of method and device of real-time storage

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
凌特利等: "一种掉电安全的嵌入式文件系统设计方法", 单片机与嵌入式系统应用, 1 May 2019 (2019-05-01), pages 33 - 36 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117743266A (en) * 2023-11-13 2024-03-22 中国电力工程顾问集团有限公司 Data storage method and device of edge controller

Similar Documents

Publication Publication Date Title
CN107943414B (en) File system partition and data read-write method of embedded Linux
US7681071B2 (en) Storage apparatus, control method therefor and program
KR101870521B1 (en) Methods and systems for improving storage journaling
US10387280B2 (en) Reporting defects in a flash memory back-up system
JPH1050005A (en) Method for managing defect on optical disk and device therefor
CN103914407B (en) A kind of SD card power down protection, restoration methods and the SD card with power down protection
JPH07182793A (en) Housing and retrieval system of optical disk and method for decision of excessive use of spare sector of optical disk
JP2000112831A (en) Disk recording/reproducing method and device therefor
CN104050056A (en) File system backup of multi-storage-medium device
CN102096561B (en) Hierarchical data storage processing method, device and storage equipment
CN105094685A (en) Method and device for storage control
CN105224891A (en) Magnetic disc optic disc fused data method for secure storing, system and device
TWI459198B (en) Memory storage device, memory controller thereof, and method for identifying valid data
WO2017143843A1 (en) Metadata recovery method and device
JP2006519444A (en) Flash memory data management method
CN114064596A (en) Log type embedded file system design method, system and storage medium
TW201007740A (en) Method for managing data and storage apparatus thereof and controller thereof
CN102609223B (en) Redundant array of independent disk system and initializing method thereof
CN113608925B (en) A data backup method and system based on continuous data protection (CDP) protocol
CN104317833A (en) Method and device for recovering system file indexes
CN105744200A (en) Video monitoring video storage method and device
CN117149062A (en) A method and computing device for processing tape damaged data
CN113050888B (en) Method, system, device and storage medium for quickly removing unstable Flash blocks
CN115373607A (en) Data storage method and device
CN105893172A (en) Hard disk data recovery method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination