Search

CN-121979457-A - Flash transaction mechanism optimization method, device, medium and equipment of embedded system

CN121979457ACN 121979457 ACN121979457 ACN 121979457ACN-121979457-A

Abstract

The application belongs to the technical field of embedded system storage management, and particularly discloses a Flash transaction mechanism optimization method, a device, a medium and equipment of an embedded system, wherein the method comprises the steps of initializing a Flash physical storage space to classify pages and define a page tail metadata format; dynamically initializing, scanning and Flash loading key management pages, constructing a free page pool in a memory, receiving a transaction request, finishing data reading and modification in the memory, selecting a target page from the free page pool based on a wear balancing strategy, atomically writing data modified by a transaction processing module and updated metadata into the target page, executing verification after writing, atomically updating an address mapping page to enable new data to be effective when the transaction is submitted, or discarding mapping changes in the memory to realize lossless rollback when the transaction is cancelled. The application can improve the transaction processing efficiency, the system reliability and the service life of Flash storage.

Inventors

  • ZHANG YAJUN
  • WANG ZONGCHAO
  • XU YU
  • WEI ZIHANG
  • WANG CHENGWEI

Assignees

  • 新疆大学

Dates

Publication Date
20260505
Application Date
20260123

Claims (10)

  1. 1. A Flash transaction mechanism optimization method of an embedded system is characterized by comprising the following steps: initializing a Flash physical storage space to classify pages and define a page tail metadata format; Dynamically initializing when the system is started, scanning and loading key management pages by Flash, and constructing a free page pool in a memory; Receiving a transaction request, and finishing data reading and modification in a memory; Selecting a target page from the free page pool based on a wear leveling policy; atomically writing the data modified by the transaction processing module and the updated metadata into the target page, and executing verification after writing; The address mapping page is atomically updated to validate new data at transaction commit or mapping changes in memory are discarded to achieve lossless rollback at transaction undo.
  2. 2. The method of claim 1, wherein initializing the Flash physical storage space to construct a page classification and metadata format comprises: carrying out page division on the Flash storage area; An additional data area is provided at the end of each divided page.
  3. 3. The method of claim 1, wherein the system dynamically initializing, scanning and loading key management pages to build a free page pool at start-up comprises: Scanning all pages of Flash, and identifying the page type; loading the address mapping page and the attribute page of the latest version; Establishing a memory mapping table from a logical address to a physical address; and constructing a free page pool, eliminating management pages and performing bad block management.
  4. 4. The method of claim 1, wherein receiving the transaction request to complete data preparation and modification in memory comprises: receiving a transaction request and acquiring a target logical address; inquiring an address mapping table to locate the original physical page address; Reading the original data from Flash into RAM cache; modifying the data content in the RAM cache based on the read-in original data; The target page information required for writing is prepared according to the data and transaction context for which the modification has been completed.
  5. 5. The method of claim 1, wherein the selecting a target page from a free page pool based on a wear leveling policy comprises: reading and analyzing the abrasion state of the idle pages, and obtaining the writing times and statistical characteristics of each page; Dynamically calculating and applying a wear selection threshold value based on the wear state, and providing a judgment basis for subsequent page selection; Performing basic selection and wear check, preferentially selecting a low wear page according to the writing times, and comparing the low wear page with a threshold value to judge whether to trigger balance adjustment; performing cold and hot data migration to indirectly adjust the free pool distribution; a target physical page meeting wear leveling requirements is determined and returned based on the above steps.
  6. 6. The method of claim 1, wherein the atomically writing the modified data and the updated metadata to the target page and verifying comprises: writing the modified data into the selected target page; based on the written data, assembling and writing the updated metadata, and completing the complete updating of the page; Performing post-write verification to ensure reliability of data persistence; And processing verification failure, and incorporating the defective page into a bad block management system.
  7. 7. The method of claim 1, wherein the implementing transaction commit by atomically updating the address mapping page or lossless undo by discarding the memory map comprises: decision judgment and memory state preparation are carried out; executing key Flash operation or resource release according to the decision; Confirm the final state and post-processing flags.
  8. 8. A Flash transaction mechanism optimization device of an embedded system, the device comprising: The storage structure management module is used for initializing the Flash physical storage space so as to classify pages and define a page tail metadata format; the system initialization and resource management module is used for dynamically initializing when the system is started, scanning and loading key management pages by Flash, and constructing a free page pool in the memory; The transaction processing module is used for receiving the transaction request and finishing data reading and modification in the memory; the wear balancing and page selecting module is used for selecting a target page from the free page pool based on a wear balancing strategy; The writing and verifying module is used for atomically writing the data modified by the transaction processing module and the updated metadata into the target page and executing the verification after writing; and the transaction control module is used for atomically updating the address mapping page to enable new data to be effective when the transaction is submitted, or discarding the mapping change in the memory to realize lossless rollback when the transaction is cancelled.
  9. 9. A storage medium comprising instructions which, when run on a computer, cause the computer to perform the method of any one of claims 1 to 7.
  10. 10. An electronic device, the electronic device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein, The method according to any one of claims 1 to 7 is implemented when the processor executes the program.

Description

Flash transaction mechanism optimization method, device, medium and equipment of embedded system Technical Field The application belongs to the technical field of embedded system storage management, and particularly relates to a Flash transaction mechanism optimization method, device, medium and equipment of an embedded system. Background With the wide application of embedded systems, flash memory has become a mainstream storage medium of embedded devices by virtue of its non-volatility, high density, low power consumption, and the like. Flash memory, however, has inherent characteristics of requiring erasure of a target block prior to writing, limited memory cell erase life (typically 10-100 tens of thousands), operation in units of pages or blocks, and no support for byte level random writing. In transaction processing, a conventional mechanism generally adopts a backup-restore or journaling mode, namely, original data is backed up or operation logs are recorded before a transaction, and backup or merging logs are cleaned after the transaction is submitted. Although the method can ensure the atomicity of the transaction, the method has obvious defects of low performance, uneven wear, advanced aging of a frequently updated area, shortened overall service life of Flash, lack of effective bad block management, influence on the reliability of a system, low space utilization rate and need to reserve a special backup or log area. Therefore, an optimization method capable of improving transaction processing efficiency, prolonging Flash life and enhancing system reliability is needed. Disclosure of Invention Aiming at the defects in the prior art, the application aims to provide a Flash transaction mechanism optimization method, device, medium and equipment of an embedded system, and aims to solve the problems of low performance, uneven wear, lack of bad block management and the like in the prior art so as to realize efficient, reliable and long-service-life Flash transaction processing. In order to achieve the above purpose, the present application provides the following technical solutions: A Flash transaction mechanism optimization method of an embedded system comprises the steps of initializing a Flash physical storage space to classify pages and define page tail metadata formats, dynamically initializing when the system is started, scanning and loading key management pages by Flash, constructing a free page pool in a memory, receiving a transaction request, finishing data reading and modification in the memory, selecting a target page from the free page pool based on a wear balancing strategy, atomically writing data modified by a transaction processing module and updated metadata into the target page, executing verification after writing, atomically updating address mapping pages to enable new data to be effective when the transaction is submitted, or discarding mapping changes in the memory to realize lossless rollback when the transaction is cancelled. Optionally, initializing the Flash physical storage space and constructing page classification and metadata formats, wherein the method comprises the steps of carrying out page division on the Flash storage area and setting an additional data area at the tail of each divided page. Optionally, the system is dynamically initialized when being started, and a key management page is scanned and loaded to construct a free page pool, wherein the method comprises the steps of scanning all pages of Flash, identifying page types, loading the address mapping page and the attribute page of the latest version, establishing a memory mapping table from a logical address to a physical address, constructing the free page pool, eliminating management pages and managing bad blocks. Optionally, the receiving the transaction request and completing data preparation and modification in the memory comprises receiving the transaction request, obtaining a target logical address, querying an address mapping table, locating an original physical page address, reading the original data from Flash into a RAM cache, modifying data content in the RAM cache based on the read original data, and preparing target page information required by writing according to the data and the transaction context which have completed modification. The method comprises the steps of selecting a target page from a free page pool based on a wear balancing strategy, reading and analyzing the wear state of the free page to obtain the writing times and statistical characteristics of each page, dynamically calculating and applying a wear selection threshold based on the wear state to provide a judging basis for subsequent page selection, executing basic selection and wear check, preferentially selecting a low-wear page according to the writing times, comparing the low-wear page with the threshold to judge whether balance adjustment is triggered or not, executing cold and hot data migration to indirectly adjust the d