Virtual block splicing method, device, target storage device and storage medium
By optimizing the combination of virtual blocks in the SSD and generating damaged virtual blocks and target virtual blocks according to the number of damaged physical blocks, the problem of SSD performance fluctuation is solved and the performance and space utilization of the storage device are improved.
Patent Information
- Application Number
- CN202411019119.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-07-26
AI Technical Summary
In the existing technology, when the concurrent write performance of an SSD approaches its limit, the presence of bad blocks in virtual blocks causes large performance fluctuations. In addition, under the fixed grouping mode, the number of bad blocks in some virtual blocks is relatively large, affecting the available space and performance stability of the SSD.
By obtaining the number of damaged physical blocks in the logical unit number, generating damaged virtual blocks and target virtual blocks, ensuring that the number of damaged physical blocks is close to prevent excessive fluctuations, using difference control within a preset range to optimize the combination of virtual blocks.
It improves the performance stability of SSD, avoids performance fluctuations, ensures the available space utilization of storage devices, and improves overall performance.
Smart Images

Figure CN118963659B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of storage devices, and in particular to a virtual block splicing method, device, target storage device and storage medium. Background Art
[0002] In existing technologies, SSDs group multiple physical blocks into virtual blocks in a fixed manner based on concurrency, and manage read and write operations in a unified manner. This ensures that concurrency reaches the performance limits of the transmission bus and flash memory.
[0003] When an SSD's sequential write performance approaches its concurrent performance limit, bad blocks in a virtual block will limit the concurrency of that virtual block, leading to performance fluctuations. Performance fluctuations are particularly noticeable when a virtual block contains a high number of bad blocks. Furthermore, some edge blocks of flash memory are more likely to be bad. Under the existing fixed grouping method, some virtual blocks may contain a high number of bad blocks. Abandoning these virtual blocks will reduce the available space on the SSD; using them will lead to performance fluctuations.
[0004] Therefore, how to keep the number of bad blocks in the virtual block close and prevent excessive fluctuations has become an urgent problem to be solved. Summary of the Invention
[0005] In view of this, the present invention provides a virtual block splicing method, apparatus, target storage device and storage medium to solve the problem of virtual block splicing.
[0006] In a first aspect, the present invention provides a virtual block assembly method, comprising:
[0007] For each logical unit number in the target storage device, obtaining a first number of damaged physical blocks in each of the multiple physical blocks in the logical unit number; each of the multiple physical blocks includes multiple physical blocks;
[0008] searching for a first plurality of physical blocks from each logical unit number according to each first quantity, and generating a damaged virtual block based on each first plurality of physical blocks;
[0009] Based on the second number of damaged physical blocks included in the remaining multiple physical blocks corresponding to each logical unit number, target physical blocks are determined in turn from the remaining multiple physical blocks corresponding to each logical unit number to generate multiple target virtual blocks; the remaining multiple physical blocks are other multiple physical blocks in each logical unit number except the first multiple physical blocks; the difference between the numbers of damaged physical blocks included in each target virtual block is within a preset range.
[0010] The virtual block piecing method provided in an embodiment of the present application obtains, for each logical unit number in a target storage device, a first number of damaged physical blocks in each of the multiple physical blocks in the logical unit number, thereby generating a damaged virtual block and a target virtual block based on the first number of damaged physical blocks in each of the multiple physical blocks. Based on each first number, the first multiple physical blocks are searched from each logical unit number, and a damaged virtual block is generated based on each of the first multiple physical blocks, thereby ensuring that the number of damaged physical blocks included in the generated damaged virtual block is large. Then, based on the second number of damaged physical blocks included in the remaining multiple physical blocks corresponding to each logical unit number, the target physical block is determined from the remaining multiple physical blocks corresponding to each logical unit number in sequence, and multiple target virtual blocks are generated. The difference between the number of damaged physical blocks included in each target virtual block is within a preset range, thereby ensuring that the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0011] In an optional embodiment, the first plurality of physical blocks include all damaged physical blocks, searching the first plurality of physical blocks from each logical unit number according to each first quantity, and generating a damaged virtual block based on each first plurality of physical blocks includes:
[0012] According to each first number, a plurality of physical blocks in which all physical blocks are damaged are determined as all damaged physical blocks;
[0013] Count the number of all damaged physical blocks included in each logical unit number;
[0014] determining a minimum value among the numbers of all damaged physical blocks included in each logical unit number as a first value;
[0015] A completely damaged physical block is selected from each logical unit number in turn to generate a damaged virtual block, and this cycle is repeated to generate a damaged virtual block of the first value.
[0016] The virtual block piecing together method provided by the embodiment of the present application determines multiple physical blocks that are all damaged as all damaged physical blocks according to each first quantity, thereby ensuring the accuracy of the determined all damaged physical blocks. The number of all damaged physical blocks included in each logical unit number is counted; the minimum value among the number of all damaged physical blocks included in each logical unit number is determined as the first value, thereby ensuring the accuracy of the determined first value. One all damaged physical block is selected from each logical unit number in turn to generate a damaged virtual block, and this cycle is repeated to generate damaged virtual blocks of the first value, thereby ensuring that the number of damaged physical blocks included in the generated damaged virtual block is large, thereby ensuring that the number of damaged physical blocks included in the generated target virtual block is small, thereby preventing excessive fluctuations and avoiding the large number of damaged physical blocks included in the target virtual block, which affects the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0017] In an optional embodiment, the first plurality of physical blocks further includes the most damaged physical blocks, where the most damaged physical blocks are the plurality of physical blocks including the largest number of damaged physical blocks other than all damaged physical blocks in each logical unit number; the method further includes:
[0018] detecting, based on the remaining plurality of physical blocks corresponding to each damaged virtual block and / or each logical unit number, whether a preset stop condition for stopping generating damaged virtual blocks is satisfied;
[0019] If the preset stop condition is not satisfied, determining the most damaged physical blocks from each logical unit number according to each first quantity;
[0020] Based on the most damaged physical blocks, damaged virtual blocks are generated.
[0021] The virtual block piecing together method provided by the embodiment of the present application detects whether the preset stop condition for stopping the generation of damaged virtual blocks is met based on each damaged virtual block and / or the remaining multiple physical blocks corresponding to each logical unit number, thereby ensuring the accuracy of the obtained detection result. If the preset stop condition is not met, the most damaged physical blocks are determined from each logical unit number based on each first quantity, thereby ensuring the accuracy of the most damaged physical blocks determined from each logical unit number. Based on each most damaged physical block, a damaged virtual block is generated, thereby ensuring that the number of damaged physical blocks included in the generated damaged virtual block is large, thereby ensuring that the number of damaged physical blocks included in the generated target virtual block is small, thereby preventing excessive fluctuations and avoiding the large number of damaged physical blocks included in the target virtual block, which affects the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0022] In an optional implementation, the preset stop condition includes:
[0023] The first good block rate corresponding to the damaged virtual block is greater than or equal to the overall bad block rate corresponding to the target storage device; wherein the first good block rate is used to represent the ratio of normal physical blocks in the damaged virtual block to all physical blocks in the damaged virtual block; and the overall bad block rate is used to represent the ratio of damaged physical blocks in the target storage device to all physical blocks in the target storage device;
[0024] and / or,
[0025] The first bad block rate corresponding to each of the multiple physical blocks in each logical unit number is less than the overall bad block rate; the first bad block rate is used to represent the ratio of damaged physical blocks in each of the multiple physical blocks to all physical blocks in the multiple physical blocks;
[0026] and / or,
[0027] The second bad block rate corresponding to the damaged virtual block is less than or equal to a preset threshold; the second bad block rate is used to represent the ratio of damaged physical blocks in each damaged virtual block to all physical blocks in the damaged virtual block;
[0028] and / or,
[0029] There are no bad physical blocks within at least one logical unit number.
[0030] The virtual block piecing method provided by the embodiment of the present application has preset stop conditions including: a first good block rate corresponding to the damaged virtual block is greater than or equal to the overall bad block rate corresponding to the target storage device; wherein the first good block rate is used to represent the ratio of normal physical blocks in the damaged virtual block to all physical blocks in the damaged virtual block; and the overall bad block rate is used to represent the ratio of damaged physical blocks in the target storage device to all physical blocks in the target storage device; and / or, the first bad block rate corresponding to each multi-block physical block in each logical unit number is less than the overall bad block rate; the first bad block rate is used to represent the ratio of damaged physical blocks in each multi-block physical block to all physical blocks in the multi-block physical block; and / or, the second bad block rate corresponding to the damaged virtual block is less than or equal to a preset threshold; the second bad block rate is used to represent the ratio of damaged physical blocks in each damaged virtual block to all physical blocks in the damaged virtual block; and / or, there is no damaged physical block in at least one logical unit number, so that whether the generation of the damaged virtual block is satisfied can be detected according to the preset stop condition, thereby ensuring that the number of damaged physical blocks in the generated damaged virtual block is large and the number of normal physical blocks is small, thereby avoiding the problem of insufficient available space in the target storage device.
[0031] In an optional implementation, based on the second number of damaged physical blocks included in the remaining physical blocks corresponding to each logical unit number, determining target physical blocks from the remaining physical blocks corresponding to each logical unit number in sequence, and generating multiple target virtual blocks, includes:
[0032] acquiring a third number of physical blocks included in the target virtual block;
[0033] determining, based on the third number and each of the remaining plurality of physical blocks, that the number of damaged physical blocks included in the target virtual block is a fourth number;
[0034] According to the second number corresponding to each of the remaining physical blocks and the fourth number corresponding to the target virtual block, the target physical block is determined in sequence from the remaining physical blocks corresponding to each logical unit number to generate multiple target virtual blocks.
[0035] The virtual block piecing together method provided by the embodiment of the present application obtains the third number of physical blocks included in the target virtual block; based on the third number and each of the remaining multiple physical blocks, the damaged physical blocks included in the target virtual block are determined to be the fourth number, thereby ensuring the accuracy of the determined fourth number. Based on the second number corresponding to each of the remaining multiple physical blocks and the fourth number corresponding to the target virtual block, the target physical block is determined from the remaining multiple physical blocks corresponding to each logical unit number in turn, and multiple target virtual blocks are generated, thereby ensuring that the number of damaged physical blocks included in the generated target virtual block is small, and the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0036] In an optional implementation, determining that the number of damaged physical blocks included in the target virtual block is a fourth number based on the third number and each of the remaining multiple physical blocks includes:
[0037] Calculating the total number of damaged physical blocks corresponding to the remaining physical blocks according to the second number corresponding to each of the remaining physical blocks;
[0038] Generate a remaining bad block rate by dividing the total number of damaged physical blocks corresponding to the remaining physical blocks by the total number of physical blocks corresponding to the remaining physical blocks;
[0039] generating a second value by multiplying the remaining bad block rate by a third number of physical blocks included in the target virtual block;
[0040] The second value is rounded up to an integer, and the number of damaged physical blocks included in the target virtual block is determined to be a fourth number.
[0041] The virtual block piecing together method provided in the embodiment of the present application calculates the total number of damaged physical blocks corresponding to the remaining multiple physical blocks based on the second number corresponding to each of the remaining multiple physical blocks; divides the total number of damaged physical blocks corresponding to the remaining multiple physical blocks by the total number of physical blocks corresponding to the remaining multiple physical blocks to generate a remaining bad block rate, thereby ensuring the accuracy of the generated remaining bad block rate. The remaining bad block rate is multiplied by the third number of physical blocks included in the target virtual block to generate a second numerical value, thereby ensuring the accuracy of the generated second numerical value. The second numerical value is rounded up to determine that the target virtual block includes a fourth number of damaged physical blocks, thereby ensuring the accuracy of the fourth number of damaged physical blocks included in the determined target virtual block.
[0042] In an optional implementation, determining the target physical block from the remaining physical blocks corresponding to each logical unit number in sequence according to the second number corresponding to each of the remaining physical blocks and the fourth number corresponding to the target virtual block, and generating the plurality of target virtual blocks, includes:
[0043] According to the second quantities corresponding to the remaining multiple physical blocks, determining the remaining multiple physical blocks with the largest second quantity as the first target physical block, and determining the logical unit number corresponding to the first target physical block as the target logical unit number;
[0044] comparing a second quantity corresponding to the first target physical block with a fourth quantity corresponding to the target virtual block;
[0045] If the second number is equal to the fourth number, selecting a plurality of remaining physical blocks excluding the damaged physical block from the first other logical unit numbers except the target logical unit number as the second target physical block;
[0046] generating a target virtual block according to the first target physical block and the second target physical block;
[0047] If the second amount is less than the fourth amount, calculating a first difference between the fourth amount and the second amount;
[0048] Determine a third target physical block from the first other logical unit numbers except the target logical unit number, and determine the logical unit number corresponding to the third target physical block as the first logical unit number; wherein the number of damaged physical blocks included in the third target physical block is the first difference value;
[0049] Selecting a plurality of remaining physical blocks excluding the damaged physical block from second other logical unit numbers except the target logical unit number and the first logical unit number as second target physical blocks;
[0050] A target virtual block is generated according to the first target physical block, the second target physical block, and the third target physical block.
[0051] The virtual block piecing together method provided by the embodiment of the present application determines the remaining multiple physical blocks with the largest second number as the first target physical block based on the second number corresponding to each of the remaining multiple physical blocks, thereby ensuring the accuracy of the determined first target physical block, and determining the logical unit number corresponding to the first target physical block as the target logical unit number. The second number corresponding to the first target physical block is compared with the fourth number corresponding to the target virtual block; if the second number is equal to the fourth number, the remaining multiple physical blocks that do not include damaged physical blocks are selected from the first other logical unit numbers except the target logical unit number as the second target physical block, thereby ensuring the accuracy of the determined second target physical block. Based on the first target physical block and the second target physical block, a target virtual block is generated, thereby ensuring that the number of damaged physical blocks included in the generated target virtual block is small, and the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device. If the second number is less than the fourth number, a first difference between the fourth number and the second number is calculated; a third target physical block is determined from a first logical unit number other than the target logical unit number, and the logical unit number corresponding to the third target physical block is determined as the first logical unit number; wherein the number of damaged physical blocks included in the third target physical block is the first difference, and the remaining multiple physical blocks that do not include damaged physical blocks are selected from a second logical unit number other than the target logical unit number and the first logical unit number as the second target physical block; based on the first target physical block, the second target physical block, and the third target physical block, a target virtual block is generated. This ensures that the number of damaged physical blocks included in the generated target virtual block is small, and the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0052] In an optional embodiment, the method further includes:
[0053] Each time a target virtual block is generated, the remaining bad block rate is updated to obtain an updated new remaining bad block rate;
[0054] generating a third value by multiplying the new remaining bad block rate by a third number of physical blocks included in the target virtual block;
[0055] rounding up the third value to determine a fifth quantity, and updating the fourth quantity using the fifth quantity;
[0056] Based on the fifth number, a target virtual block is generated.
[0057] The virtual block assembly method provided in an embodiment of the present application updates the remaining bad block rate each time a target virtual block is generated to obtain an updated new remaining bad block rate; the new remaining bad block rate is multiplied by the third number of physical blocks included in the target virtual block to generate a third value; the third value is rounded up to determine a fifth number, and the fifth number is used to update the fourth number; and the target virtual block is generated based on the fifth number. This ensures that the number of damaged physical blocks included in the generated target virtual block is small and the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0058] In an optional implementation, after generating the plurality of target virtual blocks, the method further includes:
[0059] Determine a first physical address and a first virtual address corresponding to each physical block in the target virtual block; the first virtual address is an address of the physical block in the target virtual block;
[0060] Generate a first table according to the first physical address to the first virtual address corresponding to each physical block, and store the first table in correspondence with the target virtual block;
[0061] Generate a second table according to the first virtual address to the first physical address corresponding to each physical block, and store the second table in correspondence with the target virtual block;
[0062] According to the first table and the second table, corresponding operations are performed on the target virtual block.
[0063] The virtual block piecing together method provided by the embodiment of the present application determines the first physical address and the first virtual address corresponding to each physical block in the target virtual block; the first virtual address is the address of the physical block in the target virtual block; a first table is generated according to the first physical address to the first virtual address corresponding to each physical block, and the first table is stored in correspondence with the target virtual block; a second table is generated according to the first virtual address to the first physical address corresponding to each physical block, and the second table is stored in correspondence with the target virtual block; according to the first table and the second table, corresponding operations are performed on the target virtual block, thereby improving the consistency of reading and writing the target virtual block and improving the performance of the target storage device.
[0064] In a second aspect, the present invention provides a virtual block assembly device, the device comprising:
[0065] An acquisition module, configured to acquire, for each logical unit number in the target storage device, a first number of damaged physical blocks in each of the plurality of physical blocks in the logical unit number;
[0066] A first generating module is configured to search for a first plurality of physical blocks from each logical unit number according to each first quantity, and generate a damaged virtual block based on each first plurality of physical blocks;
[0067] The second generation module is used to determine the target physical blocks from the remaining multiple physical blocks corresponding to each logical unit number based on the second number of damaged physical blocks included in the remaining multiple physical blocks corresponding to each logical unit number, and generate multiple target virtual blocks; the remaining multiple physical blocks are other multiple physical blocks in each logical unit number except the first multiple physical blocks; the difference between the numbers of damaged physical blocks included in each target virtual block is within a preset range.
[0068] The virtual block assembly device provided in an embodiment of the present application obtains the first number of damaged physical blocks in each multi-block physical block in each logical unit number in the target storage device, thereby generating a damaged virtual block and a target virtual block based on the first number of damaged physical blocks in each multi-block physical block. Based on each first number, the first multi-block physical block is searched from each logical unit number, and a damaged virtual block is generated based on each first multi-block physical block, which can ensure that the number of damaged physical blocks included in the generated damaged virtual block is large. Then, based on the second number of damaged physical blocks included in the remaining multi-block physical blocks corresponding to each logical unit number, the target physical block is determined from the remaining multi-block physical blocks corresponding to each logical unit number in turn, and multiple target virtual blocks are generated. The difference between the number of damaged physical blocks included in each target virtual block is within a preset range, thereby ensuring that the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above-mentioned device can improve the performance of the target storage device.
[0069] In a third aspect, the present invention provides a target storage device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the virtual block splicing method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0070] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the virtual block splicing method of the first aspect or any corresponding embodiment thereof.
[0071] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the virtual block assembly method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0073] Figure 1 is a flowchart of a virtual block piecing together method according to an embodiment of the present invention;
[0074] Figure 2 is a flow chart of another virtual block piecing together method according to an embodiment of the present invention;
[0075] Figure 3 is a flowchart of another virtual block splicing method according to an embodiment of the present invention;
[0076] Figure 4 is a schematic diagram of a virtual block piecing together method according to an embodiment of the present invention;
[0077] Figure 5 is a flowchart of another virtual block splicing method according to an embodiment of the present invention;
[0078] Figure 6 is a schematic diagram of the relationship between the first table and the second table according to an embodiment of the present invention;
[0079] Figure 7 is a structural block diagram of a virtual block splicing device according to an embodiment of the present invention;
[0080] Figure 8 4 is a schematic diagram of the hardware structure of the target storage device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0081] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.
[0082] It should be noted that the execution subject of the virtual block piecing method provided in the embodiment of the present application can be a virtual block piecing device, and the virtual block piecing device can be realized as part or all of the target storage device through software, hardware, or a combination of software and hardware. The target storage device can be installed in the target storage device or in a server. The server in the embodiment of the present application can be a single server or a server cluster composed of multiple servers, and the terminal in the embodiment of the present application can be a smart phone, a personal computer, a tablet computer, a wearable device, an intelligent robot or other intelligent hardware devices. In the following method embodiments, the execution subject is taken as an example for explanation.
[0083] According to an embodiment of the present invention, an embodiment of a virtual block piecing together method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0084] In this embodiment, a virtual block splicing method is provided, which can be used for the target storage device mentioned above. Figure 1 FIG. 1 is a flow chart of a virtual block splicing method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0085] Step S101: for each logical unit number in a target storage device, obtain a first number of damaged physical blocks in each of the multiple physical blocks in the logical unit number.
[0086] Each multi-block physical block includes multiple physical blocks.
[0087] Specifically, the target storage device can use its built-in hardware and software functions to detect the status of each physical block included in each of the multiple physical blocks in the logical unit number. When a problem with a physical block is detected, the target storage device will record relevant error information. This error information may include the address of the physical block, the error type, and other relevant details. The target storage device can then determine a first number of damaged physical blocks in each of the multiple physical blocks in each of the logical unit numbers by reading these error records.
[0088] Step S102: searching for a first plurality of physical blocks from each logical unit number according to each first quantity, and generating a damaged virtual block based on each first plurality of physical blocks.
[0089] Specifically, the target storage device may search for a plurality of physical blocks with the largest first number from each logical unit number according to each first number as the first plurality of physical blocks. Then, the target storage device may generate a damaged virtual block based on each first plurality of physical blocks.
[0090] This step will be described in detail below.
[0091] Step S103: Based on the second number of damaged physical blocks included in the remaining physical blocks corresponding to each logical unit number, target physical blocks are determined from the remaining physical blocks corresponding to each logical unit number in turn to generate multiple target virtual blocks.
[0092] The remaining multiple physical blocks are multiple physical blocks other than the first multiple physical blocks in each logical unit number; and the difference between the numbers of damaged physical blocks included in each target virtual block is within a preset range.
[0093] Specifically, after generating the lost virtual blocks, the target storage device may count a second number of damaged physical blocks in the remaining physical blocks excluding the first physical blocks in each logical unit number. The target storage device determines target physical blocks from the remaining physical blocks corresponding to each logical unit number in accordance with a preset condition based on the second number of damaged physical blocks in the remaining physical blocks corresponding to each logical unit number, and generates multiple target virtual blocks.
[0094] The preset condition may be that the number of damaged physical blocks included in the target virtual block does not exceed a preset damaged physical block threshold. The preset damaged physical block threshold may be input by a user to the target storage device, sent to the target storage device by another device, or set by the target storage device based on the second number of damaged physical blocks in the remaining multiple physical blocks corresponding to each logical unit number. The embodiment of the present application does not specifically limit the manner in which the target storage device obtains the preset damaged physical block threshold.
[0095] The virtual block piecing method provided in an embodiment of the present application obtains, for each logical unit number in a target storage device, a first number of damaged physical blocks in each of the multiple physical blocks in the logical unit number, thereby generating a damaged virtual block and a target virtual block based on the first number of damaged physical blocks in each of the multiple physical blocks. Based on each first number, the first multiple physical blocks are searched from each logical unit number, and a damaged virtual block is generated based on each of the first multiple physical blocks, thereby ensuring that the number of damaged physical blocks included in the generated damaged virtual block is large. Then, based on the second number of damaged physical blocks included in the remaining multiple physical blocks corresponding to each logical unit number, the target physical block is determined from the remaining multiple physical blocks corresponding to each logical unit number in sequence, and multiple target virtual blocks are generated. The difference between the number of damaged physical blocks included in each target virtual block is within a preset range, thereby ensuring that the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0096] In this embodiment, a virtual block splicing method is provided, which can be used for the target storage device mentioned above. Figure 2 FIG. 1 is a flow chart of a virtual block splicing method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0097] Step S201: for each logical unit number in the target storage device, obtain a first number of damaged physical blocks in each of the multiple physical blocks in the logical unit number.
[0098] Each multi-block physical block includes multiple physical blocks.
[0099] For details about this step, please refer to the above description of step S101 and will not be repeated here.
[0100] Step S202: searching for a first plurality of physical blocks from each logical unit number according to each first quantity, and generating a damaged virtual block based on each first plurality of physical blocks.
[0101] Specifically, the first plurality of physical blocks include all damaged physical blocks, and the above step S202 includes:
[0102] Step S2021: According to each first number, a plurality of physical blocks in which all physical blocks are damaged are determined as all damaged physical blocks.
[0103] Specifically, the target storage device can determine, based on the first number of damaged physical blocks in each multi-block physical block in the logical unit number, a multi-block physical block whose first number is equal to the number of physical blocks included in the multi-block physical block as all damaged physical blocks, that is, a multi-block physical block whose physical blocks are all damaged is determined as all damaged physical blocks.
[0104] Step S2022: Count the number of all damaged physical blocks included in each logical unit number.
[0105] Specifically, the target storage device may count the number of all damaged physical blocks included in each logical unit number.
[0106] Step S2023: Determine the minimum value of the number of all damaged physical blocks included in each logical unit number as the first value.
[0107] Specifically, the target storage device compares the numbers of all damaged physical blocks included in each logical unit number, and then determines the minimum value among the numbers of all damaged physical blocks included in each logical unit number as the first value.
[0108] Step S2024: Select one completely damaged physical block from each logical unit number in turn to generate a damaged virtual block, and repeat this cycle to generate a damaged virtual block of the first value.
[0109] Specifically, the target storage device sequentially selects a completely damaged physical block from each logical unit number to generate a damaged virtual block.
[0110] In an optional embodiment of the present application, the first plurality of physical blocks further includes the most damaged physical blocks, where the most damaged physical blocks are the plurality of physical blocks including the largest number of damaged physical blocks other than all damaged physical blocks in each logical unit number. The above embodiment may further include the following steps:
[0111] Step S2025: detecting whether a preset stop condition for stopping generating damaged virtual blocks is satisfied based on the remaining physical blocks corresponding to each damaged virtual block and / or each logical unit number.
[0112] In an optional embodiment of the present application, the preset stop condition includes:
[0113] The first good block rate corresponding to the damaged virtual block is greater than or equal to the overall bad block rate corresponding to the target storage device; wherein the first good block rate is used to represent the ratio of normal physical blocks in the damaged virtual block to all physical blocks in the damaged virtual block; and the overall bad block rate is used to represent the ratio of damaged physical blocks in the target storage device to all physical blocks in the target storage device;
[0114] and / or,
[0115] The first bad block rate corresponding to each of the multiple physical blocks in each logical unit number is less than the overall bad block rate; the first bad block rate is used to represent the ratio of damaged physical blocks in each of the multiple physical blocks to all physical blocks in the multiple physical blocks;
[0116] and / or,
[0117] The second bad block rate corresponding to the damaged virtual block is less than or equal to a preset threshold; the second bad block rate is used to represent the ratio of damaged physical blocks in each damaged virtual block to all physical blocks in the damaged virtual block;
[0118] and / or,
[0119] There are no bad physical blocks within at least one logical unit number.
[0120] Specifically, the target storage device can detect whether the first good block rate corresponding to the damaged virtual block is greater than or equal to the overall bad block rate corresponding to the target storage device, and / or whether the first bad block rate corresponding to each multiple physical block in each logical unit number is less than the overall bad block rate, and / or whether the second bad block rate corresponding to the damaged virtual block is less than or equal to a preset threshold, and / or whether there is no damaged physical block in at least one logical unit number.
[0121] If the first good block rate corresponding to the damaged virtual block is greater than or equal to the overall bad block rate corresponding to the target storage device; and / or the first bad block rate corresponding to each multiple physical block in each logical unit number is less than the overall bad block rate; and / or the second bad block rate corresponding to the damaged virtual block is less than or equal to a preset threshold; and / or there is at least one logical unit number in which no damaged physical block exists, it is determined that the preset stop condition for stopping the generation of damaged virtual blocks is met, and the target storage device stops generating damaged virtual blocks.
[0122] Step S2026: If the preset stop condition is not satisfied, the most damaged physical blocks are determined from each logical unit number according to each first quantity.
[0123] Specifically, if the preset stop condition is not satisfied, the target storage device determines the most damaged physical blocks from each logical unit number according to each first quantity.
[0124] Step S2027: Generate a damaged virtual block based on each of the most damaged physical blocks.
[0125] Specifically, the target storage device generates a damaged virtual block based on each of the most damaged physical blocks.
[0126] After generating the lost virtual block, the target storage device may continue to detect whether a preset stop condition for stopping generating the damaged virtual block is currently satisfied. If the preset stop condition is not satisfied, the target storage device may again generate a damaged virtual block from a plurality of physical blocks currently including the largest number of damaged physical blocks determined by each logical unit number. If the preset stop condition is satisfied, the target storage device may stop generating the damaged virtual block.
[0127] Step S203: Based on the second number of damaged physical blocks included in the remaining physical blocks corresponding to each logical unit number, target physical blocks are determined from the remaining physical blocks corresponding to each logical unit number in turn to generate multiple target virtual blocks.
[0128] The remaining multiple physical blocks are multiple physical blocks other than the first multiple physical blocks in each logical unit number; and the difference between the numbers of damaged physical blocks included in each target virtual block is within a preset range.
[0129] For details about this step, please refer to the above description of step S103 and will not be repeated here.
[0130] The virtual block piecing together method provided by the embodiment of the present application determines multiple physical blocks that are all damaged as all damaged physical blocks according to each first quantity, thereby ensuring the accuracy of the determined all damaged physical blocks. The number of all damaged physical blocks included in each logical unit number is counted; the minimum value among the number of all damaged physical blocks included in each logical unit number is determined as the first value, thereby ensuring the accuracy of the determined first value. One all damaged physical block is selected from each logical unit number in turn to generate a damaged virtual block, and this cycle is repeated to generate damaged virtual blocks of the first value, thereby ensuring that the number of damaged physical blocks included in the generated damaged virtual block is large, thereby ensuring that the number of damaged physical blocks included in the generated target virtual block is small, thereby preventing excessive fluctuations and avoiding the large number of damaged physical blocks included in the target virtual block, which affects the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0131] The first plurality of physical blocks also includes the most damaged physical blocks. Based on each damaged virtual block and / or the remaining plurality of physical blocks corresponding to each logical unit number, a detection is performed to determine whether a preset stop condition for stopping the generation of damaged virtual blocks is met, thereby ensuring the accuracy of the detection result. If the preset stop condition is not met, the most damaged physical blocks are determined from each logical unit number based on each first quantity, thereby ensuring the accuracy of the most damaged physical blocks determined from each logical unit number. Based on each most damaged physical block, a damaged virtual block is generated, thereby ensuring that the number of damaged physical blocks included in the generated damaged virtual block is large, thereby ensuring that the number of damaged physical blocks included in the generated target virtual block is small, thereby preventing excessive fluctuations and avoiding the large number of damaged physical blocks included in the target virtual block affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0132] Among them, the preset stop conditions include: a first good block rate corresponding to the damaged virtual block is greater than or equal to the overall bad block rate corresponding to the target storage device; wherein the first good block rate is used to represent the ratio of normal physical blocks in the damaged virtual block to all physical blocks in the damaged virtual block; the overall bad block rate is used to represent the ratio of damaged physical blocks in the target storage device to all physical blocks in the target storage device; and / or, the first bad block rate corresponding to each multi-block physical block in each logical unit number is less than the overall bad block rate; the first bad block rate is used to represent the ratio of damaged physical blocks in each multi-block physical block to all physical blocks in the multi-block physical block; and / or, a second bad block rate corresponding to the damaged virtual block is less than or equal to a preset threshold; the second bad block rate is used to represent the ratio of damaged physical blocks in each damaged virtual block to all physical blocks in the damaged virtual block; and / or, there is no damaged physical block in at least one logical unit number, so that whether the generation of the damaged virtual block is satisfied can be detected according to the preset stop conditions, thereby ensuring that the number of damaged physical blocks in the generated damaged virtual block is large and the number of normal physical blocks is small, thereby avoiding the lack of available space in the target storage device.
[0133] In this embodiment, a virtual block splicing method is provided, which can be used for the target storage device mentioned above. Figure 3 FIG. 1 is a flow chart of a virtual block splicing method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0134] Step S301: for each logical unit number in the target storage device, obtain a first number of damaged physical blocks in each of the multiple physical blocks in the logical unit number.
[0135] Each multi-block physical block includes multiple physical blocks.
[0136] For details about this step, please refer to the above description of step S201 and will not be repeated here.
[0137] Step S302: searching for a first plurality of physical blocks from each logical unit number according to each first quantity, and generating a damaged virtual block based on each first plurality of physical blocks.
[0138] For details about this step, please refer to the above description of step S202 and will not be repeated here.
[0139] Step S303: Based on the second number of damaged physical blocks included in the remaining physical blocks corresponding to each logical unit number, target physical blocks are determined from the remaining physical blocks corresponding to each logical unit number in turn to generate multiple target virtual blocks.
[0140] The remaining multiple physical blocks are multiple physical blocks other than the first multiple physical blocks in each logical unit number; and the difference between the numbers of damaged physical blocks included in each target virtual block is within a preset range.
[0141] Specifically, the above step S303 may include the following steps:
[0142] Step S3031: Obtain a third number of physical blocks included in the target virtual block.
[0143] Specifically, the target storage device may calculate the third number of physical blocks included in the target virtual block by multiplying the number of logical units included in the target storage device by the number of physical blocks included in the multiple physical blocks in the logical unit.
[0144] Step S3032: Determine, based on the third number and the remaining plurality of physical blocks, that the number of damaged physical blocks included in the target virtual block is a fourth number.
[0145] Specifically, the above step S3032 may include the following steps:
[0146] Step a1: Calculate the total number of damaged physical blocks corresponding to the remaining physical blocks according to the second number corresponding to each of the remaining physical blocks.
[0147] Specifically, the target storage device may add up the second number of damaged physical blocks included in each of the remaining physical blocks to obtain the total number of damaged physical blocks corresponding to the remaining physical blocks.
[0148] Step a2: generating a remaining bad block rate by dividing the total number of damaged physical blocks corresponding to the remaining physical blocks by the total number of physical blocks corresponding to the remaining physical blocks.
[0149] Specifically, the target storage device generates the remaining bad block rate by dividing the total number of damaged physical blocks corresponding to the remaining physical blocks by the total number of physical blocks corresponding to the remaining physical blocks.
[0150] Step a3: multiplying the remaining bad block rate by the third number of physical blocks included in the target virtual block to generate a second value.
[0151] Specifically, the target storage device generates the second value by multiplying the remaining bad block rate by the third number of physical blocks included in the target virtual block.
[0152] Step a4: round up the second value to determine that the number of damaged physical blocks included in the target virtual block is a fourth number.
[0153] Specifically, the target storage device rounds up the second value, and determines the rounded value as the fourth number of damaged physical blocks included in the target virtual block.
[0154] Step S3033: According to the second number corresponding to each of the remaining physical blocks and the fourth number corresponding to the target virtual block, the target physical block is determined from the remaining physical blocks corresponding to each logical unit number in turn, and multiple target virtual blocks are generated.
[0155] Specifically, the above step S3033 may include the following steps:
[0156] Step b1: According to the second quantity corresponding to each of the remaining multiple physical blocks, the remaining multiple physical blocks with the largest second quantity are determined as the first target physical block, and the logical unit number corresponding to the first target physical block is determined as the target logical unit number.
[0157] Specifically, the target storage device may determine the remaining physical blocks with the largest second quantity as the first target physical block according to the second quantity corresponding to each remaining physical block, and determine the logical unit number corresponding to the first target physical block as the target logical unit number.
[0158] Step b2: Compare the second quantity corresponding to the first target physical block with the fourth quantity corresponding to the target virtual block.
[0159] Specifically, the target storage device may compare the second quantity corresponding to the first target physical block with the fourth quantity corresponding to the target virtual block.
[0160] Step b3: If the second number is equal to the fourth number, select a plurality of remaining physical blocks excluding the damaged physical block from the first other logical unit numbers except the target logical unit number as the second target physical block.
[0161] Specifically, if the second number is equal to the fourth number, the target storage device selects a second target physical block from each of the first other logical unit numbers except the target logical unit number, wherein the second target physical block is the remaining multiple physical blocks excluding the damaged physical block.
[0162] Step b4: Generate a target virtual block according to the first target physical block and the second target physical block.
[0163] Specifically, the target storage device splices the first target physical block and each second target physical block to generate a target virtual block.
[0164] Exemplarily, if the fourth quantity corresponding to the target virtual block is 3, the target storage device determines the remaining physical blocks with the largest second quantity as the first target physical block according to the second quantities corresponding to the remaining physical blocks.
[0165] If the number of damaged physical blocks included in the first target physical block is 3, the target storage device selects a second target physical block from each of the first logical unit numbers other than the target logical unit number, each of which has a damaged physical block of 0. The first target physical block and each of the second target physical blocks are concatenated to generate a target virtual block, so that the number of damaged physical blocks included in the target virtual block is 3.
[0166] Step b5: If the second number is smaller than the fourth number, calculate a first difference between the fourth number and the second number.
[0167] Specifically, if the second number is smaller than the fourth number, the target storage device subtracts the second number from the fourth number to calculate a first difference.
[0168] Step b6: Determine a third target physical block from the first other logical unit numbers except the target logical unit number, and determine the logical unit number corresponding to the third target physical block as the first logical unit number.
[0169] The number of damaged physical blocks included in the third target physical block is the first difference.
[0170] Specifically, the target storage device may determine a third target physical block from the first other logical unit numbers except the target logical unit number, and determine the logical unit number corresponding to the third target physical block as the first logical unit number.
[0171] Step b7: Select a plurality of remaining physical blocks excluding the damaged physical block from the second other logical unit numbers except the target logical unit number and the first logical unit number as the second target physical block.
[0172] Specifically, the target storage device may select a plurality of remaining physical blocks excluding the damaged physical block from each second other logical unit number except the target logical unit number and the first logical unit number as the second target physical block.
[0173] Step b8: Generate a target virtual block according to the first target physical block, the second target physical block and the third target physical block.
[0174] Specifically, the target storage device splices the first target physical block, each second target physical block, and the third target physical block to generate a target virtual block.
[0175] Step b9: Each time a target virtual block is generated, the remaining bad block rate is updated to obtain an updated new remaining bad block rate.
[0176] Specifically, each time a target virtual block is generated, the target storage device may update the remaining bad block ratio to obtain an updated new remaining bad block ratio.
[0177] Step b10: multiplying the new remaining bad block rate by the third number of physical blocks included in the target virtual block to generate a third value.
[0178] Specifically, the target storage device may generate a third value by multiplying the new remaining bad block rate by the third number of physical blocks included in the target virtual block.
[0179] Step b11: round up the third value to determine a fifth quantity, and use the fifth quantity to update the fourth quantity.
[0180] Specifically, the target storage device may round up the third value to determine the fifth number, and update the fourth number using the fifth number.
[0181] Step b12: Generate a target virtual block according to the fifth quantity.
[0182] Specifically, the target storage device may determine the target physical block from the remaining physical blocks corresponding to each logical unit number according to the second number corresponding to each remaining physical block and the fifth number corresponding to the target virtual block, and generate multiple target virtual blocks.
[0183] This process can refer to the introduction of step S3033 above and will not be described in detail here.
[0184] For example, Figure 4 As shown, Figure 4 For example, "lun0 bad0" in the example, "lun0 bad0" means that the number of damaged physical blocks in the logical unit number 0 is 0, which is represented by Figure 4 It can be seen that in logical unit number 0, the multi-block physical blocks including 0 damaged physical blocks are block A, block B, block D, and block J. Similarly, in logical unit number 0, the multi-block physical blocks including 1 damaged physical block are block E and block I; in logical unit number 0, the multi-block physical blocks including 2 damaged physical blocks are block C and block F; in logical unit number 0, the multi-block physical blocks including 3 damaged physical blocks are block G; in logical unit number 0, the multi-block physical blocks including 4 damaged physical blocks are block H. Similarly, the number of damaged physical blocks included in each multi-block physical block in other logical unit numbers can be determined.
[0185] The target storage device selects a plurality of physical blocks, each of which includes four damaged physical blocks, from each logical unit number and splices the selected physical blocks into a damaged virtual block. Then, based on the number of damaged physical blocks included in the target virtual block, the target physical block is determined from the remaining physical blocks corresponding to each logical unit number and spliced into a target virtual block based on the selected physical blocks.
[0186] The virtual block piecing together method provided by the embodiment of the present application obtains the third number of physical blocks included in the target virtual block; calculates the total number of damaged physical blocks corresponding to the remaining physical blocks based on the second number corresponding to each of the remaining physical blocks; divides the total number of damaged physical blocks corresponding to the remaining physical blocks by the total number of physical blocks corresponding to the remaining physical blocks to generate a residual bad block rate, thereby ensuring the accuracy of the generated residual bad block rate. The residual bad block rate is multiplied by the third number of physical blocks included in the target virtual block to generate a second numerical value, thereby ensuring the accuracy of the generated second numerical value. The second numerical value is rounded up to determine that the target virtual block includes a fourth number of damaged physical blocks, thereby ensuring the accuracy of the fourth number of damaged physical blocks included in the determined target virtual block.
[0187] Based on the second quantity corresponding to each of the remaining multiple physical blocks, the remaining multiple physical blocks with the largest second quantity are determined as the first target physical block, thereby ensuring the accuracy of the determined first target physical block, and the logical unit number corresponding to the first target physical block is determined as the target logical unit number. The second quantity corresponding to the first target physical block is compared with the fourth quantity corresponding to the target virtual block; if the second quantity is equal to the fourth quantity, the remaining multiple physical blocks that do not include damaged physical blocks are selected from the first other logical unit numbers except the target logical unit number as the second target physical block, thereby ensuring the accuracy of the determined second target physical block. Based on the first target physical block and the second target physical block, a target virtual block is generated, thereby ensuring that the number of damaged physical blocks included in the generated target virtual block is small, and the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device. If the second number is less than the fourth number, a first difference between the fourth number and the second number is calculated; a third target physical block is determined from a first logical unit number other than the target logical unit number, and the logical unit number corresponding to the third target physical block is determined as the first logical unit number; wherein the number of damaged physical blocks included in the third target physical block is the first difference, and the remaining multiple physical blocks that do not include damaged physical blocks are selected from a second logical unit number other than the target logical unit number and the first logical unit number as the second target physical block; based on the first target physical block, the second target physical block, and the third target physical block, a target virtual block is generated. This ensures that the number of damaged physical blocks included in the generated target virtual block is small, and the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding affecting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0188] Each time a target virtual block is generated, the remaining bad block rate is updated to obtain a new, updated remaining bad block rate. The new remaining bad block rate is multiplied by the third number of physical blocks included in the target virtual block to generate a third value. The third value is rounded up to determine a fifth number, which is used to update the fourth number. The target virtual block is then generated based on the fifth number. This ensures that the number of damaged physical blocks included in the generated target virtual block is small and the number of damaged physical blocks in the generated target virtual block is close, thereby preventing excessive fluctuations and avoiding impacting the performance of the target storage device. Therefore, the above method can improve the performance of the target storage device.
[0189] In this embodiment, a virtual block splicing method is provided, which can be used for the target storage device mentioned above. Figure 5 FIG. 1 is a flow chart of a virtual block splicing method according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps:
[0190] Step S401: for each logical unit number in the target storage device, obtain a first number of damaged physical blocks in each of the multiple physical blocks in the logical unit number.
[0191] Each multi-block physical block includes multiple physical blocks.
[0192] For details about this step, please refer to the above description of step S301 and will not be repeated here.
[0193] Step S402: searching for a first plurality of physical blocks from each logical unit number according to each first quantity, and generating a damaged virtual block based on each first plurality of physical blocks.
[0194] For details about this step, please refer to the above description of step S302 and will not be repeated here.
[0195] Step S403: Based on the second number of damaged physical blocks included in the remaining physical blocks corresponding to each logical unit number, target physical blocks are determined from the remaining physical blocks corresponding to each logical unit number in turn to generate multiple target virtual blocks.
[0196] The remaining multiple physical blocks are multiple physical blocks other than the first multiple physical blocks in each logical unit number; and the difference between the numbers of damaged physical blocks included in each target virtual block is within a preset range.
[0197] For details about this step, please refer to the above description of step S303 and will not be repeated here.
[0198] Step S404: determining a first physical address and a first virtual address corresponding to each physical block in the target virtual block.
[0199] The first virtual address is the address of the physical block in the target virtual block.
[0200] Specifically, the target storage device may determine a first physical address and a first virtual address corresponding to each physical block in the target virtual block.
[0201] Step S405 : Generate a first table according to the first physical address to the first virtual address corresponding to each physical block, and store the first table in correspondence with the target virtual block.
[0202] Specifically, the target storage device may generate a first physical address to a first virtual address (Physical-to-Virtual, p2v) corresponding to each physical block, and generate a first table according to the p2v corresponding to each physical block, and store the first table in correspondence with the target virtual block.
[0203] Step S406 : Generate a second table according to the first virtual address to the first physical address corresponding to each physical block, and store the second table in correspondence with the target virtual block.
[0204] Specifically, the target storage device may generate a first virtual address to a first physical address (Virtual-to-Physical, v2p) corresponding to each physical block, generate a second table according to the v2p corresponding to each physical block, and store the second table in correspondence with the target virtual block.
[0205] Step S407 : performing corresponding operations on the target virtual block according to the first table and the second table.
[0206] In an optional embodiment, when reading data from a target storage device, if the l2p (Logical-to-Physical) table records physical block information, the first table is queried during the reading process. The first table can be used to determine the corresponding target virtual block, and then the read count of the target virtual block is updated. This allows tracking the frequency of each target virtual block being read for subsequent data analysis or optimization operations. For example, the read count can be used to determine which target virtual blocks should be cached to improve access efficiency.
[0207] When writing data to the target storage device, the target virtual block is confirmed when clearing vdfb and vdfc during the write process: When performing a write operation and clearing vdfb and vdfc, the first table is also referenced to confirm the corresponding target virtual block. This ensures that the relevant target virtual block can be accurately found and processed during these operations, ensuring data consistency and correctness.
[0208] In another optional implementation, if the information recorded in the l2p table is virtual block information in the target virtual block.
[0209] When the l2p table records the virtual block information of the target virtual block, the second table needs to be queried to determine the actual location of the data when reading data. The second table can be used to map the virtual block to the actual physical storage location, so that the data can be read correctly.
[0210] When writing or modifying the L2P table, if the table records the virtual block information of the target virtual block, the operation is relatively straightforward and does not require any special operations. This is because the virtual block information in the target virtual block already contains the necessary information related to the data operation, making the writing and modifying process more efficient.
[0211] Taking both scenarios into consideration, using the target virtual block's virtual block information in the L2P table offers certain advantages. While reading requires querying the second table to confirm the location, writing and modifying the table requires no additional operations, improving overall data processing efficiency. In contrast, if the L2P table records physical block information, some read and write operations require additional queries to the first table, increasing operational complexity and potential overhead. Therefore, for these reasons, the L2P table prefers to use the target virtual block's virtual block information.
[0212] For example, Figure 6 As shown, after generating the target virtual block, the target storage device can save the target virtual block. Then, after the power-on module is powered on, the first table, i.e., the p2v table, and the second table, i.e., the v2p table, are restored. When performing data recovery and data reading, writing, or erasing, the target storage device reads the first and second tables, respectively, and performs processing based on the first and second tables.
[0213] The virtual block piecing together method provided by the embodiment of the present application determines the first physical address and the first virtual address corresponding to each physical block in the target virtual block; the first virtual address is the address of the physical block in the target virtual block; a first table is generated according to the first physical address to the first virtual address corresponding to each physical block, and the first table is stored in correspondence with the target virtual block; a second table is generated according to the first virtual address to the first physical address corresponding to each physical block, and the second table is stored in correspondence with the target virtual block; according to the first table and the second table, corresponding operations are performed on the target virtual block, thereby improving the consistency of reading and writing the target virtual block and improving the performance of the target storage device.
[0214] In this embodiment, a virtual block assembly device is also provided, which is used to implement the above-mentioned embodiments and preferred implementations. Details that have been described will not be repeated here. As used below, the term "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0215] This embodiment provides a virtual block splicing device, such as Figure 7 Shown, including:
[0216] An acquisition module 501 is configured to acquire, for each logical unit number in a target storage device, a first number of damaged physical blocks in each of the plurality of physical blocks in the logical unit number;
[0217] A first generating module 502 is configured to search for a first plurality of physical blocks from each logical unit number according to each first quantity, and generate a damaged virtual block based on each first plurality of physical blocks;
[0218] The second generation module 503 is used to determine the target physical blocks from the remaining multiple physical blocks corresponding to each logical unit number based on the second number of damaged physical blocks included in the remaining multiple physical blocks corresponding to each logical unit number, and generate multiple target virtual blocks; the remaining multiple physical blocks are the other multiple physical blocks in each logical unit number except the first multiple physical blocks.
[0219] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0220] The virtual block assembly device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0221] The embodiment of the present invention also provides a computer device target storage device having the above Figure 7 The virtual block assembly device shown.
[0222] See also Figure 8 , Figure 8 is a structural diagram of a target storage device provided by an optional embodiment of the present invention, such as Figure 8As shown, this target storage device comprises: one or more processors 10, memory 20, and the interface for connecting each component, comprises high-speed interface and low-speed interface.Each component utilizes different buses to communicate with each other and is connected, and can be installed on a common mainboard or install in other ways as required.The processor can process the instruction that executes in the target storage device, comprise the instruction that is stored in the memory or on the memory to display the graphic information of GUI on external input / output device (such as, being coupled to the display device of interface).In some optional embodiments, if necessary, can use multiple processors and / or multiple buses together with multiple memories and multiple memories.Equally, can connect multiple target storage devices, each equipment provides part necessary operation (for example, as server array, one group of blade server or multiprocessor system). Figure 8 A processor 10 is taken as an example.
[0223] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.
[0224] The memory 20 stores instructions that can be executed by at least one processor 10, so as to enable at least one processor 10 to execute the method shown in the above embodiment.
[0225] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the target storage device, etc. In addition, the memory 20 may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely located relative to the processor 10, and these remote memories may be connected to the target storage device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0226] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0227] The target storage device further includes a communication interface 30 for the target storage device to communicate with other devices or a communication network.
[0228] The embodiment of the present invention also provides a computer-readable storage medium. The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0229] A portion of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the form in which the computer program instruction exists in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc. Accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by the computer.
[0230] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention. Such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A virtual block piecing method, characterized in that: The method comprises: For each logical unit number in the target storage device, obtaining a first number of damaged physical blocks in each of the plurality of physical blocks in the logical unit number; each of the plurality of physical blocks includes a plurality of physical blocks; searching for a first plurality of physical blocks from each of the logical unit numbers according to each of the first quantities, and generating a damaged virtual block based on each of the first plurality of physical blocks; Based on a second number of the defective physical blocks included in the remaining plurality of physical blocks corresponding to each of the logical unit numbers, target physical blocks are sequentially determined from the remaining plurality of physical blocks corresponding to each of the logical unit numbers to generate a plurality of target virtual blocks; the remaining plurality of physical blocks are the remaining plurality of physical blocks other than the first plurality of physical blocks in each of the logical unit numbers; and a difference between the numbers of the defective physical blocks included in each of the target virtual blocks is within a preset range. The first plurality of physical blocks include all damaged physical blocks, searching the first plurality of physical blocks from each of the logical unit numbers according to each of the first quantities, and generating a damaged virtual block based on each of the first plurality of physical blocks, including: determining, according to each of the first numbers, the plurality of physical blocks in which all physical blocks are damaged as the all-damaged physical blocks; Counting the number of all damaged physical blocks included in each of the logical unit numbers; Determine the minimum value of the number of all damaged physical blocks included in each of the logical unit numbers as a first value; Selecting one of the damaged physical blocks from each of the logical unit numbers in sequence to generate a damaged virtual block, and repeating this process to generate the damaged virtual block of the first value; The step of determining target physical blocks from the remaining physical blocks corresponding to each logical unit number based on the second number of damaged physical blocks included in the remaining physical blocks corresponding to each logical unit number, and generating multiple target virtual blocks includes: acquiring a third number of physical blocks included in the target virtual block; Determining, based on the third number and each of the remaining plurality of physical blocks, that the number of damaged physical blocks included in the target virtual block is a fourth number; According to the second number corresponding to each of the remaining physical blocks and the fourth number corresponding to the target virtual block, the target physical block is determined in turn from the remaining physical blocks corresponding to each of the logical unit numbers to generate multiple target virtual blocks.
2. The method according to claim 1, characterized in that The first plurality of physical blocks further include the most damaged physical blocks, where the most damaged physical blocks are the plurality of physical blocks including the largest number of damaged physical blocks determined in each of the logical unit numbers except for all the damaged physical blocks; the method further includes: detecting, according to each of the damaged virtual blocks and / or the remaining plurality of physical blocks corresponding to each of the logical unit numbers, whether a preset stop condition for stopping generating the damaged virtual block is satisfied; If the preset stop condition is not satisfied, determining the most damaged physical blocks from each of the logical unit numbers according to each of the first quantities; The damaged virtual block is generated based on each of the most damaged physical blocks.
3. The method according to claim 2, characterized in that The preset stop conditions include: The first good block rate corresponding to the damaged virtual block is greater than or equal to the overall bad block rate corresponding to the target storage device; wherein the first good block rate is used to represent the ratio of normal physical blocks in the damaged virtual block to all physical blocks in the damaged virtual block; and the overall bad block rate is used to represent the ratio of damaged physical blocks in the target storage device to all physical blocks in the target storage device; and / or, A first bad block rate corresponding to each of the plurality of physical blocks in each of the logical unit numbers is less than the overall bad block rate; the first bad block rate is used to represent a ratio of damaged physical blocks in each of the plurality of physical blocks to all physical blocks in the plurality of physical blocks; and / or, The second bad block rate corresponding to the damaged virtual block is less than or equal to a preset threshold; the second bad block rate is used to represent the ratio of damaged physical blocks in each of the damaged virtual blocks to all physical blocks in the damaged virtual block; and / or, There is at least one logical unit number in which the damaged physical block does not exist.
4. The method according to claim 1, wherein The step of determining, based on the third number and each of the remaining physical blocks, that the number of damaged physical blocks included in the target virtual block is a fourth number, includes: Calculating the total number of damaged physical blocks corresponding to the remaining physical blocks according to the second number corresponding to each of the remaining physical blocks; Generating a remaining bad block rate by dividing the total number of damaged physical blocks corresponding to the remaining physical blocks by the total number of physical blocks corresponding to the remaining physical blocks; generating a second value by multiplying the remaining bad block rate by a third number of physical blocks included in the target virtual block; The second value is rounded up to an integer, and the number of damaged physical blocks included in the target virtual block is determined to be a fourth number.
5. The method according to claim 4, characterized in that The step of determining a target physical block from the remaining physical blocks corresponding to each logical unit number according to the second number corresponding to each of the remaining physical blocks and the fourth number corresponding to the target virtual block, and generating the plurality of target virtual blocks, comprises: According to the second quantities corresponding to the remaining physical blocks, the remaining physical blocks having the largest second quantity are determined as first target physical blocks, and the logical unit number corresponding to the first target physical block is determined as a target logical unit number; comparing the second number corresponding to the first target physical block with a fourth number corresponding to the target virtual block; If the second number is equal to the fourth number, selecting the remaining plurality of physical blocks excluding the damaged physical block from the first other logical unit number except the target logical unit number as the second target physical block; generating the target virtual block according to the first target physical block and the second target physical block; If the second number is less than the fourth number, calculating a first difference between the fourth number and the second number; Determine a third target physical block from the first other logical unit numbers except the target logical unit number, and determine the logical unit number corresponding to the third target physical block as the first logical unit number; wherein the number of the damaged physical blocks included in the third target physical block is the first difference; Selecting the remaining plurality of physical blocks excluding the damaged physical block from second other logical unit numbers except the target logical unit number and the first logical unit number as the second target physical block; The target virtual block is generated according to the first target physical block, the second target physical block, and the third target physical block.
6. The method according to claim 5, characterized in that The method further comprises: Each time the target virtual block is generated, the remaining bad block rate is updated to obtain an updated new remaining bad block rate; generating a third value by multiplying the new remaining bad block rate by a third number of physical blocks included in the target virtual block; rounding up the third value to determine a fifth number, and updating the fourth number using the fifth number; The target virtual block is generated according to the fifth number.
7. The method according to claim 1, characterized in that After generating a plurality of target virtual blocks, the method further includes: Determine a first physical address and a first virtual address corresponding to each physical block in the target virtual block; the first virtual address is an address of the physical block in the target virtual block; generating a first table according to the first physical address to the first virtual address corresponding to each physical block, and storing the first table in correspondence with the target virtual block; generating a second table according to the first virtual address corresponding to each physical block to the first physical address, and storing the second table in correspondence with the target virtual block; According to the first table and the second table, corresponding operations are performed on the target virtual block.
8. A virtual block assembly device, characterized in that: The device comprises: an acquiring module, configured to acquire, for each logical unit number in a target storage device, a first number of damaged physical blocks in each of the plurality of physical blocks in the logical unit number; A first generating module is configured to search for a first plurality of physical blocks from each logical unit number according to each first quantity, and generate a damaged virtual block based on each first plurality of physical blocks; wherein the first plurality of physical blocks include all damaged physical blocks, and searching for a first plurality of physical blocks from each logical unit number according to each first quantity, and generating a damaged virtual block based on each first plurality of physical blocks, including: determining, according to each first quantity, the plurality of physical blocks in which all physical blocks are damaged as the all damaged physical blocks; counting the number of the all damaged physical blocks included in each logical unit number; determining the minimum value among the numbers of the all damaged physical blocks included in each logical unit number as a first value; sequentially selecting one of the all damaged physical blocks from each logical unit number to generate a damaged virtual block, and repeating this process to generate the first value of damaged virtual blocks; The second generation module is used to determine the target physical blocks from the remaining physical blocks corresponding to each logical unit number in sequence based on the second number of the damaged physical blocks included in the remaining physical blocks corresponding to each logical unit number, and generate multiple target virtual blocks; the remaining physical blocks are the other physical blocks in each logical unit number except the first physical blocks; wherein, based on the second number of the damaged physical blocks included in the remaining physical blocks corresponding to each logical unit number, the target physical blocks are determined from the remaining physical blocks corresponding to each logical unit number in sequence, and generate multiple target virtual blocks, including: obtaining the third number of physical blocks included in the target virtual block; determining the damaged physical blocks included in the target virtual block as the fourth number according to the third number and each of the remaining physical blocks; determining the target physical blocks from the remaining physical blocks corresponding to each of the logical unit numbers in sequence according to the second number corresponding to each of the remaining physical blocks and the fourth number corresponding to the target virtual block, and generating multiple target virtual blocks.
9. A target storage device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the virtual block splicing method according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the virtual block splicing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device of virtual-block abandoning of solid-state disk
CN107506148A
IO request processing method, system and device and computer readable storage medium
CN111399767A