[0055] In order to fully understand the technical content of the present invention, the technical solution of the present invention will be further introduced and illustrated below in conjunction with specific embodiments, but it is not limited thereto.
[0056] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
[0057] It should be understood that when used in this specification and the appended claims, the terms "including" and "including" indicate the existence of the described features, wholes, steps, operations, elements and/or components, but do not exclude one or The existence or addition of multiple other features, wholes, steps, operations, elements, components, and/or collections thereof.
[0058] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates other circumstances, the singular forms "a", "an" and "the" are intended to include plural forms.
[0059] It should be further understood that the term "and/or" used in the specification and appended claims of the present invention refers to any combination of one or more of the items listed in the associated list and all possible combinations, and includes these combinations .
[0060] The existing single-threaded way to send read commands, please refer to figure 1 , Host sends read commands to SSD in a single channel. One command is completed and the next is sent. This method can ensure the sequential execution of read commands, but does not bring out the performance of NVMe. The command queue supported by NVMe can reach 64K. In the present invention, the read command is sent through the Overlapped I/O mode, please refer to figure 2 , Overlapped is an asynchronous I/O model. Asynchronous I/O is different from synchronous I/O. In synchronous I/O, the program is suspended until the I/O is processed, and the program can be controlled. Asynchronous I/O, call a function to tell the OS to perform an I/O operation, return immediately before the end of the I/O, and continue the program. After the operating system completes the I/O, it sends a notification message. Overlapped I/O replaces the multi-threaded function. The OS transfers data, completes the context switch, and informs after processing. The data structure of Overlapped is as follows:
[0061] typedef struct_OVERLAPPED{
[0062] DWORD Internal;
[0063] DWORD InternalHigh;
[0064] DWORD Offset;
[0065] DWORD OffsetHigh;
[0066] HANDLE hEvent;
[0067] }OVERLAPPED, *LPOVERLAPPED;
[0068] By sending multiple overlapped requests, each overlapped handles independent request operations. For the same file Handle, when the system has multiple asynchronous operations, the event kernel object can be identified through hEvent in the overlapped. CreateEvent creates an event for each request, initializes the hEvent member of each request, multiple read and write requests to the same file, binds an event object for each operation, and calls GetOverlappedresult to wait for one (or all) to complete.
[0069] Please refer to image 3 , The method of the present invention for improving the overall scanning efficiency of SSD includes the following steps:
[0070] S10. Define several overlapped resources, and execute S20 in the next step;
[0071] S20: Initialize the overlapped resources, and execute S30 in the next step;
[0072] S30. Determine whether there is a read command to be sent, if yes, execute step S40, if not, execute step S70;
[0073] S40. Determine whether there are idle overlapped resources among the plurality of overlapped resources, if yes, execute step S50, and if not, execute step S60;
[0074] S50: Send a read command through the idle overlapped resources, and execute S60 in the next step;
[0075] S60: Wait for idle overlapped resources after sending the read command.
[0076] S70. Release all overlapped resources.
[0077] Specifically, by first defining a macro to identify how many overlapped resources need to be opened, defining N resources, and then performing initialization, if there is a read command to be sent, it will look for free OVP (overlapped abbreviation) resources. If so, send a read command through OVP, that is, the last parameter Overlapped in deviceIoControl is assigned to the acquired free OVP resource. After sending, wait for the free OVP resource to be released. When there is free resource, continue to send the read command. If there is no free resource, continue to wait, and so on, until all pending read commands are sent.
[0078] Please refer to Figure 4 , Judging whether there are idle overlapped resources among the several overlapped resources, obtaining idle overlapped resources specifically includes the following steps:
[0079] S401: Determine whether the number of free overlapped resources in the defined overlapped resources is greater than zero, if yes, execute step S402, if not, end the entire process;
[0080] S402: Index the defined overlapped resources in sequence, and execute S403 in the next step;
[0081] S403: Determine whether the event kernel object member in the currently indexed Overlapped resource is an illegal handle, if yes, execute step S404, and if not, end the entire process;
[0082] S404: Create an event handle for the current overlapped resource through the CreateEvent function, and reduce one idle overlapped resource among the correspondingly defined overlapped resources by one.
[0083] Specifically, if there are free resources, index the N OVPs, starting from the 0th, determine whether the hEvent member in the OVP is an INVALID (illegal) handle, and initialize it as an illegal handle to identify the idle state. If it is an illegal handle, create an event handle through the CreateEvent function and assign it to the hEvent member of OVP. The number of corresponding OVP free resources is reduced by 1, and the OVP resource is returned.
[0084] Please refer to Figure 5 In the step of waiting for the idle overlapped resources after sending the read command, waiting for the release of the idle overlapped resources specifically includes the following steps:
[0085] S601. Index the defined overlapped resources in sequence starting from the zeroth one, and execute S602 in the next step;
[0086] S602. Check the result of the overlapped resource of the current index through the GetOverlappedresult() function, and determine whether the command is sent, if yes, execute step S603, if not, execute step S604;
[0087] S603. Release the current overlapped resource as an idle overlapped resource, and increase one idle overlapped resource among the correspondingly defined overlapped resources.
[0088] S604: Determine whether it is the last overlapped resource, if yes, end the entire process, if not, proceed to step S601.
[0089] Specifically, first index the N OVPs, starting from the 0th, view the OVP results through the GetOverlappedresult() function, and set the last parameter bWait to False, which means that it does not wait for the completion of the I/O execution and asynchronous operation. If the result is complete, the current OVP resources are released, the number of OVP idle resources is increased by 1, and the hEvent member event handle is set to an illegal handle, indicating idle resources. If it has not been waiting for free resources, it will directly return the result, continue to call the module in the main program and continue to wait for free resources.
[0090] It should be understood that the size of the sequence number of each step in the foregoing embodiment does not mean the order of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0091] Corresponding to the above-mentioned method for improving the overall scanning efficiency of the SSD, the present invention also provides a device for improving the overall scanning efficiency of the SSD. Please refer to Image 6 , The device includes a definition unit 1, an initialization unit 2, a first judgment unit 3, a second judgment unit 4, a read command sending unit 5, a waiting unit 6 and a release unit 7;
[0092] Definition unit 1, used to define several overlapped resources;
[0093] The initialization unit 2 is used to initialize the overlapped resources;
[0094] The first judging unit 3 is used to judge whether there is a read command to be sent;
[0095] The second judging unit 4 is used for judging whether there is an idle overlapped resource among the multiple overlapped resources;
[0096] The read command sending unit 5 is used to send a read command through idle overlapped resources;
[0097] The waiting unit 6 is used to wait for idle overlapped resources after sending a read command;
[0098] The release unit 7 is used to release all overlapped resources.
[0099] Further, please refer to Figure 7 , The second judgment unit 4 includes a first judgment module 41, a first index module 42, a second judgment module 43, and an event handle creation module 44;
[0100] The first judgment module 41 is used to judge whether the number of idle overlapped resources among the defined overlapped resources is greater than zero;
[0101] The first indexing module 42 is used to sequentially index a number of overlapped resources defined;
[0102] The second judgment module 43 is used to judge whether the event kernel object member in the overlapped resource of the current index is an illegal handle;
[0103] The event handle creation module 44 is used to create an event handle for the current overlapped resource through the CreateEvent function, and the number of correspondingly defined overlapped resources is reduced by one.
[0104] Further, please refer to Figure 8 , The waiting unit 6 includes a second index module 61, a third judgment module 62, and a release module 63;
[0105] The second indexing module 61 is used for indexing a number of overlapped resources defined sequentially starting from the zeroth;
[0106] The third judgment module 62 is used to check the result of the overlapped resource of the current index through the GetOverlappedresult() function, and judge whether the command is sent completely;
[0107] The releasing module 63 is used to release the current overlapped resource as an idle overlapped resource, and one idle overlapped resource among the correspondingly defined overlapped resources is increased by one.
[0108] Such as Picture 9 As shown, the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and running on the processor. The processor executes the computer program to achieve the above-mentioned improvement in the efficiency of SSD full scan Method steps.
[0109] The computer device 700 may be a terminal or a server. The computer device 700 includes a processor 720, a memory, and a network interface 750 connected through a system bus 710, where the memory may include a non-volatile storage medium 730 and an internal memory 740.
[0110] The non-volatile storage medium 730 can store an operating system 731 and a computer program 732. When the computer program 732 is executed, the processor 720 can execute any method to improve the overall scanning efficiency of the SSD.
[0111] The processor 720 is used to provide computing and control capabilities, and support the operation of the entire computer device 700.
[0112] The internal memory 740 provides an environment for the operation of the computer program 732 in the non-volatile storage medium 730. When the computer program 732 is executed by the processor 720, the processor 720 can execute any method for improving the efficiency of SSD full disk scanning.
[0113] The network interface 750 is used for network communication, such as sending assigned tasks. Those skilled in the art can understand, Picture 9 The structure shown in is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation to the computer device 700 to which the solution of the present application is applied. The specific computer device 700 may include more More or fewer components, or combinations of certain components, or different component arrangements. Wherein, the processor 720 is configured to run the program code stored in the memory to implement the following steps:
[0114] Define several Overlapped resources;
[0115] Initialize Overlapped resources;
[0116] Determine whether there is a read command to be sent;
[0117] If yes, judge whether there are idle overlapped resources among the several overlapped resources;
[0118] If yes, send the read command through the idle Overlapped resource;
[0119] Wait for free overlapped resources after sending the read command.
[0120] Its further technical solution is: after the step of judging whether there is a read command to be sent, it further includes the following steps:
[0121] If not, release all overlapped resources.
[0122] The further technical solution is: in the judging whether there are idle overlapped resources among the plurality of overlapped resources, obtaining idle overlapped resources specifically includes the following steps:
[0123] Determine whether the number of free overlapped resources among the defined overlapped resources is greater than zero;
[0124] If yes, then index the defined overlapped resources in turn;
[0125] Determine whether the event kernel object member in the currently indexed Overlapped resource is an illegal handle;
[0126] If it is, an event handler is created for the current overlapped resource through the CreateEvent function, and the number of free overlapped resources in the correspondingly defined overlapped resources is reduced by one.
[0127] The further technical solution is: in the step of waiting for idle overlapped resources after sending the read command, waiting for the release of idle overlapped resources specifically includes the following steps:
[0128] Index the defined overlapped resources from the zeroth one;
[0129] Use the GetOverlappedresult() function to view the result of the overlapped resource of the current index to determine whether the command is sent;
[0130] If yes, the current overlapped resource is released as an idle overlapped resource, and the idle overlapped resource among the correspondingly defined overlapped resources is increased by one.
[0131] It should be understood that, in the embodiment of the present application, the processor 720 may be a central processing unit (Central Processing Unit, CPU), and the processor 720 may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), and dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
[0132] Those skilled in the art can understand, Picture 9 The structure of the computer device 700 shown in the figure does not constitute a limitation on the computer device 700, and may include more or fewer components than shown, or a combination of some components, or a different component arrangement.
[0133] 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 technical solution of the embodiment of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage The medium includes a number of instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code .
[0134] Those skilled in the art can clearly understand that for the convenience and conciseness of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned functions can be allocated to different functional units and modules as required. Module completion, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist alone physically, or two or more units can be integrated into one unit. The above-mentioned integrated units can be hardware-based Form realization can also be realized in the form of software functional unit. 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 protection scope of the present application. For the specific working process of the units and modules in the above-mentioned device, reference may be made to the corresponding process in the foregoing method embodiment, which will not be repeated here.
[0135] A person of ordinary skill in the art may realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered as going beyond the scope of the present invention.
[0136] In the embodiments provided by the present invention, it should be understood that the disclosed device and method may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, for example, multiple units or components may be It can be combined or integrated into another device, or some features can be omitted or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
[0137] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
[0138] The above only uses examples to further illustrate the technical content of the present invention for easier understanding of the reader, but it does not mean that the implementation of the present invention is limited to this. Any technical extension or re-creation made according to the present invention shall be subject to the present invention. protection of. The protection scope of the present invention is subject to the claims.