Storage device formatting test method, device, terminal device and storage medium
By sending formatting commands and performing functional tests on storage devices that support NVMe protocol, the problem of high formatting testing in the prior art is solved, and low-cost formatting functional testing is achieved.
Patent Information
- Application Number
- CN202011631247.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-30
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2040-12-30
AI Technical Summary
In the prior art, when testing the formatting function of the storage device that supports the NVMe protocol, it is necessary to use expensive special protocol testing equipment, and testers need to master the manufacturer's customized syntax, resulting in high testing costs.
By sending the NVMe protocol formatting command to the storage device during the reading and writing operation on the storage device that supports the NVMe protocol, check whether the device can format normally during the reading and writing process, and start the functional test after the formatting is successful, and determine that the formatting test is passed.
The formatting function test of storage devices that support NVMe protocol is realized, which reduces the testing cost, and the method can be implemented through ordinary personal computers and other devices.
Smart Images

Figure CN114694742B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of storage devices, and in particular to a formatting test method, apparatus, terminal device and storage medium for storage devices. Background Art
[0002] With the development of storage device technology, more and more storage devices (such as solid-state drives) are using the NVMe protocol. The NVMe protocol is an open collection of standards and information that can effectively improve the performance of storage devices and significantly reduce the time delay for accessing storage devices.
[0003] Currently, the method for testing the formatting function of a storage device supporting the NVMe protocol is mainly implemented through a dedicated protocol testing device.
[0004] However, existing protocol test equipment is expensive, and testers are required to master the syntax customized by the protocol test equipment manufacturer to develop test scripts, resulting in high costs for formatting function tests on storage devices. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a formatting test method, apparatus, terminal device and storage medium for a storage device, which can reduce the cost of formatting function testing of storage devices that support the NVMe protocol.
[0006] A first aspect of an embodiment of the present application provides a formatting test method for a storage device, comprising:
[0007] In the process of performing a read and write operation on a storage device supporting the NVMe protocol, a formatting command of the NVMe protocol is sent to the storage device;
[0008] If the storage device is successfully formatted after receiving the format command, stop performing read and write operations on the storage device and start a functional test on the storage device;
[0009] If the functional test of the storage device passes, it is determined that the formatting test of the storage device passes.
[0010] In the process of performing read and write operations on a storage device supporting the NVMe protocol, the embodiment of the present application sends a formatting command of the NVMe protocol to the storage device, thereby verifying whether the storage device can be formatted normally during the read and write process. In addition, after detecting that the storage device can be formatted normally during the read and write process, a functional test of the storage device will be initiated to verify whether the basic functions of the storage device after formatting are normal. Through such a setting, it is possible to test the formatting function of a storage device supporting the NVMe protocol, and the formatting test method can be implemented using an ordinary personal computer or other device, which greatly reduces the testing cost.
[0011] In one embodiment of the present application, before performing a read and write operation on a storage device supporting the NVMe protocol, the following may also be included:
[0012] Detecting whether the storage device is mounted;
[0013] If the storage device is mounted, the storage device is unmounted.
[0014] Before the tester performs the formatting function test on the storage device, the storage device may have been mounted on the terminal device by other personnel. In order to ensure the comprehensiveness and completeness of the formatting function test, before performing read and write operations on the storage device, you can first check whether the storage device has been mounted. If it has been mounted, unmount the storage device before performing read and write operations.
[0015] Further, detecting whether the storage device has been mounted may include:
[0016] Call the specified operating system command to obtain the mount information of all currently connected disks;
[0017] Searching the target mount information corresponding to the drive letter of the storage device from the mount information of all the disks;
[0018] Determining whether there is a mount point of the drive letter of the storage device according to the target mount information;
[0019] If there is a mount point of the drive letter of the storage device, determining that the storage device has been mounted;
[0020] If the mount point of the drive letter of the storage device does not exist, it is determined that the storage device is not mounted.
[0021] When detecting whether a storage device is mounted, some specified operating system commands can be called to obtain the mount information of all disks currently connected to the terminal device. Then, the target mount information corresponding to the drive letter of the storage device is searched from the mount information of all disks, and the corresponding mount point is determined according to the target mount information to determine whether the storage device is mounted.
[0022] In one embodiment of the present application, if the functional test of the storage device passes, before determining that the formatting test of the storage device passes, the following may also be included:
[0023] Mounting the storage device;
[0024] Performing a write operation on the storage device and verifying the written data;
[0025] If the write operation is performed on the storage device and the written data is verified successfully, the step of determining whether the formatting test of the storage device has passed is performed.
[0026] After the storage device is mounted, the terminal device performs a write operation on the storage device and verifies the written data. Specifically, the write operation may be a random write or a sequential write with a specified block size, and after the data is written, the data may be verified using a specified verification method. By setting this up, it is possible to further detect whether the write operation and verification of the storage device after formatting are normal.
[0027] Furthermore, if the write operation is performed on the storage device and the written data is verified successfully, before the step of determining whether the formatting test of the storage device has passed is performed, the following may also be included:
[0028] Unmounting the storage device;
[0029] Recording the completion of the formatting test process of the storage device once;
[0030] If the number of times the formatting test process of the storage device is completed does not reach the set number of cycles, return to the step of sending a formatting command of the NVMe protocol to the storage device during the process of performing read and write operations on the storage device supporting the NVMe protocol;
[0031] If the number of times the formatting test process of the storage device is completed reaches the number of cycles, the step of determining whether the formatting test of the storage device is passed is performed.
[0032] The storage device can be formatted normally during the reading and writing process, the basic functions after formatting are normal, and the write operation and verification after formatting are normal. If these three parts of the test pass at the same time, in order to improve the test accuracy and ensure sufficient test pressure, a cycle number can also be set to repeat multiple tests.
[0033] Furthermore, after sending the format command of the NVMe protocol to the storage device, the following may also be included:
[0034] If the storage device fails to format after receiving the format command, an error message is recorded in a test log file;
[0035] After starting the functional test on the storage device, the method may further include:
[0036] If the functional test of the storage device fails, an error message is recorded in the test log file;
[0037] After performing a write operation on the storage device and verifying the written data, the method may further include:
[0038] If the write operation is performed on the storage device and the written data is verified, an error message is recorded in the test log file;
[0039] If the number of times the formatting test process of the storage device has been completed has reached the number of cycles, the step of determining whether the formatting test of the storage device has passed may include:
[0040] If the number of times the formatting test process of the storage device has been completed has reached the number of cycles, detecting whether the test log file contains error information;
[0041] If the test log file does not contain error information, the step of determining whether the formatting test of the storage device has passed is performed.
[0042] By adding a test log file, each error in the formatting test process of the storage device is recorded in the test log file. Afterwards, when the formatting test of the storage device is completed, the formatting test result of the storage device can be easily obtained by detecting whether the test log file contains error information.
[0043] In one embodiment of the present application, in the process of performing a read and write operation on a storage device supporting the NVMe protocol, sending a format command of the NVMe protocol to the storage device may include:
[0044] Initiate a read and write operation on the storage device;
[0045] After delaying for a preset time, a formatting command of the NVMe protocol is sent to the storage device, and the preset time is less than the time required for the storage device to perform the read and write operations.
[0046] The NVMe format command can be sent to the storage device in the process of performing read and write operations on the storage device by delay. Specifically, when the read and write operations on the storage device are started, the timing starts, and when the timing reaches a preset time (for example, 1 to 5 minutes), the terminal device sends the NVMe format command to the storage device.
[0047] A second aspect of an embodiment of the present application provides a formatting test device for a storage device, comprising:
[0048] A formatting command sending module, used to send a formatting command of the NVMe protocol to the storage device during a read and write operation on the storage device supporting the NVMe protocol;
[0049] A read / write operation stopping module, configured to stop executing read / write operations on the storage device and start a functional test on the storage device if the storage device is successfully formatted after receiving the format command;
[0050] The formatting test result determination module is used to determine whether the formatting test of the storage device has passed if the functional test of the storage device has passed.
[0051] A third aspect of an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the formatting test method for a storage device provided in the first aspect of the embodiment of the present application are implemented.
[0052] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of the formatting test method of the storage device provided in the first aspect of the embodiment of the present application.
[0053] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the steps of the formatting test method for a storage device described in the first aspect of the embodiments of the present application.
[0054] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0056] Figure 1 It is a flowchart of an embodiment of a formatting test method of a storage device provided in an embodiment of the present application;
[0057] Figure 2 is a flowchart of another embodiment of a formatting test method for a storage device provided in an embodiment of the present application;
[0058] Figure 3 is a flowchart of another embodiment of a formatting test method for a storage device provided in an embodiment of the present application;
[0059] Figure 4 is a flowchart of another embodiment of a formatting test method for a storage device provided in an embodiment of the present application;
[0060] Figure 5 It is a schematic diagram of the operation flow of the formatting test method of a storage device provided by an embodiment of the present application in an actual application scenario;
[0061] Figure 6 It is a structural diagram of an embodiment of a formatting test device for a storage device provided in an embodiment of the present application;
[0062] Figure 7 It is a schematic diagram of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system structures, technologies, etc. are proposed, so as to thoroughly understand the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details. In other cases, the detailed description of well-known systems, devices, circuits and methods is omitted to prevent unnecessary details from hindering the description of the present application. In addition, in the description of the present application specification and the attached claims, the terms "first", "second", "third" etc. are only used to distinguish the description, and cannot be interpreted as indicating or suggesting relative importance.
[0064] In view of the problem that in the prior art, when performing formatting function tests on storage devices that support the NVMe protocol, special protocol testing equipment is required, and the testing cost is high, this application proposes a new method for formatting function testing for storage devices that support the NVMe protocol. This method can be used to verify whether the FW processing mechanism of the storage device is reasonable in the scenario where the formatting operation is performed during the read and write operations on the storage device. The FW processing mechanism is the core technology of each equipment manufacturer and is related to various aspects such as sample performance, function, life, stability, and compatibility. In addition, the method can be implemented using ordinary personal computers and other equipment, without the need to purchase special protocol testing equipment, thereby greatly reducing the testing cost.
[0065] It should be understood that the execution entities of the various method embodiments of the present application may be various types of terminal devices or servers, such as mobile phones, tablet computers, laptop computers, desktop computers, and wearable devices.
[0066] See also Figure 1 , shows a formatting test method for a storage device provided in an embodiment of the present application, comprising:
[0067] 101. During a read and write operation on a storage device supporting the NVMe protocol, a format command of the NVMe protocol is sent to the storage device;
[0068] First, the test environment is set up. The test method for the formatting function proposed in the embodiment of the present application can be applied to ordinary terminal devices such as personal computers. After the terminal device is connected to the storage device to be tested, the test method proposed in the embodiment of the present application is executed. Among them, the storage device to be tested can be any storage device that supports the NVMe protocol, such as a solid-state hard drive.
[0069] When the test starts, the terminal device first sends a read / write operation instruction to the storage device to perform a read / write operation on the storage device. Specifically, the read / write operation may be a random mixed read / write operation with a specified block size and a specified read / write ratio, for example, a 4k block size and a read / write ratio of 1:1 may be used to randomly read and write the storage device, and the read / write operation may be performed until the capacity of the storage device is fully written, or until a specified ratio (e.g., 50%) of the capacity of the storage device is fully written.
[0070] During the process of performing read and write operations on the storage device, a format command of the NVMe protocol is sent to the storage device. Specifically, the format command can be sent a certain time after the storage device starts to perform read and write operations, and the read and write operations have not yet ended. The format command of the NVMe protocol is also the NVMe format command. The terminal device controls the storage device to perform the formatting operation by sending the NVMe format command to the storage device. There are two types of commands in the NVMe protocol: admin commands and I / O commands. Among them, admin commands are used by the host to manage and control storage devices, and I / O commands are used for data transmission. NVMe format is an admin command, which is used to format storage devices or perform secure erasure on storage devices.
[0071] In one embodiment of the present application, before performing a read and write operation on a storage device supporting the NVMe protocol, the following may also be included:
[0072] (1) Detect whether the storage device is mounted;
[0073] (2) If the storage device is mounted, unmount the storage device.
[0074] Before the tester performs the formatting function test on the storage device, the storage device may have been mounted on the terminal device by other personnel. In order to ensure the comprehensiveness and completeness of the formatting function test, before performing read and write operations on the storage device, you can first check whether the storage device has been mounted. If it has been mounted, unmount the storage device before performing the read and write operations; if it has not been mounted, you can directly perform the read and write operations.
[0075] Specifically, the above step (1) may include:
[0076] (1.1) Call the specified operating system command to obtain the mount information of all currently connected disks;
[0077] (1.2) searching the target mount information corresponding to the drive letter of the storage device from the mount information of all the disks;
[0078] (1.3) determining whether there is a mount point of the drive letter of the storage device according to the target mount information;
[0079] If there is a mount point of the drive letter of the storage device, determining that the storage device has been mounted;
[0080] (1.4) If there is no mount point for the drive letter of the storage device, it is determined that the storage device is not mounted.
[0081] When detecting whether a storage device has been mounted, certain specified operating system commands (such as Diskpart, list disk, etc.) can be called to obtain the mount information of all disks currently connected to the terminal device. Since the storage device has been connected to the terminal device, the terminal device can obtain the drive letter of the storage device (the drive letter is an identifier for disk storage devices in DOS and WINDOWS systems), and then search for the target mount information corresponding to the drive letter from the mount information of all disks. Next, determine whether the mount point of the drive letter exists based on the target mount information. If it exists, it means that the storage device has been mounted, and at this time, you can call the operating system command to uninstall it; if it does not exist, it means that the storage device is not mounted, and you can directly start to perform read and write operations on the storage device.
[0082] In one embodiment of the present application, in the process of performing a read and write operation on a storage device supporting the NVMe protocol, sending a format command of the NVMe protocol to the storage device may include:
[0083] (1) starting a read and write operation on the storage device;
[0084] (2) After a preset delay time, a formatting command of the NVMe protocol is sent to the storage device, and the preset delay time is less than the time required for the storage device to perform the read and write operations.
[0085] The NVMe format command can be sent to the storage device in the process of performing read and write operations on the storage device by delay. Specifically, when the read and write operations on the storage device are started, the timing starts. When the timing reaches a certain preset time (for example, 1 to 5 minutes), the terminal device sends the NVMe format command to the storage device. It should be noted that the preset time must be less than the time required for the storage device to perform the read and write operations, so as to ensure that the NVMe format command is sent before the read and write operations are completed.
[0086] 102. Detect whether the storage device can be successfully formatted after receiving the format command;
[0087] After the terminal device sends the NVMe format command to the storage device, the storage device performs a formatting operation based on the NVMe format command and returns the result of the formatting operation to the terminal device. The terminal device determines whether the storage device can be formatted successfully based on the result of the formatting operation.
[0088] If the storage device is successfully formatted after receiving the format command, step 103 is executed; if the storage device fails to be formatted after receiving the format command, step 105 is executed.
[0089] 103. Stop executing read and write operations on the storage device, and start a functional test on the storage device;
[0090] The storage device is successfully formatted after receiving the format command, and the read and write operations on the storage device are stopped, and a functional test of the storage device is started to check whether the basic functions of the storage device after formatting are normal. The functional test may include testing the initialization function, partitioning function, formatting function, and read and write function of the storage device.
[0091] Specifically, after the NVMe format command is successfully executed, the terminal device will obtain which process is currently occupying the disk IO of the storage device, which is the process that performs read and write operations on the storage device. Then, the terminal device will close the process, thereby stopping the read and write operations performed on the storage device to avoid interference with subsequent functional tests.
[0092] 104. If the function test of the storage device passes, it is determined that the format test of the storage device passes;
[0093] If the functional test passes, it indicates that the basic functions of the storage device after formatting are normal, and it has been previously verified that the storage device can be formatted normally during the reading and writing process, so it can be determined that the formatting function test of the storage device has passed.
[0094] 105. Determine whether the formatting test of the storage device has failed.
[0095] The storage device fails to format after receiving the format command, indicating that the storage device cannot be formatted normally during the reading and writing process. At this time, an error message can be output, and it is determined that the format test of the storage device has not passed. In addition, if the functional test fails, it indicates that the basic function of the storage device after formatting is not normal. At this time, an error message can also be output, and it is determined that the format test of the storage device has not passed.
[0096] In the process of performing read and write operations on a storage device supporting the NVMe protocol, the embodiment of the present application sends a formatting command of the NVMe protocol to the storage device, thereby verifying whether the storage device can be formatted normally during the read and write process. In addition, after detecting that the storage device can be formatted normally during the read and write process, a functional test of the storage device will be initiated to verify whether the basic functions of the storage device after formatting are normal. Through such a setting, it is possible to test the formatting function of a storage device supporting the NVMe protocol, and the formatting test method can be implemented using an ordinary personal computer or other device, which greatly reduces the testing cost.
[0097] See also Figure 2 , shows another storage device formatting test method provided by an embodiment of the present application, including:
[0098] 201. During a read and write operation on a storage device supporting the NVMe protocol, a format command of the NVMe protocol is sent to the storage device;
[0099] 202. Detect whether the storage device can be formatted successfully after receiving the format command;
[0100] If the storage device is successfully formatted after receiving the format command, step 203 is executed; if the storage device fails to be formatted after receiving the format command, step 208 is executed.
[0101] 203. Stop executing read and write operations on the storage device, and start a functional test on the storage device;
[0102] Steps 201-203 are similar to steps 101-103, and the details may refer to the relevant description of steps 101-103.
[0103] 204. If the function test of the storage device passes, mount the storage device;
[0104] In the previous embodiment of the present application, if the functional test of the storage device passes, it is directly determined that the formatting functional test of the storage device passes. In this embodiment, if the functional test of the storage device passes, a write operation plus verification test is further performed. Before performing a write operation, the storage device needs to be mounted first.
[0105] 205. Perform a write operation on the storage device and verify the written data;
[0106] After mounting the storage device, the terminal device performs a write operation on the storage device and verifies the written data. Specifically, the write operation can be a random write or a sequential write with a specified block size, and the data can be verified by a specified verification method after writing the data. For example, a block size of 512k can be used to sequentially write to the storage device to fill the capacity of the storage device, or the storage device can be sequentially written to one-third of the capacity of the storage device (which can shorten the test time). After writing the data, the written data can be verified by CRC32 or other methods.
[0107] 206. Check whether the write operation to the storage device and the verification of the written data are successful;
[0108] After the terminal device performs a write operation on the storage device and verifies the written data, it detects whether the operation is successful. If the write operation is performed on the storage device and the written data is verified successfully, step 207 is executed; if the write operation is performed on the storage device and the written data is verified unsuccessfully, step 208 is executed.
[0109] 207. Determine whether the formatting test of the storage device passes;
[0110] The storage device can be formatted normally during the reading and writing process, the basic functions after formatting are normal, and the write operation and verification after formatting are normal. If these three parts of the test pass at the same time, it can be determined that the formatting test of the storage device has passed.
[0111] 208. Determine whether the formatting test of the storage device has failed.
[0112] In contrast to step 207, if any one or more of the three parts of the test fail, the test process can be terminated and it can be determined that the formatting test of the storage device has failed. In addition, a corresponding error message can be printed out.
[0113] In the process of performing read and write operations on a storage device that supports the NVMe protocol, an embodiment of the present application sends a formatting command of the NVMe protocol to the storage device, thereby verifying whether the storage device can be formatted normally during the read and write process. In addition, after detecting that the storage device can be formatted normally during the read and write process, a functional test of the storage device will be initiated to verify whether the basic functions of the storage device after formatting are normal. Next, the embodiment of the present application will further verify whether the write operation and verification of the storage device after formatting are normal. Compared with the previous embodiment of the present application, this embodiment further enriches the test scenarios of the formatting test and improves the comprehensiveness of the formatting test.
[0114] See also Figure 3 , shows another storage device formatting test method provided by an embodiment of the present application, including:
[0115] 301. During a read and write operation on a storage device supporting the NVMe protocol, a format command of the NVMe protocol is sent to the storage device;
[0116] 302. Detect whether the storage device can be formatted successfully after receiving the format command;
[0117] If the storage device is successfully formatted after receiving the format command, step 303 is executed; if the storage device fails to be formatted after receiving the format command, step 312 is executed.
[0118] 303. Stop executing read and write operations on the storage device, and start a functional test on the storage device;
[0119] 304. Check whether the functional test of the storage device passes;
[0120] If the functional test of the storage device passes, step 305 is executed, otherwise, step 312 is executed.
[0121] 305. Mount the storage device;
[0122] 306. Perform a write operation on the storage device and verify the written data;
[0123] 307. Check whether the write operation on the storage device and the verification of the written data are successful;
[0124] If the write operation is performed on the storage device and the written data is verified successfully, step 308 is executed; if the write operation is performed on the storage device and the written data is verified failed, step 312 is executed.
[0125] For the specific contents of steps 301-307, please refer to the relevant introduction of the previous embodiment of this application.
[0126] 308. Uninstall the storage device;
[0127] The storage device can be formatted normally during the reading and writing process, the basic functions after formatting are normal, and the write operation and verification after formatting are normal. In order to improve the test accuracy and ensure sufficient test pressure, the embodiment of the present application also sets a cycle number to repeat multiple tests. Specifically, after the three parts of the test are passed, the storage device is first uninstalled.
[0128] 309. Recording the completion of the formatting test process of the storage device once;
[0129] After the storage device is uninstalled, the formatting test process of the storage device is recorded once.
[0130] 310. Check whether the number of times the formatting test process of the storage device is completed reaches a set number of cycles;
[0131] Then, check whether the number of formatting test processes reaches the set number of cycles. In order to ensure sufficient test pressure, the number of cycles can generally be set to several hundred times.
[0132] If the number of times the formatting test process of the storage device is completed does not reach the set number of cycles, return to step 301, that is, start the next formatting test process of the storage device; if the number of times the formatting test process of the storage device is completed has reached the set number of cycles, execute step 311.
[0133] 311. Determine whether the formatting test of the storage device passes;
[0134] If the number of times the formatting test process of the storage device has been completed reaches the number of cycles, and each formatting test process performed on the storage device passes, it can be determined that the formatting test of the storage device passes.
[0135] 312. Determine whether the formatting test of the storage device has failed.
[0136] If any one or more of the formatting test processes of the storage device fail during the multiple formatting test processes, it can be determined that the formatting test of the storage device fails.
[0137] In the process of performing read and write operations on a storage device supporting the NVMe protocol, an embodiment of the present application sends a formatting command of the NVMe protocol to the storage device, thereby verifying whether the storage device can be formatted normally during the read and write process. In addition, after detecting that the storage device can be formatted normally during the read and write process, a functional test of the storage device will be initiated to verify whether the basic functions of the storage device after formatting are normal. Next, the write operation and verification of the storage device after formatting are verified to be normal. In addition, compared with the previous embodiment of the present application, this embodiment also sets a number of cycles to repeat multiple tests to ensure sufficient test pressure.
[0138] See also Figure 4 , shows another storage device formatting test method provided by an embodiment of the present application, including:
[0139] 401. During a read / write operation on a storage device supporting the NVMe protocol, a format command of the NVMe protocol is sent to the storage device;
[0140] 402. Detect whether the storage device can be successfully formatted after receiving the format command;
[0141] If the storage device is successfully formatted after receiving the format command, step 404 is directly executed; if the storage device fails to be formatted after receiving the format command, step 403 is executed.
[0142] 403. Record error information in the test log file;
[0143] If the storage device fails to format after receiving the format command, the terminal device may record a corresponding error message in the test log file, for example, the message "the current sample cannot be formatted normally during the reading and writing process" may be recorded. Then, step 404 is executed.
[0144] 404. Stop executing read and write operations on the storage device, and start a functional test on the storage device;
[0145] 405. Check whether the functional test of the storage device passes;
[0146] If the function test of the storage device passes, directly execute step 407 , otherwise execute step 406 .
[0147] 406. Record error information in the test log file;
[0148] If the function test of the storage device fails, the terminal device may record another error message in the test log file, for example, the message "the current sample does not function properly after formatting" may be recorded. Then, step 407 is executed.
[0149] 407. Mount the storage device;
[0150] 408. Perform a write operation on the storage device and verify the written data;
[0151] 409. Check whether the write operation to the storage device and the verification of the written data are successful;
[0152] If the write operation is performed on the storage device and the written data is verified successfully, step 411 is directly executed; if the write operation is performed on the storage device and the written data is verified failed, step 410 is executed.
[0153] 410. Record error information in the test log file;
[0154] If the write operation and verification of the written data fail, the terminal device may record another error message in the test log file, such as "the current sample fails to write data and verify after formatting". Then, step 411 is executed.
[0155] 411. Uninstall the storage device;
[0156] 412. Recording the completion of the formatting test process of the storage device once;
[0157] 413. Check whether the number of times the formatting test process of the storage device is completed reaches a set number of cycles;
[0158] If the number of times the formatting test process of the storage device is completed does not reach the set number of cycles, return to step 401, that is, start the next formatting test process of the storage device; if the number of times the formatting test process of the storage device is completed has reached the set number of cycles, execute step 414.
[0159] 414. Detect whether the test log file contains error information;
[0160] The number of times the formatting test process of the storage device has been completed has reached the number of cycles, and the test is now finished. The test result can be determined by detecting whether the test log file contains error information. Specifically, if the test log file does not contain error information, step 415 is executed. If the test log file contains error information, step 416 is executed.
[0161] 415. Determine whether the formatting test of the storage device passes;
[0162] The test log file does not record any error information. For example, if the test log file is empty, it indicates that the storage device has passed multiple formatting tests. Therefore, it can be determined that the formatting test of the storage device has passed.
[0163] 416. Determine whether the formatting test of the storage device fails.
[0164] The test log file records error information, for example, if there is any one or more error information recorded when executing step 403, step 406 or step 410, it means that the storage device has failed at least one formatting test process in multiple formatting tests. At this time, it can be determined that the formatting test of the storage device has failed.
[0165] Compared with the previous embodiment of the present application, this embodiment adds a test log file, and each error in the formatting test process of the storage device is recorded in the test log file. Afterwards, when the formatting test of the storage device is completed, the formatting test result of the storage device can be easily obtained by detecting whether the test log file contains error information.
[0166] For ease of understanding, the formatting test method for a storage device proposed in this application is described below using an actual application scenario.
[0167] like Figure 5 , which is a schematic diagram of the operation flow of the formatting test method for a storage device provided in an embodiment of the present application in an actual application scenario.
[0168] In execution Figure 5 Before the operation process shown, the test environment needs to be set up. This application scenario uses an ordinary PC to implement the formatting function test of a solid-state drive sample, where the solid-state drive sample supports the NVMe protocol. An example of the basic performance requirements of the PC is as follows:
[0169] Motherboard: Ordinary PC motherboard supporting PCIE slot
[0170] CPU: Intel i3, i5, i7 or above
[0171] Memory: ≥4GB
[0172] Hard disk: ≥60GB
[0173] Operating system: Linux kernel version 3.10.0 or later
[0174] After the SSD sample is connected to the PC, Figure 5 As shown, the following steps are used to implement the formatting function test of the solid state drive sample:
[0175] (1) Obtain the drive letter of the solid state drive sample and the preset number of test cycles.
[0176] (2) The preprocessing of the SSD sample mainly involves judging whether the sample has been mounted by the drive letter, and if it has been mounted, uninstalling it. At the same time, the basic information of the SSD sample can also be obtained, such as DeviceModel, Serial Number, LU WWN Device Id, Firmware Version, User Capacity, current speed, and SMART information. In the subsequent testing process, further tests for these basic information can be added, and the test data of this basic information can be added when the test report is generated.
[0177] (2) Execute a cyclic test process, first perform a mixed read and write test of the full disk and 4k block size on the solid state drive sample.
[0178] (3) After a delay of 1 to 5 minutes, execute the NVMe format command.
[0179] (4) Determine whether the NVMe format command is executed successfully. If it is executed successfully, close the process of performing the mixed read-write test on the solid-state hard disk sample, then perform tests on the basic functions such as initialization and partitioning on the solid-state hard disk sample, and mount the solid-state hard disk sample. If the execution fails, the corresponding error information can be recorded in the test log file, it is determined that the formatting function test of the solid-state hard disk sample has not passed, and exit the test process. In addition, the PC can print out the error information so that the tester can analyze the error information.
[0180] (5) Perform a sequential write operation on the solid-state hard disk sample with a block size of 512k, which is 1 / 3 of the hard disk capacity, and use CRC and other methods to verify the written data.
[0181] (6) Determine whether the executed write operation and verification are successful. If successful, unload the solid state hard disk sample, and then determine whether the cycle is completed. If not, return to step (2) and execute the next mixed read and write test process. If the cycle is completed, execute step (7). If the executed write operation and verification fail, the corresponding error information can be recorded in the test log file, and it is determined that the formatting function test of the solid state hard disk sample has not passed, and the test process is exited.
[0182] (7) Check whether the test log file is empty. If the test log file is empty, it means that no error occurred during the test of the solid state drive sample, and it can be determined that the formatting test of the solid state drive sample passed. If the test log file records error information, it means that an error occurred during the test of the solid state drive sample, and it can be determined that the formatting test of the solid state drive sample failed, that is, failed.
[0183] Compared with the existing formatting function test method for storage devices supporting the NVMe protocol, the test environment of the formatting function test method proposed in this application is simple to match, and the test script is easy to write, which can cover certain test application scenarios.
[0184] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0185] A formatting test method for a storage device is mainly described above, and a formatting test device for a storage device will be described below.
[0186] See also Figure 6 , an embodiment of a formatting test device for a storage device in an embodiment of the present application includes:
[0187] The formatting command sending module 601 is used to send a formatting command of the NVMe protocol to the storage device during the process of performing a read and write operation on the storage device supporting the NVMe protocol;
[0188] A read / write operation stopping module 602, configured to stop executing read / write operations on the storage device and start a functional test on the storage device if the storage device is successfully formatted after receiving the format command;
[0189] The formatting test result determination module 603 is used to determine whether the formatting test of the storage device has passed if the functional test of the storage device has passed.
[0190] In one embodiment of the present application, the formatting test device may further include:
[0191] A mount detection module, used to detect whether the storage device has been mounted;
[0192] The device uninstallation module is used to uninstall the storage device if the storage device has been mounted.
[0193] Furthermore, the mounting detection module may include:
[0194] A mount information acquisition unit, used to call a specified operating system command to acquire the mount information of all currently connected disks;
[0195] A mount information search unit, used to search the mount information of all disks for target mount information corresponding to the drive letter of the storage device;
[0196] A mount point detection unit, used for determining whether there is a mount point of the drive letter of the storage device according to the target mount information;
[0197] A first mount determination unit, configured to determine that the storage device has been mounted if a mount point of the drive letter of the storage device exists;
[0198] The second mount determination unit is configured to determine that the storage device is not mounted if the mount point of the drive letter of the storage device does not exist.
[0199] In one embodiment of the present application, the formatting test device may further include:
[0200] A device mounting module, used for mounting the storage device;
[0201] A write verification module, used to perform a write operation on the storage device and verify the written data;
[0202] The first execution module is used to execute the step of determining whether the formatting test of the storage device has passed if the write operation is performed on the storage device and the written data is verified successfully.
[0203] Furthermore, the formatting test device may also include:
[0204] A test number recording module, used for recording a completion of the formatting test process of the storage device once;
[0205] A second execution module is used for returning to the step of sending a formatting command of the NVMe protocol to the storage device during the process of performing a read and write operation on the storage device supporting the NVMe protocol if the number of times the formatting test process of the storage device is completed does not reach the set number of cycles;
[0206] The third execution module is used to execute the step of determining whether the formatting test of the storage device has passed if the number of times the formatting test process of the storage device has been completed has reached the number of cycles.
[0207] Furthermore, the formatting test device may also include:
[0208] A first error information recording module, configured to record error information in a test log file if the storage device fails to be formatted after receiving the format command;
[0209] A second error information recording module, configured to record error information in the test log file if the functional test of the storage device fails;
[0210] A third error information recording module, configured to record error information in the test log file if a write operation is performed on the storage device and verification of the written data fails;
[0211] The third execution module may include:
[0212] an error information detection unit, configured to detect whether the test log file contains error information if the number of times the formatting test process of the storage device has been completed has reached the number of cycles;
[0213] The determination execution unit is used to execute the step of determining whether the formatting test of the storage device passes if the test log file does not contain error information.
[0214] In one embodiment of the present application, the formatting command sending module may include:
[0215] A read / write operation initiating unit, used for initiating a read / write operation on the storage device;
[0216] The delay unit is used to send a formatting command of the NVMe protocol to the storage device after a delay of a preset time length, and the preset time length is less than the time length required for the storage device to perform the read and write operations.
[0217] The present application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, Figures 1 to 4 The steps of a formatting test method for any storage device are shown.
[0218] The embodiment of the present application also provides a computer program product, when the computer program product is run on a terminal device, the terminal device executes the following Figures 1 to 4 The steps of a formatting test method for any storage device are shown.
[0219] Figure 7 Schematic diagram of a terminal device provided by an embodiment of the present application. Figure 7 As shown, the terminal device 7 of this embodiment includes: a processor 70, a memory 71, and a computer program 72 stored in the memory 71 and executable on the processor 70. When the processor 70 executes the computer program 72, the steps in the above-mentioned embodiments of the formatting test method for each storage device are implemented, for example Figure 1 Alternatively, when the processor 70 executes the computer program 72, the functions of each module / unit in the above-mentioned device embodiments are realized, for example, Figure 6 Functions of modules 601 to 603 are shown.
[0220] The computer program 72 may be divided into one or more modules / units, which are stored in the memory 71 and executed by the processor 70 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 72 in the terminal device 7.
[0221] The processor 70 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) 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, etc.
[0222] The memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used to store the computer program and other programs and data required by the terminal device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
[0223] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by 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 embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0224] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0225] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0226] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0227] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0228] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0229] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0230] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. . Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0231] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A formatting test method for a storage device, characterized in that: include: In the process of performing a read and write operation on a storage device supporting the NVMe protocol, a formatting command of the NVMe protocol is sent to the storage device; If the storage device is successfully formatted after receiving the format command, stop performing read and write operations on the storage device and start a functional test on the storage device; If the functional test of the storage device passes, determining that the formatting test of the storage device passes; Wherein, in the process of performing a read and write operation on a storage device supporting the NVMe protocol, sending a formatting command of the NVMe protocol to the storage device includes: Initiate a read and write operation on the storage device; After a preset delay time, a formatting command of the NVMe protocol is sent to the storage device, wherein the preset delay time is less than the delay time required for the storage device to perform the read and write operations; Before performing read and write operations on a storage device that supports the NVMe protocol, the following steps are also included: Detecting whether the storage device is mounted; If the storage device is mounted, the storage device is unmounted.
2. The formatting test method according to claim 1, characterized in that: Detecting whether the storage device is mounted includes: Call the specified operating system command to obtain the mount information of all currently connected disks; Searching the target mount information corresponding to the drive letter of the storage device from the mount information of all the disks; Determining whether there is a mount point of the drive letter of the storage device according to the target mount information; If there is a mount point of the drive letter of the storage device, determining that the storage device has been mounted; If the mount point of the drive letter of the storage device does not exist, it is determined that the storage device is not mounted.
3. The formatting test method according to claim 1, characterized in that: If the function test of the storage device passes, before determining that the format test of the storage device passes, the method further includes: Mounting the storage device; Performing a write operation on the storage device and verifying the written data; If the write operation is performed on the storage device and the written data is verified successfully, the step of determining whether the formatting test of the storage device has passed is performed.
4. The formatting test method according to claim 3, characterized in that: If the write operation is performed on the storage device and the written data is verified successfully, before executing the step of determining that the formatting test of the storage device has passed, the method further includes: Unmounting the storage device; Recording the completion of the formatting test process of the storage device once; If the number of times the formatting test process of the storage device is completed does not reach the set number of cycles, return to the step of sending a formatting command of the NVMe protocol to the storage device during the process of performing read and write operations on the storage device supporting the NVMe protocol; If the number of times the formatting test process of the storage device is completed reaches the number of cycles, the step of determining whether the formatting test of the storage device is passed is performed.
5. The formatting test method according to claim 4, characterized in that: After sending the format command of the NVMe protocol to the storage device, the method further includes: If the storage device fails to format after receiving the format command, an error message is recorded in a test log file; After starting the functional test of the storage device, the method further includes: If the functional test of the storage device fails, recording error information in the test log file; After performing a write operation on the storage device and verifying the written data, the method further includes: If the write operation is performed on the storage device and the written data is verified, an error message is recorded in the test log file; If the number of times the formatting test process of the storage device has been completed has reached the number of cycles, the step of determining whether the formatting test of the storage device has passed is performed, including: If the number of times the formatting test process of the storage device has been completed has reached the number of cycles, detecting whether the test log file contains error information; If the test log file does not contain error information, the step of determining whether the formatting test of the storage device has passed is performed.
6. A formatting test device for a storage device, characterized in that: include: A formatting command sending module, used to send a formatting command of the NVMe protocol to the storage device during a read and write operation on the storage device supporting the NVMe protocol; A read / write operation stopping module, configured to stop executing read / write operations on the storage device and start a functional test on the storage device if the storage device is successfully formatted after receiving the format command; A formatting test result determination module, used for determining that the formatting test of the storage device has passed if the functional test of the storage device has passed; Wherein, the formatting command sending module includes: A read / write operation initiating unit, used for initiating a read / write operation on the storage device; A delay unit, used to send a formatting command of the NVMe protocol to the storage device after a delay of a preset time length, wherein the preset time length is less than the time length required for the storage device to perform the read and write operations; The formatting test device also includes: A mount detection module, used to detect whether the storage device has been mounted; The device uninstallation module is used to uninstall the storage device if the storage device has been mounted.
7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the formatting test method for a storage device according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the formatting test method for a storage device according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Control method for storage device externally connected with router
CN104734979A
Storage device quality detector
CN201796608U