CN113050887A - Flash partition data processing method and device, computer equipment and storage medium - Google Patents

Flash partition data processing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113050887A
CN113050887A CN202110254531.3A CN202110254531A CN113050887A CN 113050887 A CN113050887 A CN 113050887A CN 202110254531 A CN202110254531 A CN 202110254531A CN 113050887 A CN113050887 A CN 113050887A
Authority
CN
China
Prior art keywords
file
timer
backup
partition
preset value
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
CN202110254531.3A
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.)
Shenzhen Guangtong Yuanchi Technology Co ltd
Original Assignee
Shenzhen Guangtong Yuanchi 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 Shenzhen Guangtong Yuanchi Technology Co ltd filed Critical Shenzhen Guangtong Yuanchi Technology Co ltd
Priority to CN202110254531.3A priority Critical patent/CN113050887A/en
Publication of CN113050887A publication Critical patent/CN113050887A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0619Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
    • 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/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1441Resetting or repowering
    • 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
    • G06F11/1448Management of the data involved in backup or backup restore
    • 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/17Details of further file system functions
    • G06F16/174Redundancy elimination performed by the file system
    • G06F16/1744Redundancy elimination performed by the file system using compression, e.g. sparse files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The application relates to a flash memory partition data processing method and device, computer equipment and a storage medium. The method comprises the following steps: when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system, triggering a timer to count time from an initial preset value; when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file; generating a file writing instruction; the file writing command carries file writing strategy data; writing the compressed file into a first backup directory of a first logic erasing block of the application partition based on the file write strategy data to obtain a first backup file; and writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the data of the flash partition. By adopting the method, the system abnormity caused by important data loss in the flash memory partition when the system is abnormally powered down can be avoided.

Description

Flash partition data processing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of embedded technologies, and in particular, to a method and an apparatus for processing partitioned data, a computer device, and a storage medium.
Background
With the development of source code and the mature technology, the Linux system is largely used in an embedded design. Configuration data and log information of the embedded system are generally stored in a flash memory, a Linux system directly mounts some partitions in the nandflash to corresponding directories, then a user program modifies files in the corresponding directories, and the files are stored in the nandflash in a binary data mode.
However, currently, a user program reads and writes files in a designated directory, data is copied from a kernel cache to the user program during a read operation, data is copied from the user program to the kernel cache during a write operation, the data is written into a flash by the kernel, and when the kernel does not write the data back to the flash, power is lost, so that the data in the kernel cache is lost, and the system is abnormally started.
Disclosure of Invention
Therefore, in order to solve the above technical problems, it is necessary to provide a flash partition data processing method, an apparatus, a computer device, and a storage medium, which can avoid system exception caused by important data loss in a flash partition when a system is powered down abnormally.
A flash partition data processing method, the method comprising:
when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system, triggering a timer to count time from an initial preset value;
when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
generating a file writing instruction; the file writing instruction carries file writing strategy data;
writing the compressed file into a first backup directory of a first logic erasing block of an application partition based on the file write strategy data to obtain a first backup file;
and writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the flash partition data.
In one embodiment, the method further comprises:
when the timing value of the timer is not the target preset value and a second incremental file is detected to exist in the target subdirectory, resetting the timer and updating the initial preset value; the updated initial preset value is smaller than the initial preset value;
triggering the timer to count time from the updated initial preset value;
and when the timing value of the timer is a target preset value, compressing the file carrying the second incremental file, resetting the timer, and executing the step of generating a file writing instruction.
In one embodiment, the flash memory includes a system partition and an application partition, and before the triggering a timer to count from an initial preset value when the first incremental file is detected to exist in the target subdirectory for mounting the temporary file system, the method further includes:
starting an application program after mounting the system partition;
and mounting the application partition, when the mounting abnormality of the application partition is detected, formatting the application partition, and initializing the application partition according to an initial configuration file in an initial backup directory of a root file system to obtain a first backup directory of the application partition.
In one embodiment, the method further comprises:
when the system is detected to run, acquiring a first MD5 value of a first backup catalog in the application partition;
and checking the first MD5 value, and when the checking is passed, decompressing and copying the first backup directory into the target subdirectory.
In one embodiment, the method further comprises:
when the first MD5 value is not verified, acquiring a second MD5 value of a second backup catalog in the application partition;
and checking the second MD5 value, and when the checking is passed, decompressing and copying the second backup directory into the target subdirectory.
In one embodiment, the method further comprises:
and when a system state control command is received, compressing the incremental files in the target subdirectory and executing the step of generating the file writing command.
A flash partition data processing apparatus, the apparatus comprising:
the detection module is used for triggering a timer to count time from an initial preset value when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system;
the compression module is used for compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file when the timing value of the timer is a target preset value;
the generating module is used for generating a file writing instruction; the file writing instruction carries file writing strategy data;
the first writing module is used for writing the compressed file into a first backup directory of a first logic erasing block of an application partition based on the file writing strategy data to obtain a first backup file;
and the second writing module is used for writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the data of the flash partition.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system, triggering a timer to count time from an initial preset value;
when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
generating a file writing instruction; the file writing instruction carries file writing strategy data;
writing the compressed file into a first backup directory of a first logic erasing block of an application partition based on the file write strategy data to obtain a first backup file;
and writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the flash partition data.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system, triggering a timer to count time from an initial preset value;
when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
generating a file writing instruction; the file writing instruction carries file writing strategy data;
writing the compressed file into a first backup directory of a first logic erasing block of an application partition based on the file write strategy data to obtain a first backup file;
and writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the flash partition data.
According to the flash partition data processing method, the flash partition data processing device, the computer equipment and the storage medium, when a first incremental file is detected to exist in a target subdirectory, namely when the first incremental file is detected to be written in the memory, a timer is triggered to count from an initial preset value, and when the timing value of the timer is a target preset value, the file carrying the first incremental file is compressed and the timer is reset; writing the obtained compressed file into a first backup directory of a first logic erasing block and a second backup directory of a second logic erasing block of the application partition according to the file writing instruction to obtain a first backup file and a second backup file, and finishing the processing of the flash partition data; the incremental file is written into the memory, the file of the target subdirectory is stored in the flash memory in a delayed mode through the timer, and the file is backed up and stored, so that power failure in the file updating process is guaranteed, the file is not written into the flash memory, system starting abnormity caused by data loss in the flash memory is avoided, and system stability and data integrity are improved.
Drawings
FIG. 1 is a flow diagram illustrating a method for processing data in a flash partition, according to an embodiment;
FIG. 2 is a flow diagram that illustrates the application of partition mount exception handling in one embodiment;
FIG. 3 is a flow chart illustrating a method for processing data in a flash partition according to another embodiment;
FIG. 4 is a diagram illustrating an application scenario in which partition mount exception handling is applied in one embodiment;
FIG. 5 is a block diagram of an embodiment of a flash partition data processing apparatus;
FIG. 6 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In an embodiment, as shown in fig. 1, a flash partition data processing method is provided, and this embodiment is illustrated by applying the method to a terminal, it is to be understood that the method may also be applied to a server, and may also be applied to a system including a terminal and a server, and is implemented by interaction between the terminal and the server. In this embodiment, the method includes the steps of:
and 102, when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system, triggering a timer to count time from an initial preset value.
The temporary file system is a file system based on a memory, namely a tmpfs file system; the first delta file refers to a file in which the target subdirectory is modified, that is, an added file, and may be a user data file or a system configuration file. The initial preset values may be, but are not limited to, 10 seconds, 8 seconds, and 5 seconds.
Specifically, when the terminal is started, the application program is started after the system partition is automatically mounted on the directory, the mounting user partition is mounted through the mounting point, and when the mounting of the user partition is successful, the user program normally runs; when the terminal service detects that the files in the target subdirectory of the mounted temporary file system are modified, a timer is triggered to start, and the timer starts timing according to an initial preset value, or performs countdown according to the initial preset value.
And step 104, when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file.
The target preset value is a preset value, and may be, but not limited to, 0, and may also be, for example, 1 or 2.
Specifically, when the timer counts according to an initial preset value and a timing value is a target preset value, compressing all files under a target subdirectory, namely compressing a file set carrying a first incremental file to obtain a compressed file corresponding to the target subdirectory; and the timer is initialized, namely reset to the initial preset value. For example, when the timer counts down according to the initial preset value 10 and the timing value is the target preset value 0, all files in the target subdirectory are compressed to obtain a compressed file.
Step 106, generating a file writing instruction.
The file writing instruction is a command for writing a target file into a target storage area, the target storage area can be a UBI volume which has a mapping relation with a user partition, and the UBI volume is a series of logical erase blocks; wherein the file writing command carries file writing strategy data.
And step 108, writing the compressed file into a first backup directory of a first logic erasing block of the application partition based on the file write strategy data to obtain a first backup file.
The file write strategy data may be, but is not limited to, firstly writing a file into a first backup directory of a first logical erase block of the application partition to obtain a first backup file; and copying the first backup file to a second backup directory of a second logic erasing block of the application partition to obtain a second backup file. The data of the first backup file and the second backup file are the same, when the first backup file is lost, the second backup file can be obtained from the second backup directory of the second logic erasing block, the file loss is avoided, and the integrity of the data is ensured.
Step 110, writing the first backup file into a second backup directory of a second logical erase block of the application partition to obtain a second backup file, and completing the processing of the flash partition data.
Specifically, based on the file write strategy data, after the compressed file is sequentially backed up into a first backup directory of a first logical erase block of the application partition and a second backup directory of a second logical erase block of the application partition, the data write of the flash application partition is completed according to the mapping relationship between the logical erase block and the application partition. For example, when the system is powered down abnormally, but not limited to, the first backup file may be obtained from the first backup directory, the application program of the application partition is updated according to the first backup file, when the first backup file is damaged, the second backup file is obtained from the second backup directory, and the application program of the application partition is updated according to the second backup file.
In the flash memory partition data processing method, a first incremental file in a target subdirectory is written into a memory firstly, a timer is triggered to carry out timing according to an initial preset value, and when the timing value of the timer is a target preset value, the file carrying the first incremental file is compressed and the timer is reset; writing the obtained compressed file into a first backup directory of a first logic erasing block and a second backup directory of a second logic erasing block of the application partition according to the file writing instruction to obtain a first backup file and a second backup file, and finishing the processing of the flash partition data; the incremental file is written into the memory, the file of the target subdirectory is stored in the flash memory in a delayed mode through the timer, and the file is backed up and stored, so that power failure in the file updating process is guaranteed, the file is not written into the flash memory, system starting abnormity caused by data loss in the flash memory is avoided, and system stability and data integrity are improved.
In an embodiment, as shown in fig. 2, a method for processing an application partition mount exception is provided, where this embodiment is exemplified by applying the method to a terminal, and in this embodiment, the method includes the following steps:
step 202, when the abnormal mounting of the application partition is detected, formatting the application partition, and initializing the application partition according to an initial configuration file in an initial backup directory of the root file system to obtain a first backup directory of the application partition.
The root file system is a file system based on a system partition in the flash memory, and the flash memory is divided into the system partition and the application partition.
Specifically, when detecting that the application partition is abnormally mounted, the terminal formats the application partition, initializes the application partition according to an initial configuration file in an initial backup directory in the root file system based on the root file system of the system partition, and obtains a first backup directory of the application partition, that is, restores the initial setting of the application partition, and may also be understood as restoring the factory state of the application partition.
At step 204, it is determined whether the first MD5 value of the first backup directory in the application partition checks. If so, go to step 206, otherwise go to step 208.
The MD5 value refers to that the whole file is treated as a large text Message by a Message Digest Algorithm (Message Digest Algorithm MD5), and a unique MD5 Message Digest is generated by its irreversible string transformation Algorithm.
Step 206, decompressing and copying the first backup directory into the target subdirectory.
At step 208, a second MD5 value for a second backup catalog in the application partition is obtained.
Step 210, checking the value of the second MD5, and determining whether the value of the second MD5 passes the check, if so, performing step 212, otherwise, performing step 214.
Step 212, decompressing and copying the second backup directory into the target subdirectory.
And 214, copying the initial backup directory in the system partition to obtain a third backup directory, and copying the third backup directory into the target subdirectory.
The first backup catalog is the backup catalog of a first logic erasing block in a first logic in the application partition; the second backup directory is a backup directory of a second logic erase block in a second logic in the application partition; the third backup directory is obtained by copying the initial backup directory in the root file system based on the root file system of the system partition.
In the method for processing the mounting exception of the application partition, when the mounting exception of the application partition occurs, formatting processing is carried out on the application partition, and the application partition is initialized according to an initial configuration file in an initial backup directory of a root file system to obtain a first backup directory of the application partition; when the first MD5 value of the first backup directory in the application partition passes verification, decompressing and copying the first backup directory into the target subdirectory; the first MD5 value of the first backup directory in the application partition fails the check. And determining the directory in the target subdirectory by checking whether the second MD5 value of the second backup directory in the application partition is correct, so as to ensure normal operation of the system and normal reading and writing of data of the target subdirectory.
In another embodiment, as shown in fig. 3, a method for processing data of a flash partition is provided, which is exemplified by applying the method to a terminal, and in this embodiment, the method includes the following steps:
step 302, when detecting that a first incremental file exists in a target subdirectory for mounting the temporary file system, triggering a timer to count time from an initial preset value.
Optionally, in an embodiment, the flash memory flash includes a system partition and an application partition, and when it is detected that a first incremental file exists in a target subdirectory of the mounted temporary file system, before a timer is triggered to count time from an initial preset value, an application program is started after the system partition is mounted; mounting the application partition, when the mounting abnormality of the application partition is detected, formatting the application partition, and initializing the application partition according to an initial configuration file in an initial backup directory of the root file system to obtain a first backup directory of the application partition; by detecting whether the application partition is abnormally mounted or not, formatting and initializing the abnormally mounted application partition are carried out, and data can be ensured to be normally written.
Optionally, in an embodiment, after the first backup directory of the application partition is obtained after the application partition is initialized, and when the system runtime is detected, a first MD5 value of the first backup directory in the application partition is obtained; checking the value of the first MD5, and when the checking is passed, decompressing and copying the first backup directory into the target subdirectory; when the first MD5 value is not verified, acquiring a second MD5 value of a second backup catalog in the application partition; and checking the value of the second MD5, decompressing and copying the second backup directory into the target subdirectory when the check is passed, copying the initial backup directory in the system partition to obtain a third backup directory when the check of the value of the second MD5 is not passed, copying the third backup directory into the target subdirectory, and checking the backup directory according to the MD5 value to ensure the integrity and the accuracy of the backup directory.
Step 304, when the timing value of the timer is not the target preset value, detecting whether a second incremental file exists in the target subdirectory, if so, executing step 306, otherwise, executing step 310.
And step 306, resetting the timer and updating the initial preset value, wherein the updated initial preset value is smaller than the initial preset value.
And 308, triggering a timer to count time from the updated initial preset value.
Specifically, when a first incremental file exists in a target subdirectory, triggering a timer to count down from an initial preset value, detecting that a second incremental file exists in the target subdirectory in the counting down process, namely the target subdirectory has the file modified again, resetting the timer and updating the initial preset value, wherein the updated initial preset value is smaller than the initial preset value, triggering the timer to count time from the updated initial preset value, and when the timing value of the timer is the target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file; in the countdown process, the fact that the target subdirectory has the file modified again is detected, the timer is reset, the initial preset value is updated, frequent writing is avoided, data errors are avoided, and the accuracy of the data is improved.
And 310, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file when the timing value of the timer is the target preset value.
Step 312, generating a file writing instruction; the file writing command carries file writing strategy data.
Step 314, based on the file write strategy data, writing the compressed file into the first backup directory of the first logical erase block of the application partition to obtain a first backup file.
Step 316, writing the first backup file into a second backup directory of a second logical erase block of the application partition to obtain a second backup file, and completing the processing of the flash partition data.
Optionally, in an embodiment, when a system state control instruction is received, compressing the incremental file in the target subdirectory, and executing the step of generating a file write instruction, that is, the system state control instruction may be any one of a shutdown instruction or a restart instruction; and performing backup compression on files in the target subdirectory to avoid data loss when the system is shut down or restarted.
As shown in fig. 4, the following is a diagram of an application scenario of flash partition data processing in an embodiment.
Starting an application program after a terminal is started to mount a system partition, mounting an application partition, formatting the application partition when the mounting abnormality of the application partition is detected, initializing the application partition according to an initial configuration file in an initial backup directory of a root file system to obtain a first backup directory A of the application partition, and acquiring a first MD5 value of the first backup directory A in the application partition when the system operation is detected; checking the value of the first MD5, and when the checking is passed, decompressing and copying the first backup directory into the target subdirectory; when the first MD5 value is not verified, acquiring a second MD5 value of a second backup catalog B in the application partition; and checking the second MD5 value, and when the check is passed, decompressing and copying the second backup directory B into the target subdirectory.
A background service process (such as a process A, a process B and a process C) monitors all files in a directory D, monitors whether the files in a target subdirectory are modified or not, and triggers a timer to count time from an initial preset value when detecting that a first incremental file exists in the target subdirectory of the mounted temporary file system; when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file; when the timing value of the timer is not the target preset value and a second incremental file is detected to exist in the target subdirectory, resetting the timer and updating the initial preset value; the updated initial preset value is smaller than the initial preset value; triggering a timer to count time from the updated initial preset value; and when the timing value of the timer is a target preset value, compressing the file carrying the second incremental file, resetting the timer, and executing the step of generating a file writing instruction.
Generating a file writing instruction; the file writing command carries file writing strategy data; writing the compressed file into a first backup directory of a first logic erasing block of the application partition based on the file write strategy data to obtain a first backup file; writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the flash partition data; the integrity of the files is ensured by verifying the MD5 value of the files in the application partition, and on the basis of ensuring the integrity of the files, when a first incremental file is detected to exist in a target subdirectory, a timer is triggered to count time from an initial preset value, and the files in the target subdirectory are stored in a delayed manner; and in the process of timing by the timer, the file in the target subdirectory is detected to be modified again, and the initial preset value is updated by resetting the timer, so that the data error caused by frequent writing is avoided, and the accuracy of the data is improved.
In the flash memory partition data processing method, when a first incremental file is detected to exist in a target subdirectory of a mounted temporary file system, a timer is triggered to time from an initial preset value, if the file of the target subdirectory is detected to be modified again, the timer is reset and the initial preset value is updated, the updated initial preset value is smaller than the initial preset value, the timer is triggered to time from the updated initial preset value, and when the timing value of the timer is the target preset value, the file carrying the first incremental file is compressed and the timer is reset to obtain a compressed file; based on the file write strategy data, the compressed file is sequentially written into a first logic erasing block and a second logic erasing block of an application partition to obtain a first backup file and a second backup file, the processing of the data of the flash memory partition is completed, the data write of the flash memory application partition is completed according to the mapping relation between the logic erasing block and the application partition, and when the terminal system is abnormally powered off, the incremental file is firstly written into a memory, so that the abnormal starting of the system caused by the loss of the data in the flash memory is avoided, and the stability of the system and the integrity of the data are improved.
It should be understood that although the various steps in the flow charts of fig. 1-3 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1-3 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 5, there is provided a flash partition data processing apparatus including: a detection module 502, a compression module 504, a generation module 506, a first write module 508, and a second write module 510, wherein:
the detecting module 502 is configured to trigger a timer to count time from an initial preset value when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system.
And the compressing module 504 is configured to compress the file carrying the first incremental file and reset the timer to obtain a compressed file when the timing value of the timer is the target preset value.
A generating module 506, configured to generate a file writing instruction; the file writing command carries file writing strategy data.
The first writing module 508 is configured to write the compressed file into a first backup directory of a first logical erase block of the application partition based on the file write policy data, so as to obtain a first backup file.
The second writing module 510 is configured to write the first backup file into a second backup directory of a second logical erase block of the application partition, obtain a second backup file, and complete processing of the flash partition data.
In the flash memory partition data processing device, a first incremental file in a target subdirectory is written into a memory firstly, a timer is triggered to carry out timing according to an initial preset value, and when the timing value of the timer is a target preset value, the file carrying the first incremental file is compressed and the timer is reset; writing the obtained compressed file into a first backup directory of a first logic erasing block and a second backup directory of a second logic erasing block of the application partition according to the file writing instruction to obtain a first backup file and a second backup file, and finishing the processing of the flash partition data; the incremental file is written into the memory, the file of the target subdirectory is stored in the flash memory in a delayed mode through the timer, and the file is backed up and stored, so that power failure in the file updating process is guaranteed, the file is not written into the flash memory, system starting abnormity caused by data loss in the flash memory is avoided, and system stability and data integrity are improved.
In another embodiment, a flash partition data processing apparatus is provided, which includes, in addition to the detection module 502, the compression module 504, the generation module 506, the first writing module 508, and the second writing module 510: mounting module, initialization module, acquisition module, check-up module and reset module, wherein:
and the mounting module is used for starting the application program after mounting the system partition.
And the initialization module is used for mounting the application partition, formatting the application partition when the mounting abnormality of the application partition is detected, and initializing the application partition according to an initial configuration file in an initial backup directory of the root file system to obtain a first backup directory of the application partition.
And the obtaining module is used for obtaining a first MD5 value of a first backup catalog in the application partition when the system is detected to run.
And the checking module is used for checking the value of the first MD5, and decompressing and copying the first backup directory into the target subdirectory when the checking is passed.
In one embodiment, the checking module is further configured to obtain a second MD5 value of a second backup directory in the application partition when the first MD5 value fails to check; and checking the second MD5 value, and when the check is passed, decompressing and copying the second backup directory into the target subdirectory.
The resetting module is used for resetting the timer and updating the initial preset value when the timing value of the timer is not the target preset value and the second incremental file is detected to exist in the target subdirectory; the updated initial preset value is smaller than the initial preset value.
The detection module comprises a trigger submodule, and the trigger submodule is used for triggering the timer to time from the updated initial preset value.
In one embodiment, the compressing module 504 is further configured to compress the file carrying the second incremental file and reset the timer when the timing value of the timer is the target preset value.
In one embodiment, the compression module 504 is further configured to compress the delta file in the target subdirectory when the system status control command is received.
In one embodiment, a terminal starts an application program after a system partition is mounted, the application partition is mounted, when abnormal mounting of the application partition is detected, formatting processing is performed on the application partition, the application partition is initialized according to an initial configuration file in an initial backup directory of a root file system to obtain a first backup directory of the application partition, and when the system is detected to run, a first MD5 value of a backup directory A in the application partition is obtained; checking the value of the first MD5, and when the checking is passed, decompressing and copying the first backup directory into the target subdirectory; when the first MD5 value verification fails, acquiring a second MD5 value of a backup catalog B in the application partition; and checking the second MD5 value, and when the check is passed, decompressing and copying the second backup directory into the target subdirectory.
Monitoring all files in a directory D by a background service process (such as a process A, a process B, a process C and a process D), monitoring whether the files in a target subdirectory are modified, and triggering a timer to count time from an initial preset value when detecting that a first incremental file exists in the target subdirectory for mounting the temporary file system; when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file; when the timing value of the timer is not the target preset value and a second incremental file is detected to exist in the target subdirectory, resetting the timer and updating the initial preset value; the updated initial preset value is smaller than the initial preset value; triggering a timer to count time from the updated initial preset value; and when the timing value of the timer is a target preset value, compressing the file carrying the second incremental file, resetting the timer, and executing the step of generating a file writing instruction.
Generating a file writing instruction; the file writing command carries file writing strategy data; writing the compressed file into a first backup directory of a first logic erasing block of the application partition based on the file write strategy data to obtain a first backup file; writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the flash partition data; the files of the target subdirectory are stored in the flash memory in a delayed mode through the timer, backup storage is conducted on the files, power failure in the file updating process is guaranteed, the files are not written into the flash memory, system starting abnormity caused by data loss in the flash memory is avoided, and stability of the system and integrity of the data are improved.
For specific limitations of the flash partition data processing apparatus, reference may be made to the above limitations of the flash partition data processing method, which are not described herein again. The various modules in the flash partitioned data processing apparatus described above may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a flash partition data processing method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 6 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system, triggering a timer to count time from an initial preset value;
when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
generating a file writing instruction; the file writing command carries file writing strategy data;
writing the compressed file into a first backup directory of a first logic erasing block of the application partition based on the file write strategy data to obtain a first backup file;
and writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the data of the flash partition.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
when the timing value of the timer is not the target preset value and a second incremental file is detected to exist in the target subdirectory, resetting the timer and updating the initial preset value; the updated initial preset value is smaller than the initial preset value;
triggering a timer to count time from the updated initial preset value;
and when the timing value of the timer is a target preset value, compressing the file carrying the second incremental file, resetting the timer, and executing the step of generating a file writing instruction.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
starting an application program after mounting the system partition;
and mounting the application partition, when the mounting abnormality of the application partition is detected, formatting the application partition, and initializing the application partition according to an initial configuration file in an initial backup directory of the root file system to obtain a first backup directory of the application partition.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
when the system is detected to run, acquiring a first MD5 value of a first backup catalog in an application partition;
and checking the value of the first MD5, and when the check is passed, decompressing and copying the first backup directory into the target subdirectory.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
when the first MD5 value is not verified, acquiring a second MD5 value of a second backup catalog in the application partition;
and checking the second MD5 value, and when the check is passed, decompressing and copying the second backup directory into the target subdirectory.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and when a system state control command is received, compressing the incremental files in the target subdirectory, and executing the step of generating a file writing command.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system, triggering a timer to count time from an initial preset value;
when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
generating a file writing instruction; the file writing command carries file writing strategy data;
writing the compressed file into a first backup directory of a first logic erasing block of the application partition based on the file write strategy data to obtain a first backup file;
and writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the data of the flash partition.
In one embodiment, the computer program when executed by the processor further performs the steps of:
when the timing value of the timer is not the target preset value and a second incremental file is detected to exist in the target subdirectory, resetting the timer and updating the initial preset value; the updated initial preset value is smaller than the initial preset value;
triggering a timer to count time from the updated initial preset value;
and when the timing value of the timer is a target preset value, compressing the file carrying the second incremental file, resetting the timer, and executing the step of generating a file writing instruction.
In one embodiment, the computer program when executed by the processor further performs the steps of:
starting an application program after mounting the system partition;
and mounting the application partition, when the mounting abnormality of the application partition is detected, formatting the application partition, and initializing the application partition according to an initial configuration file in an initial backup directory of the root file system to obtain a first backup directory of the application partition.
In one embodiment, the computer program when executed by the processor further performs the steps of:
when the system is detected to run, acquiring a first MD5 value of a first backup catalog in an application partition;
and checking the value of the first MD5, and when the check is passed, decompressing and copying the first backup directory into the target subdirectory.
In one embodiment, the computer program when executed by the processor further performs the steps of:
when the first MD5 value is not verified, acquiring a second MD5 value of a second backup catalog in the application partition;
and checking the second MD5 value, and when the check is passed, decompressing and copying the second backup directory into the target subdirectory.
In one embodiment, the computer program when executed by the processor further performs the steps of:
and when a system state control command is received, compressing the incremental files in the target subdirectory, and executing the step of generating a file writing command.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method for processing partitioned data in a flash memory, the method comprising:
when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system, triggering a timer to count time from an initial preset value;
when the timing value of the timer is a target preset value, compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file;
generating a file writing instruction; the file writing instruction carries file writing strategy data;
writing the compressed file into a first backup directory of a first logic erasing block of an application partition based on the file write strategy data to obtain a first backup file;
and writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the flash partition data.
2. The method of claim 1, further comprising:
when the timing value of the timer is not the target preset value and a second incremental file is detected to exist in the target subdirectory, resetting the timer and updating the initial preset value; the updated initial preset value is smaller than the initial preset value;
triggering the timer to count time from the updated initial preset value;
and when the timing value of the timer is a target preset value, compressing the file carrying the second incremental file, resetting the timer, and executing the step of generating a file writing instruction.
3. The method of claim 1, wherein the flash memory comprises a system partition and an application partition, and wherein before the triggering the timer to count from an initial preset value when the first delta file is detected to be present in the target subdirectory for mounting the temporary file system, the method further comprises:
starting an application program after mounting the system partition;
and mounting the application partition, when the mounting abnormality of the application partition is detected, formatting the application partition, and initializing the application partition according to an initial configuration file in an initial backup directory of a root file system to obtain a first backup directory of the application partition.
4. The method according to any one of claims 1 or 3, further comprising:
when the system is detected to run, acquiring a first MD5 value of a first backup catalog in the application partition;
and checking the first MD5 value, and when the checking is passed, decompressing and copying the first backup directory into the target subdirectory.
5. The method of claim 4, further comprising:
when the first MD5 value is not verified, acquiring a second MD5 value of a second backup catalog in the application partition;
and checking the second MD5 value, and when the checking is passed, decompressing and copying the second backup directory into the target subdirectory.
6. The method of claim 1, further comprising:
and when a system state control command is received, compressing the incremental files in the target subdirectory and executing the step of generating the file writing command.
7. A flash partition data processing apparatus, characterized in that the apparatus comprises:
the detection module is used for triggering a timer to count time from an initial preset value when detecting that a first incremental file exists in a target subdirectory of the mounted temporary file system;
the compression module is used for compressing the file carrying the first incremental file and resetting the timer to obtain a compressed file when the timing value of the timer is a target preset value;
the generating module is used for generating a file writing instruction; the file writing instruction carries file writing strategy data;
the first writing module is used for writing the compressed file into a first backup directory of a first logic erasing block of an application partition based on the file writing strategy data to obtain a first backup file;
and the second writing module is used for writing the first backup file into a second backup directory of a second logic erasing block of the application partition to obtain a second backup file, and finishing the processing of the data of the flash partition.
8. The apparatus of claim 7, further comprising:
the detection circulating module is used for resetting the timer and updating the initial preset value when the timing value of the timer is not the target preset value and a second incremental file is detected to exist in the target subdirectory; the updated initial preset value is smaller than the initial preset value;
the triggering module is used for triggering the timer to time from the updated initial preset value;
and the compression module is also used for compressing the file carrying the second incremental file and resetting the timer when the timing value of the timer is a target preset value.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 6.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN202110254531.3A 2021-03-09 2021-03-09 Flash partition data processing method and device, computer equipment and storage medium Pending CN113050887A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110254531.3A CN113050887A (en) 2021-03-09 2021-03-09 Flash partition data processing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110254531.3A CN113050887A (en) 2021-03-09 2021-03-09 Flash partition data processing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113050887A true CN113050887A (en) 2021-06-29

Family

ID=76510444

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110254531.3A Pending CN113050887A (en) 2021-03-09 2021-03-09 Flash partition data processing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113050887A (en)

Similar Documents

Publication Publication Date Title
US9164756B2 (en) Software updating process for an embedded device
CN106951345B (en) Consistency test method and device for disk data of virtual machine
US20110004871A1 (en) Embedded electronic device and firmware updating method thereof
CN108646982B (en) Automatic data restoration method and device based on UBIFS
US7356744B2 (en) Method and system for optimizing testing of memory stores
US20200250313A1 (en) Bios recovery and update
CN109086078B (en) Android system upgrading method and device, server and mobile terminal
CN114706661B (en) Disaster recovery backup method and system for virtual machine, computer equipment and storage medium
CN115793985B (en) Secure storage method, apparatus, device and storage medium
CN109271206B (en) Memory compression and storage method for abnormal site
CN109582332B (en) System upgrading method and device for Internet camera
CN113157303A (en) Upgrading method, embedded system, terminal and computer storage medium
CN105786545B (en) Breakpoint recovery method and system based on heterogeneous hybrid memory
CN111651304A (en) Software recovery method and device based on double-core intelligent electric meter and computer equipment
JPH11514124A (en) How to load an operating system
KR100853941B1 (en) Multimedia storage device and data recovering method of the device
KR101393034B1 (en) Apparatus and method for restoring system
CN113050887A (en) Flash partition data processing method and device, computer equipment and storage medium
CN114385418A (en) Protection method, device, equipment and storage medium for communication equipment
CN114356369A (en) SSD firmware consistency loading method and device, computer equipment and storage medium
CN114356653A (en) Power-down protection method and device for industrial control firewall
CN113778485A (en) System operation method and device of electronic chip, electronic chip and storage medium
CN110826114A (en) User data testing method and device based on SSD after safe erasure
US11922170B2 (en) Systems and method for bootup activation of firmware images
KR20140032071A (en) Apparatus and method for managing file system of a computing device

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