CN110888596B - File erasing method and device for Flash storage area - Google Patents

File erasing method and device for Flash storage area Download PDF

Info

Publication number
CN110888596B
CN110888596B CN201910554352.4A CN201910554352A CN110888596B CN 110888596 B CN110888596 B CN 110888596B CN 201910554352 A CN201910554352 A CN 201910554352A CN 110888596 B CN110888596 B CN 110888596B
Authority
CN
China
Prior art keywords
physical page
target
file
check code
storage area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910554352.4A
Other languages
Chinese (zh)
Other versions
CN110888596A (en
Inventor
刘青
王卫东
黄明
毕健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Huahong Integrated Circuit Design Co ltd
Original Assignee
Beijing Huahong Integrated Circuit Design Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Huahong Integrated Circuit Design Co ltd filed Critical Beijing Huahong Integrated Circuit Design Co ltd
Priority to CN201910554352.4A priority Critical patent/CN110888596B/en
Publication of CN110888596A publication Critical patent/CN110888596A/en
Application granted granted Critical
Publication of CN110888596B publication Critical patent/CN110888596B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/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
    • 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/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/1008Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
    • G06F11/1048Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices using arrangements adapted for a specific error detection or correction feature
    • G06F11/106Correcting systematically all correctable errors, i.e. scrubbing
    • 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/1008Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
    • G06F11/1068Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices in sector programmable memories, e.g. flash disk
    • 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]

Abstract

The application provides a file erasing method and a device for a Flash storage area, wherein the method comprises the following steps: responding to an update request of a target file, and searching a current latest effective file body physical page in a target storage area of Flash, wherein the target storage area is a storage area pre-allocated for the target file, and the current latest effective file body physical page at least stores latest historical content of the target file; selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page; and obtaining the updated content aiming at the target file according to the latest historical content and the update request, and writing the updated content aiming at the target file into the target physical page. In the application, the frequency that the target file can be erased and written in the Flash can be increased through the method, and the utilization rate of the Flash is increased.

Description

File erasing method and device for Flash storage area
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for erasing a file in a Flash storage area.
Background
The existing embedded operating system generally adopts a FLASH Memory (english name is FLASH Memory, which is abbreviated as FLASH) as a storage medium.
However, the number of times of erasing and writing of Flash is generally limited, and often cannot meet the requirement of high number of times of erasing and writing of a specific file (e.g., a file updated frequently), and the utilization rate of Flash is not high, so how to increase the number of times that the specific file can be erased and written in Flash to increase the utilization rate of Flash becomes an urgent problem to be solved.
Disclosure of Invention
In order to solve the above technical problems, embodiments of the present application provide a method and an apparatus for erasing a file in a Flash storage area, so as to achieve the purposes of increasing the number of times that a target file can be erased and written in Flash and increasing the utilization rate of Flash, and the technical scheme is as follows:
a file erasing method of a Flash storage area comprises the following steps:
responding to an update request of a target file, and searching a current latest effective file body physical page in a target storage area of Flash, wherein the target storage area is a storage area pre-allocated for the target file, and the current latest effective file body physical page at least stores latest historical content of the target file;
selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page;
and obtaining the updated content aiming at the target file according to the latest historical content and the update request, and writing the updated content aiming at the target file into the target physical page.
Optionally, the obtaining, according to the latest history content and the update request, update content for the target file, and writing the update content for the target file into the target physical page specifically includes:
acquiring the erasing times of the current latest effective file physical page, updating the acquired erasing times of the file, and taking the updated erasing times of the file as the erasing times of the target file;
acquiring the latest historical content from the current latest effective file body physical page, updating the latest historical content according to the updating request to obtain the latest data content, calculating a check code according to the latest data content and the erasing frequency of the target file, and taking the calculated check code as a reference data check code of the target physical page;
and writing the latest data content, the reference data check code of the target physical page and the erasing times of the target file into the target physical page.
Optionally, the searching for the physical page of the current latest valid file body in the target storage area of Flash includes:
obtaining effective identification information and data content of each physical page in the target storage area, wherein the effective identification information comprises: checking codes of the reference data and erasing times of the file;
calculating a check code according to the data content of each physical page and the erasing times of the file, and taking the calculated check code as a first target data check code;
respectively comparing whether the reference data check code and the first target data check code of each physical page are consistent, and taking the physical page with the consistent comparison result as an effective physical page;
and taking the effective physical page with the file erasing times meeting the first set condition as the current latest effective file body physical page.
Optionally, the searching for the physical page of the current latest valid file body in the target storage area of Flash includes: acquiring a physical address from a set area, and taking a physical page corresponding to the acquired physical address as a current latest effective file body physical page;
after writing the target physical page for the updated content of the target file, further comprising:
calculating a check code according to the data content in the target physical page and the erasing frequency of the target file, and taking the calculated check code as a second data check code;
and comparing whether the reference data check code of the target physical page is consistent with the second data check code, and if so, updating the physical address in the set area to be the physical address of the target physical page.
Optionally, the selecting a physical page different from the physical page of the current latest valid file body from the target storage area as a target physical page specifically includes: and selecting the next physical page adjacent to the current latest effective file body physical page from the target storage area as a target physical page, and when the current latest effective file body physical page is the last physical page in the target storage area, taking the first physical page in the target storage area as the target physical page.
A file erasing device of a Flash storage area comprises:
the searching module is used for responding to an updating request of a target file and searching a current latest effective file body physical page in a target storage area of Flash, wherein the target storage area is a storage area pre-allocated aiming at the target file, and the current latest effective file body physical page at least stores latest historical content of the target file;
the selecting module is used for selecting a physical page different from the physical page of the current latest effective file body searched by the searching module from the target storage area as a target physical page;
and the first writing module is used for obtaining the updated content aiming at the target file according to the latest historical content and the updating request and writing the updated content aiming at the target file into the target physical page.
Optionally, the first writing module includes:
the first obtaining sub-module is used for obtaining the file erasing times of the physical page of the current latest effective file body, updating the obtained file erasing times and taking the updated file erasing times as the erasing times of the target file;
the first determining submodule is used for acquiring the latest historical content from the current latest effective file physical page, updating the latest historical content according to the updating request to obtain the latest data content, calculating a check code according to the latest data content and the erasing times of the target file, and taking the calculated check code as a reference data check code of the target physical page;
and the first writing submodule is used for writing the latest data content, the reference data check code of the target physical page and the erasing times of the target file into the target physical page.
Optionally, the search module includes:
a second obtaining sub-module, configured to obtain valid identification information and data content of each physical page in the target storage area, where the valid identification information includes: checking codes of the reference data and erasing times of the file;
the second determining submodule is used for calculating a check code according to the data content of each physical page and the erasing times of the file, and taking the calculated check code as a first target data check code;
the third determining submodule is used for respectively comparing whether the reference data check code and the first target data check code of each physical page are consistent or not, and taking the physical page with the consistent comparison result as an effective physical page;
and the fourth determining submodule is used for taking the effective physical page with the file erasing times meeting the first set condition as the current latest effective file body physical page.
Optionally, the search module includes:
the fifth determining submodule is used for acquiring a physical address from the set area and taking a physical page corresponding to the acquired physical address as a current latest effective file body physical page;
the device further comprises:
the first determining module is used for calculating a check code according to the data content in the target physical page and the erasing frequency of the target file, and taking the calculated check code as a second data check code;
the comparison module is used for comparing whether the reference data check code of the target physical page is consistent with the second data check code;
and the updating module is used for updating the physical address in the set area to the physical address of the target physical page if the reference data check code of the target physical page is consistent with the second data check code.
Optionally, the selecting module is specifically configured to select, from the target storage area, a next physical page adjacent to the current latest valid file body physical page as a target physical page, and when the current latest valid file body physical page is a last physical page in the target storage area, take a first physical page in the target storage area as the target physical page.
Compared with the prior art, the beneficial effect of this application is:
in the application, in response to an update request of a target file, a current latest effective file body physical page is searched in a target storage area of Flash, a physical page, in which the latest historical content of the target file is currently stored, of the target storage area is determined, on the basis, a physical page different from the current latest effective file body physical page is selected from the target storage area and is used as a target physical page, the update content of the target file is written into the target physical page, the target file is updated in different physical pages in a circulating manner, the erasing frequency of the target file in Flash is equal to the sum of the erasing frequency of different physical pages, compared with the situation that the target file is always updated in the same physical page, the erasing frequency of the target file in Flash is improved, and the utilization rate of Flash is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1 is a flowchart of a file erasing method for a Flash storage area provided in the present application;
FIG. 2 is a flowchart of another file erasing method for a Flash storage area provided in the present application;
FIG. 3 is a flowchart of another file erasing method for a Flash storage area provided in the present application;
FIG. 4 is a flowchart of another file erasing method for a Flash storage area provided in the present application;
FIG. 5 is a flowchart of another file erasing method for a Flash storage area provided in the present application;
FIG. 6 is a flowchart of another file erasing method for a Flash storage area provided in the present application;
FIG. 7 is a flowchart of another file erasing method for a Flash storage area provided in the present application;
FIG. 8 is a flowchart of another file erasing method for a Flash storage area provided in the present application;
fig. 9 is a schematic diagram of a logic structure of a file erasing device in a Flash storage area according to the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application discloses a file erasing method of a Flash storage area, which comprises the following steps: responding to an update request of a target file, and searching a current latest effective file body physical page in a target storage area of Flash, wherein the target storage area is a storage area pre-allocated for the target file, and the current latest effective file body physical page at least stores latest historical content of the target file; selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page; and obtaining the updated content aiming at the target file according to the latest historical content and the update request, and writing the updated content aiming at the target file into the target physical page. In the application, the erasing frequency of the target file in the Flash is improved, and the utilization rate of the Flash is improved.
As shown in fig. 1, a flowchart of an embodiment 1 of a file erasing method for a Flash storage area provided by the present application may include the following steps:
and step S11, responding to the update request of the target file, and searching the physical page of the current latest effective file body in the target storage area of Flash.
In this embodiment, the target storage area target file of Flash is a file that needs to be updated frequently, for example, heat data of a heat meter in a heating system, gas data of a gas meter, water meter data, electricity meter data, recorded data in an automobile, a clock of an intelligent device, and the like. For files that are infrequently updated, such as keys (which may be updated once a month or a quarter), they may be stored in areas other than the target storage area of Flash.
In this embodiment, the update request of the target file may be a response to an external command or an execution of a preset command.
The target storage area is a storage area pre-allocated for the target file, and the physical page of the current latest effective file body at least stores the latest historical content of the target file.
Optionally, the target storage area is divided into a plurality of physical pages. A plurality of physical pages may be used in turn for a storage area as a target file.
It can be understood that the update request of the target file may carry header information of the target file, and the structure of the header information may be as shown in table 1, and as shown in table 1, the start position of the target storage area may be determined according to the start position information of the physical page of the header.
TABLE 1
Figure BDA0002106429770000061
For example, the file index is 0x01, the number of multi-file bodies is 0x04, and the physical page start position of a file body is 0x 00078600.
The file index can be used as the unique identifier of the target file in the embedded file system. The definition and storage of the file index occupy space, which is not limited in this embodiment, and can be defined and specified according to the needs of the actual system.
The file volume number may be used to indicate the number of recyclable physical pages allocated in the target storage area by the target file, where the target file may occupy one physical page or may occupy multiple physical pages, for example, the target storage area has 4 physical pages, if the target file occupies 2 physical pages, the file volume number is 2, and if the target file occupies 1 physical page, the file volume number is 4.
The starting position of the physical page of the file body can be understood as: the starting position of the target storage area in Flash, namely the starting position of the target file in Flash.
It should be noted that, after the target storage area is divided into a plurality of physical pages, if the space size of one physical page cannot meet the storage requirement of the data content of the target file, the current latest effective file body physical page may be composed of a plurality of physical pages. Of course, if the space size of one physical page can meet the storage requirement of the data content of the target file, one of the physical pages obtained by dividing the target storage area is used as the current latest effective file body physical page.
Optionally, in this embodiment, the number of file bodies, the target storage area, and the number of physical pages of the target storage area are all preset.
And step S12, selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page.
Step S12 may specifically be: selecting a next physical page adjacent to the current latest effective file body physical page from the target storage area as a target physical page; further, when the current latest valid file body physical page is the last physical page in the target storage area, the first physical page in the target storage area is taken as the target physical page.
It should be noted that, specifically, whether the current latest valid file body physical page is the last physical page is calculated according to the physical address of the target storage area and the size of the physical page, and if the current latest valid file body physical page is the last physical page in the target storage area, the first physical page in the target storage area is taken as the target physical page.
Alternatively, in step S12, specifically, the method includes: selecting a physical page which is different from the physical page of the current latest effective file body and has the least erasing times from the target storage area as a target physical page; further, when there are a plurality of physical pages with the smallest erasing times, one of the physical pages may be selected as the target physical page. For example, the number of physical pages in the target storage area is 4, and if the number of times of erasing the physical page of the current latest valid file body is 5, the number of times of erasing the physical page 1 is 5, and the number of times of erasing the physical page 2 is 4, one of the two physical pages with the number of times of erasing the physical page 4 is selected as the target physical page.
After the target physical page is determined, a data pointer is pointed to the target physical page so as to write the updated contents of the target file to the target physical page.
And step S13, obtaining the updated content of the target file according to the latest historical content and the update request, and writing the updated content of the target file into the target physical page.
Specifically, the data content in the physical page of the currently latest valid file body may be read out to the cache, and the data content in the cache is updated according to the update request of the target file, and the updated content is written into the target physical page.
For example, if the data to be updated is water flow data or heat data of 2 bytes carried in the update request (the water flow data/heat data is data obtained by real-time monitoring), the corresponding water flow data or heat data in the latest history content may be updated.
Further, step S13 may specifically be: and obtaining the updated content aiming at the target file according to the erasing times of the physical page of the current latest effective file body, the latest historical content and the updating request, and writing the updated content aiming at the target file into the target physical page.
Optionally, step S13 may specifically include: acquiring the erasing times of the current latest effective file physical page, updating the acquired erasing times of the file, and taking the updated erasing times of the file as the erasing times of the target file;
acquiring the latest historical content from the current latest effective file body physical page, updating the latest historical content according to the updating request to obtain the latest data content, calculating a check code according to the latest data content and the erasing frequency of the target file, and taking the calculated check code as the reference data check code of the target physical page;
and writing the latest data content, the reference data check code of the target physical page and the erasing times of the target file into the target physical page.
It can be understood that, if the target physical page stores data, the data in the target physical page needs to be erased first, and then the updated content for the target file needs to be written into the target physical page.
In the application, in response to an update request of a target file, a current latest effective file body physical page is searched in a target storage area of Flash, a physical page, in which the latest historical content of the target file is currently stored, of the target storage area is determined, on the basis, a physical page different from the current latest effective file body physical page is selected from the target storage area and is used as a target physical page, the update content of the target file is written into the target physical page, the target file is updated in different physical pages in a circulating manner, the erasing frequency of the target file in Flash is equal to the sum of the erasing frequency of different physical pages, compared with the situation that the target file is always updated in the same physical page, the erasing frequency of the target file in Flash is improved, and the utilization rate of Flash is improved.
In addition, the file erasing method of the Flash storage area disclosed by the embodiment of the application can only aim at the target file which needs to be updated frequently, and has higher implementation flexibility and interface independence and lower system implementation cost.
As another optional embodiment of the present application, referring to fig. 2, a schematic flow chart of embodiment 2 of a file erasing method for a Flash storage area provided by the present application is provided, where this embodiment mainly relates to a refinement scheme of the file erasing method for the Flash storage area described in the above embodiment 1, and as shown in fig. 2, the method may include, but is not limited to, the following steps:
step S21, responding to the update request of the target file, and acquiring effective identification information and data content of each physical page in the target storage area of Flash, wherein the effective identification information comprises: the reference data check code and the file erasing times.
The target storage area is a storage area pre-allocated for the target file.
In this embodiment, a physical page with a size of 512 bytes is taken as an example to introduce the data structure of the physical page, and as shown in table 2, 1 to 6 bytes of the physical page may store valid identification information, and 7 to 512 bytes may store data content.
TABLE 2
Figure BDA0002106429770000091
In this embodiment, the number of times of erasing the file may be recorded by the update counter. The update counter can count the erasing times of the file by performing an increasing or decreasing operation on the erasing times of the initial file.
And step S22, calculating the check code according to the data content of each physical page and the erasing times of the file, and taking the calculated check code as the first target data check code.
In this embodiment, step S22 may specifically be: and calculating a check code through a Cyclic Redundancy Check (CRC) check code according to the data content of each physical page and the erasing times of the file, and taking the calculated check code as a first target data check code. Calculating the check code according to the data content of each physical page and the number of times of erasing the file, and taking the calculated check code as a first target data check code, which can be understood as follows: calculating a check code aiming at each physical page, and taking the check code calculated by each physical page as a corresponding first target data check code; the process of calculating the check code for each physical page may be: and calculating the check code according to the data content of the physical page and the erasing times of the file.
And step S23, comparing whether the reference data check code and the first target data check code of each physical page are consistent, respectively, to obtain a comparison result, and taking the physical page with the consistent comparison result as an effective physical page.
By comparing the reference data check code and the first target data check code of the physical page, the reliability of reading and writing of the physical page can be improved.
Of course, there may be cases where the comparison results are inconsistent, and when the comparison results are inconsistent, the physical page whose comparison result is inconsistent is regarded as an invalid physical page.
And step S24, taking the effective physical page with the file erasing times meeting the first set condition as the current latest effective file body physical page.
The current latest effective file body physical page at least stores the latest historical content of the target file.
When the physical page is determined to be the valid physical page in step S23, the valid physical page whose number of times of file erasure matches the first setting condition is used as the current latest valid file body physical page, so that the reliability of determining the current latest valid file body physical page can be improved.
It is understood that the setting of the first setting condition is required to satisfy the requirement that the physical page on which the latest written data can be determined from the valid physical pages. The first setting condition may be set according to a specific scenario. If the value of the erase count of the initial file is 0, and the scenes of the erase count of the file are sequentially incremented, the first setting condition may be set as: the value of the number of file erasures is the largest. Or, the value corresponding to the initial file erasing times is a set value, and the scenes of the file erasing times are sequentially decreased, where the first set condition may be set as: the value of the number of file erasures is minimal.
For simplicity of implementation, the first setting condition may be set to a value at which the number of file erasures is maximum. It should be noted that the setting conditions include, but are not limited to, the maximum value of the number of times of erasing the file, and other counting mechanisms that satisfy the application limit of the number of times of erasing the file and can identify the physical pages of the valid file body, which are not limited in this application.
As described in the foregoing embodiment step S11, if the current latest valid file body physical page is composed of a plurality of physical pages, in order to save the physical page storage space, the valid identification information may be recorded only in the first physical page of the plurality of physical pages. And the reference data check code in the effective identification information is obtained by calculating the data content and the file erasing times of all the physical pages forming the current latest effective file body physical page.
Steps S21-S24 are exemplary steps S11 of the previous embodiment.
And step S25, selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page.
It is understood that this step is intended to select a physical page from the target storage area that is different from the current latest valid file body physical page, and the target storage area includes valid physical pages and/or invalid physical pages, but the physical page in the target storage area can be a target physical page as long as it is different from the current latest valid file body physical page.
Therefore, selecting a physical page different from the physical page of the current latest valid file body from the target storage area as a target physical page, which can be understood as: and selecting a valid physical page or an invalid physical page which is different from the physical page of the current latest valid file body from the target storage area as a target physical page.
Step S26, obtaining the updated content for the target file according to the latest history content and the update request, and writing the updated content for the target file into a target physical page.
Step S26 is the same as step S13 in the previous embodiment, and the detailed process of step S26 can be referred to the related description of step S13, which is not repeated herein.
As another optional embodiment of the present application, referring to fig. 3, a schematic flow chart of embodiment 3 of a file erasing method for a Flash storage area provided by the present application is provided, where this embodiment mainly relates to a refinement scheme of the file erasing method for the Flash storage area described in the above embodiment 1, and as shown in fig. 3, the method may include, but is not limited to, the following steps:
and step S31, responding to the update request of the target file, and searching the physical page of the current latest effective file body in the target storage area of Flash.
The target storage area is a storage area pre-allocated for the target file, and the physical page of the current latest effective file body at least stores the latest historical content of the target file.
And step S32, selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page.
The detailed procedures of steps S31-S32 can be found in the related descriptions of steps S11-S12 in embodiment 1, and are not repeated herein.
And step S33, acquiring the erasing times of the files in the physical page of the current latest effective file body, updating the acquired erasing times of the files, and taking the updated erasing times of the files as the erasing times of the target files.
It can be understood that the number of times of erasing the file recorded in the physical page of the current latest valid file body is the latest number of times of erasing the target file, and therefore, before the target file is written into a new physical page in response to an update request of the target file, the number of times of erasing the file in the physical page of the current latest valid file body needs to be obtained, the obtained number of times of erasing the file in the physical page of the current latest valid file body is updated, and the updated number of times of erasing the file is used as the number of times of erasing the target file.
In this embodiment, the number of times of erasing and writing the file in the physical page of the current latest valid file body may be updated according to the set number update rule, for example, n is added to the number of times of erasing and writing the file in the physical page of the current latest valid file body when the set number update rule is an increment rule, where n is an integer greater than 0. Or, in the case that the set number updating rule is a decreasing rule, decreasing n by the number of erasing times of the file in the physical page of the current latest valid file body, where n is an integer greater than 0. For example, n is 1, and when the set number updating rule is an increment rule, 1 is added to the number of file erasing times in the physical page of the current latest valid file body; and if the set number updating rule is a decreasing rule, subtracting 1 from the number of file erasing times in the physical page of the current latest effective file body.
Step S34, obtaining the latest history content from the current latest valid file physical page, updating the latest history content according to the update request to obtain the latest data content, calculating a check code according to the latest data content and the erasing and writing times of the target file, and using the calculated check code as the reference data check code of the target physical page.
The update request carries data of preset bytes, and the data of the preset bytes is used for updating corresponding data in the latest historical content, for example, the update request carries heat data or water meter data of 2 bytes, and the data of 2 bytes is used for updating corresponding heat data or water meter data in the latest historical content).
And calculating a check code according to the latest data content and the erasing times of the target file, so as to realize the updating of the data check code.
And step S35, writing the latest data content, the reference data check code of the target physical page, and the erasing times of the target file into the target physical page.
It can be understood that the data content of the target file, the reference data check code of the target physical page, and the erasing times of the target file carried in the update request are the update content of the target file in step S13 in embodiment 1.
And writing the data content of the target file carried by the updating request into a target physical page to complete the updating of the data content of the target file in Flash.
And writing the reference data check code of the target physical page and the erasing times of the target file into the target physical page, so as to ensure the effectiveness and accuracy of the effective identification information stored in the target physical page.
Steps S33-S35 are a specific implementation of step S13 in example 1.
It should be noted that the number of times of erasing the file recorded in the physical page of the current latest valid file body may not be equal to the number of times that the physical page of the current latest valid file body has actually erased the file, and the number of times of erasing the target file may not be equal to the number of times that the physical page of the target file has actually erased the file. For example, the target file has been updated 6 times, the updating occurs in physical pages 1, 3, 2, 5, 6, 7 respectively, where physical page 7 is the physical page of the current latest valid file body, and in 6 updates, the number of times that physical page 7 has actually erased the file is 1. After 6 times of updating, the target file needs to be updated again, the number of times of erasing and writing of the file is acquired from the physical page 7 and is 6, the acquired number of times of erasing and writing of the file is 6 and is updated to 7 in a mode of increasing 1, the number of times of erasing and writing of the target file is 7, if the determined target physical page is the physical page 3, the number of times of erasing and writing of the target file is 7 and the number of times of actually erasing and writing of the file on the physical page 3 is 2, wherein the number of times of erasing and writing of the file is 7 and is recorded in the physical page 3.
As another optional embodiment of the present application, referring to fig. 4, a flowchart of an embodiment 4 of a file erasing method for a Flash storage area provided by the present application is shown, where this embodiment mainly refers to a refinement scheme of the file erasing method for the Flash storage area described in the above embodiment 2, and as shown in fig. 4, the method may include, but is not limited to, the following steps:
step S41, responding to the update request of the target file, and acquiring effective identification information and data content of each physical page in the target storage area of Flash, wherein the effective identification information comprises: the reference data check code and the file erasing times.
And step S42, calculating the check code according to the data content of each physical page and the erasing times of the file, and taking the calculated check code as the first target data check code.
And step S43, comparing whether the reference data check code and the first target data check code of each physical page are consistent, respectively, to obtain a comparison result, and taking the physical page with the consistent comparison result as an effective physical page.
And step S44, taking the effective physical page with the file erasing times meeting the first set condition as the current latest effective file body physical page.
And step S45, selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page.
The detailed procedures of steps S41-S45 can be referred to the related descriptions of steps S21-S25 in embodiment 2, and are not described herein again.
And step S46, acquiring the erasing times of the files in the physical page of the current latest effective file body, updating the acquired erasing times of the files, and taking the updated erasing times of the files as the erasing times of the target files.
Step S47, obtaining the latest history content from the current latest valid file physical page, updating the latest history content according to the update request to obtain the latest data content, calculating a check code according to the latest data content and the erasing and writing times of the target file, and using the calculated check code as the reference data check code of the target physical page.
And step S48, writing the latest data content, the reference data check code of the target physical page, and the erasing times of the target file into the target physical page.
The detailed procedures of steps S46-S48 can be referred to the related descriptions of steps S33-S35 in embodiment 3, and are not described herein again.
As another optional embodiment of the present application, referring to fig. 5, a schematic flow chart of embodiment 5 of a file erasing method for a Flash storage area provided by the present application is provided, where this embodiment mainly relates to an extension scheme of the file erasing method for a Flash storage area described in the foregoing embodiment 1, and as shown in fig. 5, the method may include, but is not limited to, the following steps:
and step S51, responding to the update request of the target file, acquiring a physical address from the set area of the Flash, and taking the physical page corresponding to the acquired physical address as the current latest effective file body physical page.
The setting area may be in one physical page in the target storage area, or may be in a storage area outside the target storage area, and is used for storing the physical address of the current latest valid file body physical page.
It can be understood that, after the update of the target file in Flash is completed last time, the physical address of the physical page of the data content written into the target file last time (i.e. the physical page of the current latest valid file body) can be stored in the set area, so that the physical address can be obtained from the set area, the physical page of the current latest valid file body can be directly determined, and the searching efficiency of the physical page of the latest valid file body can be improved.
The current latest effective file body physical page is a part of a target storage area of Flash, the target storage area is a storage area pre-allocated for the target file, and the current latest effective file body physical page at least stores the latest historical content of the target file.
And step S52, selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page.
And step S53, writing the updated content aiming at the target file into the target physical page.
The detailed procedures of steps S52-S53 can be found in the related descriptions of steps S12-S13 in embodiment 1, and are not repeated herein.
As another optional embodiment of the present application, referring to fig. 6, a flowchart of an embodiment 6 of a file erasing method for a Flash storage area provided by the present application is shown, where this embodiment mainly is an extension scheme of the file erasing method for a Flash storage area described in the above embodiment 5, and as shown in fig. 6, the method may include, but is not limited to, the following steps:
and step S61, responding to the update request of the target file, acquiring a physical address from the set area of the Flash, and taking the physical page corresponding to the acquired physical address as the current latest effective file body physical page.
And step S62, selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page.
And step S63, writing the updated content aiming at the target file into the target physical page.
The detailed procedures of steps S61-S63 can be referred to the related descriptions of steps S51-S53, and are not described herein again.
And step S64, calculating a check code according to the data content in the target physical page and the erasing times of the target file, and taking the calculated check code as a second data check code.
And step S65, comparing whether the reference data check code of the target physical page and the second data check code are consistent.
If yes, go to step S66.
Comparing whether the reference data check code of the target physical page is consistent with the second data check code to judge whether the data content is successfully written into the target physical page, and if so, indicating that the target physical page is a valid physical page; if the number of times of erasing and writing of any one of the files is different from that of the target physical page, the effective physical page with the erasing and writing times meeting the set conditions can be regarded as the current latest effective file body physical page, and the physical address in the set area is updated to the physical address of the effective physical page. Of course, if they do not match, the physical address in the setting area may be used as the identifier of the current latest valid physical page.
And step S66, updating the physical address in the setting area to the physical address of the target physical page.
Optionally, step S66 may specifically be: the data in the set area is updated using the address of the target physical page. When the target physical page is an effective physical page, the target physical page is considered to be a current latest effective file body physical page, the physical address of the target physical page is used as the identifier of the current latest effective file body physical page, and the physical address in the set area is updated to be the physical address of the target physical page, so that the current latest effective file body physical page can be quickly found when the target file is updated next time, and the overall updating efficiency is improved.
In this embodiment, another refinement scheme for the file erasing method of the Flash storage area described in embodiment 5 above is provided, and the method may include, but is not limited to, the following steps:
a11, responding to the update request of the target file, acquiring a physical address from the set area of the Flash, calculating a check code according to the data content in the physical page corresponding to the acquired physical address and the erasing and writing times of the target file, and taking the calculated check code as a second data check code.
And A12, comparing whether the reference data check code and the second data check code in the physical page corresponding to the acquired physical address are consistent.
If yes, go to step A13; if not, step A14 is performed.
A13, taking the physical page corresponding to the acquired physical address as the current latest effective file body physical page;
and A14, setting any physical page with erasing times different from the physical page corresponding to the acquired physical address and meeting the set condition as the current latest effective file body physical page.
A11-A14 is a detailed description of step S51 in example 5.
And A15, selecting a physical page different from the physical page of the current latest effective file body from the set area as a target physical page.
And A16, writing the updated content aiming at the target file into the target physical page.
A17, storing the address of the target physical page in the setting area.
As another alternative embodiment of the present application, referring to fig. 7, a flowchart of embodiment 7 of a file erasing method for a Flash storage area provided by the present application is shown in fig. 7, where the method may include, but is not limited to, the following steps:
and step S71, responding to the update request of the target file, acquiring a physical address from the set area of the Flash, and taking the physical page corresponding to the acquired physical address as the current latest effective file body physical page.
The setting area is used for storing the physical address of the physical page of the current latest valid file body.
The detailed process of step S71 can be referred to the related description of step S51 in embodiment 5, and is not repeated here.
And step S72, selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page.
And step S73, acquiring the erasing times of the files in the physical page of the current latest effective file body, updating the acquired erasing times of the files, and taking the updated erasing times of the files as the erasing times of the target files.
Step S74, obtaining the latest history content from the current latest valid file physical page, updating the latest history content according to the update request to obtain the latest data content, calculating a check code according to the latest data content and the erasing and writing times of the target file, and using the calculated check code as the reference data check code of the target physical page.
And step S75, writing the latest data content, the reference data check code of the target physical page, and the erasing times of the target file into the target physical page.
The detailed procedures of steps S72-S75 can be referred to the related descriptions of steps S32-S35 in embodiment 3, and are not described herein again.
As another optional embodiment of the present application, referring to fig. 8, a schematic flow chart of an embodiment 8 of a file erasing method for a Flash storage area provided by the present application is provided, where this embodiment mainly is an extension scheme of the file erasing method for a Flash storage area described in the above embodiment 7, and as shown in fig. 8, the method may include, but is not limited to, the following steps:
and step S81, responding to the update request of the target file, acquiring a physical address from the set area of the Flash, and taking the physical page corresponding to the acquired physical address as the current latest effective file body physical page.
The setting area is used for storing the physical address of the physical page of the current latest valid file body.
And step S82, selecting a physical page different from the physical page of the current latest effective file body from the target storage area as a target physical page.
And step S83, acquiring the erasing times of the files in the physical page of the current latest effective file body, updating the acquired erasing times of the files, and taking the updated erasing times of the files as the erasing times of the target files.
Step S84, obtaining the latest history content from the current latest valid file physical page, updating the latest history content according to the update request to obtain the latest data content, calculating a check code according to the latest data content and the erasing and writing times of the target file, and using the calculated check code as the reference data check code of the target physical page.
And step S85, writing the latest data content, the reference data check code of the target physical page, and the erasing times of the target file into the target physical page.
The detailed procedures of steps S81-S85 can be found in the related descriptions of steps S71-S75 in example 7, and are not repeated herein.
And step S86, calculating a check code according to the data content in the target physical page and the erasing times of the target file, and taking the calculated check code as a second data check code.
And step S87, comparing whether the reference data check code of the target physical page and the second data check code are consistent.
If yes, go to step S88.
And step S88, updating the physical address in the setting area to the physical address of the target physical page.
The detailed procedures of steps S86-S88 can be found in the related descriptions of steps S64-S66 in embodiment 6, and are not repeated herein.
Alternatively, in step S87, if the comparison result is inconsistent, the flow is terminated (i.e., whether the area is set to the original physical address)
Next, a file erasing device of a Flash storage area provided by the present application is introduced, and the file erasing device of the Flash storage area and the file erasing method of the Flash storage area introduced above may be referred to correspondingly.
Referring to fig. 9, the file erasing apparatus of the Flash storage area includes: a search module 11, a selection module 12 and a first writing module 13.
The searching module 11 is configured to search, in response to an update request of a target file, a current latest valid file body physical page in a target storage area of Flash, where the target storage area is a storage area pre-allocated to the target file, and the current latest valid file body physical page stores at least latest history content of the target file;
a selecting module 12, configured to select, from the target storage area, a physical page that is different from the physical page of the current latest valid file body found by the searching module, as a target physical page;
a first writing module 13, configured to obtain the updated content for the target file according to the latest history content and the update request, and write the updated content for the target file into the target physical page.
In this embodiment, the first writing module 13 may include:
the first obtaining sub-module is used for obtaining the file erasing times of the physical page of the current latest effective file body, updating the obtained file erasing times and taking the updated file erasing times as the erasing times of the target file;
the first determining submodule is used for acquiring the latest historical content from the current latest effective file physical page, updating the latest historical content according to the updating request to obtain the latest data content, calculating a check code according to the latest data content and the erasing times of the target file, and taking the calculated check code as a reference data check code of the target physical page;
and the first writing submodule is used for writing the latest data content, the reference data check code of the target physical page and the erasing times of the target file into the target physical page.
In this embodiment, the searching module 11 may include:
a second obtaining sub-module, configured to obtain valid identification information and data content of each physical page in the target storage area, where the valid identification information includes: checking codes of the reference data and erasing times of the file;
the second determining submodule is used for calculating a check code according to the data content of each physical page and the erasing times of the file, and taking the calculated check code as a first target data check code;
the third determining submodule is used for respectively comparing whether the reference data check code and the first target data check code of each physical page are consistent or not, and taking the physical page with the consistent comparison result as an effective physical page;
and the fourth determining submodule is used for taking the effective physical page with the file erasing times meeting the first set condition as the current latest effective file body physical page.
In this embodiment, the searching module 11 may include:
the fifth determining submodule is used for acquiring a physical address from the set area and taking a physical page corresponding to the acquired physical address as a current latest effective file body physical page;
correspondingly, the file erasing device of the Flash storage area may further include:
the first determining module is used for calculating a check code according to the data content in the target physical page and the erasing frequency of the target file, and taking the calculated check code as a second data check code;
the comparison module is used for comparing whether the reference data check code of the target physical page is consistent with the second data check code;
and the updating module is used for updating the physical address in the set area to the physical address of the target physical page if the reference data check code of the target physical page is consistent with the second data check code.
In this embodiment, the selecting module 12 is specifically configured to select, from the target storage area, a next physical page adjacent to the current latest valid file body physical page as a target physical page, and when the current latest valid file body physical page is a last physical page in the target storage area, take a first physical page in the target storage area as the target physical page.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. For the device-like embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
From the above description of the embodiments, it is clear to those skilled in the art that the present application can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present application may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments of the present application.
The method and the device for erasing the file in the Flash storage area provided by the application are introduced in detail, a specific example is applied in the method to explain the principle and the implementation of the application, and the description of the embodiment is only used for helping to understand the method and the core idea of the application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (16)

1. A file erasing method of a Flash storage area is characterized by comprising the following steps:
responding to an update request of a target file, and searching a current latest effective file body physical page in a target storage area of Flash, wherein the target storage area is a storage area pre-allocated for the target file, the current latest effective file body physical page at least stores latest historical content of the target file, and the target file is a file with frequent update;
selecting a physical page different from the physical page of the current latest valid file body from the target storage area as a target physical page, and selecting a physical page different from the physical page of the current latest valid file body from the target storage area as a target physical page, specifically: selecting a physical page which is different from the physical page of the current latest effective file body and has the least erasing times from the target storage area as a target physical page, and selecting one physical page as the target physical page when the physical page with the least erasing times is multiple;
and obtaining the updated content aiming at the target file according to the latest historical content and the update request, and writing the updated content aiming at the target file into the target physical page.
2. The method according to claim 1, wherein obtaining the updated content for the target file according to the latest history content and the update request, and writing the updated content for the target file into the target physical page specifically includes:
acquiring the erasing times of the current latest effective file physical page, updating the acquired erasing times of the file, and taking the updated erasing times of the file as the erasing times of the target file;
acquiring the latest historical content from the current latest effective file body physical page, updating the latest historical content according to the updating request to obtain the latest data content, calculating a check code according to the latest data content and the erasing frequency of the target file, and taking the calculated check code as a reference data check code of the target physical page;
and writing the latest data content, the reference data check code of the target physical page and the erasing times of the target file into the target physical page.
3. The method according to claim 1 or 2, wherein the searching for the physical page of the current latest valid file body in the target storage area of Flash comprises:
obtaining effective identification information and data content of each physical page in the target storage area, wherein the effective identification information comprises: checking codes of the reference data and erasing times of the file;
calculating a check code according to the data content of each physical page and the erasing times of the file, and taking the calculated check code as a first target data check code;
respectively comparing whether the reference data check code and the first target data check code of each physical page are consistent, and taking the physical page with the consistent comparison result as an effective physical page;
and taking the effective physical page with the file erasing times meeting the first set condition as the current latest effective file body physical page.
4. The method of claim 3, further comprising:
and taking the physical page with the inconsistent comparison result as an invalid physical page.
5. The method according to claim 3, wherein the first setting condition is specifically: the value of the number of file erasures is the largest, or the value of the number of file erasures is the smallest.
6. The method of claim 5,
when the first setting condition is that the value of the number of times of erasing the file is maximum, the obtaining of the update content for the target file according to the latest history content and the update request includes: updating the value of the number of times of erasing the file in a descending manner;
when the value of the number of times of file erasing included in the first setting condition is minimum, the obtaining of the update content for the target file according to the latest history content and the update request includes: updating the value of the number of file erasures in an incremental manner.
7. The method according to claim 1 or 2, wherein the searching for the physical page of the current latest valid file body in the target storage area of Flash comprises: acquiring a physical address from a set area, and taking a physical page corresponding to the acquired physical address as a current latest effective file body physical page;
after writing the target physical page for the updated content of the target file, further comprising:
calculating a check code according to the data content in the target physical page and the erasing frequency of the target file, and taking the calculated check code as a second data check code;
and comparing whether the reference data check code of the target physical page is consistent with the second data check code, and if so, updating the physical address in the set area to be the physical address of the target physical page.
8. The method of claim 7, further comprising:
and if the reference data check code of the target physical page is inconsistent with the second data check code, taking an effective physical page with any one file erasing frequency different from that of the target physical page meeting set conditions as a current latest effective file body physical page, and updating a physical address in a set area to be a physical address of an effective physical page with any one file erasing frequency different from that of the target physical page meeting set conditions.
9. The method according to claim 1 or 2, wherein the searching for the physical page of the current latest valid file body in the target storage area of Flash comprises:
acquiring a physical address from a set area of Flash, calculating a check code according to data content in a physical page corresponding to the acquired physical address and the erasing frequency of a target file, and taking the calculated check code as a second data check code;
comparing whether the reference data check code in the physical page corresponding to the acquired physical address is consistent with the second data check code;
and if the physical pages are consistent, taking the physical page corresponding to the acquired physical address as the current latest effective file body physical page.
10. The method of claim 9, further comprising:
and if the reference data check code and the second data check code in the physical page corresponding to the acquired physical address are not consistent, taking the physical page with any erasing and writing times different from those of the physical page corresponding to the acquired physical address and meeting the set condition as the current latest effective file body physical page.
11. The method of claim 1, wherein the physical page different from the current latest valid file body physical page is selected from the target storage area and replaced with: and selecting the next physical page adjacent to the current latest effective file body physical page from the target storage area as a target physical page, and when the current latest effective file body physical page is the last physical page in the target storage area, taking the first physical page in the target storage area as the target physical page.
12. A file erasing device of a Flash storage area is characterized by comprising:
the searching module is used for responding to an updating request of a target file and searching a current latest effective file body physical page in a target storage area of Flash, wherein the target storage area is a storage area pre-allocated aiming at the target file, the current latest effective file body physical page at least stores latest historical content of the target file, and the target file is a file which is frequently updated;
the selecting module is specifically configured to select, from the target storage area, a physical page that is different from the physical page of the current latest valid document body found by the searching module and has the smallest erasing frequency as a target physical page, and when there are a plurality of physical pages having the smallest erasing frequency, select one of the physical pages as the target physical page;
and the first writing module is used for obtaining the updated content aiming at the target file according to the latest historical content and the updating request and writing the updated content aiming at the target file into the target physical page.
13. The apparatus of claim 12, wherein the first write module comprises:
the first obtaining sub-module is used for obtaining the file erasing times of the physical page of the current latest effective file body, updating the obtained file erasing times and taking the updated file erasing times as the erasing times of the target file;
the first determining submodule is used for acquiring the latest historical content from the current latest effective file physical page, updating the latest historical content according to the updating request to obtain the latest data content, calculating a check code according to the latest data content and the erasing times of the target file, and taking the calculated check code as a reference data check code of the target physical page;
and the first writing submodule is used for writing the latest data content, the reference data check code of the target physical page and the erasing times of the target file into the target physical page.
14. The apparatus of claim 12 or 13, wherein the lookup module comprises:
a second obtaining sub-module, configured to obtain valid identification information and data content of each physical page in the target storage area, where the valid identification information includes: checking codes of the reference data and erasing times of the file;
the second determining submodule is used for calculating a check code according to the data content of each physical page and the erasing times of the file, and taking the calculated check code as a first target data check code;
the third determining submodule is used for respectively comparing whether the reference data check code and the first target data check code of each physical page are consistent or not, and taking the physical page with the consistent comparison result as an effective physical page;
and the fourth determining submodule is used for taking the effective physical page with the file erasing times meeting the first set condition as the current latest effective file body physical page.
15. The apparatus of claim 12 or 13, wherein the lookup module comprises:
the fifth determining submodule is used for acquiring a physical address from the set area and taking a physical page corresponding to the acquired physical address as a current latest effective file body physical page;
the device further comprises:
the first determining module is used for calculating a check code according to the data content in the target physical page and the erasing frequency of the target file, and taking the calculated check code as a second data check code;
the comparison module is used for comparing whether the reference data check code of the target physical page is consistent with the second data check code;
and the updating module is used for updating the physical address in the set area to the physical address of the target physical page if the reference data check code of the target physical page is consistent with the second data check code.
16. The apparatus of claim 12, wherein the selecting module is specifically configured to select, from the target storage area, a physical page that is different from the physical page of the currently latest valid file body and has the smallest erasure count as the target physical page, and when there are a plurality of physical pages having the smallest erasure count, a process of selecting one of the physical pages as the target physical page is replaced with: and selecting the next physical page adjacent to the current latest effective file body physical page from the target storage area as a target physical page, and when the current latest effective file body physical page is the last physical page in the target storage area, taking the first physical page in the target storage area as the target physical page.
CN201910554352.4A 2019-06-25 2019-06-25 File erasing method and device for Flash storage area Active CN110888596B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910554352.4A CN110888596B (en) 2019-06-25 2019-06-25 File erasing method and device for Flash storage area

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910554352.4A CN110888596B (en) 2019-06-25 2019-06-25 File erasing method and device for Flash storage area

Publications (2)

Publication Number Publication Date
CN110888596A CN110888596A (en) 2020-03-17
CN110888596B true CN110888596B (en) 2021-07-09

Family

ID=69745827

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910554352.4A Active CN110888596B (en) 2019-06-25 2019-06-25 File erasing method and device for Flash storage area

Country Status (1)

Country Link
CN (1) CN110888596B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156731A (en) * 2011-04-08 2011-08-17 传聚互动(北京)科技有限公司 Data storage method and device for flash memory
CN103064792A (en) * 2012-12-26 2013-04-24 北京创毅讯联科技股份有限公司 Method and device for writing data
CN105630701A (en) * 2015-05-29 2016-06-01 上海磁宇信息科技有限公司 Data storage apparatus and read/write method using unavailable page table or unavailable block table
CN107037986A (en) * 2017-03-20 2017-08-11 北京握奇智能科技有限公司 A kind of method and apparatus for extending the erasable chip life-span
US10013346B2 (en) * 2015-11-17 2018-07-03 Western Digital Technologies, Inc. Method of decreasing write amplification of NAND flash using a journal approach
CN108255740A (en) * 2017-12-07 2018-07-06 深圳市中易通安全芯科技有限公司 A kind of FLASH equilibriums erasing-writing method and system
CN108664208A (en) * 2017-03-27 2018-10-16 纳思达股份有限公司 File appending write operation method based on FLASH memory and device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102789423B (en) * 2012-07-11 2014-12-10 山东华芯半导体有限公司 Four-pool flash wear leveling method
CN105138655A (en) * 2015-08-31 2015-12-09 深圳市茁壮网络股份有限公司 Data storage and reading method and device
CN205179041U (en) * 2015-10-20 2016-04-20 厦门中天微电子科技有限公司 Concentrator communication device among three -phase power line communication system
CN107301015B (en) * 2016-04-15 2022-05-13 恩智浦美国有限公司 System and method for reducing stress on memory devices
CN106598484A (en) * 2016-11-17 2017-04-26 华为技术有限公司 Data storage method, flash memory chip and storage device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156731A (en) * 2011-04-08 2011-08-17 传聚互动(北京)科技有限公司 Data storage method and device for flash memory
CN103064792A (en) * 2012-12-26 2013-04-24 北京创毅讯联科技股份有限公司 Method and device for writing data
CN105630701A (en) * 2015-05-29 2016-06-01 上海磁宇信息科技有限公司 Data storage apparatus and read/write method using unavailable page table or unavailable block table
US10013346B2 (en) * 2015-11-17 2018-07-03 Western Digital Technologies, Inc. Method of decreasing write amplification of NAND flash using a journal approach
CN107037986A (en) * 2017-03-20 2017-08-11 北京握奇智能科技有限公司 A kind of method and apparatus for extending the erasable chip life-span
CN108664208A (en) * 2017-03-27 2018-10-16 纳思达股份有限公司 File appending write operation method based on FLASH memory and device
CN108255740A (en) * 2017-12-07 2018-07-06 深圳市中易通安全芯科技有限公司 A kind of FLASH equilibriums erasing-writing method and system

Also Published As

Publication number Publication date
CN110888596A (en) 2020-03-17

Similar Documents

Publication Publication Date Title
US8065304B2 (en) Using asymmetric memory
US8041883B2 (en) Restoring storage devices based on flash memories and related circuit, system, and method
CN106598876B (en) Data storage device and data maintenance method thereof
US20200117744A1 (en) Counter-based compaction of key-value store tree data block
US20080147998A1 (en) Method and apparatus for detecting static data area, wear-leveling, and merging data units in nonvolatile data storage device
US7725646B2 (en) Method of using a flash memory for a circular buffer
CN108776614B (en) Recovery method and device of storage block
CN106843842B (en) Method and device for updating application program configuration file
CN105988722A (en) Data storage method and embedded system
CN102136296A (en) Method for identifying metadata format of NANDFlash memory chip
CN114356248A (en) Data processing method and device
CN112988611A (en) Data writing method of nonvolatile memory, terminal and readable storage medium
CN110532195A (en) The workload sub-clustering of storage system and the method for executing it
CN110888596B (en) File erasing method and device for Flash storage area
CN111261214B (en) Answer protection monotonic counter and method for managing count value thereof
CN111143116A (en) Method and device for processing bad blocks of disk
CN111913890A (en) Non-volatile memory random read-write method based on security module
KR101699779B1 (en) Indexing method for flash memory
JP2018170603A (en) Coding program, coding apparatus, and coding method
CN116301614A (en) Memory data access method, system, device and storage medium
US11500721B2 (en) Solid-state disk and reading and writing method thereof
EP4134802A1 (en) Method and apparatus for data access of nand flash file, and storage medium
CN114185849A (en) File operation method, file operation system, electronic device and storage medium
CN110008059B (en) Data updating method and device for nonvolatile storage medium and storage medium
CN107346288B (en) Data writing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100089 Floor 12 1506, Building A 1, 66 Zhongguancun East Road, Haidian District, Beijing

Applicant after: Beijing Huahong Integrated Circuit Design Co., Ltd.

Address before: 100015 Beijing city Chaoyang District Gaojiayuan No. 1

Applicant before: BEIJING HUAHONG INTEGRATED CIRCUIT DESIGN Co.,Ltd.

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant