Test method of storage device, electronic device and computer program product

CN123033544APending Publication Date: 2026-11-03BIWIN STORAGE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611528991.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-30
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

Existing storage device testing methods lack effective timing coordination mechanisms in concurrent scenarios, resulting in poor test results. In particular, in scenarios involving multiple segments of trimming, reading and writing, and data verification, testing tools cannot simultaneously support the concurrent scheduling of the three operations, increasing testing difficulty and implementation costs, and potentially leading to false positives in verification results.

Method used

By recording the pruning status of the storage area with a flag bit, the expected data for the verification read command is adaptively determined. Combined with preset verification conditions, concurrent operations are uniformly scheduled and decided. Operations that do not meet the conditions are dynamically switched to the pruning branch, realizing the coordinated execution of read, write, pruning and verification operations. It is suitable for single-segment and multi-segment pruning scenarios and ensures the determinism of operation timing.

Benefits of technology

This improved the accuracy and reliability of test results, reduced test complexity, and enabled comprehensive functional verification of storage devices under complex concurrent loads, thereby enhancing their applicability and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123033544A_ABST
    Figure CN123033544A_ABST
Patent Text Reader

Abstract

The application is suitable for the technical field of storage, and provides a test method of a storage device, an electronic device and a computer program product. The method comprises the following steps: acquiring a concurrent test task for the storage device; judging whether a preset check condition is met; if yes, issuing a check read command to the storage device according to a mark bit, so as to read actual data; if not, issuing a clipping command according to a clipping type, so as to mark the data in a specified address range as invalid; and obtaining a test result according to a comparison result of the actual data and expected data. In the application, the clipping state is recorded by the mark bit, and the expected data is adaptively determined, so that the false positives of the check result caused by uncertain concurrent timing are eliminated, and the accuracy of the test result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of storage technology, and in particular relates to testing methods for storage devices, electronic devices, and computer program products. Background Technology

[0002] As storage device performance continues to improve, its application in various data storage scenarios is becoming increasingly widespread. To ensure the reliability and performance of storage devices in actual use, comprehensive functional verification and performance testing are required.

[0003] Currently, storage device testing typically employs concurrent I / O operations to simulate real-world load scenarios. However, this testing method suffers from poor reliability and fails to accurately reflect the true performance of the storage device. Summary of the Invention

[0004] This application provides a testing method, electronic device, and computer program product for storage devices, which can solve the technical problem of poor reliability in the testing methods for storage devices in the prior art.

[0005] In a first aspect, embodiments of this application provide a method for testing a storage device, including: Received a concurrent test task for the storage device. The concurrent test task is used to test the data read / write operation, data pruning operation, and data verification operation of the storage device. Determine whether the current condition meets the preset verification criteria; If the preset verification conditions are met, a verification read command is sent to the storage device according to the flag bit. The verification read command is used to read the actual data from the storage device, and the flag bit is used to record the clipping status of the storage area in the storage device. If the preset verification conditions are not met, a trimming command is sent to the storage device according to the trimming type of the data trimming operation. The trimming type includes single-segment trimming or multi-segment trimming. Based on the comparison between actual data and expected data, the test results of the concurrent test task are obtained.

[0006] In one possible implementation of the first aspect, issuing a verification read command to the storage device based on the flag bit includes: Obtain the flag bit from the first data node in the list of verification nodes. The first data node contains the starting offset and operation length for identifying the storage area to be verified in the storage device. Determine whether the current state is uncropped based on the flag bit; If the current state is undroped, construct a verification read command based on the starting offset and operation length, and send the verification read command to the storage device; or, If the flag indicates that the current state is clipping, no verification read command will be issued.

[0007] In one possible implementation of the first aspect, a pruning command is issued to the storage device according to the pruning type of the data pruning operation, including: If the clipping type is single-segment clipping, the flag bit is obtained from the second data node in the clipping node list, and the clipping command is issued based on the flag bit; If the clipping type is multi-segment clipping, determine the address range of the clipping operation based on the scenario type of the clipping operation, and issue the clipping command based on the address range.

[0008] In one possible implementation of the first aspect, the clipping command is issued based on the flag bit, including: If the flag indicates that the current state is not clipped, pass the flag to the clipping operation; A trim command is issued based on the starting offset and the operation length; the marker bit is cleared after the trim operation is completed; or, if the marker bit indicates that the current state is trim, no trim command is issued. In one possible implementation of the first aspect, the address range of the clipping operation is determined based on the scenario type of the clipping operation, and a clipping command is issued based on the address range, including: If the scenario type is sequential clipping, obtain the end position of the previous clipping operation and the end position of the previous write operation, and determine the start position of the current clipping operation based on the end positions of the previous clipping operation and the previous write operation; determine the address range of the current clipping operation based on the preset interval length and the start position, and issue clipping commands based on the address range. If the scene type is random cropping, the starting position of the current cropping operation is randomly generated; the address range of the current cropping operation is determined based on the preset interval length and the starting position, and cropping commands are issued according to the address range.

[0009] In one possible implementation of the first aspect, the pruning command is issued based on the address range, including: Repeat the steps to determine the address range until the number of determined address ranges reaches the preset number; Construct the same multi-segment trimming command based on the determined address range; Send multiple trimming commands to the storage device.

[0010] In one possible implementation of the first aspect, after issuing the pruning command to the storage device, the following is also included: Insert the address range corresponding to the pruning command into the red-black tree. The red-black tree is used to record the address range of all pruning operations that have been executed. Send a verification read command to the storage device, including: The verification address range is determined based on the starting offset and the operation length. Perform the first overlap check in the red-black tree to find if there is a pruning address range in the red-black tree that overlaps with the check address range; If there is no overlap, a verification read command is sent to the storage device; or, If there is overlap, skip this verification operation and do not issue a verification read command.

[0011] One possible implementation of the first aspect also includes: Obtain the actual data read when the storage device executes a verification read command; Perform a second overlap check in the red-black tree to determine whether there is a pruning address range in the red-black tree that overlaps with the check address range; If there is no overlap, the actual data is compared with the expected data to obtain the comparison result; or, If there is overlap, the verification result will be discarded and no data comparison will be performed.

[0012] In one possible implementation of the first aspect, the test results of the concurrent test task are obtained based on the comparison between the actual data read by the verification read command and the expected data, including: If the comparison results show that the actual data matches the expected data, the test result of the concurrent test task is determined to be a pass. If the comparison results show that the actual data is inconsistent with the expected data, then the test result of the concurrent test task is determined to be a test failure.

[0013] Secondly, embodiments of this application provide a testing apparatus for a storage device, comprising: The task acquisition module is used to acquire concurrent test tasks for storage devices. These concurrent test tasks are used to test data read / write operations, data pruning operations, and data verification operations of the storage devices. The judgment module is used to determine whether the preset verification conditions are met. The command issuance module is used to issue a verification read command to the storage device according to the flag bit when the preset verification conditions are met. The verification read command is used to read the actual data from the storage device, and the flag bit is used to record the clipping status of the storage area in the storage device. In addition, when the preset verification conditions are not met, a pruning command is sent to the storage device according to the pruning type of the data pruning operation. The pruning command is used to mark the data in the specified address range in the storage device as invalid. The pruning type includes single-segment pruning or multi-segment pruning. The test result acquisition module is used to obtain the test results of concurrent test tasks based on the comparison between the actual data read by the verification read command and the expected data.

[0014] Thirdly, embodiments of this application provide an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method as described in any of the first aspects.

[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed, implements the method of any one of the first aspects.

[0016] Fifthly, embodiments of this application provide a computer program product, which includes: computer program code, which, when run on a computer, causes the computer to perform the method described in any of the first aspects above.

[0017] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.

[0018] In this embodiment, after receiving a concurrent test task for a storage device, a write operation is first performed to write test data to the storage device, and then it is determined whether the preset verification conditions are met. If they are met, a verification read command is sent to the storage device according to the flag bit to read the actual data. If they are not met, a trimming command is sent to the storage device according to the trimming type to mark the data in the specified address range as invalid. Finally, the actual data read by the read command is compared with the expected data to obtain the test result.

[0019] By using the above method, the pruning status of the storage area is recorded by a flag bit, so that the expected data of the verification read command can be adaptively determined according to the status. This ensures the timing determinism of the three types of operations, namely read, write, pruning and verification, when executed concurrently, eliminates false alarms in the verification results caused by the uncertainty of the timing between operations, and improves the accuracy of the test results.

[0020] Meanwhile, by setting up unified scheduling decisions for concurrent operations based on preset verification conditions, operations that do not meet the conditions are dynamically switched to the pruning branch. This enables the coordinated execution of read / write operations, pruning operations, and verification operations in mixed concurrent scenarios, eliminating the need for testers to write complex concurrency control logic and reducing testing complexity.

[0021] Secondly, by scheduling single-segment and multi-segment pruning separately according to pruning type, it adapts to a variety of pruning operation scenarios, solves the functional deficiency problem in multi-segment pruning and mixed concurrent testing of read / write and verification, realizes comprehensive functional verification of storage devices under complex concurrent loads, and further improves the applicability and reliability of the testing method. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0023] Figure 1 This is a flowchart illustrating a testing method for a storage device provided in an embodiment of this application. Figure 1 ; Figure 2 This is a flowchart illustrating a testing method for a storage device provided in an embodiment of this application. Figure 2 ; Figure 3 This is a flowchart illustrating the verification read command issuance process provided in an embodiment of this application; Figure 4 This is a flowchart illustrating the cropping command issuance process according to an embodiment of this application; Figure 5 This is a flowchart illustrating the multi-segment cropping command issuance process provided in an embodiment of this application; Figure 6 This is a schematic diagram illustrating the region isolation principle in a sequential multi-segment clipping scenario provided by an embodiment of this application; Figure 7 This is a schematic diagram of the principle of a red-black tree provided in one embodiment of this application; Figure 8 This is a flowchart illustrating the red-black tree overlap detection and data comparison process provided in an embodiment of this application; Figure 9 This is a structural block diagram of a testing device provided in an embodiment of this application; Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0024] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0025] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0026] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0027] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0028] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0029] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0030] First, the terminology used in the embodiments of this application will be explained: Solid State Drive (SSD); Embedded Multi Media Card (eMMC); Universal Flash Storage (UFS); Input / Output (I / O); Read / Write (RW) operations: I / O operations that write data to or read data from a storage device; Trim operation: An instruction that instructs the storage device to mark data within a specified logical address range as invalid, and that the data can be used for subsequent garbage collection or erase operations; Verification: The operation of reading data from the storage device and comparing the actual data with the expected data to verify the correctness of the data on the storage device; Flag bit: A status indicator used to record whether a specified storage area in the storage device has been pruned; Red-Black Tree (RBT): A self-balancing binary search tree used to record the address range of all pruning operations performed, supporting insertion, deletion, and search operations; Verify Node List: A linked list used to store information about data nodes to be verified. Each data node contains the starting offset and operation length of the storage area to be verified. Trim Node List: A linked list used to store information about data nodes to be trimmed. Each data node contains the starting offset and operation length of the storage area to be trimmed. Single-Range Trim: Each trim command contains only a trim operation for one address range; Multi-Range Trim: Each trimming command contains trimming operations for multiple address ranges.

[0031] As storage device performance continues to improve, its application in various data storage scenarios is becoming increasingly widespread. To ensure the reliability of storage devices, comprehensive functional verification and performance testing are necessary.

[0032] Currently, when testing storage devices, multiple I / O operations are typically performed concurrently to simulate real-world load scenarios. Specifically, data read / write, data trim / deallocate, and data verification are the three most basic and core operation types. These three operations often need to be executed in a multi-threaded, multi-queue concurrent environment to simulate real business loads and verify the consistency of the storage device's behavior under complex pressure.

[0033] However, the inventors discovered that the above three operations lack an effective timing coordination mechanism when executed concurrently, resulting in poor accuracy of the test results. Specifically, this manifests in the following two aspects: Firstly, in scenarios involving multiple segments of clipping, reading / writing, and data verification in a mixed concurrent manner, the testing tool cannot simultaneously support the concurrent scheduling of the three operations. Testers need to write complex concurrency control logic themselves, which increases the difficulty of testing and the implementation cost.

[0034] Secondly, in scenarios involving single-segment pruning, read / write operations, and concurrent data verification, the lack of an effective timing coordination mechanism between pruning and verification read operations can lead to situations where the target area has already been pruned before the verification read operation is issued, or a new pruning command happens to cover the area during the verification read operation's response return. This results in inconsistencies between the read data and the expected data. This inconsistency is not caused by storage device failure, but rather by the timing uncertainties inherent in the testing tool itself, causing false alarms in the verification results and interfering with the efficiency of problem localization.

[0035] Therefore, how to ensure the accuracy and reliability of test results in a mixed concurrent scenario of reading, writing, cropping, and data verification has become a key focus for those skilled in the art.

[0036] In view of this, embodiments of this application provide a testing method, electronic device, and computer program product for a storage device. Upon receiving a concurrent test task for the storage device, it is determined whether a preset verification condition is met. If met, a verification read command is sent to the storage device based on a flag bit. This verification read command is used to read actual data from the storage device, and the flag bit is used to record the pruning status of the storage area in the storage device. If not met, a pruning command is sent to the storage device based on the pruning type. The pruning command is used to mark data within a specified address range in the storage device as invalid. The pruning type includes single-segment pruning or multi-segment pruning. Finally, the test result of the concurrent test task is obtained based on the comparison result between the actual data read by the verification read command and the expected data.

[0037] By using the above method, the pruning status of the storage area is recorded by a flag bit, so that the expected data of the verification read command can be adaptively determined according to the status. This ensures the timing determinism of the three types of operations, namely read, write, pruning and verification, when executed concurrently, eliminates false alarms in the verification results caused by the uncertainty of the timing between operations, and improves the accuracy of the test results.

[0038] Meanwhile, by setting up unified scheduling decisions for concurrent operations based on preset verification conditions, operations that do not meet the conditions are dynamically switched to the pruning branch. This enables the coordinated execution of read / write operations, pruning operations, and verification operations in mixed concurrent scenarios, eliminating the need for testers to write complex concurrency control logic and reducing testing complexity.

[0039] Secondly, by scheduling single-segment and multi-segment pruning separately according to pruning type, it adapts to a variety of pruning operation scenarios, solves the functional deficiency problem in multi-segment pruning and mixed concurrent testing of read / write and verification, realizes comprehensive functional verification of storage devices under complex concurrent loads, and further improves the applicability and reliability of the testing method.

[0040] In some embodiments, the electronic device (e.g., a host) involved in this application issues I / O operations to the storage device and verifies the execution results returned by the storage device to obtain the test results of the storage device. Exemplarily, the electronic device may be a computer, server, workstation, industrial control equipment, or edge computing device, etc.

[0041] In some embodiments, the electronic device runs a testing tool that initiates concurrent test tasks and issues write commands, read verification commands, and pruning commands to the storage device. For example, this testing tool could be fio (Flexible I / O Tester, an open-source I / O performance testing and stress verification tool) or an I / O performance testing tool with similar functionality.

[0042] In some embodiments, the storage device is configured to respond to I / O operations issued by an electronic device, perform corresponding data writing, data reading, or data trimming, and return the execution result or the actual data read to the electronic device. Exemplarily, the storage device includes, but is not limited to, SSDs, eMMC, and UFS.

[0043] Accordingly, the electronic device compares the execution results returned by the storage device or the actual data read, thereby obtaining the test results for the storage device. These test results characterize the functional correctness and data consistency of the storage device under mixed concurrent scenarios of read / write, pruning, and verification.

[0044] Figure 1 This is a flowchart illustrating a testing method for a storage device provided in an embodiment of this application. Figure 1 It should be understood that the execution subject of the embodiments of this application is an electronic device. For example... Figure 1 As shown, the test method includes the following steps: S101, Obtain concurrent test tasks for storage devices.

[0045] In some embodiments, the concurrent test task is used to instruct at least two of the following to be performed simultaneously on the storage device: data read / write operations, data pruning operations, and data verification operations, thereby testing the data consistency and functional correctness of the storage device under mixed concurrent scenarios of real business load.

[0046] During the testing of storage devices, electronic devices acquire concurrent test tasks for the storage devices. For example, the electronic device runs a testing tool (such as fio), and these concurrent test tasks can be configured and issued by testers (e.g., the electronic device can trigger acquisition in response to a tester's operation command, i.e., executing S101 when the tester starts the test); or, they can be automatically triggered in an automated testing process according to a preset test plan (e.g., automatically issuing concurrent test tasks according to set test cases during regression testing or stress testing). It should be understood that the above methods are merely examples, and this application does not impose specific limitations on them.

[0047] Optionally, after acquiring the concurrent test task, the electronic device can issue a write command to the storage device through a test tool to write test data within a specified address range of the storage device. For example, this test data can be a preset data pattern (such as random data, fixed data, or a specific data pattern) used as expected data during subsequent verification read operations. The electronic device can synchronously record the address range of the write command and the written data content to determine the expected data during the verification phase.

[0048] Furthermore, after a write command is successfully executed, the electronic device sets the flag of the corresponding storage area to an unpruned state to indicate that the data in that area is valid. If the storage area had previously been pruned, the write operation will overwrite the original invalid data, restoring the area to a valid data state. Subsequent read operations will then update the expected data to the test data written in this operation.

[0049] Optionally, after receiving a write command, the storage device can write test data to a specified address range and return the execution result of the write operation to the electronic device (such as a status code indicating success or failure).

[0050] S102, determine whether the current condition meets the preset verification conditions.

[0051] In some embodiments, after receiving a concurrent test task, the electronic device determines whether preset verification conditions are met. These preset verification conditions indicate whether the storage area to be verified is in a verifiable state. For example, the preset verification conditions may include one or more of the following: the storage area has completed data writing, the storage area is not undergoing a pruning operation, and the current test thread's scheduling state allows for the insertion of a verification read operation. The electronic device makes a comprehensive judgment based on the above conditions to determine whether it is appropriate to issue a verification read command.

[0052] In some embodiments, the preset verification conditions can be dynamically determined based on the current state of the storage device. For example, when the storage area to be verified is being processed by a pruning operation, the electronic device determines that the preset verification conditions are not currently met; when the storage area to be verified has completed data writing and is not undergoing any operation processing, the electronic device determines that the preset verification conditions are currently met. It should be understood that the above conditions are merely examples, and the specific content of the preset verification conditions can be flexibly set by those skilled in the art according to the actual test scenario. This application does not impose any specific limitations on this.

[0053] S103, if the preset verification conditions are met, a verification read command is sent to the storage device according to the flag bit.

[0054] The read command is used to read actual data from the storage device, and the flag bit is used to record the pruning status of the storage area in the storage device. For example, the flag bit can be stored in the memory of the electronic device as bits, with each bit corresponding to a storage area, indicating whether that area has been pruned. By reading the value of the flag bit, the electronic device can determine whether the target storage area is in a pruned state.

[0055] In some embodiments, before sending a verification read command to the storage device, the electronic device first determines the expected data based on the state of the flag bits, and then sends a verification read command carrying the read address to the storage device. In response to the verification read command, the storage device reads the actual data from the specified storage area and returns it to the electronic device. The electronic device receives the actual data returned by the storage device and temporarily stores it in memory for subsequent data comparison operations.

[0056] S104 If the preset verification conditions are not met, a trimming command is sent to the storage device according to the trimming type of the data trimming operation.

[0057] In some embodiments, pruning commands are used to mark data within a specified address range in a storage device as invalid. Pruning types include single-segment pruning and multi-segment pruning. Single-segment pruning means that each pruning command contains only one address range, used to mark data in a single, contiguous address interval as invalid. Multi-segment pruning means that each pruning command contains multiple address ranges, used to mark data in multiple non-contiguous address intervals as invalid in a single command.

[0058] In some embodiments, after a pruning command is issued, the storage device responds by marking the data in the specified address range as invalid. When the marked invalid data is subsequently read, the storage device may return all zeros or other preset values, depending on the implementation of the storage device. Simultaneously, the electronic device updates the status of the marker bits, setting the marker bits corresponding to the pruned storage area to a pruned state for use in determining the expected data for subsequent read commands.

[0059] S105: Based on the comparison between the actual data read by the verification read command and the expected data, obtain the test results of the concurrent test task.

[0060] In some embodiments, after receiving the actual data returned by the verification read command, the electronic device compares the actual data with the expected data and obtains the test results of the concurrent test task based on the comparison result. The expected data is determined by the state of the flag bit. For example, if the flag bit is not set (i.e., the storage area has not been pruned), the expected data is the test data previously written to the area via a write command; if the flag bit is set (i.e., the storage area has been pruned), the expected data is all zeros.

[0061] In some embodiments, the electronic device can compare the actual data with the expected data byte by byte. If all bytes match, the verification is considered successful; if there are inconsistent bytes, the verification is considered a failure. Optionally, the electronic device records the verification success or failure result and can output the result as the test result of a concurrent test task. For example, after the test is completed, the electronic device can display a success or failure message to the tester, or generate a test report containing the verification results.

[0062] It should be noted that during the comparison process, if the actual data matches the expected data, it indicates that the data behavior of the storage device within the address range involved in the verification read command is as expected; if they do not match, it indicates that the storage device may have data errors or abnormal behavior within that address range. Through this method, the electronic device can obtain the test results of concurrent test tasks, providing a basis for the functional verification and performance evaluation of the storage device.

[0063] In the above method, the pruning state of the storage area is recorded by a flag bit, so that the expected data of the verification read command can be adaptively determined according to the state. This ensures the timing determinism of the three types of operations, namely read, write, pruning and verification, when executed concurrently, eliminates false alarms in the verification results caused by the uncertainty of the timing between operations, and improves the accuracy of the test results.

[0064] Meanwhile, by setting up unified scheduling decisions for concurrent operations based on preset verification conditions, operations that do not meet the conditions are dynamically switched to the pruning branch. This enables the coordinated execution of read / write operations, pruning operations, and verification operations in mixed concurrent scenarios, eliminating the need for testers to write complex concurrency control logic and reducing testing complexity.

[0065] Secondly, by scheduling single-segment and multi-segment pruning separately according to pruning type, it adapts to a variety of pruning operation scenarios, solves the functional deficiency problem in multi-segment pruning and mixed concurrent testing of read / write and verification, realizes comprehensive functional verification of storage devices under complex concurrent loads, and further improves the applicability and reliability of the testing method.

[0066] Figure 2 This is a flowchart illustrating a testing method for a storage device provided in an embodiment of this application. Figure 2 It should be understood that the execution subject of the embodiments of this application is an electronic device. For example... Figure 2 As shown, the test method specifically includes the following steps: S201, Obtain concurrent test tasks for storage devices.

[0067] S202, determine whether the current condition meets the preset verification conditions.

[0068] S203, if the preset verification conditions are met, a verification read command is sent to the storage device according to the flag bit.

[0069] It should be noted that the implementation methods of S201~S203 are different from those of S201~S203. Figure 2 Steps S101 to S103 in the illustrated embodiment are similar and will not be described in detail here.

[0070] S204. If the preset verification conditions are not met, determine the cropping type of the cropping operation.

[0071] The cutting types include single-segment cutting and multi-segment cutting.

[0072] S205, if the clipping type is single-segment clipping, obtain the marker bit from the second data node in the clipping node list, and issue a clipping command based on the marker bit.

[0073] Specifically, the electronic device can obtain the marker bit from the second data node in the trim node list (i.e., the trim node list). For example, the trim node list is used to store information about the data nodes to be trimmed, and the second data node contains the starting offset and operation length (len) of the storage area to be trimmed in the storage device.

[0074] Furthermore, the electronic device issues a trim command based on the acquired flag bit. Specifically, the electronic device determines whether the current state is uncropped based on the flag bit; if the current state is uncropped, the flag bit is passed to the trim operation, a trim command is issued based on the starting offset and the operation length, and the flag bit is cleared after the trim operation is completed; if the flag bit indicates that the current state is trimmed, no trim command is issued.

[0075] By using the above method, clipping commands are only issued in the un-clipping state, and not in the clipping state. This avoids repeated clipping of the same area, reduces invalid command issuance, and improves testing efficiency. Furthermore, clearing the marker bits after clipping synchronizes the marker bits with the actual execution result of the clipping operation, ensuring that subsequent verification read commands can determine the expected data based on the correct status of the marker bits, thus avoiding incorrect judgment of expected data.

[0076] S206, If the clipping type is multi-segment clipping, determine the scene type of the clipping operation.

[0077] In some embodiments, the scene type includes two types: sequential cropping and random cropping.

[0078] Sequential clipping refers to an electronic device determining the starting position of the current clipping operation as the ending position of the previous clipping operation, so that the address range of the clipping operation advances continuously in the address space.

[0079] Random pruning refers to an electronic device using a random number generation algorithm to randomly generate the starting position of the current pruning operation within the address space of the storage device, so that the address ranges of each pruning operation are randomly distributed in the address space and there is no fixed address contiguous relationship between them.

[0080] S207, if the scene type is sequential cropping, obtain the end position of the previous cropping operation and the end position of the previous cropping operation, and determine the start position of the current cropping operation based on the end position of the previous cropping operation and the end position of the previous cropping operation; determine the address range of the current cropping operation based on the preset interval length and the start position, and issue a cropping command based on the address range.

[0081] In some embodiments, since write and trim operations are executed concurrently, each maintains its own end position, and the end positions of both are updated synchronously after each operation is completed. To ensure that the address range of the current trim operation does not overlap with the area of ​​the previously executed write operation, the electronic device compares the end position of the previous write operation with the end position of the previous trim operation, and takes the larger of the two values ​​as the start position of the current trim operation.

[0082] For example, the electronic device obtains the end position of the previous clipping operation from the last region information saved in the clipping operation, and at the same time obtains the end position of the previous write operation from the record of the write operation. The two are compared, and the larger end position is used as the starting position of the current clipping operation, so that the address range of the clipping operation advances continuously in the address space and does not overlap with the write region.

[0083] Furthermore, after determining the starting position, the electronic device determines the address range for the current trimming operation based on a preset interval length (e.g., 128KB) and the starting position. For example, the end position of the address range is the sum of the starting position and the preset interval length. Accordingly, the electronic device issues a trimming command based on the determined address range.

[0084] In the above manner, in the sequential pruning scenario, the starting position of the current pruning operation is determined based on the later end position of the previous write operation and the previous pruning operation. This ensures that the write region and the pruning region do not overlap in the address space, and realizes the continuous advancement of the pruning operation in the address space, which facilitates batch testing of continuous address ranges of storage devices.

[0085] S208, if the scene type is random cropping, randomly generate the starting position of the current cropping operation; determine the address range of the current cropping operation based on the preset interval length and the starting position, and issue cropping commands according to the address range.

[0086] In some embodiments, the electronic device may employ a random number generation algorithm to randomly generate a starting offset within the address space of the storage device to simulate the scenario in real business where pruning operations are randomly distributed in the address space.

[0087] Furthermore, after randomly generating the starting position, the electronic device determines the address range of the current trimming operation based on the preset interval length (e.g., 128KB) and the starting position, and issues a trimming command according to the determined address range. For example, the ending position of the address range is the sum of the starting position and the preset interval length.

[0088] By using the above method, the starting position is randomly generated in the random pruning scenario, simulating the scenario where pruning operations are randomly distributed in the address space during actual operation of the storage device, thus improving the comprehensiveness and coverage of the test.

[0089] S209: Based on the comparison between the actual data read by the verification read command and the expected data, obtain the test results of the concurrent test task.

[0090] Specifically, after receiving the actual data returned by the verification read command, the electronic device compares the actual data with the expected data and obtains the test results of the concurrent test task based on the comparison result. The expected data is determined by the state of the flag bit: if the flag bit is not set (i.e., the storage area has not been pruned), the expected data is the test data previously written to that area via the write command; if the flag bit is set (i.e., the storage area has been pruned), the expected data is all zeros.

[0091] For example, the electronic device compares the actual data with the expected data byte by byte. If all bytes are consistent, the verification is considered successful and the concurrent test task is considered successful; if there are inconsistent bytes, the verification is considered unsuccessful and the concurrent test task is considered unsuccessful.

[0092] Furthermore, the electronic device records the result of the verification as either successful or unsuccessful, and outputs the result as the test result of the concurrent test task.

[0093] It should be noted that during the comparison process, if the actual data matches the expected data, it indicates that the data behavior of the storage device within the address range involved in the verification read command is as expected; if they do not match, it indicates that the storage device may have data errors or abnormal behavior within that address range. Through this method, the electronic device can obtain the test results of concurrent test tasks, providing a basis for the functional verification and performance evaluation of the storage device.

[0094] Figure 3 This is a flowchart illustrating the verification read command issuance process according to an embodiment of this application. It should be understood that the execution entity in this embodiment is an electronic device. Figure 3 As shown, the verification read command issuance process specifically includes the following steps: S301, if the preset verification conditions are met, obtain the flag bit from the first data node in the verification node list.

[0095] The first data node contains the starting offset and operation length for identifying the storage area to be verified in the storage device.

[0096] In some embodiments, after satisfying preset verification conditions, the electronic device retrieves a first data node from a verification node list (i.e., a verify node list). Exemplarily, the verification node list is a linked list structure maintained in the electronic device's memory, used to store information about all data nodes to be verified. Each data node corresponds to a storage area in the storage device, containing the starting offset and operation length of that storage area. The electronic device traverses the verification node list and reads the first data node from it to obtain the tag bit stored in that node.

[0097] It should be noted that the flag bit is used to record whether the storage area corresponding to the data node has been pruned. For example, the flag bit can be stored in the first data node in the form of bits, such as 1 indicating pruning and 0 indicating no pruning. The electronic device can quickly determine the pruning status of the target storage area by reading the value of this flag bit.

[0098] S302, determine whether the current state is uncropped based on the flag bit.

[0099] In some embodiments, after acquiring a flag bit, the electronic device determines whether the current storage area is in an uncropped state based on the value of the flag bit. For example, if the value of the flag bit is 0 (not set), it is determined that the current state is uncropped; if the value of the flag bit is 1 (set), it is determined that the current state is uncropped.

[0100] It should be noted that the setting of the flag bit reflects the pruning status of the storage area. When a storage area has been pruned, the flag bit corresponding to that area is set to the pruned state; when the area is subsequently rewritten with data, the flag bit can be cleared (restored to the unpruned state) to indicate that the data in that area has been updated.

[0101] S303, if the current state is undone, construct a verification read command based on the starting offset and operation length.

[0102] In some embodiments, when the electronic device determines that the current state is uncropped, it constructs a verification read command based on a starting offset and an operation length. Exemplarily, the verification read command includes at least a starting address (determined by the starting offset) and a read length (determined by the operation length), instructing the storage device to read data from a specified address range. The electronic device can fill the starting offset and operation length into the corresponding fields of the command to construct the verification read command.

[0103] S304 sends a verification read command to the storage device.

[0104] Specifically, after constructing the verification read command, the electronic device sends the verification read command to the storage device. For example, the electronic device can send the verification read command to the storage device via the NVMe protocol or the io_uring_cmd engine. Correspondingly, the storage device responds to the verification read command, reads data from the specified address range, and returns the actual data to the electronic device.

[0105] S305: If the flag indicates that the current state is clipping, no verification read command will be issued.

[0106] In some embodiments, if the flag indicates that the current state is pruning, it means that the storage area has been marked as invalid by the pruning operation, and its data no longer has verification significance. In this case, the electronic device does not issue a verification read command.

[0107] For example, the electronic device may skip the verification read operation of the current data node and continue to process the next data node in the verification node list; or, if the current data node is the last node to be verified, the current verification process will end.

[0108] By using the above method, the verification read command is only built and issued in the untrimmed state, and the verification read command is not issued in the trimmed state. This avoids invalid verification read operations on the trimmed areas, reduces the number of command issuances, and improves the overall testing efficiency.

[0109] Figure 4 This is a flowchart illustrating the cropping command issuance process according to an embodiment of this application. It should be understood that the executing entity in this embodiment is an electronic device. Figure 4 As shown, the process of issuing the cropping command includes the following steps: S401, if the clipping type is single-segment clipping, obtain the marker bit from the second data node in the clipping node list.

[0110] The second data node contains the starting offset and operation length for identifying the storage region to be pruned in the storage device.

[0111] In some embodiments, when the electronic device determines that the clipping type is single-segment clipping, it retrieves a second data node from the clipping node list. Exemplarily, the clipping node list is a linked list structure maintained in the electronic device's memory, used to store information about all data nodes to be clipped. Each data node corresponds to a storage area in the storage device, containing the starting offset and operation length (len) of that storage area. The electronic device traverses the clipping node list, reads the second data node from it, and retrieves the flag bit stored in that node.

[0112] S402, determine whether the current state is uncropped based on the flag bit.

[0113] In some embodiments, after acquiring a flag bit, the electronic device determines whether the current storage area is in an uncropped state based on the value of the flag bit. For example, if the value of the flag bit is 0 (not set), it is determined that the current state is uncropped; if the value of the flag bit is 1 (set), it is determined that the current state is uncropped.

[0114] S403, if the current state is undone, pass the flag bit to the clipping operation.

[0115] In some embodiments, when the electronic device determines that the current state is uncropped, it passes a flag bit to the cropping operation. For example, the electronic device uses the value of the flag bit as an input parameter to the cropping operation, enabling the cropping operation to obtain the cropping status of the region during execution, thereby determining whether the flag bit needs to be cleared after cropping is complete. It should be noted that the flag bit remains uncropped until the cropping operation is complete, allowing other operations (such as verification reads) to query this status during cropping.

[0116] S404 issues a trimming command based on the starting offset and the operation length.

[0117] In some embodiments, the electronic device constructs and issues a pruning command based on a starting offset and an operation length in a second data node. Exemplarily, the pruning command includes a starting address (determined by the starting offset) and an operation length, instructing the storage device to mark data within that address range as invalid.

[0118] S405 Clears the markers after the trimming operation is complete.

[0119] In some embodiments, after the storage device returns the execution result of the trim command, the electronic device clears the flag bit from its current value (indicating an untrimmed state), that is, sets the flag bit to a trimmed state to record that the storage area has been trimmed. In this way, the flag bit is updated after the trim operation is completed, so that subsequent verification read commands can correctly identify the trimming status of the area.

[0120] S406 If the flag indicates that the current state is clipping, then no clipping command will be issued.

[0121] In some embodiments, if the flag indicates that the current state is clipping, it means that the storage area has been marked as invalid by the clipping operation and there is no need to perform clipping again. In this case, the electronic device does not issue a clipping command.

[0122] For example, the electronic device can skip the pruning operation of the current data node and continue processing the next data node in the pruning node list; or, if the current data node is the last node to be pruned, the current pruning process ends.

[0123] In this embodiment, the cropping command is only issued when the area is not cropped, which avoids repeated cropping operations on already cropped areas, reduces unnecessary command issuance, saves system overhead, and improves overall testing efficiency.

[0124] Furthermore, the marker bits are cleared after pruning, ensuring that the marker bit state is synchronized with the actual pruning state of the storage area. This avoids errors in the expected data judgment caused by the marker bit state lagging behind the actual pruning state, further guaranteeing the accuracy of the verification results and forming a closed-loop logic from pruning to verification.

[0125] Figure 5 This is a flowchart illustrating the multi-segment cropping command issuance process according to an embodiment of this application. It should be understood that the executing entity in this embodiment is an electronic device. Figure 5 As shown, the process of issuing multi-segment cropping commands includes the following steps: S501, If ​​the cropping type is multi-segment cropping, determine the starting position of the current cropping operation based on the scenario type of the cropping operation.

[0126] The scene types include two types: sequential cropping and random cropping.

[0127] Specifically, if the scenario type is sequential clipping, the end position of the previous write operation and the end position of the previous clipping operation are obtained, and the start position of the current clipping operation is determined based on the larger of the two values. For example, the electronic device obtains the end position of the previous clipping operation from the last region information saved in the clipping operation, and uses this end position as the start position of the current clipping operation, so that the address range of the clipping operation advances continuously in the address space.

[0128] Alternatively, if the scenario type is random pruning, the starting position of the current pruning operation is randomly generated. For example, the electronic device uses a random number generation algorithm to randomly generate a starting offset within the address space of the storage device to simulate a scenario where pruning operations are randomly distributed in the address space in real-world business scenarios.

[0129] S502 determines the address range of the current clipping operation based on the preset interval length and starting position.

[0130] In some embodiments, after determining the starting position, the electronic device determines the address range of the current clipping operation based on a preset interval length and the starting position. For example, the preset interval length can be 128KB, and the ending position of the address range is the sum of the starting position and the preset interval length. The electronic device temporarily stores the determined address range (including the starting and ending positions) in memory.

[0131] Figure 6 This is a schematic diagram illustrating the region isolation principle in a sequential multi-segment clipping scenario provided by an embodiment of this application. For example... Figure 6 As shown in the embodiments of this application, in the scenario of sequential multi-segment clipping, the electronic device achieves address space isolation between the writing region and the clipping region by synchronously updating the end position of the write operation and the end position of the clipping operation, and taking the larger of the two values ​​as the starting position of the next operation.

[0132] It should be noted that, Figure 6 In this context, a Range can be understood as an address range, defined by its starting position and length. The default range length (bs) is the length of the Range, which determines the size of the address range covered by each Range (e.g., 128KB).

[0133] For example, Figure 6The following example illustrates the process using a Range length of bs = 128KB. After each write operation, the electronic device synchronously updates the end position of the write operation and the end position of the trim operation. The starting position of the next operation advances from the synchronized end position, ensuring that the write region and the trim region do not overlap in the address space. The diagram uses Trim #1 and Trim #2 as examples.

[0134] In some embodiments, such as Figure 6 As shown, before Trim #1 is executed, write region #1 is executed first, covering the address range [0, 128KB]. After writing region #1 is completed, the electronic device updates the end position of the write operation to 128KB, and also updates the end position of the trim operation to 128KB. At this time, the end position of the previous write operation is 128KB, and the end position of the previous trim operation is also 128KB (the initial state can be considered the same). The larger value of the two, 128KB, is taken as the starting position of Trim #1. Subsequently, the electronic device executes Trim #1. This trim command contains 3 Ranges, each with a length of bs = 128KB, and a total coverage length of bs × 3 = 384KB. Among them, Range 1 covers [128KB, 256KB), Range 2 covers [256KB, 384KB), Range 3 covers [384KB, 512KB), and Trim #1 covers the entire [128KB, 512KB]. It can be seen that the starting address (128KB) of Trim #1 is the same as the ending position (128KB) of the write region #1. The two are contiguous in the address space but do not overlap.

[0135] In some embodiments, such as Figure 6 As shown, after Trim #1 is completed, the electronic device updates the end position of the trim operation to 512KB, and also updates the end position of the write operation to 512KB. Then, the electronic device executes write region #2, with the start position of write region #2 at 512KB (i.e., the synchronized end position), covering [512KB, 640KB). After write region #2 is completed, the electronic device again synchronizes and updates the end positions of the write and trim operations to 640KB. At this point, the end position of the previous write operation is 640KB, and the end position of the previous trim operation is 512KB (the end position of Trim #1). The larger value, 640KB, is taken as the start position of Trim #2. Then, the electronic device executes Trim #2, which covers the entire [640KB, 1024KB) range, containing three ranges: [640KB, 768KB), [768KB, 896KB), and [896KB, 1024KB].

[0136] In this way, after each operation is completed, the end positions of the write operation and the trim operation are updated simultaneously. When the next trim operation begins, the larger value between the end position of the previous write operation and the end position of the previous trim operation is taken as the starting position, so that the write region and the trim region do not overlap in the address space, thus ensuring the accuracy of data verification.

[0137] S503, determine whether the number of the determined address ranges has reached the preset number.

[0138] In some embodiments, if the preset number is not reached, the steps for determining the address range described above are repeated until the number of determined address ranges reaches the preset number. The preset number is the number of Ranges, for example, a preset number of 3.

[0139] In some embodiments, the electronic device repeatedly executes S501 and S502, determining one address range each time, until the number of determined address ranges reaches a preset number. For example, taking a multi-segment trimming command containing three address ranges as an example, the electronic device sequentially determines the first address range, the second address range, and the third address range. After each determination, it checks whether the accumulated number of address ranges has reached the preset number (3). If not, it continues to determine the next address range; if it has, it stops repeating the process.

[0140] It should be noted that the method for determining the starting position each time an address range is determined depends on the scenario type. For example, in a sequential scenario, the range is continuously advanced based on the ending position of the previous clipping operation (e.g., after the first address range ends, its ending position becomes the starting position of the second address range); in a random scenario, the range is generated independently and randomly each time.

[0141] S504: If the preset quantity has been reached, construct the same multi-segment trimming command based on the determined total address range.

[0142] In some embodiments, the electronic device encapsulates all determined address ranges in a single multi-segment trimming command according to a protocol format. For example, the multi-segment trimming command includes multiple address range descriptors, each containing a starting offset and an operation length (len), instructing the storage device to perform data invalidation processing on each of the multiple address ranges separately.

[0143] S505 sends multiple trimming commands to the storage device at once.

[0144] In some embodiments, the electronic device sends the constructed multi-segment trimming commands to the storage device all at once. Correspondingly, the storage device responds to the command by performing data invalidation processing on each address range separately. By sending the commands all at once, the number of command interactions is reduced, improving testing efficiency.

[0145] S506 inserts the address range corresponding to the pruning command into the red-black tree.

[0146] The red-black tree is used to record the address range of all pruning operations that have been performed.

[0147] In some embodiments, after issuing multiple pruning commands to the storage device, the electronic device inserts the entire address range contained in the commands into a red-black tree one by one. Exemplarily, a red-black tree is a self-balancing binary search tree that uses the starting address of each pruning operation as a sorting key to store the address ranges of all executed pruning operations. Each node contains at least a starting offset and an operation length for use in subsequent overlap detection during the verification phase.

[0148] It should be noted that S506 can be executed after the pruning command issued by S505 has been successfully executed; alternatively, it can be pre-inserted before S505 is issued to record the address range to be pruned earlier. This application does not impose specific limitations on this, as long as it ensures that the red-black tree contains all address ranges that have undergone pruning operations when performing overlap detection during the verification phase.

[0149] Figure 7 This is a schematic diagram illustrating the principle of a red-black tree according to an embodiment of this application. Figure 7 As shown, in this embodiment of the application, a red-black tree data structure is used to record the address range of all pruning operations that have been performed.

[0150] In some embodiments, the red-black tree uses the starting offset (start) of each pruning operation as the sort key. Each node corresponds to the address range of an executed pruning operation, and the node stores the starting offset (start) and operation length (len) of that address range. Each node in the tree has a color attribute, including red nodes (R) and black nodes (B), and the leaf nodes are NIL nodes.

[0151] For example, Figure 7 The image shows a red-black tree storing five pruning address ranges, which are black nodes: [0x60000, 0x7FFFF], [0x00000, 0x1FFFF], [0x40000, 0x5FFFF], [0x80000, 0x9FFFF] and [0xC0000, 0xDFFFF].

[0152] In this embodiment, the red-black tree supports only three operations: inserting a pruning range, detecting overlap, and clearing the entire tree. The inserting a pruning range operation inserts the newly pruned address range into the red-black tree after a pruning operation. The detecting overlap operation checks if there is a pruning interval in the red-black tree that overlaps with the verification address range before the verification read command is issued or after the response is returned. The clearing the entire tree operation releases the memory resources occupied by the red-black tree after the test process ends.

[0153] In this way, red-black trees can efficiently maintain the address range of all executed pruning operations, providing accurate overlap detection basis for the subsequent verification stage. At the same time, their self-balancing characteristics ensure search efficiency in large-scale concurrent test scenarios and avoid performance degradation caused by too many pruning records.

[0154] Figure 8 This is a flowchart illustrating the red-black tree overlap detection and data comparison process provided in one embodiment of this application. It should be understood that the execution entity in this embodiment is an electronic device. Figure 8 As shown, the red-black tree overlap detection and data comparison process specifically includes the following steps: S601 determines the verification address range based on the starting offset and operation length.

[0155] In some embodiments, when an electronic device needs to perform a verification operation, it determines the verification address range based on the starting offset of the first data node in the verification node list and the operation length. For example, the verification address range is [start, start + len - 1], where start is the starting offset and len is the operation length.

[0156] S602, perform the first overlap detection in the red-black tree to find whether there is a pruning address range in the red-black tree that overlaps with the check address range.

[0157] In some embodiments, the electronic device performs a first overlap detection in the red-black tree before issuing the verification read command. For example, the electronic device traverses the red-black tree using the verification address range as a query condition, checking whether there exists a pruning address range in the red-black tree that overlaps with the verification address range. Two address ranges overlapping means that they have an intersection, i.e., the start position of one address range is less than the end position of another address range, and the end position of one address range is greater than the start position of another address range.

[0158] S603 If there is overlap, skip this verification operation and do not issue a verification read command.

[0159] In some embodiments, if the result of the first overlap detection is that there is a clipped address range that overlaps with the verification address range, it indicates that the verification address range has been covered by a previous clipping operation, and its data state may have been modified. The electronic device skips this verification operation, does not issue a verification read command, and ends the current verification process.

[0160] S604 If there is no overlap, a verification read command is sent to the storage device.

[0161] In some embodiments, if the result of the first overlap detection is that there is no clipped address range overlapping with the verification address range, it indicates that the verification address range has not been covered by the previous clipping operation. The electronic device sends a verification read command to the storage device to read the actual data from the address range.

[0162] S605, retrieves the actual data read when the storage device executes a verification read command.

[0163] In some embodiments, the electronic device receives the execution result of a verification read command returned by the storage device and obtains the actual data read from it. For example, the actual data is the data content read by the storage device from the verification address range, which the electronic device temporarily stores in memory for subsequent comparison operations.

[0164] S606 performs a second overlap detection in the red-black tree to determine whether there is a pruning address range in the red-black tree that overlaps with the check address range.

[0165] In some embodiments, after the electronic device receives a response to the verification read command, it performs a second overlap detection in the red-black tree. For example, the electronic device again traverses the red-black tree using the verification address range as the query condition, checking whether, within the time period from the issuance of the verification read command to the return of the response, a new address range of a pruning operation has been inserted into the red-black tree and overlaps with the verification address range.

[0166] S607 If there is overlap, the verification result is discarded and no data comparison is performed.

[0167] It should be noted that the reason for performing the second overlap detection is that there is a time window between the issuance of the verification read command and the return of the response. During this period, new pruning operations may be issued and executed, and the address range they cover may overlap with the verification address range. As a result, the actual data read back has been modified by the new pruning operation and is no longer the original expected data.

[0168] In this scenario, if the second overlap detection indicates the existence of a clipped address range that overlaps with the verification address range, it means that a new clipping operation covered this verification address range during the execution of the verification read command, potentially modifying the actual data read back. Therefore, the electronic device discards this verification result and does not perform data comparison to avoid false alarms due to timing uncertainties.

[0169] S608 If there is no overlap, the actual data is compared with the expected data to obtain the comparison result.

[0170] In some embodiments, if the result of the second overlap detection is that there is no clipped address range overlapping with the verification address range, it indicates that no new clipping operation interfered with the verification address range during the execution of the verification read command. The electronic device compares the actual data read with the expected data to obtain the comparison result.

[0171] For example, the expected data is determined by the state of the flag bit: if the flag bit is not set (i.e., the storage area has not been pruned), the expected data is the test data previously written to the area via a write command; if the flag bit is set (i.e., the storage area has been pruned), the expected data is all zeros. The electronic device compares the actual data with the expected data byte by byte. If all bytes match, the comparison result is a pass; if there are inconsistent bytes, the comparison result is a failure.

[0172] S609: Based on the comparison between the actual data read by the verification read command and the expected data, the test results of the concurrent test task are obtained.

[0173] In some embodiments, if the comparison is consistent, the test result of the concurrent test task is determined to be a successful test; if the comparison is inconsistent, the test result of the concurrent test task is determined to be a failed test.

[0174] In some embodiments, the electronic device generates the final test result of the concurrent test task based on the comparison results. For example, if all bytes are consistent, the electronic device determines that the test result of the concurrent test task is a pass, and can show the tester a pass message or generate a test report containing the pass result; if there are inconsistent bytes, the electronic device determines that the test result of the concurrent test task is a fail, and can record the specific address range and byte differences of the inconsistency for problem localization and analysis.

[0175] In this embodiment, a red-black tree is used to record the address range of all executed pruning operations. A first overlap check is performed before the read command is issued, and a second overlap check is performed after the read command response is returned. Through this method, the first overlap check before the read command is issued identifies whether the verification address range has been covered by an already executed pruning operation, thus determining whether to issue the read command and avoiding invalid reads. The second overlap check after the read command response is returned identifies whether a new pruning operation was inserted and covered the verification address range during the execution of the read command, thus determining whether to perform data comparison. The two overlap checks work together to eliminate false alarms in the verification results caused by the timing uncertainty of concurrent read and pruning operations, ensuring the accuracy of the test results.

[0176] Corresponding to the test method in the above embodiments, Figure 9 This is a structural block diagram of a testing apparatus provided in one embodiment of this application, which is applied to an electronic device. For ease of explanation, only the parts relevant to the embodiment of this application are shown. (Refer to...) Figure 9 The testing apparatus includes: The task acquisition module 91 is used to acquire concurrent test tasks for storage devices. The concurrent test tasks are used to test the data read and write operations, data pruning operations and data verification operations of the storage devices. Module 92 is used to determine whether the preset verification conditions are met. The command issuing module 93 is used to issue a verification read command to the storage device according to the flag bit when the preset verification conditions are met. The verification read command is used to read the actual data from the storage device, and the flag bit is used to record the clipping status of the storage area in the storage device. In addition, when the preset verification conditions are not met, a trimming command is sent to the storage device according to the trimming type of the data trimming operation. The trimming type includes single-segment trimming or multi-segment trimming. The test result acquisition module 94 is used to obtain the test results of concurrent test tasks based on the comparison results of actual data and expected data.

[0177] This application provides an electronic device. Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. For example... Figure 10 As shown, the electronic device includes: at least one processor 100 ( Figure 10 (Only one is shown in the diagram), memory 101, and computer program 102 stored in memory 101 and executable on at least one processor 100, wherein processor 100 executes computer program 102 to implement the steps in any of the above method embodiments.

[0178] Electronic device 10 can be a desktop computer, laptop, handheld computer, cloud server, or other computing device. This electronic device may include, but is not limited to, a processor 100 and a memory 101. Those skilled in the art will understand that... Figure 10 This is merely an example of electronic device 10 and does not constitute a limitation on electronic device 10. It may include more or fewer components than shown, or combine certain components, or different components, such as input / output devices, network access devices, etc.

[0179] The processor 100 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0180] In some embodiments, memory 101 may be an internal storage unit of electronic device 10, such as a hard disk or memory of electronic device 10. In other embodiments, memory 101 may be an external storage device of electronic device 10, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on electronic device 100. Furthermore, memory 101 may include both internal and external storage units of electronic device 10. Memory 101 is used for operating system, electronic device, bootloader, data, and other programs, such as program code of computer programs. Memory 101 may also be used to temporarily store data that has been output or will be output.

[0181] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks.

[0182] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0183] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0184] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0185] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps described in the various method embodiments above.

[0186] This application provides a computer program product that, when run on an electronic device, enables the electronic device to perform the steps described in the various method embodiments above.

[0187] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0188] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0189] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0190] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A testing method for a storage device, characterized in that, include: Obtain concurrent test tasks for the storage device, the concurrent test tasks being used to test the data read / write operations, data pruning operations, and data verification operations of the storage device; Determine whether the preset verification conditions are met. If the preset verification conditions are met, a verification read command is sent to the storage device according to the flag bit. The verification read command is used to read actual data from the storage device. The flag bit is used to record the clipping status of the storage area in the storage device. If the preset verification conditions are not met, a trimming command is sent to the storage device according to the trimming type of the data trimming operation. The trimming type includes single-segment trimming or multi-segment trimming. The test results of the concurrent test task are obtained based on the comparison between the actual data and the expected data.

2. The method according to claim 1, characterized in that, The step of issuing a verification read command to the storage device based on the flag bit includes: The flag bit is obtained from the first data node in the list of verification nodes, the first data node containing the starting offset and operation length for identifying the storage area to be verified in the storage device; Determine whether the current state is uncropped based on the flag bit; If the current state is undroped, construct the verification read command based on the starting offset and the operation length, and send the verification read command to the storage device; or, If the flag indicates that the current state is clipping, the verification read command will not be issued.

3. The method according to claim 2, characterized in that, The step of issuing a trimming command to the storage device according to the trimming type of the data trimming operation includes: If the cropping type is single-segment cropping, then the flag bit is obtained from the second data node in the cropping node list, and the cropping command is issued according to the flag bit; If the cropping type is multi-segment cropping, the address range of the cropping operation is determined according to the scenario type of the cropping operation, and a cropping command is issued according to the address range; the scenario type includes sequential cropping and random cropping.

4. The method according to claim 3, characterized in that, The step of issuing the cropping command based on the flag bit includes: If the flag indicates that the current state is not clipped, the flag is passed to the clipping operation; The trimming command is issued based on the starting offset and the operation length, and the marker is cleared after the trimming operation is completed. Alternatively, if the flag indicates that the current state is clipping, then no clipping command is issued.

5. The method according to claim 3, characterized in that, The step of determining the address range of the cropping operation based on the scenario type of the cropping operation, and issuing the cropping command based on the address range, includes: If the scenario type is sequential cropping, obtain the end position of the previous cropping operation and the end position of the previous write operation, and determine the start position of the current cropping operation based on the end position of the previous cropping operation and the end position of the previous write operation; determine the address range of the current cropping operation based on the preset interval length and the start position, and issue the cropping command based on the address range. If the scenario type is random cropping, the starting position of the current cropping operation is randomly generated; the address range of the current cropping operation is determined based on the preset interval length and the starting position, and the cropping command is issued according to the address range.

6. The method according to claim 5, characterized in that, The step of issuing the cropping command based on the address range includes: Repeat the step of determining the address range until the number of determined address ranges reaches a preset number; Construct the same multi-segment trimming command based on the determined address range; The multi-segment trimming command is issued to the storage device.

7. The method according to any one of claims 2-6, characterized in that, After issuing the trimming command to the storage device, the process also includes: Insert the address range corresponding to the pruning command into a red-black tree, which is used to record the address range of all pruning operations that have been performed; Sending the verification read command to the storage device includes: The verification address range is determined based on the starting offset and the operation length; Perform a first overlap detection in the red-black tree to check if there is a pruning address range in the red-black tree that overlaps with the verification address range; If there is no overlap, the verification read command is sent to the storage device; or, if there is overlap, the verification operation is skipped and the verification read command is not sent.

8. The method according to claim 7, characterized in that, Also includes: Obtain the actual data read by the storage device when executing the verification read command; A second overlap detection is performed in the red-black tree to determine whether there is a pruning address range in the red-black tree that overlaps with the verification address range; If there is no overlap, the actual data is compared with the expected data to obtain the comparison result; or, if there is overlap, the verification result is discarded and no data comparison is performed.

9. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method as described in any one of claims 1 to 8.

10. A computer program product, characterized in that, The computer program product includes: computer program code, which, when run on a computer, causes the computer to perform the steps of the testing method for the storage device as described in any one of claims 1-8.