NVMe hard disk zero writing method, device and storage medium

By determining the data protection type of the write-zero region in the NVMe SSD and designing the corresponding write-zero process, the problem of the write-zero command not being able to provide timely feedback was solved, enabling timely feedback and efficient verification of write-zero results, and saving human resources.

CN117270764BActive Publication Date: 2026-08-25INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311068158.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-23
Publication Date
2026-08-25
Estimated Expiration
2043-08-23

AI Technical Summary

Technical Problem

The existing NVMe SSD write-zero command cannot provide timely feedback and verification of write-zero results during execution, resulting in low efficiency and the need for manual repetitive testing, which wastes resources.

Method used

By obtaining the target write zero area of ​​the NVMe hard drive, its data protection type is determined, and different write zeroing processes are designed according to the type, including issuing read commands after a preset interval to generate write zeroing results, automatically generating write zeroing command results, and providing timely feedback on success or failure.

Benefits of technology

It enables timely feedback of write-to-zero results, saves labor costs, adapts to write-to-zero processes of different data protection types, and improves operational efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117270764B_ABST
    Figure CN117270764B_ABST
Patent Text Reader

Abstract

The application provides an NVMe hard disk zero writing method, device and storage medium, and belongs to the technical field of data processing. The method comprises the following steps: obtaining a target zero writing area of an NVMe hard disk, and determining whether the target zero writing area is an end-to-end data protection type; when the target zero writing area is not the end-to-end data protection type, issuing a zero writing command to the target zero writing area, issuing a read command to the target zero writing area after a preset interval of issuing the zero writing command, and generating a zero writing result of the zero writing command; when the target zero writing area is the end-to-end data protection type, in the case that end-to-end data protection of the target zero writing area is verified, determining a zero writing command of a protection type corresponding to the target zero writing area according to a protection parameter corresponding to the target zero writing area, issuing a read command to the target zero writing area after a preset interval of issuing the zero writing command of the protection type, and generating a zero writing result of the zero writing command. The application aims to timely feedback the zero writing result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and more specifically, to a method, apparatus, and storage medium for writing zeros to an NVMe hard drive. Background Technology

[0002] With the development of technology, data, as the fifth factor of production, has gradually become the core driving force for economic development. Various large, medium and small data centers have become the infrastructure of the digital economy, and data storage technology has become an indispensable cornerstone technology for digital development.

[0003] In terms of data storage, various types of hard drives have emerged for storing data. Among them, NVMe (Non-Volatile Memory Express) SSD (Solid State Disk) is connected via PCIe (Peripheral Component Interconnect Express) bus, which has higher bandwidth and lower latency, and can provide faster data transfer speeds and higher performance.

[0004] In the use of NVMe SSDs, the write zeroes command is often used to set the logical block range to zero. However, the write zero command may fail due to mismatched instructions or other reasons. The current write zero method cannot provide timely feedback and verification of the write zero result. Summary of the Invention

[0005] This application provides a method, apparatus, and storage medium for writing zero to an NVMe hard drive, which aims to provide timely feedback on the zero-writing results.

[0006] In a first aspect, embodiments of this application provide a method for writing zero to an NVMe hard drive, applied to an NVMe hard drive, the method comprising:

[0007] Obtain the target write zero region of the NVMe hard drive and determine whether the target write zero region is an end-to-end data protection type;

[0008] When the target write zero region is not an end-to-end data protection type, a write zero command is issued to the target write zero region. After a preset interval after issuing the write zero command, a read command is issued to the target write zero region, and the write zero result of the write zero command is generated.

[0009] When the target write-zero region is an end-to-end data protection type, if the end-to-end data protection of the target write-zero region passes the support verification, the protection parameters corresponding to the target write-zero region are obtained.

[0010] Based on the protection parameters corresponding to the target write-zero region, determine the write-zero command for the protection type corresponding to the target write-zero region, wherein the write-zero command for the protection type corresponds one-to-one with the protection parameters;

[0011] After a preset interval following the issuance of the write-zero command of the protection type, a read command is issued to the target write-zero region to generate the write-zero result of the write-zero command.

[0012] Optionally, when the target write-zero region is not an end-to-end data protection type, a write-zero command is issued to the target write-zero region. After a preset interval following the issuance of the write-zero command, a read command is issued to the target write-zero region, and the write-zero result of the write-zero command is generated, including:

[0013] When the target write-zero region is a single-segment LBA region, obtain the initial data stored in the target write-zero region and the initial data of the critical region of the target write-zero region;

[0014] A write-zero command is issued to the target write-zero region;

[0015] After a preset interval after issuing a write-zero command, a read command is issued to both the target write-zero region and the critical region of the target write-zero region to obtain the current data of the target write-zero region and the critical region of the target write-zero region.

[0016] When the current data of the target write-zero region is zero, and the current data of the critical region is the same as the initial data of the critical region, a write-zero success result is generated.

[0017] Optionally, when the target write-zero region is not an end-to-end data protection type, a write-zero command is issued to the target write-zero region. After a preset interval following the issuance of the write-zero command, a read command is issued to the target write-zero region, and the write-zero result of the write-zero command is generated, including:

[0018] When the target write zero region is an LBA with multiple overlapping regions, a write zero command is issued to the target write zero region;

[0019] After a preset interval following the issuance of the write zero command, a read command is issued to the overlapping region;

[0020] When the data read from the overlapping region is zero, a result indicating successful write to zero is generated.

[0021] Optionally, when the target write-zero region is not an end-to-end data protection type, a write-zero command is issued to the target write-zero region. After a preset interval following the issuance of the write-zero command, a read command is issued to the target write-zero region, and the write-zero result of the write-zero command is generated, including:

[0022] When the target write zero region is not an end-to-end data protection type, a write zero command is issued to the target write zero region. After a preset interval after issuing the write zero command, a read command is issued to the target write zero region to generate a first read result.

[0023] Monitor the driver management commands issued to the target write-zero region;

[0024] When a driver management command is detected to be sent to the target write zero region, a read command is sent to the target write zero region to generate a second read result;

[0025] If both the first read result and the second read result are zero, a result indicating successful write to zero is generated.

[0026] Optionally, when the target write-zero region is an end-to-end data protection type, the method further includes:

[0027] Format the target write-zero region;

[0028] A reset command is issued to the formatted NVMe hard drive to make the formatting of the target write-zero area take effect;

[0029] Check if the dps parameter of the target write-zero region is 1;

[0030] If the dps parameter of the target write-zero region is 1, then the end-to-end data protection of the target write-zero region passes the support verification.

[0031] If the dps parameter of the target write-zero region is 1, then the end-to-end data protection of the target write-zero region fails the support verification, and a prompt indicating that the target write-zero region has failed the support verification is generated.

[0032] Optionally, obtaining the protection parameters corresponding to the target write-zero region includes:

[0033] The PRACT, PRCHK[0], PRCHK[1] and PRCHK[2] of the target write-zero region are obtained as protection parameters.

[0034] Optionally, the method further includes:

[0035] Based on the values ​​of PRACT, PRCHK[0], PRCHK[1] and PRCHK[2], various combinations of protection parameters are generated;

[0036] Generate write zero commands for the protection types corresponding to the various different combinations of protection parameters;

[0037] The various combinations of protection parameters and the write zero commands for the protection types corresponding to each combination of protection parameters are stored in a preset list, which is stored in a tree structure.

[0038] Optionally, based on the protection parameters corresponding to the target write-zero region, a write-zero command corresponding to the protection type of the target write-zero region is determined, including:

[0039] Matching is performed in the preset list based on the protection parameters corresponding to the target write-zero region;

[0040] Obtain the protection parameter combination corresponding to the protection parameters of the target write-zero region;

[0041] The write zero command of the protection type corresponding to the protection parameter combination is used as the write zero command of the protection type corresponding to the target write zero region.

[0042] Optionally, the method further includes:

[0043] The write-zero process of the target write-zero region of the NVMe hard drive is acquired and recorded in real time;

[0044] After generating the write zeroing result of the write zeroing command for the target write zeroing region, a write zeroing report for the target write zeroing region of the NVMe hard drive is generated and displayed. The write zeroing report includes the name of the NVMe hard drive, the interval identifier of the target write zeroing region, the end-to-end data protection type of the target write zeroing region, and the write zeroing result.

[0045] Secondly, embodiments of this application provide an NVMe hard drive zero-write device, applied to an NVMe hard drive, the device comprising:

[0046] The acquisition module is used to acquire the target write zero area of ​​the NVMe hard drive and determine whether the target write zero area is an end-to-end data protection type.

[0047] The first write-zero module is used to issue a write-zero command to the target write-zero region when the target write-zero region is not an end-to-end data protection type, issue a read command to the target write-zero region after a preset interval after issuing the write-zero command, and generate the write-zero result of the write-zero command.

[0048] The second write-zero module is used to, when the target write-zero region is an end-to-end data protection type, obtain the protection parameters corresponding to the target write-zero region after the end-to-end data protection of the target write-zero region has passed the support verification; determine the write-zero command corresponding to the protection type of the target write-zero region based on the protection parameters, wherein the write-zero command of the protection type corresponds one-to-one with the protection parameters; and after a preset interval after issuing the write-zero command of the protection type, issue a read command to the target write-zero region to generate the write-zero result of the write-zero command.

[0049] Thirdly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the NVMe hard drive zero-write method as described in the first aspect of the embodiments.

[0050] Beneficial effects:

[0051] When it is necessary to write zeros to a target write zero region, the target write zero region of the NVMe hard drive is first obtained, and then it is determined whether the target write zero region is an end-to-end data protection type. When the target write zero region is not an end-to-end data protection type, a write zero command is directly issued to the target write zero region. After a preset interval after issuing the write zero command, a read command is issued to the target write zero region, and the write zero result of the write zero command is generated.

[0052] When the target write-zero region is an end-to-end data protection type, and the end-to-end data protection of the target write-zero region passes the support verification, the protection parameters corresponding to the target write-zero region are obtained; based on the protection parameters corresponding to the target write-zero region, the write-zero command for the protection type corresponding to the target write-zero region is determined, and the write-zero command for the protection type corresponds one-to-one with the protection parameters; after a preset interval after issuing the write-zero command for the protection type, a read command is issued to the target write-zero region to generate the write-zero result of the write-zero command.

[0053] This method automatically generates the write zero command result when writing zeros to the target write zero region, and can provide timely feedback on the write zero result to verify whether the write zero result is successful, saving the cost of repeated manual testing. At the same time, it designs more adaptive write zero processes for different scenarios involved in the target write zero region, such as whether it is an end-to-end data protection type, and under the end-to-end data protection type, there are different write zero processes corresponding to different protection parameters. Attached Figure Description

[0054] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application 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.

[0055] Figure 1 This is a flowchart of the steps of an embodiment of the NVMe hard drive zero-writing method proposed in this application;

[0056] Figure 2 This is a schematic diagram of the structure of the write zero command for the protection parameter combination and protection type proposed in an embodiment of this application;

[0057] Figure 3 This is a functional block diagram of an NVMe hard drive zero-write device provided in one embodiment of this application. Detailed Implementation

[0058] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0059] NVMe: Non-Volatile Memory Express, a non-volatile memory host controller interface specification.

[0060] SSD: Solid State Disk

[0061] Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard

[0062] NS: Namespace

[0063] LBA: Logical Block Address

[0064] PI: Protection Information

[0065] Format: Formatting command

[0066] LBAF: LBA Format

[0067] DPS: E2E Data Protection Type Settings

[0068] PRACT: Protection Information Action

[0069] PRCHK: Protection Information Check

[0070] In the use of NVMe SSDs, the write zeroes command is often used to set the logical block range to zero. However, the write zero command may fail due to problems with the command or other commands. The current write zeroing method cannot provide timely feedback and verification of the write zeroing result. It requires manual inspection of the written zeroing logical blocks, which is inefficient and wastes a lot of human resources. Based on this, the embodiments of this application provide an NVMe hard drive write zeroing method that can provide timely feedback of the write zeroing result.

[0071] Reference Figure 1 The diagram illustrates a step-by-step flowchart of an NVMe hard drive zero-writing method according to an embodiment of this application. The method may specifically include the following steps:

[0072] S101: Obtain the target write zero region of the NVMe hard drive and determine whether the target write zero region is an end-to-end data protection type.

[0073] NVMe hard drives can generally include end-to-end data protection type and non-end-to-end data protection type. End-to-end data protection means that the data written to the flash memory by the host must be consistent with the data originally written by the host, and the data read by the host must also be consistent with the data originally read from the flash memory.

[0074] NVMe SSDs use a Protection Information (PI) feature added to the controller to verify data consistency. Specifically, this involves adding an extra 8 bytes of PI to user logical blocks or having the host software add ≥8 bytes of metadata, enabling the controller and / or host software to verify the integrity and consistency of user data logical blocks.

[0075] PI is a type of metadata. PI is like a bodyguard for logical block data. The NVMe protocol defines that SSD controllers can support adding additional metadata to each logical block, as well as how the host can customize how metadata zones are used. One of the most common uses of metadata is to deliver end-to-end data protection information from PI.

[0076] For example, an NVMe SSD can support four LBAF types: LBAF0, LBAF1, LBAF2, and LBAF3. The corresponding logical block types after formatting the NVMe SSD are 512B, 512B+8, 4K, and 4K+8. Among them, 512B+8 and 4K+8 support end-to-end data protection, while 512B and 4K do not support end-to-end data protection.

[0077] Therefore, once the target write zero area of ​​the NVMe hard drive that needs to be written zero is determined, it can be determined whether the target write zero area is an end-to-end data protection type by obtaining the logical block type of the target write zero area.

[0078] S102: When the target write zero region is not an end-to-end data protection type, a write zero command is issued to the target write zero region. After a preset interval after issuing the write zero command, a read command is issued to the target write zero region, and the write zero result of the write zero command is generated.

[0079] If the target write-zero region is not an end-to-end data protection type, the write-zero command issued to the target write-zero region does not need to carry protection information; the write-zero command can be sent directly. When the target write-zero region is not an end-to-end data protection type, different test processes can be performed depending on whether the target write-zero region is a single-segment LBA region, a multi-segment overlapping LBA region, and whether a driver management command has been issued to the target write-zero region after the write-zero operation.

[0080] In one feasible implementation, when the target write-zero region is a single-segment LBA region, the initial data stored in the target write-zero region and the initial data of the critical region of the target write-zero region are obtained; a write-zero command is issued to the target write-zero region; after a preset interval after issuing the write-zero command, a read command is issued to both the target write-zero region and the critical region of the target write-zero region to obtain the current data of the target write-zero region and the critical region of the target write-zero region; when the current data of the target write-zero region is zero, and the current data of the critical region is the same as the initial data of the critical region, a write-zero success result is generated.

[0081] When the target write zero region is a single-segment LBA region, by comparing the data before and after writing zero in the target write zero region and the critical region of the target write zero region, we can not only test whether the write zero result of the target write zero region was successful, but also verify whether the data in the critical region has changed due to data errors in the write zero instruction for the target write zero region.

[0082] In one feasible implementation, when the target write-zero region is an LBA with multiple overlapping regions, a write-zero command is issued to the target write-zero region; after a preset interval after issuing the write-zero command, a read command is issued to the overlapping region; when the data read from the overlapping region is zero, a write-zero success result is generated.

[0083] For example, the target write zero regions are defined as 1-8LBA and 2-9LBA. The target write zero regions include the overlapping region: 2-8LBA. In actual implementation, after issuing the write zero command, a read command can be issued to 2-8LBA. If the write zero result for the target write zero region is successful, then the data in 2-8LBA will all be 0. When the data in 2-8LBA is all 0, then all the data in the corresponding 1-9LBA will also be 0.

[0084] In one feasible implementation, when the target write-zero region is not an end-to-end data protection type, a write-zero command is issued to the target write-zero region, and after a preset interval after issuing the write-zero command, a read command is issued to the target write-zero region to generate a first read result.

[0085] Then, driver management commands sent to the target write-zero region can be monitored at certain time intervals; when a driver management command sent to the target write-zero region is detected, a read command is sent to the target write-zero region to generate a second read result; if both the first read result and the second read result are zero, a write-zero success result is generated.

[0086] The driver management commands are trim commands, including but not limited to format, reset, driver unloading / loading, normal power-on / off, abnormal power-on / off, and restart commands. Driver management commands are generally used to notify the NVMe hard drive's controller that data in a certain area can be cleared. However, driver management commands only affect the state of the NVMe hard drive and theoretically cannot write new data to it. But if an error occurs in a driver management command, it can still cause changes to the data in the NVMe hard drive. Therefore, in this embodiment, after writing zeros to the target zero-write area, the driver management commands for the target zero-write area can be monitored. Only when the data read before and after executing the driver management commands in the target zero-write area is 0 is the zero-write result of the target zero-write area considered successful. In actual implementation, the time period for monitoring driver management commands after writing zeros to the target zero-write area can be customized according to actual needs, and this application embodiment does not impose any restrictions.

[0087] S103: When the target write-zero region is an end-to-end data protection type, if the end-to-end data protection of the target write-zero region passes the support verification, obtain the protection parameters corresponding to the target write-zero region; determine the write-zero command for the protection type corresponding to the target write-zero region based on the protection parameters, wherein the write-zero command for the protection type corresponds one-to-one with the protection parameters; after a preset interval after issuing the write-zero command for the protection type, issue a read command to the target write-zero region to generate the write-zero result of the write-zero command.

[0088] When the target write-zero region is an end-to-end data protection type, the end-to-end data protection of the target write-zero region needs to be supported by verification to ensure that the target write-zero region correctly supports end-to-end data protection.

[0089] Specifically, the target write-zero region can be formatted. For example, when formatting the target write-zero region, Format LBF1 mset=0 is used. After LBF1 formatting, the corresponding type is 512B+8, which supports end-to-end data protection. mset refers to the format type of metadata in the NVMe hard drive. When mset=0, the metadata is generally located in the cache area. When mset=1, the metadata is appended to the data. When the value of mset is 0 or 1, the end-to-end data protection support verification of the target write-zero region is consistent.

[0090] A reset command is issued to the formatted NVMe hard drive to make the formatting of the target write-zero area effective. Then, an NVMe management command is invoked to check whether the dps parameter of the target write-zero area is 1. If the dps parameter of the target write-zero area is 1, the end-to-end data protection of the target write-zero area passes the support verification. If the dps parameter of the target write-zero area is 1, the end-to-end data protection of the target write-zero area fails the support verification, and the write-zeroing process of the target write-zero area can be stopped. A prompt indicating that the target write-zero area has failed the support verification is generated and displayed so that staff can be promptly informed of the problem with the NVMe hard drive and take recovery action.

[0091] The two key parameters of PI are PRACT and PRCHK. PRACT specifies the mechanism for generating PI information, while PRCHK specifies the fields of PI information to be checked.

[0092] When PRACT=0, the data sent by the host to the NVMe SSD carries protection information, and the NVMe SSD writes it directly to NAND without changing the protection information; when PRACT=1, the NVMe SSD controller changes the data protection information after the host sends the data to the NVMe SSD.

[0093] PRCHK consists of three bits: bit[0], bit[1], and bit[2], where:

[0094] When PRCHK bit[0] = 1, it indicates that the Reference Tag field of the PI is being checked; the Reference Tag is a field in the metadata protection information (PI), which is generally the first 4 bits of the LBA;

[0095] When PRCHK bit[1] = 1, it indicates that the Application Tag field of the PI is being checked; the field in the protection information (PI) in the metadata of the Application Tag field can be added by the user and can be any value;

[0096] When PRCHK bit[2] = 1, it indicates that the Guard field of PI is being checked.

[0097] If the end-to-end data protection of the target write zero region passes the support verification, it is necessary to ensure that the write zero instruction for the target write zero region also carries protection information. Therefore, the PRACT, PRCHK[0], PRCHK[1] and PRCHK[2] of the target write zero region are first obtained as protection parameters.

[0098] In one feasible implementation, based on the values ​​of PRACT, PRCHK[0], PRCHK[1] and PRCHK[2], a variety of different protection parameter combinations are generated; write zero commands for the protection type corresponding to each of the various different protection parameter combinations are generated respectively; the various different protection parameter combinations and the write zero commands for the protection type corresponding to each of the various different protection parameter combinations are stored in a preset list, and the preset list is stored in a tree structure.

[0099] For example, a combination of protection parameters may include:

[0100] PRACT=0,SLBA! =RefTag(CMD);

[0101] PRACT=0, SLBA=RefTag(CMD), PRCHK bit[0]=0, PRCHK bit[1]=0, PRCHK bit[2]=0;

[0102] PRACT=0, SLBA=RefTag(CMD), PRCHK bit[0]=1, PRCHK bit[1]=1, PRCHK bit[2]=1;

[0103] PRACT = 0, SLBA = RefTag(CMD), PRCHK bit[0] = 1, PRCHK bit[1] = 0, PRCHK bit[2] = 0, s = 2^32;

[0104] PRACT=1SLBA! =RefTag(CMD);

[0105] PRACT=1, SLBA=RefTag(CMD), PRCHK bit[0]=0, PRCHK bit[1]=0, PRCHK bit[2]=0;

[0106] PRACT=1, SLBA=RefTag(CMD), PRCHK bit[0]=0, PRCHK bit[1]=1, PRCHK bit[2]=0;

[0107] PRACT=1, SLBA=RefTag(CMD), PRCHK bit[0]=0, PRCHK bit[1]=0, PRCHK bit[2]=1;

[0108] PRACT=1, SLBA=RefTag(CMD), PRCHK bit[0]=1, PRCHK bit[1]=1, PRCHK bit[2]=1.

[0109] Specifically, the write-zero command for each protection type is determined for different combinations of protection parameters. The write-zero commands for different combinations of protection parameters are as follows:

[0110] 1) PRACT = 0, SLBA! = RefTag(CMD), the corresponding write-zero command for the protection type is:

[0111] nvme write-zeroes / dev / nvme0n1-s0-c0-r1-p0.

[0112] If the result is INVALID_PROTECION_INFO, continue the test; otherwise, the test fails.

[0113] 2) PRACT = 0, SLBA = RefTag(CMD), PRCHK bit[0] = 0, PRCHK bit[1] = 0, PRCHK bit[2] = 0, and the corresponding write-zero command for the protection type is:

[0114] nvme write-zeroes / dev / nvme0n1-s0-c0-r0-p0.

[0115] 3) PRACT = 0, SLBA = RefTag(CMD), PRCHK bit[0] = 1, PRCHK bit[1] = 1, PRCHK bit[2] = 1, and the corresponding write-zero command for the protection type is:

[0116] nvme write-zeroes / dev / nvme0n1-s0-c0-r0-p0x7.

[0117] 4) PRACT = 0, SLBA = RefTag(CMD), PRCHK bit[0] = 1, PRCHK bit[1] = 0, PRCHK bit[2] = 0, s = 2^32, and the corresponding write-zero command for the protection type is:

[0118] nvme write-zeroes / dev / nvme0n1-s4294967296-c0-r0-p1.

[0119] 5) PRACT = 1SLBA! = RefTag(CMD), and its corresponding write-zero command for the protection type is:

[0120] nvme write-zeroes / dev / nvme0n1-s0-c0-r1-p0x8.

[0121] 6) PRACT = 1, SLBA = RefTag(CMD), PRCHK bit[0] = 0, PRCHK bit[1] = 0, PRCHK bit[2] = 0, and the corresponding write-zero command for the protection type is:

[0122] nvme write-zeroes / dev / nvme0n1-s0-c0-r0-p0x8.

[0123] 7) PRACT = 1, SLBA = RefTag(CMD), PRCHK bit[0] = 0, PRCHK bit[1] = 1, PRCHK bit[2] = 0, and the corresponding write-zero command for the protection type is:

[0124] nvme write-zeroes / dev / nvme0n1-s0-c0-r0-p0xa.

[0125] 8) PRACT = 1, SLBA = RefTag(CMD), PRCHK bit[0] = 0, PRCHK bit[1] = 0, PRCHK bit[2] = 1, and the corresponding write-zero command for the protection type is:

[0126] nvme write-zeroes / dev / nvme0n1-s0-c0-r0-p0xc.

[0127] 9) PRACT = 1, SLBA = RefTag(CMD), PRCHK bit[0] = 1, PRCHK bit[1] = 1, PRCHK bit[2] = 1, and the corresponding write-zero command for the protection type is:

[0128] nvme write-zeroes / dev / nvme0n1-s0-c0-r0-p0xf.

[0129] In the write-zero command for each of the above protection types, -s0 means starting from the 0th LBA, -c represents the number of LBAs, -r is the value of RefTag, and -p represents four bits, namely PRCHK[0], PRCHK[1], PRCHK[2] and PRACT.

[0130] Reference Figure 2 The diagram illustrates a structure of a protection parameter combination and a write zero command for a protection type. In a feasible implementation, when storing the various different protection parameter combinations and the write zero commands for the protection types corresponding to each of the various different protection parameter combinations in a preset list, the protection parameter combinations of PRACT and PRCHK in the case of SLBA=RefTag(CMD) can be stored in a tree structure. For example, an empty root node is created, and PRACT=0 and PRACT=1 are used as first-level leaf nodes, PRCHK[0]=0 and PRCHK[0]=1 are used as the second leaf nodes of each first-level leaf node, and so on. The write zero command for the protection type is stored in the leaf nodes of the lowest level. Leaf nodes for protection parameter combinations that do not have a corresponding write zero command for the protection type can be left empty.

[0131] Matching is performed in the preset list based on the protection parameters corresponding to the target write zero region; the protection parameter combination corresponding to the protection parameters corresponding to the target write zero region is obtained; the write zero command of the protection type corresponding to the protection parameter combination is used as the write zero command of the protection type corresponding to the target write zero region. The write zero command of the protection type stored in the form of a tree structure can be matched on a fixed path, which shortens the matching time and improves the efficiency of the write zero operation.

[0132] After determining the write zero command of the protection type corresponding to the target write zero region, the write zero command of the protection type is issued to the target write zero region. Specifically, in the scenarios of PRACT = 0, SLBA! = RefTag(CMD) and PRACT = 1, SLBA! = RefTag(CMD), after issuing the corresponding write zero command of the protection type, the execution result will be automatically returned. If the returned result is:

[0133] INVALID_PROTECION_INFO

[0134] If the write to the zero region of the target is successful, a result indicating successful write to zero will be generated; otherwise, an error message will be generated.

[0135] For any other write-to-zero command besides the two protection parameter combinations mentioned above, after the write-to-zero command is sent to the target write-to-zero area, a read command is sent to the target write-to-zero area after a preset interval. If the data returned by the read is 0, a write-to-zero success result is generated. If a write-to-zero success result is not generated, a write-to-zero failure result is generated, and a failure prompt pop-up window is displayed.

[0136] In one feasible implementation, to visualize the zero-write process, the zero-write process of the target zero-write region of the NVMe hard drive can be acquired and recorded in real time; after generating the zero-write result of the zero-write command for the target zero-write region, a zero-write report for the target zero-write region of the NVMe hard drive is generated and displayed. The zero-write report includes the name of the NVMe hard drive, the interval identifier of the target zero-write region, whether the end-to-end of the target zero-write region is a data protection type, the issued zero-write command, and the zero-write result, thereby facilitating staff to promptly identify problems, analyze problems, and perform recovery processing.

[0137] This method automatically generates the result of the write zero command when writing zero to the target write zero area, and can provide timely feedback on the write zero result to verify whether the write zero result is successful, saving the cost of repeated manual testing. At the same time, it designs more adaptive write zeroing processes for different scenarios involved in the target write zero area, such as whether it is an end-to-end data protection type, and under the end-to-end data protection type, there are different write zeroing processes corresponding to different protection parameters, which can be adapted to various types of hard drives.

[0138] Reference Figure 3 This diagram illustrates a functional block diagram of an NVMe hard drive zero-write device according to an embodiment of this application. The device is applied to an NVMe hard drive and includes:

[0139] The acquisition module 100 is used to acquire the target write zero area of ​​the NVMe hard drive and determine whether the target write zero area is an end-to-end data protection type.

[0140] The first write-zero module 200 is used to issue a write-zero command to the target write-zero region when the target write-zero region is not an end-to-end data protection type, issue a read command to the target write-zero region after a preset interval after issuing the write-zero command, and generate the write-zero result of the write-zero command.

[0141] The second write-zero module 300 is configured to, when the target write-zero region is an end-to-end data protection type, and provided that the end-to-end data protection of the target write-zero region has passed support verification, obtain the protection parameters corresponding to the target write-zero region; determine the write-zero command corresponding to the protection type of the target write-zero region based on the protection parameters, wherein the write-zero command of the protection type corresponds one-to-one with the protection parameters; and, after a preset interval after issuing the write-zero command of the protection type, issue a read command to the target write-zero region to generate the write-zero result of the write-zero command.

[0142] Optionally, the first write-zero module includes:

[0143] The first write-zero unit is configured to, when the target write-zero region is a single-segment LBA region, acquire the initial data stored in the target write-zero region and the initial data of the critical region of the target write-zero region; issue a write-zero command to the target write-zero region; after a preset interval following the issuance of the write-zero command, issue read commands to both the target write-zero region and the critical region of the target write-zero region to acquire the current data of the target write-zero region and the critical region of the target write-zero region; and generate a write-zero success result when the current data of the target write-zero region is zero and the current data of the critical region is the same as the initial data of the critical region.

[0144] Optionally, the first write-zero module includes:

[0145] The second write-zero unit is used to issue a write-zero command to the target write-zero region when the target write-zero region is an LBA with multiple overlapping regions.

[0146] After a preset interval following the issuance of the write zero command, a read command is issued to the overlapping region;

[0147] When the data read from the overlapping region is zero, a result indicating successful write to zero is generated.

[0148] Optionally, the first write-zero module includes:

[0149] The third write-zero unit is used to issue a write-zero command to the target write-zero region when the target write-zero region is not an end-to-end data protection type, and after a preset interval after issuing the write-zero command, issue a read command to the target write-zero region to generate a first read result.

[0150] Monitor the driver management commands issued to the target write-zero region;

[0151] When a driver management command is detected to be sent to the target write zero region, a read command is sent to the target write zero region to generate a second read result;

[0152] If both the first read result and the second read result are zero, a result indicating successful write to zero is generated.

[0153] Optionally, the device further includes:

[0154] The format verification process is used to format the target write-zero region; a reset command is issued to the formatted NVMe hard drive to make the formatting of the target write-zero region effective; the dps parameter of the target write-zero region is checked to see if it is 1; if the dps parameter of the target write-zero region is 1, then the end-to-end data protection of the target write-zero region passes the support verification; if the dps parameter of the target write-zero region is 1, then the end-to-end data protection of the target write-zero region fails the support verification, and a prompt indicating that the target write-zero region has failed the support verification is generated.

[0155] Optionally, the second write-zero module includes:

[0156] The protection parameter acquisition unit is used to acquire PRACT, PRCHK[0], PRCHK[1] and PRCHK[2] of the target write-zero region as protection parameters.

[0157] Optionally, the device further includes:

[0158] The protection parameter combination storage module is used to generate a variety of different protection parameter combinations based on the values ​​of PRACT, PRCHK[0], PRCHK[1] and PRCHK[2]; generate write zero commands for the protection type corresponding to each of the various different protection parameter combinations; and store the various different protection parameter combinations and the write zero commands for the protection type corresponding to each of the various different protection parameter combinations in a preset list, wherein the preset list is stored in a tree structure.

[0159] Optionally, the second write-zero module includes:

[0160] The protection type write zero command determination unit is used to match the protection parameters corresponding to the target write zero region in the preset list; obtain the protection parameter combination corresponding to the protection parameters corresponding to the target write zero region; and use the write zero command of the protection type corresponding to the protection parameter combination as the write zero command of the protection type corresponding to the target write zero region.

[0161] Optionally, the device further includes:

[0162] A real-time acquisition unit is used to acquire and record the write-zero process of the target write-zero region of the NVMe hard drive in real time.

[0163] The write zero report generation module is used to generate and display a write zero report for the target write zero region of the NVMe hard drive after generating the write zero result of the write zero command for the target write zero region. The write zero report includes the name of the NVMe hard drive, the interval identifier of the target write zero region, the end-to-end data protection type of the target write zero region, and the write zero result.

[0164] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the NVMe hard drive zero-write method as described in the embodiments of the present application.

[0165] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0166] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0167] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0168] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0169] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0170] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.

[0171] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0172] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for writing zero to an NVMe hard drive, characterized in that, Applied to NVMe hard drives, the method includes: Obtain the target write zero region of the NVMe hard drive and determine whether the target write zero region is an end-to-end data protection type; When the target write zero region is not an end-to-end data protection type, a write zero command is issued to the target write zero region. After a preset interval after issuing the write zero command, a read command is issued to the target write zero region, and the write zero result of the write zero command is generated. When the target write-zero region is an end-to-end data protection type, if the end-to-end data protection of the target write-zero region passes the support verification, the protection parameters corresponding to the target write-zero region are obtained. Based on the protection parameters corresponding to the target write-zero region, determine the write-zero command for the protection type corresponding to the target write-zero region, wherein the write-zero command for the protection type corresponds one-to-one with the protection parameters; After a preset interval following the issuance of the write-zero command of the protection type, a read command is issued to the target write-zero region to generate the write-zero result of the write-zero command.

2. The method according to claim 1, characterized in that, When the target write-zero region is not an end-to-end data protection type, a write-zero command is issued to the target write-zero region. After a preset interval following the issuance of the write-zero command, a read command is issued to the target write-zero region, and the write-zero result of the write-zero command is generated, including: When the target write-zero region is a single-segment LBA region, obtain the initial data stored in the target write-zero region and the initial data of the critical region of the target write-zero region; A write-zero command is issued to the target write-zero region; After a preset interval after issuing a write-zero command, a read command is issued to both the target write-zero region and the critical region of the target write-zero region to obtain the current data of the target write-zero region and the critical region of the target write-zero region. When the current data of the target write-zero region is zero, and the current data of the critical region is the same as the initial data of the critical region, a write-zero success result is generated.

3. The method according to claim 1, characterized in that, When the target write-zero region is not an end-to-end data protection type, a write-zero command is issued to the target write-zero region. After a preset interval following the issuance of the write-zero command, a read command is issued to the target write-zero region, and the write-zero result of the write-zero command is generated, including: When the target write zero region is an LBA with multiple overlapping regions, a write zero command is issued to the target write zero region; After a preset interval following the issuance of the write zero command, a read command is issued to the overlapping region; When the data read from the overlapping region is zero, a result indicating successful write to zero is generated.

4. The method according to claim 1, characterized in that, When the target write-zero region is not an end-to-end data protection type, a write-zero command is issued to the target write-zero region. After a preset interval following the issuance of the write-zero command, a read command is issued to the target write-zero region, and the write-zero result of the write-zero command is generated, including: When the target write zero region is not an end-to-end data protection type, a write zero command is issued to the target write zero region. After a preset interval after issuing the write zero command, a read command is issued to the target write zero region to generate a first read result. Monitor the driver management commands issued to the target write-zero region; When a driver management command is detected to be sent to the target write zero region, a read command is sent to the target write zero region to generate a second read result; If both the first read result and the second read result are zero, a result indicating successful write to zero is generated.

5. The method according to claim 1, characterized in that, When the target write-zero region is an end-to-end data protection type, the method further includes: Format the target write-zero region; A reset command is issued to the formatted NVMe hard drive to make the formatting of the target write-zero area take effect; Check if the dps parameter of the target write-zero region is 1; If the dps parameter of the target write-zero region is 1, then the end-to-end data protection of the target write-zero region passes the support verification. If the dps parameter of the target write-zero region is 1, then the end-to-end data protection of the target write-zero region fails the support verification, and a prompt indicating that the target write-zero region has failed the support verification is generated.

6. The method according to claim 1, characterized in that, Obtaining the protection parameters corresponding to the target write-zero region includes: The PRACT, PRCHK[0], PRCHK[1] and PRCHK[2] of the target write-zero region are obtained as protection parameters.

7. The method according to claim 6, further comprising: Based on the values ​​of PRACT, PRCHK[0], PRCHK[1] and PRCHK[2], various combinations of protection parameters are generated; Generate write zero commands for the protection types corresponding to the various different combinations of protection parameters; The various combinations of protection parameters and the write zero commands for the protection types corresponding to each combination of protection parameters are stored in a preset list, which is stored in a tree structure.

8. The method according to claim 7, characterized in that, Based on the protection parameters corresponding to the target write-zero region, determine the write-zero command for the protection type corresponding to the target write-zero region, including: Matching is performed in the preset list based on the protection parameters corresponding to the target write-zero region; Obtain the protection parameter combination corresponding to the protection parameters of the target write-zero region; The write zero command of the protection type corresponding to the protection parameter combination is used as the write zero command of the protection type corresponding to the target write zero region.

9. The method according to claim 1, characterized in that, The method further includes: The write-zero process of the target write-zero region of the NVMe hard drive is acquired and recorded in real time; After generating the write zeroing result of the write zeroing command for the target write zeroing region, a write zeroing report for the target write zeroing region of the NVMe hard drive is generated and displayed. The write zeroing report includes the name of the NVMe hard drive, the interval identifier of the target write zeroing region, the end-to-end data protection type of the target write zeroing region, and the write zeroing result.

10. An NVMe hard drive zero-write device, characterized in that, The device, applied to NVMe hard drives, includes: The acquisition module is used to acquire the target write zero area of ​​the NVMe hard drive and determine whether the target write zero area is an end-to-end data protection type. The first write-zero module is used to issue a write-zero command to the target write-zero region when the target write-zero region is not an end-to-end data protection type, issue a read command to the target write-zero region after a preset interval after issuing the write-zero command, and generate the write-zero result of the write-zero command. The second write-zero module is used to, when the target write-zero region is an end-to-end data protection type, obtain the protection parameters corresponding to the target write-zero region after the end-to-end data protection of the target write-zero region has passed the support verification; determine the write-zero command corresponding to the protection type of the target write-zero region based on the protection parameters, wherein the write-zero command of the protection type corresponds one-to-one with the protection parameters; and after a preset interval after issuing the write-zero command of the protection type, issue a read command to the target write-zero region to generate the write-zero result of the write-zero command.

11. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the NVMe hard disk write-zero method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method for deleting the data and device thereof

    CN102511044A

  • VM encryption of block storage with end-to-end data integrity protection in a smartnic

    US20210150074A1