WO2020038186A1 - Data migration method and apparatus, and storage device - Google Patents

Data migration method and apparatus, and storage device Download PDF

Info

Publication number
WO2020038186A1
WO2020038186A1 PCT/CN2019/098061 CN2019098061W WO2020038186A1 WO 2020038186 A1 WO2020038186 A1 WO 2020038186A1 CN 2019098061 W CN2019098061 W CN 2019098061W WO 2020038186 A1 WO2020038186 A1 WO 2020038186A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage
data
virtual
offset
address
Prior art date
Application number
PCT/CN2019/098061
Other languages
French (fr)
Chinese (zh)
Inventor
贾胜迁
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2020038186A1 publication Critical patent/WO2020038186A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0647Migration mechanisms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0662Virtualisation aspects

Definitions

  • the embodiments of the present application relate to the field of communications technologies, and in particular, to a data migration method, device, and storage device.
  • Some electronic devices include storage media that need to be erased before writing, and these storage media include multiple storage areas. Data is written into the storage area in an additional write manner. After the storage addresses in the storage area are filled in order, a garbage collection (GC) process may need to be performed on the storage area.
  • the GC process refers to: after the storage address in the storage area is filled up in order, if a part of the data in the storage area is deleted, the storage space after the partial data is deleted because the remaining data occupies the storage space Not available, so you need to migrate the data in the storage area and reset the storage area.
  • the storage address information of data is recorded through metadata, and the metadata is organized in a tree structure. After the above GC process is performed, it is necessary to start from the leaf node metadata corresponding to the migrated data and modify the metadata layer by layer.
  • the embodiments of the present application provide a data migration method, device, and storage device, which are used to solve the problem of low data management efficiency in the prior art.
  • a first aspect of the embodiments of the present application provides a data migration method.
  • the method is applied to a storage device.
  • the storage device includes a controller and at least one hard disk.
  • the controller is configured to manage data stored in the hard disk.
  • the first data is stored in a first storage address, and a first virtual address is recorded in the metadata of the first data. There is a first mapping relationship between the first storage address and the first virtual address.
  • the method includes:
  • the storage device migrates the first data from the first storage address to the second storage address, and further, the storage device adjusts the first mapping relationship to a second mapping relationship, where the second mapping relationship is the second storage address and The corresponding relationship of the first virtual address.
  • a first virtual address is recorded in metadata of the first data
  • a first mapping relationship between the first virtual address and the first storage address storing the first data is recorded in the storage device before the first data is migrated
  • the first mapping relationship needs to be modified to the second mapping relationship between the first virtual address and the second storage address, so that there is no need to modify the first data
  • the metadata can also ensure that the first data can still be accessed correctly after the migration. Therefore, this embodiment greatly reduces the number of metadata modification times while ensuring that the data is correctly accessed, thereby greatly improving the metadata. Management efficiency reduces the load on the storage system.
  • the storage address is determined by a storage area ID and a storage offset in the storage area.
  • the first virtual address is jointly identified by the identifier of the first virtual area and the first virtual offset.
  • the first mapping relationship includes a mapping relationship between the identifier of the first virtual area and the first storage area, and a mapping relationship between the first virtual offset and the first storage offset.
  • the second mapping relationship includes a mapping relationship between the identifier of the first virtual area and the second storage area, and a mapping relationship between the first virtual offset and the second storage offset.
  • the following process may also be performed:
  • the storage device migrates all the data in the storage area corresponding to the first storage address to the storage area corresponding to the second storage address, the storage device updates a migration identifier, which is used to identify the migration of the first virtual area. frequency.
  • the above method further includes:
  • the third mapping relationship includes: a mapping relationship between an identifier of the second virtual area and a third storage area, and a mapping between the second virtual offset and a third storage offset relationship.
  • the determination is made in combination with the migration identifier, so that after the data is migrated, the virtual offset of the newly written data will not be different from the virtual offset of the already written data. Duplicates occur to avoid errors when reading and writing data.
  • the method further includes:
  • the determining the first storage address storing the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data include:
  • the mapping relationship between the first virtual offset and the first storage offset is identified by a mapping table of the first virtual offset and the first storage offset, or by a preset
  • the formula is OK.
  • a second aspect of the embodiments of the present application provides a data migration device, which is applied to a storage device, and the device may be a controller in the storage device or a part of the controller.
  • the first data is stored in a first storage address
  • a first virtual address is recorded in the metadata of the first data
  • This device can implement the functions in the first aspect described above. These functions can be realized by hardware, and can also be implemented by hardware executing corresponding software.
  • the hardware or software includes one or more modules corresponding to the functions described above.
  • the device may include a processing module, which may perform a corresponding function in the above method, for example, a processing module, configured to migrate the first data from the first storage address to the second storage. Address; and,
  • a third aspect of the embodiments of the present application provides a storage device.
  • the storage device includes a controller and at least one hard disk.
  • the controller is configured to manage data stored in the hard disk.
  • the first data is stored at a first storage address.
  • a first virtual address is recorded in the metadata of the data, and there is a first mapping relationship between the first storage address and the first virtual address.
  • the controller is further configured to execute the method according to the first aspect.
  • a fourth aspect of the embodiments of the present application provides a computer program product, where the computer program product includes computer program code, and when the computer program code is executed by a computer, causes the computer to execute the method described in the first aspect.
  • a fifth aspect of the embodiments of the present application provides a computer-readable storage medium.
  • the computer storage medium stores computer instructions.
  • the computer instructions When the computer instructions are executed by a computer, the computer is caused to execute the method described in the first aspect.
  • Figure 1 shows the storage structure of the file BB.doc in the tree structure of the file system
  • FIG. 2 is a schematic flowchart of an embodiment of a data migration method according to an embodiment of the present application
  • Figure 3 shows the storage structure of the file BB.doc in the tree structure of the file system
  • FIG. 4 is a schematic flowchart of writing second data in a storage device
  • FIG. 5 is a schematic flowchart of reading the first data from a storage device
  • FIG. 6 is a schematic block diagram of a data migration device 600 according to an embodiment of the present application.
  • FIG. 7 is a physical block diagram of a storage device 700 according to an embodiment of the present application.
  • the storage device can organize files through a file system, and the file system can be regarded as a method and a data structure of the storage device's operating system for specifying the files on the storage device.
  • data can be divided into data files and metadata, where the data file is a file stored on a storage device.
  • Metadata can be regarded as data describing data.
  • the metadata can hold information such as the owner, size, permissions, timestamp, link, and storage address of the data on the disk of the storage device.
  • the file system can be managed in a tree structure.
  • Figure 1 is the storage structure of the file BB.doc in the tree structure of the file system
  • the first layer of the tree structure, the root is the storage address of the root directory "/”.
  • the content stored in the storage address of the root directory includes metadata of "AA” and information of other files or directories included in the root directory. According to the metadata of "AA” recorded in the second layer, the storage address of "AA" can be obtained.
  • the content stored in the storage address of "AA” the content includes “BB.doc” metadata and information on other files or directories contained in the "AA” directory. According to the metadata of "AA” recorded in the third layer, the storage address of "BB.doc” can be obtained. Furthermore, in the fourth layer of the tree structure, the storage address of "BB.doc” is stored. Content, which is the data corresponding to the file "BB.doc”.
  • the storage address of a file in the file system is recorded by metadata, and is recorded layer by layer according to a tree structure.
  • SMR shingled magnetic recording
  • SSD solid-state drive
  • SMR is sometimes also called SMR disk or SMR hard disk.
  • the storage address of the data is represented by "zone + offset”.
  • the SMR hard disk is composed of multiple zones (areas), and each zone can be regarded as a storage area in the SMR hard disk.
  • offset describes a specific position within the zone, for example (zone3, 48KB) describes a position 48KB away from the starting position of zone3.
  • the offset can be any value greater than 0, as long as it does not exceed the length of the zone.
  • offset can use an integer multiple of 48K bytes as the granularity.
  • the storage address of the data is expressed in the form of "page group + offset".
  • the SSD can include multiple pages. These pages can be divided into multiple page groups. Each page group can be regarded as the SSD. Within a storage area. It can be divided into multiple offsets in each page group. Offset can be in bytes, or it can be in pages. Exemplarily, if the offset is in units of a page, an offset can be expressed as "beginning of the second page and ending at the third page" in a certain page group, or offset only describes "in a certain page group" From the second page as the starting page ", the end page is described with an additional length parameter.
  • the file “BB.doc” is stored on the SMR hard disk of a storage device, and the storage address of the file on the SMR hard disk is "zone1 + offset1", that is, the data of the file is stored in the SMR On the hard disk, zone1 is located in offset1 (in other words, offset1 in zone1 is used as the starting position for storing BB.doc).
  • the storage path of the file in the file system of the storage device is the path described in the corresponding description of FIG. 1.
  • the “zone1 + offset1” is recorded in the third layer.
  • Storage address, the storage address of "AA” is recorded in the second layer, and the storage address of "/" is recorded in the first layer.
  • the "storage address” described in the embodiments of the present application refers to the address used to identify the data storage location at the operating system level.
  • the "storage address” needs to pass through the bottom layer below the operating system. After the software performs further conversion, the actual physical address on the hard disk is obtained.
  • the specific process of the conversion may refer to the method in the prior art, which is not specifically limited in the embodiment of the present application.
  • the storage address can be zone + offset mentioned above.
  • FIG. 2 is a schematic flowchart of an embodiment of a data migration method provided by an embodiment of the present application.
  • the method is executed by the foregoing storage device, and the storage device may be a desktop computer, a notebook computer, a server, a storage controller + hard disk, and the like having data storage.
  • Functional device The storage device includes a controller and at least one hard disk, and the controller is configured to manage data stored in the hard disk.
  • a processor or a combination of a processor and other auxiliary devices, such as a combination of a processor and a memory
  • a storage controller from a functional perspective.
  • the first data may be any data in a hard disk of the storage device.
  • the first data may correspond to a file managed by the file system.
  • the first data is stored at a first storage address on a hard disk
  • the storage address recorded in the metadata of the first data is a first virtual address, and there is a one-to-one correspondence between the first storage address and the first virtual address.
  • a first mapping. relationship For convenience of description, we call it a first mapping. relationship.
  • the first virtual address is not a storage address, but a virtualized storage address, and an identifier recorded in the metadata of the first data.
  • the first virtual address and the first storage address have a first mapping relationship.
  • the first storage address of the first data can be obtained through the first virtual address recorded in the metadata and the first mapping relationship.
  • a virtual address virtualized storage address
  • the storage address recorded in the metadata is replaced with the virtual address recorded in the metadata. Therefore, when the storage address of the data is changed, it is only necessary to update the mapping relationship between the virtual address and the storage address, and the virtual address in the metadata can remain unchanged. Therefore, a large number of metadata updates caused by data migration are avoided, the metadata management efficiency is improved, and the load of the storage system is reduced.
  • the method includes:
  • the storage device migrates the first data from the first storage address to the second storage address.
  • the storage device has determined that the storage area where the first data is located needs to be GC. Further, in this step, the storage device migrates the first data from the first storage address to the second storage address.
  • the above-mentioned “migration” process may specifically be:
  • the first data is written into the second storage address.
  • the first data stored on the first storage address may be subsequently deleted.
  • the storage device adjusts the first mapping relationship to a second mapping relationship, where the second mapping relationship is a correspondence relationship between the second storage address and the first virtual address.
  • the storage device may allocate a first virtual address to the first data, and record the first virtual address in the metadata of the first data, and further After the first data is migrated from the first storage address to the second storage address, the storage device does not need to modify the first virtual address, but only the mapping relationship corresponding to the first data, that is, the first mapping relationship is modified to the second Mapping relations. Because the first storage address of the first data can be obtained through the mapping relationship between the first virtual address recorded in the metadata and the first data, after the first data is migrated, the first virtual address recorded in the metadata is obtained. As well as the modified second mapping relationship, the storage address of the first data can still be obtained. At the same time, in this process, the metadata of the first data is not modified.
  • mapping relationship (for example, the first mapping relationship and the second mapping relationship) may be recorded in the metadata, or may be recorded in another location by itself. As long as it can be read by the processor or memory controller.
  • the first mapping relationship and the second mapping relationship may be stored in the form of a mapping table.
  • a mapping table of data may be stored in the storage device.
  • the first mapping relationship is recorded in the mapping table before data migration
  • the second mapping is recorded in the mapping table after data migration. relationship.
  • Table 1 is an example of the mapping table before the first data migration
  • Table 2 is an example of the mapping table after the first data migration.
  • the above mapping table may be generated in the memory of the storage device.
  • the storage device updates and maintains the above mapping table.
  • the storage device can save the above mapping table to the hard disk of the storage device.
  • the mapping table stored in the hard disk is loaded into the memory, and then reading and writing are continued based on the mapping table, and the mapping table is updated and maintained.
  • a first virtual address is recorded in metadata of the first data, and before the first data is migrated, a first mapping relationship between the first virtual address and the first storage address storing the first data is recorded in the storage device.
  • the first data is migrated from the first storage address to the second storage address, it is only necessary to modify the first mapping relationship to the second mapping relationship between the first virtual address and the second storage address, thereby eliminating the need to modify the first data.
  • this embodiment greatly reduces the number of metadata modification times while ensuring that the data is correctly accessed, thereby greatly improving the metadata. Management efficiency, reducing the load on the storage system.
  • the storage address may be expressed differently.
  • the storage address representation method can be regarded as a "storage area + storage offset" method.
  • the hard disk is divided into multiple storage areas, and within each storage area, multiple storage offsets can be included.
  • a zone represents a storage area
  • an offset within each zone represents a storage offset within the zone.
  • a page group is used to represent a storage area, and an offset within each page group represents a storage offset within the page group.
  • the storage address of the data on the hard disk can be determined through the storage area ID and the storage offset in the storage area.
  • SMR hard disks and a type of hard disks represented by SSDs can write data in a sequential write manner.
  • new data cannot directly overwrite old data, and the space occupied by old data needs to be released through garbage collection for new data.
  • the storage address of the data D can be expressed as: zone1offset1, that is, the storage address of data D is identified by the storage area of zone1 and the storage offset of offset1.
  • zone1offset1 that is, the storage address of data D is identified by the storage area of zone1 and the storage offset of offset1.
  • the virtual address of the data may be jointly identified by the identifier of the virtual area and the virtual offset.
  • the first virtual address of the first data may be jointly identified by the identifier of the first virtual area and the first virtual offset.
  • the virtual address recorded in the metadata of the data D may be: vzone1voffset1.
  • vzone1 represents the identifier of the virtual zone of data D
  • voffset1 represents the virtual offset of data D.
  • vzone1 + voffset1 is highly similar to the way of representing the storage address "zone1 + offset1", and therefore has advantages such as being easily understood by device managers.
  • virtual addresses can also take other forms. For example, you can use hexadecimal numbers, Roman letters, English letters to describe virtual addresses, or a combination of multiple symbols to describe virtual addresses, as long as it can indicate that "zone + offset” has a corresponding relationship.
  • the first 48KB of zone1 is represented by the letter AAA1
  • the second 48KB of zone1 is represented by the letter AA2
  • the third 48KB of zone1 is represented by the letter AA3, and so on.
  • the storage address of the data in the storage device is jointly determined by the storage area ID and the storage offset in the storage area, and the virtual address of the data is collectively identified by the identification of the virtual area and the virtual offset
  • the corresponding mapping of the data The relationship can be expressed by the mapping relationship between the identification of the virtual area and the storage area, and the mapping relationship between the virtual offset and the storage offset.
  • the first mapping relationship corresponding to the first data may include:
  • mapping relationship between the identifier of the first virtual area and the first storage area and the mapping relationship between the first virtual offset and the first storage offset.
  • mapping relationship corresponding to the first data is modified to a second mapping relationship, and the second mapping relationship may include:
  • mapping relationship between the identifier of the first virtual area and the second storage area and the mapping relationship between the first virtual offset and the second storage offset.
  • mapping relationship corresponding to the data can be represented by the mapping relationship between the identification of the virtual area and the storage area, and the mapping relationship between the virtual offset and the storage offset.
  • mapping relationship between the identification of the virtual area and the storage area can be represented by the mapping relationship between the identification of the virtual area and the storage area, and the mapping relationship between the virtual offset and the storage offset.
  • mapping relationship between the identification of the virtual area and the storage area may be saved in the form of a mapping table.
  • the storage device For a piece of data in a storage device, when the data is written to the hard disk of the storage device for the first time, the storage device assigns a virtual area identifier to the data.
  • the virtual area identifier may be a virtual area identifier that already exists in the mapping table. ID for the new virtual area. If it is an existing virtual area identifier, the storage device may directly use the mapping relationship of the existing virtual area identifier. If it is the identifier of the new virtual area, the storage device adds a mapping relationship between the identifier of the new virtual area and the storage area to the mapping table according to the storage area allocated for the data. After the data is migrated, the storage device modifies the storage area corresponding to the identifier of the virtual area into the migrated storage area in the above mapping table. When the data needs to be read, query the above mapping table to get the data storage area.
  • mapping table may be as shown in Table 3 below.
  • mapping table After data D is migrated from zone1 to zone2, the above mapping table is modified into the form shown in Table 4 below.
  • mapping relationship between the virtual offset and the storage offset may be determined by a preset formula.
  • a virtual offset corresponding to the storage offset may be directly calculated by using a preset first formula.
  • a storage offset corresponding to the virtual offset may be calculated by a preset second formula, and further, data is read from a position corresponding to the storage offset.
  • the first formula may be the following formula (1)
  • the second formula may be the following formula (2).
  • Voffset offset + gctimes * sizeof (zone) (1)
  • offset is the storage offset allocated by the storage device for the data to be stored
  • zone is the ID of the storage area allocated by the storage device for the data to be stored
  • gctimes is the number of migrations of the virtual area allocated by the storage device for the data to be stored.
  • each virtual area allocated by the storage device may correspond to a migration identifier, and the migration identifier is used to identify the number of migration times of the virtual area.
  • the migration identifier corresponding to the first virtual area is used to identify Number of migrations of a virtual area.
  • the initial value of the migration identifier can be 0.
  • the storage device can update the migration identifier. For example, the storage device can add 1 to the value of the original migration identifier as the new migration identifier.
  • the virtual offset of the newly written data will not overlap with the virtual offset of the already written data. To avoid errors when reading and writing data.
  • voffset is the virtual offset of data
  • zone is the ID of the storage area allocated by the storage device for the data to be stored.
  • the storage area of the data may be preferably searched according to the identification of the virtual area of the data, and further, the above-mentioned formula (2) is used to determine the storage offset of the data.
  • mapping relationship between the virtual offset and the storage offset may be saved in the form of a mapping table.
  • the storage device For a piece of data in a storage device, when the data is written to the hard disk of the storage device for the first time, the storage device allocates a virtual area identifier, a storage area, and a storage offset for the data. Further, the storage device determines the virtual Offset, and saves the correspondence between the storage offset and the virtual offset in a mapping table. After the data is migrated, after the data is migrated, the storage device modifies the storage offset corresponding to the virtual offset into the migrated storage offset in the mapping table. When you need to read the data, you can query the mapping table to get the storage offset of the data.
  • the storage area allocated by the storage device for the data D is zone1
  • the virtual offset is voffset1
  • the storage offset allocated for the data D is offset1.
  • mapping table is modified into the form shown in Table 6 below.
  • the combined implementation process is:
  • the storage device can determine the virtual offset corresponding to the storage offset of the data according to the above formula (1). At this time, the correspondence between the storage offset and the virtual offset can be regarded as It is represented by the formula (1), and there is no need to record the corresponding relationship between the two in the storage device.
  • the storage offset corresponding to the virtual offset of the data changes. At this time, the correspondence between the virtual offset of the data and the migrated storage offset can be written into the mapping table.
  • the storage device may first determine whether a mapping table of the virtual offset and the storage offset currently exists, and if it exists, further determine whether there is a virtual offset of the data in the mapping table.
  • the storage offset corresponding to the virtual offset is the storage offset of the data. If there is no virtual offset of the data, or there is no mapping table of the virtual offset and the storage offset, you can follow
  • the above formula (1) determines the storage offset corresponding to the virtual offset of the data. At this time, the correspondence between the storage offset and the virtual offset can be regarded as represented by the formula (2).
  • the storage device may store data according to the foregoing optional representation manner, and establish a mapping relationship corresponding to the data.
  • FIG. 3 is the storage structure of the file BB.doc in the tree structure of the file system
  • the first layer of the tree structure that is, the root
  • the mapping relationship between the identifier of the virtual area and the storage area is stored in the first mapping table
  • the mapping relationship between the virtual offset and the storage offset is stored in the second mapping table or expressed by a formula.
  • the content stored in the storage area and the storage address determined by the storage offset is the tree.
  • the content of the second layer of the shape structure includes the identifier of the virtual area of "AA” and the virtual offset, and the mapping relationship between the identifier of the virtual area and the storage area is stored in the first mapping table, and the virtual offset
  • the mapping relationship with the storage offset is stored in the second mapping table or expressed by a formula. Through these two mapping relationships, the storage device can know the storage area and storage offset of "AA”.
  • the content stored in the storage area and the storage address determined by the storage offset is a tree structure.
  • the content of the third layer which includes the identification of the virtual area of "BB.doc" and the virtual offset, the storage device continues to follow the mapping relationship, and finally obtains the storage address of "BB.doc".
  • the metadata recorded in each layer of the tree structure includes the identification of the virtual area and the virtual offset, rather than the storage area ID and storage offset of the data. Therefore, after the data is migrated, The metadata in each layer of the tree structure does not need to be modified, but only the corresponding mapping relationship can be modified.
  • FIG. 4 is a schematic flowchart of writing second data in a storage device. As shown in FIG. 4, the writing process includes:
  • S401 Allocate an identifier of a second virtual area to the second data to be stored, and allocate a third storage area corresponding to a third storage address for storing the second data.
  • the storage device After determining the second data storage, the storage device first allocates a virtual area identifier and a storage area for the second data, that is, the identifier of the second virtual area and the third storage area.
  • the storage device may allocate a virtual area identifier and a storage area for the second data according to a preset policy.
  • the storage device After the identifier of the virtual area and the storage area are allocated for the second data, the storage device further allocates a storage offset for the second data, that is, a third storage offset.
  • the storage device may allocate a storage offset for the second data starting from the first free storage offset of the allocated storage area.
  • the size of the data is not the same. Therefore, the storage offset occupied by one data may be one or more. Therefore, the storage described in the embodiment of the present application
  • the offset can be regarded as the starting position of the data in the storage area.
  • the storage device needs to further combine the length of the data to obtain the complete storage offset of the data, which can also be stored in the metadata of the data at the same time.
  • the storage address allocated by the storage device for the second data is the storage area zone2 + storage offset offset2.
  • the starting position of the second data is a position 48KB from the starting position of zone2.
  • the second data has length information, for example, the length is 20 KB.
  • the storage device After determining the third storage area and the third storage offset for storing the second data, the storage device determines the storage address of the second data, that is, the third storage address. Further, in this step, the storage device The two data are written into a third storage address determined by the third storage area and the third storage offset.
  • the storage device starts from the starting position indicated by the third storage offset, and writes the second data into the starting position and the subsequent storage positions in a sequential writing manner.
  • the storage device records the identifier of the virtual area allocated for the second data and the determined second virtual offset in the metadata of the second data.
  • the storage device further writes length information of the second data into metadata of the second data.
  • the storage device may establish the mapping relationship between the identifier of the second virtual area and the third storage area according to the method described in the corresponding description in Table 3 above, and establish the first relationship according to the method described in the foregoing formula (1) or table (5).
  • the mapping relationship between the second virtual offset and the third storage offset is not repeated here.
  • FIG. 5 is a schematic flowchart of reading the first data from a storage device. As shown in FIG. 5, the process of reading the first data includes:
  • the first storage address when the foregoing first storage address is expressed in a "storage area + storage offset" manner, the first storage address includes a first storage area ID and a first storage offset, and the first virtual address includes a first The identification of the virtual area and the first virtual offset. Furthermore, according to the foregoing embodiment, it can be known that the first mapping relationship corresponding to the first data includes the mapping relationship between the identifier of the first virtual area and the first storage area, and the mapping between the first virtual offset and the first storage offset. relationship.
  • the identifier of the first virtual area corresponding to the first data and the first virtual offset may be obtained first through the metadata of the first data, and further, according to the identifier of the first virtual area and the first storage, Area mapping relationship to obtain a first storage area ID corresponding to the first storage address, and to obtain a first storage area corresponding to the first storage address according to the mapping relationship between the first virtual offset and the first storage offset Stores the offset.
  • the storage device may obtain the first storage area ID corresponding to the first storage address by reading the mapping table.
  • the storage device may obtain the first storage offset corresponding to the first storage address by using the foregoing formula (2).
  • the storage device After obtaining the first storage area of the first data and the first storage offset, the storage device obtains the starting storage position of the first data. The storage device can further combine the length information of the first data to read the complete first data. data.
  • the storage device first addresses a position within zone1 which is 48KB from the starting position of zone1. This position is the starting position of the first data. From this position, 20KB is sequentially read.
  • the read data is the first data. Full content.
  • FIG. 6 is a schematic block diagram of a data migration apparatus 600 according to an embodiment of the present application.
  • the apparatus is applied to a storage device.
  • the device may be a controller of the storage device, or be a part of the controller of the storage device.
  • the first data is stored in a first storage address
  • a first virtual address is recorded in the metadata of the first data
  • the apparatus 600 includes: a processing module 601.
  • a processing module 601 configured to migrate the first data from the first storage address to the second storage address
  • the first mapping relationship is adjusted to a second mapping relationship
  • the second mapping relationship is a correspondence relationship between the second storage address and the first virtual address.
  • the storage address is jointly determined by a storage area ID and a storage offset in the storage area.
  • the first virtual address is jointly identified by an identifier of the first virtual area and a first virtual offset.
  • the first mapping relationship includes a mapping relationship between the identifier of the first virtual area and the first storage area, and a relationship between the first virtual offset and the first storage offset. Mapping relations.
  • the second mapping relationship includes a mapping relationship between the identifier of the first virtual area and the second storage area, and a mapping relationship between the first virtual offset and the second storage offset.
  • processing module 601 is further configured to:
  • a migration identifier is updated, and the migration identifier is used to identify the number of migration times of the first virtual area.
  • processing module 601 is further configured to:
  • An identifier of a second virtual area is allocated to the second data to be stored, and a third storage area corresponding to a third storage address used to store the second data is allocated.
  • a third storage offset in a third storage area is allocated to the second data, and the third storage area and the third storage offset jointly determine the third storage address.
  • the third mapping relationship includes: a mapping relationship between an identifier of the second virtual area and a third storage area, and a mapping between the second virtual offset and a third storage offset relationship.
  • processing module 601 is further configured to:
  • processing module 601 is specifically configured to:
  • a first storage area ID corresponding to the first storage address is obtained.
  • a first storage offset corresponding to the first storage address is obtained.
  • the mapping relationship between the first virtual offset and the first storage offset is identified by a mapping table of the first virtual offset and the first storage offset, or by a preset
  • the formula is OK.
  • FIG. 7 is a physical block diagram of a storage device 700 according to an embodiment of the present application.
  • the storage device includes a controller 701 and at least one hard disk 702.
  • the controller 701 is configured to manage data stored in the hard disk 702.
  • the first data is stored in a first storage address, a first virtual address is recorded in the metadata of the first data, and there is a first mapping relationship between the first storage address and the first virtual address.
  • the controller 701 is also used for:
  • the first mapping relationship is adjusted to a second mapping relationship
  • the second mapping relationship is a correspondence relationship between the second storage address and the first virtual address.
  • the storage address is jointly determined by a storage area ID and a storage offset in the storage area.
  • the first virtual address is jointly identified by an identifier of the first virtual area and a first virtual offset.
  • the first mapping relationship includes a mapping relationship between the identifier of the first virtual area and the first storage area, and a relationship between the first virtual offset and the first storage offset. Mapping relations.
  • the second mapping relationship includes a mapping relationship between the identifier of the first virtual area and the second storage area, and a mapping relationship between the first virtual offset and the second storage offset.
  • controller 701 is further configured to:
  • a migration identifier is updated, and the migration identifier is used to identify the number of migration times of the first virtual area.
  • controller 701 is further configured to:
  • An identifier of a second virtual area is allocated to the second data to be stored, and a third storage area corresponding to a third storage address used to store the second data is allocated.
  • a third storage offset in a third storage area is allocated to the second data, and the third storage area and the third storage offset jointly determine the third storage address.
  • the third mapping relationship includes: a mapping relationship between an identifier of the second virtual area and a third storage area, and a mapping between the second virtual offset and a third storage offset relationship.
  • controller 701 is further configured to:
  • controller 701 is specifically configured to:
  • a first storage area ID corresponding to the first storage address is obtained.
  • a first storage offset corresponding to the first storage address is obtained.
  • the mapping relationship between the first virtual offset and the first storage offset is identified by a mapping table of the first virtual offset and the first storage offset, or by a preset
  • the formula is OK.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be from a website site, computer, server, or data center Transmission by wire (for example, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) to another website site, computer, server, or data center.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, and the like that includes one or more available medium integration.
  • the available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (Solid State Disk (SSD)), and the like.
  • a magnetic medium for example, a floppy disk, a hard disk, a magnetic tape
  • an optical medium for example, a DVD
  • a semiconductor medium for example, a solid state disk (Solid State Disk (SSD)
  • this application may be provided as a method, a system, or a computer program product. Therefore, this application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to work in a particular manner such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device, the instructions
  • the device implements the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing device, so that a series of steps can be performed on the computer or other programmable device to produce a computer-implemented process, which can be executed on the computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.

Abstract

Provided are a data migration method and apparatus and a storage device. First data is stored in a first storage address, a first virtual address is recorded in metadata of the first data, and there is a first mapping relationship between the first storage address and the first virtual address. The method comprises: the storage device migrating the first data from the first storage address to a second storage address; and the storage device adjusting the first mapping relationship to a second mapping relationship, wherein the second mapping relationship is a correlation between the second storage address and the first virtual address. According to the method, after the first data is migrated, a storage address in the metadata of the first data does not need to be modified, thereby greatly improving the metadata management efficiency.

Description

数据迁移方法、装置及存储设备Data migration method, device and storage device 技术领域Technical field
本申请实施例涉及通信技术领域,尤其涉及一种数据迁移方法、装置及存储设备。The embodiments of the present application relate to the field of communications technologies, and in particular, to a data migration method, device, and storage device.
背景技术Background technique
一些电子设备中包括写入前需要首先擦除的存储介质,这些存储介质中包括多个存储区域。该存储区域内部采用追加写的方式写入数据。当该存储区域内的存储地址按照顺序被写满后,可能需要对该存储区域执行垃圾回收(garbage collection,GC)过程。GC过程是指:当该存储区域内的存储地址按照顺序被写满后,如果删除了该存储区域内的一部分数据,则由于剩余的数据占据了存储空间导致删除了该一部分数据之后的存储空间不可用,因此,需要将该存储区域内的数据迁移,并重置该存储区域。Some electronic devices include storage media that need to be erased before writing, and these storage media include multiple storage areas. Data is written into the storage area in an additional write manner. After the storage addresses in the storage area are filled in order, a garbage collection (GC) process may need to be performed on the storage area. The GC process refers to: after the storage address in the storage area is filled up in order, if a part of the data in the storage area is deleted, the storage space after the partial data is deleted because the remaining data occupies the storage space Not available, so you need to migrate the data in the storage area and reset the storage area.
现有技术中,通过元数据记录数据的存储地址信息,元数据的组织形式为树形结构。当执行上述GC过程之后,需要从被迁移的数据对应的叶子节点元数据开始,向上逐层修改元数据。In the prior art, the storage address information of data is recorded through metadata, and the metadata is organized in a tree structure. After the above GC process is performed, it is necessary to start from the leaf node metadata corresponding to the migrated data and modify the metadata layer by layer.
但是,现有技术的方法会导致元数据管理效率低下。However, the prior art methods lead to inefficient metadata management.
发明内容Summary of the Invention
本申请实施例提供一种数据迁移方法、装置及存储设备,用于解决现有技术中数据管理效率低下的问题。The embodiments of the present application provide a data migration method, device, and storage device, which are used to solve the problem of low data management efficiency in the prior art.
本申请实施例第一方面提供一种数据迁移方法,该方法应用于存储设备,该存储设备包括控制器和至少一个硬盘,该控制器用于对硬盘存储的数据进行管理。第一数据存储在第一存储地址,第一数据的元数据中记录有第一虚拟地址,该第一存储地址与第一虚拟地址之间有第一映射关系,该方法包括:A first aspect of the embodiments of the present application provides a data migration method. The method is applied to a storage device. The storage device includes a controller and at least one hard disk. The controller is configured to manage data stored in the hard disk. The first data is stored in a first storage address, and a first virtual address is recorded in the metadata of the first data. There is a first mapping relationship between the first storage address and the first virtual address. The method includes:
存储设备将第一数据从上述第一存储地址迁移到第二存储地址,进而,存储设备将上述第一映射关系调整为第二映射关系,其中,该第二映射关系是上述第二存储地址与上述第一虚拟地址的对应关系。The storage device migrates the first data from the first storage address to the second storage address, and further, the storage device adjusts the first mapping relationship to a second mapping relationship, where the second mapping relationship is the second storage address and The corresponding relationship of the first virtual address.
该方法中,第一数据的元数据中记录第一虚拟地址,在第一数据迁移前,存储设备中记录第一虚拟地址与存储第一数据的第一存储地址之间的第一映射关系,当第一数据从第一存储地址迁移到第二存储地址后,仅需要将第一映射关系修改为第一虚拟地址与第二存储地址的第二映射关系即可,从而无需修改第一数据的元数据,同时又能保证第一数据在迁移后仍然能正确的访问,因此,本实施例在保证数据被正确访问的同时极大减少了元数据的修改次数,从而极大提升了元数据的管理效率,减少了存储系统的负载。In the method, a first virtual address is recorded in metadata of the first data, and a first mapping relationship between the first virtual address and the first storage address storing the first data is recorded in the storage device before the first data is migrated, After the first data is migrated from the first storage address to the second storage address, only the first mapping relationship needs to be modified to the second mapping relationship between the first virtual address and the second storage address, so that there is no need to modify the first data The metadata can also ensure that the first data can still be accessed correctly after the migration. Therefore, this embodiment greatly reduces the number of metadata modification times while ensuring that the data is correctly accessed, thereby greatly improving the metadata. Management efficiency reduces the load on the storage system.
在一种可能的设计中,上述存储地址通过存储区域ID以及存储区域内的存储偏移量共同确定。In a possible design, the storage address is determined by a storage area ID and a storage offset in the storage area.
在一种可能的设计中,上述第一虚拟地址通过第一虚拟区域的标识以及第一虚拟偏移量共同标识。In a possible design, the first virtual address is jointly identified by the identifier of the first virtual area and the first virtual offset.
在一种可能的设计中,上述第一映射关系包括:上述第一虚拟区域的标识与第一存储 区域的映射关系,以及,上述第一虚拟偏移量与第一存储偏移量的映射关系。In a possible design, the first mapping relationship includes a mapping relationship between the identifier of the first virtual area and the first storage area, and a mapping relationship between the first virtual offset and the first storage offset. .
上述第二映射关系包括:上述第一虚拟区域的标识与第二存储区域的映射关系,以及,上述第一虚拟偏移量与第二存储偏移量的映射关系。The second mapping relationship includes a mapping relationship between the identifier of the first virtual area and the second storage area, and a mapping relationship between the first virtual offset and the second storage offset.
在一种可能的设计中,在存储设备将上述第一映射关系调整为第二映射关系之后,还可以执行下述过程:In a possible design, after the storage device adjusts the first mapping relationship to the second mapping relationship, the following process may also be performed:
在存储设备将上述第一存储地址对应的存储区域中的数据全部迁移至上述第二存储地址对应的存储区域后,上述存储设备更新迁移标识,该迁移标识用于标识上述第一虚拟区域的迁移次数。After the storage device migrates all the data in the storage area corresponding to the first storage address to the storage area corresponding to the second storage address, the storage device updates a migration identifier, which is used to identify the migration of the first virtual area. frequency.
在一种可能的设计中,上述方法还包括:In a possible design, the above method further includes:
为待存储的第二数据分配第二虚拟区域的标识以及分配用于存储所述第二数据的第三存储地址所对应的第三存储区域;Assigning an identifier of a second virtual area to the second data to be stored and assigning a third storage area corresponding to a third storage address for storing the second data;
为所述第二数据分配第三存储区域内的第三存储偏移量,所述第三存储区域和所述第三存储偏移量共同确定所述第三存储地址;Assigning a third storage offset in a third storage area to the second data, and the third storage area and the third storage offset jointly determine the third storage address;
根据所述第三存储偏移量以及所述迁移标识确定所述第二数据对应的第二虚拟偏移量;Determining a second virtual offset corresponding to the second data according to the third storage offset and the migration identifier;
将所述第二数据写入所述第三存储地址,并在所述第二数据的元数据中记录所述第二虚拟区域的标识以及所述第二虚拟偏移量;Writing the second data into the third storage address, and recording the identifier of the second virtual area and the second virtual offset in metadata of the second data;
建立第三映射关系,所述第三映射关系包括:所述第二虚拟区域的标识与第三存储区域的映射关系,以及,所述第二虚拟偏移量与第三存储偏移量的映射关系。Establishing a third mapping relationship, where the third mapping relationship includes: a mapping relationship between an identifier of the second virtual area and a third storage area, and a mapping between the second virtual offset and a third storage offset relationship.
该方法中,在确定待存储数据的存储位置时,结合迁移标识进行确定,可以使得数据发生迁移后,新写入的数据的虚拟偏移量不会与已写入的数据的虚拟偏移量出现重复,避免数据读写时发生错误。In this method, when determining the storage location of the data to be stored, the determination is made in combination with the migration identifier, so that after the data is migrated, the virtual offset of the newly written data will not be different from the virtual offset of the already written data. Duplicates occur to avoid errors when reading and writing data.
在一种可能的设计中,所述方法还包括:In a possible design, the method further includes:
根据所述第一映射关系以及所述第一数据的元数据中所记录的第一虚拟地址,确定存储所述第一数据的所述第一存储地址;Determining the first storage address storing the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data;
从所述第一存储地址读取所述第一数据。Reading the first data from the first storage address.
在一种可能的设计中,所述根据所述第一映射关系以及所述第一数据的元数据中所记录的第一虚拟地址,确定存储所述第一数据的所述第一存储地址,包括:In a possible design, the determining the first storage address storing the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data, include:
根据所述第一虚拟区域的标识与第一存储区域的映射关系,得到所述第一存储地址对应的第一存储区域ID;Obtaining a first storage area ID corresponding to the first storage address according to a mapping relationship between the identifier of the first virtual area and the first storage area;
根据所述第一虚拟偏移量与第一存储偏移量的映射关系,得到所述第一存储地址对应的第一存储偏移量;Obtaining a first storage offset corresponding to the first storage address according to the mapping relationship between the first virtual offset and the first storage offset;
其中,所述第一虚拟偏移量与第一存储偏移量的映射关系通过所述第一虚拟偏移量与所述第一存储偏移量的映射表进行标识,或者,通过预设的公式确定。The mapping relationship between the first virtual offset and the first storage offset is identified by a mapping table of the first virtual offset and the first storage offset, or by a preset The formula is OK.
本申请实施例第二方面提供一种数据迁移装置,应用于存储设备,该装置可以是存储设备中的控制器,或者是控制器的一部分。第一数据存储在第一存储地址,所述第一数据的元数据中记录有第一虚拟地址,所述第一存储地址与所述第一虚拟地址之间有第一映射关系。A second aspect of the embodiments of the present application provides a data migration device, which is applied to a storage device, and the device may be a controller in the storage device or a part of the controller. The first data is stored in a first storage address, a first virtual address is recorded in the metadata of the first data, and there is a first mapping relationship between the first storage address and the first virtual address.
该装置可以实现上述第一方面中的功能。这些功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。This device can implement the functions in the first aspect described above. These functions can be realized by hardware, and can also be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the functions described above.
在一种可能的设计中,该装置可以包括处理模块,该处理模块可以执行上述方法中的相应功能,例如:处理模块,用于将第一数据从所述第一存储地址迁移到第二存储地址;以及,In a possible design, the device may include a processing module, which may perform a corresponding function in the above method, for example, a processing module, configured to migrate the first data from the first storage address to the second storage. Address; and,
将所述第一映射关系调整为第二映射关系,所述第二映射关系是所述第二存储地址与所述第一虚拟地址的对应关系。Adjusting the first mapping relationship to a second mapping relationship, where the second mapping relationship is a correspondence between the second storage address and the first virtual address.
本申请实施例第三方面提供一种存储设备,该存储设备包括控制器和至少一个硬盘,该控制器用于对硬盘存储的数据进行管理,第一数据存储在第一存储地址,所述第一数据的元数据中记录有第一虚拟地址,所述第一存储地址与所述第一虚拟地址之间有第一映射关系,该控制器还用于执行上述第一方面所述的方法。A third aspect of the embodiments of the present application provides a storage device. The storage device includes a controller and at least one hard disk. The controller is configured to manage data stored in the hard disk. The first data is stored at a first storage address. A first virtual address is recorded in the metadata of the data, and there is a first mapping relationship between the first storage address and the first virtual address. The controller is further configured to execute the method according to the first aspect.
本申请实施例第四方面提供一种计算机程序产品,所述计算机程序产品包括计算机程序代码,当所述计算机程序代码被计算机执行时,使得所述计算机执行第一方面所述的方法。A fourth aspect of the embodiments of the present application provides a computer program product, where the computer program product includes computer program code, and when the computer program code is executed by a computer, causes the computer to execute the method described in the first aspect.
本申请实施例第五方面提供一种计算机可读存储介质,所述计算机存储介质存储有计算机指令,当所述计算机指令被计算机执行时,使得所述计算机执行上述第一方面所述的方法。A fifth aspect of the embodiments of the present application provides a computer-readable storage medium. The computer storage medium stores computer instructions. When the computer instructions are executed by a computer, the computer is caused to execute the method described in the first aspect.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为该文件BB.doc在文件系统的树形结构中的存储结构;Figure 1 shows the storage structure of the file BB.doc in the tree structure of the file system;
图2为本申请实施例提供的数据迁移方法实施例的流程示意图;2 is a schematic flowchart of an embodiment of a data migration method according to an embodiment of the present application;
图3为该文件BB.doc在文件系统的树形结构中的存储结构;Figure 3 shows the storage structure of the file BB.doc in the tree structure of the file system;
图4为在存储设备中写入第二数据的流程示意图;4 is a schematic flowchart of writing second data in a storage device;
图5为从存储设备中读取上述第一数据的流程示意图;5 is a schematic flowchart of reading the first data from a storage device;
图6为本申请实施例提供的一种数据迁移装置600的模块示意图;FIG. 6 is a schematic block diagram of a data migration device 600 according to an embodiment of the present application;
图7为本申请实施例提供的一种存储设备700的实体框图。FIG. 7 is a physical block diagram of a storage device 700 according to an embodiment of the present application.
具体实施方式detailed description
存储设备可以通过文件系统组织文件,文件系统可以看作是存储设备的操作系统用于明确存储设备上的文件的方法和数据结构。在文件系统中,可以将数据分为数据文件和元数据,其中,数据文件是存储设备上所保存的文件。元数据可以看作是描述数据的数据,元数据中可以保存数据的属主、大小、权限、时间戳、链接以及数据在存储设备的磁盘上的存储地址等信息。文件系统可以采用树形结构进行管理。The storage device can organize files through a file system, and the file system can be regarded as a method and a data structure of the storage device's operating system for specifying the files on the storage device. In the file system, data can be divided into data files and metadata, where the data file is a file stored on a storage device. Metadata can be regarded as data describing data. The metadata can hold information such as the owner, size, permissions, timestamp, link, and storage address of the data on the disk of the storage device. The file system can be managed in a tree structure.
假设文件系统中保存了一个文件BB.doc,该文件BB.doc的存储位置为“/AA/BB.doc”,则图1为该文件BB.doc在文件系统的树形结构中的存储结构,如图1所示,树形结构的第一层,即根部,为“/”这个根目录的存储地址。进而,在树形结构的第二层,为根目录的存储地址中所存储的内容,该内容包括“AA”的元数据以及根目录下所包括的其他文件或目录的信息。根据第二层中所记录的“AA”的元数据,可以获知“AA”的存储地址,进 而,在树形结构的第三层,为“AA”的存储地址中所存储的内容,该内容包括“BB.doc”的元数据以及“AA”这个目录下所包括的其他文件或目录的信息。根据第三层中所记录的“AA”的元数据,可以获知“BB.doc”的存储地址,进而,在树形结构的第四层,为“BB.doc”的存储地址中所存储的内容,即“BB.doc”这个文件对应的数据。Assume that a file BB.doc is stored in the file system, and the storage location of the file BB.doc is "/AA/BB.doc", then Figure 1 is the storage structure of the file BB.doc in the tree structure of the file system As shown in Figure 1, the first layer of the tree structure, the root, is the storage address of the root directory "/". Furthermore, in the second layer of the tree structure, the content stored in the storage address of the root directory includes metadata of "AA" and information of other files or directories included in the root directory. According to the metadata of "AA" recorded in the second layer, the storage address of "AA" can be obtained. Furthermore, in the third layer of the tree structure, the content stored in the storage address of "AA", the content Includes "BB.doc" metadata and information on other files or directories contained in the "AA" directory. According to the metadata of "AA" recorded in the third layer, the storage address of "BB.doc" can be obtained. Furthermore, in the fourth layer of the tree structure, the storage address of "BB.doc" is stored. Content, which is the data corresponding to the file "BB.doc".
由上述存储结构可知,文件系统中文件的存储地址通过元数据记录,并且按照树形的结构逐层记录。It can be known from the above storage structure that the storage address of a file in the file system is recorded by metadata, and is recorded layer by layer according to a tree structure.
对于不同的硬盘类型,其存储地址的表示方式可能存在差异。以下以叠瓦式磁记录(shingled magnetic recording,SMR)和固态硬盘(solid-state drive,SSD)为例进行说明,SMR有时也称为SMR盘或者SMR硬盘。For different types of hard disks, the storage address may be expressed differently. In the following, shingled magnetic recording (SMR) and solid-state drive (SSD) are used as examples. SMR is sometimes also called SMR disk or SMR hard disk.
在SMR硬盘中,通过“zone+offset”的方式表示数据的存储地址。在有必要的情况下(例如在读数据时),还可以用长度(length)参数描述数据的长度。In the SMR hard disk, the storage address of the data is represented by "zone + offset". When necessary (such as when reading data), you can also use the length parameter to describe the length of the data.
其中,SMR硬盘由多个zone(区域)组成,每个zone可以看作是SMR硬盘内的一个存储区域。offset(偏移量)描述了在zone内的一个具体位置,例如(zone3,48KB)描述的是距离zone3的起始位置48KB的位置。理论上offset可以是大于0的任意数值,只要不超过zone的长度即可。在实际产品中,为了方便数据的管理,offset可以用48K字节的整数倍作为粒度。Among them, the SMR hard disk is composed of multiple zones (areas), and each zone can be regarded as a storage area in the SMR hard disk. offset (offset) describes a specific position within the zone, for example (zone3, 48KB) describes a position 48KB away from the starting position of zone3. In theory, the offset can be any value greater than 0, as long as it does not exceed the length of the zone. In actual products, in order to facilitate data management, offset can use an integer multiple of 48K bytes as the granularity.
在SSD中,通过“page组+offset”的方式表示数据的存储地址,其中,SSD可以包括多个page,这些page(页)可以划分为多个page组,每个page组可以看作是SSD内的一个存储区域。在每个page组内可以划分为多个offset。offset可以以字节为单位,或者,也可以以page为单位。示例性的,如果offset以page为单位,则某个offset可以表示为某个page组内的“第2个page始,至第3个page结束”,或者,offset仅描述某个page组内“从第二个page作为起始page”,用额外的长度参数描述结束page。In the SSD, the storage address of the data is expressed in the form of "page group + offset". The SSD can include multiple pages. These pages can be divided into multiple page groups. Each page group can be regarded as the SSD. Within a storage area. It can be divided into multiple offsets in each page group. offset can be in bytes, or it can be in pages. Exemplarily, if the offset is in units of a page, an offset can be expressed as "beginning of the second page and ending at the third page" in a certain page group, or offset only describes "in a certain page group" From the second page as the starting page ", the end page is described with an additional length parameter.
由以上对SMR硬盘和SSD的介绍可以看出,这两种介质都可以使用“zone+offset”的方式描述数据的存储位置。As can be seen from the above introduction of SMR hard disks and SSDs, both types of media can use "zone + offset" to describe the storage location of data.
以上述的SMR硬盘为例,假设某存储设备的SMR硬盘上存储有“BB.doc”这个文件,该文件在SMR硬盘上的存储地址为“zone1+offset1”,即该文件的数据存储在SMR硬盘上的zone1这个存储区域内的offset1上(换句话说,在zone1的offset1作为存储BB.doc的起始位置)。该文件在该存储设备的文件系统中的存储路径为上述图1对应描述中的路径,则在现有技术中,在文件系统的树形结构中,第三层中记录“zone1+offset1”这个存储地址,第二层中记录“AA”的存储地址,第一层中记录“/”的存储地址。Taking the above SMR hard disk as an example, it is assumed that the file "BB.doc" is stored on the SMR hard disk of a storage device, and the storage address of the file on the SMR hard disk is "zone1 + offset1", that is, the data of the file is stored in the SMR On the hard disk, zone1 is located in offset1 (in other words, offset1 in zone1 is used as the starting position for storing BB.doc). The storage path of the file in the file system of the storage device is the path described in the corresponding description of FIG. 1. In the prior art, in the tree structure of the file system, the “zone1 + offset1” is recorded in the third layer. Storage address, the storage address of "AA" is recorded in the second layer, and the storage address of "/" is recorded in the first layer.
在此基础上,如果“BB.doc”所在的zone1的数据进行了GC,zone1的有效数据进行了迁移,假设zone1的有效数据被迁移至zone2,并且“BB.doc”被迁移至了zone2中的offset2,则“BB.doc”的存储地址从迁移前的“zone1+offset1”变为“zone2+offset2”。在该技术中,需要首先修改第三层中记录的“BB.doc”的存储地址,将其值从“zone1+offset1”修改为“zone2+offset2”,进而,需要逐层向上修改第二层中记录的“AA”的存储地址以及第一层中记录的“/”的存储地址。而zone1中可能存储了大量的数据,当这些数据被迁移之后,这些数据的元数据均需要修改。On this basis, if the data of zone1 where "BB.doc" is GC, the valid data of zone1 is migrated, assuming that the valid data of zone1 is migrated to zone2 and "BB.doc" is migrated to zone2 Offset2, the storage address of "BB.doc" is changed from "zone1 + offset1" before migration to "zone2 + offset2". In this technology, the storage address of "BB.doc" recorded in the third layer needs to be modified first, and its value is changed from "zone1 + offset1" to "zone2 + offset2". Furthermore, the second layer needs to be modified layer by layer. The storage address of "AA" recorded in the and the storage address of "/" recorded in the first layer. A large amount of data may be stored in zone1. After the data is migrated, the metadata of the data needs to be modified.
因此,使用上述的方法,当硬盘执行了GC,文件系统中数据文件的存储位置变化之后, 需要进行多次的元数据修改,从而导致硬盘的数据管理效率低下。Therefore, using the above method, when the hard disk performs GC and the storage location of the data files in the file system changes, multiple metadata modifications need to be performed, resulting in low data management efficiency of the hard disk.
本申请实施例的技术方案,可以解决上述问题。The technical solutions in the embodiments of the present application can solve the foregoing problems.
需要说明的是,本申请实施例所述的“存储地址”,是指操作系统层面上用来标识数据存储位置的地址,在具体实施过程中,该“存储地址”需要经过操作系统以下的底层软件进行进一步的转换后,得到硬盘上的实际物理地址。该转换的具体过程可以参照现有技术中的方法,本申请实施例对此不做具体限定。存储地址可以是上面所提到的zone+offset。It should be noted that the "storage address" described in the embodiments of the present application refers to the address used to identify the data storage location at the operating system level. In the specific implementation process, the "storage address" needs to pass through the bottom layer below the operating system. After the software performs further conversion, the actual physical address on the hard disk is obtained. The specific process of the conversion may refer to the method in the prior art, which is not specifically limited in the embodiment of the present application. The storage address can be zone + offset mentioned above.
图2为本申请实施例提供的数据迁移方法实施例的流程示意图,该方法的执行主体为上述存储设备,该存储设备可以是台式电脑、笔记本电脑、服务器、存储控制器+硬盘等具有数据存储功能的设备。该存储设备包括控制器和至少一个硬盘,该控制器用于对硬盘存储的数据进行管理。对于非专用存储设备,从功能上可以把处理器(或者处理器与其他辅助器件的组合,例如处理器和内存的组合)理解为存储控制器。FIG. 2 is a schematic flowchart of an embodiment of a data migration method provided by an embodiment of the present application. The method is executed by the foregoing storage device, and the storage device may be a desktop computer, a notebook computer, a server, a storage controller + hard disk, and the like having data storage. Functional device. The storage device includes a controller and at least one hard disk, and the controller is configured to manage data stored in the hard disk. For non-dedicated storage devices, a processor (or a combination of a processor and other auxiliary devices, such as a combination of a processor and a memory) can be understood as a storage controller from a functional perspective.
为便于理解,本实施例以第一数据为对象说明数据迁移的过程。该第一数据可以是存储设备的硬盘中的任意一个数据。示例性的,该第一数据可以对应文件系统所管理的的一个文件。For ease of understanding, this embodiment uses the first data as an object to describe a data migration process. The first data may be any data in a hard disk of the storage device. Exemplarily, the first data may correspond to a file managed by the file system.
在进行数据迁移(例如进行GC所做的数据迁移,或者冷热数据分级存储所做的迁移,或者其他原因所做的数据迁移)之前,该第一数据存储在硬盘上的第一存储地址,而该第一数据的元数据中所记录的存储地址为第一虚拟地址,该第一存储地址与该第一虚拟地址之间具有一一对应关系,为了方便描述,我们称之为第一映射关系。Before performing data migration (for example, data migration by GC, migration by hot and cold data tiered storage, or data migration by other reasons), the first data is stored at a first storage address on a hard disk, The storage address recorded in the metadata of the first data is a first virtual address, and there is a one-to-one correspondence between the first storage address and the first virtual address. For convenience of description, we call it a first mapping. relationship.
可选的,上述第一虚拟地址并非一个存储地址,而是对存储地址进行了虚拟化,在第一数据的元数据中所记录的一个标识。该第一虚拟地址与第一存储地址之间具有第一映射关系,进而,通过元数据中所记录的第一虚拟地址以及该第一映射关系,可以获知第一数据的第一存储地址。本申请实施例中,引入了虚拟地址(虚拟化的存储地址),把在元数据中所记录的存储地址替换为在元数据中记录虚拟地址。因此,可以在数据的存储地址发生改变的情况下,只需要更新虚拟地址和存储地址之间的映射关系即可,元数据中的虚拟地址可保持不变。从而,避免了数据迁移所引起的元数据大量更新,提高了元数据管理效率,减少了存储系统的负载。Optionally, the first virtual address is not a storage address, but a virtualized storage address, and an identifier recorded in the metadata of the first data. The first virtual address and the first storage address have a first mapping relationship. Furthermore, the first storage address of the first data can be obtained through the first virtual address recorded in the metadata and the first mapping relationship. In the embodiment of the present application, a virtual address (virtualized storage address) is introduced, and the storage address recorded in the metadata is replaced with the virtual address recorded in the metadata. Therefore, when the storage address of the data is changed, it is only necessary to update the mapping relationship between the virtual address and the storage address, and the virtual address in the metadata can remain unchanged. Therefore, a large number of metadata updates caused by data migration are avoided, the metadata management efficiency is improved, and the load of the storage system is reduced.
如图2所示,该方法包括:As shown in Figure 2, the method includes:
S201、存储设备将第一数据从上述第一存储地址迁移到第二存储地址。S201. The storage device migrates the first data from the first storage address to the second storage address.
可选的,在本步骤之前,存储设备已经确定第一数据所在的存储区域需要进行GC。进而,在本步骤中,存储设备将第一数据从第一存储地址迁移到第二存储地址。Optionally, before this step, the storage device has determined that the storage area where the first data is located needs to be GC. Further, in this step, the storage device migrates the first data from the first storage address to the second storage address.
其中,上述“迁移”的过程具体可以为:The above-mentioned "migration" process may specifically be:
首先,将第一数据写入第二存储地址。可选的,后续可以将第一存储地址上所存储的第一数据进行删除。First, the first data is written into the second storage address. Optionally, the first data stored on the first storage address may be subsequently deleted.
S202、存储设备将上述第一映射关系调整为第二映射关系,该第二映射关系是上述第二存储地址与上述第一虚拟地址的对应关系。S202. The storage device adjusts the first mapping relationship to a second mapping relationship, where the second mapping relationship is a correspondence relationship between the second storage address and the first virtual address.
可选的,针对上述第一数据,当其保存至硬盘时,存储设备可以为该第一数据分配一个第一虚拟地址,并将该第一虚拟地址记录在第一数据的元数据中,进而,当第一数据从第一存储地址迁移到第二存储地址后,存储设备并不需要修改该第一虚拟地址,而仅修改 第一数据对应的映射关系,即将第一映射关系修改为第二映射关系。由于第一数据的第一存储地址可以通过元数据中记录的第一虚拟地址和第一数据对应的映射关系得到,因此,当第一数据发生迁移后,通过元数据中记录的第一虚拟地址以及修改后的第二映射关系,仍然可以获知第一数据的存储地址,同时,在此过程中,并未对第一数据的元数据进行修改。Optionally, when the first data is saved to a hard disk, the storage device may allocate a first virtual address to the first data, and record the first virtual address in the metadata of the first data, and further After the first data is migrated from the first storage address to the second storage address, the storage device does not need to modify the first virtual address, but only the mapping relationship corresponding to the first data, that is, the first mapping relationship is modified to the second Mapping relations. Because the first storage address of the first data can be obtained through the mapping relationship between the first virtual address recorded in the metadata and the first data, after the first data is migrated, the first virtual address recorded in the metadata is obtained. As well as the modified second mapping relationship, the storage address of the first data can still be obtained. At the same time, in this process, the metadata of the first data is not modified.
需要说明的是,这个映射关系(例如第一映射关系、第二映射关系)可以记录在元数据中,也可以自己录在其他位置。只要能够被处理器或者存储控制器读出即可。It should be noted that this mapping relationship (for example, the first mapping relationship and the second mapping relationship) may be recorded in the metadata, or may be recorded in another location by itself. As long as it can be read by the processor or memory controller.
可选的,上述第一映射关系和上述第二映射关系可以通过映射表的形式进行保存。示例性的,存储设备中可以保存一张数据的映射表,针对上述第一数据,在数据迁移之前,该映射表中记录第一映射关系,在数据迁移之后,该映射表中记录第二映射关系。下述表1为第一数据迁移之前的映射表的示例,下述表2为第一数据迁移之后的映射表的示例。Optionally, the first mapping relationship and the second mapping relationship may be stored in the form of a mapping table. Exemplarily, a mapping table of data may be stored in the storage device. For the above-mentioned first data, the first mapping relationship is recorded in the mapping table before data migration, and the second mapping is recorded in the mapping table after data migration. relationship. The following Table 1 is an example of the mapping table before the first data migration, and the following Table 2 is an example of the mapping table after the first data migration.
表1Table 1
虚拟地址Virtual address 存储地址Storage address
第一虚拟地址First virtual address 第一存储地址First storage address
表2Table 2
虚拟地址Virtual address 存储地址Storage address
第一虚拟地址First virtual address 第二存储地址Secondary storage address
在具体实施过程中,存储设备在运行过程中,可以首先在存储设备的内存中生成上述映射表,随着存储设备的硬盘上数据的读写变化,存储设备对上述映射表进行更新维护,当存储设备需要停止运行时,例如需要关机时,存储设备可以将上述映射表保存至存储设备的硬盘中。当存储设备下次再启动运行时,再将保存在硬盘中的映射表加载到内存中,进而基于该映射表继续进行读写,以及对该映射表进行更新维护。In the specific implementation process, during the operation of the storage device, the above mapping table may be generated in the memory of the storage device. As the data on the hard disk of the storage device reads and writes, the storage device updates and maintains the above mapping table. When the storage device needs to stop running, for example, when it needs to be shut down, the storage device can save the above mapping table to the hard disk of the storage device. When the storage device is restarted next time, the mapping table stored in the hard disk is loaded into the memory, and then reading and writing are continued based on the mapping table, and the mapping table is updated and maintained.
本实施例中,第一数据的元数据中记录第一虚拟地址,在第一数据迁移前,存储设备中记录第一虚拟地址与存储第一数据的第一存储地址之间的第一映射关系,当第一数据从第一存储地址迁移到第二存储地址后,仅需要将第一映射关系修改为第一虚拟地址与第二存储地址的第二映射关系即可,从而无需修改第一数据的元数据,同时又能保证第一数据在迁移后仍然能正确的访问,因此,本实施例在保证数据被正确访问的同时极大减少了元数据的修改次数,从而极大提升了元数据的管理效率,减少了存储系统的负载。In this embodiment, a first virtual address is recorded in metadata of the first data, and before the first data is migrated, a first mapping relationship between the first virtual address and the first storage address storing the first data is recorded in the storage device. After the first data is migrated from the first storage address to the second storage address, it is only necessary to modify the first mapping relationship to the second mapping relationship between the first virtual address and the second storage address, thereby eliminating the need to modify the first data. At the same time, it can also ensure that the first data can still be correctly accessed after the migration. Therefore, this embodiment greatly reduces the number of metadata modification times while ensuring that the data is correctly accessed, thereby greatly improving the metadata. Management efficiency, reducing the load on the storage system.
对于不同的硬盘类型,其存储地址的表示方式可能存在差异。For different types of hard disks, the storage address may be expressed differently.
一种方式中,上述的SMR硬盘和SSD所代表的一类硬盘中,其存储地址的表示方式可以看作是“存储区域+存储偏移量”的方式。在这类硬盘中,硬盘被划分为多个存储区域,在每个存储区域内,可以包括多个存储偏移量。例如,在SMR硬盘中,一个zone表示一个存储区域,每个zone内的一个offset表示该zone内的一个存储偏移量。又例如,在SSD中,以一个page组表示一个存储区域,每个page组内的一个offset表示该page组内的一个存储偏移量。In one mode, in the above-mentioned SMR hard disk and a type of hard disk represented by the SSD, the storage address representation method can be regarded as a "storage area + storage offset" method. In this type of hard disk, the hard disk is divided into multiple storage areas, and within each storage area, multiple storage offsets can be included. For example, in an SMR hard disk, a zone represents a storage area, and an offset within each zone represents a storage offset within the zone. As another example, in the SSD, a page group is used to represent a storage area, and an offset within each page group represents a storage offset within the page group.
针对上述SMR硬盘和SSD所代表的一类硬盘,其上的数据的存储地址可以通过存储区域ID以及存储区域内的存储偏移量共同确定。SMR硬盘和SSD所代表的一类硬盘可以 通过顺序写的方式写入数据。SMR硬盘和SSD所代表的一类硬盘中,新数据无法直接覆盖旧数据,需要通过垃圾回收才能把旧数据所占用的空间释放出来供新数据使用。For the above-mentioned SMR hard disk and a type of hard disk represented by the SSD, the storage address of the data on the hard disk can be determined through the storage area ID and the storage offset in the storage area. SMR hard disks and a type of hard disks represented by SSDs can write data in a sequential write manner. In SMR hard disks and the type of hard disks represented by SSDs, new data cannot directly overwrite old data, and the space occupied by old data needs to be released through garbage collection for new data.
示例性的,假设存储设备已经获知某个数据D存储在zone1的offset1中,该数据D的存储地址可以表示为:zone1offset1,即,数据D的存储地址通过zone1这个存储区域标识以及offset1这个存储偏移量来共同确定。在读取该数据D时,可以首先通过zone1这个标识寻址到数据D所在的存储区域,进而,再通过offset1这个偏移量寻址到数据D所在的存储位置,从这个存储位置按照数据D的长度(length)即可读出数据D,长度(length)可以记录在数据D的元数据中,和/或,记录在读取该数据D的读请求中。Exemplarily, assuming that the storage device has learned that a certain data D is stored in offset1 of zone1, the storage address of the data D can be expressed as: zone1offset1, that is, the storage address of data D is identified by the storage area of zone1 and the storage offset of offset1. To determine jointly. When reading the data D, it can be addressed to the storage area where the data D is located through the identifier of zone1, and then to the storage location where the data D is located through the offset of offset1. From this storage location, according to the data D The length (length) of the data D can be read, and the length (length) can be recorded in the metadata of the data D, and / or recorded in a read request to read the data D.
进而,可选的,数据的虚拟地址可以通过虚拟区域的标识和虚拟偏移量共同标识。Further, optionally, the virtual address of the data may be jointly identified by the identifier of the virtual area and the virtual offset.
具体的,针对上述第一数据,该第一数据的第一虚拟地址可以通过第一虚拟区域的标识和第一虚拟偏移量共同标识。Specifically, for the above-mentioned first data, the first virtual address of the first data may be jointly identified by the identifier of the first virtual area and the first virtual offset.
示例性的,假设存储设备中存储了数据D,数据D的元数据中记录的虚拟地址可以为:vzone1voffset1。其中,vzone1表示数据D的虚拟区域的标识,voffset1表示数据D的虚拟偏移量。Exemplarily, assuming that data D is stored in the storage device, the virtual address recorded in the metadata of the data D may be: vzone1voffset1. Among them, vzone1 represents the identifier of the virtual zone of data D, and voffset1 represents the virtual offset of data D.
需要说明的是,上述的通过“vzone1+voffset1”表示虚拟地址的方式与存储地址的表示方式“zone1+offset1”的相似度高,因此具有易于被设备管理人员理解等优点。实际上,虚拟地址也可以有其他形式。例如,可以用16进制的数字,罗马字母表示,用英语字母来描述虚拟地址,或者多种符号的组合来来描述虚拟地址,只要能够表示“zone+offset”具有对应关系即可。It should be noted that the above-mentioned way of representing the virtual address by "vzone1 + voffset1" is highly similar to the way of representing the storage address "zone1 + offset1", and therefore has advantages such as being easily understood by device managers. In fact, virtual addresses can also take other forms. For example, you can use hexadecimal numbers, Roman letters, English letters to describe virtual addresses, or a combination of multiple symbols to describe virtual addresses, as long as it can indicate that "zone + offset" has a corresponding relationship.
示例性的,zone1的第一个48KB使用字母AAA1表示,zone1的第二个48KB使用字母AA2表示,zone1的第三个48KB使用字母AA3表示,依次类推。For example, the first 48KB of zone1 is represented by the letter AAA1, the second 48KB of zone1 is represented by the letter AA2, the third 48KB of zone1 is represented by the letter AA3, and so on.
可选的,如果存储设备中数据的存储地址通过存储区域ID以及存储区域内的存储偏移量共同确定,数据的虚拟地址通过虚拟区域的标识以及虚拟偏移量共同标识,则数据对应的映射关系可以通过虚拟区域的标识与存储区域的映射关系,以及虚拟偏移量与存储偏移量的映射关系来表示。Optionally, if the storage address of the data in the storage device is jointly determined by the storage area ID and the storage offset in the storage area, and the virtual address of the data is collectively identified by the identification of the virtual area and the virtual offset, the corresponding mapping of the data The relationship can be expressed by the mapping relationship between the identification of the virtual area and the storage area, and the mapping relationship between the virtual offset and the storage offset.
具体的,针对上述第一数据,在该第一数据被迁移之前,该第一数据对应的第一映射关系可以包括:Specifically, for the first data, before the first data is migrated, the first mapping relationship corresponding to the first data may include:
第一虚拟区域的标识与第一存储区域的映射关系,以及,第一虚拟偏移量与第一存储偏移量的映射关系。The mapping relationship between the identifier of the first virtual area and the first storage area, and the mapping relationship between the first virtual offset and the first storage offset.
当该第一数据被迁移之后,该第一数据对应的映射关系被修改为第二映射关系,该第二映射关系可以包括:After the first data is migrated, the mapping relationship corresponding to the first data is modified to a second mapping relationship, and the second mapping relationship may include:
第一虚拟区域的标识与第二存储区域的映射关系,以及,第一虚拟偏移量与第二存储偏移量的映射关系。The mapping relationship between the identifier of the first virtual area and the second storage area, and the mapping relationship between the first virtual offset and the second storage offset.
以下说明上述映射关系的可选实现方式。The following describes an optional implementation manner of the above mapping relationship.
如上所述,数据对应的映射关系可以通过虚拟区域的标识与存储区域的映射关系,以及虚拟偏移量与存储偏移量的映射关系来表示,以下分别说明该两种映射关系的可选实现方式。As mentioned above, the mapping relationship corresponding to the data can be represented by the mapping relationship between the identification of the virtual area and the storage area, and the mapping relationship between the virtual offset and the storage offset. The following describes the optional implementation of the two mapping relationships, respectively. the way.
1、虚拟区域的标识与存储区域的映射关系1. Mapping relationship between the identification of the virtual area and the storage area
可选的,虚拟区域的标识与存储区域的映射关系可以通过映射表的形式进行保存。Optionally, the mapping relationship between the identification of the virtual area and the storage area may be saved in the form of a mapping table.
针对存储设备中的一个数据,当该数据被首次写入存储设备的硬盘时,存储设备为其分配虚拟区域的标识,该虚拟区域的标识可能为映射表中已经存在的虚拟区域标识,也可能为新的虚拟区域的标识。如果为已经存在的虚拟区域标识,则存储设备直接使用该已经存在的虚拟区域标识的映射关系即可。如果为新的虚拟区域的标识,则存储设备根据为该数据分配的存储区域,在上述映射表中增加该新的虚拟区域的标识与存储区域的映射关系。当该数据被迁移之后,存储设备在上述映射表中将虚拟区域的标识对应的存储区域修改为迁移后的存储区域。当需要读取该数据时,查询上述映射表可以得到数据的存储区域。For a piece of data in a storage device, when the data is written to the hard disk of the storage device for the first time, the storage device assigns a virtual area identifier to the data. The virtual area identifier may be a virtual area identifier that already exists in the mapping table. ID for the new virtual area. If it is an existing virtual area identifier, the storage device may directly use the mapping relationship of the existing virtual area identifier. If it is the identifier of the new virtual area, the storage device adds a mapping relationship between the identifier of the new virtual area and the storage area to the mapping table according to the storage area allocated for the data. After the data is migrated, the storage device modifies the storage area corresponding to the identifier of the virtual area into the migrated storage area in the above mapping table. When the data needs to be read, query the above mapping table to get the data storage area.
以下以一个示例进行说明。An example is described below.
假设存储设备中有一个待存储的数据D,存储设备为该数据D分配的虚拟区域的标识为vzone1,为该数据D分配的存储区域为zone1。则该数据D被保存后,上述映射表可以如下述表3所示。Assume that there is data D to be stored in the storage device. The identifier of the virtual area allocated by the storage device to the data D is vzone1, and the storage area allocated to the data D is zone1. After the data D is saved, the above mapping table may be as shown in Table 3 below.
表3table 3
虚拟区域的标识Identification of the virtual area 存储区域Storage area
vzone1vzone1 zone1zone1
当数据D从zone1迁移到zone2之后,上述映射表被修改为下述表4所示的形式。After data D is migrated from zone1 to zone2, the above mapping table is modified into the form shown in Table 4 below.
表4Table 4
虚拟区域的标识Identification of the virtual area 存储区域Storage area
vzone1vzone1 zone2zone2
2、虚拟偏移量与存储偏移量的映射关系Mapping relationship between virtual offset and storage offset
一种可选方式中,虚拟偏移量与存储偏移量的映射关系可以通过预设的公式确定。In an optional manner, the mapping relationship between the virtual offset and the storage offset may be determined by a preset formula.
可选的,当存储设备为待存储的一个数据分配了虚拟区域、存储区域以及存储偏移量之后,可以通过预设的第一公式直接计算出该存储偏移量对应的虚拟偏移量。进而,在需要读取该数据时,可以通过预设的第二公式计算虚拟偏移量对应的存储偏移量,进而,从该存储偏移量对应位置读取到数据。Optionally, after the storage device allocates a virtual area, a storage area, and a storage offset for a piece of data to be stored, a virtual offset corresponding to the storage offset may be directly calculated by using a preset first formula. Furthermore, when the data needs to be read, a storage offset corresponding to the virtual offset may be calculated by a preset second formula, and further, data is read from a position corresponding to the storage offset.
一种示例中,上述第一公式可以为下述公式(1),上述第二公式可以为下述公式(2)。In one example, the first formula may be the following formula (1), and the second formula may be the following formula (2).
Voffset=offset+gctimes*sizeof(zone)   (1)Voffset = offset + gctimes * sizeof (zone) (1)
其中,offset为存储设备为待存储的数据分配的存储偏移量,zone为存储设备为待存储的数据分配的存储区域的ID,gctimes为存储设备为待存储的数据分配的虚拟区域的迁移次数。Among them, offset is the storage offset allocated by the storage device for the data to be stored, zone is the ID of the storage area allocated by the storage device for the data to be stored, and gctimes is the number of migrations of the virtual area allocated by the storage device for the data to be stored. .
可选的,在存储设备中,存储设备已分配的每个虚拟区域可以对应一个迁移标识,该迁移标识用于标识虚拟区域的迁移次数,例如,第一虚拟区域对应的迁移标识用来标识第一虚拟区域的迁移次数。迁移标识的初始值可以为0,以第一虚拟区域为例,当存储设备将第一存储地址对应的存储区域中的数据全部迁移至第二存储地址对应的存储区域后,即第一虚拟区域进行过迁移后,存储设备可以更新迁移标识,例如,存储设备可以将原迁移标识的值加上1,作为新的迁移标识。Optionally, in the storage device, each virtual area allocated by the storage device may correspond to a migration identifier, and the migration identifier is used to identify the number of migration times of the virtual area. For example, the migration identifier corresponding to the first virtual area is used to identify Number of migrations of a virtual area. The initial value of the migration identifier can be 0. Taking the first virtual area as an example, when the storage device migrates all the data in the storage area corresponding to the first storage address to the storage area corresponding to the second storage address, the first virtual area After the migration, the storage device can update the migration identifier. For example, the storage device can add 1 to the value of the original migration identifier as the new migration identifier.
本示例中,通过在上述公式(1)中加入迁移标识的值,可以使得数据发生迁移后,新 写入的数据的虚拟偏移量不会与已写入的数据的虚拟偏移量出现重复,避免数据读写时发生错误。In this example, by adding the value of the migration identifier in the above formula (1), after the data is migrated, the virtual offset of the newly written data will not overlap with the virtual offset of the already written data. To avoid errors when reading and writing data.
Offset=voffset%sizeof(zone)   (2)Offset = voffset% sizeof (zone) (2)
其中,voffset为数据的虚拟偏移量,zone为存储设备为待存储的数据分配的存储区域的ID。Among them, voffset is the virtual offset of data, and zone is the ID of the storage area allocated by the storage device for the data to be stored.
在数据读取之前,可以首选根据数据的虚拟区域的标识查找数据的存储区域,进而,使用上述公式(2)确定数据的存储偏移量。Before the data is read, the storage area of the data may be preferably searched according to the identification of the virtual area of the data, and further, the above-mentioned formula (2) is used to determine the storage offset of the data.
另一种可选方式中,虚拟偏移量与存储偏移量的映射关系可以通过映射表的形式进行保存。In another optional manner, the mapping relationship between the virtual offset and the storage offset may be saved in the form of a mapping table.
针对存储设备中的一个数据,当该数据被首次写入存储设备的硬盘时,存储设备为其分配虚拟区域的标识、存储区域和存储偏移量,进而,存储设备确定该存储设备对应的虚拟偏移量,把并将该存储偏移量和虚拟偏移量的对应关系保存在映射表中。当数据被迁移之后,当该数据被迁移之后,存储设备在该映射表中将虚拟偏移量对应的存储偏移量修改为迁移后的存储偏移量。当需要读取该数据时,可以查询该映射表,得到该数据的存储偏移量。For a piece of data in a storage device, when the data is written to the hard disk of the storage device for the first time, the storage device allocates a virtual area identifier, a storage area, and a storage offset for the data. Further, the storage device determines the virtual Offset, and saves the correspondence between the storage offset and the virtual offset in a mapping table. After the data is migrated, after the data is migrated, the storage device modifies the storage offset corresponding to the virtual offset into the migrated storage offset in the mapping table. When you need to read the data, you can query the mapping table to get the storage offset of the data.
以下以一个示例进行说明。An example is described below.
假设存储设备中有一个待存储的数据D,存储设备为该数据D分配的存储区域为zone1,虚拟偏移量为voffset1,为该数据D分配的存储偏移量为offset1。则该数据D被保存后,上述映射表可以如下述表5所示。Assume that the storage device has data D to be stored, the storage area allocated by the storage device for the data D is zone1, the virtual offset is voffset1, and the storage offset allocated for the data D is offset1. After the data D is saved, the above mapping table may be as shown in Table 5 below.
表5table 5
虚拟区域的标识Identification of the virtual area 存储区域Storage area
voffset1voffset1 offset1offset1
之后,数据D从zone1的offset1迁移到zone2的offset2,则上述映射表被修改为下述表6所示的形式。After that, the data D is migrated from offset1 of zone1 to offset2 of zone2, and the above mapping table is modified into the form shown in Table 6 below.
表6Table 6
虚拟区域的标识Identification of the virtual area 存储区域Storage area
voffset1voffset1 offset2offset2
需要说明的是,在具体实施过程中,上述两种可选方式可以单独实施,也可以结合起来实施。It should be noted that in the specific implementation process, the above two optional methods may be implemented separately or in combination.
结合实施的过程为:The combined implementation process is:
当数据首次写入存储设备时,存储设备可以按照上述公式(1)确定数据的存储偏移量对应的虚拟偏移量,此时,存储偏移量和虚拟偏移量的对应关系可以看作是由该公式(1)来表示,存储设备中不需要额外记录二者的对应关系。当数据发生迁移之后,数据的虚拟偏移量所对应的存储偏移量发生变化,此时,可以将数据的虚拟偏移量与迁移后的存储偏移量的对应关系写入映射表中。当需要读取该数据时,存储设备可以首先判断当前是否存在虚拟偏移量和存储偏移量的映射表,如果存在,则进一步判断映射表中是否存在数据的 虚拟偏移量,若存在,则该虚拟偏移量对应的存储偏移量即为数据的存储偏移量,如果不存在数据的虚拟偏移量,或者不存在虚拟偏移量和存储偏移量的映射表,则可以按照上述公式(1)确定数据的虚拟偏移量对应的存储偏移量,此时,存储偏移量和虚拟偏移量的对应关系可以看作是由该公式(2)来表示。When data is first written to the storage device, the storage device can determine the virtual offset corresponding to the storage offset of the data according to the above formula (1). At this time, the correspondence between the storage offset and the virtual offset can be regarded as It is represented by the formula (1), and there is no need to record the corresponding relationship between the two in the storage device. After the data is migrated, the storage offset corresponding to the virtual offset of the data changes. At this time, the correspondence between the virtual offset of the data and the migrated storage offset can be written into the mapping table. When the data needs to be read, the storage device may first determine whether a mapping table of the virtual offset and the storage offset currently exists, and if it exists, further determine whether there is a virtual offset of the data in the mapping table. The storage offset corresponding to the virtual offset is the storage offset of the data. If there is no virtual offset of the data, or there is no mapping table of the virtual offset and the storage offset, you can follow The above formula (1) determines the storage offset corresponding to the virtual offset of the data. At this time, the correspondence between the storage offset and the virtual offset can be regarded as represented by the formula (2).
如上说明了数据的存储地址和虚拟地址的可选表示方式,以及存储地址和虚拟地址的映射关系的可选表示方式。在具体实施过程中,存储设备可以按照上述的可选表示方式存储数据,以及建立数据对应的映射关系。The optional representations of the storage address and the virtual address of the data and the optional representations of the mapping relationship between the storage address and the virtual address are explained above. In a specific implementation process, the storage device may store data according to the foregoing optional representation manner, and establish a mapping relationship corresponding to the data.
以下继续使用上述图1对应描述中的示例,说明本申请实施例中数据的存储以及映射关系建立。The following continues to use the example in the corresponding description of FIG. 1 to describe data storage and the establishment of a mapping relationship in the embodiment of the present application.
假设文件系统中保存了一个文件BB.doc,该文件BB.doc的存储位置为“/AA/BB.doc”,则图3为该文件BB.doc在文件系统的树形结构中的存储结构,如图3所示,树形结构的第一层,即根部,为“/”这个根目录的虚拟区域的标识以及虚拟偏移量。该虚拟区域的标识与存储区域的映射关系存储在第一映射表中,该虚拟偏移量与存储偏移量的映射关系存储在第二映射表中或者通过公式表示。通过该两个映射关系,存储设备可以获知“/”这个根目录的存储区域以及存储偏移量,该存储区域以及存储偏移量所共同确定出的存储地址中所存储的内容,即为树形结构的第二层的内容,该内容包括“AA”的虚拟区域的标识以及虚拟偏移量,该虚拟区域的标识与存储区域的映射关系存储在第一映射表中,该虚拟偏移量与存储偏移量的映射关系存储在第二映射表中或者通过公式表示。通过该两个映射关系,存储设备可以获知“AA”的存储区域以及存储偏移量,该存储区域以及存储偏移量所共同确定出的存储地址中所存储的内容,即为树形结构的第三层的内容,该内容包括“BB.doc”的虚拟区域的标识以及虚拟偏移量,存储设备再继续按照映射关系,最终得出“BB.doc”的存储地址。Assume that a file BB.doc is saved in the file system, and the storage location of the file BB.doc is “/AA/BB.doc”, then FIG. 3 is the storage structure of the file BB.doc in the tree structure of the file system As shown in FIG. 3, the first layer of the tree structure, that is, the root, is the identifier of the virtual area of the root directory and the virtual offset. The mapping relationship between the identifier of the virtual area and the storage area is stored in the first mapping table, and the mapping relationship between the virtual offset and the storage offset is stored in the second mapping table or expressed by a formula. Through these two mapping relationships, the storage device can know the storage area and storage offset of the root directory "/". The content stored in the storage area and the storage address determined by the storage offset is the tree. The content of the second layer of the shape structure includes the identifier of the virtual area of "AA" and the virtual offset, and the mapping relationship between the identifier of the virtual area and the storage area is stored in the first mapping table, and the virtual offset The mapping relationship with the storage offset is stored in the second mapping table or expressed by a formula. Through these two mapping relationships, the storage device can know the storage area and storage offset of "AA". The content stored in the storage area and the storage address determined by the storage offset is a tree structure. The content of the third layer, which includes the identification of the virtual area of "BB.doc" and the virtual offset, the storage device continues to follow the mapping relationship, and finally obtains the storage address of "BB.doc".
在上述示例中,树形结构的每一层中所记录的元数据中包括虚拟区域的标识以及虚拟偏移量,而并非数据的存储区域ID以及存储偏移量,因此,数据发生迁移后,树形结构的每一层中的元数据都不需要修改,而仅修改对应的映射关系即可。In the above example, the metadata recorded in each layer of the tree structure includes the identification of the virtual area and the virtual offset, rather than the storage area ID and storage offset of the data. Therefore, after the data is migrated, The metadata in each layer of the tree structure does not need to be modified, but only the corresponding mapping relationship can be modified.
以下说明在上述的可选表示方式下,存储设备进行数据读写的过程。The following describes the process of reading and writing data from the storage device under the above-mentioned optional representation mode.
图4为在存储设备中写入第二数据的流程示意图,如图4所示,写入过程包括:FIG. 4 is a schematic flowchart of writing second data in a storage device. As shown in FIG. 4, the writing process includes:
S401、为待存储的第二数据分配第二虚拟区域的标识以及分配用于存储第二数据的第三存储地址所对应的第三存储区域。S401: Allocate an identifier of a second virtual area to the second data to be stored, and allocate a third storage area corresponding to a third storage address for storing the second data.
存储设备在确定出第二数据存储后,首先为第二数据分配虚拟区域的标识以及存储区域,即上述第二虚拟区域的标识以及第三存储区域。After determining the second data storage, the storage device first allocates a virtual area identifier and a storage area for the second data, that is, the identifier of the second virtual area and the third storage area.
可选的,存储设备可以按照预设的策略为第二数据分配虚拟区域的标识以及存储区域。Optionally, the storage device may allocate a virtual area identifier and a storage area for the second data according to a preset policy.
S402、为第二数据分配第三存储区域内的第三存储偏移量,上述第三存储区域和该第三存储偏移量共同确定上述第三存储地址。S402. Allocate a third storage offset in the third storage area for the second data, and the third storage area and the third storage offset determine the third storage address together.
在为第二数据分配虚拟区域的标识以及存储区域后,存储设备进一步为第二数据分配存储偏移量,即第三存储偏移量。可选的,存储设备可以从已分配的存储区域的第一个空闲存储偏移量开始,为第二数据分配存储偏移量。After the identifier of the virtual area and the storage area are allocated for the second data, the storage device further allocates a storage offset for the second data, that is, a third storage offset. Optionally, the storage device may allocate a storage offset for the second data starting from the first free storage offset of the allocated storage area.
需要说明的是,在具体实施过程中,数据的大小不尽相同,因此,一个数据所占用的 存储偏移量可能为一个,也可能为多个,因此,本申请实施例中所述的存储偏移量可以看作是数据在存储区域内的起始位置,存储设备还需要进一步结合数据的长度得到数据的完整存储偏移量,该长度也可以同时存储在数据的元数据中。It should be noted that in the specific implementation process, the size of the data is not the same. Therefore, the storage offset occupied by one data may be one or more. Therefore, the storage described in the embodiment of the present application The offset can be regarded as the starting position of the data in the storage area. The storage device needs to further combine the length of the data to obtain the complete storage offset of the data, which can also be stored in the metadata of the data at the same time.
示例性的,存储设备为第二数据分配的存储地址为存储区域zone2+存储偏移量offset2,假设offset2的值为48KB,则第二数据的起始位置为距离zone2的起始位置48KB的位置,同时,第二数据具有长度信息,例如长度为20KB。则在读取第二数据时,通过虚拟地址和存储地址的映射关系得到第二数据的存储区域ID(zone2)和存储偏移量(48KB),即得到第二数据的起始位置,再向后读取20KB,即可读取到第二数据的完整内容。Exemplarily, the storage address allocated by the storage device for the second data is the storage area zone2 + storage offset offset2. Assuming that the value of offset2 is 48KB, the starting position of the second data is a position 48KB from the starting position of zone2. Meanwhile, the second data has length information, for example, the length is 20 KB. When reading the second data, the storage area ID (zone2) and storage offset (48KB) of the second data are obtained through the mapping relationship between the virtual address and the storage address, that is, the starting position of the second data is obtained, and then After reading 20KB, you can read the complete content of the second data.
S403、根据上述第三存储偏移量以及上述迁移标识确定上述第二数据对应的第二虚拟偏移量。S403. Determine a second virtual offset corresponding to the second data according to the third storage offset and the migration identifier.
具体过程可以参照上述公式(1)的对应描述,此处不再赘述。The specific process can refer to the corresponding description of the above formula (1), which will not be repeated here.
S404、将上述第二数据写入上述第三存储地址,并在上述第二数据的元数据中记录上述第二虚拟区域的标识以及所述第二虚拟偏移量。S404. Write the second data into the third storage address, and record an identifier of the second virtual area and the second virtual offset in metadata of the second data.
在确定出存储第二数据的第三存储区域和第三存储偏移量后,存储设备即确定出第二数据的存储地址,即第三存储地址,进而,在本步骤中,存储设备将第二数据写入由第三存储区域和第三存储偏移量共同确定出的第三存储地址中。After determining the third storage area and the third storage offset for storing the second data, the storage device determines the storage address of the second data, that is, the third storage address. Further, in this step, the storage device The two data are written into a third storage address determined by the third storage area and the third storage offset.
可选的,存储设备从第三存储偏移量所表示的起始位置开始,以顺序写的方式将第二数据写入起始位置及其之后的存储位置中。Optionally, the storage device starts from the starting position indicated by the third storage offset, and writes the second data into the starting position and the subsequent storage positions in a sequential writing manner.
进而,存储设备将为第二数据分配的虚拟区域的标识以及确定出的第二虚拟偏移量记录在第二数据的元数据中。可选的,存储设备还将第二数据的长度信息写入第二数据的元数据中。Furthermore, the storage device records the identifier of the virtual area allocated for the second data and the determined second virtual offset in the metadata of the second data. Optionally, the storage device further writes length information of the second data into metadata of the second data.
S405、建立第三映射关系,该第三映射关系包括:上述第二虚拟区域的标识与第三存储区域的映射关系,以及,上述第二虚拟偏移量与第三存储偏移量的映射关系。S405. Establish a third mapping relationship, where the third mapping relationship includes: the mapping relationship between the identifier of the second virtual area and the third storage area, and the mapping relationship between the second virtual offset and the third storage offset .
可选的,存储设备可以按照上述表3对应描述中的方法建立第二虚拟区域的标识与第三存储区域的映射关系,按照上述公式(1)或表(5)对应描述中的方法建立第二虚拟偏移量与第三存储偏移量的映射关系,此处不再赘述。Optionally, the storage device may establish the mapping relationship between the identifier of the second virtual area and the third storage area according to the method described in the corresponding description in Table 3 above, and establish the first relationship according to the method described in the foregoing formula (1) or table (5). The mapping relationship between the second virtual offset and the third storage offset is not repeated here.
图5为从存储设备中读取上述第一数据的流程示意图,如图5所示,读取上述第一数据的过程包括:FIG. 5 is a schematic flowchart of reading the first data from a storage device. As shown in FIG. 5, the process of reading the first data includes:
S501、根据上述第一映射关系以及上述第一数据的元数据中所记录的第一虚拟地址,确定存储上述第一数据的上述第一存储地址。S501. Determine the first storage address storing the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data.
可选的,当上述第一存储地址使用“存储区域+存储偏移量”的方式表示时,第一存储地址包括第一存储区域ID和第一存储偏移量,第一虚拟地址包括第一虚拟区域的标识和第一虚拟偏移量。进而,经过前述的实施例可知,第一数据对应的第一映射关系包括第一虚拟区域的标识和第一存储区域的映射关系,以及第一虚拟偏移量和第一存储偏移量的映射关系。Optionally, when the foregoing first storage address is expressed in a "storage area + storage offset" manner, the first storage address includes a first storage area ID and a first storage offset, and the first virtual address includes a first The identification of the virtual area and the first virtual offset. Furthermore, according to the foregoing embodiment, it can be known that the first mapping relationship corresponding to the first data includes the mapping relationship between the identifier of the first virtual area and the first storage area, and the mapping between the first virtual offset and the first storage offset. relationship.
进而,在本步骤中,可以首先通过第一数据的元数据获取第一数据对应的第一虚拟区域的标识以及第一虚拟偏移量,进而,根据上述第一虚拟区域的标识与第一存储区域的映射关系,得到上述第一存储地址对应的第一存储区域ID,以及,根据上述第一虚拟偏移量 与第一存储偏移量的映射关系,得到上述第一存储地址对应的第一存储偏移量。Further, in this step, the identifier of the first virtual area corresponding to the first data and the first virtual offset may be obtained first through the metadata of the first data, and further, according to the identifier of the first virtual area and the first storage, Area mapping relationship to obtain a first storage area ID corresponding to the first storage address, and to obtain a first storage area corresponding to the first storage address according to the mapping relationship between the first virtual offset and the first storage offset Stores the offset.
作为一种示例,存储设备可以通过读取映射表来得到第一存储地址对应的第一存储区域ID。As an example, the storage device may obtain the first storage area ID corresponding to the first storage address by reading the mapping table.
作为一种示例,存储设备可以通过前述的公式(2)得到第一存储地址对应的第一存储偏移量。As an example, the storage device may obtain the first storage offset corresponding to the first storage address by using the foregoing formula (2).
S502、从上述第一存储地址读取上述第一数据。S502. Read the first data from the first storage address.
在得到第一数据的第一存储区域以及第一存储偏移量后,存储设备即得到第一数据起始存储位置,存储设备可以进一步结合第一数据的长度信息,读取到完整的第一数据。After obtaining the first storage area of the first data and the first storage offset, the storage device obtains the starting storage position of the first data. The storage device can further combine the length information of the first data to read the complete first data. data.
示例性的,假设通过上述步骤S501得到第一数据的第一存储区域为zone1,第一存储偏移量为48KB,同时,第一数据的元数据中所记录的第一数据的长度为20KB,则存储设备首先寻址到zone1内距离zone1起始位置48KB的位置,该位置为第一数据的起始位置,从该位置开始,顺序读取20KB,所读出的数据即为第一数据的完整内容。Exemplarily, it is assumed that the first storage area of the first data obtained through the foregoing step S501 is zone1, the first storage offset is 48KB, and the length of the first data recorded in the metadata of the first data is 20KB, Then the storage device first addresses a position within zone1 which is 48KB from the starting position of zone1. This position is the starting position of the first data. From this position, 20KB is sequentially read. The read data is the first data. Full content.
图6为本申请实施例提供的一种数据迁移装置600的模块示意图,该装置应用于存储设备。可选的,该装置可以是存储设备的控制器,或者为存储设备的控制器的一部分。第一数据存储在第一存储地址,所述第一数据的元数据中记录有第一虚拟地址,所述第一存储地址与所述第一虚拟地址之间有第一映射关系。如图6所示,该装置600包括:处理模块601。FIG. 6 is a schematic block diagram of a data migration apparatus 600 according to an embodiment of the present application. The apparatus is applied to a storage device. Optionally, the device may be a controller of the storage device, or be a part of the controller of the storage device. The first data is stored in a first storage address, a first virtual address is recorded in the metadata of the first data, and there is a first mapping relationship between the first storage address and the first virtual address. As shown in FIG. 6, the apparatus 600 includes: a processing module 601.
处理模块601,用于将第一数据从第一存储地址迁移到第二存储地址,以及,A processing module 601, configured to migrate the first data from the first storage address to the second storage address, and
将上述第一映射关系调整为第二映射关系,该第二映射关系是上述第二存储地址与上述第一虚拟地址的对应关系。The first mapping relationship is adjusted to a second mapping relationship, and the second mapping relationship is a correspondence relationship between the second storage address and the first virtual address.
该装置用于实现前述方法实施例,其实现原理和技术效果类似,此处不再赘述。This device is used to implement the foregoing method embodiments, and its implementation principles and technical effects are similar, and details are not described herein again.
在一种可选的实施方式中,上述存储地址通过存储区域ID以及存储区域内的存储偏移量共同确定。In an optional implementation manner, the storage address is jointly determined by a storage area ID and a storage offset in the storage area.
在一种可选的实施方式中,上述第一虚拟地址通过第一虚拟区域的标识以及第一虚拟偏移量共同标识。In an optional implementation manner, the first virtual address is jointly identified by an identifier of the first virtual area and a first virtual offset.
在一种可选的实施方式中,上述第一映射关系包括:上述第一虚拟区域的标识与第一存储区域的映射关系,以及,上述第一虚拟偏移量与第一存储偏移量的映射关系。In an optional implementation manner, the first mapping relationship includes a mapping relationship between the identifier of the first virtual area and the first storage area, and a relationship between the first virtual offset and the first storage offset. Mapping relations.
上述第二映射关系包括:上述第一虚拟区域的标识与第二存储区域的映射关系,以及,上述第一虚拟偏移量与第二存储偏移量的映射关系。The second mapping relationship includes a mapping relationship between the identifier of the first virtual area and the second storage area, and a mapping relationship between the first virtual offset and the second storage offset.
在一种可选的实施方式中,处理模块601还用于:In an optional implementation manner, the processing module 601 is further configured to:
在上述第一存储地址对应的存储区域中的数据全部迁移至上述第二存储地址对应的存储区域后,更新迁移标识,该迁移标识用于标识上述第一虚拟区域的迁移次数。After all data in the storage area corresponding to the first storage address is migrated to the storage area corresponding to the second storage address, a migration identifier is updated, and the migration identifier is used to identify the number of migration times of the first virtual area.
在一种可选的实施方式中,处理模块601还用于:In an optional implementation manner, the processing module 601 is further configured to:
为待存储的第二数据分配第二虚拟区域的标识以及分配用于存储所述第二数据的第三存储地址所对应的第三存储区域。An identifier of a second virtual area is allocated to the second data to be stored, and a third storage area corresponding to a third storage address used to store the second data is allocated.
为所述第二数据分配第三存储区域内的第三存储偏移量,所述第三存储区域和所述第三存储偏移量共同确定所述第三存储地址。A third storage offset in a third storage area is allocated to the second data, and the third storage area and the third storage offset jointly determine the third storage address.
根据所述第三存储偏移量以及所述迁移标识确定所述第二数据对应的第二虚拟偏移 量。Determining a second virtual offset corresponding to the second data according to the third storage offset and the migration identifier.
将所述第二数据写入所述第三存储地址,并在所述第二数据的元数据中记录所述第二虚拟区域的标识以及所述第二虚拟偏移量。Write the second data into the third storage address, and record the identifier of the second virtual area and the second virtual offset in metadata of the second data.
建立第三映射关系,所述第三映射关系包括:所述第二虚拟区域的标识与第三存储区域的映射关系,以及,所述第二虚拟偏移量与第三存储偏移量的映射关系。Establishing a third mapping relationship, where the third mapping relationship includes: a mapping relationship between an identifier of the second virtual area and a third storage area, and a mapping between the second virtual offset and a third storage offset relationship.
在一种可选的实施方式中,处理模块601还用于:In an optional implementation manner, the processing module 601 is further configured to:
根据所述第一映射关系以及所述第一数据的元数据中所记录的第一虚拟地址,确定存储所述第一数据的所述第一存储地址。Determining the first storage address storing the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data.
从所述第一存储地址读取所述第一数据。Reading the first data from the first storage address.
在一种可选的实施方式中,处理模块601具体用于:In an optional implementation manner, the processing module 601 is specifically configured to:
根据所述第一虚拟区域的标识与第一存储区域的映射关系,得到所述第一存储地址对应的第一存储区域ID。According to the mapping relationship between the identifier of the first virtual area and the first storage area, a first storage area ID corresponding to the first storage address is obtained.
根据所述第一虚拟偏移量与第一存储偏移量的映射关系,得到所述第一存储地址对应的第一存储偏移量。According to the mapping relationship between the first virtual offset and the first storage offset, a first storage offset corresponding to the first storage address is obtained.
其中,所述第一虚拟偏移量与第一存储偏移量的映射关系通过所述第一虚拟偏移量与所述第一存储偏移量的映射表进行标识,或者,通过预设的公式确定。The mapping relationship between the first virtual offset and the first storage offset is identified by a mapping table of the first virtual offset and the first storage offset, or by a preset The formula is OK.
图7为本申请实施例提供的一种存储设备700的实体框图,如图7所示,该存储设备包括控制器701和至少一个硬盘702,控制器701用于对硬盘702存储的数据进行管理,第一数据存储在第一存储地址,第一数据的元数据中记录有第一虚拟地址,该第一存储地址与该第一虚拟地址之间有第一映射关系。控制器701还用于:FIG. 7 is a physical block diagram of a storage device 700 according to an embodiment of the present application. As shown in FIG. 7, the storage device includes a controller 701 and at least one hard disk 702. The controller 701 is configured to manage data stored in the hard disk 702. The first data is stored in a first storage address, a first virtual address is recorded in the metadata of the first data, and there is a first mapping relationship between the first storage address and the first virtual address. The controller 701 is also used for:
将第一数据从第一存储地址迁移到第二存储地址,以及,Migrating the first data from the first storage address to the second storage address, and,
将上述第一映射关系调整为第二映射关系,该第二映射关系是上述第二存储地址与上述第一虚拟地址的对应关系。The first mapping relationship is adjusted to a second mapping relationship, and the second mapping relationship is a correspondence relationship between the second storage address and the first virtual address.
在一种可选的实施方式中,上述存储地址通过存储区域ID以及存储区域内的存储偏移量共同确定。In an optional implementation manner, the storage address is jointly determined by a storage area ID and a storage offset in the storage area.
在一种可选的实施方式中,上述第一虚拟地址通过第一虚拟区域的标识以及第一虚拟偏移量共同标识。In an optional implementation manner, the first virtual address is jointly identified by an identifier of the first virtual area and a first virtual offset.
在一种可选的实施方式中,上述第一映射关系包括:上述第一虚拟区域的标识与第一存储区域的映射关系,以及,上述第一虚拟偏移量与第一存储偏移量的映射关系。In an optional implementation manner, the first mapping relationship includes a mapping relationship between the identifier of the first virtual area and the first storage area, and a relationship between the first virtual offset and the first storage offset. Mapping relations.
上述第二映射关系包括:上述第一虚拟区域的标识与第二存储区域的映射关系,以及,上述第一虚拟偏移量与第二存储偏移量的映射关系。The second mapping relationship includes a mapping relationship between the identifier of the first virtual area and the second storage area, and a mapping relationship between the first virtual offset and the second storage offset.
在一种可选的实施方式中,控制器701还用于:In an optional implementation manner, the controller 701 is further configured to:
在上述第一存储地址对应的存储区域中的数据全部迁移至上述第二存储地址对应的存储区域后,更新迁移标识,该迁移标识用于标识上述第一虚拟区域的迁移次数。After all data in the storage area corresponding to the first storage address is migrated to the storage area corresponding to the second storage address, a migration identifier is updated, and the migration identifier is used to identify the number of migration times of the first virtual area.
在一种可选的实施方式中,控制器701还用于:In an optional implementation manner, the controller 701 is further configured to:
为待存储的第二数据分配第二虚拟区域的标识以及分配用于存储所述第二数据的第三存储地址所对应的第三存储区域。An identifier of a second virtual area is allocated to the second data to be stored, and a third storage area corresponding to a third storage address used to store the second data is allocated.
为所述第二数据分配第三存储区域内的第三存储偏移量,所述第三存储区域和所述第 三存储偏移量共同确定所述第三存储地址。A third storage offset in a third storage area is allocated to the second data, and the third storage area and the third storage offset jointly determine the third storage address.
根据所述第三存储偏移量以及所述迁移标识确定所述第二数据对应的第二虚拟偏移量。Determining a second virtual offset corresponding to the second data according to the third storage offset and the migration identifier.
将所述第二数据写入所述第三存储地址,并在所述第二数据的元数据中记录所述第二虚拟区域的标识以及所述第二虚拟偏移量。Write the second data into the third storage address, and record the identifier of the second virtual area and the second virtual offset in metadata of the second data.
建立第三映射关系,所述第三映射关系包括:所述第二虚拟区域的标识与第三存储区域的映射关系,以及,所述第二虚拟偏移量与第三存储偏移量的映射关系。Establishing a third mapping relationship, where the third mapping relationship includes: a mapping relationship between an identifier of the second virtual area and a third storage area, and a mapping between the second virtual offset and a third storage offset relationship.
在一种可选的实施方式中,控制器701还用于:In an optional implementation manner, the controller 701 is further configured to:
根据所述第一映射关系以及所述第一数据的元数据中所记录的第一虚拟地址,确定存储所述第一数据的所述第一存储地址。Determining the first storage address storing the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data.
从所述第一存储地址读取所述第一数据。Reading the first data from the first storage address.
在一种可选的实施方式中,控制器701具体用于:In an optional implementation manner, the controller 701 is specifically configured to:
根据所述第一虚拟区域的标识与第一存储区域的映射关系,得到所述第一存储地址对应的第一存储区域ID。According to the mapping relationship between the identifier of the first virtual area and the first storage area, a first storage area ID corresponding to the first storage address is obtained.
根据所述第一虚拟偏移量与第一存储偏移量的映射关系,得到所述第一存储地址对应的第一存储偏移量。According to the mapping relationship between the first virtual offset and the first storage offset, a first storage offset corresponding to the first storage address is obtained.
其中,所述第一虚拟偏移量与第一存储偏移量的映射关系通过所述第一虚拟偏移量与所述第一存储偏移量的映射表进行标识,或者,通过预设的公式确定。The mapping relationship between the first virtual offset and the first storage offset is identified by a mapping table of the first virtual offset and the first storage offset, or by a preset The formula is OK.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the embodiments of the present invention are wholly or partially generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be from a website site, computer, server, or data center Transmission by wire (for example, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, and the like that includes one or more available medium integration. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (Solid State Disk (SSD)), and the like.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as a method, a system, or a computer program product. Therefore, this application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
本申请是参照根据本申请实施例的方法、装置(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程 序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。This application is described with reference to the flowcharts and / or block diagrams of the method, apparatus (system), and computer program product according to the embodiments of the present application. It should be understood that each process and / or block in the flowcharts and / or block diagrams, and combinations of processes and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, so that the instructions generated by the processor of the computer or other programmable data processing device are used to generate Means for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to work in a particular manner such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device, the instructions The device implements the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device, so that a series of steps can be performed on the computer or other programmable device to produce a computer-implemented process, which can be executed on the computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.
尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。Although the preferred embodiments of the present application have been described, those skilled in the art can make other changes and modifications to these embodiments once they know the basic inventive concepts. Therefore, the following claims are intended to be construed to include the preferred embodiments and all changes and modifications that fall within the scope of this application.
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. In this way, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application also intends to include these changes and variations.

Claims (19)

  1. 一种数据迁移方法,应用于存储设备,所述存储设备包括控制器和至少一个硬盘,所述控制器用于对硬盘存储的数据进行管理,其特征在于,第一数据存储在第一存储地址,所述第一数据的元数据中记录有第一虚拟地址,所述第一存储地址与所述第一虚拟地址之间有第一映射关系,所述方法包括:A data migration method is applied to a storage device. The storage device includes a controller and at least one hard disk. The controller is used to manage data stored in the hard disk. The method is characterized in that the first data is stored at a first storage address. A first virtual address is recorded in the metadata of the first data, and there is a first mapping relationship between the first storage address and the first virtual address. The method includes:
    所述存储设备将第一数据从所述第一存储地址迁移到第二存储地址;The storage device migrates the first data from the first storage address to a second storage address;
    所述存储设备将所述第一映射关系调整为第二映射关系,所述第二映射关系是所述第二存储地址与所述第一虚拟地址的对应关系。The storage device adjusts the first mapping relationship to a second mapping relationship, and the second mapping relationship is a correspondence relationship between the second storage address and the first virtual address.
  2. 根据权利要求1所述的方法,其特征在于,所述存储地址通过存储区域ID以及存储区域内的存储偏移量共同确定。The method according to claim 1, wherein the storage address is jointly determined by a storage area ID and a storage offset in the storage area.
  3. 根据权利要求2所述的方法,其特征在于,所述第一虚拟地址通过第一虚拟区域的标识以及第一虚拟偏移量共同标识。The method according to claim 2, wherein the first virtual address is jointly identified by an identifier of the first virtual area and a first virtual offset.
  4. 根据权利要求3所述的方法,其特征在于,The method according to claim 3, wherein:
    所述第一映射关系包括:所述第一虚拟区域的标识与第一存储区域的映射关系,以及,所述第一虚拟偏移量与第一存储偏移量的映射关系;The first mapping relationship includes a mapping relationship between an identifier of the first virtual area and a first storage area, and a mapping relationship between the first virtual offset and a first storage offset;
    所述第二映射关系包括:所述第一虚拟区域的标识与第二存储区域的映射关系,以及,所述第一虚拟偏移量与第二存储偏移量的映射关系。The second mapping relationship includes a mapping relationship between an identifier of the first virtual area and a second storage area, and a mapping relationship between the first virtual offset and a second storage offset.
  5. 根据权利要求4所述的方法,其特征在于,所述存储设备将所述第一映射关系调整为第二映射关系之后,还包括:The method according to claim 4, wherein after the storage device adjusts the first mapping relationship to a second mapping relationship, the method further comprises:
    在所述存储设备将所述第一存储地址对应的存储区域中的数据全部迁移至所述第二存储地址对应的存储区域后,所述存储设备更新迁移标识,所述迁移标识用于标识所述第一虚拟区域的迁移次数。After the storage device migrates all data in the storage area corresponding to the first storage address to the storage area corresponding to the second storage address, the storage device updates a migration identifier, where the migration identifier is used to identify all The migration times of the first virtual area are described.
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:The method according to claim 5, further comprising:
    为待存储的第二数据分配第二虚拟区域的标识以及分配用于存储所述第二数据的第三存储地址所对应的第三存储区域;Assigning an identifier of a second virtual area to the second data to be stored and assigning a third storage area corresponding to a third storage address for storing the second data;
    为所述第二数据分配第三存储区域内的第三存储偏移量,所述第三存储区域和所述第三存储偏移量共同确定所述第三存储地址;Assigning a third storage offset in a third storage area to the second data, and the third storage area and the third storage offset jointly determine the third storage address;
    根据所述第三存储偏移量以及所述迁移标识确定所述第二数据对应的第二虚拟偏移量;Determining a second virtual offset corresponding to the second data according to the third storage offset and the migration identifier;
    将所述第二数据写入所述第三存储地址,并在所述第二数据的元数据中记录所述第二虚拟区域的标识以及所述第二虚拟偏移量;Writing the second data into the third storage address, and recording the identifier of the second virtual area and the second virtual offset in metadata of the second data;
    建立第三映射关系,所述第三映射关系包括:所述第二虚拟区域的标识与第三存储区域的映射关系,以及,所述第二虚拟偏移量与第三存储偏移量的映射关系。Establishing a third mapping relationship, where the third mapping relationship includes: a mapping relationship between an identifier of the second virtual area and a third storage area, and a mapping between the second virtual offset and a third storage offset relationship.
  7. 根据权利要求5或6所述的方法,其特征在于,所述方法还包括:The method according to claim 5 or 6, further comprising:
    根据所述第一映射关系以及所述第一数据的元数据中所记录的第一虚拟地址,确定存储所述第一数据的所述第一存储地址;Determining the first storage address storing the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data;
    从所述第一存储地址读取所述第一数据。Reading the first data from the first storage address.
  8. 根据权利要求7所述的方法,其特征在于,所述根据所述第一映射关系以及所述第一数据的元数据中所记录的第一虚拟地址,确定存储所述第一数据的所述第一存储地址, 包括:The method according to claim 7, characterized in that the determining to store the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data The first storage address includes:
    根据所述第一虚拟区域的标识与第一存储区域的映射关系,得到所述第一存储地址对应的第一存储区域ID;Obtaining a first storage area ID corresponding to the first storage address according to a mapping relationship between the identifier of the first virtual area and the first storage area;
    根据所述第一虚拟偏移量与第一存储偏移量的映射关系,得到所述第一存储地址对应的第一存储偏移量;Obtaining a first storage offset corresponding to the first storage address according to the mapping relationship between the first virtual offset and the first storage offset;
    其中,所述第一虚拟偏移量与第一存储偏移量的映射关系通过所述第一虚拟偏移量与所述第一存储偏移量的映射表进行标识,或者,通过预设的公式确定。The mapping relationship between the first virtual offset and the first storage offset is identified by a mapping table of the first virtual offset and the first storage offset, or by a preset The formula is OK.
  9. 一种数据迁移装置,应用于存储设备,其特征在于,第一数据存储在第一存储地址,所述第一数据的元数据中记录有第一虚拟地址,所述第一存储地址与所述第一虚拟地址之间有第一映射关系,所述装置包括:处理模块;A data migration device applied to a storage device is characterized in that first data is stored at a first storage address, a first virtual address is recorded in metadata of the first data, and the first storage address and the There is a first mapping relationship between first virtual addresses, and the device includes: a processing module;
    所述处理模块,用于将第一数据从所述第一存储地址迁移到第二存储地址;以及,The processing module is configured to migrate the first data from the first storage address to a second storage address; and
    将所述第一映射关系调整为第二映射关系,所述第二映射关系是所述第二存储地址与所述第一虚拟地址的对应关系。Adjusting the first mapping relationship to a second mapping relationship, where the second mapping relationship is a correspondence between the second storage address and the first virtual address.
  10. 根据权利要求9所述的装置,其特征在于,所述存储地址通过存储区域ID以及存储区域内的存储偏移量共同确定。The device according to claim 9, wherein the storage address is jointly determined by a storage area ID and a storage offset in the storage area.
  11. 根据权利要求10所述的装置,其特征在于,所述第一虚拟地址通过第一虚拟区域的标识以及第一虚拟偏移量共同标识。The device according to claim 10, wherein the first virtual address is jointly identified by an identifier of the first virtual area and a first virtual offset.
  12. 根据权利要求11所述的装置,其特征在于,The device according to claim 11, wherein:
    所述第一映射关系包括:所述第一虚拟区域的标识与第一存储区域的映射关系,以及,所述第一虚拟偏移量与第一存储偏移量的映射关系;The first mapping relationship includes a mapping relationship between an identifier of the first virtual area and a first storage area, and a mapping relationship between the first virtual offset and a first storage offset;
    所述第二映射关系包括:所述第一虚拟区域的标识与第二存储区域的映射关系,以及,所述第一虚拟偏移量与第二存储偏移量的映射关系。The second mapping relationship includes a mapping relationship between an identifier of the first virtual area and a second storage area, and a mapping relationship between the first virtual offset and a second storage offset.
  13. 根据权利要求12所述的装置,其特征在于,所述处理模块还用于:The apparatus according to claim 12, wherein the processing module is further configured to:
    在所述第一存储地址对应的存储区域中的数据全部迁移至所述第二存储地址对应的存储区域后,更新迁移标识,所述迁移标识用于标识所述第一虚拟区域的迁移次数。After all the data in the storage area corresponding to the first storage address is migrated to the storage area corresponding to the second storage address, the migration identifier is updated, and the migration identifier is used to identify the number of migration times of the first virtual area.
  14. 根据权利要求13所述的装置,其特征在于,所述处理模块还用于:The apparatus according to claim 13, wherein the processing module is further configured to:
    为待存储的第二数据分配第二虚拟区域的标识以及分配用于存储所述第二数据的第三存储地址所对应的第三存储区域;Assigning an identifier of a second virtual area to the second data to be stored and assigning a third storage area corresponding to a third storage address for storing the second data;
    为所述第二数据分配第三存储区域内的第三存储偏移量,所述第三存储区域和所述第三存储偏移量共同确定所述第三存储地址;Assigning a third storage offset in a third storage area to the second data, and the third storage area and the third storage offset jointly determine the third storage address;
    根据所述第三存储偏移量以及所述迁移标识确定所述第二数据对应的第二虚拟偏移量;Determining a second virtual offset corresponding to the second data according to the third storage offset and the migration identifier;
    将所述第二数据写入所述第三存储地址,并在所述第二数据的元数据中记录所述第二虚拟区域的标识以及所述第二虚拟偏移量;Writing the second data into the third storage address, and recording the identifier of the second virtual area and the second virtual offset in metadata of the second data;
    建立第三映射关系,所述第三映射关系包括:所述第二虚拟区域的标识与第三存储区域的映射关系,以及,所述第二虚拟偏移量与第三存储偏移量的映射关系。Establishing a third mapping relationship, where the third mapping relationship includes: a mapping relationship between an identifier of the second virtual area and a third storage area, and a mapping between the second virtual offset and a third storage offset relationship.
  15. 根据权利要求13或14所述的装置,其特征在于,所述处理模块还用于:The apparatus according to claim 13 or 14, wherein the processing module is further configured to:
    根据所述第一映射关系以及所述第一数据的元数据中所记录的第一虚拟地址,确定存 储所述第一数据的所述第一存储地址;Determining the first storage address storing the first data according to the first mapping relationship and a first virtual address recorded in metadata of the first data;
    从所述第一存储地址读取所述第一数据。Reading the first data from the first storage address.
  16. 根据权利要求15所述的装置,其特征在于,所述处理模块具体用于:The apparatus according to claim 15, wherein the processing module is specifically configured to:
    根据所述第一虚拟区域的标识与第一存储区域的映射关系,得到所述第一存储地址对应的第一存储区域ID;Obtaining a first storage area ID corresponding to the first storage address according to a mapping relationship between the identifier of the first virtual area and the first storage area;
    根据所述第一虚拟偏移量与第一存储偏移量的映射关系,得到所述第一存储地址对应的第一存储偏移量;Obtaining a first storage offset corresponding to the first storage address according to the mapping relationship between the first virtual offset and the first storage offset;
    其中,所述第一虚拟偏移量与第一存储偏移量的映射关系通过所述第一虚拟偏移量与所述第一存储偏移量的映射表进行标识,或者,通过预设的公式确定。The mapping relationship between the first virtual offset and the first storage offset is identified by a mapping table of the first virtual offset and the first storage offset, or by a preset The formula is OK.
  17. 一种存储设备,所述存储设备包括控制器和至少一个硬盘,所述控制器用于对硬盘存储的数据进行管理,其特征在于,第一数据存储在第一存储地址,所述第一数据的元数据中记录有第一虚拟地址,所述第一存储地址与所述第一虚拟地址之间有第一映射关系,所述控制器还用于执行权利要求1-8任一项所述的方法。A storage device includes a controller and at least one hard disk. The controller is used to manage data stored in the hard disk, and is characterized in that the first data is stored at a first storage address, and the first data is A first virtual address is recorded in the metadata, and there is a first mapping relationship between the first storage address and the first virtual address. The controller is further configured to execute the one of claims 1-8. method.
  18. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序代码,当所述计算机程序代码被计算机执行时,使得所述计算机执行权利要求1-8任一项所述的方法。A computer program product, wherein the computer program product includes computer program code, and when the computer program code is executed by a computer, the computer causes the computer to execute the method according to any one of claims 1-8.
  19. 一种计算机可读存储介质,其特征在于,所述计算机存储介质存储有计算机指令,当所述计算机指令被计算机执行时,使得所述计算机执行权利要求1-8任一项所述的方法的指令。。A computer-readable storage medium, wherein the computer storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer causes the computer to execute the method according to any one of claims 1-8. instruction. .
PCT/CN2019/098061 2018-08-24 2019-07-27 Data migration method and apparatus, and storage device WO2020038186A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810971371.2A CN109324758A (en) 2018-08-24 2018-08-24 Data migration method, device and storage equipment
CN201810971371.2 2018-08-24

Publications (1)

Publication Number Publication Date
WO2020038186A1 true WO2020038186A1 (en) 2020-02-27

Family

ID=65263397

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/098061 WO2020038186A1 (en) 2018-08-24 2019-07-27 Data migration method and apparatus, and storage device

Country Status (2)

Country Link
CN (1) CN109324758A (en)
WO (1) WO2020038186A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022268108A1 (en) * 2021-06-22 2022-12-29 华为技术有限公司 Data processing method and related apparatus

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109324758A (en) * 2018-08-24 2019-02-12 华为技术有限公司 Data migration method, device and storage equipment
CN110007875B (en) * 2019-04-15 2022-07-08 苏州浪潮智能科技有限公司 Method, device and equipment for migrating effective data
CN110287169B (en) * 2019-06-28 2022-02-01 四川长虹电器股份有限公司 Main data migration method between cloud applications
CN110928490B (en) * 2019-10-28 2021-08-17 中国科学院上海微系统与信息技术研究所 Data storage method and device
CN111078158A (en) * 2019-12-29 2020-04-28 北京浪潮数据技术有限公司 Data migration method and related device
CN113741812B (en) * 2021-08-09 2024-04-12 浙江大华技术股份有限公司 Memory partition updating method and device, electronic device and storage medium
CN117806526A (en) * 2022-09-23 2024-04-02 华为技术有限公司 Data migration method, device, chip and computer readable storage medium
CN115442388B (en) * 2022-10-21 2023-01-06 四川省华存智谷科技有限责任公司 Capacity expansion method, device and system for 100% utilization rate of distributed storage cluster
CN115718620A (en) * 2022-11-22 2023-02-28 科东(广州)软件科技有限公司 Code program migration method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9727485B1 (en) * 2014-11-24 2017-08-08 Pure Storage, Inc. Metadata rewrite and flatten optimization
CN107678981A (en) * 2017-08-24 2018-02-09 北京盛和大地数据科技有限公司 Data processing method and device
CN108021336A (en) * 2016-10-31 2018-05-11 甲骨文国际公司 Data layout scheme for seamless Data Migration
CN109324758A (en) * 2018-08-24 2019-02-12 华为技术有限公司 Data migration method, device and storage equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9727485B1 (en) * 2014-11-24 2017-08-08 Pure Storage, Inc. Metadata rewrite and flatten optimization
CN108021336A (en) * 2016-10-31 2018-05-11 甲骨文国际公司 Data layout scheme for seamless Data Migration
CN107678981A (en) * 2017-08-24 2018-02-09 北京盛和大地数据科技有限公司 Data processing method and device
CN109324758A (en) * 2018-08-24 2019-02-12 华为技术有限公司 Data migration method, device and storage equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022268108A1 (en) * 2021-06-22 2022-12-29 华为技术有限公司 Data processing method and related apparatus

Also Published As

Publication number Publication date
CN109324758A (en) 2019-02-12

Similar Documents

Publication Publication Date Title
WO2020038186A1 (en) Data migration method and apparatus, and storage device
WO2017000658A1 (en) Storage system, storage management device, storage device, hybrid storage device, and storage management method
US8521949B2 (en) Data deleting method and apparatus
US8924664B2 (en) Logical object deletion
US10282286B2 (en) Address mapping using a data unit type that is variable
TW201520889A (en) Hybrid storage
CN110502455B (en) Data storage method and system
EP3958107A1 (en) Storage system, memory management method, and management node
WO2022095346A1 (en) Blockchain data storage method, system, device, and readable storage medium
JPWO2009096180A1 (en) MEMORY CONTROLLER, NONVOLATILE STORAGE DEVICE, AND NONVOLATILE STORAGE SYSTEM
US20180275889A1 (en) Append only streams for storing data on a solid state device
EP4012547B1 (en) Storage method and apparatus for key value (kv) and storage device
WO2015018305A1 (en) Storage method and storage system of memory
WO2021159711A1 (en) B+ tree access method and apparatus, and computer-readable storage medium
EP3974974A1 (en) Virtualization method and system for persistent memory
WO2020192710A1 (en) Method for processing garbage based on lsm database, solid state hard disk, and storage apparatus
WO2016082559A1 (en) Data writing method and storage device
WO2017000821A1 (en) Storage system, storage management device, storage device, hybrid storage device, and storage management method
JP6531574B2 (en) Storage device, storage device control program and storage device control method
WO2016206070A1 (en) File updating method and storage device
US10768829B2 (en) Opportunistic use of streams for storing data on a solid state device
US20220350779A1 (en) File system cloning method and apparatus
US11132134B2 (en) Flexible over-provisioning of storage space within solid-state storage devices (SSDs)
JP6378364B2 (en) File management method and file system
US20100217787A1 (en) Controller, information recording device, access device, information recording system, and information recording method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19851360

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19851360

Country of ref document: EP

Kind code of ref document: A1