Disclosure of Invention
The embodiment of the invention provides a data backup method and device, which improve the data backup speed.
The embodiment of the invention provides a data backup method, which comprises the following steps:
receiving a backup command carrying a source logical block address group and a target logical block address group;
storing the data in the source logical block address group into a cache memory inside the solid state disk according to the backup command;
and storing the data in the cache memory into the target logical block address group to realize internal data backup of the solid state disk, wherein the data backup inside the solid state disk does not need to exchange data with a cache of a host.
The embodiment of the invention provides a device for realizing data backup, which comprises a receiving unit, a cache memory and a processing unit, wherein the receiving unit, the cache memory and the processing unit
The receiving unit is used for receiving a backup command carrying a source logical block address group and a target logical block address group;
the processing unit is used for storing the data in the source logical block address group into a cache memory inside the solid state disk according to the backup command received by the receiving unit, storing the data in the cache memory into the target logical block address group, and realizing internal data backup of the solid state disk, wherein the data backup inside the solid state disk does not need to exchange data with a cache of a host.
In the embodiment of the invention, the internal data backup of the solid state disk is realized by utilizing the cache memory in the solid state disk, and the data interaction with the cache of the host is not needed, so that the data backup speed is improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
An embodiment of the present invention provides a data backup method, as shown in fig. 1, including the following steps:
step 101, receiving a backup command carrying a source logical block address group and a destination logical block address group.
The backup command may be a COPY _ BACK command newly added in an ATA (Advanced Technology Attachment) protocol.
Wherein each logical block address value in the logical address group may be carried in a COPY _ BACK command; the start logical address value and the data length value of the logical address group may also be carried in the COPY BACK command.
Because the backup command needs to include at least two LBA (Logical Block Address) values, and a single command issued by the host can only transmit one LBA value to the solid state disk, transmission of the command cannot be completed at one time. The host can decompose the COPY _ BACK command into two decomposition commands to be issued, command codes of the two issued commands can be the same or different (the command codes can be defined by themselves), meanwhile, a command identifier for indicating that the two decomposition commands belong to the same COPY _ BACK command is required, and the solid state disk can identify that the two decomposition commands belong to the same COPY _ BACK command according to the command identifier. In addition, ordinal numbers of the two decomposition commands can be set, the decomposition command with the lower ordinal number carries information of a source logical block address group, the decomposition command with the higher ordinal number carries information of a target logical block address group, and the solid state disk can identify the source logical block address group and the target logical block address group according to the ordinal numbers of the two decomposition commands.
Table 1 is a simple COPY BACK split command.
TABLE 1 COPY _ BACK decomposition Command
Wherein PRE is the ordinal number of the COPY _ BACK decomposition command;
wherein, Tag is a command identifier, and two decomposition commands belonging to the same COPY _ BACK command need to adopt the same command identifier;
wherein, the Sector count is the length of data to be backed up;
wherein, the LBA is the logical block address;
wherein, F0 is COPY _ BACK command code.
Tables 2 and 3 are two decomposition commands based on the COPY _ BACK decomposition command defined in table 1.
TABLE 2 first decompose Command
TABLE 3 second decompose Command
The COPY BACK command shown in tables 2 and 3 has the following meaning:
data with a starting LBA address of 0x0 and a data length of 6 SECTORs is backed up to an address with a starting LBA address of 0 xFFFF.
And 102, storing the data in the source logical block address group into a cache memory inside the solid state disk according to the backup command.
The step of storing the data in the source logical block address group into a cache memory inside the solid state disk according to the backup command comprises the following steps:
reading data in the source logical block address group;
writing the read data into the cache memory.
Step 103, storing the data in the cache memory into the destination logical block address group.
Wherein the storing the data in the cache memory into the destination logical block address group comprises:
reading data in the cache memory;
and writing the read data into the destination logical block address group.
In the embodiment of the invention, the internal data backup of the solid state disk is realized by utilizing the cache memory in the solid state disk, and the data interaction with the cache of the host is not needed, so that the data backup speed is improved.
An apparatus for implementing data backup is provided in the embodiment of the present invention, as shown in fig. 2, and includes a receiving unit 201, a cache memory 202, and a processing unit 203, wherein,
a receiving unit 201, configured to receive a backup command carrying a source logical block address group and a destination logical block address group;
a processing unit 203, configured to store the data in the source logical block address group into the cache memory 202 according to the backup command received by the receiving unit 201, and store the data in the cache memory 202 into the destination logical block address group.
The backup command may be a COPY BACK command newly added in the ATA protocol.
Wherein the processing unit 203 comprises:
a reading subunit 2031, configured to read data in the source logical block address group;
a write subunit 2032 for writing the data read by the read subunit 2031 into the cache memory 202.
Wherein,
a read subunit 2031, further configured to read data in the cache memory 202;
the writing subunit 2032 is further configured to write the data read by the reading subunit 2031 into the destination logical block address group.
The device for realizing data backup can be a solid state disk.
In the embodiment of the invention, the internal data backup of the solid state disk is realized by utilizing the cache memory in the solid state disk, and the data interaction with the cache of the host is not needed, so that the data backup speed is improved.
From the above description of the embodiments, it is clear to those skilled in the art that the present invention can be implemented by hardware, or by software plus a necessary general hardware platform, and based on such understanding, the technical solution of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the method described in the embodiments of the present invention.
In short, the above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.