Data storage method and storage device
Patent Information
- Application Number
- CN202610954227.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-30
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2046-06-30
AI Technical Summary
[0006]本申请各提供了一种数据存储方法及存储设备,可以解决相关技术中存在的不同数据存储模式混用影响物理块寿命管理的问题
[0009] In the above technical solution, after acquiring the data to be written, the storage device first queries the dynamic buffer block set in the available storage area to determine if there are any free, clean physical blocks. Since a clean physical block is a physical block that has not undergone data storage different from the first storage mode, if a free clean physical block exists in the dynamic buffer block set, the data to be written is stored in that free clean physical block in the first storage mode. If no free clean physical block exists in the dynamic buffer block set, the storage device then selects a second target physical block according to the set write strategy and stores the data to be written in the second target physical block. Therefore, while prioritizing the use of free clean physical blocks for storage in the first storage mode, the impact of mixing different data storage modes on physical block lifespan management can be reduced. This ensures that the data to be written can continue to be stored even when the dynamic buffer block set cannot accommodate it, thus balancing write performance, storage capacity, and physical block lifespan management, effectively solving the problem of the impact of mixing different data storage modes on physical block lifespan management in related technologies.
Smart Images

Figure CN122470132B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and more specifically, to a data storage method and a storage device. Background Technology
[0002] As electronic devices increasingly demand higher storage capacity, read / write performance, and data reliability, storage devices such as eMMC (embedded MultiMediaCard), UFS (Universal Flash Storage), and SSD (Solid State Drive) are widely used in mobile terminals, automotive devices, industrial control equipment, and consumer electronics. These storage devices typically consist of multiple physical blocks, and can store data to be written to the corresponding physical blocks based on host write requests.
[0003] In NAND flash (Not AND Flash) storage devices, physical blocks can use different data storage modes to store data. For example, some data can be stored using a data storage mode with higher reliability and faster write speed, while other data can be stored using a data storage mode with higher storage density.
[0004] However, different data storage modes have varying lifespans for physical blocks. During storage device operation, physical blocks may have different data storage histories. If the data storage modes used in the past are not distinguished during data storage, the historical impact of different data storage modes may be superimposed on the same physical block, thus affecting the lifespan management of the physical block.
[0005] Therefore, the problem of the mixed use of different data storage modes affecting physical block lifetime management still needs to be solved. Summary of the Invention
[0006] This application provides a data storage method and a storage device, which can solve the problem of the mixed use of different data storage modes affecting the management of physical block lifetimes in related technologies. The technical solutions are as follows:
[0007] According to one aspect of this application, a data storage method is applied to a storage device, the storage device including a plurality of physical blocks, the physical blocks including clean physical blocks determined based on historical pattern information; the clean physical block refers to a physical block that has not experienced data storage different from a first storage mode; the historical pattern information is used to indicate the historical data storage mode of the physical block; the storage device is provided with an optional storage area; the method includes: acquiring data to be written; querying a dynamic buffer block set in the optional storage area; wherein the dynamic buffer block set includes at least one of the clean physical blocks; if there is a free clean physical block in the dynamic buffer block set, then selecting a first target physical block from the free clean physical blocks, and storing the data to be written in the first target physical block in the first storage mode; if there is no free clean physical block in the dynamic buffer block set, then selecting a second target physical block in the storage device according to a set write strategy, and storing the data to be written in the second target physical block.
[0008] According to one aspect of this application, a storage device includes a storage medium and a controller; the storage medium includes a plurality of physical blocks; the controller is connected to the storage medium and is configured to perform the data storage method described above.
[0009] In the above technical solution, after acquiring the data to be written, the storage device first queries the dynamic buffer block set in the available storage area to determine if there are any free, clean physical blocks. Since a clean physical block is a physical block that has not undergone data storage different from the first storage mode, if a free clean physical block exists in the dynamic buffer block set, the data to be written is stored in that free clean physical block in the first storage mode. If no free clean physical block exists in the dynamic buffer block set, the storage device then selects a second target physical block according to the set write strategy and stores the data to be written in the second target physical block. Therefore, while prioritizing the use of free clean physical blocks for storage in the first storage mode, the impact of mixing different data storage modes on physical block lifespan management can be reduced. This ensures that the data to be written can continue to be stored even when the dynamic buffer block set cannot accommodate it, thus balancing write performance, storage capacity, and physical block lifespan management, effectively solving the problem of the impact of mixing different data storage modes on physical block lifespan management in related technologies. Attached Figure Description
[0010] Figure 1 This is a schematic diagram based on the implementation environment involved in this application;
[0011] Figure 2 This is a flowchart illustrating a data storage method according to an exemplary embodiment;
[0012] Figure 3 This is a structural block diagram of a data storage device according to an exemplary embodiment. Detailed Implementation
[0013] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings. Similar elements in different embodiments are referred to by associated similar element reference numerals. In the following embodiments, many details are described to facilitate a better understanding of this application. However, those skilled in the art will readily recognize that some features may be omitted in different situations, or may be replaced by other elements, materials, or methods. In some cases, certain operations related to this application are not shown or described in the specification. This is to avoid obscuring the core parts of this application with excessive description. For those skilled in the art, detailed description of these related operations is not necessary; they can fully understand the related operations based on the description in the specification and general technical knowledge in the art.
[0014] Furthermore, the features, operations, or characteristics described in the specification can be combined in any suitable manner to form various embodiments. At the same time, the steps or actions in the method description can be rearranged or adjusted in a manner obvious to those skilled in the art. Therefore, the various orders in the specification and drawings are only for the clear description of a particular embodiment and do not imply a necessary order, unless otherwise stated that a particular order must be followed.
[0015] The serial numbers assigned to components in this document, such as "first" and "second," are used only to distinguish the objects being described and have no sequential or technical meaning. Unless otherwise specified, the terms "connection" and "linkage" used in this application include both direct and indirect connections (linkages).
[0016] The following is an introduction and explanation of several terms used in this application:
[0017] SLC mode, Single Level Cell mode;
[0018] XLC mode, X Level Cell mode, where X represents an integer greater than 1;
[0019] MLC mode, Multi Level Cell mode;
[0020] TLC mode, Triple Level Cell mode;
[0021] QLC mode, Quad Level Cell mode.
[0022] As mentioned earlier, different data storage modes result in varying lifespans of physical blocks during the data storage process of storage devices. If the same physical block is repeatedly used by different data storage modes at different stages, the lifespan of that physical block may be affected by multiple data storage modes simultaneously.
[0023] Specifically, in storage devices, different data storage modes all affect the write speed, storage density, and lifespan of physical blocks. Taking SLC mode as the first storage mode and XLC mode as the second storage mode as an example, SLC mode usually has a faster write speed and better reliability, but it can store less data per unit of physical storage space; XLC mode can increase the data storage capacity per unit of physical storage space, but its write speed and lifespan differ from SLC mode.
[0024] During the research and development process, the applicant initially considered setting up a buffer area and ensuring that the physical blocks within the buffer area stored data only in the first storage mode. This approach allows for faster write speeds for data entering the buffer area, and because the physical blocks in the buffer area are not used in conjunction with the second storage mode, it also facilitates lifetime management of these physical blocks. However, the applicant further discovered limitations in configuring the fixed buffer area's capacity: if the fixed buffer area is set too large, it will consume a significant amount of physical storage resources, potentially affecting the effective storage capacity provided by the storage device; if the fixed buffer area is set too small, it may fill up quickly during continuous writing by the host or when the amount of data to be written is large, making it difficult for subsequent data to continue to be buffered and stored in the first storage mode.
[0025] Based on the above understanding, the applicant further considered setting up dynamically usable buffer resources outside the fixed buffer area. However, if free physical blocks in the optional storage area are directly used as dynamic buffer resources, physical blocks that have already undergone data storage in the second storage mode may be reused as buffer physical blocks in the first storage mode. Since these physical blocks already have a data storage history different from the first storage mode, continuing to use them as buffer resources in the first storage mode may cause the lifetime impact of different data storage modes to be superimposed on the same physical block, thereby affecting the accuracy of physical block lifetime management.
[0026] Therefore, the applicant further realized that dynamic buffer resources should not be determined solely based on whether a physical block is currently idle, but should also be determined in conjunction with the historical data storage modes of the physical block. For physical blocks in the optional storage area that have not experienced data storage different from the first storage mode, they can be recorded as clean physical blocks in the dynamic buffer block set. When fixed buffer resources are insufficient or buffer write capacity needs to be expanded, the data to be written is stored in the free clean physical blocks in the dynamic buffer block set in the first storage mode. In this way, the buffer write capacity in the first storage mode can be expanded without occupying too much physical storage resources, and the impact of mixing different data storage modes on physical block lifespan management can be reduced.
[0027] To this end, this application provides a data storage method that can determine a clean physical block suitable for data storage in a first storage mode from the selectable storage area based on the historical mode information corresponding to the physical block, and prioritize storing the data to be written to the clean physical block when there is a free clean physical block, thereby reducing the impact of mixing different data storage modes on the lifespan management of physical blocks.
[0028] Accordingly, this data storage method is applicable to data storage devices that can be deployed in storage equipment. The storage equipment can be an eMMC storage device, a UFS storage device, an SSD storage device, or other NAND flash memory storage devices.
[0029] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0030] Figure 1 This is a schematic diagram of an implementation environment involved in a data storage method. It should be noted that this implementation environment is merely an example adapted to the present invention and should not be considered as providing any limitation on the scope of the invention.
[0031] The implementation environment includes storage device 110 and host device 130.
[0032] Specifically, the storage device 110 can be an eMMC storage device, a UFS storage device, an SSD storage device, or other NAND flash memory storage devices, without any specific limitations.
[0033] The storage device includes multiple physical blocks, including clean physical blocks determined based on historical mode information; a clean physical block refers to a physical block that has not experienced data storage different from the first storage mode; historical mode information is used to indicate the historical data storage mode of the physical block; the storage device is equipped with optional storage areas.
[0034] The host device 130 can be an electronic device such as a desktop computer, laptop computer, or server, or it can be a computer cluster consisting of multiple servers, or even a cloud computing center consisting of multiple servers. The host device 130 is used to provide backend services.
[0035] The host device 130 and the storage device 110 establish a network communication connection in advance via wired or wireless means, and data transmission between the host device 130 and the storage device 110 is realized through this network communication connection. The transmitted data includes, but is not limited to, data to be written.
[0036] In one application scenario, through the interaction between storage device 110 and host device 130, the host device sends the data to be written to storage device 110 for storage.
[0037] For storage device 110, the dynamic buffer block set in the selectable storage area is queried; wherein the dynamic buffer block set includes at least one clean physical block; if there is a free clean physical block in the dynamic buffer block set, a first target physical block is selected from the free clean physical blocks, and the data to be written is stored in the first target physical block in a first storage mode; if there is no free clean physical block in the dynamic buffer block set, a second target physical block is selected in the storage device according to the set write strategy, and the data to be written is stored in the second target physical block; thereby solving the problem of the mixed use of different data storage modes affecting the lifespan management of physical blocks in related technologies.
[0038] In one exemplary embodiment, this application also provides a storage device. The storage device may include a storage controller and a storage medium. The storage controller is connected to the storage medium and is used to control the storage medium to perform operations such as data storage, data retrieval, data migration, and physical block management.
[0039] The storage medium may include multiple physical blocks. Physical blocks include clean physical blocks determined based on historical mode information; a clean physical block is a physical block for which no data storage other than the first storage mode has occurred; historical mode information is used to indicate the historical data storage modes of the physical blocks. The storage medium has optional storage areas.
[0040] The storage controller may include a processing unit and a controller memory. The controller memory may be used to store firmware programs, historical mode information, etc. The processing unit may be used to execute the firmware programs stored in the controller memory to implement the data storage method described in any of the above embodiments.
[0041] In some embodiments, the storage controller acquires the data to be written and queries a set of dynamic buffer blocks in the selectable storage area. If a free, clean physical block exists in the set of dynamic buffer blocks, the storage controller stores the data to be written in the free, clean physical block using a first storage mode. If no free, clean physical block exists in the set of dynamic buffer blocks, the storage controller selects a target physical block in the storage device according to a set write policy and stores the data to be written in the target physical block.
[0042] Please see Figure 2 This application provides a data storage method, which is applicable to storage devices, such as electronic devices. Figure 1 The storage device 110 in the implementation environment is shown.
[0043] In the following method embodiments, for ease of description, the execution subject of each step of the method is a storage device as an example, but this does not constitute a specific limitation.
[0044] like Figure 2 As shown, the method may include the following steps:
[0045] Step 310: Obtain the data to be written.
[0046] First, it should be noted that the storage device includes multiple physical blocks, including clean physical blocks determined based on historical mode information; a clean physical block refers to a physical block that has not experienced data storage different from the first storage mode; historical mode information is used to indicate the historical data storage mode of the physical block; the storage device is provided with optional storage areas, that is, historical mode information can be used to characterize the storage mode used by the corresponding physical block in the previous data storage process.
[0047] For example, if a physical block has historically only used the first storage mode for data storage, or if the physical block has not experienced data storage different from the first storage mode, then the physical block can be recorded as a clean physical block in the dynamic buffer block set. If a physical block has historically experienced data storage different from the first storage mode, then the physical block is not considered a clean physical block in the dynamic buffer block set. Therefore, after acquiring the data to be written, the storage device can determine whether there are physical blocks in the selectable storage area suitable for storing the data to be written in the first storage mode by querying the dynamic buffer block set.
[0048] The data to be written can refer to data that needs to be stored in the storage device. The storage device can respond to a write request sent by the host device and obtain the data to be written corresponding to that write request. This write request can be used to instruct the storage device to store the data to be written into the corresponding physical block.
[0049] In some implementations, the data to be written may include user data, system data, cached data, or other data that needs to be written to the storage device; this application embodiment does not limit this. After obtaining the data to be written, the storage device can further determine the storage location of the data to be written based on the dynamic buffer block set in the optional storage area.
[0050] Step 330: Query the set of dynamic buffer blocks in the optional storage area.
[0051] The optional storage area can refer to a storage region within a storage device that can be used for physical block selection. The dynamic buffer block set can refer to the set of clean physical blocks within the optional storage area. The physical blocks in the dynamic buffer block set can be used as buffer storage resources in the first storage mode.
[0052] The dynamic buffer block set includes clean physical blocks determined based on historical pattern information. After subsequently acquiring the data to be written, the storage device can query the dynamic buffer block set to determine whether there are any free clean physical blocks available to store the data to be written in the first storage mode.
[0053] By setting a dynamic buffer block set, the buffer storage resources in the first storage mode can be expanded without pre-fixing excessive physical storage resources. Specifically, if a large number of physical blocks are directly fixed to store data only in the first storage mode, although buffer write capability can be improved, the data storage space available for the second storage mode will be reduced, which may affect the effective storage capacity provided by the storage device. If the fixed buffer resources are too small, in scenarios with a large amount of data to be written or continuous writes, the fixed buffer resources may be filled up quickly, making it difficult to continue buffering subsequent data in the first storage mode.
[0054] Based on this, the embodiments of this application query a dynamic buffer block set in the optional storage area, enabling physical blocks in the optional storage area that meet the historical mode conditions to be used as dynamic buffer storage resources. Therefore, the physical blocks in the dynamic buffer block set are not pre-fixed buffer physical blocks, but are dynamically determined based on the historical mode information and idle status of the physical blocks. This improves the buffer write capability in the first storage mode while ensuring the effective storage capacity of the storage device, and reduces the impact of mixing different data storage modes on physical block lifespan management.
[0055] Furthermore, by setting a dynamic buffer block set, the write performance of storage devices in burst write or sequential write scenarios can be improved. Specifically, the first storage mode typically corresponds to a lower data storage density, and it needs to distinguish fewer storage states during the write process. Therefore, compared to the second storage mode, the first storage mode usually has a faster write speed and better write stability.
[0056] Step 350: If there are free clean physical blocks in the dynamic buffer block set, select the first target physical block from the free clean physical blocks and store the data to be written in the first target physical block in the first storage mode.
[0057] Here, a free, clean physical block can refer to a clean physical block in the dynamic buffer block set that is currently available for writing data. After querying the dynamic buffer block set, if the storage device determines that there is a free, clean physical block in the dynamic buffer block set, it can select a first target physical block from the free, clean physical block and store the data to be written into the first target physical block according to the first storage mode.
[0058] In this embodiment, since the first target physical block is a clean physical block in the dynamic buffer block set, the first target physical block has never experienced data storage different from the first storage mode in its history. By storing the data to be written to the first target physical block in the first storage mode, the data to be written can continue to utilize the write performance corresponding to the first storage mode for storage, and avoids using physical blocks that already have a history of other data storage modes as buffer physical blocks in the first storage mode.
[0059] Therefore, when there are free clean physical blocks in the dynamic buffer block set, the storage device can prioritize using the free clean physical blocks for writing in the first storage mode, thereby expanding the buffer write resources in the first storage mode, reducing the situation where the second storage mode write process is entered prematurely due to insufficient fixed buffer resources, and reducing the impact of mixing different data storage modes on physical block lifespan management.
[0060] In one embodiment, after the above-mentioned dynamic buffer block set contains free clean physical blocks, the following steps may be further included: determining whether the data to be written can be stored in a free clean physical block based on the size of the data to be written and the number of free clean physical blocks; if yes, selecting a first target physical block from the free clean physical blocks and storing the data to be written in the first target physical block in a first storage mode; if no, selecting a second target physical block in the storage device according to the set write strategy and storing the data to be written in the second target physical block in a second storage mode.
[0061] Among them, the size of the data to be written can be used to characterize the storage space required by the data to be written, and the number of free clean physical blocks can be used to characterize the buffer storage resources that the dynamic buffer block set can currently provide in the first storage mode.
[0062] Since clean physical blocks are used for data storage in the first storage mode, the storage device can determine the available buffer capacity that the dynamic buffer block set can currently provide based on the number of free clean physical blocks and the amount of data that each clean physical block can store in the first storage mode.
[0063] If the size of the data to be written is less than or equal to the available buffer capacity, it can be determined that the data to be written can be stored in a free, clean physical block. In this case, the storage device can select a first target physical block from the free, clean physical blocks and store the data to be written in the first target physical block using a first storage mode.
[0064] If the amount of data to be written exceeds the available buffer capacity, it can be determined that the entire amount of data to be written cannot be stored in a free, clean physical block. In this case, the storage device can select a second target physical block according to the set write strategy and store the data to be written in the second target physical block using a second storage mode.
[0065] In this second storage mode, the amount of data stored per unit of physical storage space is greater than that of the first storage mode. In other words, compared to the first storage mode, the second storage mode can store more data within the same physical storage space. Therefore, when there are insufficient free physical blocks to hold the data to be written, storing the data to be written in the second target physical block using the second storage mode can improve the utilization of physical storage space and prevent the normal storage of the data to be written from being affected by insufficient available buffer capacity in the dynamic buffer block set.
[0066] Step 370: If there is no free clean physical block in the dynamic buffer block set, then select the second target physical block in the storage device according to the set write strategy, and store the data to be written in the second target physical block.
[0067] The write policy setting can be a write policy used in the storage device firmware for regular physical block allocation. Specifically, the write policy setting can be used not only to determine the second target physical block corresponding to the data to be written, but also to determine the data storage mode adopted by the data to be written in the second target physical block.
[0068] In one implementation, step 370 further includes: selecting a free physical block from the physical blocks in the optional storage area that do not belong to the dynamic buffer block set as the second target physical block.
[0069] In this context, physical blocks in the optional storage area that do not belong to the dynamic buffer block set can refer to physical blocks that are not recorded as clean physical blocks or that are not currently used as dynamic buffer resources. If no free clean physical blocks exist in the dynamic buffer block set, the storage device can search for free physical blocks among the physical blocks in the optional storage area that do not belong to the dynamic buffer block set, according to a set write policy, and use the found free physical block as the second target physical block.
[0070] For example, the write policy can be set based on the free block pool in the storage device, the number of physical block erases, the wear leveling policy, the data hot / cold attributes, the current writable page status, the amount of data to be written, and / or the current operating status of the storage device, to determine the second target physical block and the corresponding data storage mode. The data storage mode corresponding to the second target physical block can be either the first storage mode or the second storage mode, and this application embodiment does not limit this.
[0071] Specifically, the storage device can determine the second target physical block and the corresponding data storage mode based on factors such as the data type, data volume, write performance requirements, number of free physical blocks in the optional storage area, number of physical block erases, and wear leveling status.
[0072] The data storage mode may include a first storage mode and a second storage mode.
[0073] In one implementation, if the data to be written is data for which writing speed needs to be prioritized, or if the storage device determines, according to the set writing strategy, that there are still physical blocks available for writing in the first storage mode, then the data to be written can be stored in the second target physical block in the first storage mode.
[0074] In another implementation, the write strategy can determine the data storage mode corresponding to the second target physical block based on the hot / cold attribute of the data to be written. The hot / cold attribute characterizes the likelihood of the data to be written being accessed, updated, or migrated subsequently. For example, if the data to be written is "hot" data (data accessed or updated frequently), the storage device can prioritize using the first storage mode according to the set write strategy to improve response speed during subsequent writes or updates. If the data to be written is "cold" data (data accessed or updated infrequently), the storage device can use the second storage mode according to the set write strategy to increase the data storage capacity per unit physical storage space.
[0075] Therefore, even if there are no free, clean physical blocks in the dynamic buffer block set, the storage device can still complete the storage of the data to be written according to the set write strategy, and can flexibly determine the second target physical block and its corresponding data storage mode according to the actual write requirements, physical block status and storage device operating status.
[0076] In one embodiment, the first storage mode is SLC mode and the second storage mode is XLC mode; wherein, XLC mode includes MLC mode, TLC mode or QLC mode.
[0077] SLC mode refers to a storage mode where each storage cell stores 1 bit of data. Because SLC mode requires fewer data states to be distinguished in a single storage cell, it typically has faster write speeds, better data reliability, and lower write endurance, but the amount of data that can be stored per unit of physical storage space is relatively small.
[0078] MLC, TLC, and QLC modes can all be considered XLC modes. MLC mode refers to a storage mode where each storage cell stores 2 bits of data, TLC mode refers to a storage mode where each storage cell stores 3 bits of data, and QLC mode refers to a storage mode where each storage cell stores 4 bits of data. Compared to SLC mode, XLC mode can increase the amount of data stored per unit of physical storage space, thus improving the effective storage capacity of the storage device; however, because each storage cell needs to distinguish more data states, its write speed, data reliability, and write endurance typically differ from SLC mode.
[0079] Therefore, in this embodiment, SLC mode can be used as the first storage mode so that when there is a free clean physical block, the data to be written is preferentially stored in the free clean physical block, thereby utilizing the faster write speed and better lifespan of SLC mode for buffer storage. Correspondingly, when there is no free clean physical block in the dynamic buffer block set, the storage device can select a second target physical block according to the set write strategy, and determine the corresponding data storage mode according to the set write strategy, so as to balance write performance, effective storage capacity and physical block lifespan management.
[0080] Through the above process, after acquiring the data to be written, the storage device first queries the dynamic buffer block set in the available storage area to determine if there are any free, clean physical blocks. Since a clean physical block is a physical block that has not undergone data storage different from the first storage mode, if a free clean physical block exists in the dynamic buffer block set, the data to be written is stored in that free clean physical block in the first storage mode. If no free clean physical block exists in the dynamic buffer block set, the storage device then selects a second target physical block according to the set write strategy and stores the data to be written in the second target physical block. Therefore, while prioritizing the use of free clean physical blocks for storage in the first storage mode, the impact of mixing different data storage modes on physical block lifespan management can be reduced, ensuring that the data to be written can continue to be stored even when the dynamic buffer block set cannot accommodate it, thus balancing write performance, storage capacity, and physical block lifespan management.
[0081] In an exemplary embodiment, prior to step 330, the method may further include the following steps:
[0082] Step 410: Obtain the historical mode information corresponding to the physical blocks of the optional storage area.
[0083] Historical pattern information is used to indicate the historical data storage patterns of physical blocks. In other words, the storage device can record historical pattern information for physical blocks in optional storage areas to characterize the data storage patterns used by the corresponding physical block during historical data storage. For example, historical pattern information can be used to indicate whether the corresponding physical block has undergone data storage different from a first storage pattern.
[0084] Step 430: If the historical mode information corresponding to the physical block indicates that the physical block has not undergone data storage different from the first storage mode, then the physical block is regarded as a pure physical block in the dynamic buffer block set.
[0085] In other words, the storage device can filter physical blocks in the selectable storage area based on the historical mode information corresponding to the physical blocks in the selectable storage area. If the historical mode information corresponding to a physical block indicates that the physical block has not experienced data storage different from the first storage mode, then the physical block can be considered to meet the condition of a pure physical block and is included as a pure physical block in the dynamic buffer block set. If the historical mode information corresponding to a physical block indicates that the physical block has experienced data storage different from the first storage mode, then the physical block is not included as a pure physical block in the dynamic buffer block set.
[0086] Furthermore, the dynamic buffer block set in this embodiment does not need to be fixed at the factory. That is, the storage device does not need to permanently divide certain physical blocks in the optional storage area into pure physical blocks in the dynamic buffer block set in advance at the factory stage. Instead, the dynamic buffer block set can be dynamically updated during the operation of the storage device based on the historical mode information corresponding to each physical block.
[0087] Specifically, as the storage device continuously performs data storage operations, physical blocks in the optional storage area may have different data storage states at different times. For physical blocks whose historical mode information indicates that no data storage different from the first storage mode has occurred, the storage device can record the physical block as a clean physical block in the dynamic buffer block set.
[0088] In some cases, clean physical blocks may also be stored in a way that differs from the first storage mode. For example, when there are insufficient physical blocks in the optional storage area that do not belong to the dynamic buffer block set, insufficient available capacity of free physical blocks in the optional storage area that do not belong to the dynamic buffer block set, a large amount of data to be written, or when the storage device needs to prioritize ensuring that the data to be written can be stored normally, the storage device may store clean physical blocks that originally belong to the dynamic buffer block set in the second storage mode.
[0089] In this scenario, although the clean physical block has not undergone any data storage different from the first storage mode prior to this data storage, it no longer meets the condition of "no data storage different from the first storage mode" because the current data storage uses the second storage mode. Therefore, the storage device can update the historical mode information corresponding to the clean physical block according to the actual storage mode used in this data storage, and cancel the record of the clean physical block as a clean physical block based on the updated historical mode information. In other words, it can remove the clean physical block from the dynamic buffer block set and use it as a regular physical block in the optional storage area.
[0090] In this way, the dynamic buffer block set can be updated as physical blocks are actually stored, rather than relying on a fixed configuration at the factory. This avoids pre-setting excessive physical blocks as buffer resources at the time of storage device shipment, thus reducing the impact on effective storage capacity configuration. Furthermore, it allows for timely adjustment of physical blocks in the dynamic buffer block set based on the actual data storage patterns that have occurred, reducing the likelihood of physical blocks that have undergone data storage different from the initial storage pattern continuing to be used as clean physical blocks. This improves the matching degree between the dynamic buffer block set and the actual operating state of the storage device, and reduces the impact of mixing different data storage patterns on physical block lifespan management.
[0091] In an exemplary embodiment, after step 430, the above method may further include the following steps:
[0092] Step 510: After the pure physical block is stored, update the historical mode information corresponding to the pure physical block according to the actual storage mode used for this data storage.
[0093] The actual storage mode refers to the data storage mode actually used when the clean physical block is stored. After each data storage event, the storage device can update the historical mode information corresponding to the clean physical block based on the actual storage mode used in that data storage. Therefore, the historical mode information can be updated as the clean physical block's data storage process progresses.
[0094] Step 530: If the actual storage mode used for this data storage of the pure physical block is different from the first storage mode, then update the historical mode information corresponding to the pure physical block to indicate that the pure physical block has undergone data storage different from the first storage mode.
[0095] In other words, when the actual storage mode used for the current data storage of a clean physical block differs from the first storage mode, it means that the clean physical block no longer meets the condition of "no data storage different from the first storage mode has occurred". At this time, the storage device can update the historical mode information corresponding to the clean physical block, so that the updated historical mode information can indicate that the clean physical block has undergone data storage different from the first storage mode.
[0096] In one embodiment, step 510 may be followed by the following step: if the actual storage mode used for the current data storage of the clean physical block is the first storage mode, then the clean physical block is allowed to remain in the dynamic buffer block set. That is, when the current data storage of the clean physical block still uses the first storage mode, the clean physical block still satisfies the condition of "no data storage different from the first storage mode has occurred", and therefore can continue to be managed as a clean physical block in the dynamic buffer block set.
[0097] Step 550: Based on the updated historical pattern information, cancel the record of the pure physical block as a pure physical block and remove the pure physical block from the dynamic buffer block set.
[0098] Specifically, if the updated historical mode information indicates that a clean physical block has undergone data storage different from the first storage mode, the storage device can cancel the record of that physical block as a clean physical block and remove it from the dynamic buffer block set. This prevents physical blocks that have undergone data storage different from the first storage mode from continuing to be used as clean physical blocks in the dynamic buffer block set.
[0099] Furthermore, physical blocks that have undergone data storage different from the first storage mode can no longer be managed as pure physical blocks in the dynamic buffer block set. This is because the core condition for a pure physical block is that it has not undergone data storage different from the first storage mode; once a physical block has undergone data storage different from the first storage mode, its historical mode information no longer meets the criteria for a pure physical block.
[0100] In other words, after a data storage event different from the first storage mode has occurred, the data storage history of that physical block has been affected by the other data storage modes, which can be understood as its pure state being corrupted. If the physical block is still kept in the dynamic buffer block set and continues to be buffered as a pure physical block in the first storage mode, the same physical block may be affected by the lifetimes of different data storage modes simultaneously, thus affecting the accuracy of physical block lifetime management. Therefore, after the historical mode information indicates that the physical block has undergone data storage different from the first storage mode, it is necessary to cancel its record as a pure physical block and remove it from the dynamic buffer block set.
[0101] In conjunction with the above embodiments, the storage device can manage the admission, retention, and removal of clean physical blocks through historical mode information: physical blocks that have not undergone data storage different from the first storage mode can be added to the dynamic buffer block set as clean physical blocks; clean physical blocks that are still storing data in the first storage mode can be allowed to remain in the dynamic buffer block set; and physical blocks that have undergone data storage different from the first storage mode are removed from the dynamic buffer block set. This improves the accuracy of clean physical block management in the dynamic buffer block set and reduces the impact of mixing different data storage modes on physical block lifetime management.
[0102] In one exemplary embodiment, the physical block includes a fixed physical block, and the storage device further includes a fixed buffer; the fixed buffer includes a fixed physical block configured to store data only in a first storage mode.
[0103] Specifically, the fixed physical blocks are not used to store data in the second storage mode, nor are they used to store data in any other data storage mode different from the first storage mode. In other words, the fixed physical blocks in the fixed buffer do not participate in the mixing of the first and second storage modes, but always store data according to the first storage mode.
[0104] Before step 310, the above method may also include the following steps:
[0105] Step 610: Determine whether there are any free fixed physical blocks in the fixed buffer.
[0106] After acquiring the data to be written, the storage device can first determine whether there are any free fixed physical blocks in the fixed buffer. A free fixed physical block can be a fixed physical block in the fixed buffer that is not currently storing data to be written, or a fixed physical block that is currently available for writing data to be written.
[0107] Step 630: If there are any free fixed physical blocks, select a third target physical block from the free fixed physical blocks and store the data to be written in the third target physical block in the first storage mode.
[0108] Specifically, when there are free fixed physical blocks in the fixed buffer, the storage device can preferentially select a third target physical block from the free fixed physical blocks and store the data to be written in the third target physical block using the first storage mode. Since the third target physical block is a fixed physical block in the fixed buffer and is only used to store data in the first storage mode, the mixing of the third target physical block between the first storage mode and the second storage mode can be avoided.
[0109] It's important to note that the capacity of the fixed buffer should generally not be set too large. This is because the fixed physical blocks in the fixed buffer are configured to store data only in the first storage mode, and the data storage capacity per unit of physical storage space corresponding to the first storage mode is typically lower than that corresponding to the second storage mode. Therefore, while allocating too many physical blocks to the fixed buffer can increase buffered write resources in the first storage mode, it will consume more physical storage space, potentially reducing the effective storage capacity that the storage device can provide.
[0110] On the other hand, if the fixed buffer is set too small, when the amount of data to be written is large or the host is writing continuously, the free fixed physical blocks in the fixed buffer may be consumed quickly, making it difficult for subsequent data to be written to continue to be buffered and stored in the first storage mode through the fixed buffer. Therefore, the capacity configuration of the fixed buffer needs to be balanced between write performance, effective storage capacity, and physical block lifespan management.
[0111] In one embodiment, the capacity of the fixed buffer can be determined based on the customer's capacity requirements, application scenario, and write performance requirements of the storage device. For example, when configuring the capacity of the storage device, the effective storage capacity that the storage device needs to provide can be determined first based on customer requirements, and the typical write data volume, continuous write frequency, and write speed requirements of the storage device can be determined based on the application scenario. While ensuring that the effective storage capacity provided by the storage device meets the customer's capacity requirements, a portion of physical blocks can be partitioned from the multiple physical blocks of the storage device as fixed physical blocks in the fixed buffer, so that this portion of fixed physical blocks stores data only in a first storage mode. Thus, while meeting the customer's capacity requirements, a certain amount of first storage mode buffer write resources can be provided for the data to be written.
[0112] Furthermore, after determining whether there are any free fixed physical blocks in the fixed buffer, the storage device can also determine the amount of data to be written and the number of free fixed physical blocks in the fixed buffer.
[0113] The size of the data to be written can be used to characterize the storage space required by the data to be written. The number of free fixed physical blocks can be used to characterize the buffer storage resources that the fixed buffer can currently provide in the first storage mode. Since the fixed physical blocks are set to store data only in the first storage mode, the storage device can determine the available buffer capacity that the fixed buffer can currently provide based on the number of free fixed physical blocks and the amount of data that can be stored in each fixed physical block in the first storage mode.
[0114] If the amount of data to be written is less than or equal to the available buffer capacity currently provided by the fixed buffer, then the fixed buffer can be determined to be able to handle the data to be written. In this case, the storage device can select a third target physical block from the free fixed physical blocks and store the data to be written in the third target physical block using the first storage mode.
[0115] If the amount of data to be written exceeds the available buffer capacity of the fixed buffer, it can be determined that the fixed buffer is insufficient to handle the data to be written. In this case, even if there are free fixed physical blocks in the fixed buffer, the storage device needs to continue querying the dynamic buffer block set in the optional storage area to determine if there are any free clean physical blocks available to store the data to be written.
[0116] In an exemplary embodiment, the above method may further include the following steps: if the data migration conditions are met, selecting a free physical block from the optional storage area; migrating the data to be written stored in the third target physical block to the free physical block; and erasing the third target physical block after the migration of the data to be written is completed.
[0117] The third target physical block is a fixed physical block in the fixed buffer that stores the data to be written in the first storage mode. Data migration conditions can be used to indicate that the data to be written in the fixed buffer needs to be migrated to an optional storage area. For example, data migration conditions may include the number of free fixed physical blocks in the fixed buffer being less than a set number, the used capacity of the fixed buffer reaching a set capacity, or the storage device being in an idle state, etc., which are not limited in this embodiment.
[0118] Specifically, if the write policy determines that the data to be written will be stored in a first storage mode, then the free physical block can be a clean physical block in the optional storage area; if the write policy determines that the data to be written will be stored in a second storage mode, then the free physical block can be a physical block in the optional storage area that does not belong to the dynamic buffer block set, or a physical block whose historical mode information indicates that data storage different from the first storage mode has occurred. Thus, the storage device can select a matching free physical block to receive the migrated data to be written based on the storage requirements of the data to be written and the historical mode information of the physical block.
[0119] Under the above embodiments, when the storage device has insufficient free fixed physical blocks, the used capacity of the fixed buffer is high, or the storage device is in an idle state, it can promptly migrate the data stored in the third target physical block to a free physical block in the optional storage area. On the one hand, it can release the fixed buffer, thereby ensuring that the fixed buffer can continue to provide buffer storage resources in the first storage mode for subsequent data to be written; on the other hand, it can determine whether the migrated data to be written is stored in the first storage mode or the second storage mode according to the set write strategy, so that the physical blocks match the storage requirements of the data to be migrated.
[0120] Furthermore, by performing data migration when the data migration conditions are met, long-term data occupation of the fixed buffer can be avoided, preventing subsequent write requests from utilizing the fixed buffer. Simultaneously, selecting free physical blocks during the migration process by incorporating historical physical block pattern information can reduce the impact of mixing different data storage modes on physical block lifetime management, thereby improving the efficiency of fixed buffer release and the accuracy of storage device lifetime management.
[0121] Step 650: If there are no free fixed physical blocks in the fixed buffer, then query whether there are any free clean physical blocks in the dynamic buffer block set.
[0122] It's understandable that if there are no free fixed physical blocks in the fixed buffer, it means that the fixed buffer is currently unable to handle new data to be written. In this case, the storage device can further query the dynamic buffer block set to determine if there are any free, clean physical blocks in the available storage area.
[0123] It should be noted that the clean physical blocks in the dynamic buffer block set are not the fixed physical blocks in the fixed buffer, but rather physical blocks in the optional storage area determined based on historical mode information. Since the clean physical blocks have not experienced data storage different from the first storage mode, if there are still free clean physical blocks in the dynamic buffer block set when there are no free fixed physical blocks in the fixed buffer, the storage device can use the free clean physical blocks as dynamic buffer resources in the first storage mode.
[0124] If no free, clean physical blocks are available in the dynamic buffer block set, it indicates that neither the fixed buffer nor the dynamic buffer block set can currently provide buffer storage resources under the first storage mode. In this case, the storage device can select a second target physical block according to the set write policy and store the data to be written in the second target physical block.
[0125] Through the hierarchical storage process described above, the storage device can prioritize the use of free fixed physical blocks in the fixed buffer for data storage in the first storage mode. If no free fixed physical blocks exist in the fixed buffer, then free clean physical blocks in the dynamic buffer set are used for data storage in the first storage mode. If neither the fixed buffer nor the dynamic buffer set can handle the data to be written, subsequent storage is performed according to the set write strategy. Therefore, while prioritizing the write performance and lifespan characteristics corresponding to the first storage mode, it avoids affecting the effective storage capacity of the storage device due to an excessively large fixed buffer capacity, and ensures that data to be written can continue to be stored even when buffer resources are insufficient.
[0126] Furthermore, since the clean physical blocks in the dynamic buffer block set are determined based on historical pattern information, the aforementioned hierarchical write process does not simply select free physical blocks from the available storage area after the fixed buffer is full. Instead, it prioritizes selecting clean physical blocks that have not undergone data storage different from the first storage mode. This allows for the expansion of the first storage mode buffer storage resources while reducing the impact of mixing different data storage modes on physical block lifetime management.
[0127] In an exemplary embodiment, the method further includes: updating the lifetime statistics of any physical block based on the historical mode information corresponding to any physical block in the storage device.
[0128] First, it should be noted that the unit write lifetime consumption corresponding to the first storage mode is lower than that corresponding to the second storage mode. Specifically, under the same or similar data write conditions, when a physical block uses the first storage mode for data storage, the lifetime consumption increment generated by the lifetime statistics of that physical block is less than the lifetime consumption increment generated when the physical block uses the second storage mode for data storage.
[0129] In one embodiment, the first storage mode is SLC mode and the second storage mode is XLC mode; wherein, XLC mode includes MLC mode, TLC mode or QLC mode.
[0130] For example, when the first storage mode is SLC mode and the second storage mode is XLC mode, since the data states that need to be distinguished by a single storage cell are less in SLC mode, the data writing process has a relatively small impact on the reliability of the physical block. Therefore, it can be considered that the unit write lifetime consumption corresponding to SLC mode is lower than that corresponding to XLC mode.
[0131] If the historical mode information indicates that any physical block stores data only through the first storage mode, then the lifetime statistics of that physical block are updated based on the first statistical rule. Here, the first statistical rule may refer to the lifetime statistics rule corresponding to the first storage mode.
[0132] Specifically, if the historical mode information indicates that a physical block has only been used for data storage in the first storage mode, the lifetime statistics of that physical block can be updated by writing lifetime consumption in units corresponding to the first storage mode. The lifetime statistics can be used to reflect the lifetime consumption of the physical block in the first storage mode.
[0133] If the historical mode information indicates that any physical block stores data only through the second storage mode, then the lifetime statistics of that physical block are updated based on the second statistical rule. Here, the second statistical rule can refer to the lifetime statistics rule corresponding to the second storage mode.
[0134] Specifically, if historical mode information indicates that a physical block has only been used for data storage in the second storage mode, the lifetime statistics of that physical block can be updated by writing lifetime consumption in units corresponding to the second storage mode. The lifetime statistics can be used to reflect the lifetime consumption of the physical block in the second storage mode.
[0135] It should be noted that parameters such as unit write lifetime consumption, erase count statistics, and write count conversion methods corresponding to different storage modes can be pre-configured by storage device manufacturers based on storage media type, process parameters, reliability test results, and firmware management strategies. Therefore, once a storage device determines that a physical block has historically stored data only in the first storage mode or only in the second storage mode, it can directly call the corresponding first or second statistical rule to update the physical block's lifetime statistics. This ensures that the lifetime statistics process matches the actual data storage modes used by the physical block, facilitating differentiated lifetime management for different physical blocks.
[0136] If the historical mode information indicates that any physical block stores data simultaneously through both the first and second storage modes, then the lifetime statistics of that physical block are updated based on the third statistical rule. The third statistical rule can be used to perform lifetime statistics on physical blocks that simultaneously have data storage history in both the first and second storage modes.
[0137] For example, the third statistical rule can update the lifetime statistics of the physical block by combining the number of times the physical block stores data through the first storage mode, the number of times it stores data through the second storage mode, and / or the unit write lifetime consumption corresponding to different storage modes.
[0138] It should be noted that for physical blocks that have data storage history in both the first and second storage modes, their lifetime statistics are usually more complex than those of physical blocks with only a single data storage mode history. This is because the unit write lifetime consumption differs for different storage modes, and the actual lifetime degradation of a physical block after switching between different storage modes may be affected by factors such as the number of writes, the amount of data written, the number of erases, the data retention time, and the characteristics of the storage medium's manufacturing process.
[0139] In practical applications, the lifetime conversion relationships under different storage modes and the lifetime degradation models after mixed use are often difficult to obtain accurately. In other words, lifetime degradation models based on limited information cannot fully and accurately reflect the actual lifetime consumption of physical blocks. That is to say, for physical blocks that have been used for data storage in both the first and second storage modes, if lifetime statistics are still performed according to the statistical rules corresponding to a single storage mode, it is easy to cause a mismatch between the lifetime statistics and the actual lifetime consumption of the physical block, resulting in distorted wear statistics, uneven distribution of physical blocks, and even premature failure of some physical blocks.
[0140] To ensure storage stability, storage devices typically employ a more conservative lifespan assessment method for physical blocks that have already undergone secondary storage mode data storage.
[0141] In one implementation, the third statistical rule can refer to the lifetime statistical rule corresponding to the second storage mode.
[0142] However, a conservative assessment might prematurely exclude physical blocks that still have a usable lifespan from the range of usable physical blocks, resulting in wasted usable physical blocks and reduced storage space utilization. In other words, for physical blocks that have already been used in combination with different storage modes, both optimistic and conservative statistical methods may result in inaccurate lifespan management.
[0143] For example, to ensure storage stability, storage devices may make a conservative lifetime assessment of physical blocks that have previously been used for data storage in QLC mode. However, a conservative assessment may prematurely exclude physical blocks that still have a usable lifetime from the range of physical blocks suitable for buffer storage in the first storage mode, resulting in wasted usable physical blocks and reduced storage space utilization.
[0144] Therefore, this application can identify clean physical blocks that have not experienced data storage different from the first storage mode through historical pattern information, and manage these clean physical blocks as physical blocks in the dynamic buffer block set. For physical blocks that have experienced data storage different from the first storage mode, their record as clean physical blocks is canceled, and they are removed from the dynamic buffer block set. This minimizes the mixing of different data storage modes on the same physical block, reducing the uncertainty in lifetime statistics caused by mixed use.
[0145] In summary, storage devices can differentiate between cases where a physical block has stored data only in the first storage mode, only in the second storage mode, and simultaneously in both modes, based on its historical mode information. The storage device can then update the physical block's lifetime statistics using the first, second, or third statistical rules, respectively. For physical blocks with only a single data storage mode history, lifetime statistics can be directly calculated based on the unit write lifetime consumption of the corresponding data storage mode, thus facilitating the acquisition of lifetime statistics results that match their actual storage mode.
[0146] For physical blocks that simultaneously possess data storage history in both the first and second storage modes, the lifetime degradation relationship after the mixing of different storage modes is difficult to determine accurately. Even when using a third statistical rule for lifetime statistics, it is usually only possible to perform differentiated statistics or conservative assessments based on limited information, making it difficult to completely eliminate lifetime statistics errors. Therefore, this application does not base the improvement of lifetime statistics accuracy entirely on the lifetime conversion of mixed-mode physical blocks. Instead, it identifies pure physical blocks that have not experienced data storage different from the first storage mode through historical mode information and manages these pure physical blocks as physical blocks in a dynamic buffer block set.
[0147] Therefore, on the one hand, differentiated lifetime statistics rules can be adopted for physical blocks with different data storage histories, avoiding simply using the same method to count single-mode and mixed-mode physical blocks; on the other hand, dynamic buffer block sets can minimize the mixing of the first and second storage modes on the same physical block, reducing the uncertainty in lifetime statistics caused by mixed use from the source. This helps improve the reliability of physical block lifetime management and reduces problems such as uneven physical block allocation, wasted available physical blocks, and premature failure of local physical blocks caused by lifetime statistics distortion.
[0148] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0149] The following are embodiments of the apparatus described in this application, which can be used to execute the data storage method involved in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the method embodiments of the data storage method involved in this application.
[0150] Please see Figure 3 This application provides a data storage device 900 configured in a storage device. The storage device includes multiple physical blocks, including clean physical blocks determined based on historical pattern information. A clean physical block refers to a physical block that has not experienced data storage different from a first storage pattern. The historical pattern information is used to indicate the historical data storage patterns of the physical blocks. The storage device is provided with optional storage areas.
[0151] The data storage device 900 includes, but is not limited to: a data acquisition module 910, a physical block query module 930, a first write module 950, and a second write module 970.
[0152] The data acquisition module 910 is used to acquire the data to be written.
[0153] The physical block query module 930 is used to query the set of dynamic buffer blocks in the optional storage area; wherein the set of dynamic buffer blocks includes at least one of the pure physical blocks.
[0154] The first write module 950 is used to select a first target physical block from the free clean physical blocks if there are free clean physical blocks in the dynamic buffer block set, and to store the data to be written into the first target physical block in the first storage mode.
[0155] The second write module 970 is used to select a second target physical block in the storage device according to a set write strategy if there is no free clean physical block in the dynamic buffer block set, and to store the data to be written into the second target physical block.
[0156] It should be noted that the data storage device provided in the above embodiments is only illustrated by the division of the above functional modules when storing data. In actual applications, the above functions can be assigned to different functional modules as needed. That is, the internal structure of the data storage device will be divided into different functional modules to complete all or part of the functions described above.
[0157] Furthermore, the data storage device and data storage method embodiments provided in the above embodiments belong to the same concept, and the specific way in which each module performs operations has been described in detail in the method embodiments, and will not be repeated here.
[0158] This document describes various exemplary embodiments with reference to them. However, those skilled in the art will recognize that changes and modifications can be made to the exemplary embodiments without departing from the scope of this document. For example, various operational steps and components for performing operational steps can be implemented in different ways depending on the specific application or considering any number of cost functions associated with the operation of the system (e.g., one or more steps can be deleted, modified, or combined with other steps).
[0159] Those skilled in the art will understand that all or part of the functions of the various methods in the above embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, which may include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the program is executed by a computer to achieve the above functions. For example, the program can be stored in the memory of a device, and when the program in the memory is executed by the processor, all or part of the above functions can be achieved. In addition, when all or part of the functions in the above embodiments are implemented by computer programs, the program can also be stored in a server, another computer, disk, optical disk, flash drive, or external hard drive, etc., and can be downloaded or copied to the memory of a local device, or the system of the local device can be updated. When the program in the memory is executed by the processor, all or part of the functions in the above embodiments can be achieved.
[0160] In the above embodiments, implementation can be achieved, in whole or in part, by software, hardware, firmware, or any combination thereof. Furthermore, as those skilled in the art will understand, the principles herein can be reflected in a computer program product on a computer-readable storage medium pre-loaded with computer-readable program code. Any tangible, non-transitory computer-readable storage medium may be used, including magnetic storage devices (hard disks, floppy disks, etc.), optical storage devices (CD-ROMs, DVDs, Blu-ray discs, etc.), flash memory, and / or the like. These computer program instructions can be loaded onto a general-purpose computer, special-purpose computer, or other programmable data processing apparatus to form a machine, such that instructions executing on the computer or other programmable data processing apparatus can generate means for performing a specified function. These computer program instructions can also be stored in a computer-readable storage medium that can instruct the computer or other programmable data processing apparatus to operate in a particular manner, such that instructions stored in the computer-readable storage medium can form an article of manufacture including means for implementing the specified function. The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to perform a series of operational steps on the computer or other programmable apparatus to produce a computer-implemented process, such that instructions executing on the computer or other programmable apparatus can provide steps for implementing the specified function.
[0161] While the principles herein have been illustrated in various embodiments, numerous modifications to the structure, arrangement, proportions, elements, materials, and components, particularly suited to specific environmental and operational requirements, may be used without departing from the principles and scope of this disclosure. These modifications and other alterations or alterations will be included within the scope of this document.
[0162] The foregoing specific descriptions have been described with reference to various embodiments. However, those skilled in the art will recognize that various modifications and changes can be made without departing from the scope of this disclosure. Therefore, considerations for this disclosure are to be illustrative rather than restrictive, and all such modifications are to be included within its scope. Similarly, advantages, other advantages, and solutions to problems with respect to various embodiments have been described above. However, benefits, advantages, solutions to problems, and any elements that produce these, or make them more explicit, should not be construed as critical, essential, or necessary. The term “comprising” and any other variations thereof as used herein are non-exclusive inclusion, meaning that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not expressly listed or not part of the process, method, system, article, or apparatus. Furthermore, the term “coupled” and any other variations thereof as used herein refer to physical connections, electrical connections, magnetic connections, optical connections, communication connections, functional connections, and / or any other connections.
[0163] Those skilled in the art will recognize that many changes can be made to the details of the above embodiments without departing from the basic principles of the invention. Therefore, the scope of the invention should be determined only by the claims.
Claims
1. A data storage method, characterized in that, This is applied to a storage device, which includes multiple physical blocks, including clean physical blocks determined based on historical pattern information; a clean physical block refers to a physical block that has not experienced data storage different from a first storage pattern; the historical pattern information is used to indicate the historical data storage pattern of the physical block; the storage device is provided with optional storage areas; The method includes: Get the data to be written; Query the set of dynamic buffer blocks in the optional storage area; wherein the set of dynamic buffer blocks includes the clean physical blocks; If there are free clean physical blocks in the dynamic buffer block set, then a first target physical block is selected from the free clean physical blocks, and the data to be written is stored in the first target physical block in the first storage mode. If there are no free, clean physical blocks in the dynamic buffer block set, a second target physical block is selected in the storage device according to the set write strategy, and the data to be written is stored in the second target physical block.
2. The data storage method according to claim 1, characterized in that, Before querying the set of dynamic buffer blocks in the optional storage area, the method further includes: Obtain the historical mode information corresponding to the physical blocks of the optional storage area; If the historical mode information corresponding to the physical block indicates that the physical block has not undergone data storage different from the first storage mode, then the physical block is regarded as a pure physical block in the dynamic buffer block set.
3. The data storage method according to claim 2, characterized in that, After the physical block is designated as a clean physical block in the dynamic buffer block set, the method further includes: After the pure physical block is stored, the historical mode information corresponding to the pure physical block is updated according to the actual storage mode used for this data storage. If the actual storage mode used for the data storage of the pure physical block this time is different from the first storage mode, then the historical mode information corresponding to the pure physical block is updated to indicate that the pure physical block has undergone data storage different from the first storage mode; Based on the updated historical pattern information, the record of the pure physical block as a pure physical block is cancelled, and the pure physical block is removed from the dynamic buffer block set.
4. The data storage method according to claim 3, characterized in that, After the data storage of the clean physical block occurs, and the historical mode information corresponding to the clean physical block is updated according to the actual storage mode used for this data storage, the method further includes: If the actual storage mode used for this data storage of the pure physical block is the first storage mode, then the pure physical block is allowed to remain in the dynamic buffer block set.
5. The data storage method according to any one of claims 1 to 4, characterized in that, The physical block includes a fixed physical block, and the storage device further includes a fixed buffer; the fixed buffer includes a fixed physical block configured to store data only in the first storage mode. Before querying the set of dynamic buffer blocks in the optional storage area, the method further includes: Determine whether there are any free fixed physical blocks in the fixed buffer; If there is an idle fixed physical block, a third target physical block is selected from the idle fixed physical blocks, and the data to be written is stored in the third target physical block in the first storage mode; If there is no free fixed physical block in the fixed buffer, then query whether there is a free clean physical block in the dynamic buffer block set.
6. The data storage method according to claim 5, characterized in that, After storing the data to be written to the third target physical block in the first storage mode, the method further includes: If the data migration conditions are met, select a free physical block from the optional storage area; The data to be written stored in the third target physical block is migrated to the free physical block; After the migration of the data to be written is completed, the third target physical block is erased.
7. The data storage method according to any one of claims 1 to 4, characterized in that, If there are free, clean physical blocks in the dynamic buffer block set, then a first target physical block is selected from the free, clean physical blocks, and the data to be written is stored in the first target physical block using the first storage mode, including: Based on the size of the data to be written and the number of free clean physical blocks, determine whether the data to be written can be stored in the free clean physical blocks; If so, the first target physical block is selected from the free clean physical blocks, and the data to be written is stored in the first target physical block in the first storage mode; If not, then a second target physical block is selected in the storage device according to the set write policy, and the data to be written is stored in the second target physical block in the second storage mode; wherein, the data storage amount per unit physical storage space corresponding to the second storage mode is greater than the data storage amount per unit physical storage space corresponding to the first storage mode.
8. The data storage method according to any one of claims 1 to 4, characterized in that, The method further includes: updating the lifetime statistics of any physical block according to the historical mode information corresponding to any physical block in the storage device; The step of updating the lifetime statistics information of any physical block based on the historical mode information corresponding to any physical block in the storage device includes: If the historical mode information indicates that any physical block stores data only through the first storage mode, then the lifetime statistics of any physical block are updated based on the first statistical rule. If the historical mode information indicates that any physical block stores data only through the second storage mode, then the lifetime statistics of any physical block are updated based on the second statistical rule; If the historical pattern information indicates that any physical block stores data simultaneously through the first storage mode and the second storage mode, then the lifetime statistics of any physical block are updated based on the third statistical rule. The write lifetime consumption per unit corresponding to the first storage mode is lower than that per unit write lifetime consumption per unit corresponding to the second storage mode.
9. The data storage method according to claim 8, characterized in that, The first storage mode is SLC mode, and the second storage mode is XLC mode; wherein, the XLC mode includes MLC mode, TLC mode or QLC mode.
10. A storage device, characterized in that, Including storage media and controller; The storage medium comprises multiple physical blocks; The controller is connected to the storage medium and is used to execute the data storage method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Flash memory device variable capacity device and method based on mixed mode
CN110569002A
Method and device for controlling physical blocks in NAND flash memory, and SSD equipment
CN113918091A