Method, device and equipment for copying data in SSD (Solid State Disk) and medium
By assembling multiple discontinuous source LBA addresses in the SSD disk and performing one-time data copying, the data inconsistency caused by multiple read and write commands in the prior art is solved, and an efficient and reliable data copying process is achieved, extending the service life of the SSD.
Patent Information
- Application Number
- CN202510248470.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-06-20
AI Technical Summary
The prior art realizes data copying of multiple LBA discontinuous intervals in the SSD disk, which requires multiple read and write commands, resulting in incomplete data copying and inconsistency, affecting system stability and performance.
By confirming the source address and destination address information, we can determine whether there is overlap. If there is no overlap, assemble the multi-segment source LBA address into a source LBA address, read the data and temporarily store it in the cache area, perform a one-time copy operation, and record the data before and after copying to ensure data consistency.
It reduces the number of read and write commands that need to be issued during the data copying process, reduces the possibility of incomplete and inconsistency in data copying, improves the efficiency and reliability of data copying, and extends the service life of SSD.
Smart Images

Figure CN120179575A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular, to a method, apparatus, device, and medium for copying data within an SSD disk. Background Art
[0002] With the rapid development of solid-state drive (SSD) technology, its read and write speeds and data storage density have been continuously improved, making SSD an important device for data storage and transmission. However, in actual applications, SSD needs to use read and write commands to achieve the purpose of internal data copying. To copy data in multiple non-contiguous intervals of LBA (Logical Block Addressing), multiple read and write commands need to be issued. During the process of data migration, backup, or replication, due to various reasons (such as hardware failures, software errors, transmission interruptions, etc.), multiple read and write operations may result in incomplete data copying and inconsistent copied data (there are differences in the data at the SSD source address and the target address), etc., which cannot meet the user's purpose of copying data. Multiple read and write operations will also seriously reduce the stability and performance of the system. Inconsistent copied data may lead to serious consequences such as user data loss, damage, or system crashes, and users have no available means to timely detect and correct the differences during the data copying process. Therefore, how to implement a one-time operation copy function within the SSD and ensure the consistency of data before and after copying has become an urgent technical problem to be solved. Summary of the Invention
[0003] Embodiments of the present invention provide a method, apparatus, device, and medium for copying data within an SSD disk, aiming to solve the problem of data inconsistency caused by multiple read and write operations required to copy data in multiple non-contiguous intervals of LBA in the prior art method.
[0004] In a first aspect, embodiments of the present invention provide a method for copying data within an SSD disk, including:
[0005] Confirm the source address information and destination address information of the copy;
[0006] Wherein, both the source address information and the destination address information are LBA address information, the source address information corresponds to multiple segments of source LBA addresses, and the destination address information corresponds to one segment of destination LBA address;
[0007] According to the source address information and the destination address information, determine whether there is an overlap between the source LBA address and the destination LBA address;
[0008] If there is no overlap between the LBA address and the destination LBA address, assemble multiple segments of source LBA addresses into one segment of source LBA address to obtain an assembled source LBA address;
[0009] Read the data at the assembled source LBA address to obtain the assembled source LBA address data, and record the assembled source LBA address data to obtain the recorded source address data;
[0010] Temporarily store the assembled source LBA address data in the buffer;
[0011] According to the destination address information, copy the assembled source LBA address data to the destination LBA address corresponding to the destination address information to obtain the destination LBA address data;
[0012] Record the destination LBA address data to obtain the recorded destination address data;
[0013] Compare whether the recorded destination address data is consistent with the recorded source address data;
[0014] If the recorded destination address data is not consistent with the recorded source address data, return to execute the step of copying the assembled source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information to obtain the destination LBA address data.
[0015] In a second aspect, an embodiment of the present invention provides a device for copying data within an SSD disk, which is used to execute the method described in the first aspect. The device includes:
[0016] An address confirmation module, configured to confirm the source address information and destination address information of the copy; wherein, both the source address information and the destination address information are LBA address information, the source address information corresponds to multiple segments of source LBA addresses, and the destination address information corresponds to one segment of destination LBA address;
[0017] A first judgment module, configured to judge whether there is an overlap between the LBA address and the destination LBA address according to the source address information and the destination address information;
[0018] An assembly module, configured to assemble multiple segments of source LBA addresses into one segment of source LBA address to obtain the assembled source LBA address if there is no overlap between the LBA address and the destination LBA address;
[0019] A first data recording module, configured to read the data at the assembled source LBA address to obtain the assembled source LBA address data, and record the assembled source LBA address data to obtain the recorded source address data;
[0020] A first buffer module, configured to temporarily store the assembled source LBA address data in the buffer;
[0021] The first data transmission module is configured to copy the assembled source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information, so as to obtain destination LBA address data;
[0022] The second data recording module is configured to record the destination LBA address data to obtain recorded destination address data;
[0023] The first comparison module is configured to compare whether the recorded destination address data is consistent with the recorded source address data;
[0024] The first return and execution module is configured to, if the recorded destination address data is inconsistent with the recorded source address data, return and execute the step of copying the assembled source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information, so as to obtain destination LBA address data.
[0025] In a third aspect, an embodiment of the present invention provides a computer device, which includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus;
[0026] The memory is used to store a computer program;
[0027] The processor is configured to, when executing the program stored on the memory, implement the steps of the method for copying data within an SSD disk described in the first aspect of the claims.
[0028] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for copying data within an SSD disk described in the first aspect are implemented.
[0029] Beneficial effects: The embodiments of the present invention provide a method, device, equipment and medium for copying data within an SSD disk. The method includes: confirming the source address information and destination address information for copying; wherein, both the source address information and the destination address information are LBA address information, the source address information corresponds to multiple segments of source LBA addresses, and the destination address information corresponds to one segment of destination LBA address; according to the source address information and the destination address information, determining whether there is an overlap between the source LBA address and the destination LBA address; if there is no overlap between the LBA address and the destination LBA address, assembling the multiple segments of source LBA addresses into one segment of source LBA address to obtain an assembled source LBA address; reading the data on the assembled source LBA address to obtain assembled source LBA address data, recording the assembled source LBA address data to obtain recorded source address data; temporarily storing the assembled source LBA address data in a buffer area; according to the destination address information, copying the assembled source LBA address data into the destination LBA address corresponding to the destination address information to obtain destination LBA address data; recording the destination LBA address data to obtain recorded destination address data; comparing whether the recorded destination address data is consistent with the recorded source address data; if the recorded destination address data is inconsistent with the recorded source address data, then return to execute the step of copying the assembled source LBA address data into the destination LBA address corresponding to the destination address information to obtain destination LBA address data.
[0030] By assembling the separated source LBA addresses to obtain an assembled source LBA address, when copying data from the assembled source LBA address, only the data of the assembled source LBA address needs to be read to obtain the assembled source LBA address data, avoiding multiple reads of the separated source LBA addresses. When writing data to the destination LBA address, it can also be written once, that is, written in parallel, thereby reducing the number of read and write commands that need to be issued during the data copying process, reducing the possibility of incomplete data copying and inconsistent copied data caused by multiple reads and writes. And by recording the data of the source LBA address before data copying to obtain recorded source address data, after data copying, recording the data of the destination LBA address to obtain recorded destination address data, and judging whether there are problems of data loss or data inconsistency during the copying process by comparing whether the recorded source address data and the recorded destination address data are consistent, and repeating the copying step until the recorded source address data and the recorded destination address data are consistent to ensure that the data of the source LBA address is completely and accurately copied to the destination LBA address, ensuring the consistency before and after data copying. Brief Description of the Drawings
[0031] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.
[0032] Figure 1 It is a flowchart of the method for copying data within an SSD provided by an embodiment of the present invention;
[0033] Figure 2 It is another flowchart of the method for copying data within an SSD provided by an embodiment of the present invention;
[0034] Figure 3 It is yet another flowchart of the method for copying data within an SSD provided by an embodiment of the present invention;
[0035] Figure 4 It is yet another flowchart of the method for copying data within an SSD provided by an embodiment of the present invention;
[0036] Figure 5 It is a schematic block diagram of the device for copying data within an SSD provided by an embodiment of the present invention;
[0037] Figure 6 It is a schematic block diagram of the computer device provided by an embodiment of the present invention. Detailed Embodiments
[0038] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention.
[0039] It should be understood that when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0040] It should also be understood that the terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms.
[0041] It should be further understood that the term "and / or" used in the specification and appended claims of the present invention refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0042] It should also be noted that, unless otherwise clearly specified and defined, terms such as "installation", "connection", "connection", "fixation", "setting" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or integrated; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the communication inside two components or the interaction relationship between two components. When an element is referred to as "on" or "under" another element, the element can be "directly" or "indirectly" located above the other element, or there may also be one or more intermediate elements. The terms "first", "second", "third", etc. are only for the convenience of describing the present technical solution, and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first", "second", "third", etc. may explicitly or implicitly include one or more of such features. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0043] Please refer to Figure 1 , an embodiment of the present invention provides a method for copying data within an SSD disk, mainly used for copying data within the SSD disk, that is, copying data from a certain address in the SSD disk to another address in the SSD disk, and the data copy includes backup and migration.
[0044] As Figure 1 shown, in some embodiments, the method for copying data within an SSD disk includes steps S100 to S190.
[0045] S100. Receive a copy instruction input by the user.
[0046] The SSD disk can be specifically assembled in a computer device, and the user can perform an operation of copying data to the computer device to input a copy instruction. The copy instruction includes the target location and source location of the data copy, and the target location and source location correspond to the source address and destination address in the SSD disk.
[0047] S110. Confirm the source address information and destination address information of the copy.
[0048] Among them, the source address information and the destination address information are both LBA address information, the source address information corresponds to multiple segments of source LBA addresses, and the destination address information corresponds to one segment of destination LBA address.
[0049] Specifically, by parsing the copy instruction input by the user, the source address information and destination address information for the copy are confirmed. In this embodiment, both the source address information and the destination address information are LBA address information. Each segment of LBA address information includes the starting address and length of the LBA address. Among them, the LBA addresses within each segment of LBA address information are usually arranged in a linearly increasing order. For example, a certain segment of LBA address information is (lba start address, lba length), where lba startaddress represents the starting address of this segment of LBA address, and lba length represents the length of this segment of LBA address. For example, if a certain segment of LBA address information is specifically (LBA0, 8), then the LBA addresses corresponding to this segment of LBA address information are:
[0050] (LBA0 LBA1 LBA2 LBA3 LBA4 LBA5 LBA6 LBA7), where LBA7 is the termination address of this segment of LBA address.
[0051] Among them, the source address information corresponds to multiple non - continuous source LBA addresses, that is, multiple separated LBA addresses, that is, the termination address of the previous segment of LBA address is not continuous with the starting address of the next segment of LBA address. The destination address information corresponds to one segment of destination LBA address. In the prior art, when the SSD disk copies data for multiple separated LBA addresses, multiple read and write commands are required, and data copy may be incomplete or the copied data may be inconsistent due to multiple read and write operations.
[0052] In a specific embodiment, the source address information includes the starting address and length of each segment of source LBA address; the destination address information includes the starting address and length of the destination LBA address, and the length of the destination LBA address is equal to the sum of the lengths of each segment of source LBA address.
[0053] Among them, the lengths of each segment of the source LBA address may not be equal, and the starting address of the subsequent segment of the source LBA address may be less than the starting address of the previous segment of the source LBA address, that is, the source LBA addresses of each segment may overlap. However, the length of the destination LBA address is equal to the sum of the lengths of each segment of the source LBA address, ensuring that the storage capacity of the destination LBA address is equal to or greater than the sum of the storage capacities of each segment of the source LBA address, so as to ensure that when data copying is performed, the destination LBA address can support the copying of data stored in each segment of the source LBA address to the destination LBA address. For example, the X segments of the source LBA address are [{lba1 start address, lba1 length}, {…}, {lbaX start address, lbaX length}], and the destination LBA address is {lba start address, lbalength}, lba length = lba1 length + … + lbaX length.
[0054] S120. According to the source address information and the destination address information, determine whether the source LBA address and the destination LBA address overlap.
[0055] Specifically, it can be determined whether the source LBA address and the destination LBA address overlap by determining whether the starting address of the source LBA address is between the starting address and the ending address of the destination LBA address, or by determining whether the ending address of the source LBA address is between the starting address and the ending address of the destination LBA address. The ending address is obtained according to the starting address and the address length of this segment of the LBA address. Alternatively, the complete source LBA address and destination LBA address are obtained through the source address information and the destination address information, and it is determined whether the source LBA address and the destination LBA address overlap by determining whether there are the same LBA addresses in the source LBA address and the destination LBA address.
[0056] S130. If the LBA address and the destination LBA address do not overlap, assemble the multiple segments of the source LBA address into one segment of the source LBA address to obtain the assembled source LBA address.
[0057] Specifically, if there is no overlap between the LBA address and the destination LBA address, each segment of the source LBA address is obtained according to the source LBA address information. The specific process of obtaining a segment of the LBA address according to the address information can refer to the corresponding relationship between the LBA address information and the LBA address described in detail in step S110. The multiple separated source LBA addresses are assembled into a continuous source LBA address to obtain the assembled source LBA address. Thus, when reading the data of the source LBA address, the data of the assembled source LBA address can be read. Compared with the need to read multiple times from the separated source LBA addresses, in this embodiment, all the data of the assembled source LBA address can be obtained by one read, so as to reduce the number of reads in the copy process. On the one hand, the possibility of data copy errors caused by multiple reads can be reduced. On the other hand, the time required for data copy can be reduced to improve the accuracy and efficiency of data copy.
[0058] S140. Read the data on the assembled source LBA address to obtain the assembled source LBA address data, and record the assembled source LBA address data to obtain the recorded source address data.
[0059] Specifically, since the multiple separated source LBA addresses have been assembled into a continuous source LBA address, the data on the assembled source LBA address is also assembled into one piece of data, that is, the assembled source LBA address data. When reading, it can be read once, without separately and repeatedly reading the data of the separated source LBA addresses. When writing to the destination LBA address subsequently, it can also be written once, that is, written in parallel, so as to reduce the number of read and write operations in the copy process and improve the accuracy and efficiency of data copy.
[0060] S150. Temporarily store the assembled source LBA address data in the buffer.
[0061] Among them, the buffer can be the buffer of the SSD itself. If the SSD is not configured with a buffer, a buffer module can be added in the SSD to be used as the buffer. The read assembled source LBA address data is temporarily stored in the buffer. If a copy error occurs accidentally and the data of the source LBA address is lost or damaged, the data of the source LBA address can be repaired by the assembled source LBA address data temporarily stored in the buffer, thereby further improving the reliability of data copy.
[0062] S160. According to the destination address information, copy the assembled source LBA address data to the destination LBA address corresponding to the destination address information to obtain the destination LBA address data.
[0063] Specifically, obtain a continuous destination LBA address according to the destination address information. For the specific process of obtaining an LBA address according to the address information, reference can be made to the corresponding relationship between the LBA address information and the LBA address described in detail in step S110. Parallel write the assembled source LBA address data read in step S140, that is, write it into the destination LBA address at one time, so as to obtain the data stored in the destination LBA address, that is, the destination LBA address data, thereby copying the data stored in the source LBA address to the destination LBA.
[0064] S170. Record the destination LBA address data to obtain the recorded destination address data.
[0065] Specifically, read and record the destination LBA address data to obtain the recorded destination address data. Since the destination LBA address is a continuous LBA address, the destination LBA address data can be read out at one time and this destination LBA address data is recorded.
[0066] S180. Compare whether the recorded destination address data is consistent with the recorded source address data;
[0067] By comparing whether the recorded destination address data is consistent with the recorded source address data, it is judged whether problems such as data loss occur during the process of copying data from the source LBA address to the destination LBA address. The problems may be caused by hardware failures, software errors, transmission interruptions, etc. If the recorded destination address data is consistent with the recorded source address data, it indicates that the data copy is successfully implemented. If the recorded destination address data is inconsistent with the recorded source address data, it indicates that the data copy is in error. For example, the recorded destination address data is missing compared with the recorded source address data.
[0068] S190. If the recorded destination address data is inconsistent with the recorded source address data, then return to execute S160, and copy the assembled source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information to obtain the destination LBA address data.
[0069] If the recorded destination address data is inconsistent with the recorded source address data, it indicates that the data copy is in error. Return to execute step S160, that is, repeatedly execute steps S160 to S180 until the recorded destination address data is consistent with the recorded source address data, that is, the copy is completed and the data is completely copied from the source LBA address to the destination LBA address. End the execution.
[0070] If the recorded destination address data is consistent with the recorded source address data, it indicates that this copy process has been successfully completed, and end the execution.
[0071] The method for copying data within an SSD provided by an embodiment of the present invention assembles the separated source LBA addresses to obtain an assembled source LBA address. When copying data for the assembled source LBA address, only the data of the assembled source LBA address needs to be read to obtain the assembled source LBA address data, avoiding multiple reads of the separated source LBA addresses. When writing data to the destination LBA address, it can also be written once, that is, written in parallel, thereby reducing the number of read and write commands that need to be issued during the data copying process, reducing the possibility of incomplete data copying and inconsistent copied data caused by multiple reads and writes, improving the efficiency of data copying, and reducing the number of read and write commands, which can reduce the wear of the SSD and extend the service life of the SSD. And by recording the data of the source LBA address before data copying to obtain the recorded source address data, and after data copying (i.e., after writing data to the destination LBA address), recording the data of the destination LBA address to obtain the recorded destination address data, by comparing whether the recorded source address data and the recorded destination address data are consistent, it is judged whether there are problems of data loss or data inconsistency during the copying process, and by repeating the copying steps until the recorded source address data and the recorded destination address data are consistent, to ensure that the data of the source LBA address is completely and accurately copied to the destination LBA address, ensuring the consistency before and after data copying, thereby further ensuring the reliability of data copying to avoid serious consequences such as data loss, damage, or system crashes of users, and improving the user experience.
[0072] As Figure 2 shown, in a further embodiment, for the method of copying data within an SSD, after step S180 of comparing whether the recorded destination address data and the recorded source address data are consistent, steps S200 to S230 are further included.
[0073] S200. If the recorded destination address data is consistent with the recorded source address data, read the data on the assembled source LBA address after the copy ends to obtain the copied source address data.
[0074] If the recorded destination address data is consistent with the recorded source address data, it means that the data has been completely and accurately copied to the destination LBA address. To prevent the loss of the copied source address data due to other reasons, after the copy ends, the original data on the source LBA address is further detected. In this further embodiment, data copying does not include data migration because after data migration, the data on the source LBA address will necessarily change. Therefore, data migration is not within the protection scope of this further embodiment.
[0075] S210. Compare whether the copied source address data is consistent with the recorded source address data.
[0076] By comparing whether the source address data after copying is the same as the recorded source address data obtained before copying, it is determined whether the source LBA address data is lost or damaged due to accidental factors such as hardware failures or software errors after copying.
[0077] S220: If the source address data after copying is inconsistent with the recorded source address data, restore the source address data based on the source LBA address data temporarily stored in the buffer.
[0078] If the source address data after copying is inconsistent with the recorded source address data, it indicates that there may be a problem of loss of source address data. At this time, the source address data after copying can be repaired by using the source LBA address data temporarily stored in the buffer before data copying to restore the source address data. Specifically, the source address data can be repaired by copying or rewriting.
[0079] S230: Return to execute S210 and compare whether the source address data after copying is the same as the recorded source address data.
[0080] Return to execute S200, that is, repeat steps S200 - S220 until the source address data after copying is the same as the recorded source address data.
[0081] If the source address data after copying is the same as the recorded source address data, end the execution.
[0082] In a further embodiment provided by the present invention, in order to avoid the loss of the original data of the source address due to accidental factors, the source LBA address data temporarily stored in the buffer before data copying can be used to repair the source address data after copying to restore the original data of the source LBA address, so as to ensure that both the destination LBA address data and the source LBA address data are complete data after data copying, meeting the needs of users.
[0083] As Figure 3 shown, in some embodiments, for the method of copying data within an SSD disk, after S120: according to the source address information and the destination address information, determine whether the LBA address and the destination LBA address overlap, the method further includes steps S131 - S181.
[0084] S131: If the source LBA address and the destination LBA address overlap, read the data on the source LBA address to obtain the source LBA address data, and record the source LBA address data to obtain the recorded source address data.
[0085] Specifically, if there is an overlap between the source LBA address and the destination LBA address, to prevent the data in the overlapping part of the source LBA address from being overwritten by the destination LBA address during the copying process, which may result in inconsistent data at the LBA address where the data is copied to, the separate source LBA address is no longer assembled. Instead, the data on the source LBA address is still sequentially read to obtain the source LBA address data, and the source LBA address data is recorded to obtain the recorded source address data, providing a comparison object for the subsequent comparison step.
[0086] S141. Temporarily store the source LBA address data in a buffer.
[0087] The function of this step is similar to that of S150, and will not be elaborated here.
[0088] S151. According to the destination address information and the source address information, copy the source LBA address data to the destination LBA address corresponding to the destination address information to obtain the destination LBA address data.
[0089] Among them, since there is an overlap between the source LBA address and the destination LBA address, when writing the read source LBA address data to the destination LBA address, a serial writing method is adopted to prevent inconsistent data copying. As Figure 4 shown, specifically, S151 includes sub-steps S1511 to S1513.
[0090] S1511. According to the destination address information and the source address information, determine whether the starting address of the source LBA address is greater than the starting address of the destination LBA address.
[0091] The size of the starting address can be determined by comparing the sequence numbers of the starting addresses. For example, if the starting address of the source LBA address is LBA0 and the starting address of the destination LBA address is LBA2, then the starting address of the source LBA address is less than the starting address of the destination LBA address; if the starting address of the source LBA address is LBA2 and the starting address of the destination LBA address is LBA0, then the starting address of the source LBA address is greater than the starting address of the destination LBA address. (As described above, the length of the destination LBA address is equal to the sum of the lengths of the source LBA addresses, so the case where the starting address of the source LBA address is equal to the starting address of the destination LBA address is not considered.)
[0092] S1512. If the starting address of the source LBA address is greater than the starting address of the destination LBA address, copy the source LBA address data from the source LBA address to the destination LBA address in a sequential serial manner.
[0093] Among them, the sequential serial method is as follows: in the order of increasing LBA addresses, the source LBA address data is sequentially written to the corresponding destination LBA address; the starting address of the source LBA address corresponds to the starting address of the destination LBA address, and the ending address of the source LBA address corresponds to the ending address of the destination LBA address.
[0094] For example, the following Table 1 simply shows the sequential serial writing process.
[0095] Table 1:
[0096]
[0097] In Table 1, the row where src is located represents the source LBA address, LBA2 is its starting address, and LBA9 is its ending address; the row where dst is located represents the destination LBA address, LBA0 is its starting address, and LBA7 is its ending address. The part with the same serial number in the source LBA address and the destination LBA address is the overlapping part; the arrow represents the order in which the data is sequentially written. That is, when writing the data, first complete the writing of the data from the starting address of the source LBA address, which is LBA2, to the starting address of the destination LBA address, which is LBA0, and then write the data from the second address of the source LBA address, which is LBA3, to the second address of the destination LBA address, which is LBA1. Write in order from front to back according to the direction of the arrow to complete the data copy and avoid copy errors caused by overlapping of the source LBA address and the destination LBA address.
[0098] S1513. If the starting address of the source LBA address is less than the starting address of the destination LBA address, use the reverse serial method to copy the source LBA address data from the source LBA address to the destination LBA address;
[0099] Among them, the reverse serial method is as follows: in the order of decreasing LBA addresses, the source LBA address data is sequentially written to the corresponding destination LBA address. The starting address of the source LBA address corresponds to the starting address of the destination LBA address, and the ending address of the source LBA address corresponds to the ending address of the destination LBA address.
[0100] For example, the following Table 2 simply shows the reverse serial writing process.
[0101] Table 2:
[0102]
[0103] In Table 2, the row where "src" is located represents the source LBA address, with LBA0 as its starting address and LBA7 as its ending address; the row where "dst" is located represents the destination LBA address, with LBA2 as its starting address and LBA9 as its ending address. The overlapping part of the source LBA address and the destination LBA address is the part with the same serial number; the arrow represents the order in which data is written sequentially. That is, when writing data, first complete the writing of data from the ending address of the source LBA address, i.e., LBA7, to the ending address of the destination LBA address, i.e., LBA9, and then write data from the second-to-last address of the source LBA address, i.e., LBA6, to the second-to-last address of the destination LBA address, i.e., LBA8. Write in reverse order according to the direction of the arrow from the back to the front to complete the data copy and avoid copy errors caused by overlapping of the source LBA address and the destination LBA address.
[0104] S161. Record the data of the destination LBA address to obtain the recorded destination address data.
[0105] The function of this step is similar to that of S170 and will not be elaborated here.
[0106] S171. Compare whether the recorded destination address data is consistent with the recorded source address data.
[0107] The function of this step is similar to that of S180 and will not be elaborated here.
[0108] S181. If the recorded destination address data is inconsistent with the recorded source address data, then return to execute S151. According to the destination address information and the source address information, copy the source LBA address data to the destination LBA address corresponding to the destination address information to obtain the destination LBA address data.
[0109] Specifically, return to execute S151, that is, repeatedly execute S151 to S171 until the recorded destination address data is consistent with the recorded source address data.
[0110] If the recorded destination address data is consistent with the recorded source address data, then execute step S200 or end the execution.
[0111] A method for copying data within an SSD disk provided by an embodiment of the present invention has at least the following beneficial effects: realizing the fast data copy function of the SSD, which can significantly improve the data copy speed inside the SSD, reduce the copy time, and improve the efficiency of data migration or backup. At the same time, reduce the read and write operations to reduce the wear of the SSD and extend the service life of the SSD. Achieving the purpose of verifying and correcting the consistency of data before and after copying, which can efficiently and accurately detect possible differences during the data copy process of the SSD, and timely perform data repair or re-copying, thereby ensuring the reliability of data migration or backup.
[0112] As Figure 5 shown, an embodiment of the present invention further provides a device for copying data within an SSD disk, which is used to execute the method described in the above embodiment. The device can be configured within the SSD disk and includes: an address confirmation module 10, a first judgment module 20, a first data recording module 40, a cache module 50, a data transmission module 60, a second data recording module 70, and a return execution module 90.
[0113] The address confirmation module 10 is used to confirm the source address information and destination address information of the copy; wherein, both the source address information and the destination address information are LBA address information. The source address information corresponds to multiple segments of source LBA addresses, and the destination address information corresponds to one segment of destination LBA address.
[0114] The first judgment module 20 is used to judge whether there is an overlap between the LBA address and the destination LBA address according to the source address information and the destination address information.
[0115] The assembly module 30 is used to assemble multiple segments of source LBA addresses into one segment of source LBA address to obtain an assembled source LBA address if there is no overlap between the LBA address and the destination LBA address.
[0116] The first data recording module 40 is used to read the data on the assembled source LBA address to obtain the assembled source LBA address data, and record the assembled source LBA address data to obtain the recorded source address data.
[0117] The first cache module 50 is used to temporarily store the assembled source LBA address data in the buffer area.
[0118] The first data transmission module 60 is used to copy the assembled source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information to obtain the destination LBA address data.
[0119] The second data recording module 70 is used to record the destination LBA address data to obtain the recorded destination address data.
[0120] The first comparison module 80 is used to compare whether the recorded destination address data is consistent with the recorded source address data.
[0121] The first return execution module 90 is used to return and execute the step of copying the assembled source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information to obtain the destination LBA address data if the recorded destination address data is inconsistent with the recorded source address data.
[0122] In some embodiments, the device for copying data within an SSD may further include an instruction receiving module configured to receive a copy instruction input by a user.
[0123] In some embodiments, the device for copying data within an SSD may further include:
[0124] A third data recording module configured to, if the recorded destination address data is the same as the recorded source address data, read the data at the assembled source LBA address after the copy is completed to obtain the copied source address data.
[0125] A second comparison module configured to compare whether the copied source address data is the same as the recorded source address data.
[0126] A data recovery module configured to, if the copied source address data is not the same as the recorded source address data, recover the source address data based on the source LBA address data temporarily stored in the buffer.
[0127] A second return and execution module configured to return and execute S210 and compare whether the copied source address data is the same as the recorded source address data.
[0128] In some embodiments, the device for copying data within an SSD may further include:
[0129] A fourth data recording module configured to, if the source LBA address and the destination LBA address overlap, read the data at the source LBA address to obtain the source LBA address data and record the source LBA address data to obtain the recorded source address data.
[0130] A second buffer module configured to temporarily store the source LBA address data in a buffer.
[0131] A second data transmission module configured to copy the source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information and the source address information to obtain the destination LBA address data.
[0132] A fifth data recording module configured to record the destination LBA address data to obtain the recorded destination address data.
[0133] A third comparison module configured to compare whether the recorded destination address data is the same as the recorded source address data.
[0134] A third return execution module, configured to return and execute S151 if the recorded destination address data is inconsistent with the recorded source address data, and copy the source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information and the source address information, so as to obtain the destination LBA address data.
[0135] The above device for copying data within an SSD can be implemented in the form of a computer program, and this computer program can run on a computer device as Figure 6 shown.
[0136] Refer to Figure 6 , the computer device 500 includes a processor 502, a memory, and a network interface 505 connected through a communication bus 501. Among them, the memory may include a storage medium 503 and an internal memory 504.
[0137] The storage medium 503 can store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, it can cause the processor 502 to execute the method for copying data within an SSD. Among them, the storage medium 503 can be a volatile storage medium or a non-volatile storage medium.
[0138] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
[0139] The internal memory 504 provides an environment for the operation of the computer program 5032 in the storage medium 503. When the computer program 5032 is executed by the processor 502, it can cause the processor 502 to execute the method for copying data within an SSD.
[0140] The network interface 505 is used for network communication, such as providing the transmission of data information, etc. Those skilled in the art can understand that Figure 6 the structure shown in
[0141] is only a block diagram of some structures related to the solution of the present invention, and does not constitute a limitation on the computer device 500 to which the solution of the present invention is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0142] Those skilled in the art can understand that Figure 6The embodiments of the computer device shown do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component layout. For example, in some embodiments, the computer device may only include a memory and a processor. In such an embodiment, the structures and functions of the memory and the processor are the same as those in Figure 6 the shown embodiment and will not be elaborated herein.
[0143] It should be understood that in the embodiments of the present invention, the processor 502 may be a central processing unit (CPU), and this processor 502 may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0144] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps included in the above-mentioned method for copying data within an SSD disk are implemented.
[0145] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the above-described devices, apparatuses, and units can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein. Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0146] In several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, or units with the same function can be aggregated into one unit. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed coupling, direct coupling, or communication connection to each other can be an indirect coupling or communication connection through some interfaces, devices, or units, or can also be an electrical, mechanical, or other form of connection.
[0147] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of the present invention.
[0148] In addition, each functional unit in various embodiments of the present invention can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0149] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned computer-readable storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), magnetic disks, or optical discs that can store program codes.
[0150] The above is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A method for copying data in an SSD disk, characterized in that: include: Confirm the source address information and destination address information of the copy; Wherein, the source address information and the destination address information are both LBA address information, the source address information corresponds to multiple source LBA addresses, and the destination address information corresponds to one destination LBA address; According to the source address information and the destination address information, determining whether the source LBA address and the destination LBA address overlap; If the LBA address and the destination LBA address do not overlap, assembling the multiple source LBA addresses into one source LBA address to obtain an assembled source LBA address; Reading data on the assembly source LBA address to obtain assembly source LBA address data, and recording the assembly source LBA address data to obtain recording source address data; Temporarily storing the assembly source LBA address data in a buffer area; According to the destination address information, copy the assembly source LBA address data to the destination LBA address corresponding to the destination address information to obtain the destination LBA address data; Recording the destination LBA address data to obtain recorded destination address data; Comparing whether the recorded destination address data is consistent with the recorded source address data; If the recorded destination address data is inconsistent with the recorded source address data, the process returns to execute the process according to the destination address information, copies the assembled source LBA address data to the destination LBA address corresponding to the destination address information, and obtains the destination LBA address data.
2. The method for copying data in an SSD disk according to claim 1, characterized in that: After determining whether the LBA address and the destination LBA address overlap according to the source address information and the destination address information, the method further includes: If the source LBA address and the destination LBA address overlap, read the data on the source LBA address to obtain source LBA address data, and record the source LBA address data to obtain recorded source address data; Temporarily storing the source LBA address data in a buffer area; According to the destination address information and the source address information, the source LBA address data is copied to the destination LBA address corresponding to the destination address information to obtain the destination LBA address data; Recording the destination LBA address data to obtain recorded destination address data; Comparing whether the recorded destination address data is consistent with the recorded source address data; If the recorded destination address data is inconsistent with the recorded source address data, the process returns to execute the process according to the destination address information and the source address information, copies the source LBA address data to the destination LBA address corresponding to the destination address information, and obtains the destination LBA address data.
3. The method for copying data in an SSD disk according to claim 2, characterized in that: The step of copying the source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information and the source address information to obtain the destination LBA address data includes: According to the destination address information and the source address information, determining whether the starting address of the source LBA address is greater than the starting address of the destination LBA address; If the starting address of the source LBA address is greater than the starting address of the destination LBA address, the source LBA address data is copied from the source LBA address to the destination LBA address in a sequential serial manner; Among them, the starting address of the source LBA address corresponds to the starting address of the destination LBA address, and the ending address of the source LBA address corresponds to the ending address of the destination LBA address. If the starting address of the source LBA address is smaller than the starting address of the destination LBA address, the source LBA address data is copied from the source LBA address to the destination LBA address in a reverse serial manner; The starting address of the source LBA address corresponds to the starting address of the destination LBA address, and the ending address of the source LBA address corresponds to the ending address of the destination LBA address.
4. The method for copying data in an SSD disk according to claim 3, characterized in that: The sequential serial method is: writing the source LBA address data to the corresponding destination LBA address in sequence according to the order of LBA addresses from small to large; the reverse serial method is: writing the source LBA address data to the corresponding destination LBA address in sequence according to the order of LBA addresses from large to small.
5. The method for copying data in an SSD disk according to claim 1, characterized in that: After comparing whether the recorded destination address data is consistent with the recorded source address data, the method further includes: If the recorded destination address data is consistent with the recorded source address data, read the data on the assembled source LBA address after the copy is completed to obtain the copied source address data; Comparing the copied source address data with the recorded source address data to see if they are consistent; If the copied source address data is inconsistent with the recorded source address data, restoring the source address data based on the source LBA address data temporarily stored in the buffer area; Returning the comparison to determine whether the copied source address data is consistent with the recorded source address data.
6. The method for copying data in an SSD disk according to claim 1, characterized in that: Before confirming the source address information and the destination address information of the copy, the method includes: Receive the copy instruction input by the user.
7. The method for copying data in an SSD disk according to claim 1, characterized in that: The source address information includes the starting address and length of each source LBA address segment; the destination address information includes the starting address and length of the destination LBA address, and the length of the destination LBA address is equal to the sum of the lengths of each source LBA address segment.
8. A device for copying data in an SSD disk, characterized in that: For executing the method according to any one of claims 1 to 7, the device comprises: An address confirmation module, used to confirm the source address information and the destination address information of the copy; wherein the source address information and the destination address information are both LBA address information, the source address information corresponds to multiple source LBA addresses, and the destination address information corresponds to one destination LBA address; A first judgment module, used for judging whether the LBA address and the destination LBA address overlap according to the source address information and the destination address information; An assembling module, used for assembling multiple source LBA addresses into one source LBA address to obtain an assembled source LBA address if the LBA address and the destination LBA address do not overlap; A first data recording module is used to read the data on the assembly source LBA address to obtain the assembly source LBA address data, and record the assembly source LBA address data to obtain the recording source address data; A first cache module, used for temporarily storing the assembly source LBA address data in a cache area; A first data transmission module, configured to copy the assembly source LBA address data to a destination LBA address corresponding to the destination address information according to the destination address information, to obtain the destination LBA address data; A second data recording module is used to record the destination LBA address data to obtain recorded destination address data; A first comparison module, used for comparing whether the recorded destination address data is consistent with the recorded source address data; The first return execution module is used to return to execute the method of copying the assembled source LBA address data to the destination LBA address corresponding to the destination address information according to the destination address information to obtain the destination LBA address data if the recorded destination address data is inconsistent with the recorded source address data.
9. A computer device, characterized in that: The device includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement the steps of the method for copying data in an SSD disk described in any one of claims 1 to 7 when executing the program stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for copying data in an SSD disk as described in any one of claims 1 to 7 are implemented.