Flash bandwidth allocation method and device based on mixed media
By migrating the free plane data of the first medium to the second medium in the mixed storage medium, the problem of insufficient free blocks required for the write operation is solved, and the write operation efficiency is improved.
Patent Information
- Application Number
- CN202510762896.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-07-22
AI Technical Summary
In a hybrid storage medium, when the free block required for a write operation is larger than the actual free block, the prior art cannot effectively allocate flash bandwidth, resulting in a slower write operation speed.
By determining the number of free blocks of the first medium and the second medium, the data of the plane in the idle state in the first medium is migrated into the free block of the second medium, ensuring the success rate of data migration and freeing up enough free blocks to meet the write operation requirements.
When the free blocks required for the write operation are larger than the actual free block, reasonable flash bandwidth allocation is achieved, improving the write operation efficiency.
Smart Images

Figure CN120353402A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology or storage technology, and in particular to a flash bandwidth allocation method and device based on hybrid media. Background Art
[0002] Hybrid storage media, as the name suggests, is a hybrid structure of at least two pure storage media. Taking MLC-TLC hybrid storage media as an example, since MTL is fast and TLC is slow, when MLC-TLC hybrid storage media uses MTL write operations, when the number of MLC free blocks is less than a certain number, the data in MTL will be migrated to TLC so that the MLC free blocks can maintain a certain number of blocks to facilitate write operations.
[0003] However, when the number of free blocks required for write operations increases suddenly, the number of MLC free blocks cannot meet the write operation requirements, and the flash memory conversion layer will initiate garbage collection and / or data migration to free up more MTC free blocks to meet the write operation requirements. However, since the flash memory conversion layer will occupy the flash bandwidth for the MTL free block freeing operation, the bandwidth allocated to the write operation is reduced, thereby reducing the speed of the write operation. Therefore, how to achieve reasonable flash bandwidth allocation for hybrid storage media to improve the write operation efficiency when the free blocks required for the write operation are larger than the actual free blocks needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present application provide a flash bandwidth allocation method and device based on a hybrid medium, which can realize reasonable flash bandwidth allocation for hybrid storage media when the free blocks required for write operations are larger than the actual free blocks, so as to improve the write operation efficiency.
[0005] In a first aspect, an embodiment of the present application provides a flash bandwidth allocation method based on a hybrid medium, which is applied to an electronic device, wherein the electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the reading speed of the first medium is greater than the reading speed of the second medium; the method includes:
[0006] determining a first number of free blocks of the first medium;
[0007] When the first quantity is less than a preset quantity, determining a second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity;
[0008] determining a third number of free blocks of the second medium;
[0009] Determine the planes in the idle state in the first medium, and obtain m planes, where m is a positive integer;
[0010] According to the second quantity and the third quantity, migrate the data of the good blocks in the m planes to the idle blocks of the second medium.
[0011] In a second aspect, an embodiment of the present application provides a flash bandwidth allocation device based on a hybrid medium, which is applied to an electronic device. The electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than the read speed of the second medium; the flash bandwidth allocation device based on the hybrid medium includes: a first determination unit, a second determination unit, and a migration unit, where,
[0012] The first determination unit is configured to determine a first quantity of idle blocks in the first medium; when the first quantity is less than a preset quantity, determine a second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity;
[0013] The second determination unit is configured to determine a third quantity of idle blocks in the second medium; determine the planes in the idle state in the first medium, and obtain m planes, where m is a positive integer;
[0014] The migration unit is configured to migrate the data of the good blocks in the m planes to the idle blocks of the second medium according to the second quantity and the third quantity.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, a communication interface, and one or more programs. Among them, the above one or more programs are stored in the above memory and are configured to be executed by the above processor. The above programs include instructions for performing the steps in the first aspect of the embodiments of the present application.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. Among them, the above computer-readable storage medium stores a computer program for electronic data exchange. Among them, the above computer program enables a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application.
[0017] In a fifth aspect, an embodiment of the present application provides a computer program product. Among them, the above computer program product includes a non-transitory computer-readable storage medium storing a computer program. The above computer program is operable to enable a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application. The computer program product can be a software installation package.
[0018] Implementing the embodiments of the present application has the following beneficial effects:
[0019] It can be seen that the flash bandwidth allocation method and device based on a hybrid medium described in the embodiments of the present application are applied to an electronic device. The electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than that of the second medium. Determine the first quantity of free blocks in the first medium. When the first quantity is less than a preset quantity, it indicates that the free blocks required for the write operation are greater than the actual free blocks. Determine the second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity. Determine the third quantity of free blocks in the second medium. Determine the planes in the first medium that are in the idle state to obtain m planes, where m is a positive integer. Migrate the data of the good blocks in the m planes to the free blocks in the second medium according to the second quantity and the third quantity. That is, comparing the second quantity and the third quantity can ensure the success rate of migrating the data in the first medium to the second medium. When the data in the first medium can be successfully migrated to the second medium, when the free blocks required for the write operation are greater than the actual free blocks, enough free blocks can be vacated to meet the write operation requirements of the first medium. Thus, reasonable flash bandwidth allocation is achieved to improve the write operation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0021] Figure 1 is a schematic flowchart of a flash bandwidth allocation method based on a hybrid medium provided by an embodiment of the present application;
[0022] Figure 2 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
[0023] Figure 3 is a schematic structural diagram of a hybrid storage medium provided by an embodiment of the present application;
[0024] Figure 4 is a schematic structural diagram of another hybrid storage medium provided by an embodiment of the present application;
[0025] Figure 5 is a schematic structural diagram of another hybrid storage medium provided by an embodiment of the present application;
[0026] Figure 6It is a schematic structural diagram of another hybrid storage medium provided by an embodiment of the present application;
[0027] Figure 7 It is a schematic structural diagram of another electronic device provided by an embodiment of the present application;
[0028] Figure 8 It is a functional unit composition block diagram of a flash bandwidth allocation device based on a hybrid medium provided by an embodiment of the present application. Detailed implementation manners
[0029] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts belong to the scope of protection of the present application.
[0030] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally further include steps or units not listed, or may optionally further include other steps or units inherent to these processes, methods, products or devices.
[0031] Referring to "embodiment" in this article means that a specific feature, structure or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The appearance of this phrase in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0032] In the embodiments of the present application, the electronic device involved may be a device with storage capabilities. The electronic device may include various wearable devices with wireless communication functions (such as smart glasses, smart bracelets, Internet of Things devices (such as smart refrigerators, smart washing machines, smart TVs), smart watches, etc.), handheld devices, smart home devices, in-vehicle devices (such as dash cams, in-vehicle cameras, in-vehicle speakers, etc.), solid state disks (Solid State Disk or Solid State Drive, SSD), smart flash chips, computing devices or other processing devices connected to a wireless modem, and various forms of user equipment (User Equipment, UE), mobile stations (Mobile Station, MS), terminal devices (terminal device), etc.
[0033] In the embodiments of the present application, taking the SSD as an example, a plane is a key level inside the flash chip. It is located below the chip and die and above the block. Each plane contains multiple blocks, and each block contains multiple pages.
[0034] In the embodiments of the present application, the hybrid storage medium can be understood as: using different types of storage devices simultaneously in the same storage system. The hybrid storage medium may include at least one of the following: hard disk (HDD), solid state disk (SSD), flash memory, tape, etc., which are not limited herein.
[0035] In the embodiments of the present application, an idle plane, in short, is a plane in an idle state, or a plane that is in an idle state. Specifically, an idle plane may refer to those planes that are not currently in use or do not store valid data. On the contrary, a non-idle plane, in short, is a plane in a non-idle state, or a plane that is not in an idle state, and is a plane that is performing read and write operations.
[0036] In the embodiments of the present application, the hybrid storage medium can generally be understood as a hybrid structure of at least two pure storage media. For example, MLC-TLC hybrid storage medium, SLC-QLC hybrid storage medium, which are not limited herein.
[0037] In the embodiments of the present application, a good block (a good storage block) can be understood as a flash block that can normally perform read or write operations. A bad block (a bad storage block) can be understood as a flash block in the storage medium that cannot normally perform read or write operations.
[0038] The embodiments of the present application will be introduced in detail below.
[0039] Please refer to Figure 1 ,Figure 1 It is a schematic flowchart of a flash bandwidth allocation method based on a hybrid medium provided by an embodiment of the present application, which is applied to an electronic device. The electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than that of the second medium; the flash bandwidth allocation method based on the hybrid medium includes:
[0040] 101. Determine a first quantity of free blocks of the first medium.
[0041] In an embodiment of the present application, as Figure 2 shown, the electronic device may include a hybrid storage medium. The hybrid storage medium may include two or more pure storage media. For example, as Figure 3 shown, the hybrid storage medium may include a first medium and a second medium, and both the first medium and the second medium are pure storage media. For another example, as Figure 4 shown, the hybrid storage medium may include a first medium, a second medium, a third medium, …, and the first medium, the second medium, the third medium, … are all pure storage media.
[0042] In an embodiment of the present application, the read speed of the first medium is greater than that of the second medium. In a specific implementation, a first quantity of free blocks of the first medium may be determined. The first quantity may be only the number of good blocks in the first medium. The first quantity can be understood as the actual free blocks.
[0043] 102. When the first quantity is less than a preset quantity, determine a second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity.
[0044] Among them, the preset quantity may be set in advance or be the system default. The preset quantity is used to represent the free blocks required for an actual write operation. When the first quantity is less than the preset quantity, it means that the free blocks required for the write operation are greater than the actual free blocks.
[0045] Among them, in a specific implementation, the second quantity may be determined according to the preset quantity and the first quantity, and the second quantity is greater than or equal to the preset quantity. Thus, it is ensured that enough free blocks in the first medium are vacated to meet the write operation requirements.
[0046] 103. Determine a third quantity of free blocks of the second medium.
[0047] In an embodiment of the present application, a third quantity of free blocks of the second medium may be determined, and the third quantity may be the number of good blocks among the free blocks in the second medium.
[0048] 104. Determine the planes in the first medium that are in an idle state, and obtain m planes, where m is a positive integer.
[0049] In the embodiments of the present application, the first medium may include multiple planes. For the planes that may be in the read / write operation, they are not in the idle state. Based on this, the planes in the idle state in the first medium can be determined, and m planes are obtained, where m is a positive integer.
[0050] For example, as Figure 5 shown, the first medium may include multiple planes. Correspondingly, the second medium may also include multiple planes. Then, as Figure 6 shown, the first medium may include multiple planes, where the multiple planes may include at least one idle plane and at least one non-idle plane. Correspondingly, the second medium may also include multiple planes, where the multiple planes may include at least one idle plane and at least one non-idle plane.
[0051] 105. Migrate the data of the good blocks in the m planes to the idle blocks of the second medium according to the second quantity and the third quantity.
[0052] In the embodiments of the present application, the data of the good blocks in the m planes can be migrated to the idle blocks of the second medium according to the second quantity and the third quantity. Comparing the second quantity and the third quantity can ensure the success rate of migrating the data in the first medium to the second medium. When the data in the first medium can be successfully migrated to the second medium, when the number of idle blocks required for the write operation is greater than the actual number of idle blocks, enough idle blocks can be freed to meet the write operation requirements of the first medium. Thus, reasonable flash bandwidth allocation is achieved to improve the write operation efficiency.
[0053] In the embodiments of the present application, only the data in the good blocks of the first medium can be read and migrated, which improves the effectiveness of data migration and further ensures the data migration efficiency.
[0054] Correspondingly, in the embodiments of the present application, the data in the bad blocks of the first medium is not migrated, and the data in the bad blocks can be erased, which is equivalent to playing the role of "garbage collection", and further helps to improve the flash bandwidth utilization rate.
[0055] In some possible examples, for the above step 105, migrating the data of the good blocks in the m planes to the idle blocks of the second medium according to the second quantity and the third quantity can be implemented in the following manner:
[0056] When the second quantity is less than or equal to the third quantity, count the storage block quantity of the migratable good blocks of each plane in the m planes to obtain m fourth quantities;
[0057] Determine the sum of the m fourth quantities to obtain a first total quantity;
[0058] When the first total quantity is greater than or equal to the second quantity, select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities;
[0059] Migrate the data in the second quantity of storage blocks to the free blocks of the second medium.
[0060] Among them, when the second quantity is less than or equal to the third quantity, it means that the second medium has enough free blocks to meet the data migration of the first medium. On the contrary, when the second quantity is greater than the third quantity, it means that the second medium does not have enough free blocks to meet the data migration of the first medium, and the user can be prompted that the data migration operation cannot be completed.
[0061] Next, when the second quantity is less than or equal to the third quantity, the storage block quantity of the good blocks that can be migrated in each plane of the m planes can be counted to obtain m fourth quantities. In this way, the good blocks that cannot be migrated can not be migrated to ensure the effectiveness and legality of the migration.
[0062] Then, the sum of the m fourth quantities can be determined to obtain a first total quantity. When the first total quantity is greater than or equal to the second quantity, it means that enough free blocks can be vacated from the first medium to meet the write operation requirements. On the contrary, when the first total quantity is less than the second quantity, it means that enough free blocks cannot be vacated from the first medium to meet the write operation requirements. In this way, the effectiveness and legality of the migration can be further ensured.
[0063] Next, when enough free blocks can be vacated from the first medium to meet the write operation requirements, select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities. Finally, the data in the second quantity of storage blocks can be migrated to the free blocks of the second medium. In this way, the effectiveness and legality of the migration can be ensured. Furthermore, when the data in the first medium can be successfully migrated to the second medium, when the free blocks required for the write operation are greater than the actual free blocks, enough free blocks can be vacated to meet the write operation requirements of the first medium, so as to realize reasonable flash broadband allocation and improve the write operation efficiency.
[0064] In some possible examples, for the above step of selecting the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities, it can be implemented in the following manner:
[0065] Determine m weights according to the m fourth quantities, the sum of the m weights is 1, and the larger the fourth quantity, the larger the weight;
[0066] Determine m fifth quantities according to the m weights and the second quantity;
[0067] Determine the priority order of the migratable storage blocks in each of the m planes, obtaining m priority orders;
[0068] Select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities according to the m fifth quantities and the m priority orders.
[0069] In the embodiments of the present application, m weights can be determined according to the m fourth quantities, and the sum of the m weights is 1. The larger the fourth quantity, the larger the weight. Then, determine m fifth quantities according to the m weights and the second quantity, that is, determine the product between each weight and the second quantity to obtain the corresponding fifth quantity. Then, determine the priority order of the migratable storage blocks in each of the m planes, obtaining m priority orders. Finally, the second quantity of storage blocks can be selected from the storage blocks corresponding to the m fourth quantities according to the m fifth quantities and the m priority orders.
[0070] Specifically, m processes can be used to synchronously execute the process of selecting the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities according to the m fifth quantities and the m priority orders, with each of the m planes corresponding to one process; or, m threads can be used to synchronously execute the process of selecting the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities according to the m fifth quantities and the m priority orders, with each of the m planes corresponding to one thread. In this way, the determination efficiency of the storage blocks to be migrated can be ensured, and further, the read operation efficiency can be ensured.
[0071] In this example, on the one hand, more data of good blocks can be selected from the planes with more good blocks for migration. On the other hand, for each plane, good blocks with excellent performance are preferentially selected for data migration, so as to ensure the data migration efficiency. Further, when the data in the first medium can be successfully migrated to the second medium and the free blocks required for the write operation are greater than the actual free blocks, enough free blocks can be vacated to meet the write operation requirements of the first medium, thus realizing reasonable flash bandwidth allocation to improve the write operation efficiency.
[0072] In some possible examples, for the above step of determining the priority order of the migratable storage blocks in each of the m planes, obtaining m priority orders, it can be implemented in the following manner:
[0073] Determine the memory size and remaining erase count of each migratable storage block in the first plane, obtaining k memory sizes and k remaining erase counts, where the first plane is any one of the m planes; k is a positive integer;
[0074] Determine the evaluation values corresponding to the k memory sizes, obtaining k first evaluation values. The smaller the memory size, the larger the first evaluation value;
[0075] Determine the evaluation values corresponding to the k remaining erase counts, obtaining k second evaluation values; the larger the remaining erase count, the larger the second evaluation value;
[0076] Determine k target evaluation values based on the k first evaluation values and the k second evaluation values;
[0077] Determine the priority order of the migratable storage blocks in the first plane according to the k target evaluation values. The larger the target evaluation value, the higher the priority.
[0078] In the embodiments of the present application, taking the first plane as an example, where the first plane is any one of the m planes, the memory size and remaining erase count of each migratable storage block in the first plane can be determined, obtaining k memory sizes and k remaining erase counts. Each storage block corresponds to a memory size and a remaining erase count. The memory size reflects the data migration speed, and the remaining erase count reflects the performance of the storage block.
[0079] Furthermore, the mapping relationship between the preset memory size and the evaluation value can be pre-stored. Then, based on this mapping relationship, the evaluation values corresponding to the k memory sizes can be determined, obtaining k first evaluation values. The smaller the memory size, the larger the first evaluation value, that is, the smaller the memory size, the easier the migration and the faster the migration speed.
[0080] Correspondingly, the mapping relationship between the preset remaining erase count and the evaluation value can also be pre-stored. Then, based on this mapping relationship, the evaluation values corresponding to the k remaining erase counts can be determined, obtaining k second evaluation values; the larger the remaining erase count, the larger the second evaluation value, that is, the better the performance of the storage block, the more conducive it is to improving the migration efficiency.
[0081] Next, k target evaluation values can be determined based on the k first evaluation values and the k second evaluation values, that is, a weight pair can be obtained. The weight pair includes a first weight and a second weight. The first weight is the weight corresponding to the first evaluation value, and the second weight is the weight corresponding to the second evaluation value. The sum of the first weight and the second weight is 1. The weight pair can be set in advance or be the system default. For example, the weight pair is set based on experience, or the weight pair can be related to the attributes of the hybrid storage medium, or the weight pair can be related to the environmental parameters of the hybrid storage medium.
[0082] Among them, the attributes related to the hybrid storage medium may include at least one of the following: material, model, structure, performance, etc., which are not limited here.
[0083] Among them, the environmental parameters of the hybrid storage medium may include at least one of the following: physical environmental parameters, software environmental parameters, hardware environmental parameters, etc., which are not limited here. The physical environmental parameters may include at least one of the following: temperature, humidity, magnetic field interference intensity, weather, atmospheric pressure, etc., which are not limited here. The software environmental parameters may include at least one of the following: flash bandwidth, operating system, control algorithm, etc., which are not limited here. The hardware environmental parameters may include at least one of the following: hardware configuration parameters, hardware structure parameters, etc., which are not limited here.
[0084] Finally, the priority order of the migratable storage blocks of the first plane can be determined according to the k target evaluation values. The larger the target evaluation value, the higher the priority. In this way, the storage blocks with smaller memory size and better performance can be migrated first, so as to ensure the data migration efficiency. Furthermore, when the data in the first medium can be successfully migrated to the second medium and the free blocks required for the write operation are greater than the actual free blocks, enough free blocks can be vacated to meet the write operation requirements of the first medium, so as to achieve reasonable flash broadband allocation and improve the write operation efficiency.
[0085] In some possible examples, step 102 above, determining the second quantity according to the preset quantity and the first quantity, can be implemented as follows:
[0086] Determine a first difference between the preset quantity and the first quantity;
[0087] Determine a first adjustment parameter corresponding to the first difference;
[0088] Adjust the preset quantity according to the first adjustment parameter to obtain the second quantity.
[0089] In specific implementation, the difference between the preset quantity and the first quantity can be determined to obtain the first difference. Since the preset quantity is greater than the first quantity, it means that the first difference is a positive number.
[0090] Next, the mapping relationship between the preset difference and the adjustment parameter can be pre-stored. The adjustment parameter can be a positive number. The larger the difference, the larger the adjustment parameter. The value range of the adjustment parameter can be preset or system default. For example, the value range of the adjustment parameter can be 0 to 0.1, or 0 to 0.05. Furthermore, the first adjustment parameter corresponding to the first difference can be determined based on this mapping relationship. Finally, the preset quantity can be adjusted according to the first adjustment parameter to obtain the second quantity. The second quantity = (1 + the first adjustment parameter) * the preset quantity. When the free blocks required for the write operation are greater than the actual free blocks, the corresponding redundancy (adjustment parameter) can be dynamically set based on the difference between the free blocks required for the write operation and the actual free blocks. Thus, sufficient free blocks in the first medium can be ensured to meet the write operation requirements. Furthermore, when the free blocks required for the write operation are greater than the actual free blocks, reasonable flash bandwidth allocation can be achieved to improve the write operation efficiency.
[0091] It can be seen that the flash bandwidth allocation method based on the hybrid medium described in the embodiments of the present application is applied to an electronic device. The electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than the read speed of the second medium. Determine the first quantity of the free blocks of the first medium. When the first quantity is less than the preset quantity, it means that the free blocks required for the write operation are greater than the actual free blocks. Determine the second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity. Determine the third quantity of the free blocks of the second medium. Determine the planes in the first medium that are in the idle state to obtain m planes, where m is a positive integer. Migrate the data of the good blocks in the m planes to the free blocks of the second medium according to the second quantity and the third quantity. That is, comparing the second quantity and the third quantity can ensure the success rate of migrating the data in the first medium to the second medium. When the data in the first medium can be successfully migrated to the second medium, sufficient free blocks can be vacated to meet the write operation requirements of the first medium when the free blocks required for the write operation are greater than the actual free blocks. Thus, reasonable flash bandwidth allocation is achieved to improve the write operation efficiency.
[0092] Please refer to Figure 7 , 7 Figure 7 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. The electronic device includes a processor, a memory, a communication interface, and one or more programs. The above one or more programs are stored in the above memory and are configured to be executed by the above processor. In the embodiments of the present application, the electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than the read speed of the second medium; the above programs include instructions for performing the following steps:
[0093] Determine a first quantity of free blocks of the first medium;
[0094] When the first quantity is less than a preset quantity, determine a second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity;
[0095] Determine a third quantity of free blocks of the second medium;
[0096] Determine planes in the first medium that are in an idle state, obtaining m planes, where m is a positive integer;
[0097] Migrate data of good blocks in the m planes to free blocks of the second medium according to the second quantity and the third quantity.
[0098] In some possible examples, in terms of migrating data of good blocks in the m planes to free blocks of the second medium according to the second quantity and the third quantity, the above program includes instructions for performing the following steps:
[0099] When the second quantity is less than or equal to the third quantity, count the number of storage blocks of migratable good blocks in each of the m planes, obtaining m fourth quantities;
[0100] Determine a sum of the m fourth quantities, obtaining a first total quantity;
[0101] When the first total quantity is greater than or equal to the second quantity, select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities;
[0102] Migrate data in the second quantity of storage blocks to free blocks of the second medium.
[0103] In some possible examples, in terms of selecting the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities, the above program includes instructions for performing the following steps:
[0104] Determine m weights according to the m fourth quantities, the sum of the m weights is 1, and the larger the fourth quantity, the larger the weight;
[0105] Determine m fifth quantities according to the m weights and the second quantity;
[0106] Determine a priority order of migratable storage blocks in each of the m planes, obtaining m priority orders;
[0107] Select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities according to the m fifth quantities and the m priority orders.
[0108] In some possible examples, in determining the priority orders of the migratable storage blocks in each of the m planes to obtain m priority orders, the above program includes instructions for performing the following steps:
[0109] Determine the memory size and the remaining number of erasures of each migratable storage block in the first plane to obtain k memory sizes and k remaining numbers of erasures, where the first plane is any one of the m planes; k is a positive integer;
[0110] Determine the evaluation values corresponding to the k memory sizes to obtain k first evaluation values. The smaller the memory size, the larger the first evaluation value;
[0111] Determine the evaluation values corresponding to the k remaining numbers of erasures to obtain k second evaluation values; the larger the remaining number of erasures, the larger the second evaluation value;
[0112] Determine k target evaluation values according to the k first evaluation values and the k second evaluation values;
[0113] Determine the priority order of the migratable storage blocks in the first plane according to the k target evaluation values. The larger the target evaluation value, the higher the priority.
[0114] In some possible examples, in determining the second quantity according to the preset quantity and the first quantity, the above program includes instructions for performing the following steps:
[0115] Determine the first difference between the preset quantity and the first quantity;
[0116] Determine the first adjustment parameter corresponding to the first difference;
[0117] Adjust the preset quantity according to the first adjustment parameter to obtain the second quantity.
[0118] It can be seen that for the electronic device described in the embodiments of the present application, the electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than that of the second medium. Determine the first quantity of free blocks of the first medium. When the first quantity is less than a preset quantity, it indicates that the free blocks required for the write operation are greater than the actual free blocks. Determine the second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity. Determine the third quantity of free blocks of the second medium, determine the planes in the first medium that are in the free state, and obtain m planes, where m is a positive integer. Migrate the data of the good blocks in the m planes to the free blocks of the second medium according to the second quantity and the third quantity. That is, comparing the second quantity and the third quantity can ensure the success rate of migrating the data in the first medium to the second medium. When the data in the first medium can be successfully migrated to the second medium, when the free blocks required for the write operation are greater than the actual free blocks, enough free blocks can be vacated to meet the write operation requirements of the first medium. Thus, reasonable flash bandwidth allocation is achieved to improve the write operation efficiency.
[0119] Figure 8 It is a functional unit composition block diagram of a flash bandwidth allocation device 800 based on a hybrid medium involved in the embodiments of the present application. The flash bandwidth allocation device 800 based on a hybrid medium is applied to an electronic device, and the electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than that of the second medium; the flash bandwidth allocation device 800 based on a hybrid medium includes: a first determination unit 801, a second determination unit 802, and a migration unit 803, where
[0120] The first determination unit 801 is configured to determine the first quantity of free blocks of the first medium; when the first quantity is less than a preset quantity, determine the second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity;
[0121] The second determination unit 802 is configured to determine the third quantity of free blocks of the second medium; determine the planes in the first medium that are in the free state, and obtain m planes, where m is a positive integer;
[0122] The migration unit 803 is configured to migrate the data of the good blocks in the m planes to the free blocks of the second medium according to the second quantity and the third quantity.
[0123] In some possible examples, in terms of migrating the data of good blocks in the m planes to the free blocks of the second medium according to the second quantity and the third quantity, the migration unit 803 is specifically configured to:
[0124] When the second quantity is less than or equal to the third quantity, count the number of storage blocks of migratable good blocks in each of the m planes to obtain m fourth quantities;
[0125] Determine the sum of the m fourth quantities to obtain a first total quantity;
[0126] When the first total quantity is greater than or equal to the second quantity, select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities;
[0127] Migrate the data in the second quantity of storage blocks to the free blocks of the second medium.
[0128] In some possible examples, in terms of selecting the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities, the migration unit 803 is specifically configured to:
[0129] Determine m weights according to the m fourth quantities, the sum of the m weights is 1, and the larger the fourth quantity, the larger the weight;
[0130] Determine m fifth quantities according to the m weights and the second quantity;
[0131] Determine the priority order of the migratable storage blocks in each of the m planes to obtain m priority orders;
[0132] Select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities according to the m fifth quantities and the m priority orders.
[0133] In some possible examples, in terms of determining the priority order of the migratable storage blocks in each of the m planes to obtain m priority orders, the migration unit 803 is specifically configured to:
[0134] Determine the memory size and the remaining number of erasure times of each migratable storage block in the first plane to obtain k memory sizes and k remaining numbers of erasure times, where the first plane is any one of the m planes; k is a positive integer;
[0135] Determine the evaluation values corresponding to the k memory sizes to obtain k first evaluation values, and the smaller the memory size, the larger the first evaluation value;
[0136] Determine the evaluation values corresponding to the k remaining erasure times to obtain k second evaluation values; the larger the remaining erasure times, the larger the second evaluation value.
[0137] Determine k target evaluation values according to the k first evaluation values and the k second evaluation values.
[0138] Determine the priority order of the migratable storage blocks of the first plane according to the k target evaluation values; the larger the target evaluation value, the higher the priority.
[0139] In some possible examples, in terms of determining the second quantity according to the preset quantity and the first quantity, the first determining unit 801 is specifically configured to:
[0140] Determine a first difference between the preset quantity and the first quantity.
[0141] Determine a first adjustment parameter corresponding to the first difference.
[0142] Adjust the preset quantity according to the first adjustment parameter to obtain the second quantity.
[0143] It can be seen that the flash bandwidth allocation device based on a hybrid medium described in the embodiments of the present application is applied to an electronic device. The electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than that of the second medium. Determine the first quantity of the free blocks of the first medium. When the first quantity is less than the preset quantity, it indicates that the free blocks required for the write operation are greater than the actual free blocks. Determine the second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity. Determine the third quantity of the free blocks of the second medium. Determine the planes in the first medium that are in the idle state to obtain m planes, where m is a positive integer. Migrate the data of the good blocks in the m planes to the free blocks of the second medium according to the second quantity and the third quantity. That is, comparing the second quantity and the third quantity can ensure the success rate of migrating the data in the first medium to the second medium. When the data in the first medium can be successfully migrated to the second medium, enough free blocks can be vacated to meet the write operation requirements of the first medium when the free blocks required for the write operation are greater than the actual free blocks. Thus, reasonable flash broadband allocation is achieved to improve the write operation efficiency.
[0144] It can be understood that the functions of the respective program modules of a flash bandwidth allocation device based on a hybrid medium in this embodiment can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can refer to the relevant descriptions of the above method embodiments and will not be elaborated here.
[0145] An embodiment of the present application further provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, and the computer program causes the computer to execute part or all of the steps of any of the methods described in the foregoing method embodiments.
[0146] An embodiment of the present application further provides a computer program product. The computer program product includes a non-transitory computer-readable storage medium storing a computer program. The computer program is operable to cause the computer to execute part or all of the steps of any of the methods described in the foregoing method embodiments. The computer program product can be a software installation package.
[0147] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.
[0148] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0149] In several embodiments provided by the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the above division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical or other form.
[0150] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0151] In addition, in each embodiment of the present application, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0152] If the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the above methods in various embodiments of the present application. The aforementioned memory includes: USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs, etc., all of which can store program codes.
[0153] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing relevant hardware through a program. This program can be stored in a computer-readable memory, and the memory can include: flash drives, read-only memories (abbreviation: ROM, English: Read-Only Memory), random access memories (abbreviation: RAM, English: Random Access Memory), magnetic disks, or optical discs, etc.
[0154] The above has introduced the embodiments of the present application in detail. Specific examples are used in this article to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A flash bandwidth allocation method based on a hybrid medium, characterized in that Applied to an electronic device, the electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than that of the second medium; the method includes: Determine a first quantity of free blocks in the first medium; When the first quantity is less than a preset quantity, determine a second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity; Determine a third quantity of free blocks in the second medium; Determine planes in the first medium that are in an idle state, obtaining m planes, where m is a positive integer; Migrate the data of good blocks in the m planes to the free blocks of the second medium according to the second quantity and the third quantity.
2. The method according to claim 1, wherein The migrating the data of good blocks in the m planes to the free blocks of the second medium according to the second quantity and the third quantity includes: When the second quantity is less than or equal to the third quantity, count the number of storage blocks of migratable good blocks in each of the m planes, obtaining m fourth quantities; Determine the sum of the m fourth quantities, obtaining a first total quantity; When the first total quantity is greater than or equal to the second quantity, select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities; Migrate the data in the second quantity of storage blocks to the free blocks of the second medium.
3. The method according to claim 2, wherein The selecting the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities includes: Determine m weights according to the m fourth quantities, the sum of the m weights is 1, and the larger the fourth quantity, the larger the weight; Determine m fifth quantities according to the m weights and the second quantity; Determine the priority order of migratable storage blocks in each of the m planes, obtaining m priority orders; Select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities according to the m fifth quantities and the m priority orders.
4. The method according to claim 3, characterized in that, The determining the priority order of migratable storage blocks in each of the m planes, obtaining m priority orders, includes: Determine the memory size and the remaining number of erase times of each migratable storage block in a first plane, obtaining k memory sizes and k remaining numbers of erase times, where the first plane is any one of the m planes; k is a positive integer; Determine the evaluation values corresponding to the k memory sizes, obtaining k first evaluation values, and the smaller the memory size, the larger the first evaluation value; Determine the evaluation values corresponding to the k remaining numbers of erase times, obtaining k second evaluation values; the larger the remaining number of erase times, the larger the second evaluation value; Determine k target evaluation values according to the k first evaluation values and the k second evaluation values; Determine the priority order of migratable storage blocks in the first plane according to the k target evaluation values, and the larger the target evaluation value, the higher the priority.
5. The method according to any one of claims 1 to 4, characterized in that, The determining the second quantity according to the preset quantity and the first quantity includes: Determine a first difference between the preset quantity and the first quantity; Determine a first adjustment parameter corresponding to the first difference; Adjust the preset quantity according to the first adjustment parameter to obtain the second quantity.
6. A flash bandwidth allocation device based on a hybrid medium, characterized in that, Applied to an electronic device, the electronic device includes a hybrid storage medium, and the hybrid storage medium includes a first medium and a second medium; the read speed of the first medium is greater than the read speed of the second medium; The flash bandwidth allocation device based on the hybrid medium includes: a first determination unit, a second determination unit, and a migration unit, where, The first determination unit is configured to determine a first quantity of free blocks of the first medium; when the first quantity is less than a preset quantity, determine a second quantity according to the preset quantity and the first quantity; the second quantity is greater than or equal to the preset quantity; The second determination unit is configured to determine a third quantity of free blocks of the second medium; determine planes in the first medium that are in an idle state to obtain m planes, where m is a positive integer; The migration unit is configured to migrate data of good blocks in the m planes to free blocks of the second medium according to the second quantity and the third quantity.
7. The flash bandwidth allocation device based on a hybrid medium according to claim 6, wherein In terms of migrating data of good blocks in the m planes to free blocks of the second medium according to the second quantity and the third quantity, the migration unit is specifically configured to: When the second quantity is less than or equal to the third quantity, count the number of storage blocks of migratable good blocks in each of the m planes to obtain m fourth quantities; Determine the sum of the m fourth quantities to obtain a first total quantity; When the first total quantity is greater than or equal to the second quantity, select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities; Migrate the data in the second quantity of storage blocks to free blocks of the second medium.
8. The flash bandwidth allocation device based on a hybrid medium according to claim 7, wherein In terms of selecting the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities, the migration unit is specifically configured to: Determine m weights according to the m fourth quantities, the sum of the m weights is 1, and the larger the fourth quantity, the larger the weight; Determine m fifth quantities according to the m weights and the second quantity; Determine the priority order of migratable storage blocks in each of the m planes to obtain m priority orders; Select the second quantity of storage blocks from the storage blocks corresponding to the m fourth quantities according to the m fifth quantities and the m priority orders.
9. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory is used to store one or more programs and is configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to any one of claims 1-5.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 5.