A method and device for updating data of Flash memory
By updating and writing the free physical pages of the Flash memory in the cache, combined with the sequential update of the address mapping table, the problem of insufficient file data erasing life in the existing technology is solved, and a higher file data erasing life and Storage performance.
Patent Information
- Application Number
- CN202011502128.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-17
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2040-12-17
AI Technical Summary
Due to the limitation of fixed file addresses, the file storage and erasing life of file data is consistent with the life of physical memory, making it difficult to meet the needs of high-life applications.
By updating the file data to be updated in the cache and writing it to the free physical page of the Flash memory, and at the same time sequentially updating the current address mapping table in the cache and writing it to the free physical page, the number of data erasures is reduced. , improve the erasing and writing life of file data.
This method effectively reduces the number of data erasing and writing, improves the erasing and writing life of general file data, and optimizes the system's free space utilization by rolling updates of files within free physical pages, improving the life and performance of the memory.
Smart Images

Figure CN112597072B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method and device for updating data of a Flash memory. Background Art
[0002] Flash memory is a semiconductor storage chip. The data writing method is to erase the data first and then write the data in units of pages. Existing embedded operating systems are generally based on the solution of Flash physical device storage medium. The number of times Flash storage is erased and written is the key performance of its service life. However, the existing Flash file storage method:
[0003] Fixed file storage method, this method uses the file body to be logically mapped to a single physical address. Each update to the file is in the physical storage location. Since the physical storage location of the file is fixed, the fixed file storage solution cannot meet the specific application requirements with high erase and write times. The update life of its stored data is consistent with the extreme erase and write performance of Flash. The basic file mechanism cannot increase the erase and write life of the file.
[0004] Therefore, the problem with accessing the Flash memory is that the fixed file address method makes the storage and erasing life of the file data consistent with the life of the physical memory, which makes it difficult to meet the application requirements of high life. Summary of the invention
[0005] In view of the above analysis, the embodiments of the present invention aim to provide a method and device for updating data of a Flash memory, so as to solve the problem that the storage and erasing of existing file data cannot guarantee the application requirements of a long life.
[0006] On the one hand, an embodiment of the present invention provides a method for updating data of a Flash memory, comprising: determining, according to a file data update request and a current address mapping table, an original logical page corresponding to the file data to be updated and an original physical page mapped by the original logical page, wherein the original physical page includes one or more physical pages; searching for one or more free physical pages in a free physical page table in a circular manner according to the position of the physical page where the current address mapping table is located and using the found free physical pages as data free physical pages, wherein the data free physical pages include one or more first free physical pages having the same number as the number of physical pages in the original physical page; reading the file data to be updated into a cache, updating the file data in the cache, and writing the updated file data into the data free physical page accordingly; and reading the current address mapping table into the cache, updating the current address mapping table in the cache, and writing the updated current address mapping table into a second free physical page.
[0007] The beneficial effects of the above technical solution are as follows: the data update method of the Flash memory provided in this embodiment is based on the address mapping method, the file data to be updated is updated in the cache and the updated file data is written to the free physical page of the Flash memory, the current address mapping table is sequentially updated in the cache, and then the updated current address mapping table is written to the free physical page of the Flash memory, so as to reduce the number of data erases and improve the erase life of general file data. At the same time, since files can be updated in all free physical pages, the free space of the system is effectively utilized to achieve the improvement of life and performance, and the overall storage resource consumption is less.
[0008] Based on a further improvement of the above method, the current address mapping table includes a check code, version information, an address mapping table identifier and multiple mapping table entries, wherein the sequence number of the mapping table entry corresponds to the logical page, and the content in the mapping table entry corresponds to the physical page.
[0009] The beneficial effects of the above technical solution are as follows: the address mapping table includes a check code, version information, an address mapping table identifier and multiple mapping table entries, so that the storage space of the physical page is used to store the mapping table entries to manage more Flash memory space.
[0010] Based on a further improvement of the above method, updating the current address mapping table in the cache further includes: incrementing the version information in the current address mapping table in the cache to update the version information; updating the content of one or more mapping table items in the current address mapping table in the cache; and recalculating the check code in the cache based on the updated version information, the address mapping table identifier and the updated one or more mapping table items, and using the calculated check code to update the check code of the current address mapping table.
[0011] The beneficial effects of the above technical solution are as follows: Verification mechanism based on version information and identification: In order to ensure the system uniqueness of the valid address mapping table, this embodiment ensures the identification and uniqueness check of the system address mapping table through the logical incremental design of "version information" and "address mapping table identification"; and by performing a "verification code" check on all data in the address mapping table, the method has a fault-tolerant mechanism for abnormal power failure.
[0012] Based on a further improvement of the above method, when the original physical page includes a physical page, a mapping table entry in the current address mapping table is updated, including: modifying the mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table by modifying the content in the mapping table entry with the serial number of the original logical page to the address of a physical page in the data free physical page.
[0013] Based on a further improvement of the above method, when the original physical page includes multiple physical pages, multiple mapping table entries in the current address mapping table are updated, including: modifying the mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table by sequentially modifying the contents of multiple mapping table entries with serial numbers as the original logical page to the addresses of multiple physical pages in the data free physical page.
[0014] Based on a further improvement of the above method, the free physical page table is used to manage all physical pages of the Flash memory, wherein the status of the one or more original physical pages is marked as free and the status of the one or more first free physical pages is marked as occupied in the free physical page table.
[0015] The beneficial effects of the above technical solution are as follows: Physical page table usage marking mechanism: In order to ensure the efficient use and update of idle physical pages during the rolling cycle update of all idle physical pages and reduce the erase and write operations of the Flash memory, a physical page table mechanism is provided to record the idle recovery and allocation of physical pages through a "physical page marking table".
[0016] Based on a further improvement of the above method, determining the original logical page corresponding to the file data to be updated and the original physical page mapped by the original logical page according to the file data update request and the current address mapping table further includes: determining the logical address range of the file data to be updated according to the logical address and update data length provided by the file data update request; obtaining the original logical page corresponding to the logical address range based on the logical address range; and determining the original physical page where the file data to be updated is actually stored according to the current address mapping table and the original logical page.
[0017] Based on a further improvement of the above method, reading the current address mapping table into the cache, updating the current address mapping table in the cache, and writing the updated current address mapping table into the second free physical page further includes: according to the position of the physical page where the current address mapping table is located, searching for a free physical page in the free physical page table in a circular manner and using the found free physical page as the second free physical page; reading the current address mapping table to be updated into the cache, and updating the current address mapping table in the cache; writing the updated current address mapping table into the second free physical page; and marking the state of the physical page storing the current address mapping table to be updated as a free state in the free physical page table and marking the state of the second free physical page as an occupied state.
[0018] Based on a further improvement of the above method, according to the position of the physical page where the current address mapping table is located, searching for a free physical page in the free physical page table in a circular manner further includes: starting from the physical page where the current address mapping table is located to a higher address in the free physical page table for the first time: stopping the search until a free physical page is found, and returning a found free physical page; and when no free physical page is found during the first search, starting from the starting physical page in the free physical page table for a second search, stopping the search until a free physical page is found, and returning a found free physical page.
[0019] Based on the further improvement of the above method, according to the position of the physical page storing the current address mapping table, searching for multiple free physical pages in the free physical page table in a circular manner further includes: performing a first search in the free physical page table from the physical page where the current address mapping table is located to a higher address: stopping the search until the multiple free physical pages are found and returning the multiple free physical pages found; and when no free physical pages are found or the number of free physical pages found is insufficient during the first search, starting a second search from the starting physical page in the free physical page table until the multiple free physical pages are found or the sum of the free physical pages found is equal to the number of the multiple free physical pages, stopping the search and returning the multiple free physical pages found.
[0020] Based on a further improvement of the above method, a power-off interruption occurs before the file data to be updated is not successfully updated, after all the file data to be updated is successfully updated, or when the current address mapping table is not completely updated successfully, and after power is restored, the file data is the file data to be updated; and a power-off interruption occurs when all the current address mapping table is successfully updated, and after power is restored, the file data and the current address mapping table are all successfully updated.
[0021] On the other hand, an embodiment of the present invention provides a data update device of a Flash memory, comprising: a logical page and physical page determination module, used to determine, according to a file data update request and a current address mapping table, an original logical page corresponding to the file data to be updated and an original physical page mapped by the original logical page, wherein the original physical page includes one or more physical pages; an idle physical page search module, used to search for one or more idle physical pages in an idle physical page table in a cyclic manner according to the position of the physical page where the current address mapping table is located and use the found idle physical pages as the data idle physical pages, wherein the data idle physical pages include one or more first idle physical pages having the same number as the number of physical pages in the original physical page; a file data update module, used to read the file data to be updated into a cache, update the file data in the cache, and write the updated file data into the data idle physical page accordingly; and an address mapping table update module, used to read the current address mapping table into the cache, update the current address mapping table in the cache, and write the updated current address mapping table into a second idle physical page.
[0022] Based on further improvement of the above device, the current address mapping table includes a check code, version information, an address mapping table identifier and multiple mapping table entries, wherein the sequence number of the mapping table entry corresponds to the logical page, and the content in the mapping table entry corresponds to the physical page.
[0023] Based on further improvements of the above-mentioned device, the address mapping table update module further includes: a version information update submodule, used to increment the version information in the current address mapping table in the cache to update the version information; a mapping table item update submodule, used to update the content of one or more mapping table items in the current address mapping table in the cache; and a check code update submodule, used to recalculate the check code in the cache according to the updated version information, the address mapping table identifier and the updated one or more mapping table items, and use the calculated check code to update the check code of the current address mapping table.
[0024] Based on the further improvement of the above-mentioned device, when the original physical page includes a physical page, the mapping table entry update submodule is used to modify the mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table by modifying the content in the mapping table entry with the serial number of the original logical page to the address of a physical page in the data free physical page.
[0025] Based on the further improvement of the above-mentioned device, when the original physical page includes multiple physical pages, the mapping table entry update submodule is used to modify the mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table by sequentially modifying the contents of multiple mapping table entries with serial numbers as the original logical page to the addresses of multiple physical pages in the data free physical page.
[0026] Based on further improvement of the above-mentioned device, the data update device of the Flash memory also includes a free physical page table setting module, wherein the free physical page table is used to manage all physical pages of the Flash memory; and the free physical page table setting module is used to mark the status of the one or more original physical pages as free status and mark the status of the one or more first free physical pages as occupied status in the free physical page table.
[0027] Based on further improvements of the above-mentioned device, the logical page and physical page determination module is further used for: a logical page determination submodule, used to determine the logical address range of the file data to be updated according to the logical address and update data length provided by the file data update request, and obtain the original logical page corresponding to the logical address range based on the logical address range; and a physical page determination submodule, used to determine the original physical page where the file data to be updated is actually stored according to the current address mapping table and the original logical page.
[0028] Based on the further improvement of the above-mentioned device, the free physical page search module is used to search for a free physical page in the free physical page table in a circular manner according to the position of the physical page where the current address mapping table is located, and use the found free physical page as the second free physical page; the address mapping table update module is used to read the current address mapping table to be updated into the cache, and update the current address mapping table in the cache, and write the updated current address mapping table into the second free physical page; and the free physical page table setting module is used to mark the state of the physical page storing the current address mapping table to be updated as a free state in the free physical page table and mark the state of the second free physical page as an occupied state.
[0029] Based on the further improvement of the above-mentioned device, the free physical page search module is further used to perform a first search in the free physical page table starting from the physical page where the current address mapping table is located to a higher address: stop searching until a free physical page is found, and return a found free physical page; and when no free physical page is found during the first search, perform a secondary search starting from the starting physical page in the free physical page table until a free physical page is found, stop searching, and return a found free physical page.
[0030] Based on the further improvement of the above-mentioned device, the free physical page search module is further used to perform a first search in the free physical page table starting from the physical page where the current address mapping table is located to a higher address: until the multiple free physical pages are found, the search is stopped and the multiple free physical pages found are returned; and when no free physical pages are found or the number of free physical pages found is insufficient during the first search process, a second search is performed starting from the starting physical page in the free physical page table until the multiple free physical pages are found or the sum of the free physical pages found is equal to the number of the multiple free physical pages, the search is stopped and the multiple free physical pages found are returned.
[0031] Based on further improvement of the above device, the data updating device of the Flash memory further includes: an update judgment module, which is used to generate a power-off interruption before the file data to be updated is not successfully updated, after all the file data to be updated is successfully updated, or when the current address mapping table is not completely updated successfully, and after power is restored, the file data is the file data to be updated; and generate a power-off interruption when all the current address mapping table is successfully updated, and after power is restored, the file data and the current address mapping table are all successfully updated.
[0032] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0033] 1. Update the file data to be updated in the cache and write the updated file data to the free physical page of the Flash memory, sequentially update the current address mapping table in the cache, and then write the updated current address mapping table to the free physical page of the Flash memory to reduce the number of data erases and improve the erase life of general file data. At the same time, since files can be updated in all free physical pages in a rolling manner, the free space of the system is effectively utilized to achieve the improvement of life and performance, and the overall storage resource consumption is less.
[0034] 2. Verification mechanism based on version information and identification: To ensure the system uniqueness of the effective address mapping table, this embodiment ensures the identification and uniqueness check of the system address mapping table through the logical increment design of "version information" and "address mapping table identification"; and by performing a "verification code" check on all data in the address mapping table, this method has a fault-tolerant mechanism for abnormal power failure.
[0035] 3. Physical page table usage marking mechanism: To ensure efficient use and update of idle physical pages and reduce the erase and write operations of Flash memory during the rolling cycle update of all idle physical pages, a physical page table mechanism is provided to record the idle recovery and allocation of physical pages through the "physical page marking table".
[0036] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like components throughout the drawings.
[0038] Figure 1 The figure is a flow chart of a method for updating data of a Flash memory according to an embodiment of the present invention.
[0039] Figure 2 The flowchart is a specific example of the method for updating data in the Flash memory.
[0040] Figure 3 A schematic diagram of the storage structure change based on data update of the address mapping table.
[0041] Figure 4 A flowchart for completing the cyclic update of file content and address mapping page itself through the control of address mapping page.
[0042] Figure 5 A schematic diagram of the initial file system data storage structure.
[0043] Figure 6 A schematic diagram of the initial file system data storage structure.
[0044] Figure 7 Diagram of allocating and updating new physical pages for data.
[0045] Figure 8 Schematic diagram of allocating and updating a new physical page for the address mapping table.
[0046] Fig. 9 Schematic diagram of the storage structure completed for the data update process.
[0047] Fig.10 4 is a block diagram of a data updating device for a Flash memory according to an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0049] A specific embodiment of the present invention discloses a method for updating data in a Flash memory. Figure 1 The data updating method of the Flash memory includes: step S102, determining the original logical page corresponding to the file data to be updated and the original physical page mapped by the original logical page according to the file data update request and the current address mapping table, wherein the original physical page includes one or more physical pages; step S104, searching for one or more free physical pages in a free physical page table in a circular manner according to the position of the physical page where the current address mapping table is located and using the found free physical pages as data free physical pages, wherein the data free physical pages include one or more first free physical pages having the same number of physical pages in the original physical page; step S106, reading the file data to be updated into the cache, updating the file data in the cache, and writing the updated file data into the data free physical page accordingly; and step S108, reading the current address mapping table into the cache, updating the current address mapping table in the cache, and writing the updated current address mapping table into the second free physical page.
[0050] Compared with the prior art, the data update method of the Flash memory provided in this embodiment is based on an address mapping method, which updates the file data to be updated in the cache and writes the updated file data into the free physical pages of the Flash memory, sequentially updates the current address mapping table in the cache, and then writes the updated current address mapping table into the free physical pages of the Flash memory, so as to reduce the number of data erases and improve the erase life of general file data. At the same time, since files can be updated in a rolling manner within all free physical pages, the free space of the system is effectively utilized to achieve improved life and performance, and the overall storage resource consumption is less.
[0051] The data update method of the Flash memory adopts a rolling cycle update, wherein the rolling cycle update is to update the physical page of the data storage, adopt a non-fixed physical address storage method, and cyclically update and write to the new physical page in a fixed order. Figure 1 , step S102, step S104, step S106 and step S108 of the data updating method of the Flash memory are described in detail.
[0052] Step S102, according to the file data update request and the current address mapping table, determine the original logical page corresponding to the file data to be updated and the original physical page mapped by the original logical page, wherein the original physical page includes one or more physical pages. Address mapping is an indirect data access method that converts a logical address into a physical address through an address mapping mechanism. The address mapping table is a system data structure for storing logical address and physical address conversion information and related management information of the address mapping mechanism. The current address mapping table includes a checksum, version information, an address mapping table identifier, and a plurality of mapping table entries, wherein the sequence number of the mapping table entry corresponds to the logical page, and the content in the mapping table entry corresponds to the physical page. Specifically, according to the file data update request and the current address mapping table, determining the original logical page corresponding to the file data to be updated and the original physical page mapped by the original logical page further includes: determining the logical address range of the file data to be updated according to the logical address and the update data length provided by the file data update request; obtaining the original logical page corresponding to the logical address range based on the logical address range; and determining the original physical page where the file data to be updated is actually stored according to the current address mapping table and the original logical page.
[0053] Compared with the prior art, the verification mechanism is based on version information and identification: to ensure the system uniqueness of the valid address mapping table, this embodiment ensures the identification and uniqueness check of the system address mapping table through the logical incremental design of "version information" and "address mapping table identification"; and by performing a "verification code" check on all data in the address mapping table, the method has a fault-tolerant mechanism for abnormal power failure.
[0054] Step S104, according to the position of the physical page where the current address mapping table is located, one or more free physical pages are searched in a loop in the free physical page table and the found free physical pages are used as data free physical pages, wherein the data free physical pages include one or more first free physical pages with the same number of physical pages as the original physical page. The free physical page table is used to manage all physical pages of the Flash memory. In one embodiment, according to the position of the physical page where the current address mapping table is located, searching for a free physical page in the free physical page table in a loop further includes: searching for the first time in the free physical page table from the physical page where the current address mapping table is located to a higher address: stopping the search until a free physical page is found, and returning a found free physical page; and when no free physical page is found in the first search process, performing a second search from the starting physical page in the free physical page table until a free physical page is found, stopping the search, and returning a found free physical page. In another embodiment, based on the location of the physical page storing the current address mapping table, searching for multiple free physical pages in the free physical page table in a circular manner further includes: performing a first search in the free physical page table starting from the physical page where the current address mapping table is located toward a higher address: stopping the search until multiple free physical pages are found and returning the multiple free physical pages found; and when no free physical pages are found during the first search or the number of free physical pages found is insufficient, performing a second search starting from the starting physical page in the free physical page table until multiple free physical pages are found or the sum of the free physical pages found is equal to the number of multiple free physical pages, then stopping the search and returning the multiple free physical pages found.
[0055] Compared with the prior art, in the data update method of the Flash memory provided in this embodiment, the physical page table usage marking mechanism is provided: in order to ensure the efficient use and update of the idle physical pages during the rolling cycle update of all idle physical pages, and reduce the erase and write operations of the Flash memory, a physical page table mechanism is provided, and the idle recovery and allocation of the physical pages are recorded through the "physical page marking table".
[0056] Step S106, read the file data to be updated into the cache, update the file data in the cache, and write the updated file data into the data free physical page accordingly. In the free physical page table, mark the status of one or more original physical pages (i.e., the original physical pages storing the file data to be updated) as free, i.e., set to "0", and mark the status of one or more first free physical pages (i.e., the data free physical pages storing the updated file data) as occupied, i.e., set to "1".
[0057] Step S108, read the current address mapping table into the cache, update the current address mapping table in the cache, and write the updated current address mapping table into the second free physical page. Specifically, reading the current address mapping table into the cache, updating the current address mapping table in the cache, and writing the updated current address mapping table into the second free physical page further includes: according to the position of the physical page where the current address mapping table is located, searching for a free physical page in the free physical page table in a circular manner and using the found free physical page as the second free physical page; reading the current address mapping table to be updated into the cache, and updating the current address mapping table in the cache; writing the updated current address mapping table into the second free physical page; and marking the state of the physical page storing the current address mapping table to be updated as free in the free physical page table and marking the state of the second free physical page as occupied. Specifically, according to the position of the physical page where the current address mapping table is located, searching for an idle physical page in the idle physical page table in a circular manner further includes: searching for the first time from the physical page where the current address mapping table is located to a higher address in the idle physical page table: stopping the search until a idle physical page is found, and returning a found idle physical page; and when no idle physical page is found during the first search, performing a secondary search from the starting physical page in the idle physical page table until a idle physical page is found, stopping the search, and returning a found idle physical page. In an optional embodiment, the extended address mapping table can be stored on two physical pages. The current address mapping table includes a check code, a version information, an address mapping table identifier, and a plurality of mapping table entries, wherein the plurality of mapping table entries are stored on two physical pages. In this way, the extended address mapping table can search for two idle physical pages by the following method. Specifically, according to the location of the physical page storing the current address mapping table, searching for two free physical pages in the free physical page table in a circular manner further includes: performing a first search in the free physical page table from the physical page where the current address mapping table is located to a higher address: stopping the search until two free physical pages are found and returning the two free physical pages found; and when no free physical pages are found in the first search process or the number of free physical pages found is insufficient (i.e., only one free physical page is found), performing a second search starting from the starting physical page in the free physical page table until two free physical pages are found or the sum of the free physical pages found is two free physical pages, stopping the search and returning the multiple free physical pages found.
[0058] Hereinafter, updating the current address mapping table in the cache is described in detail.
[0059] Updating the current address mapping table in the cache further includes: incrementing the version information in the current address mapping table in the cache to update the version information; updating the content in one or more mapping table items in the current address mapping table in the cache; and recalculating the check code in the cache according to the updated version information, the address mapping table identifier and the updated one or more mapping table items, and updating the check code of the current address mapping table using the calculated check code. In one embodiment, when the original physical page includes one physical page, updating a mapping table item in the current address mapping table includes: modifying the mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table by modifying the content in the mapping table item with the sequence number of the original logical page to the address of a physical page in the data free physical page. In another embodiment, when the original physical page includes multiple physical pages, updating multiple mapping table items in the current address mapping table includes: modifying the mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table by sequentially modifying the content in the multiple mapping table items with the sequence number of the original logical page to the addresses of multiple physical pages in the data free physical page.
[0060] In addition, a power-off interruption occurs before the file data to be updated is not successfully updated, after all the file data to be updated is successfully updated, or when the current address mapping table is not fully updated successfully, and after power is restored, the file data is the file data to be updated; and a power-off interruption occurs when all the current address mapping table is successfully updated, and after power is restored, the file data and the current address mapping table are all successfully updated.
[0061] The embodiment of the present invention provides a new general dynamic file storage mechanism, which is based on an address mapping method to improve the general data erase and write life. The method designs a configurable address mapping page according to the size of the file system space managed, and innovatively introduces a free physical page table, which effectively improves the access performance of general data including the file system on the Flash memory. Figures 2 to 9 , the data updating method of the Flash memory is described in detail by means of a specific example.
[0062] Basic design scheme: To simplify the scheme description, the present invention first sets the address mapping table size to be stored in one physical page.
[0063] 1. The address mapping table mainly includes key data items such as the data check code of the entire mapping table, the mapping table version, the address mapping table identification information, and the mapping address table items. Among them:
[0064] The data check code is calculated from the mapping table version, the address mapping table identification information, and the entire data of the mapping address table entry content; the data check code serves as a basis for determining the validity of the address mapping table.
[0065] The mapping table version can define the version change rules after each mapping table update according to the actual design needs. This method judges and determines that the address mapping table is the most recently updated valid mapping table according to the mapping table version.
[0066] Table 2-1 Address mapping table structure
[0067] Data item length content L1 Check code L2 Version Information L3 Address mapping table identifier: L_i Mapping table entry 1 ... ... L_i Mapping table entry N-1 L_i Mapping table entry N
[0068] Note 1: The sequence numbers of the mapping table entries in the address mapping table in Table 2-1 are expressed as storage logical page numbers. The storage content of each mapping table entry is the physical page number. Through this correspondence, the association between the logical page and the physical page is identified, thereby realizing the mapping of the logical address space to the physical address space.
[0069] During the data update process, by modifying the content (physical page) in the mapping table entry (the serial number is the logical page), the dynamic mapping of the storage page from the logical address space to the physical address space is completed.
[0070] Table 2-2 Physical page mark table structure
[0071] F_1 F_2 F_3 … F_M-1 F_M
[0072] Note 2: Table 2-2 Physical Page Mark Table records the mapping status of all physical pages in the storage space. If the total number of all physical pages is M, the members of the physical page table are (F_1--F_M), with M items. The content of this table changes according to the mapping status of the address mapping table: if a physical page is not mapped in the address mapping table, the physical page is marked as 0 in the physical page table, indicating that the page is in an idle state; if a physical page is mapped in the address mapping table, the physical page is marked as 1 in the physical page table, indicating that the page is in an occupied state;
[0073] 2. Reference Figure 2 According to the logical address and update data length provided by the file data update request, the method determines the physical page corresponding to the logical address according to the mapping address table entry information of the address mapping table; Figure 2 Step 1.
[0074] The main steps include:
[0075] First, according to the logical address and update data length provided by the file data update request, the logical address range of the operated data is determined, and based on the logical address range, the logical page corresponding to the address range can be obtained.
[0076] A mapping address table is designed, and the content stored in the table entry is the physical page stored by the logical page number. From this mapping relationship, the physical page where the updated data is actually stored can be obtained.
[0077] Note: The logical address space is indicated in the address mapping table by mapping table entries with sequential table entry numbers. The size of the space range indicated by each table entry is a FLASH page, for example, 512 bytes.
[0078] 3. According to the logical page C1 where the file data to be updated is located and the currently mapped physical page P1 position determined in step 1, according to the logical order of rolling update, find the next free physical page where the updated file needs to be written and updated;
[0079] The main steps include: based on the physical page PA where the current address mapping page is located, querying the address of the next idle physical page, and recording the queried new physical page as the physical page P1'.
[0080] 4. Step 3, read the content of the physical page P1 where the current file data is located into the cache, update the corresponding data to the new data, and then write the updated cache page content into the newly queried physical page P1'. After the update is completed, the physical page number P1 of the original data mapping is marked as free in the free physical page table, and the content of the logical page C1 of the address mapping table in the cache is modified to P1' (reference Figure 2 Step 3).
[0081] 5. Increment the version number of the address mapping table in the current cached address mapping table, and find the new free physical page PA' according to rule 1: free physical page search rule, modify the physical page number corresponding to the address mapping page in the current cached address mapping table to PA', recalculate the check code of the address mapping table after the data is updated, and update it in the cached address mapping table. Write the updated address mapping table to the new physical page PA' (refer to Figure 2 Step 4).
[0082] The above schematic diagram describing steps 1 to 4 of the invention solution is shown in FIG. Figure 3 .
[0083] Rule 1: Free physical page search rule:
[0084] Taking the physical page PA where the current address mapping page is located as the benchmark, in a one-way sequential search direction (for example: towards the higher address), in the "physical page mark table", check in turn whether the physical page number is free. If it is free, return the free physical page. If it is not free, continue searching until the entire physical address space is searched.
[0085] Processing mechanism for abnormal power failure interruption:
[0086] Step 1 of the method: only read the Flash data, check the validity of the version information and the address mapping table identifier according to the verification data of the address mapping page, and abnormal interruption or power failure will not cause system abnormality.
[0087] Step 2, the processed free physical page allocation is checked and flags are set through the free page table in RAM, and abnormal interruption or power failure will not cause system abnormality.
[0088] Therefore, the update of the new physical page in step 3 and step 4 may cause abnormal power failure. Therefore, this method checks and handles it according to the following mechanism:
[0089] Case 1: In step 3, the data of physical page P1' is not updated successfully and a power failure interrupt occurs;
[0090] In this case, since the address mapping page is not modified, the data mapping relationship is still the mapping between the logical page C1 and the physical page P1. Therefore, after power is turned on again, the file data is the original data content and is not modified.
[0091] Case 2: A power failure interruption occurs after all the data on the physical page P1' is successfully updated in step 3;
[0092] In this case, since the address mapping page is not modified, the data mapping relationship is still the mapping between the logical page C1 and the physical page P1. Therefore, after power is turned on again, the file data is the original data content, and the successfully updated physical page P1' completes the mapping with the logical page C1, and the modification is invalid.
[0093] Case 3: A power failure interrupt occurs when the data of the physical page PA' is not completely updated successfully in step 4;
[0094] In this case, the update of the address mapping table in the new physical page PA' is not completely successful. After power is restarted, according to Rule 2: Judgment and search rules of the valid address mapping table, PA' is judged to be an invalid address mapping page, and the address mapping table is still the original physical address PA. Therefore, the physical page mapped by the logical page C1 is still P1, and the result is that the file data content remains the original content.
[0095] Case 4: A power failure interrupt occurs when all data on the physical page PA' is successfully updated in step 4;
[0096] In this case, all updates of the address mapping table in the new physical page PA' are successfully updated. After power is restored, according to Rule 2: Judgment and search rules of the effective address mapping table, PA' is judged to be a valid address mapping page, and the address mapping table has been updated to the physical page PA'. Therefore, the physical page mapped by the logical page C1 is also updated to P1'. As a result, the file data content is the content updated before power failure, and the data update is successful.
[0097] In summary, the data structure and data access check mechanism designed in the present invention can ensure that the address mapping relationship of valid data will not be destroyed under abnormal circumstances, thereby ensuring the transaction consistency of the file system data content.
[0098] The address mapping mechanism of the present invention needs to retrieve all physical pages managed by the system when the system is started to determine the current latest valid address mapping table. The processing and judgment mechanism is defined as Rule 2:
[0099] Rule 2: Judgment and search rules for the effective address mapping table:
[0100] Retrieve all physical pages in the physical space. If a physical page containing an "address mapping table identifier" and the "check value" of the physical page is consistent with the calculation results of all other data in the address mapping table, then the physical page is recorded as the address mapping table to be selected. Among all the address mapping tables obtained, select the one with the largest "version information". The address mapping table with the largest "version information" is the "effective address mapping table".
[0101] Rule 3: "Physical Page Mark Table" generation rules based on the effective address mapping table:
[0102] Check all mapping table entries in the effective address mapping table. The non-empty value of the mapping table entry content is the used physical page number. The physical page table composed of all physical pages in the physical storage space except the physical page numbers that have been mapped in the address mapping table is the free physical page table. The occupancy and free status of each physical page are set accordingly in the "physical page mark table".
[0103] Note: The null value of the physical page number in the address mapping table can be represented by a value that is not in the valid physical page number range, such as -1.
[0104] Figure 3 A data storage update logic diagram based on an address mapping table is shown to illustrate the data update storage structure changes.
[0105] The invention provides a method for supporting dynamic mapping updates of data stored in multiple physical pages:
[0106] The data operation process for multiple physical pages is generally the same as the method steps for a single physical page. Only in the above steps 2 and 3, the corresponding new free physical pages are allocated to the updated multiple logical pages respectively, and the data updates of the multiple new physical pages are performed in sequence. After all data physical pages are updated and written, the update and writing of the address mapping page is performed in step 4:
[0107] Method steps:
[0108] 1. According to the data update request, the method determines the mapped multiple physical pages (P1, P2, ..., PN) from the address mapping table according to the logical address range of the data (including logical pages C1, C2, ..., CN) (refer to Figure 2 Step 1).
[0109] 2. According to the physical page determined in step 1, according to the logical order of rolling update, a new free physical page P1' is allocated to each physical page, such as physical page P1 (refer to Figure 2 Step 2).
[0110] 3. Read the data content of the physical page P1 currently mapped by the data into the cache, update the corresponding data to the new data, and update the new data in the cache to the new free physical page P1'. After the update is completed, mark the physical page number P1 originally mapped by the data as free in the free physical page table, and modify the content of the logical page C1 of the address mapping table in the cache to P1' (refer to Figure 2 Step 3).
[0111] 4. According to the remaining multiple physical pages (P2, ..., PN) determined in step 1, step 2 and step 3 are respectively executed in sequence to complete the update of all newly allocated physical pages (P2', ..., PN') and the modification of the cache address mapping;
[0112] 5. Finally, execute step 4 of the technical solution to complete the update and writing of the address mapping table.
[0113] Description of the abnormal situation of the solution, for the abnormal interruption of rolling write on multiple data physical pages:
[0114] (1) The update and write of the physical page of the data is abnormally interrupted. Regardless of whether multiple physical pages are written successfully, since the address mapping page is not actually updated, after power-on reset, according to Rule 2: Retrieval of the address mapping table, the effective address mapping table has not changed, the file data content is still the original data, and the data is restored normally.
[0115] (2) Abnormal interruptions in other situations are the same as the abnormal handling and recovery process of the “processing mechanism for abnormal power-off interruptions” in the aforementioned technical solution.
[0116] Specific examples of the technical solution of the present invention
[0117] Example 1 can overcome the disadvantages of the prior art or solve the technical problems to be solved. To implement the method of the present invention, Example 1 shows an address mapping method and a rolling storage mechanism in implementing the reference data structure and process of the present invention.
[0118] refer to Figure 4, Example 1 supports a data update process method for updating data within a physical page. The data content can complete the cyclic update of the file content and the address mapping page itself through the control of the address mapping page. The example shows that this step can realize the dynamic mapping of data from logical address to physical address, and use the effective free physical pages of the FLASH storage space to realize rolling update, which effectively improves the wear resistance of general data storage; and compared with the existing scheme, it significantly reduces the erase and write operation steps of the FLASH memory, and has obvious improvements in the data storage operation speed performance. Figure 4 The feasibility of this method is demonstrated with a simple logical structure.
[0119] For example, taking the physical page size as 512 bytes, the following table is the reference data structure of the address mapping table:
[0120] Table 3: Address mapping table reference data structure
[0121] Data item length (byte) content 2 Checksum 2 Version Information 4 Address mapping table identifier: 2 Mapping table entry 1 ... ... 2 Mapping table entry N-1 2 Mapping table entry N
[0122] Based on the dynamic address mapping file system, refer to the logical structure: In order to simplify the description of the method in the application example, the address mapping table of the following example file system is designed to be stored in one physical page.
[0123] Combination Figures 4 to 9 , describe the specific implementation of Example 1 according to the direction of data flow:
[0124] 1. The storage structure of the file system based on the address mapping table in the FLASH storage space. The system consists of a unique valid address mapping table, mapped physical address pages, and free physical pages not mapped in the address mapping table to form the entire physical storage space (refer to Figure 5 ).
[0125] 2. Based on the current effective address mapping table, according to the logical address range provided by the data update request, the logical address page where the updated data is located is mapped to a physical page to obtain the information data page (old) (reference Figure 6 ).
[0126] 3. Based on the current effective address mapping table physical page location, allocate the information data page (new) from the free physical page table for data update.
[0127] The original physical page - information data page (old) content is read out to the cache, and the cached content to be updated is modified to the updated data. The updated cached data is written to the new physical page - information data page (new), and the mapping relationship is modified to the mapping of the logical address and the new physical page (reference Figure 7 ).
[0128] 4. Allocate a new free physical page for the update write of the address mapping table, set the mapping relationship between the address mapping table itself and the new physical page, logically increment the version information and recalculate the checksum, write the newly allocated physical page - address mapping table (new) (reference Figure 8 ).
[0129] 5. After the address mapping table (new) is updated, the data storage logic structure of the storage space is updated (refer to Fig. 9 ).
[0130] According to the implementation method of this example, a general dynamic address mapping file system can be implemented, and the mapped data can use the logic cycle update mechanism of the free physical blocks to achieve balanced wear of all data in the logical address.
[0131] Combined with the specific implementation of Example 1 above, the beneficial effects that can be produced compared with the existing technology are described:
[0132] 1. The present invention adopts a dynamic address mapping method, which can significantly improve the memory life of data update in the entire storage space; the logical address space range managed by the address mapping table can be flexibly configured through the number of table entries.
[0133] 2. Based on the structural design of the address mapping table and the rolling update mechanism with physical pages as the update unit, combined with the data verification mechanism, the abnormal capacitance error detection capability is stronger.
[0134] 3. The address mapping table design of the present invention has a simple data structure and is combined with a "physical page tag table" mechanism, so that the allocation and recovery of physical pages are modified through RAM cache table records, which effectively reduces the modification of FLASH data, has a wide range of applicability to different FLASH memory types, and significantly improves memory access performance.
[0135] 4. The address mapping table design of the present invention does not limit the size of the address mapping table and the managed logical address space. For application systems that require multiple physical pages to store the address mapping table, it can be expanded by uniformly managing and verifying the multiple physical pages used by the address mapping table.
[0136] Another specific embodiment of the present invention discloses a data updating device for a Flash memory. Fig.10 , a data updating device for Flash memory is described in detail. The data updating device for Flash memory includes: a logical page and physical page determining module 1002, a free physical page searching module 1004, a file data updating module 1006 and an address mapping table updating module 1008.
[0137] The logical page and physical page determination module 1002 is used to determine the original logical page corresponding to the file data to be updated and the original physical page mapped by the original logical page according to the file data update request and the current address mapping table, wherein the original physical page includes one or more physical pages. The current address mapping table includes a check code, version information, an address mapping table identifier and multiple mapping table entries, wherein the sequence number of the mapping table entry corresponds to the logical page, and the content in the mapping table entry corresponds to the physical page. The logical page and physical page determination module 1002 further includes: a logical page determination submodule, which is used to determine the logical address range of the file data to be updated according to the logical address and update data length provided by the file data update request, and obtain the original logical page corresponding to the logical address range based on the logical address range; and a physical page determination submodule, which is used to determine the original physical page where the file data to be updated is actually stored according to the current address mapping table and the original logical page.
[0138] The free physical page search module 1004 is used to search for one or more free physical pages in the free physical page table in a circular manner according to the position of the physical page where the current address mapping table is located, and use the found free physical pages as data free physical pages, wherein the data free physical pages include one or more first free physical pages with the same number as the physical pages in the original physical page. In one embodiment, the free physical page search module is further used to search the free physical page table from the physical page where the current address mapping table is located to a higher address for the first time: stop searching until a free physical page is found, and return a found free physical page; and when no free physical page is found during the first search, start a second search from the starting physical page in the free physical page table, stop searching until a free physical page is found, and return a found free physical page. In another embodiment, the free physical page search module is further used to perform a first search in the free physical page table starting from the physical page where the current address mapping table is located toward a higher address: until multiple free physical pages are found, the search is stopped and the multiple free physical pages found are returned; and when no free physical pages are found during the first search or the number of free physical pages found is insufficient, a second search is performed starting from the starting physical page in the free physical page table until multiple free physical pages are found or the sum of the free physical pages found is equal to the number of free physical pages, the search is stopped and the multiple free physical pages found are returned.
[0139] The file data update module 1006 is used to read the file data to be updated into the cache, update the file data in the cache, and write the updated file data into the data free physical page accordingly. The free physical page table is used to manage all physical pages of the Flash memory; and the free physical page table setting module is used to mark the status of one or more original physical pages as free and mark the status of one or more first free physical pages as occupied in the free physical page table.
[0140] The address mapping table update module 1008 is used to read the current address mapping table into the cache, update the current address mapping table in the cache, and write the updated current address mapping table into the second free physical page. The address mapping table update module 1008 further includes: a version information update submodule, used to increment the version information in the current address mapping table in the cache to update the version information; a mapping table item update submodule, used to update the content in one or more mapping table items in the current address mapping table in the cache; and a check code update submodule, used to recalculate the check code in the cache according to the updated version information, the address mapping table identifier and the updated one or more mapping table items, and update the check code of the current address mapping table using the calculated check code. In one embodiment, when the original physical page includes one physical page, the mapping table item update submodule is used to modify the mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table by modifying the content in the mapping table item with the sequence number of the original logical page to the address of a physical page in the data free physical page. In another embodiment, when the original physical page includes multiple physical pages, the mapping table entry update submodule is used to modify the mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table by sequentially modifying the contents in multiple mapping table entries with serial numbers of the original logical page to the addresses of multiple physical pages in the data free physical page. The free physical page search module 1004 is used to search for a free physical page in the free physical page table in a circular manner according to the position of the physical page where the current address mapping table is located and use the found free physical page as the second free physical page. The address mapping table update module is used to read the current address mapping table to be updated into the cache, update the current address mapping table in the cache, and write the updated current address mapping table into the second free physical page. The free physical page table setting module is used to mark the state of the physical page storing the current address mapping table to be updated as the free state in the free physical page table and mark the state of the second free physical page as the occupied state.
[0141] The data updating device of the Flash memory further includes: an update judgment module, which is used to generate a power-off interrupt before the file data to be updated is not updated successfully, after all the file data to be updated is updated successfully, or when the current address mapping table is not updated successfully, and after power is restored, the file data is the file data to be updated; and generate a power-off interrupt when the current address mapping table is updated successfully, and after power is restored, the file data and the current address mapping table are all updated successfully.
[0142] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0143] 1. Update the file data to be updated in the cache and write the updated file data to the free physical page of the Flash memory, sequentially update the current address mapping table in the cache, and then write the updated current address mapping table to the free physical page of the Flash memory to reduce the number of data erases and improve the erase life of general file data. At the same time, since files can be updated in all free physical pages in a rolling manner, the free space of the system is effectively utilized to achieve the improvement of life and performance, and the overall storage resource consumption is less.
[0144] 2. Verification mechanism based on version information and identification: To ensure the system uniqueness of the effective address mapping table, this embodiment ensures the identification and uniqueness check of the system address mapping table through the logical increment design of "version information" and "address mapping table identification"; and by performing a "verification code" check on all data in the address mapping table, this method has a fault-tolerant mechanism for abnormal power failure.
[0145] 3. Physical page table usage marking mechanism: To ensure efficient use and update of idle physical pages and reduce the erase and write operations of Flash memory during the rolling cycle update of all idle physical pages, a physical page table mechanism is provided to record the idle recovery and allocation of physical pages through the "physical page marking table".
[0146] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0147] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A method for updating data in a Flash memory, characterized in that: include: Determine, according to the file data update request and the current address mapping table, an original logical page corresponding to the file data to be updated and an original physical page mapped by the original logical page, wherein the original physical page includes one or more physical pages; According to the position of the physical page where the current address mapping table is located, searching one or more free physical pages in a free physical page table in a circular manner and using the found free physical pages as data free physical pages, wherein the data free physical pages include one or more first free physical pages whose number is the same as that of the physical pages in the original physical page; Reading the file data to be updated into a cache, updating the file data in the cache, and writing the updated file data into the free physical page of data accordingly; and The current address mapping table is read into the cache, the current address mapping table is updated in the cache, and the updated current address mapping table is written into the second free physical page, wherein the current address mapping table is read into the cache, the current address mapping table is updated in the cache, and the updated current address mapping table is written into the second free physical page further comprises: according to the position of the physical page where the current address mapping table is located, a free physical page is searched in a free physical page table in a circular manner and the found free physical page is used as the second free physical page; the current address mapping table to be updated is read out to the cache, and the current address mapping table in the cache is updated; the updated current address mapping table is written into the second free physical page; and the state of the physical page storing the current address mapping table to be updated is marked as free state in the free physical page table and the state of the second free physical page is marked as occupied state; The free physical page table is a physical page table composed of the remaining physical page numbers in all physical pages of the Flash memory except the physical page numbers that have been mapped and used in the address mapping table, and the free recovery and allocation of physical pages are recorded through the physical page marking table, wherein the status of one or more original physical pages storing the file data to be updated is marked as free in the free physical page table, and the status of the one or more first free physical pages storing the updated file data is marked as occupied; Wherein, according to the position of the physical page where the current address mapping table is located, searching for a free physical page in the free physical page table in a circular manner further comprises: searching for a first time in the free physical page table from the physical page where the current address mapping table is located to a higher address; stopping the search until a free physical page is found, and returning a found free physical page; and when no free physical page is found in the first search process, starting a second search from the starting physical page in the free physical page table, stopping the search until a free physical page is found, and returning a found free physical page; Among them, according to the position of the physical page storing the current address mapping table, searching for multiple free physical pages in the free physical page table in a circular manner further includes: performing a first search in the free physical page table from the physical page where the current address mapping table is located to a higher address; stopping the search until the multiple free physical pages are found and returning the multiple free physical pages found; and when no free physical pages are found in the first search process or the number of free physical pages found is insufficient, starting a second search from the starting physical page in the free physical page table until the multiple free physical pages are found or the sum of the free physical pages found is equal to the number of the multiple free physical pages, stopping the search and returning the multiple free physical pages found.
2. The method for updating data of a Flash memory according to claim 1, characterized in that: The current address mapping table includes a check code, version information, an address mapping table identifier, and a plurality of mapping table entries, wherein the sequence number of the mapping table entry corresponds to a logical page, and the content in the mapping table entry corresponds to the physical page.
3. The method for updating data of a Flash memory according to claim 2, characterized in that: Updating the current address mapping table in the cache further includes: Incrementing the version information in the current address mapping table in the cache to update the version information; updating, in the cache, the contents of one or more mapping table entries in the current address mapping table; and The check code is recalculated in the cache according to the updated version information, the address mapping table identifier and the updated one or more mapping table entries, and the check code of the current address mapping table is updated using the calculated check code.
4. The method for updating data of a Flash memory according to claim 3, characterized in that: When the original physical page includes a physical page, updating a mapping table entry in the current address mapping table includes: The mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table is modified by modifying the content in the mapping table entry with the serial number of the original logical page to the address of a physical page in the data free physical page.
5. The method for updating data of a Flash memory according to claim 3, characterized in that: When the original physical page includes multiple physical pages, updating multiple mapping table entries in the current address mapping table includes: The mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table is modified by sequentially modifying the contents of multiple mapping table entries with serial numbers of the original logical page to addresses of multiple physical pages in the data free physical page.
6. The method for updating data of a Flash memory according to claim 1, characterized in that: Determining, according to the file data update request and the current address mapping table, an original logical page corresponding to the file data to be updated and an original physical page mapped by the original logical page further comprises: Determine the logical address range of the file data to be updated according to the logical address and update data length provided by the file data update request; Based on the logical address range, obtaining an original logical page corresponding to the logical address range; and The original physical page where the file data to be updated is actually stored is determined according to the current address mapping table and the original logical page.
7. The method for updating data of a Flash memory according to claim 1, characterized in that: Before the file data to be updated is not updated successfully, after all the file data to be updated is updated successfully, or when the current address mapping table is not updated successfully, a power failure interruption occurs, and after power is restored, the file data is the file data to be updated; as well as When the current address mapping table is completely updated successfully, a power-off interruption occurs, and after power is restored, the file data and the current address mapping table are completely updated successfully.
8. A data updating device for a Flash memory, characterized in that: include: A logical page and physical page determination module, used to determine an original logical page corresponding to the file data to be updated and an original physical page mapped by the original logical page according to a file data update request and a current address mapping table, wherein the original physical page includes one or more physical pages; an idle physical page search module, configured to search for one or more idle physical pages in an idle physical page table in a circular manner according to the position of the physical page where the current address mapping table is located, and use the found idle physical pages as data idle physical pages, wherein the data idle physical pages include one or more first idle physical pages having the same number as the physical pages in the original physical page; a file data updating module, configured to read the file data to be updated into a cache, update the file data in the cache, and write the updated file data into the free physical page of the data accordingly; and an address mapping table updating module, used for reading the current address mapping table into the cache, updating the current address mapping table in the cache, and writing the updated current address mapping table into the second free physical page, wherein the free physical page searching module is used for searching for a free physical page in a free physical page table in a circular manner according to the position of the physical page where the current address mapping table is located, and using the found free physical page as the second free physical page; the address mapping table updating module is used for reading the current address mapping table to be updated into the cache, updating the current address mapping table in the cache, and writing the updated current address mapping table into the second free physical page; and the free physical page table setting module is used for marking the state of the physical page storing the current address mapping table to be updated as free state in the free physical page table and marking the state of the second free physical page as occupied state; An idle physical page table setting module is used to mark the status of one or more original physical pages storing the file data to be updated as idle status in the idle physical page table and mark the status of one or more first idle physical pages storing the updated file data as occupied status, wherein the idle physical page table is a physical page table composed of the remaining physical page numbers of all physical pages of the Flash memory except the physical page numbers mapped and used in the address mapping table, and the idle recovery and allocation of physical pages are recorded through the physical page marking table; The free physical page search module is further used to search the free physical page table from the physical page where the current address mapping table is located to a higher address for the first time; stop searching until a free physical page is found, and return the found free physical page; and when no free physical page is found during the first search, start a second search from the starting physical page in the free physical page table, stop searching until a free physical page is found, and return the found free physical page; Among them, the free physical page search module is further used to perform a first search in the free physical page table starting from the physical page where the current address mapping table is located to a higher address; stop searching until the multiple free physical pages are found and return the multiple free physical pages found; and when no free physical pages are found or the number of free physical pages found is insufficient during the first search process, start a second search from the starting physical page in the free physical page table until the multiple free physical pages are found or the sum of the free physical pages found is equal to the number of the multiple free physical pages, stop searching and return the multiple free physical pages found.
9. The data updating device of the Flash memory according to claim 8, characterized in that: The current address mapping table includes a check code, version information, an address mapping table identifier, and a plurality of mapping table entries, wherein the sequence number of the mapping table entry corresponds to a logical page, and the content in the mapping table entry corresponds to the physical page.
10. The data updating device of the Flash memory according to claim 9, characterized in that: The address mapping table updating module further comprises: A version information updating submodule, used for incrementing the version information in the current address mapping table in the cache to update the version information; a mapping table entry updating submodule, configured to update, in the cache, the contents of one or more mapping table entries in the current address mapping table; and The check code update submodule is used to recalculate the check code in the cache according to the updated version information, the address mapping table identifier and the updated one or more mapping table entries, and update the check code of the current address mapping table using the calculated check code.
11. The data updating device of the Flash memory according to claim 10, characterized in that: When the original physical page includes one physical page, the mapping table entry updating submodule is used for: The mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table is modified by modifying the content in the mapping table entry with the serial number of the original logical page to the address of a physical page in the data free physical page.
12. The data updating device of the Flash memory according to claim 10, characterized in that: When the original physical page includes multiple physical pages, the mapping table entry updating submodule is used to: The mapping relationship between the original logical page and the original physical page of the original file data in the current address mapping table is modified by sequentially modifying the contents of multiple mapping table entries with serial numbers of the original logical page to addresses of multiple physical pages in the data free physical page.
13. The data updating device of the Flash memory according to claim 8, characterized in that: The logical page and physical page determination module is further used for: A logical page determination submodule, configured to determine a logical address range of the file data to be updated according to a logical address and an update data length provided by the file data update request, and obtain an original logical page corresponding to the logical address range based on the logical address range; as well as The physical page determination submodule is used to determine the original physical page where the file data to be updated is actually stored according to the current address mapping table and the original logical page.
14. The data updating device of the Flash memory according to claim 8, characterized in that: Further including: The update judgment module is used to generate a power-off interruption before the file data to be updated is not successfully updated, after all the file data to be updated is successfully updated, or when the current address mapping table is not fully updated successfully, and after power is restored, the file data is the file data to be updated; and generate a power-off interruption when all the current address mapping table is successfully updated, and after power is restored, the file data and the current address mapping table are all successfully updated.
Citation Information
Patent Citations
Method and device for operating Flash
CN101980177A