Disk data copying method and device, electronic equipment, medium and program product
By identifying the target disk and locating the location where the write operation failed, the problem of write operation failure caused by the target disk going offline was solved, achieving efficient and accurate disk data copying and ensuring data integrity and cloning efficiency.
Patent Information
- Application Number
- CN202411234003.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-11-08
AI Technical Summary
During disk restoration or cloning, write operations fail when the target disk goes offline, and data written before the disconnection is easily lost. Existing technologies struggle to achieve efficient and accurate disk data copying.
By identifying whether the new disk is the target disk, the location where data was not successfully written is determined, and data writing continues from that location to ensure data integrity. Disk parameter comparison and data block checksum calculation are used to locate the target location, and the writing speed is adjusted to prevent the connection from dropping again.
This effectively avoids write operation failures, ensures the integrity of the target disk data, and improves the accuracy and efficiency of disk backup or cloning.
Smart Images

Figure CN118915974A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a disk data replication method, device, electronic device, non-volatile storage medium and computer program product. Background Art
[0002] Disk is a storage device that uses magnetic recording technology to store data. As a computer storage medium, it can store a large amount of binary data and keep the data intact even after a power outage. In daily work and life, users will copy a disk data to another disk to achieve the purpose of disk recovery or disk backup and restore.
[0003] Related Technology During the process of restoring or cloning a disk, if the new disk to which data is written is disconnected due to an abnormal reason, when the disk is reset, the device handle opened by the application becomes invalid, causing the write operation to fail, and the data written before the disconnection is also easily lost.
[0004] In view of this, achieving efficient and accurate copying of disk data is a technical problem that needs to be solved by those skilled in the art.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] The present application provides a disk data replication method, device, electronic device, non-volatile storage medium and computer program product, which can achieve efficient and accurate disk data replication.
[0007] In order to solve the above technical problems, this application provides the following technical solutions:
[0008] On one hand, the present application provides a disk data replication method, comprising:
[0009] During the process of copying and writing data from the source disk to the target disk, when it is detected that the target disk is offline and a new disk exists, identifying whether the new disk is the target disk;
[0010] If the new disk is the target disk, determining the target location where the data was not successfully written;
[0011] The target position is used as the starting position for reading data from the source disk, and the data read from the source disk is written to the target disk.
[0012] Exemplarily, the identifying whether the new disk is the target disk includes:
[0013] Obtaining disk parameters of the target disk and the new disk;
[0014] If the disk parameters of the target disk are completely consistent with the disk parameters of the new disk, the new disk is reset for the target disk.
[0015] Exemplarily, the identifying whether the new disk is the target disk includes:
[0016] Respectively obtain the device name, disk partition layout, disk space capacity and disk signature of the target disk and the new disk;
[0017] When the device name, disk partition layout, disk space capacity and disk signature of the new disk are respectively the same as the device name, disk partition layout, disk space capacity and disk signature of the target disk, the new disk is the target disk.
[0018] Exemplarily, the process of copying and writing data from the source disk to the target disk includes:
[0019] Dividing the data to be copied on the source disk into multiple data blocks;
[0020] Read the corresponding data blocks from the source disk in sequence according to the data block positions and write them to the target disk, and whenever a data block is successfully written, calculate the checksum of the written data block as a data integrity check value, and store the data integrity check value. Exemplarily, determining the target position of the data that was not successfully written includes:
[0021] When the writing of the target data block fails, the location of the target data block is used as the starting location of the integrity check, and each data block to be checked in the target disk is read forward in sequence;
[0022] Whenever a data block to be checked is read, the checksum information of the current data block to be checked is calculated. If the checksum information is the same as the data integrity check value corresponding to the current data block to be checked, the next data block position adjacent to the current data block to be checked is the target position.
[0023] Exemplarily, writing the data read from the source disk to the target disk includes:
[0024] Calculate the data writing speed during the process of copying data from the source disk to the target disk;
[0025] Adjust the data writing speed according to a preset speed reduction rule to obtain a data writing speed limit value;
[0026] The data read from the source disk is written to the target disk at a speed less than or equal to the data writing speed limit value.
[0027] On the other hand, the present application provides a disk data replication device, comprising:
[0028] A disk identification module is used to identify whether the new disk is the target disk when it is detected that the target disk is offline and a new disk exists during the process of copying and writing data from the source disk to the target disk;
[0029] A write position positioning module, used for determining a target position where data has not been successfully written if the new disk is the target disk;
[0030] The data replication module is used to use the target position as the starting position for reading data from the source disk, and write the data read from the source disk to the target disk.
[0031] The present application also provides an electronic device, comprising a processor, wherein the processor is used to implement the steps of the disk data copying method as described in any of the preceding items when executing a computer program stored in a memory.
[0032] The present application also provides a non-volatile storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the disk data copying method as described in any of the preceding items are implemented.
[0033] Finally, the present application also provides a computer program product, including a computer program / instruction, which implements the steps of the disk data copying method as described in any of the preceding items when executed by a processor.
[0034] The advantage of the technical solution provided by the present application is that when the target disk to which data is written is disconnected, the new disk is compared with the target disk to ensure that the opened disk is the disk that has just been disconnected, thereby avoiding the phenomenon of failure of the write operation to the target disk during restoration or cloning. After determining that the opened disk is the target disk, the location of the data that has not been successfully written is located, and the data writing operation is continued from this location, thereby ensuring that the data written before the disconnection is truly written to the target disk, thereby ensuring the integrity of the target disk data, and effectively improving the accuracy and efficiency of disk backup or disk cloning.
[0035] In addition, the present application also provides corresponding implementation devices, electronic devices, non-volatile storage media and computer program products for the disk data replication method, which further makes the method more practical, and the devices, electronic devices, non-volatile storage media and computer program products have corresponding advantages.
[0036] The technical features mentioned above, the technical features to be mentioned below, and the technical features shown separately in the drawings can be combined with each other arbitrarily, as long as the combined technical features are not contradictory. All feasible feature combinations are technical contents clearly recorded in this application. Any of the multiple sub-features contained in the same sentence can be applied independently, and does not have to be applied together with other sub-features.
[0037] It should be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. 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 any creative work.
[0039] Figure 1 A flowchart of a disk data replication method provided by the present application;
[0040] Figure 2 A flowchart of another disk data replication method provided by the present application;
[0041] Figure 3 A structural diagram of a specific implementation of the disk data replication device provided by the present application;
[0042] Figure 4 A structural diagram of a specific implementation of the electronic device provided in this application. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The terms "including" and "having" and any variations thereof in the specification and the above-mentioned drawings are intended to cover non-exclusive inclusions. The term "exemplary" means "used as an example, embodiment or illustrative". Any embodiment described herein as "exemplary" is not necessarily to be interpreted as being superior or better than other embodiments.
[0044] When users use computers, there is a need for disk restoration or disk cloning. During the process of restoring or cloning the disk, the disk to which data is written is disconnected due to abnormal reasons, such as unstable power supply. For the Windows operating system, when reading and writing disk devices, you need to use the system function CreateFile (function name) to open the disk device. CreateFile will return the device handle (HANDLE) if it succeeds. ReadFile and WriteFile both need to read and write data of the corresponding disk device through the device handle. When the offline disk is reset, the device handle opened by the application will become invalid, resulting in the failure of the write operation to the target disk during restoration or cloning, and thus causing the failure of the entire process. If you want to continue writing data, the application needs to re-open the disk device with the CreateFile function to obtain the device handle. Moreover, when the device is offline, there is a situation where the data written before the offline is not actually written, so it is also necessary to ensure the integrity of the written data before writing to the new handle.
[0045] In order to solve the problem that the read and write operations in the related art need to reopen the handle and there is data that has not been written, the present invention will first confirm whether it is a device that has just been disconnected after detecting a new disk device, detect whether the written data is actually written after turning on the device, locate the position of the data that has not been successfully written, and continue to perform the data copy operation from this position, so as to achieve efficient and accurate copying of disk data. After introducing the technical solution of the present application, various non-limiting implementation methods of the present application are described in detail below. In order to better illustrate the present application, numerous specific details are given in the specific implementation methods below. Those skilled in the art should understand that the present application can also be implemented without these specific details. In other examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the main purpose of the present application.
[0046] See first Figure 1 , Figure 1 A flowchart of a disk data replication method provided by the present application may include the following contents:
[0047] S101: During the process of copying and writing data from a source disk to a target disk, when it is detected that the target disk is offline and a new disk exists, it is identified whether the new disk is the target disk.
[0048] In this step, copying and writing the source disk data to the target disk can be a disk restoration task or a disk cloning task. The disk restoration task is to restore the data and system to the original state based on the backup, which can be a partial restoration of the system or data or a copy of the entire disk. The disk cloning task is to completely copy the contents of a hard disk to another hard disk, including the operating system, files, applications, and configuration data, etc., to create a copy that is exactly the same as the source hard disk. Among them, the source disk is the disk where the data to be copied is located, and the target disk is the disk to which the data to be copied is about to be written. In the process of copying data from the source disk to the target disk, the application uses the disk number as a parameter to open the disk device. If the target disk is offline due to abnormal conditions such as unstable power supply and reset, the operating system may assign a new disk number to the reset target disk, or when a new disk device is connected, it will occupy the disk number of the target disk. In order to avoid data writing errors, after the target disk is offline, when a new disk is detected to be connected, considering that the new disk may not be the original disk for restoration or cloning, the application needs to detect whether the newly connected disk device, that is, the new disk, is the offline target disk to ensure device consistency.
[0049] S102: If the new disk is the target disk, determine the target location where the data was not successfully written.
[0050] When it is determined that the newly connected disk is the reset disk of the target disk that has been offline, in order to ensure that the data is truly written, to ensure the integrity of the written data, and thus to ensure the integrity of the data to be copied in the target disk, it is also necessary to locate the location of the unsuccessfully written data in the target disk. For the sake of ease of description, the location of the unsuccessfully written data is defined as the target location, which may be the location where the data fails to be written. The so-called location where the data fails to be written is the location where the data being written is located when the disk is offline, and may also be a location before the location where the data fails to be written.
[0051] S103: Using the target position as the starting position for reading data from the source disk, and writing the data read from the source disk to the target disk.
[0052] When it is determined that the currently opened disk device is the offline target disk and the target position where the data is not successfully written is located, the target position is used as the starting position, and the data after the target position and subsequent positions are read from the source disk and written to the target disk in sequence.
[0053] In the technical solution provided by the present application, when the target disk to which data is written is disconnected, the new disk is compared with the target disk to ensure that the opened disk is the disk that has just been disconnected, thereby avoiding the failure of the write operation to the target disk during restoration or cloning. After determining that the opened disk is the target disk, the location of the data that has not been successfully written is located, and the data writing operation is continued from this location, thereby ensuring that the data written before the disconnection is truly written to the target disk, thereby ensuring the integrity of the target disk data, and effectively improving the accuracy and efficiency of disk backup or disk cloning.
[0054] The above embodiment does not limit how to identify whether a new disk is a target disk. This embodiment also provides a simple and easy-to-implement method for identifying a target disk, which may include the following contents:
[0055] Obtain the disk parameters of the target disk and the new disk; if the disk parameters of the target disk and the new disk are exactly the same, the new disk is reset to the target disk.
[0056] In this embodiment, when opening a disk, disk parameters may be obtained, including but not limited to device name, disk partition layout, disk size, and disk signature, such as the GUID of a GPT disk. Exemplarily, the device name, disk partition layout, disk space capacity, and disk signature of the target disk and the new disk are obtained respectively; when the device name, disk partition layout, disk space capacity, and disk signature of the new disk correspond to the device name, disk partition layout, disk space capacity, and disk signature of the target disk respectively, the new disk is the target disk.
[0057] As can be seen from the above, this embodiment ensures that the newly opened disk is a disconnected disk by comparing disk parameters, thereby avoiding the occurrence of data writing failure and effectively improving the efficiency of disk restoration and disk cloning.
[0058] The above embodiment does not limit how to locate the target position. Based on the above embodiment, the present invention also provides an exemplary implementation method of the target position, which may include the following contents:
[0059] In this embodiment, when writing data from the source disk to the target disk, the data to be copied on the source disk can be divided into multiple data blocks, and the corresponding data blocks are read from the source disk in sequence according to the data block positions and written to the target disk. Whenever a data block is read from the source disk, it is written to the target disk to determine whether the data block is successfully written. If the data block is successfully written, the checksum of the written data block is calculated as a data integrity check value, and the data integrity check value is stored. At the same time, the position corresponding to the data block can also be stored. Continue to read the next data block and loop the above process. If there is no unprocessed data, the process ends. If the target disk is offline and the data block fails to be written to the target disk, wait for the disk to be connected again. When a new disk is detected, open the newly connected disk, obtain the parameters of the reopened disk, and compare it with the disk parameters of the target disk to ensure that the newly opened disk is the target disk. If there is a difference in the comparison parameters, the comparison fails and continue to wait for the new disk to be connected. For the data block that is not written successfully, for the convenience of description, it is defined as the target data block, and the location of the target data block is used as the starting position of the integrity check, that is, the data blocks before the target data block are checked for completeness. For the convenience of description, the data block that needs to be checked is defined as the data block to be checked, that is, the data blocks to be checked in the target disk are read forward from the location of the target data block. Whenever a data block to be checked is read, the checksum information of the current data block to be checked is calculated. If the checksum information is the same as the data integrity check value corresponding to the current data block to be checked, it indicates that the data block is truly written, and the data blocks before it are also truly written, while the data blocks after the data block are not truly written, so the next data block position adjacent to the current data block to be checked is used as the target position.
[0060] In this embodiment, for the convenience of description, the checksum calculated during the copying process of the data block is defined as the data integrity check value, and the checksum calculated during the process of locating the target position is defined as the checksum information. The checksum of this embodiment is used to detect whether an error occurs in the data block when it is stored from the source disk to the target disk. The checksum can be calculated by simple summation, that is, all bytes in the data block are added to obtain a sum. If the checksum length needs to be limited, the sum can be further modulo-operated. In addition, the checksum can also be calculated by performing an XOR operation on each byte in the data block. The XOR result of the same number is 0, and 0 XORs any number to that number. The checksum of the data block can also be calculated by a cyclic redundancy check method, that is, using a predefined polynomial and an initial value. The checksum of the data block can also be calculated by Adler-32, which is a 32-bit checksum algorithm that uses two different summation processes to increase the reliability of the check. A hash algorithm, such as MD5 / SHA-1 / SHA-256, can also be used to generate a fixed-length hash of the data block as the checksum of the data block. Of course, those skilled in the art can flexibly select the checksum calculation method according to the needs of specific applications. For scenarios where fast but not completely reliable verification is required, a simple sum or XOR checksum can be selected. For application scenarios where high verification accuracy is required, a cyclic redundancy check or a hash algorithm can be selected, or a custom checksum algorithm can be used, which does not affect the implementation of the present invention.
[0061] As can be seen from the above, this embodiment can efficiently and accurately locate the location of unsuccessfully written data by comparing the checksum, thereby ensuring the data integrity of the target disk and facilitating improving the efficiency of disk restoration and disk cloning.
[0062] Based on the above embodiment, in order to prevent the target disk from being disconnected again due to insufficient power supply, the present embodiment can also control the data writing speed. In the process of copying and writing data from the source disk to the target disk, the data writing speed is calculated. The data writing speed can be calculated by counting the total amount of data written in a preset time period. The preset speed reduction rule is set in advance. The preset speed reduction rule can be flexibly adjusted according to the actual situation, such as reducing by 5%, 10%, and 20%, that is, limiting the data writing speed to 95%, 90%, and 80% of the speed before reopening. The data writing speed before the disconnection is reduced by the preset speed reduction rule to obtain the data writing speed limit value; the data read from the source disk is written to the target disk according to a speed less than or equal to the data writing speed limit value. For example, the amount of data written in one second is limited. For example, the upper limit of one second is to write 1MB, which takes 500 milliseconds, and the remaining 500 milliseconds use the function Sleep 500 milliseconds.
[0063] As can be seen from the above, this embodiment reduces the write speed of the target disk after reset, which can reduce power consumption, effectively prevent the target disk from being disconnected again due to unstable power supply, and effectively improve the efficiency of disk restoration and disk cloning.
[0064] In order to make the technical solution of the present invention more clear to those skilled in the art, the present invention also provides an exemplary implementation method. This embodiment takes the source disk as the C drive, the target disk as the USB device, and the execution task as the disk cloning task as an example to explain the process of cloning the C drive to the USB device. Figure 2 , which may include the following:
[0065] The total size of the C drive is 500GB. 500GB can be divided into 1MB data blocks, and the total number of data blocks is 500GB / 1MB. Open the USB device and obtain the disk signature and disk size of the USB device. Read the first data block of the C drive to start cloning, that is, read the data from the C drive and write it to the USB device. During the cloning process, calculate the speed of writing the USB disk. For example, if it takes 10 milliseconds to write a 1MB data block, the data writing speed is 1MB / 10 milliseconds (100 MB / second). Calculate the checksum of the written data and generate a data block information list. Each element in the list contains the data block checksum and data block index value. If the write fails when cloning to the 10,000th data block. Wait for the USB reconnection signal, reopen the disk after the disk is reconnected, obtain the disk signature and disk size of the newly opened disk, and compare the disk information obtained at the beginning to ensure that it is the same disk. Read disk data from the 10,000th data block forward. After each data block is read, calculate the data checksum and compare it with the checksum generated during cloning. If the checksum is inconsistent, the current data block has not been written successfully. Then read the previous data block from the USB device and compare the checksum. If the checksum is consistent, it indicates that the data block has been written successfully. Continue cloning from the data block position where the data checksum is consistent, and reduce the data writing speed to 90% of the data writing speed before the disconnection. When the speed drops to 50% of the maximum speed, no speed reduction is performed and the current writing speed is maintained. Complete the cloning of the remaining data blocks. If the USB device disconnects again, continue to execute in the above manner until the disk cloning task is completed.
[0066] It should be noted that there is no strict order of execution between the steps in this application. As long as they comply with the logical order, these steps can be executed simultaneously or in a certain preset order. Figure 1-Figure 2 This is just a schematic and does not mean that this is the only execution order.
[0067] The present application also provides a corresponding device for the disk data replication method, which further makes the method more practical. Among them, the device can be described from the perspective of functional modules and hardware. The disk data replication device provided by the present application is introduced below. The device is used to implement the disk data replication method provided by the present application. In this embodiment, the disk data replication device may include or be divided into one or more program modules, and the one or more program modules are stored in a storage medium and executed by one or more processors to complete the disk data replication method disclosed in the first embodiment. The program module referred to in the present application refers to a series of computer program instruction segments that can complete specific functions, which is more suitable for describing the execution process of the disk data replication device in the storage medium than the program itself. The following description will specifically introduce the functions of each program module of this embodiment. The disk data replication device described below and the disk data replication method described above can be referred to in correspondence with each other.
[0068] From the perspective of functional modules, see Figure 3 , Figure 3 This is a structural diagram of a disk data replication device provided by the present application in a specific implementation manner. The device may include:
[0069] The disk identification module 301 is used to identify whether the new disk is the target disk when it is detected that the target disk is offline and there is a new disk during the process of copying and writing data from the source disk to the target disk.
[0070] The write position positioning module 302 is used to determine the target position of the data that was not successfully written if the new disk is the target disk.
[0071] The data replication module 303 is used to use the target position as the starting position for reading data from the source disk, and write the data read from the source disk to the target disk.
[0072] Optionally, in some implementations of this embodiment, the disk identification module 301 may be further used to: obtain disk parameters of the target disk and the new disk; if the disk parameters of the target disk and the new disk are completely consistent, the new disk is reset as the target disk.
[0073] As an exemplary implementation method of the above embodiment, the above disk identification module 301 can be further used to: obtain the device name, disk partition layout, disk space capacity and disk signature of the target disk and the new disk respectively; when the device name, disk partition layout, disk space capacity and disk signature of the new disk respectively correspond to the device name, disk partition layout, disk space capacity and disk signature of the target disk, the new disk is the target disk.
[0074] Optionally, in some other implementations of the present embodiment, the above-mentioned device may further include a data processing module, which is used to: divide the data to be copied on the source disk into multiple data blocks; read the corresponding data blocks from the source disk in sequence according to the data block positions and write them to the target disk, and each time a data block is written successfully, calculate the checksum of the written data block as a data integrity check value, and store the data integrity check value.
[0075] As an exemplary implementation method of the above embodiment, the above write position positioning module 302 can be further used for: when the writing of the target data block fails, the position of the target data block is used as the starting position of the integrity check, and each data block to be checked in the target disk is read forward in sequence; each time a data block to be checked is read, the checksum information of the current data block to be checked is calculated, and if the checksum information is the same as the data integrity check value corresponding to the current data block to be checked, the position of the next data block adjacent to the current data block to be checked is the target position.
[0076] Optionally, in some implementations of the present embodiment, the above-mentioned data replication module 303 can be further used for: calculating the data writing speed during the process of copying and writing data from the source disk to the target disk; adjusting the data writing speed according to a preset speed reduction rule to obtain a data writing speed limit value; and writing the data read from the source disk to the target disk at a speed less than or equal to the data writing speed limit value.
[0077] The functions of the functional modules of the disk data replication device described in the present application can be specifically implemented according to the method in the above method embodiment. The specific implementation process can refer to the relevant description of the above method embodiment, which will not be repeated here.
[0078] As can be seen from the above, this embodiment can achieve efficient and accurate copying of disk data
[0079] The disk data copying device mentioned above is described from the perspective of functional modules. Furthermore, the present application also provides an electronic device, which is described from the perspective of hardware. Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application in one implementation manner. Figure 4 As shown, the electronic device includes a memory 40 for storing a computer program; and a processor 41 for implementing the steps of the disk data copying method mentioned in any of the above embodiments when executing the computer program.
[0080] Among them, the processor 41 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the processor 41 may also be a controller, a microcontroller, a microprocessor or other data processing chip. The processor 41 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 41 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 41 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 41 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0081] The memory 40 may include one or more computer-readable storage media, which may be non-transitory. The memory 40 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the memory 40 may be an internal storage unit of an electronic device, such as a hard disk of a server. In other embodiments, the memory 40 may also be an external storage device of an electronic device, such as a plug-in hard disk equipped on a server, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. Further, the memory 40 may also include both an internal storage unit of an electronic device and an external storage device. The memory 40 may not only be used to store application software and various types of data installed in the electronic device, such as: the code of the program in the process of executing the disk data copying method, etc., but also be used to temporarily store data that has been output or is to be output. In this embodiment, the memory 40 is at least used to store the following computer program 401, wherein, after the computer program is loaded and executed by the processor 41, the relevant steps of the disk data copying method disclosed in any of the aforementioned embodiments can be implemented. In addition, the resources stored in the memory 40 may also include an operating system 402 and data 403, and the storage method may be temporary storage or permanent storage. The operating system 402 may include Windows, Unix, Linux, etc. The data 403 may include but is not limited to data corresponding to the disk data copy result, etc.
[0082] In some embodiments, the electronic device may further include a display screen 42, an input / output interface 43, a communication interface 44 or a network interface, a power supply 45 and a communication bus 46. Among them, the display screen 42 and the input / output interface 43 such as a keyboard belong to the user interface, and the optional user interface may also include a standard wired interface, a wireless interface, etc. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface. The communication interface 44 may optionally include a wired interface and / or a wireless interface, such as a WI-FI interface, a Bluetooth interface, etc., which is usually used to establish a communication connection between the electronic device and other electronic devices. The communication bus 46 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0083] Those skilled in the art will understand that Figure 4 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than those shown in the figure, for example, it may also include a sensor 47 for realizing various functions.
[0084] It is understandable that if the disk data copying method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the relevant technology 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 medium to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes but is not limited to: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), magnetic memory, removable disk, CD-ROM, magnetic disk or optical disk, etc. Various media that can store program codes. Based on this, the present invention also provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of disk data copying described in any of the above embodiments are performed.
[0085] It is understandable that if the disk data replication method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, the computer software product does not need to be stored in a physical storage medium. For example, it can be directly transmitted to a computer or other device with information processing capabilities through a wired network or a wireless network to perform all or part of the steps of the methods of various embodiments of the present invention. Based on this understanding, the technical solution of the present invention, or the part that contributes to the relevant technology, or all or part of the technical solution can be embodied in the form of a software product. Based on this, the present invention also provides a computer program product, which stores a computer program. When the computer program is executed by a processor, the steps of disk data replication described in any of the above embodiments are performed.
[0086] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the hardware disclosed in the embodiments, including devices and electronic devices, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.
[0087] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may 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.
[0088] The above is a detailed introduction to a disk data replication method, device, electronic device, non-volatile storage medium and computer program product provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that based on the embodiments in the present application, for ordinary technicians in this technical field, all other embodiments obtained without creative work are within the scope of protection of the present application. Without departing from the principles of the present application, the present application can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the present application.
Claims
1. A disk data replication method, characterized in that: include: During the process of copying and writing data from the source disk to the target disk, when it is detected that the target disk is offline and a new disk exists, identifying whether the new disk is the target disk; If the new disk is the target disk, determining the target location where the data was not successfully written; The target position is used as the starting position for reading data from the source disk, and the data read from the source disk is written to the target disk.
2. The disk data copying method according to claim 1, characterized in that: The step of identifying whether the new disk is the target disk comprises: Obtaining disk parameters of the target disk and the new disk; If the disk parameters of the target disk are completely consistent with the disk parameters of the new disk, the new disk is reset for the target disk.
3. The disk data duplication method according to claim 2, characterized in that: The step of identifying whether the new disk is the target disk comprises: Respectively obtain the device name, disk partition layout, disk space capacity and disk signature of the target disk and the new disk; When the device name, disk partition layout, disk space capacity and disk signature of the new disk correspond to the device name, disk partition layout, disk space capacity and disk signature of the target disk respectively and are all the same, the new disk is the target disk.
4. The disk data duplication method according to claim 1, characterized in that: The process of copying the source disk data to the target disk includes: Dividing the data to be copied on the source disk into multiple data blocks; Corresponding data blocks are read from the source disk in sequence according to the data block positions and written to the target disk. Whenever a data block is written successfully, a checksum of the written data block is calculated as a data integrity check value, and the data integrity check value is stored.
5. The disk data duplication method according to claim 4, characterized in that: The determining of the target location of the data that was not successfully written comprises: When the writing of the target data block fails, the location of the target data block is used as the starting location of the integrity check, and each data block to be checked in the target disk is read forward in sequence; Whenever a data block to be checked is read, the checksum information of the current data block to be checked is calculated. If the checksum information is the same as the data integrity check value corresponding to the current data block to be checked, the next data block position adjacent to the current data block to be checked is the target position.
6. The disk data copying method according to any one of claims 1 to 5, characterized in that: The step of writing the data read from the source disk to the target disk comprises: Calculate the data writing speed during the process of copying data from the source disk to the target disk; Adjust the data writing speed according to a preset speed reduction rule to obtain a data writing speed limit value; The data read from the source disk is written to the target disk at a speed less than or equal to the data writing speed limit value.
7. A disk data duplication device, characterized in that: include: A disk identification module is used to identify whether the new disk is the target disk when it is detected that the target disk is offline and a new disk exists during the process of copying and writing data from the source disk to the target disk; A write position positioning module, used for determining a target position where data has not been successfully written if the new disk is the target disk; The data replication module is used to use the target position as the starting position for reading data from the source disk, and write the data read from the source disk to the target disk.
8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the processor is used to implement the steps of the disk data copying method according to any one of claims 1 to 6 when executing the computer program stored in the memory.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the disk data copying method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the disk data copying method according to any one of claims 1 to 6 are implemented.
