Hard disk data copying method, device and equipment and storage medium
By dividing the DDR cache blocks and adopting the asynchronous replication mode, the problem of memory resource waste in small-scale data scenarios is solved, efficient data copying and resource management are achieved, and the speed and flexibility of data distribution are improved.
Patent Information
- Application Number
- CN202510597043.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-09-16
AI Technical Summary
Existing technologies lack parallel writing mechanisms and dynamic resource management capabilities in small-scale data scenarios, resulting in the inability to reuse memory resources and repeated loading of the same data, causing a waste of time and hardware resources and reducing the efficiency and flexibility of concurrent operations on multiple target disks.
By parsing data copy instructions and configuration file parameters to determine the data range, the DDR cache is divided into cache blocks of fixed size. Using asynchronous replication mode, data is loaded into cache blocks in the order of the source disk's physical addresses and written to the target disk. Combined with read and write flag bit management, memory resource utilization is optimized.
It significantly improves data distribution speed and resource utilization efficiency, simplifies operational processes, reduces repeated loading and waiting time, and provides a faster and more flexible data copy solution.
Smart Images

Figure CN120653192A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of hard disk data processing, and in particular to a hard disk data copying method, apparatus, device and storage medium. Background Art
[0002] In data backup and distribution scenarios, when the same data needs to be quickly copied to multiple target devices, how to efficiently utilize memory resources and simplify the operation process becomes a key issue.
[0003] However, existing technologies still have significant bottlenecks in such scenarios: traditional methods usually adopt a disk-by-disk sequential operation mode, that is, first completely copy the data to a target device, and then repeat the same process to process the next device. Even in small-scale data scenarios (such as documents, pictures, etc.), due to the lack of parallel write mechanisms and dynamic resource management capabilities, the system still needs to execute the "load-write" process separately for each target device, resulting in the inability to reuse memory resources. Repeated loading of the same data causes a waste of time and hardware resources. In addition, if a target device interrupts writing due to response delays or temporary plugging and unplugging, the loaded data cannot be quickly switched to other devices and needs to wait or be reloaded, further reducing the flexibility and efficiency of multi-device copying.
[0004] In summary, this inefficient resource utilization model severely limits the concurrent operation performance of multiple target disks in scenarios with sufficient memory, and cannot meet the needs of fast copying. Summary of the Invention
[0005] In order to overcome the shortcomings of the existing technology, the present application provides a hard disk data copy method, device, equipment and storage medium to adapt to the data copy needs in small-scale data scenarios, thereby achieving the beneficial effect of significantly improving data distribution speed and resource utilization efficiency.
[0006] The technical solution adopted by this application to solve its technical problems is:
[0007] In a first aspect, the present application provides a hard disk data copying method, the method comprising:
[0008] In response to the data copy instruction, determining a data range to be copied according to the configuration file parameters to determine the data to be copied;
[0009] Dividing the DDR cache into a plurality of cache blocks of fixed sizes based on a preset cache block capacity parameter, and dividing the data to be copied into a plurality of data units according to the cache block capacity;
[0010] Comparing the total amount of the to-be-copied data with a preset DDR cache capacity threshold, and triggering an asynchronous replication mode if the amount does not exceed the threshold;
[0011] In asynchronous replication mode, the segmented data units are loaded into the corresponding cache blocks in sequence according to the physical address order of the source disk. In response to the completion of loading of each cache block, the cached data in the corresponding cache block is written to the corresponding position of the target disk until the full data replication is completed.
[0012] Optionally, the configuration file parameters include a whole disk copy instruction and a partial copy instruction; and in response to the data copy instruction, determining the data range to be copied according to the configuration file parameters to determine the data to be copied includes:
[0013] If the configuration file parameter indicates a whole disk copy instruction, determining that the data to be copied is all the data on the source disk;
[0014] Otherwise, the partition information of the source disk is parsed, and a bitmap table is read according to the file system corresponding to the partition information to generate an information set including the location and size of the data to be copied, and the data to be copied is determined based on the information set.
[0015] Optionally, if the configuration file parameter indicates a partial copy indication;
[0016] The steps of sequentially loading the divided data units into corresponding cache blocks in the order of the physical addresses of the source disk, and writing the cached data in the corresponding cache block to the corresponding location of the target disk in response to the completion of loading of each cache block until the full data copy is completed include:
[0017] Based on the bitmap table parsing results of the source disk, record the source disk starting physical address corresponding to each cache block;
[0018] Scan the cache blocks in sequence according to the recorded source disk physical address order, and when it is detected that the read / write flag is in the unwritten state, position the magnetic head to the corresponding physical address position of the target disk and perform the corresponding data unit write operation;
[0019] Each time a cache block is written, the corresponding read / write flag is updated to the written state, and the cycle is executed until the read / write flags of all cache blocks are in the written state.
[0020] Optionally, if the configuration file parameter indicates a whole disk copy instruction;
[0021] The steps of sequentially loading the divided data units into corresponding cache blocks in the order of the physical addresses of the source disk, and writing the cached data in the corresponding cache block to the corresponding location of the target disk in response to the completion of loading of each cache block until the full data copy is completed include:
[0022] Scan the cache blocks in sequence according to the physical address order of the source disk, and when a cache block with a read / write flag indicating an unwritten state is detected, write the corresponding cache data unit to the corresponding position of the target disk;
[0023] Each time a data write operation on a cache block is completed, the corresponding read / write flag is updated to the written state, and the cycle is executed until the read / write flags of all cache blocks are in the written state.
[0024] Optionally, after the step of comparing the total amount of the to-be-copied data with a preset DDR cache capacity threshold, the method further includes:
[0025] In response to the instruction to read the corresponding cache block for each data unit, scan the read / write flag of the corresponding cache block; otherwise, wait for the corresponding cache block to complete writing the corresponding hard disk data and then update the read / write flag to the overwriteable state;
[0026] If the read / write flag is in an overwriteable state, the current data unit is read into the corresponding cache block, and in response to the completion of loading of the currently read cache block, the currently read data unit is written to the corresponding position of the target disk, and the read / write flag is reset to an overwriteable state after the space written into the cache block is released;
[0027] In response to the completion of reading the data unit of the cache block at the end of the sequence, the cache block at the beginning of the sequence is used as the next cache block target to be read, and the process is executed in a loop until the full data copy is completed.
[0028] Optionally, if the configuration file parameter indicates a whole disk copy instruction;
[0029] The step of scanning the read / write flag of the corresponding cache block in response to the instruction to read the corresponding cache block of each data unit comprises:
[0030] Continuously read data units into cache blocks in the order of the source disk physical addresses, and set the read / write flag of the current cache block to the loaded state;
[0031] In response to the completion of data loading in the cache block, the data unit is written into the corresponding position of the target disk in the order of physical addresses. After writing is completed, the cache block space is released and the read-write flag is updated to an overwriteable state.
[0032] Optionally, if the configuration file parameter indicates a partial copy indication;
[0033] The step of scanning the read / write flag of the corresponding cache block in response to the instruction to read the corresponding cache block of each data unit comprises:
[0034] Based on the parsing result of the bitmap table, the data units are read into the cache block in the order of the physical addresses of the data to be copied, and the read / write flag of the current cache block is set to the loaded state;
[0035] In response to the completion of data loading in the cache block, the data unit is written into the corresponding position of the target disk in the order of physical addresses. After writing is completed, the cache block space is released and the read-write flag is updated to an overwriteable state.
[0036] In a second aspect, the present application provides a hard disk data copying device, comprising:
[0037] a copy data selection module, configured to determine a data range to be copied based on configuration file parameters in response to a data copy instruction, so as to determine the data to be copied;
[0038] a cache block division module, configured to divide the DDR cache into a plurality of cache blocks of fixed sizes based on a preset cache block capacity parameter, and to divide the to-be-copied data into a plurality of data units according to the cache block capacity;
[0039] a replication mode determination module, configured to compare the total amount of the to-be-copied data with a preset DDR cache capacity threshold, and trigger an asynchronous replication mode if the total amount does not exceed the threshold;
[0040] The asynchronous replication execution module is used to load the segmented data units into the corresponding cache blocks in the order of the source disk physical addresses in the asynchronous replication mode. In response to the completion of loading of each cache block, the cache data in the corresponding cache block is written to the corresponding position of the target disk until the full data replication is completed.
[0041] In a third aspect, the present application provides an electronic device, comprising:
[0042] one or more processors;
[0043] one or more memories;
[0044] and one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, and the one or more computer programs include instructions that, when executed by the one or more processors, cause the electronic device to perform the above method.
[0045] In a fourth aspect, the present application provides a computer-readable storage medium, in which a program or instruction is stored. When the program or instruction is executed, the above method is implemented.
[0046] The beneficial effects of this application are as follows: first, by parsing the data copy instruction and configuration file parameters, the data range and structure to be copied are determined, which provides an accurate basis for subsequent operations. Then, by comparing the total amount of data to be copied with the preset DDR cache capacity threshold, the data can be effectively processed in the buffer storage, avoiding performance bottlenecks caused by excessive data volume.
[0047] In asynchronous replication mode, the DDR cache is divided into multiple cache blocks, which are filled sequentially according to the data's address order on the source disk. This maximizes memory resource utilization and reduces data loading time. After each cache block is loaded, the read data unit is immediately written to the corresponding location on the target disk. This method not only improves data transmission efficiency but also reduces processing delays caused by external factors such as device response delays or temporary plugging and unplugging. This method significantly improves data distribution speed and resource utilization efficiency through cache block management, simplifies operational processes, reduces repeated loading and waiting time, and provides a faster and more flexible solution for processing small-scale data. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 This is a flowchart of a hard disk data copying method provided by an embodiment of the present application;
[0049] Figure 2 This is a virtual structural diagram of the hard disk data copying device provided by this application;
[0050] Figure 3 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] The present application is further described below with reference to the accompanying drawings and examples.
[0052] The following will clearly and completely describe the concept, specific structure and technical effects of this application in combination with the embodiments and drawings, so as to fully understand the purpose, characteristics and effects of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments of this application, other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application. In addition, all the connection / connection relationships involved in the patent do not refer to the direct connection of components, but refer to the formation of a better connection structure by adding or reducing connection accessories according to the specific implementation situation. The various technical features created in this application can be combined interactively without conflicting with each other.
[0053] Reference Figure 1 , Figure 1 This is a flowchart of a hard disk data copy method provided by an embodiment of the present application, which specifically illustrates multiple process steps proposed by this solution in a small-scale data copy scenario. The following is a detailed description:
[0054] In step S1 , in response to a data copy instruction, a data range to be copied is determined according to configuration file parameters to determine the data to be copied.
[0055] Specifically, when the user sends a data copy instruction through multiple control instruction input channels, the data range of the source disk storage data to be copied can be determined based on the configuration file parameters corresponding to the current data copy instruction (such as the copy mode, the number of target devices, etc.). In the embodiment of the present application, the configuration file parameters are divided into two cases: partial copy indication and whole disk copy indication. When the whole disk is copied, the data range covers all physical sectors; when partial copy is performed, the data range is defined by the address set filtered by the bitmap table to ensure accuracy and resource saving.
[0056] In the embodiment of the present application, in response to the data copy instruction, determining the data range to be copied according to the configuration file parameters to determine the data to be copied includes:
[0057] If the configuration file parameter indicates a whole disk copy instruction, it is determined that the data to be copied is all the data on the source disk.
[0058] Specifically, if the configuration is to copy the entire disk, the system directly maps the entire physical address of the source disk (LBA 0 to the maximum sector number), and includes the data of the entire hard disk into the to-be-copied set as the to-be-copied data, and adjusts the subsequent copy steps accordingly according to this instruction. Since it is a whole disk copy, there is no need to record the corresponding physical address of the cache block on the hard disk in subsequent reading steps, and it can be written directly in sequence.
[0059] Otherwise, the partition information of the source disk is parsed, and a bitmap table is read according to the file system corresponding to the partition information to generate an information set including the location and size of the data to be copied, and the data to be copied is determined based on the information set.
[0060] Specifically, if the configuration is partition data replication, it is necessary to parse the partition file system structure of the source disk, read the bitmap table in the partition to locate the valid data blocks (such as user-specified folders or files), and generate a list containing the location and size of the data to be copied, so as to determine the data to be copied later.
[0061] In step S2, the DDR cache is divided into a plurality of cache blocks of fixed size based on a preset cache block capacity parameter, and the data to be copied is divided into a plurality of data units according to the cache block capacity.
[0062] Specifically, efficient resource management of asynchronous replication is achieved through structured cache partitioning and data block strategies. In asynchronous replication mode, the system divides the DDR cache into multiple fixed-size cache blocks based on preset cache block capacity parameters (for example, 64MB / block). The capacity of each block is strictly aligned with the preset value to ensure the standardization and predictability of memory resource allocation. At the same time, the data to be copied is divided into multiple logically continuous data units according to the same block capacity parameters (for example, source disk LBA1000-1064 corresponds to data unit 1, and LBA 1065-1128 corresponds to data unit 2). Each data unit is mapped one-to-one with the cache block, and its corresponding source disk physical address range is recorded to provide a precise positioning basis for subsequent write operations.
[0063] In addition, it should be noted that the core purpose of cache block division and data segmentation is to reduce the complexity of hardware control through standardized memory management. For example, when the cache block capacity is set to 64MB, 1TB of data will be divided into 16384 independent units, each of which is loaded into an independent cache block and associated with the start / end physical address (such as block 1 corresponds to LBA 0-131072). This design allows the system to schedule data loading and writing tasks through unified rules, avoiding addressing confusion or resource contention caused by data fragmentation. In asynchronous replication mode, after all data units complete cache filling in the loading phase, the system triggers write operations in batches in the order of physical addresses.
[0064] More specifically, in one embodiment, the user needs to copy an SSD source disk (capacity 300GB) that stores video materials to three target disks. The system presets the cache block capacity to 64MB, and the total DDR cache capacity to 512GB (the threshold is set to 400GB). Since 300GB does not exceed the threshold, the system triggers the asynchronous copy mode, divides the DDR cache into 4800 64MB cache blocks, and loads the data units in the source disk LBA order (such as block 1 corresponds to LBA 0-131072). After all data is loaded, the system starts three write threads in parallel and writes the data to the target disk in the same LBA order. Each time a cache block is written, the corresponding flag is updated to "written". If a target disk is paused due to special reasons such as network delay, the system only needs to retry the unfinished cache blocks later.
[0065] In step S3, the total amount of the data to be copied is compared with a preset DDR cache capacity threshold. If the total amount does not exceed the threshold, the asynchronous copy mode is triggered.
[0066] Specifically, after the data to be copied is determined in the above steps, the total amount of the data to be copied is compared with the maximum DDR cache capacity to determine whether the cache capacity can directly accommodate all the data to be copied, thereby determining whether the asynchronous replication mode can be executed. If the total amount of the data to be copied does not exceed the threshold, the asynchronous replication mode is entered; otherwise, the synchronous replication mode is entered. In the synchronous replication mode, a read-while-write copy mode is adopted.
[0067] For example, the preset value can be a safety threshold for system memory capacity (e.g., 80% of the total capacity) to prevent memory overflow. For example, if the total DDR capacity is 320GB, the threshold can be set to 256GB. Assuming that the data to be copied is 200GB, the block preloading mechanism is triggered. The core idea is to load the data into the cache as a whole before writing it in batches, avoiding the resource contention problem caused by simultaneous read and write in synchronous replication mode.
[0068] Specifically, when entering the synchronous replication mode, the steps involved in the embodiment of the present application include: after the step of comparing the total amount of the to-be-copied data with the preset DDR cache capacity threshold, the method further includes:
[0069] If the total amount of data to be copied exceeds the preset DDR cache capacity threshold, a synchronous replication mode is triggered;
[0070] In synchronous replication mode, in response to the instruction to read the corresponding cache block for each data unit, the read / write flag of the corresponding cache block is scanned; otherwise, the read / write flag is updated to the overwriteable state after the corresponding cache block completes the writing of the corresponding hard disk data;
[0071] If the read / write flag is in an overwriteable state, the current data unit is read into the corresponding cache block, and in response to the completion of loading of the currently read cache block, the currently read data unit is written to the corresponding position of the target disk, and the read / write flag is reset to an overwriteable state after the space written into the cache block is released;
[0072] In response to the completion of reading the data unit of the cache block at the end of the sequence, the cache block at the beginning of the sequence is used as the next cache block target to be read, and the process is executed in a loop until the full data copy is completed.
[0073] Specifically, the synchronous replication mode adapts to the memory resource limitations in large data volume scenarios through the read-write thread loading and writing mechanism. When the total amount of data exceeds the preset DDR cache capacity threshold, the system divides the data into multiple cache blocks according to the block size, loads them into the cache in sequence and writes them to the target disk in real time. After the write is completed, the cache space is immediately released for reuse. After the write operation of each cache block is completed (that is, after all the data units in the cache block have been written to the corresponding positions of the target disk), the system updates the read-write flag of the cache area to "overwrite state", and the source disk read thread determines the read-write flag of the next cache block in the DDR cache. If it is overwritten, it is read in, otherwise it waits. When the read thread pointer reaches the last position of the DDR cache block, the next read-in position pointer points to the initial position of the DDR cache block, that is, a new round of overwriting and read-write operations is performed, and the cycle is executed until the full data copy is completed.
[0074] For example, in one feasible implementation, a user needs to copy data from a 4TB SSD source drive to a target drive, and the DDR cache threshold is 512GB. After the system triggers synchronous replication mode, after each data block is written, the cache space is released and marked as overwritable, ready for loading by the read thread. Under this mechanism, synchronous replication mode achieves efficient and stable copying even in large data volume scenarios through resource reuse and closed-loop process design.
[0075] Furthermore, in the synchronous copy mode, the following steps are performed respectively according to the two situations of whole disk data copy and partial data copy. In the embodiment of the present application, if the configuration file parameter indicates a whole disk copy instruction;
[0076] The step of scanning the read / write flag of the corresponding cache block in response to the instruction to read the corresponding cache block of each data unit comprises:
[0077] Continuously read data units into cache blocks in the order of the source disk physical addresses, and set the read / write flag of the current cache block to the loaded state;
[0078] In response to the completion of data loading in the cache block, the data unit is written into the corresponding position of the target disk in the order of physical addresses. After writing is completed, the cache block space is released and the read-write flag is updated to an overwriteable state.
[0079] Specifically, when copying the entire disk, the system continuously reads data from the starting address of the source disk (LBA 0) to the DDR cache. The amount of data loaded in the first batch is equal to the cache capacity (e.g., 256GB). When loading, the system marks the read and write flags of the current cache area as "loaded" (flag bit is 1), prohibiting other operations from overwriting data. The system continuously reads data from the starting address of the source disk (LBA 0) to the DDR cache. The first data unit is equal to the cache capacity (e.g., 256GB). When loading, the system marks the read and write flags of the current cache area as "loaded" (flag bit is 1), prohibiting other operations from overwriting data. After each block of data is written, the system marks the read and write flags of the current cache area as "written" (flag bit is 0). The source disk read thread determines the read and write flag of the next block in the DDR cache. If it is overwritten, it reads it in; otherwise, it waits. When the read thread pointer reaches the last position of the DDR cache block, the next read position pointer points to the initial position of the DDR cache block. The above operation is repeated until the entire disk data copy is completed.
[0080] More specifically, if the size of the DDR memory cache is exceeded, the DDR memory pointer will point to the beginning of the DDR cache. This dynamic pointer reset and cache space reuse resolves the operational bottleneck of large data volumes exceeding cache capacity in synchronous replication mode. When data loading exceeds cache capacity, the system immediately resets the DDR pointer to the starting address, forcing subsequent data to be reloaded from the cache header while ensuring that the loaded data is written and marked as overwritable. This mechanism not only avoids the risk of memory overflow, but also enables efficient processing of large amounts of data by reusing cache space in batches.
[0081] In addition, if the configuration file parameter indicates a partial copy instruction;
[0082] The step of scanning the read / write flag of the corresponding cache block in response to the instruction to read the corresponding cache block of each data unit comprises:
[0083] Based on the parsing result of the bitmap table, the data units are read into the cache block in the order of the physical addresses of the data to be copied, and the read / write flag of the current cache block is set to the loaded state;
[0084] In response to the completion of data loading in the cache block, the data unit is written into the corresponding position of the target disk in the order of physical addresses. After writing is completed, the cache block space is released and the read-write flag is updated to an overwriteable state.
[0085] Specifically, when performing a partial data copy operation, the system can quickly locate all physical storage units containing valid data by parsing the bitmap table in the source disk partition, and automatically generate an information set containing key parameters such as the starting address of the data to be copied and the length of the continuous data block. This physical space management mechanism based on bitmap marking enables the data copy process to accurately skip unused storage areas, significantly improving the efficiency of copying valid data, while ensuring that the physical address of the target disk maintains a strict correspondence with the source disk, providing underlying protection for data integrity and consistency. Compared with the whole disk copy in the synchronous copy mode in the above steps, the partial copy instruction needs to save the physical address of the data corresponding to the memory block on the SSD when reading, and reposition the head according to the address and then write the data when writing. The remaining steps are similar to the above content and will not be repeated here.
[0086] In step S4, in the asynchronous replication mode, the divided data units are loaded into the corresponding cache blocks in sequence according to the physical address order of the source disk. In response to the completion of loading of each cache block, the cache data in the corresponding cache block is written to the corresponding position of the target disk until the full data replication is completed.
[0087] Specifically, the asynchronous replication mode is divided into two cases: full disk copy and partial copy. If the configuration file parameter indicates a partial copy instruction; the steps of loading the divided data units into corresponding cache blocks in the order of the physical addresses of the source disk, and writing the cached data in the corresponding cache block to the corresponding position of the target disk in response to the completion of loading each cache block until the full data replication is completed include:
[0088] Based on the bitmap table parsing results of the source disk, record the source disk starting physical address corresponding to each cache block;
[0089] Scan the cache blocks in sequence according to the recorded source disk physical address order, and when it is detected that the read / write flag is in the unwritten state, position the magnetic head to the corresponding physical address position of the target disk and perform the corresponding data unit write operation;
[0090] Each time a cache block is written, the corresponding read / write flag is updated to the written state, and the cycle is executed until the read / write flags of all cache blocks are in the written state.
[0091] The bitmap table is a binary mapping table in the file system that records the usage status of data blocks (for example, 1 indicates that the data block is occupied, and 0 indicates that it is free). The system parses the table to filter out valid data blocks to be copied (such as the data blocks corresponding to the files specified by the user) and extracts their physical address ranges (for example, LBA 1000-2000); the address range record includes the start of each cache block associated with the source disk (for example, cache block 1 corresponds to LBA 1000), ensuring that the target disk can be accurately located according to the original address of the source disk to avoid data misalignment;
[0092] Cache block status detection involves scanning cache blocks sequentially according to the recorded physical address order, and only performing write operations on blocks whose read / write flag is "unwritten" (read / write flag is 0). For example, if the flag of cache block 1 is 0, the write process for that block is triggered. Positioning the head means that when writing, the system positions the target disk's head to the same address range (or mapped logical address) based on the recorded source disk physical address (such as LBA 1000-1064), ensuring that the data is completely copied according to the source disk layout.
[0093] For example, in one feasible implementation, a user needs to copy a "design drawings" folder (80GB of data) stored on an SSD source disk to a target disk. In this step, the data block corresponding to the folder (LBA 5000-60000) is located using the bitmap table, and the DDR cache is divided into 128 640MB cache blocks. Each cache block records its corresponding source disk address (e.g., block 1 corresponds to LBA 5000-5640). The system scans the cache blocks sequentially. When it detects that the block 1 identification bit is 0, the drive head is positioned to the target disk LBA 5000 position and writes the data. After the write is complete, the head is marked as position 1 and jumps to block 2 (LBA 5641-6280). In addition, even if the target disk loses power while writing block 3, after power is restored, the system rescans and retries only block 3, and the operation is not repeated for the remaining written blocks (identifier bits are 1). Finally, this step is repeated until all cache blocks are completely written to the target disk in the order of the source disk physical addresses, completing the partial copy instruction in asynchronous copy mode.
[0094] Furthermore, after the data copy is completed, the SSD hard drive that has completed the copy is unplugged, and all the read and write flags of the corresponding DDR cache will be set to 0. When a new SSD hard drive is inserted, you can choose to enter the next round of copying.
[0095] On the other hand, when entering the asynchronous replication mode, assuming that the entire disk replication is determined in the above steps, the steps of loading the divided data units into corresponding cache blocks in the order of the physical addresses of the source disk, and writing the cached data in the corresponding cache block to the corresponding location of the target disk in response to the completion of loading each cache block until the full data replication is completed include:
[0096] Scan the cache blocks in sequence according to the physical address order of the source disk, and when a cache block with a read / write flag indicating an unwritten state is detected, write the corresponding cache data unit to the corresponding position of the target disk;
[0097] Each time a data write operation on a cache block is completed, the corresponding read / write flag is updated to the written state, and the cycle is executed until the read / write flags of all cache blocks are in the written state.
[0098] Specifically, the core difference between full-disk copying and partition copying lies in the way the data range is determined. Full-disk copying directly maps the entire physical address of the source disk (LBA 0 to the maximum sector number), and data blocks are loaded continuously and written to the target disk in the same order, without the need for additional parsing of the file system structure. Partition copying, on the other hand, requires parsing the source disk's bitmap table (such as the $Bitmap file of NTFS), filtering out valid data blocks, and then generating a non-contiguous address list. When writing, it is necessary to dynamically position the head according to the recorded physical address or adjust the NAND flash memory write order to ensure data integrity and consistency with the target disk layout.
[0099] For example, in one feasible implementation, a user needs to quickly copy a 500GB SSD source disk storing medical imaging data to five target disks. After parsing the configuration file parameters, the system determines that the entire disk copy mode is in effect and compares the total data volume with the DDR cache capacity threshold (512GB), triggering the asynchronous copy process. The system divides the DDR cache into 8192 64MB cache blocks, continuously loading data in the source disk LBA order. After loading is complete, five write threads are started in parallel, each of which writes data to the corresponding target disk in the same LBA order, updating its flag after each cache block is written. If a target disk's write is suspended due to interface latency, the system will continue to attempt to write to the target disk repeatedly. If the system's specified settings (number of times and time) are exceeded, a target port will report an error, and the target disk on that port will no longer work in this round. At the same time, the device flag for this round of copying is set to indicate that the port number no longer exists. Finally, when all flag bits are 1, the entire disk data copy is complete.
[0100] Reference Figure 2 , Figure 2 This is a virtual structural diagram of a hard disk data copying device provided by the present application. In a second aspect, the present application provides a hard disk data copying device, comprising:
[0101] The copy data selection module 100 is configured to determine the data range to be copied based on the configuration file parameters in response to the data copy instruction to determine the data to be copied;
[0102] The cache block module 200 is used to compare the total amount of the to-be-copied data with a preset DDR cache capacity threshold, and trigger an asynchronous replication mode if the amount does not exceed the threshold;
[0103] A replication mode determination module 300 is configured to, in an asynchronous replication mode, divide the DDR cache into a plurality of cache blocks of fixed sizes based on a preset cache block capacity parameter, and divide the to-be-copied data into a plurality of data units according to the cache block capacity;
[0104] The asynchronous replication execution module 400 is used to load the segmented data units into the corresponding cache blocks in sequence according to the physical address order of the source disk in the asynchronous replication mode, and write the cached data in the corresponding cache block to the corresponding position of the target disk in response to the completion of loading of each cache block until the full data replication is completed.
[0105] The hard disk data copying device described in the embodiment of the present application can execute the hard disk data copying method provided in the above embodiment. The hard disk data copying device has the corresponding functional steps and beneficial effects of the hard disk data copying method described in the above embodiment. Please refer to the embodiment of the above hard disk data copying method for details. The embodiment of the present application will not be repeated here.
[0106] The present application also provides an electronic device. Figure 3 , Figure 3 It is a structural diagram of the electronic device provided in the embodiment of the present application, and the electronic device may include a processor and a memory, wherein the processor and the memory may be connected by a bus or otherwise. The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components and other chips, or a combination of the above-mentioned various chips. The memory, as a non-transient computer-readable storage medium, may be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the hard disk data copying method in the embodiment of the present application. The processor executes various functional applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory, i.e., realizing the hard disk data copying method in the above-mentioned method embodiment.
[0107] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. The one or more modules are stored in the memory, and when executed by the processor, the hard disk data copy method in the above method embodiment is executed. The specific details of the above electronic device can be understood by corresponding to the corresponding descriptions and effects in the above method embodiment, and will not be repeated here. Those skilled in the art will understand that all or part of the processes in the above embodiment method can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it may include the processes of the embodiments of the above methods. Among them, the storage medium may be a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the storage medium may also include a combination of the above types of memory.
[0108] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.
[0109] Similarly, it should be understood that in order to streamline the present disclosure and aid understanding of one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present application, various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting an intention that the claimed application requires more features than are expressly recited in each claim. Rather, as reflected in the claims, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Accordingly, the claims that follow the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of the present application.
[0110] It should be noted that the above-mentioned embodiments illustrate rather than limit the invention and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims.
Claims
1. A hard disk data copying method, characterized in that: The method comprises: In response to the data copy instruction, determining a data range to be copied according to the configuration file parameters to determine the data to be copied; Dividing the DDR cache into a plurality of cache blocks of fixed sizes based on a preset cache block capacity parameter, and dividing the data to be copied into a plurality of data units according to the cache block capacity; Comparing the total amount of the to-be-copied data with a preset DDR cache capacity threshold, and triggering an asynchronous replication mode if the amount does not exceed the threshold; In asynchronous replication mode, the segmented data units are loaded into the corresponding cache blocks in sequence according to the physical address order of the source disk. In response to the completion of loading of each cache block, the cached data in the corresponding cache block is written to the corresponding position of the target disk until the full data replication is completed.
2. The hard disk data copying method according to claim 1, characterized in that: The configuration file parameters include a whole disk copy instruction and a partial copy instruction; the response to the data copy instruction determines the data range to be copied according to the configuration file parameters, so that the data to be copied includes: If the configuration file parameter indicates a whole disk copy instruction, determining that the data to be copied is all the data on the source disk; Otherwise, the partition information of the source disk is parsed, and a bitmap table is read according to the file system corresponding to the partition information to generate an information set including the location and size of the data to be copied, and the data to be copied is determined based on the information set.
3. The hard disk data copying method according to claim 2, characterized in that: If the configuration file parameter indicates a partial copy instruction; The steps of sequentially loading the divided data units into corresponding cache blocks in the order of the physical addresses of the source disk, and writing the cached data in the corresponding cache block to the corresponding location of the target disk in response to the completion of loading of each cache block until the full data copy is completed include: Based on the bitmap table analysis results of the source disk, record the source disk starting physical address corresponding to each cache block; Scan the cache blocks in sequence according to the recorded source disk physical address order, and when it is detected that the read / write flag is in the unwritten state, position the magnetic head to the corresponding physical address position of the target disk and perform the corresponding data unit write operation; Each time a cache block is written, the corresponding read / write flag is updated to the written state, and the cycle is executed until the read / write flags of all cache blocks are in the written state.
4. The hard disk data copying method according to claim 2, characterized in that: If the configuration file parameter indicates a whole disk copy instruction; The steps of sequentially loading the divided data units into corresponding cache blocks in the order of the physical addresses of the source disk, and writing the cached data in the corresponding cache block to the corresponding location of the target disk in response to the completion of loading of each cache block until the full data copy is completed include: Scan the cache blocks in sequence according to the physical address order of the source disk, and when a cache block with a read / write flag indicating an unwritten state is detected, write the corresponding cache data unit to the corresponding position of the target disk; Each time a data write operation on a cache block is completed, the corresponding read / write flag is updated to the written state, and the cycle is executed until the read / write flags of all cache blocks are in the written state.
5. The hard disk data copying method according to claim 2, characterized in that: After the step of comparing the total amount of the to-be-copied data with a preset DDR cache capacity threshold, the method further includes: If the total amount of data to be copied exceeds the preset DDR cache capacity threshold, a synchronous replication mode is triggered; In synchronous replication mode, in response to the instruction to read the corresponding cache block for each data unit, the read / write flag of the corresponding cache block is scanned; otherwise, the read / write flag is updated to the overwriteable state after the corresponding cache block completes the writing of the corresponding hard disk data; If the read / write flag is in an overwriteable state, the current data unit is read into the corresponding cache block, and in response to the completion of loading of the currently read cache block, the currently read data unit is written to the corresponding position of the target disk, and the read / write flag is reset to an overwriteable state after the space written into the cache block is released; In response to the completion of reading the data unit of the cache block at the end of the sequence, the cache block at the beginning of the sequence is used as the next cache block target to be read, and the process is executed in a loop until the full data copy is completed.
6. The hard disk data copying method according to claim 5, characterized in that: If the configuration file parameter indicates a whole disk copy instruction; The step of scanning the read / write flag of the corresponding cache block in response to the instruction to read the corresponding cache block of each data unit comprises: Continuously read data units into cache blocks in the order of the source disk physical addresses, and set the read / write flag of the current cache block to the loaded state; In response to the completion of data loading in the cache block, the data unit is written into the corresponding position of the target disk in the order of physical addresses. After writing is completed, the cache block space is released and the read-write flag is updated to an overwriteable state.
7. The hard disk data copying method according to claim 5, characterized in that: If the configuration file parameter indicates a partial copy instruction; The step of scanning the read / write flag of the corresponding cache block in response to the instruction to read the corresponding cache block of each data unit comprises: Based on the parsing result of the bitmap table, read the data units into the cache block in the order of the physical addresses of the data to be copied, and set the read and write flag of the current cache block to the loaded state; In response to the completion of data loading in the cache block, the data unit is written into the corresponding position of the target disk in the order of physical addresses. After writing is completed, the cache block space is released and the read-write flag is updated to an overwriteable state.
8. A hard disk data copying device, characterized in that: include: a copy data selection module, configured to determine a data range to be copied based on configuration file parameters in response to a data copy instruction, so as to determine the data to be copied; a cache block division module, configured to divide the DDR cache into a plurality of cache blocks of fixed sizes based on a preset cache block capacity parameter, and to divide the to-be-copied data into a plurality of data units according to the cache block capacity; a replication mode determination module, configured to compare the total amount of the to-be-copied data with a preset DDR cache capacity threshold, and trigger an asynchronous replication mode if the total amount does not exceed the threshold; The asynchronous replication execution module is used to load the segmented data units into the corresponding cache blocks in the order of the source disk physical addresses in the asynchronous replication mode. In response to the completion of loading of each cache block, the cache data in the corresponding cache block is written to the corresponding position of the target disk until the full data replication is completed.
9. An electronic device, characterized in that: include: one or more processors; one or more memories; and one or more computer programs, wherein the one or more computer programs are stored in the one or more memories, and the one or more computer programs include instructions that, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The storage medium stores a program or instruction, and when the program or instruction is executed, the method according to any one of claims 1 to 7 is implemented.