Storage system and data processing method
By introducing a storage fragmentation and mapping table management mechanism into the storage system, and dynamically managing storage pages, the problems of low data page management efficiency and shortened lifespan when Flash simulates EEPROM are solved, achieving efficient data page management and extended lifespan.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- AUTOCHIPS
- Filing Date
- 2025-12-05
- Publication Date
- 2026-05-08
AI Technical Summary
Existing technologies struggle to efficiently manage data pages when using Flash to simulate EEPROM, resulting in a shortened flash erase/write lifespan and a tendency for write amplification during write operations.
By introducing a storage sharding and mapping table management mechanism into the storage system, storage pages can be dynamically managed. Fine-grained management can be achieved using shard ID and write count fields, reducing the single write load and extending the lifespan of Flash memory.
It achieves efficient data page management of the storage system, extends the erase and write life of Flash, reduces write amplification, and improves the lifespan of the storage system.
Smart Images

Figure CN121996578A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data storage technology, and in particular to a storage system and a data processing method. Background Technology
[0002] In modern embedded systems, IoT devices, and automotive electronic control units, systems often require a type of non-volatile storage medium that can retain data even when power is off and supports a small number of frequent read / write operations. Traditional solutions often use EEPROM (Electrically Erasable Programmable Read-Only Memory). EEPROM is typically written and erased in bytes and has a relatively high write / erase life. However, with the development of integrated circuit manufacturing processes, many microcontroller chips have gradually eliminated EEPROM cells and replaced their function with on-chip Flash memory to reduce chip area and manufacturing costs.
[0003] Flash memory is an electrically erasable programmable read-only memory (EEPROM) that retains data even when power is off. It is commonly used to store program code and parameter data, and is typically erased and written in blocks. Simulating an EEPROM mechanism for data reading and writing with Flash can effectively reduce write amplification. However, due to the difficulty in efficiently managing free space, valid data, and discarded data when simulating an EEPROM, and the limited number of write and erase cycles of Flash, efficiently managing data pages and improving the Flash's erase and write lifespan are pressing issues that need to be addressed when using an EEPROM-like mechanism for data reading and writing. Summary of the Invention
[0004] To address the aforementioned issues, this application provides at least a storage system and a data processing method to enable dynamic management of data pages in the storage system and improve their lifespan.
[0005] In a first aspect, this application provides a storage system, comprising: a plurality of storage pages, wherein a portion of the plurality of storage pages are dynamically used for at least two storage shards, each of the storage shards being configured with a shard ID, wherein one storage page in the storage shard is used as a storage header, the storage shard header including a shard ID field for indicating the shard ID of the storage shard and a write count field for indicating the number of writes; and a control system connected to the plurality of storage pages, for managing the plurality of storage pages through the headers of the at least two storage shards and a mapping table between the plurality of storage pages and the at least two storage shards.
[0006] In some embodiments, the control system executes an initialization process, including: the control system extracting the fragment IDs of the at least two storage fragments from the headers of the at least two storage fragments; creating the mapping table using the fragment IDs of the at least two storage fragments, wherein the mapping table is represented by the fragment ID of each storage fragment and the page number of the corresponding storage page; and marking an initialization completion status in response to the at least two storage fragments having different fragment IDs.
[0007] In some embodiments, the plurality of storage pages are configured with a bitmap, wherein the bitmap includes a plurality of bits, each bit being used to indicate the corresponding storage page; the control system executes an initialization process, further comprising: setting the bitmap to an original value; performing bit initialization for each storage page; and obtaining the bitmap as a target value in response to the completion of bit initialization of the plurality of storage pages.
[0008] In some embodiments, the header of the storage shard further includes: a magic number field for indicating the validity of the header of the storage shard; a version number field for indicating the software version number corresponding to the storage shard; and a checksum field for indicating the checksum for verifying the header of the storage shard, wherein the checksum is calculated based on the magic number, the software version number, the shard ID of the storage shard, and the number of writes; for each storage page, bit initialization is performed, including: in response to the existence of a header of the storage shard corresponding to the storage page, reading the header of the storage shard corresponding to the storage page; in response to the invalid magic number, or the valid magic number and the checksum failing the checksum verification, setting the bit corresponding to the storage page in the bit diagram to a first value to indicate that the storage page is idle; in response to the valid magic number and the checksum passing the checksum verification, setting the bit corresponding to the storage page in the bit diagram to a second value to indicate that the storage page has been occupied, and recording the number of writes.
[0009] In some embodiments, the control system executing the initialization process further includes: in response to the existence of the same shard ID among the at least two storage shards, the control system enters a power-down recovery mode to perform an exception handling process on the storage shards with the same shard ID.
[0010] In some embodiments, the write count field in the header of one of the storage shards with the same shard ID is a first value, and the write count field in the header of another storage shard is a second value, wherein the second value is greater than the first value; an exception handling process is performed on the storage shards with the same shard ID, including: performing a migration process on the storage shard corresponding to the first value, so that the storage shard corresponding to the first value is erased.
[0011] In some embodiments, the control system executes a data write process, including: determining the data to be written and the address of the data to be written, and determining the target storage segment and its segment ID corresponding to the data to be written based on the address of the data to be written; in response to the existence of the header of the target storage segment and the size of the remaining storage pages of the target storage segment being greater than or equal to the size of the data to be written, encrypting the data to be written using a dynamic key, and writing the encrypted data to be written to the storage page corresponding to the address in the target storage segment.
[0012] In some embodiments, the control system executing the write data process further includes: in response to the existence of the header of the target storage segment and the size of the remaining storage pages of the target storage segment being smaller than the size of the data to be written, performing a migration process on the target storage segment to release the storage pages in the target storage segment; encrypting the data to be written using a dynamic key, and writing the encrypted data to be written to the storage page corresponding to the address in the target storage segment after the migration process has been executed.
[0013] In some embodiments, the control system determines that the header of the target storage segment exists by: determining that the header of the target storage segment exists in response to determining from the mapping table that the corresponding header exists based on the segment ID of the target storage segment; and determining that the header of the target storage segment does not exist in response to determining from the mapping table that the corresponding header does not exist based on the segment ID of the target storage segment by searching for a free storage page from the plurality of storage pages and creating the header of the target storage segment on the free storage page, thereby determining the header of the target storage segment, wherein the header of the target storage segment includes a segment ID field for indicating the segment ID of the target storage segment and a write count field for indicating the current write count, wherein the current write count is the sum of the maximum write count corresponding to the plurality of storage pages and a preset value.
[0014] In some embodiments, the control system uses a dynamic key to encrypt the data to be written, including: generating the dynamic key based on the chip ID corresponding to the control system and the page number of the storage page to which the data to be written is written; and performing an XOR operation on the dynamic key and the data to be written to obtain the encrypted data to be written.
[0015] In some embodiments, the control system executes a migration process, including: determining the target storage segment to be migrated and its header; finding a free storage page from the plurality of storage pages, and copying the header of the target storage segment to the free storage page to obtain a header corresponding to the free storage page, wherein the value of the write count field in the header corresponding to the free storage page is replaced with the sum of the value of the write count field in the header of the target storage segment and a preset value; copying the storage data in the target storage segment to the free storage page, and erasing the header of the target storage segment and the storage data in the target storage segment.
[0016] In some embodiments, the control system copies stored data from the target storage segment to an idle storage segment, comprising: decrypting the stored data using a first dynamic key corresponding to the target storage segment to obtain decrypted stored data, wherein the first dynamic key is generated based on the chip ID corresponding to the control system and the page number of the storage page of the stored data in the target storage segment; encrypting the decrypted stored data using a second dynamic key corresponding to the idle storage page to obtain data to be copied, wherein the second dynamic key is generated based on the chip ID corresponding to the control system and the page number of the idle storage page; and copying the data to be copied to the idle storage page.
[0017] In some embodiments, the control system searches for a free storage page from the plurality of storage pages, including: in response to the maximum write count corresponding to the plurality of storage pages being 0, sequentially searching from the plurality of storage pages to obtain the free storage page; and in response to the maximum data write count corresponding to the plurality of storage pages being non-0, starting the search from the storage page corresponding to the maximum write count to obtain the free storage page.
[0018] In some embodiments, the control system executes a data reading process, including: determining the address of data to be read; determining the storage page to be read corresponding to the data to be read based on the address of the data to be read; in response to the storage page to be read corresponding to at least two storage segments to be read, splitting the address of the data to be read into at least two sub-addresses, wherein each sub-address corresponds to one storage segment to be read; reading the data of the sub-address corresponding to each storage segment to be read and placing it in a buffer; and returning the data to be read in response to the completion of data buffering of the sub-address corresponding to each storage segment to be read.
[0019] In a second aspect, this application provides a data processing method applied to the storage system described in the first aspect above, comprising: controlling the system to perform data processing on the plurality of storage pages through the headers of at least two storage shards and a mapping table between the plurality of storage pages and the at least two storage shards.
[0020] The beneficial effects of this application are as follows: Multiple storage pages are controlled by a control system within the storage system. The control system is connected to the storage pages, and some of these storage pages are dynamically used for two storage shards. Each storage shard is configured with a shard ID, and one storage page within a shard is used as a storage header. The shard header includes a shard ID field indicating the shard ID of the storage shard and a write count field indicating the number of data writes. The control system manages the multiple storage pages through the headers of at least two storage shards and a mapping table between the multiple storage pages and at least two storage shards. On one hand, the control system achieves dynamic management of the multiple storage pages 11 through the mapping table established between the storage pages and storage shards, enabling distributed storage through storage shards and fine-grained management through headers, thus improving the lifespan of the storage system 10. On the other hand, during data erasure, only the storage pages corresponding to the storage shards need to be erased, reducing the single write load and effectively reducing write amplification.
[0021] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.
[0023] Figure 1 This is a schematic diagram of the structure of a storage system according to some embodiments of this application. Figure 1 ; Figure 2 This is a simplified schematic diagram of the header of a storage fragment in some embodiments of this application; Figure 3 This is a schematic diagram of the initialization process of some embodiments of this application. Figure 1 ; Figure 4 This is a schematic diagram of the structure of a storage system according to some embodiments of this application. Figure 2 ; Figure 5 This is a schematic diagram of the structure of a storage system according to some embodiments of this application. Figure 3 ; Figure 6 This is a schematic diagram of the migration process of some embodiments of this application; Figure 7This is a schematic diagram of the data reading process in some embodiments of this application; Figure 8 This is a schematic diagram of the structure of a storage system according to some embodiments of this application. Figure 4 . Detailed Implementation
[0024] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0025] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0026] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0027] As mentioned above, when using the mechanism of Flash simulating EEPROM for data reading and writing, how to efficiently manage data pages and improve the Flash's erase and write lifespan becomes an urgent problem to be solved. Specifically, Flash memory typically requires an erase operation on a specific page or block before a write operation can be performed on that area. The erase operation is performed on a page or block basis, and it is not possible to erase individual bytes directly. When writing a small amount of data, it is necessary to erase all data in the block containing the page to be written before writing. If the entire block of data is erased when only a small amount of data needs to be written, write amplification will occur.
[0028] To enable those skilled in the art to better understand the technical solution of this application, the technical solution of this application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0029] Please see Figure 1 , Figure 1 This is a schematic diagram of the structure of a storage system according to some embodiments of this application. Figure 1, the storage system 10 includes multiple storage pages 11 and a control system 12. Some of the multiple storage pages 11 are dynamically used for at least two storage shards 110. Each storage shard 110 is configured with a shard ID. One of the storage pages 11 in the storage shard 110 is used to store a header. The header of the storage shard 110 includes a shard ID field for indicating the shard ID of the storage shard 110 and a write count field for indicating the write count. The control system 12 is connected to the multiple storage pages 11 and is used to manage the multiple storage pages 11 through the headers of at least two storage shards 110 and the mapping table between the multiple storage pages 11 and at least two storage shards 110.
[0030] Among them, the storage system 10 can be a Flash memory. The storage page 11 can be the basic unit for data reading and writing in the Flash memory. Each basic unit is electrically connected. The control system 12 can be the controller in the Flash memory or a Flash controller integrated in an external MCU (Microcontroller Unit) (not shown in the figure). It is a component that manages the data stored in the Flash memory and communicates with a computer or an electronic device, and can manage the multiple storage pages 11 through the electrical connection with the multiple storage pages 11.
[0031] Some of the multiple storage pages 11 are dynamically used for at least two storage shards 110, that is, some of the multiple storage pages 11 are logically divided into at least two storage shards 110. As Figure 1 shown, the multiple storage pages 11 can be storage page P1, storage page P2... storage page PX... storage page PN, a total of N storage pages 11. Among them, 4 < X < N. P1, P2... PX... PN can be the page numbers of the storage pages 11. The labeling of P1, P2... PX... PN for the storage pages 11 is only for exemplary distinction of different storage pages with page numbers, and is not for limiting the order of their page numbers. Figure 1The fact that only storage shards F1 and F2 are shown does not mean that storage system 10 only includes storage shards F1 and F2. Storage system 10 may also include three storage shards 110, such as storage shards F1, F2, and F3. Each storage shard 110 is configured with a shard ID, and the shard IDs of different storage shards 110 are different. For example, at least two storage shards 110 include storage shards F1, F2, ..., where storage shard F1 is configured with shard ID 1, storage shard F2 with shard ID 2, ..., and storage shard F1 includes storage page P1, storage shard F2 includes storage page P4, ..., storage page PX. That is, each storage shard 110 may include a different number of storage pages 11, and at least two storage shards 110 may have spaced storage pages 11 between them, allowing the spaced storage pages 11 to be used in other storage shards 110, such as... Figure 1 As shown, storage page P2 and storage page P3 are included between storage shard F1 and storage shard F2. Storage page P2 and storage page P3 can be used for other storage shards, such as storage shard F3 (not shown in the figure).
[0032] It should be noted that at least one storage page 11 is not used for storage shard 110 so that data can be migrated to that storage page 11 during subsequent data migration; for example, storage page PN is reserved. Thus, a portion of the storage pages 11 are dynamically used for at least two storage shards 110.
[0033] In each storage shard 110, one storage page 11 is used for storing the header, where the header can be a field, such as... Figure 2 As shown, the header includes a shard ID field for indicating the shard ID of storage shard 110 and a write count field for indicating the number of times data is written. The write count field in the header indicates the number of times data has been written to the header, and also the number of times the header has been created. For example, when storage system 10 creates storage shard 110, it has a header. At this time, data is written to the header, and the value of the write count field is updated from 0 to 1. If the storage shard 110 is subsequently written to multiple times, the value of the write count field remains 1 and is not updated. Then, when storage system 10 creates another storage shard 110, it has another header. At this time, data is written to this header, and the value of the write count field is updated from 1 to 2. When data is subsequently written to this storage shard 110, the value of the write count field remains 2 and is not updated. (Continue reading...) Figure 1Storage fragment F1 includes storage page P1, and the header can be stored in storage page P1. Storage fragment F2 includes storage pages P4...PX, and the header can be stored in any one of storage pages P4...PX. For example, if X=6, then storage fragment F2 includes storage pages P4, P5, and P6, and the header can be stored in any one of storage pages P4, P5, and P6. Furthermore, the header of storage fragment 110 can also be stored at a specific location within its corresponding storage page 11. For example, in storage fragment F1, the header of storage fragment F1 is stored at the beginning of the address of storage page P1; in storage fragment F2, the header of storage fragment F2 is stored at the beginning of the address of storage page P4. Therefore, when the control system 12 subsequently searches for the header of storage fragment 110, scanning a specific location will quickly retrieve the header of storage fragment 110. The space occupied by the header is much smaller than the storage space of the storage page 11, meaning that the storage page 11 of the header can continue to store the remaining data.
[0034] It is understandable that a storage page 11 in storage shard 110 is used for the storage header, but it is not limited to the storage shard 110 necessarily storing a header. For example, during the initialization phase of storage system 10, multiple storage pages 11 are divided into at least two storage shards 110, but no header is created for storage shards 110 that have not yet been written or have not yet been written. That is to say, in the above two cases, the header of the storage shard 110 will not be stored in the corresponding storage page 11.
[0035] The control system 12 manages multiple storage pages 11 through the headers of at least two storage shards 110 and a mapping table between multiple storage pages 11 and the at least two storage shards 110. The mapping table between the multiple storage pages 11 and the at least two storage shards 110 is, for example, a mapping table established based on the mapping relationship between the page numbers of the multiple storage pages 11 and the shard IDs of the at least two storage shards 110. The header of each storage shard 110 includes a shard ID field, allowing the control system 12 to obtain the shard ID of the storage shard 110 and the corresponding storage pages 11 by reading the header of the storage shard 110. For example, when X=6, storage fragment F2 includes storage pages P4, P5, and P6. This means there's a mapping relationship between storage fragment F2 and the page numbers of storage pages P4, P5, and P6. Therefore, the control system 12 can determine the page numbers of associated storage pages P4, P5, and P6 based on the mapping table and storage fragment F2, or vice versa. The control system 12 can also determine how many times storage fragments 110 have been created by the storage system 10 by scanning the write count field in the header of storage fragment F2. For example, if the write count field in the header of storage fragment F2 shows 3 writes, it indicates that storage fragment F2 corresponding to storage pages P4, P5, and P6 was obtained through the third storage fragment division performed by the storage system 10. Thus, the control system 12 can manage multiple storage pages 11 through the headers of at least two storage shards 110 and a mapping table between multiple storage pages 11 and at least two storage shards 110.
[0036] In this embodiment, some storage pages 11 in the storage system 10 are dynamically used for at least two storage shards 110. Each storage shard 110 is configured with a shard ID, and one storage page 11 in the storage shard 110 is used as a storage header. The header of the storage shard 110 includes a shard ID field indicating the shard ID of the storage shard 110 and a write count field indicating the number of writes. The control system 12 manages the multiple storage pages 11 through the headers of the at least two storage shards 110 and a mapping table between the multiple storage pages 11 and the at least two storage shards 110. On the one hand, the control system 12 realizes dynamic management of the multiple storage pages 11 through the mapping table established between the storage pages 11 and the storage shards 110, realizing distributed storage through storage shards 110 and fine-grained management through headers, thereby improving the lifespan of the storage system 10. On the other hand, when erasing data, only the storage pages 11 corresponding to the storage shards 110 need to be erased, reducing the single write load and effectively reducing write amplification.
[0037] Please see Figure 3 , Figure 3 This is a schematic diagram of the initialization process of some embodiments of this application. Figure 1 The initialization process can be the power-on process of the storage system 10. The control system 12 executes the initialization process, which includes the following steps: Step S31: The control system extracts the fragment IDs of at least two storage fragments from the headers of at least two storage fragments.
[0038] The control system 12 traverses and reads each storage page 11, extracts the header of storage fragment 110 from the storage page 11 that stores the header of storage fragment 110, and reads the fragment ID field of the header of storage fragment 110 to obtain the fragment ID of storage fragment 110.
[0039] Assuming at least two storage shards 110 are divided into two storage shards (storage shards F1 and F2), the storage system 10 has already been divided into these two storage shards F1 and F2 before power-on. During power-on, the headers of these two storage shards F1 and F2 need to be extracted to obtain their shard IDs, thereby enabling the management of these two storage shards F1 and F2, such as performing subsequent read and write control.
[0040] Step S32: Create a mapping table using the fragment IDs of at least two storage fragments, wherein the mapping table is represented by the fragment ID of each storage fragment and the page number of the corresponding storage page.
[0041] For example Figure 4 Taking storage shards F1 and F2 as examples, storage shard F1 includes storage page P1, and storage shard F2 includes storage pages P4, P5, and P6. A mapping relationship is established between storage shard F1 and storage page P1, that is, a mapping relationship is established between the shard ID of storage shard F1 and the page number of storage page P1. Similarly, a mapping relationship is established between storage shard F2 and storage pages P4, P5, and P6, that is, a mapping relationship is established between the shard ID of storage shard F2 and the page numbers of storage pages P4, P5, and P6. The mapping relationship is established and stored in a mapping table. The control system 12 can then query the page number of storage page P1 corresponding to shard ID1, and the page numbers of storage pages P4, P5, and P6 corresponding to shard ID2, or query the shard ID1 corresponding to the page number of storage page P1 to find storage shard F1, and query the shard ID2 corresponding to the page numbers of storage pages P4 and / or P5 and / or P6 to find storage shard F2.
[0042] Step S33: In response to at least two storage fragments having different fragment IDs, the system marks the initialization completion status.
[0043] In response to the fact that the fragment IDs of all extracted storage fragments 110 are different, the control system 12 marks the initialization completion status, that is, the initialization of the storage system 10 is complete.
[0044] In this embodiment, the control system 12 establishes a mapping table for storage pages 11 and storage shards 110 in the storage system 10, so as to find the corresponding storage shard 110 by the page number of storage page 11 and the mapping table, and to find the corresponding storage page 11 by the shard ID of storage shard 110. It also detects the shard ID of storage shard 110 so that the initialization is not marked as complete at the same time for all storage shard IDs of storage shard 110, thereby realizing the management of multiple storage pages 11 in the storage system 10.
[0045] Please see Figure 4 , Figure 4 This is a schematic diagram of the initialization process of some embodiments of this application. Figure 2 In this process, multiple storage pages 11 are configured with bitmaps, each bitmap including multiple bits, each bit being used to indicate the corresponding storage page 11; the initialization process executed by the control system 12 further includes: setting the bitmap to its original value; performing bit initialization for each storage page 11; and obtaining the bitmap as the target value in response to the completion of bit initialization of multiple storage pages 11.
[0046] by Figure 4 Taking storage shards F1 and F2 as examples, if storage system 10 includes N storage pages 11, then the bit map corresponds to an N-bit binary number. The first bit indicates storage page 11 with page number P1, the second bit indicates storage page 11 with page number P2, and so on, up to the Nth bit indicating storage page 11 with page number PX. Different bit values can indicate different states of the corresponding storage page 11, such as free state and occupied state.
[0047] In this method, the bitmap is set to its original value. For example, if the bitmap is an 8-bit binary number, the original value can be set to 00000000. Setting the bit to its original value indicates that the memory page 11 corresponding to the bit is in an idle state, that is, it indicates that the data stored in memory page 11 is empty.
[0048] For each storage page 11, bit initialization is performed. For example, the control system 12 verifies whether the storage page 11 is valid by initializing the bits corresponding to the storage page 11. Bit initialization can be performed by setting a bit to 0 or 1 to indicate the corresponding storage page 11. For example, if the storage page 11 is valid, the corresponding bit is set to 0 or retains its original value; if the storage page 11 is invalid, the corresponding bit is set to 1.
[0049] In response to the completion of bit initialization of multiple memory pages 11, a bit map is obtained as the target value. For example, the bit map corresponding to 8 memory pages 11 has a total of 8 bits. In response to the completion of bit initialization of multiple memory pages 11, the target value of the bit map is 11110110.
[0050] In this embodiment, a bit map is configured for multiple storage pages 11. Each bit in the bit map is used to indicate the corresponding storage page 11, so that the state of the storage page 11 can be indicated according to the bit. In this way, the state of the corresponding storage page 11 can be known from the bit in the bit map.
[0051] In some embodiments, the header of storage shard 110 further includes: a magic number field for indicating a magic number representing the validity of the header of storage shard 110; a version number field for indicating a software version number corresponding to storage shard 110; and a checksum field for indicating a checksum for checking the header of storage shard 110, wherein the checksum is calculated from the magic number, the software version number, the shard ID of storage shard 110, and the number of writes.
[0052] The structure of the magic number field, version number field, and checksum field in the header can be as follows: Figure 2 As shown, the magic number field can be a preset fixed value used to identify the validity of the header of storage shard 110. For example, the magic number field in the header of each storage shard 110 is 0x5AA5. The version number field can record the software version number corresponding to the creation of the header of storage shard 110, such as the driver software version number in storage system 10. When the header is created in storage shard 110, the version number field in the header stores the current driver software version number. If the driver software version number is updated, then when the header is created in storage shard 110, the version number field in the header stores the current driver software version number, that is, it stores the updated driver software version number. The checksum field can be a cyclic redundancy check value, such as a cyclic redundancy check value calculated based on the magic number field, the version number field, the shard ID of the storage shard, and the number of writes, and the calculated cyclic redundancy check value is stored in the checksum field. The header of storage shard 110 also includes a reserved field, which can be used to store other data. The sizes of the magic number field, version number field, shard ID field, checksum field, write count field, reserved field, and checksum field can be 2B, 2B, 2B, 4B, 2B, and 2B, respectively.
[0053] Performing bit initialization for each storage page 11 includes: in response to the existence of a header for a corresponding storage fragment 110 for storage page 11, reading the header of the storage fragment 110 corresponding to storage page 11; in response to an invalid magic number, or a valid magic number but a failed checksum verification, setting the bit corresponding to storage page 11 in the bit diagram to a first value to indicate that storage page 11 is free; in response to an invalid magic number but a passed checksum verification, setting the bit corresponding to storage page 11 in the bit diagram to a second value to indicate that storage page 11 has been occupied, and recording the write count.
[0054] The first value can be 0, indicating that storage page 11 is free, and the second value can be 1, indicating that storage page 11 is occupied. During the bit initialization process, the control system 12 traverses and scans multiple storage pages 11, performs bit initialization on the storage page 11 that contains the head of storage fragment 110, and reads the head.
[0055] First, the magic number field in the read header is verified and the magic number is extracted. If the magic number is different from the preset fixed value, the magic number is invalid, and the bits of the storage page 11 storing the header are set to the first value.
[0056] Invalid magic number and invalid checksum can occur during data migration when storage system 10 experiences an unexpected power outage. For example, if the magic number is being copied but the copying process is incomplete, and storage system 10 experiences an unexpected power outage, the magic number will be invalid when checking the magic number field in the header of storage shard 110. Similarly, if the updated checksum is not yet calculated and storage system 10 experiences an unexpected power outage, the checksum field in the storage shard will fail the check. In this example, the head copying stage occurs during data migration, before the data migration itself. Therefore, the bit in the bitmap of the storage page 11 containing the invalid header can be set to the first value, and the invalid header can be directly overwritten when storing another header.
[0057] If the magic number is the same as the preset fixed value, then the magic number is valid. Next, the checksum field in the read header is checked. If the checksum field fails the checksum verification, the bit in the bitmap of the storage page 11 storing the header is set to the first value. If the checksum field passes the checksum verification, meaning the storage page 11 stores a valid header, the bit in the bitmap of the storage page 11 is set to the second value. Simultaneously, the number of times the header in the storage page 11 has been written is recorded.
[0058] Thus, after the control system 12 has traversed all storage pages 11, it records the number of writes of the valid headers stored in all valid storage pages 11. Based on all the write counts, the maximum number of writes of the storage system 10 can be determined, providing a basis for data recovery or fragment migration of the storage system 10.
[0059] For storage page 11 without a header, it is directly determined whether there is data. If data is stored, the bit in the bit diagram of storage page 11 is set to the second value; if there is no data, the bit in the bit diagram of storage page 11 is set to the first value.
[0060] In this embodiment, the header of the storage shard 110 also includes a magic number field, a version number field, and a checksum field, which are used to perform bit initialization on the storage pages 11 with headers, so that the control system 12 can determine whether the storage page 11 is idle by reading the bits of each storage page 11, and then manage multiple storage pages 11.
[0061] As described above, the verification field in the read header is verified. In some embodiments, the verification value verification includes: calculating the magic number, software version number, shard ID of storage shard 110, and write count to obtain a calculated value; comparing the calculated value with the verification value; wherein, if the calculated value and the verification value are consistent, it means that the verification value verification has passed, and if the calculated value and the verification value are inconsistent, it means that the verification value verification has failed.
[0062] Specifically, when calculating the magic number, software version number, fragment ID of storage fragment 110, and write count in the read header, the calculated value can be obtained based on the calculation rules of cyclic redundancy check code. The calculated value is then compared with the check value field in the read header. If the comparison matches, the check value verification is successful; otherwise, the check value verification fails.
[0063] In this embodiment, the check value field in the header of storage fragment 110 is checked to verify the validity of the header of storage fragment 110.
[0064] In some embodiments, the initialization process performed by the control system 12 further includes: in response to the existence of the same shard ID for at least two storage shards 110, the control system 12 enters a power-down recovery mode to perform an exception handling process on the storage shards 110 with the same shard ID.
[0065] like Figure 5As shown, the storage system 10 includes storage shards F3 and F4. Storage shard F3 includes storage pages Pm and Pn, and storage shard F4 includes storage pages Pu and Pv. Pm, Pn, Pu, and Pv are used to characterize the different page numbers. The power-loss recovery mode refers to the data recovery mode performed after the storage system 10 experiences an unexpected power outage. For example, data in storage pages Pm and Pn is migrated to storage pages Pu and Pv. Storage pages Pu and Pv are free storage pages found by the control system 12 through the migration process. First, the header of storage shard F3 is copied and updated to one of the found storage pages Pu and Pv, so that storage pages Pu and Pv can be used for storage shard F4. Then, the data to be migrated is copied to the corresponding storage pages Pu and Pv of storage shard F4. After the data copying is completed, the header and data stored in storage pages Pm and Pn are deleted. If the storage system 10 experiences an unexpected power outage during the data copying process, the shard IDs of storage shards F3 and F4 will be the same because the ID fields in the headers of storage shards F3 and F4 are related as copying and being copied.
[0066] Therefore, when the control system 12 detects that the shard IDs of storage shard F3 and storage shard F4 are the same during the initialization process, the control system 12 enters the power-down recovery mode to perform an exception handling process on storage shard F3 and storage shard F4.
[0067] In this embodiment, the control system 12 further includes checking the fragment ID of the storage fragment 110 when executing the initialization process, so as to enter the power failure recovery mode when it is detected that at least two storage fragments 110 have the same fragment ID, so as to perform an abnormal handling process on the storage fragment 110 with abnormality.
[0068] In some embodiments, the write count field in the header of one storage shard 110 with the same shard ID is the first value, and the write count field in the header of another storage shard 110 is the second value, wherein the second value is greater than the first value; an exception handling process is performed on the storage shards 110 with the same shard ID, including: performing a migration process on the storage shard 110 corresponding to the first value, so that the storage shard 110 corresponding to the first value is erased.
[0069] For details, please refer to [link / reference]. Figure 5Taking the unexpected power outage during data migration as an example, when copying the header of storage shard F3, this includes copying the magic number, software version number, and shard ID of storage shard F3. The write count and checksum fields in the header need to be updated. For example, the write count field needs to be updated, and a checksum is calculated based on the magic number, software version number, shard ID of storage shard F3, and the updated write count. This checksum is then written as the updated checksum into the header of storage shard F4.
[0070] At this time, the write count field in the header of storage shard F3 is the first value, and the write count field in the header of storage shard F4 is the second value. The second value is an updated value of the first value and is used as the value of the total number of writes in the header of the record storage system 10. That is, the second value is greater than the first value.
[0071] Therefore, it is necessary to perform an exception handling process for storage shards F3 and F4, that is, to perform a migration process for storage shard F3 corresponding to the first value.
[0072] In this embodiment, the write count field in the header of storage shard 110 records the write count so that when the storage system 10 loses power unexpectedly and the data migration is not completed, the write count of shards with the same ID can be compared to distinguish the storage shard F3 that needs to migrate out and the storage shard F4 that needs to migrate in, so as to perform data migration management on the storage pages 11 in the storage system 10.
[0073] In some embodiments, the control system 12 performs a write data process including determining the data to be written and the address of the data to be written, and determining the target storage segment and its segment ID corresponding to the data to be written based on the address of the data to be written; in response to the existence of the header of the target storage segment and the size of the remaining storage pages of the target storage segment being greater than or equal to the size of the data to be written, encrypting the data to be written using a dynamic key, and writing the encrypted data to be written to the storage page 11 corresponding to the address in the target storage segment.
[0074] Specifically, the target storage segment can be one of at least two storage segments 110 in the storage system 10. The target storage segment and its segment ID corresponding to the data to be written are determined based on the address of the data to be written. For example, if the address of the data to be written corresponds to the address of storage page 11 in the storage system 10, the page number of storage page 11 can be determined based on the address of storage page 11, and the segment ID corresponding to the page number of storage page 11 can be found in the mapping table, thereby determining the target storage segment.
[0075] The existence of the header in the target storage segment means that the target storage segment has already undergone one data write and has a corresponding header. Therefore, it is necessary to determine the size of the remaining storage pages in the target storage segment. The size of the remaining storage pages can be the remaining storage space after deducting the space occupied by the header and the space occupied by the original data in at least one storage page 11 corresponding to the target storage segment. When the size of the remaining storage pages in the target storage segment is greater than or equal to the size of the data to be written, the data to be written is written. Specifically, when writing the data to be written to the storage page 11 corresponding to the target storage segment, a dynamic key is used to encrypt the data to be written, and then the encrypted data is written to the storage page 11 at the address corresponding to the target storage segment.
[0076] In this embodiment, the corresponding storage page 11 is determined according to the address of the data to be written for data writing. Before writing the data to be written, the size of the remaining storage pages of the target storage segment is judged. Then, when the size of the remaining storage pages is greater than or equal to the size of the data to be written, the data to be written is encrypted with a dynamic key and stored in the storage page 11 corresponding to the target storage segment.
[0077] In some embodiments, the control system 12 further includes executing the write data process as follows: in response to the existence of the header of the target storage segment and the size of the remaining storage pages of the target storage segment being smaller than the size of the data to be written, performing a migration process on the target storage segment to release the storage pages 11 in the target storage segment; encrypting the data to be written using a dynamic key, and writing the encrypted data to be written to the storage page 11 corresponding to the address in the target storage segment after the migration process has been executed.
[0078] If the size of the remaining storage pages in the target storage segment is smaller than the size of the data to be written, the target storage segment cannot write the complete data to be written. Therefore, it enters the migration process, which migrates the data in the target storage segment to the free storage page 11, thereby releasing the storage page 11 corresponding to the target storage segment. Then, when migrating the data in the target storage segment to the free storage page 11, a dynamic key is used to encrypt the data to be written, and the encrypted data to be written is written to the storage page 11 corresponding to the address in the target storage segment after the migration process is executed.
[0079] In this embodiment, the corresponding storage page 11 is determined according to the address of the data to be written for data writing. Before writing the data to be written, the size of the remaining storage pages of the target storage segment is judged. Then, when the size of the remaining storage pages is smaller than the size of the data to be written, the migration process is performed on the target storage segment, and the data to be written is encrypted and written to the storage page 11 corresponding to the target storage segment.
[0080] In some embodiments, the control system 12 determines that the header of the target storage segment exists by: determining that the header of the target storage segment exists in response to determining from a mapping table that the corresponding header exists based on the segment ID of the target storage segment; and determining that the header of the target storage segment does not exist in response to determining from the mapping table that the corresponding header does not exist based on the segment ID of the target storage segment by searching for a free storage page from a plurality of storage pages 11 and creating the header of the target storage segment on the free storage page, thereby determining the header of the target storage segment, wherein the header of the target storage segment includes a segment ID field for indicating the segment ID of the target storage segment and a write count field for indicating the current write count, wherein the current write count is the sum of the maximum write count corresponding to the plurality of storage pages 11 and a preset value.
[0081] The existence of the corresponding header is determined from the mapping table based on the segment ID of the target storage segment. For example, the page number of the corresponding storage page 11 is looked up from the mapping table based on the segment ID of the target storage segment, and the header of the storage page 11 corresponding to the target storage segment is scanned. If the header of the target storage segment is found in the storage page 11 corresponding to the target storage segment, it is determined that the header of the target storage segment exists.
[0082] Based on the segment ID of the target storage segment, it is determined from the mapping table that the corresponding header does not exist. For example, based on the segment ID of the target storage segment, the page number of the corresponding storage page 11 is looked up from the mapping table, and the header of the storage page 11 corresponding to the target storage segment is scanned. If the header of the target storage segment is not found in the storage page 11 corresponding to the target storage segment, it is determined that the header of the target storage segment does not exist.
[0083] A free storage page is searched among multiple storage pages 11. This free storage page can be the storage page 11 corresponding to the target storage fragment, or it can be the storage page 11 whose bit in the bitmap of the storage system 10 has a first value. A header for the target storage fragment is then created on the free storage page. The fragment ID field, indicating the fragment ID of the target storage fragment, and the write count field, indicating the current write count, are stored in this header. The write count field is the sum of the maximum write count corresponding to the multiple storage pages 11 and a preset value. For example, if the maximum write count is 10 and the preset value is 1, then the value of the write count field is 11. The created header can then identify the target storage fragment and the corresponding storage page 11.
[0084] In this embodiment, the existence of the header of the target storage segment is determined by the mapping relationship between storage page 11 and storage segment 110 in the mapping table. Then, it is determined whether it is necessary to search for a free storage page and create the header of the target storage segment so as to store the header and data of the target storage segment in the free storage page corresponding to the target storage segment.
[0085] In some embodiments, the control system 12 uses a dynamic key to encrypt the data to be written, including: generating a dynamic key based on the chip ID corresponding to the control system 12 and the page number of the storage page 11 to which the data to be written is written; and performing an XOR operation on the dynamic key and the data to be written to obtain the encrypted data to be written.
[0086] The chip ID can be the chip ID of the control chip in the control system 12 of the storage system 10, or it can be the chip ID of the Flash controller in the MCU. A dynamic key is generated based on the chip ID and the page number of the memory page 11 to be written. For example, the chip ID and the page number of the memory page 11 are read, added together, and then XORed with the data to be written for encryption. Here, the chip ID is a fixed value, and the page number of the memory page 11 is related to the address of the data to be written. When the address of the data to be written changes, the page number of the memory page 11 changes accordingly, thereby achieving dynamic encryption.
[0087] Please see Figure 6 , Figure 6 This is a schematic diagram of the migration processing flow of some embodiments of this application. The control system 12 executes the migration processing flow including the following steps: Step S61: Determine the target storage fragment to be migrated and its header.
[0088] The control system 12 determines the storage page 11 corresponding to the address of the data to be written based on the address of the data to be written, and then determines the target storage fragment and the header of the target storage fragment to be migrated based on the mapping table and the page number of the storage page 11 corresponding to the address of the data to be written.
[0089] Step S62: Locate a free storage page from multiple storage pages, and copy the header of the target storage fragment to the free storage page to obtain the header corresponding to the free storage page. The value of the write count field in the header corresponding to the free storage page is replaced with the sum of the value of the write count field in the header of the target storage fragment and a preset value.
[0090] Specifically, free storage pages are searched based on the bitmaps corresponding to multiple storage pages 11. Once the required number of free storage pages is found, for example, the number of at least one storage page 11 corresponding to the target storage fragment is the same. The header of the target storage fragment is copied to one of the at least one free storage page. When copying the header of the target storage fragment, the value of the write count field in its header is replaced with the sum of the write count field value in the header of the target storage fragment and a preset value, and then stored in the corresponding free storage page. The preset value can be a pre-set value, for example, a preset value of 1. Simultaneously, a mapping relationship is established based on the page number of at least one free storage page and the fragment ID stored in the header, and stored in a mapping table. Furthermore, the bits in the bitmap corresponding to the storage page 11 containing data in at least one free storage page are set to a second value.
[0091] Step S63: Copy the storage data in the target storage fragment to a free storage page, and erase the header of the target storage fragment and the storage data in the target storage fragment.
[0092] The stored data in the target storage fragment includes data other than the header stored in at least one storage page 11 in the target storage fragment. After copying the stored data in the target storage fragment to the corresponding free storage page, the header and the stored data in the target storage fragment are erased to release the target storage fragment. After erasing the header and the stored data in the target storage fragment, the division of the target storage fragment disappears. That is, the fragment ID of the target storage fragment and the page number of the storage page 11 corresponding to the target storage fragment are deleted from the mapping table, and the bit in the bit diagram corresponding to the storage page 11 of the target storage fragment is set to the first value.
[0093] In this embodiment, a migration process is performed on the target storage segment, which can migrate the data in the target storage segment to a free storage page, thereby releasing the target storage page and making the storage page 11 corresponding to the target storage page a free storage page, which can be used to store the header and store data.
[0094] In some embodiments, the control system 12 copies the stored data in the target storage segment to the idle storage segment 110, including: decrypting the stored data using a first dynamic key corresponding to the target storage segment to obtain decrypted stored data, wherein the first dynamic key is generated based on the chip ID corresponding to the control system and the page number of the storage page 11 in the target storage segment; encrypting the decrypted stored data using a second dynamic key corresponding to the idle storage page to obtain data to be copied, wherein the second dynamic key is generated based on the chip ID corresponding to the control system 12 and the page number of the idle storage page; and copying the data to be copied to the idle storage page.
[0095] In one example, migrating stored data in a target storage segment requires obtaining a first dynamic key and decrypting the stored data in the target storage segment using the first dynamic key. The first dynamic key is generated based on the chip ID corresponding to the control system 12 and the page number of at least one storage page 11 in the target storage segment where the stored data is located. After decrypting the stored data using the first dynamic key, the decrypted stored data is obtained. The decrypted stored data is then encrypted using a second dynamic key. The second dynamic key is generated based on the chip ID corresponding to the control system 12 and the page number of at least one free storage page. The decrypted stored data is then encrypted using the second dynamic key to obtain the data to be copied, and the data to be copied is copied to a free storage page.
[0096] In this embodiment, a dynamic key is generated by combining the page number of the storage page 11 to be migrated out and the page number of the storage page 11 to be migrated in with the chip ID, so as to realize the decryption and encryption of the stored data. The generation of the dynamic key changes dynamically with the different page numbers of the storage page 11, thereby improving the security of the stored data.
[0097] In some embodiments, the control system 12 searches for a free storage page from a plurality of storage pages 11, including: in response to the maximum number of writes corresponding to the plurality of storage pages 11 being 0, sequentially searching from the plurality of storage pages 11 to obtain a free storage page; and in response to the maximum number of writes corresponding to the plurality of storage pages being not 0, starting from the storage page 11 corresponding to the maximum number of writes to obtain a free storage page.
[0098] In one example, the maximum number of writes corresponding to multiple storage pages 11 is 0, that is, the storage system 10 has not performed storage sharding 110 and there is no data storage. The search is performed sequentially according to the page number of the storage page 11, that is, starting from the storage page 11 with the smallest page number and searching in order of increasing page number. By sequentially checking the bits of the bit map corresponding to multiple storage pages 11, the storage page 11 with the first bit value in the bit map is regarded as the free storage page, so as to obtain the free storage page.
[0099] In another example, the maximum write count corresponding to multiple storage pages 11 is not 0, that is, the storage system 10 has been divided into storage shards 110 and there is data storage. Locate the storage shard 110 with the maximum write count, and starting from the page number of the storage page 11 corresponding to the storage shard 110, sequentially search for the other storage pages 11 with a page number greater than that page number. By sequentially checking the bits of the bit map corresponding to multiple storage pages 11, the storage page 11 with the first bit value in the bit map is taken as the free storage page, so as to obtain the free storage page.
[0100] In this embodiment, regardless of whether the maximum number of writes is 0 or not, the free storage pages are queried in ascending order of the page number of the storage page 11 to achieve fast search and sequential utilization of the free storage pages, reduce the time for querying the free storage pages and balance the wear and tear of multiple storage pages 11.
[0101] Please see Figure 7 , Figure 7 This is a schematic diagram of the data reading process according to some embodiments of this application. The control system 12 executes the data reading process including the following steps: Step S71: Determine the address of the data to be read.
[0102] The control system 12 receives a data read command from the host computer and determines the address of the data to be read. The host computer can be a computer connected to the control system 12.
[0103] Step S72: Based on the address of the data to be read, determine at least two of the at least two storage fragments to be read.
[0104] The address of the data to be read can be the physical address of the storage page 11 that stores the data to be read, and the storage fragment to be read can be the storage fragment 110 corresponding to the storage page 11 that stores the data to be read. The data to be read corresponds to at least two of the storage fragments 110. That is to say, the address of the data to be read corresponds to the physical address of at least two storage pages 11, and at least two storage pages 11 correspond to different storage fragments 110.
[0105] Step S73: Split the address of the data to be read into at least two sub-addresses, where at least two word addresses correspond to at least two storage fragments to be read, and each sub-address corresponds to one storage fragment to be read.
[0106] The data to be read is stored in different storage segments 110. The address of the data to be read is divided according to the physical address of the storage page 11 corresponding to at least two storage segments, resulting in at least two sub-addresses, each sub-address corresponding to one storage segment to be read. For example... Figure 8 As shown, the page numbers of the storage pages 11 corresponding to the address of the data to be read are P11, P12, P13, and P14, respectively. The storage pages 11 with page numbers P11 and P12 correspond to the storage fragment F5 to be read, and the storage pages 11 with page numbers P13 and P14 correspond to the storage fragment F6 to be read. The address of the data to be read is divided into two sub-addresses according to the storage fragments F5 and F6 to be read. One sub-address corresponds to the physical address of the storage page 11 with page numbers P11 and P12, and the other sub-address corresponds to the physical address of the storage page with page numbers P13 and P14.
[0107] Step S74: Read the data corresponding to the sub-address of each storage fragment to be read and place it in the buffer.
[0108] Continuing with the example of page numbers P11, P12, P13, and P14 corresponding to the addresses of the data to be read, the data of the sub-addresses corresponding to the storage fragments F5 and F6 to be read are read respectively. The data in the storage pages 11 of the storage fragments F5 to be read, with page numbers P11 and P22 respectively, and the data in the storage pages 11 of the storage fragments F6 to be read, with page numbers P13 and P14 respectively, are placed in the buffer.
[0109] Step S75: In response to the completion of the data buffer for the sub-address corresponding to each storage fragment to be read, return the data to be read.
[0110] Continuing with the example of page numbers P11, P12, P13, and P14 corresponding to the addresses of the data to be read, in response to the data corresponding to both sub-addresses being read and placed in the buffer, the data corresponding to both sub-addresses is returned, that is, the data to be read is returned to the host computer.
[0111] It should be noted that if the address of the data to be read corresponds to only one storage segment, then the storage segment to be read is read directly, the corresponding data is obtained, placed in the buffer, and the corresponding data is returned after buffering is complete.
[0112] In this embodiment, when the data to be read corresponds to at least two storage shards 110, the data to be read is read in shards and placed in a buffer, and then returned together after the data to be read is read.
[0113] In some embodiments, the data processing method can be applied to the storage system 10 in the above embodiments, including: the control system 12 performs data processing on multiple storage pages 11 through the headers of at least two storage shards 110 and a mapping table between multiple storage pages 11 and at least two storage shards 110. Specific implementation steps are as described in the above embodiments and will not be repeated here.
[0114] In this embodiment, the control system 12 in the storage system 10 controls multiple storage pages 11. The control system 12 processes data on the multiple storage pages 11 through the headers of at least two storage shards 110 and a mapping table between the multiple storage pages 11 and the at least two storage shards 110. On the one hand, the control system 12 realizes dynamic management of multiple storage pages 11 through the mapping table established between the storage pages 11 and the storage shards 110, thereby improving the service life of the storage system 10. On the other hand, when erasing data, only the storage pages 11 corresponding to the storage shards 110 need to be erased, effectively reducing write amplification.
[0115] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0116] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0117] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the division of modules or units is merely a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
Claims
1. A storage system, characterized in that, include: Multiple storage pages, some of which are dynamically used for at least two storage shards, each of which is configured with a shard ID, wherein one storage page in the storage shard is used as a storage header, and the shard header includes a shard ID field for indicating the shard ID of the storage shard and a write count field for indicating the number of writes; A control system, connected to the plurality of storage pages, is used to manage the plurality of storage pages through the headers of the at least two storage shards and a mapping table between the plurality of storage pages and the at least two storage shards.
2. The storage system according to claim 1, characterized in that, The control system executes an initialization process, including: The control system extracts the fragment IDs of the at least two storage fragments from the headers of the at least two storage fragments; The mapping table is created using the fragment IDs of the at least two storage fragments, wherein the mapping table is represented by the fragment ID of each storage fragment and the page number of the corresponding storage page; In response to the fact that the fragment IDs of the at least two storage fragments are different, the control system marks the initialization completion status.
3. The storage system according to claim 2, characterized in that, The plurality of storage pages are configured with a bit map, wherein the bit map includes a plurality of bits, each bit being used to indicate the corresponding storage page; The control system executes an initialization process, which also includes: Set the bitmap to its original value; For each of the aforementioned storage pages, perform bit initialization; Upon completion of bit initialization of the plurality of storage pages, the bit map is obtained as the target value.
4. The storage system according to claim 3, characterized in that, The header of the storage fragment also includes: A magic number field indicating the magic number that identifies the validity of the header of the storage fragment; and The version number field is used to indicate the software version number corresponding to the storage shard; and The checksum field is used to indicate the checksum of the header of the storage shard, wherein the checksum is calculated based on the magic number, the software version number, the shard ID of the storage shard, and the number of writes; For each of the aforementioned storage pages, bit initialization is performed, including: In response to the existence of the header of the corresponding storage segment for the storage page, read the header of the storage segment corresponding to the storage page; In response to the magic number being invalid, or the magic number being valid and the check value failing the check, the bit corresponding to the storage page in the bit diagram is set to a first value to indicate that the storage page is idle; In response to the magic number being valid and the check value passing the check, the bit corresponding to the storage page in the bit diagram is set to a second value to indicate that the storage page has been occupied, and the number of writes is recorded.
5. The storage system according to claim 2, characterized in that, The control system executes an initialization process, which also includes: In response to the existence of the same shard ID for at least two storage shards, the control system enters a power-down recovery mode to perform an exception handling process on the storage shards with the same shard ID.
6. The storage system according to claim 5, characterized in that, The write count field in the header of one of the storage shards with the same shard ID is a first value, and the write count field in the header of the other storage shard is a second value, wherein the second value is greater than the first value; An exception handling process is performed on the storage shards with the same shard ID, including: A migration process is performed on the storage fragment corresponding to the first value so that the storage fragment corresponding to the first value is erased.
7. The storage system according to claim 1, characterized in that, The control system executes a data writing process, including: Determine the data to be written and its address, and based on the address of the data to be written, determine the target storage fragment and its fragment ID corresponding to the data to be written; In response to the existence of the header of the target storage segment and the size of the remaining storage pages of the target storage segment being greater than or equal to the size of the data to be written, the data to be written is encrypted using a dynamic key, and the encrypted data to be written is written to the storage page corresponding to the address in the target storage segment.
8. The storage system according to claim 7, characterized in that, The control system executes the data writing process, which also includes: In response to the existence of the header of the target storage segment and the size of the remaining storage pages of the target storage segment being less than the size of the data to be written, a migration process is performed on the target storage segment to release the storage pages in the target storage segment; The data to be written is encrypted using a dynamic key, and the encrypted data is written to the storage page corresponding to the address in the target storage shard after the migration process is executed.
9. The storage system according to claim 7, characterized in that, The control system determines the existence of the header of the target storage fragment by: In response to determining from the mapping table that the corresponding header exists based on the fragment ID of the target storage fragment, the existence of the header of the target storage fragment is determined; In response to determining from the mapping table that the corresponding header does not exist based on the fragment ID of the target storage fragment, a free storage page is searched from the plurality of storage pages, and the header of the target storage fragment is created on the free storage page, thereby determining the header of the target storage fragment. The header of the target storage fragment includes a fragment ID field for indicating the fragment ID of the target storage fragment and a write count field for indicating the current write count, wherein the current write count is the sum of the maximum write count corresponding to the plurality of storage pages and a preset value.
10. The storage system according to claim 7 or 8, characterized in that, The control system uses a dynamic key to encrypt the data to be written, including: The dynamic key is generated based on the chip ID corresponding to the control system and the page number of the storage page to which the data to be written is written; An XOR operation is performed on the dynamic key and the data to be written to obtain the encrypted data to be written.
11. The storage system according to claim 1, characterized in that, The control system executes a migration process, including: Identify the target storage fragment to be migrated and its header; Find a free storage page from the plurality of storage pages, and copy the header of the target storage segment to the free storage page to obtain the header corresponding to the free storage page. The value of the write count field in the header corresponding to the free storage page is replaced with the sum of the value of the write count field in the header of the target storage segment and a preset value. The storage data in the target storage segment is copied to the free storage page, and the header of the target storage segment and the storage data in the target storage segment are erased.
12. The storage system according to claim 11, characterized in that, The control system copies the stored data from the target storage segment to the idle storage segment, including: The storage data is decrypted using the first dynamic key corresponding to the target storage segment to obtain the decrypted storage data, wherein the first dynamic key is generated based on the chip ID corresponding to the control system and the page number of the storage page of the storage data in the target storage segment; The decrypted stored data is encrypted using the second dynamic key corresponding to the free storage page to obtain the data to be copied. The second dynamic key is generated based on the chip ID corresponding to the control system and the page number of the free storage page. The data to be copied is copied to the free storage page.
13. The storage system according to claim 1, characterized in that, The control system searches for a free storage page from the plurality of storage pages, including: In response to the maximum number of writes corresponding to the plurality of storage pages being 0, the search is performed sequentially from the plurality of storage pages to obtain the free storage page; In response to the fact that the maximum number of writes corresponding to the plurality of storage pages is not 0, a search is performed starting from the storage page corresponding to the maximum number of data writes to obtain the free storage page.
14. The storage system according to claim 1, characterized in that, The control system executes a data reading process, including: Determine the address of the data to be read; Based on the address of the data to be read, it is determined that the data to be read corresponds to at least two of the at least two storage fragments. The address of the data to be read is split into at least two sub-addresses, wherein the at least two sub-addresses correspond to the at least two storage fragments to be read, and each sub-address corresponds to one storage fragment to be read. The data at the sub-address corresponding to each of the storage segments to be read is read and placed in the buffer; In response to the completion of data buffering for each sub-address corresponding to the storage segment to be read, the data to be read is returned.
15. A data processing method, characterized in that, Applied to the storage system as described in any one of claims 1-14, comprising: The control system processes data on the multiple storage pages through the headers of at least two storage shards and a mapping table between multiple storage pages and the at least two storage shards.