Data storage method and device, equipment, storage medium and computer program product

By obtaining the data modification amount of each sector in the Flash memory, centrally storing and updating data, frequent erasing and rewriting operations are avoided, and the problem of excessive erasing times during Flash memory write operations is solved, and the device life is extended And improve efficiency.

CN119473145APending Publication Date: 2025-02-18HANGZHOU CHIPJET TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411533216.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the prior art, when using Flash memory to perform write operations, the number of erases is too high, resulting in a reduction in memory space and affecting the life of Flash memory.

Method used

By obtaining the data modification amount of each sector in the Flash storage space, determining the target sector and obtaining its data, saving it in an idle sector, and in subsequent work, directly saving the updated data into an idle sector and modifying the data The status is invalid, avoiding every erase and rewrite.

Benefits of technology

This reduces the number of erasing times of Flash memory when performing write operations, extends the service life of Flash memory, and improves the efficiency of data writing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473145A_ABST
    Figure CN119473145A_ABST
Patent Text Reader

Abstract

The invention discloses a Flash data storage method which is used for reducing the erasure frequency when a Flash memory executes write operation, so that the service life of the Flash memory is prolonged. The method comprises the following steps: acquiring data modification amount of each sector in a Flash storage space in a working process; determining a target sector according to the data modification amount, and obtaining target data corresponding to the target sector; determining an idle sector in the Flash storage space, storing the target data into the idle sector, and recording the state of the target data as effective in the idle sector; acquiring update data corresponding to the target data in the working process; and storing the update data in the idle sector, and modifying the state of the target data to be invalid.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a Flash data storage method, device, equipment, storage medium and computer program product. Background Art

[0002] Flash memory has been widely used in the field of data storage because of its ability to save data even when power is off.

[0003] The storage units of Flash memory include bytes, pages, sectors, and blocks. Among them, a sector is a storage structure unit in Flash memory and is also the smallest unit of Flash memory erase operation. A sector can be divided into multiple storage addresses, and each storage address can store data independently.

[0004] Although Flash has no restrictions on reading data, it has many restrictions on writing data. Flash memory write operations can be divided into two categories: programming and erasing. Programming operations are based on bytes, and each bit in the byte can be changed from 1 (high state) to 0 (low state), or maintain the original value, but a bit that is 0 cannot be changed to 1. The erase operation is based on sectors, and all bits in the sector are changed to 1. Before writing data to a storage address in a sector, if the storage address has been written before, the data stored in other storage addresses of the sector needs to be saved, and then the entire sector containing the address is erased. After the erasure is completed, the saved data and the data to be written are rewritten to the sector, which seriously affects the data writing efficiency.

[0005] At the same time, due to the implementation technology of Flash memory, the number of erasures of each sector is limited (generally, the number of erasures of each sector cannot exceed 100,000 times). In the file system, some blocks of Flash memory have very high read and write frequencies. If the existing data erasure method is used, if the entire sector needs to be erased every time data is written, the sectors with high usage frequency will soon exceed the number of erasures, thereby reducing the storage space of the Flash memory and affecting the life of the Flash memory.

[0006] Therefore, how to reduce the number of Flash erase times as much as possible when using the Flash memory to perform write operations, thereby increasing the service life of the Flash memory has become a technical problem that needs to be solved urgently. Summary of the invention

[0007] The embodiment of the present application provides a Flash data storage method, which is used to reduce the number of erasure times when the Flash memory performs a write operation, thereby increasing the service life of the Flash memory.

[0008] The embodiment of the present application also provides a Flash data storage device, which is used to reduce the number of erasure times when the Flash memory performs a write operation, thereby increasing the service life of the Flash memory.

[0009] The embodiment of the present application also provides a Flash data storage device, which is used to reduce the number of erasure times when the Flash memory performs a write operation, thereby increasing the service life of the Flash memory.

[0010] The embodiment of the present application also provides a computer-readable storage medium, which is used to reduce the number of erasure times when the Flash memory performs a write operation, thereby increasing the service life of the Flash memory.

[0011] The embodiment of the present application also provides a computer program product for reducing the number of erasures when a Flash memory performs a write operation, thereby increasing the service life of the Flash memory.

[0012] The present application embodiment adopts the following technical solutions: A Flash data storage method comprises: obtaining the data modification amount of each sector in a Flash storage space during a working process; determining a target sector according to the data modification amount, and obtaining target data corresponding to the target sector; determining an idle sector in the Flash storage space, storing the target data in the idle sector, and recording the status of the target data as valid in the idle sector; obtaining updated data corresponding to the target data during the working process; storing the updated data in the idle sector, and modifying the status of the target data to invalid.

[0013] A Flash data storage device comprises: an identification unit, used to obtain the data modification amount of each sector in the Flash storage space during the working process; an original data acquisition unit, used to determine the target sector according to the data modification amount, and obtain the target data corresponding to the target sector; a storage unit, used to determine the free sector in the Flash storage space, store the target data in the free sector, and record the status of the target data as valid in the free sector; an update data acquisition unit, used to obtain the update data corresponding to the target data during the working process; a data modification unit, used to store the update data in the free sector, and modify the status of the target data to invalid.

[0014] A Flash data storage device, comprising: A processor; and a memory arranged to store computer executable instructions, wherein the executable instructions, when executed, cause the processor to perform the following operations: obtain the amount of data modification of each sector in the Flash storage space during the working process; determine the target sector according to the amount of data modification, and obtain the target data corresponding to the target sector; determine the free sector in the Flash storage space, store the target data in the free sector, and record the status of the target data as valid in the free sector; obtain the updated data corresponding to the target data during the working process; store the updated data in the free sector, and modify the status of the target data to invalid.

[0015] A computer-readable storage medium stores one or more programs. When the one or more programs are executed by an electronic device including multiple application programs, the electronic device performs the following operations: obtaining the data modification amount of each sector in a Flash storage space during a working process; determining a target sector according to the data modification amount, and obtaining target data corresponding to the target sector; determining a free sector in the Flash storage space, storing the target data in the free sector, and recording the status of the target data as valid in the free sector; obtaining updated data corresponding to the target data during the working process; storing the updated data in the free sector, and modifying the status of the target data to invalid.

[0016] A computer program product comprises a computer program, wherein when the computer program is executed by a processor, the following steps are implemented: obtaining the data modification amount of each sector in a Flash storage space during a working process; determining a target sector according to the data modification amount, and obtaining target data corresponding to the target sector; determining a free sector in the Flash storage space, storing the target data in the free sector, and recording the status of the target data as valid in the free sector; obtaining updated data corresponding to the target data during the working process; storing the updated data in the free sector, and modifying the status of the target data to invalid.

[0017] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: By adopting the Flash data storage method provided in the embodiment of the present application, in the process of using the Flash memory, the data modification amount of each sector in the Flash storage space during the working process can be first obtained; the target sector is determined according to the data modification amount, and the data modified in the target sector during the working process is obtained as the target data, and the free sector in the Flash storage space is determined, the target data is stored in the free sector, and the status of the target data is recorded as valid in the free sector, and then, in the subsequent working process, before the free sector still has storage space, the update data corresponding to the target data in the working process is obtained; the updated data is stored in the free sector, and the status of the target data is modified to invalid. By adopting the Flash data storage method provided in the embodiment of the present application, since the modified data in the sectors with a smaller amount of data modification during use can be centrally stored in a free sector, in the subsequent working process, before there is still storage space in the free sector, the updated data corresponding to the acquired modified data stored in the free sector can be directly stored in the free sector, and the status of the target data can be modified to invalid. In this way, the write modification of the data stored in the free sector can be realized without erasing the free sector first. When writing data, the number of erasures of the Flash memory when performing a write operation is greatly reduced, thereby improving the service life of the Flash memory. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 A schematic diagram of a specific process of a Flash data storage method provided in an embodiment of the present application; Figure 2 A schematic diagram of a specific process of another Flash data storage method provided in an embodiment of the present application; Figure 3 A schematic diagram of the specific structure of a Flash data storage device provided in an embodiment of the present application; Figure 4 A schematic diagram of the specific structure of a Flash data storage device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0020] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0021] A Flash data storage method provided in an embodiment of the present application is used to reduce the number of erasure times when a Flash memory performs a write operation, thereby increasing the service life of the Flash memory.

[0022] In order to facilitate the understanding of this solution, the basic structure of Flash memory is first introduced: 1. Sector: A storage structure unit in Flash memory. Flash memory is divided into a series of sectors for storing files and data. A sector can be divided into multiple storage addresses, and each storage address can store data independently.

[0023] 2. Block: A storage structure unit in Flash memory that is one level higher than a sector. It consists of a group of continuous sectors and is also the basic unit of file system management. The file system divides the disk space into a series of blocks for storing file data.

[0024] In one embodiment, based on the Flash memory structure as described above, a specific implementation flow diagram of the Flash data storage method provided by the present application is as follows: Figure 1 As shown, it mainly includes the following steps: Step 11, obtaining the data modification amount of each sector in the Flash storage space during the working process; Step 12, determining the target sector according to the data modification amount, and obtaining the target data corresponding to the target sector; The target data refers to the data modified during the operation of the target sector.

[0025] Step 13, determining a free sector in the Flash storage space, storing the target data in the free sector, and recording in the free sector that the data status of the target data is valid; Step 14, obtaining updated data corresponding to the target data during the working process; Step 15: store the updated data in a free sector and modify the state of the target data to be invalid.

[0026] By adopting the Flash data storage method provided in the embodiment of the present application, since the target data in the sectors with a smaller amount of data modification during use can be centrally stored in a free sector, in the subsequent working process, before there is still storage space in the free sector, the updated data corresponding to the acquired target data stored in the free sector can be directly used as modified data and stored in the free sector, and the state of the target data can be modified to invalid. In this way, direct write modification of the data in the free sector can be achieved without erasing the free sector each time and then writing data, which greatly reduces the number of erase times of the Flash memory when performing a write operation, thereby improving the service life and work efficiency of the Flash memory.

[0027] In another embodiment, a specific implementation flow chart of the Flash data storage method provided in the present application is as follows: Figure 2 As shown, it mainly includes the following steps: Step 21, obtaining the data modification amount of each sector in the Flash storage space during the working process; It should be noted here that in actual use, generally not all sectors of the Flash memory are used up. There will be some unused sectors (hereinafter referred to as free sectors), and the data stored in the sectors that are actually used is also different. Some sectors store more data, and some sectors store less data. In addition, the amount of data that needs to be modified in each sector during use is also different.

[0028] According to the existing Flash data writing scheme, before writing data to a certain storage address in a sector, if the storage address has been written with data, the entire sector needs to be erased before writing data. In this case, if the amount of data to be modified is small, for example, there are 100 storage addresses in a sector with data stored, and only the data in one of the storage addresses needs to be modified during use, but according to the existing Flash data writing scheme, all the data in the entire sector still needs to be erased before rewriting the data, which greatly affects the data writing efficiency.

[0029] In order to avoid the above situation, in an embodiment of the present application, the Flash memory can first determine the data modification amount of each sector during the working process, and then determine the sector with a smaller data modification amount as the target sector based on the acquired data modification amount.

[0030] Step 22, determining a target sector according to the data modification amount obtained by executing step 21, and obtaining target data corresponding to the target sector; The target data refers to the data modified during the operation of the target sector.

[0031] In the embodiment of the present application, the sector whose data modification amount is less than the preset data modification amount threshold (for example, 5 Byte) can be directly used as the target sector according to the size of the specific data modification amount. However, considering that the storage space and actual data storage amount of each sector are different, in this case, if the target sector is determined only according to the preset fixed data modification amount threshold, there may be a problem of affecting the data update efficiency.

[0032] For example, suppose a sector has only 5 bytes of storage space and currently stores 4 bytes of data. During use, the 4 bytes of data are modified. If the target sector is determined according to a preset fixed data modification amount threshold (such as 5 bytes), then in this case, the sector will be determined as the target sector, and then the original modified data of at least two target sectors will be combined and stored in other free sectors before the data is modified. However, since the proportion of data modified in the sector during operation accounts for 80% of the total data stored in the sector, in this case, directly erasing and rewriting the sector according to the prior art is the most preferred data modification solution.

[0033] In order to avoid the above problems, in the embodiment of the present application, the proportion of the data modification amount to the total amount of data stored in the sector can be determined according to the amount of data modification of each sector during use, and the data modification proportion corresponding to each sector can be obtained. Further, according to the data modification proportion, the sector whose data modification proportion is less than the preset modification proportion is determined as the target sector. It can be understood that the meaning of the data modification amount described in the present application includes but is not limited to the specific number of data modifications and the data modification proportion. As long as similar descriptions that can meet the inventive concept of the present application are included in the protection scope of the present application.

[0034] In an embodiment of the present application, the modification ratio can be set in advance (generally, sectors with a modification ratio of 10% or less are selected, such as 0.2%, 0.5%, 1%, 3%, 5%, and 10%). Then, when the data modification ratio corresponding to a sector is less than the preset modification ratio, the sector can be determined as a target sector, and the data that needs to be modified during use of the sector can be obtained as the target data corresponding to the sector.

[0035] For example, the preset modification ratio is 10%, and sectors a and b both have 20 storage addresses. During use, the data at storage address 1 of sector a and the data at storage address 5 of sector b need to be modified. It can be determined that the corresponding data modification ratio of sectors a and sector b during use is 5%, and then the sectors a and sector b can be determined as target sectors, and the data in storage address 1 of sector a and the data in storage address 5 of sector b can be used as their respective corresponding target data.

[0036] Step 23, determining the free sectors in the Flash storage space; Step 24, storing the target data in the free sector, and modifying the state of the target data to invalid; It should be noted here that by executing step 22, multiple target sectors that meet the conditions can be determined. In order to improve the data writing and modification efficiency for these target sectors, in this scheme, the target data corresponding to multiple target sectors can be combined, and the combined target data obtained after the combination can be stored in the same free sector. Then, in the subsequent use process, only one data modification needs to be performed on the free sector, and the data modification of multiple target sectors in the prior art can be realized, which greatly improves the data writing and modification efficiency.

[0037] In one implementation, the original data may be stored in the free sector according to the following method, including: obtaining target data corresponding to at least two of the target sectors; combining the obtained at least two target data to obtain combined target data; and storing the combined target data in the free sector.

[0038] It should be noted here that the user can set the target data combination corresponding to several target sectors to obtain the combined target data according to business needs; in addition, the Flash memory can also determine the target data combination corresponding to several target sectors to obtain the combined target data according to the number of free sectors determined by executing step 23 and the number of target data obtained by executing step 22. For example, when the number of target data obtained by executing step 22 is large and the number of free sectors determined by executing step 23 is small, the number of target data included in the combined target data can be increased, thereby ensuring that the target data in the target sectors determined by executing step 22 can be stored in these free sectors.

[0039] In addition, it should be noted that, in order to facilitate subsequent write operations, in the embodiment of the present application, the Flash memory can divide and set the storage area of ​​the free sector according to the combined target data, so as to store the combined target data and subsequently write and modify the data. Specifically, in one implementation, the Flash memory can set the storage area of ​​the free sector and store the combined target data in the set free sector by following the following sub-steps, which may specifically include: Sub-step 2401, determining the number of target data items included in the combined target data; Assume that there are three target sectors, and each target sector has one target data. The Flash memory combines the target data corresponding to the three target sectors to obtain combined target data. Then, the number of target data included in the combined target data is 3.

[0040] Sub-step 2402, dividing the free sectors into a plurality of storage areas according to the number of target data items; Sub-step 2403, determining the number of storage addresses contained in each storage area according to the number of target data items; In an embodiment of the present application, the free sector can store each target data in the combined target data in a storage address respectively, and record the status of the combined target data in one of the storage addresses. Therefore, in one implementation, the Flash memory can determine the number of storage addresses contained in each storage area in the free sector according to the number of target data contained in the combined target data plus one, and then divide the free sector into multiple storage areas according to the determined number of storage addresses contained in each storage area. Such a setting can make full use of the storage space of the free sector, improve the use efficiency of the Flash memory, and extend its service life.

[0041] For example, assuming that the Flash memory combines the target data corresponding to the three target sectors to obtain combined target data, the number of target data items contained in the combined target data is 3. The Flash memory can determine that the number of storage addresses contained in each storage area in the free sector is 4. The free sector has a total of 512 storage addresses. According to the number of storage addresses contained in each storage area, the Flash memory can divide the free sector into 128 storage areas.

[0042] Sub-step 2404: storing the combined target data in a first storage area in a free sector, so that each storage address in the first storage area stores a piece of target data included in the combined target data.

[0043] For example, assume that there are four sectors, namely sector 0, sector 1, sector 2 and sector 3. Among them, there is target data in storage address 0 of sector 0, storage address 1 of sector 1 and storage address 0 of sector 2, and sector 3 is a free sector, as shown in the following Table 1. According to the existing scheme, during use, when data needs to be updated, sectors 0, sector 1 and sector 2 are first erased, and then the updated data are written to storage address 0 of sector 0, storage address 1 of sector 1 and storage address 0 of sector 2 respectively.

[0044] By using the method provided in the embodiment of the present application, the Flash memory can respectively obtain the data 0xA0 stored in the storage address 0 of sector 0, the data 0xA1 stored in the storage address 1 of sector 1, and the data 0xA2 stored in the storage address 0 of sector 2 to form the combined target data. At the same time, the Flash memory can divide sector 3 into several storage areas with four storage addresses as a segment, wherein the first storage area of ​​sector 3 includes storage address 0, storage address 1, storage address 2, and storage address 3, and the second storage area includes storage address 4, storage address 5, storage address 6, and storage address 7, and so on. Then the Flash memory can store the data 0xA0 in the combined target data in sequence into the storage address 0 of the first storage area of ​​sector 3, store the data 0xA1 into the storage address 1 of the first storage area of ​​sector 3, and store the data 0xA2 into the storage address 2 of the first storage area of ​​sector 3, as shown in Table 2 below. At this time, the data value of the storage address 3 of the first storage area of ​​sector 3 is a status valid identifier, such as 0xFF, indicating that the data of the storage address 0, storage address 1 and storage address 2 of sector 3 are valid. With this storage method, the extra storage address in each storage area of ​​the idle sector can be used to store the data status, and then when the new update data is written into the sector, it only needs to modify the data of the last storage address of the previous storage area to an invalid identifier to invalidate the original data point without erasing and rewriting the entire sector, which greatly improves the use efficiency of the Flash memory.

[0045] Table 1 Existing sector storage table

[0046] Table 2 Target data is stored in free sectors and then the sector storage table is processed

[0047] Step 25, obtaining updated data corresponding to the target data during the working process; Step 26, determining the data length of the update data, and judging whether the free sector can store the update data according to the data length; Assuming that the number of data entries corresponding to the update data is 4, and the number of storage address entries remaining in the free sector is only 2, it can be determined that the free sector cannot store the update data, otherwise, it can be determined that the free sector can store the update data.

[0048] When the judgment result is yes, execute step 27; when the judgment result is no, execute step 28.

[0049] Step 27, storing the updated data obtained by executing step 15 into the free sector, and changing the state of the target data to invalid; In an embodiment of the present application, the Flash memory can store the updated data in sequence in a storage area after the last storage area storing data in the free sector. In one implementation, the Flash memory can specifically store the updated data in the free sector in the following manner, including: determining a first storage area in the free sector that stores the target data; determining a second storage area corresponding to the updated data in the free sector based on the first storage area; storing the updated data as modified data in the second storage area, so that each storage address in the second storage area stores a modified data contained in the updated data.

[0050] Still continuing the above example, when there is data update, the Flash memory can write the updated data to the storage address 4, storage address 5 and storage address 6 of the second storage area of ​​the sector 3, and modify the content of the storage address 3 of the first storage area of ​​the sector 3 to 0, indicating that the content stored in the storage address 0, storage address 1 and storage address 2 in the first storage area of ​​the free sector is invalid. At this time, the data value of the storage address 7 of the second storage area of ​​the free sector is 0xFF, indicating that the data stored in the storage address 4, storage address 5 and storage address 6 are valid, as shown in Table 3 below after the update. When calling the update data later, it is only necessary to read the valid identifier 0xFF of the free sector to obtain the updated data therein. In the above manner, before there is still storage space in the sector 3, for the updated data corresponding to the modified data obtained and stored in the sector 3, the updated data can be directly stored in the free sector, without the need to erase the sector first and then write data each time, which greatly reduces the number of erasures of the Flash memory when performing a write operation, thereby improving the service life of the Flash memory.

[0051] Table 3 Sector 3 storage table after update

[0052] Step 28, performing an erasing operation on the idle sectors, and storing the updated data in the idle sectors after the erasing operation is completed.

[0053] By adopting the Flash data storage method provided in the embodiment of the present application, in the process of using the Flash memory, the data modification ratio of each sector in the Flash storage space during the working process can be first obtained; according to the data modification amount, the target sector is determined according to the data modification amount, and the data modified in the target sector during the working process is obtained as the target data, and the free sectors in the Flash storage space are determined, the target data is stored in the free sectors, and the status of the target data is recorded as valid in the free sectors, and then, in the subsequent working process, before the free sector still has storage space, the updated data corresponding to the target data in the working process is obtained; the updated data is stored in the free sectors, and the status of the target data is modified to invalid. By adopting the Flash data storage method provided in the embodiment of the present application, since the modified data in the sectors with a smaller amount of data modification during use can be centrally stored in a free sector, in the subsequent working process, before there is still storage space in the free sector, the updated data corresponding to the acquired modified data stored in the free sector can be directly stored in the free sector, and the status of the target data can be modified to invalid. In this way, the write modification of the data stored in the free sector can be realized without erasing the free sector first and then writing data each time, which greatly reduces the number of erase times of the Flash memory when performing a write operation, thereby improving the service life of the Flash memory.

[0054] In one implementation, the present application also provides a Flash data storage device to reduce the number of erasures when the Flash memory performs a write operation, thereby increasing the service life of the Flash memory. Figure 3 As shown, it includes: an identification unit 31, an original data acquisition unit 32, a storage unit 33, an update data acquisition unit 34 and a data modification unit 35.

[0055] The identification unit 31 is used to obtain the data modification amount of each sector in the Flash storage space during the working process; The original data acquisition unit 32 is used to determine the target sector according to the data modification amount, and acquire the target data corresponding to the target sector; The storage unit 33 is used to determine a free sector in the Flash storage space, store the target data in the free sector, and record in the free sector that the state of the target data is valid; An update data acquisition unit 34, used to acquire update data corresponding to the target data during the working process; The data modification unit 35 is used to store the update data into the free sector and modify the state of the target data to be invalid.

[0056] In one implementation, the storage unit 33 is specifically used to: obtain target data corresponding to at least two of the target sectors; combine the obtained at least two of the target data to obtain combined target data; and store the combined target data in the free sector.

[0057] In one embodiment, the storage unit 33 is specifically used to: determine the number of target data items included in the combined target data; divide the free sector into multiple storage areas according to the number of target data items; determine the number of storage addresses included in each storage area according to the number of target data items; store the combined target data in the first storage area in the free sector, so that each storage address in the first storage area stores a target data item included in the combined target data.

[0058] In one embodiment, the data modification unit 35 is specifically used to: determine the data length of the updated data; determine whether the idle sector can store the updated data based on the data length; when the determination result is yes, store the updated data as modified data in the idle sector, and modify the status of the target data to invalid; when the determination result is no, perform an erase operation on the idle sector, and store the updated data in the idle sector after the erase operation is completed.

[0059] In one embodiment, the data modification unit 35 is specifically used to: determine a first storage area in the free sector that stores the target data; determine a second storage area in the free sector corresponding to the updated data based on the first storage area; store the updated data as modified data in the second storage area, so that each storage address in the second storage area stores a modified data contained in the updated data.

[0060] In one implementation, the data modification unit 35 is specifically configured to modify the data in the storage address storing the data state in the first storage area to an invalid identifier, for example, the value may be modified to 0.

[0061] In one implementation, the storage unit 33 is specifically configured to: add one to the number of target data items included in the combined target data, as the number of storage addresses included in each of the storage areas.

[0062] In one implementation, a storage address that is increased by one bit compared to the number of data to be modified in the storage area is used to store data status.

[0063] In one embodiment, the original data acquisition unit 32 is specifically used to: determine the amount of data modification of the sector during the working process; determine the data modification ratio corresponding to the sector based on the ratio of the data modification amount to the total data volume stored in the sector; and determine the sector whose data modification ratio is less than the preset modification ratio as the target sector.

[0064] By adopting the Flash data storage device provided in the embodiment of the present application, in the process of using the Flash memory, the data modification amount of each sector in the Flash storage space during the working process can be firstly obtained through the identification unit, and then the original data acquisition unit can determine the target sector according to the data modification amount obtained by the identification unit, and obtain the data modified in the target sector during the working process as the target data, and determine the free sector in the Flash storage space through the storage unit, store the target data in the free sector, and record the status of the target data as valid in the free sector. Then, in the subsequent working process, before the free sector still has storage space, the update data corresponding to the target data in the working process is obtained through the update data acquisition unit, and the update data is stored as modified data in the free sector through the data modification unit, and the status of the target data is modified to invalid. By using the Flash data storage device provided in the embodiment of the present application, since the modified data in the sectors with a smaller amount of data modification during use can be centrally stored in a free sector, in the subsequent working process, before there is still storage space in the free sector, for the updated data corresponding to the acquired modified data stored in the free sector, the updated data can be directly used as the modified data and stored in the free sector, and the status of the target data can be modified to invalid. In this way, the write modification of the data stored in the free sector can be realized without erasing the free sector first. When writing data, the number of erasures of the Flash memory when performing a write operation is greatly reduced, thereby improving the service life of the Flash memory.

[0065] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 4 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.

[0066] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0067] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.

[0068] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a Flash data storage device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations: obtain the data modification amount of each sector in the Flash storage space during the working process; determine the target sector according to the data modification amount, and obtain the target data corresponding to the target sector, wherein the modified data represents the data modified in the target sector during the working process; determine the free sector in the Flash storage space, store the target data in the free sector, and record the status of the target data as valid in the free sector; obtain the updated data corresponding to the target data during the working process; store the updated data in the free sector, and modify the status of the target data to invalid.

[0069] The above application Figure 4The method performed by the Flash data storage electronic device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in software form. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0070] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0071] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations: Obtain the data modification amount of each sector in the Flash storage space during the working process; determine the target sector according to the data modification amount, and obtain the target data corresponding to the target sector, wherein the modified data represents the data modified in the target sector during the working process; determine the free sector in the Flash storage space, store the target data in the free sector, and record the status of the target data as valid in the free sector; obtain the updated data corresponding to the target data during the working process; store the updated data in the free sector, and modify the status of the target data to invalid. Similarly, it can be seen that the data modification amount in this embodiment can be specifically reflected as the data modification ratio, which will not be repeated here.

[0072] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0073] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0074] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0075] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0076] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0077] Memory may include non-permanent storage in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0078] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0079] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0080] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0081] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A Flash data storage method, characterized in that: include: Obtain the data modification amount of each sector in the Flash storage space during the working process; Determine a target sector according to the data modification amount, and obtain target data corresponding to the target sector; Determine an idle sector in the Flash storage space, store the target data in the idle sector, and record in the idle sector that the data status of the target data is valid; Acquire update data corresponding to the target data during the working process; The updated data is stored in the free sector, and the state of the target data is modified to be invalid.

2. The method according to claim 1, characterized in that The storing the target data into the free sector specifically includes: Acquire target data corresponding to at least two of the target sectors; Combining the acquired at least two target data to obtain combined target data; The combined target data is stored in the free sector.

3. The method according to claim 2, characterized in that The storing the combined target data into the free sector specifically includes: Determining the number of target data items included in the combined target data; According to the target number of data pieces, the free sectors are divided into a plurality of storage areas; Determining the number of storage addresses contained in each storage area according to the number of target data items; The combined target data is stored in a first storage area in the free sector, so that each storage address in the first storage area stores a corresponding target data included in the combined target data.

4. The method according to claim 3, characterized in that The storing the updated data into the idle sector specifically includes: Determining the data length of the update data; According to the data length, determining whether the idle sector can store the update data; When the judgment result is yes, storing the updated data in the free sector and modifying the state of the target data to be invalid; When the judgment result is no, an erasing operation is performed on the idle sector, and the updated data is stored in the idle sector after the erasing operation is completed.

5. The method according to claim 4, characterized in that The storing the updated data into the idle sector specifically includes: Determine a first storage area in the free sector for storing the target data; According to the first storage area, determining a second storage area corresponding to the update data in the free sector; The update data is stored in the second storage area, so that each storage address in the second storage area stores a corresponding piece of modified data included in the update data.

6. The method according to claim 5, characterized in that The modifying the state of the target data to be invalid specifically includes: The data in the storage address storing the data state in the first storage area is modified to an invalid identifier.

7. The method according to claim 3, characterized in that Determining the number of storage addresses contained in each storage area according to the number of target data items specifically includes: The number of target data items included in the combined target data is increased by one to obtain the number of storage addresses included in each storage area.

8. The method according to claim 7, characterized in that The storage area has a storage address that is increased by one bit compared to the number of data to be modified and is used to store an identifier that records the data status.

9. The method according to claim 1, characterized in that: The determining the target sector according to the data modification amount specifically includes: Determining the amount of data modification of the sector during operation; Determine the data modification ratio corresponding to the sector according to the ratio of the data modification amount to the total data amount stored in the sector; The sector whose data modification ratio is less than the preset modification ratio is determined as the target sector.

10. The method according to claim 9, characterized in that The preset modification accounts for no more than 10%.

11. A Flash data storage device, characterized in that: include: An identification unit, used to obtain the data modification amount of each sector in the Flash storage space during the working process; a target data acquisition unit, configured to determine a target sector according to the data modification amount, and acquire target data corresponding to the target sector, wherein the modified data represents data modified in the target sector during operation; A storage unit, used for determining a free sector in the Flash storage space, storing the target data in the free sector, and recording in the free sector that the state of the target data is valid; An update data acquisition unit, used to acquire update data corresponding to the target data during the working process; The data modification unit is used to store the updated data in the free sector and modify the state of the target data to be invalid.

12. A Flash data storage device, comprising: processor; a memory arranged to store computer executable instructions which, when executed, cause the processor to: Get the amount of data in each sector of the Flash storage space during the working process; Determine a target sector according to the data modification amount, and obtain target data corresponding to the target sector, wherein the modified data represents data modified in the target sector during the working process; Determine an idle sector in the Flash storage space, store the target data in the idle sector, and record in the idle sector that the status of the target data is valid; Acquire update data corresponding to the target data during the working process; The updated data is stored in the free sector, and the state of the target data is modified to be invalid.

13. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, enables the electronic device to execute the Flash data storage method as described in any one of claims 1 to 10.

14. A computer program product, characterized in that It comprises a computer program, which, when executed by a processor, implements the Flash data storage method according to any one of claims 1 to 10.