WO2016045096A1 - 一种文件迁移方法、装置和存储设备 - Google Patents

一种文件迁移方法、装置和存储设备 Download PDF

Info

Publication number
WO2016045096A1
WO2016045096A1 PCT/CN2014/087572 CN2014087572W WO2016045096A1 WO 2016045096 A1 WO2016045096 A1 WO 2016045096A1 CN 2014087572 W CN2014087572 W CN 2014087572W WO 2016045096 A1 WO2016045096 A1 WO 2016045096A1
Authority
WO
WIPO (PCT)
Prior art keywords
data block
file
target data
target
write time
Prior art date
Application number
PCT/CN2014/087572
Other languages
English (en)
French (fr)
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 华为技术有限公司
Priority to EP14897428.0A priority Critical patent/EP3035197B1/en
Priority to JP2016549609A priority patent/JP6122557B2/ja
Priority to CN201480037601.8A priority patent/CN105637491B/zh
Priority to PCT/CN2014/087572 priority patent/WO2016045096A1/zh
Priority to US15/085,626 priority patent/US10417186B2/en
Publication of WO2016045096A1 publication Critical patent/WO2016045096A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1724Details of de-fragmentation performed by the file system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/06Addressing a physical block of locations, e.g. base addressing, module addressing, memory dedication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/214Database migration support
    • 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/061Improving I/O performance
    • 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/0614Improving the reliability of storage systems
    • G06F3/0619Improving the reliability of storage systems in relation to data integrity, e.g. data losses, bit errors
    • 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/0638Organizing or formatting or addressing of data
    • G06F3/0643Management of files
    • 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/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/065Replication 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/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1203Improving or facilitating administration, e.g. print management
    • G06F3/1204Improving or facilitating administration, e.g. print management resulting in reduced user or operator actions, e.g. presetting, automatic actions, using hardware token storing data
    • 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1222Increasing security of the print job
    • 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1236Connection 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1237Print job management
    • G06F3/1238Secure printing, e.g. user identification, user rights for device usage, unallowed content, blanking portions or fields of a page, releasing held jobs
    • 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1237Print job management
    • G06F3/1253Configuration of print job parameters, e.g. using UI at the client
    • G06F3/1258Configuration of print job parameters, e.g. using UI at the client by updating job settings at the printer
    • 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1278Dedicated interfaces to print systems specifically adapted to adopt a particular infrastructure
    • G06F3/1285Remote printer device, e.g. being remote from client or server
    • 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/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1278Dedicated interfaces to print systems specifically adapted to adopt a particular infrastructure
    • G06F3/1292Mobile client, e.g. wireless printing

Definitions

  • Embodiments of the present invention relate to the field of storage technologies, and in particular, to a file migration method, apparatus, and storage device.
  • a file system is a data structure that stores and organizes user data, providing users with simple and convenient data access.
  • the storage space on the disk is transparent to the user. The user does not care about the specific location where the data is stored on the disk, and the data can be accessed only by accessing the directory or file.
  • the write redirection (full name: Redirection On Write, RW for short) file system refers to the file system that writes data by means of write-time redirection.
  • the new data will not overwrite the old data. Instead, the new space is allocated on the storage device to write the data.
  • the new data is successfully written, the new data is released. Storage space for old data.
  • new storage space is continuously allocated on the storage device, and the storage space of the old data is continuously released, and the storage space of the released old data is also discrete and cannot be written. Into the new data, it caused the problem of fragmentation of storage space on the disk. Therefore, it is necessary to defragment the storage space. Defragmentation refers to arranging discrete small pieces of free storage space into large contiguous storage spaces.
  • the embodiment of the invention provides a file migration method, device and storage device, which can migrate the target file into a pre-allocated continuous storage space, thereby achieving the purpose of disk defragmentation.
  • a first aspect of the embodiments of the present invention provides a file migration method, where the method is applied to a storage device, where the storage device stores a target file, and the target file includes multiple data blocks, and the method includes:
  • the target data block is migrated into a pre-allocated continuous storage space.
  • the method further includes:
  • the continuous storage space is pre-allocated, and the size of the storage space is not less than the size of the target file.
  • the method further includes:
  • the migrating the target data block into the pre-allocated contiguous storage space comprises: writing the target data block into a storage space corresponding to the physical address.
  • the method further includes:
  • the time at which the physical address and the target data block are written into the storage space corresponding to the physical address is saved in the metadata of the target file.
  • the target data block is obtained from the metadata of the target file according to the logical address of the target data block
  • the method further includes:
  • the storage device acquires metadata of the target file
  • the snapshots include:
  • the storage device acquires a snapshot of the metadata of the target file when a preset time arrives or when a file migration instruction is received.
  • a second aspect of the embodiments of the present invention provides a file migration device, where the device is located in a storage device, the storage device stores an object file, the object file includes a plurality of data blocks, and the device includes a defragmentation module.
  • the defragmentation module includes:
  • a snapshot obtaining module configured to acquire a snapshot of the metadata of the target file, where the snapshot includes a logical address of the plurality of data blocks and a first write time of the plurality of data blocks, the first write Time refers to the time when the data block recorded in the snapshot is written to the storage device;
  • An address mapping module configured to save a snapshot of the metadata of the target file and metadata of the target file
  • the snapshot obtaining module is further configured to determine a logical address of the target data block and a first of the target data block from a logical address of the plurality of data blocks and a first write time of the plurality of data blocks Write time
  • a migrating module configured to obtain, according to a logical address of the target data block, a second write time corresponding to a logical address of the target data block from metadata of the target file saved by the address mapping module, where
  • the metadata of the target file includes a logical address of the target data block and the second write time, and the second write time refers to a time when the target data block was last written to the storage device;
  • the migration module is further configured to: when the first write time is the same as the second write time, migrate the target data block into a pre-allocated continuous storage space.
  • the file migration apparatus further includes a space management module, configured to pre-allocate the continuous storage space, where the size of the storage space is not less than the target file. size.
  • the migration module is further configured to allocate a physical to the target data block in the storage space.
  • the migration module is specifically configured to: write the target data block into a storage space corresponding to the physical address.
  • the migration module is further configured to: after the physical address is allocated to the target data block in the storage space, The physical address and the time at which the target data block is written to the storage space corresponding to the physical address are saved in the metadata of the target file.
  • the migrating module is further configured to perform performing, adding, to the logical address of the target data block and the second write time. a lock operation, such that a logical address of the target data block and the second write time are after the second write time corresponding to the logical address of the target data block to the physical address and the The time at which the target data block is written to the storage space corresponding to the physical address cannot be modified until it is saved in the metadata of the target file.
  • the defragmentation module further includes a trigger
  • the trigger is configured to set a preset time or receive a file migration instruction
  • the snapshot obtaining module is configured to acquire a snapshot of the metadata of the target file when a preset time arrives or when a file migration instruction is received.
  • a third aspect of the embodiments of the present invention provides a storage device, where the storage device includes a controller and a magnetic disk, and the controller includes a processor and a communication interface;
  • the communication interface is configured to communicate with the disk
  • the processor is configured to acquire a snapshot of the metadata of the target file, where the snapshot includes a logical address of the multiple data blocks and a first write time of the multiple data blocks, the first write The entry time refers to the time when the data block recorded in the snapshot is written to the disk;
  • the target data block is migrated into a pre-allocated continuous storage space.
  • the processor is further configured to pre-allocate the contiguous storage space, where the size of the storage space is not less than a size of the target file.
  • the processor is further configured to allocate a physical to the target data block in the storage space
  • the processor is specifically configured to write the target data block into a storage space corresponding to the physical address.
  • the processor is further configured to: after the physical data address is allocated to the target data block in the storage space, The physical address and the time at which the target data block is written to the storage space corresponding to the physical address are saved in the metadata of the target file.
  • the processor is further configured to:, in the according to the logical address of the target data block, the element from the target file When the second write time corresponding to the logical address of the target data block is obtained in the data, Performing a lock operation on the logical address of the target data block and the second write time, such that the logical address of the target data block and the second write time correspond to the logical address of the target data block After the second write time until the time when the physical address and the target data block are written into the storage space corresponding to the physical address are saved in the metadata of the target file, the modification cannot be performed.
  • the processor is specifically configured to be preset When the time arrives or when a file migration instruction is received, the storage device acquires a snapshot of the metadata of the target file.
  • the storage device acquires a snapshot of the metadata of the target file, where the snapshot includes a logical address of the plurality of data blocks and a first write time of the plurality of data blocks, the first write time Means the time at which the data block recorded in the snapshot is written to the storage device; determining the target data block from a logical address of the plurality of data blocks and a first write time of the plurality of data blocks a logical address and a first write time of the target data block; obtaining, according to the logical address, a second write time corresponding to the logical address from metadata of the target file, the second write time Referring to the time when the target data block was last written to the storage device, and determining that the first write time and the second write time are the same, indicating that the target data block has not been modified after the snapshot, then Migrating to a pre-allocated contiguous storage space, thereby migrating the entire object file into the contiguous storage space for disk defragmentation purposes.
  • FIG. 1 is a structural diagram of a storage system according to an embodiment of the present invention.
  • FIG. 2 is a hardware composition structure of a controller according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a logical structure of a file system according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a B+ tree of metadata of a file according to an embodiment of the present invention.
  • FIG. 5 is a schematic flowchart of a file migration method according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a B+ tree of a snapshot of metadata of a file according to an embodiment of the present invention
  • FIG. 7 is a schematic diagram of a defragmentation process with file as a granularity according to an embodiment of the present invention.
  • the embodiment of the invention provides a file migration method, a file migration device and a storage device, which can migrate the target file into a continuous storage space to achieve the purpose of defragmenting the storage space of the disk.
  • the file is often locked during the migration process to prevent the user from modifying the file. Since the file contains several data blocks, in the prior art, each data block needs to be migrated in order to unlock the file, which affects the user's access to the file.
  • the embodiment of the present invention not only achieves the purpose of defragmentation, but also does not lock the file during the migration process of the file, but obtains a snapshot of the metadata of the file, and further obtains that the file has not been modified after the snapshot.
  • the data blocks are migrated to pre-allocated contiguous storage space, making the file migration process transparent to the user.
  • the metadata of the file refers to the data describing the file information, including the logical address, the physical address, the mapping relationship between the logical address and the physical address, and the data block write storage of the data block included in the file.
  • Information such as the time of the device.
  • FIG. 1 depicts a composition diagram of a storage system provided by an embodiment of the present invention.
  • the storage system illustrated in FIG. 1 includes at least one application server 10 and at least one storage device 20.
  • the application server 10 can include any computing device known in the art, such as a host, server, desktop computer, and the like.
  • An application 11 is run in the application server 10, and the user can transmit various file processing requests to the storage device 20 through the application 11.
  • the storage device 20 and the application server 11 can perform data transmission through the NFS/CIFS protocol in the network, and can be any storage device including a file system, such as a storage array, a storage server, etc., which is known in the prior art. .
  • the storage device 20 includes a controller 21 and a plurality of disks 31.
  • Controller 21 may comprise any computing device known in the art, such as a server, desktop computer, or the like. Inside the controller, a file system 210 and other applications are installed. The controller 21 is operative to perform various operations of the file processing request, such as creating a file operation, opening a file operation, reading a file operation, writing a file operation, and the like.
  • the storage device 20 includes a plurality of disks 31 for providing storage space to save files.
  • FIG. 2 is a schematic structural diagram of the controller 21 according to the embodiment of the present invention.
  • the controller 21 mainly includes a processor 118, a cache 120, a memory 122, a communication bus (abbreviated as bus) 126, and a communication interface 128.
  • the processor 118, the cache 120, the memory 122, and the communication interface 128 complete communication with one another via the communication bus 126.
  • the communication interface 128 is configured to communicate with the application server 10 or the disk 31.
  • the memory 122 is configured to store the program 124.
  • the memory 122 may include a high speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory. It can be understood that the memory 122 can be a random access memory (RAM), a magnetic disk, a hard disk, an optical disk, a solid state disk (SSD), or a nonvolatile memory, and can store program codes. Non-transitory machine readable medium.
  • Program 124 can include program code, including file system 210 and other program code.
  • a cache 120 is used to buffer data received from the application server 10 or data read from the disk 31.
  • the cache 120 may be a non-transitory machine readable medium that can store data, such as a RAM, a ROM, a flash memory, or a solid state disk (SSD), which is not limited herein.
  • memory 122 and the cache 120 may be provided in combination or separately, which is not limited by the embodiment of the present invention.
  • the processor 118 may be a central processing unit CPU, or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.
  • the processor 118 may be configured to receive various file processing requests from the application server 10, and perform various operations of the file processing request, such as a file migration operation, a read file operation, by the file system 210, Write file operations and more.
  • File system 210 is a method of storing and organizing data in storage device 20 that facilitates access and lookup of data.
  • File system 210 replaces the use of physical devices such as disks with abstract logical concepts of files and tree directories. The concept of data blocks.
  • the storage device 20 uses the file system 210 to save data, the user does not have to care about the data block whose data is actually stored on the disk, and only needs to remember the directory and file name of the file. Similarly, before writing new data, the user does not have to care that the block address on the disk is not being used.
  • the storage space management (allocation and release) function on the disk is automatically done by the file system 210, and the user only needs to remember that the data is written. Which file was entered. It should be noted that although the data stored in the storage device 20 is presented to the user in the form of a file, the unit in which the file is stored in the disk 31 is still a data block. Therefore, a file can contain multiple data blocks.
  • the file system 210 in this embodiment is a write redirection (full name: Redirection On Write, RW for short) file system.
  • RW Redirection On Write
  • the new data does not overwrite the old data, but a new space is allocated on the storage device 20 to write new data, and when the new data is successfully written, Free up storage space for old data.
  • the disk space on the storage device 20 constantly allocates new storage space, and the original continuous user data becomes discrete due to multiple modifications, thereby affecting the data. Access performance. Therefore, a defragmentation module is added to the file system 210 in this embodiment for defragmenting the disk space on the storage device 20.
  • FIG. 3 is an embodiment of the present invention.
  • the file system 210 mainly includes a defragmentation module 214 and a space management module 212.
  • the defragmentation module 214 is configured to migrate the data blocks included in the target file;
  • the space arranging module 212 is configured to pre-allocate a contiguous storage space to save the migrated data blocks.
  • the defragmentation module 214 can include a snapshot acquisition module 2140, an address mapping module 2145, and a migration module 2144.
  • the snapshot obtaining module 2140 is configured to acquire a snapshot of the metadata of the target file;
  • the address mapping module 2145 is configured to save a snapshot of the metadata of the target file and metadata of the target file;
  • the migration module 2144 is configured to The metadata of the target file is searched in the address mapping module 2145, and the migration module 2144 is further configured to migrate data included in the target file into the pre-allocated continuous storage space.
  • the snapshot obtaining module 2140 may include: a finishing control module 2143 and a snapshot adapter 2141.
  • the finishing control module 2143 is configured to control the entire process of defragmentation, and implements a defragmentation function by coordinating the division of labor of several other modules; the snapshot adapter 2141 may be configured to generate a snapshot of the metadata of the target file.
  • the snapshot adapter 2141 may only be used for data interaction with the snapshot module 211, for example, to the snapshot module 211. A snapshot request is sent, and the snapshot module 211 is required to generate a snapshot and save the snapshot information.
  • the defragmentation module 214 may further include: a trigger 2142.
  • Trigger 2142 is the entry to initiate defragmentation, providing file system 210 with the timing and strategy for defragmentation. Specifically, a timer may be set in the trigger 2142. When the preset time arrives, the defragmentation task is started, or other trigger conditions are set, and when the preset condition is met, the defragmentation task is started.
  • the trigger 2142 can also be used to receive a file migration instruction, a defragmentation instruction, or the like to initiate a defragmentation task.
  • the trigger 2142 is configured with a defragmentation policy, for example, defragmentation in units of files or defragmentation in units of directories or defragmentation in units of all files.
  • the file system 210 can further include a data IO module 213 for implementing magnetic
  • the space management module 212 is pre-allocated in a contiguous storage space.
  • the new metadata can be saved in the address mapping module 2145.
  • the new metadata here includes a logical address of the data block, a physical address of a storage space in which the data block is written, a correspondence between the logical address and the physical address, and a time at which the data block is written. And other information. It should be noted that the physical address of the data block changes before and after the migration, and the logical address does not change. However, since the physical address is shielded from the application server 10, the migration process of the data block and the entire file is transparent to the application server 10. .
  • file system 210 can also include other functional modules, which are not discussed in the embodiment of the present invention.
  • the file system 210 includes both the snapshot adapter 2141 and the snapshot module 211, wherein the snapshot module 211 is configured to perform an operation of generating a snapshot, and the snapshot adapter 2141 is used for
  • the snapshot module 211 performs data interaction, requires the snapshot module 211 to generate a snapshot, and saves snapshot information and the like.
  • the functionality of the snapshot module 211 can be integrated into the snapshot adapter 2141, and the snapshot adapter 2141 performs the operations of generating a snapshot.
  • the module division of the file system 210 shown in FIG. 3 is merely an exemplary description of the embodiments of the present invention, as long as the modules capable of performing the above functions are within the protection scope of the embodiments of the present invention.
  • the address mapping module 2145 can manage the mapping relationship between the logical address and the physical address using an address mapping tree (eg, a B+ tree).
  • Figure 4 is a schematic diagram of the B+ tree corresponding to the file system, as shown in Figure 4:
  • the B+ tree corresponding to the file system herein refers to a B+ tree for managing metadata of all files in the storage device.
  • the B+ tree includes a root node, an index of each level, and a plurality of leaf nodes, wherein the root node is an entry of the B+ tree, and the root node can enter the B+ tree.
  • Each leaf node holds a pair of key values (full name: Key-Value, abbreviated as KV).
  • KV Key-Value
  • the Key field is used to store a logical address, also known as a logical offset or a logical start address; the Value field holds two parts of content, one is the write time and the other is the physical address.
  • the physical address refers to a specific location where the data block pointed to by the logical address is stored on the disk; the write time refers to the time when the data block pointed to by the logical address is written to the disk.
  • the representation of the write time may be a 64-bit serial number or a numerical or alphabetic sequence, or other manners.
  • the embodiment of the present invention does not limit the form of the write time. Also, it can be understood that the write time can be the time allocated before the data block pointed to by the logical address is written to the disk, and not necessarily the time when the data block is actually written to the disk.
  • each physical address can point to the metadata of a file or the metadata of the directory, so a subtree corresponding to the file can be obtained by the B+ tree corresponding to the file system (the file corresponds to B+ tree).
  • the B+ tree corresponding to the file also includes all levels of indexes and a plurality of leaf nodes, and each leaf node holds a pair of KVs, wherein the Key field and the Value field have the same definition as the above table. Since a file is composed of multiple data blocks, the physical address stored in the Value field in the subtree of the file can point to the metadata of one or more data blocks.
  • FIG. 5 is a flowchart of a file migration method according to an embodiment of the present invention. As shown in FIG. 5, the method includes:
  • Step S301A The processor 118 acquires a snapshot of the metadata of the target file, the target file includes a plurality of data blocks, the snapshot includes a logical address of the plurality of data blocks and a first write of the plurality of data blocks Time, the first write time refers to the time when the data block recorded in the snapshot is written to the storage device.
  • the metadata of the target file is saved in a B+ tree corresponding to the file, and each leaf node of the B+ tree holds a pair of Key-Value (KV), wherein the Key field is used as a retrieval value.
  • KV Key-Value
  • the Value field is used as a value for storing the physical address of each data block and the time each data block is written to the storage device 20.
  • the step S301A can be performed when the preset time arrives or when the file migration instruction is received.
  • the trigger 2142 of FIG. 3 and related description and details are not described herein again.
  • step S301A the processor 118 needs to generate a snapshot of the metadata of the target file.
  • a snapshot is an image of the corresponding data at a certain write time (the write time at which the copy begins).
  • the metadata of the target file can generate a frozen image that will not be modified.
  • the metadata of the target file is organized according to the B+ tree corresponding to the file shown in FIG. 4, and the snapshot of the metadata of the target file refers to another B+ tree corresponding to the file.
  • a B+ tree as shown in Figure 6.
  • the B+ tree corresponding to the metadata of the target file (hereinafter referred to as the B+ tree corresponding to the file) and the B+ tree corresponding to the snapshot are root nodes. Different, but you can share leaf nodes.
  • the processor 118 may receive a modification request for the data block, and the modification request is used to modify the data block by modifying the new allocation of the modified data block.
  • a piece of storage space, the modified data block is written into the newly allocated storage space, and after the write is successful, the storage space where the data block before the modification is located is released.
  • the processor 118 may generate a KV according to the modification request, and insert a new leaf node in the B+ tree corresponding to the file to save the newly generated KV.
  • the Key field in the newly generated KV is still the logical address of the modified data block
  • the physical address in the Value field is an address in which the modified data block is stored in the newly allocated storage space.
  • the write time in the Value field is the time when the modified data block is written into the newly allocated storage space. Since the logical address is unchanged, the write time is also the data block pointed to by the logical address. The last write time.
  • the new leaf node is the The leaf node of the B+ tree corresponding to the file is not shared with the B+ tree corresponding to the snapshot. Therefore, although the B+ tree corresponding to the file and the B+ tree corresponding to the snapshot share some leaf nodes, the write time saved in the Value field in the B+ tree corresponding to the file and the write time saved in the B+ tree corresponding to the snapshot represent different meanings. .
  • the write time saved in the B+ tree corresponding to the snapshot is referred to as the first write time
  • the write time saved in the B+ tree corresponding to the file is called For the second write time.
  • the first write time refers to the time when the data block recorded in the snapshot is written to the storage device
  • the second write time refers to the latest write time of the data block.
  • Step S301B The processor 118 determines a logical address of the target data block and a first write time of the target data block from a logical address of the plurality of data blocks and a first write time of the plurality of data blocks. .
  • this data block in order to facilitate the migration process by using one data block in the target file, this data block is referred to as a target data block. It can be understood that, in addition to the target data block, other data blocks in the target file are migrated in the same manner.
  • the device 118 may scan the KV corresponding to each data block to obtain a KV corresponding to the target data block.
  • the Key field includes a logical address of the target data block
  • the Value field includes a first write time of the target data block.
  • Step S302 The processor 118 obtains, according to the logical address of the target data block, a second write time corresponding to the logical address of the target data block from the metadata of the target file, where the metadata of the target file includes a logical address of the target data block and the second write time, the second write time being a time when the target data block was last written to the storage device.
  • the metadata of the target file refers to the B+ tree corresponding to the file. Since the logical address of the target data block is obtained in step S301A, the corresponding address may be corresponding to the file according to the logical address.
  • the B+ tree finds the KV corresponding to the logical address. Among them, The Key field is used to save the logical address, and the Value field is used to save the second write time (see the description in step S301A), so the second write time can be further obtained.
  • Step S303 When it is determined that the first write time is the same as the second write time, the processor 118 migrates the target data block into a pre-allocated continuous storage space.
  • the processor 118 may determine whether the two are the same. If they are the same, the target data block is not modified after the snapshot is generated, so the The target data block is migrated into a pre-allocated contiguous storage space; if not, the target data block is modified after the snapshot is generated, and the modified data block has been written into the new storage space, The target data block does not need to be migrated.
  • the pre-allocated continuous storage space may be allocated before performing step S301A, or may be allocated before step 303 after step S301A is performed.
  • the size of the continuous storage space is not less than the size of the target file, so that there is enough space to store each data block of the migrated target file, so as to achieve the purpose of defragmentation.
  • the allocation manner may be that a sufficient storage space is allocated at a time, or may be a plurality of allocations, and the total allocated storage space is not smaller than the size of the target file.
  • the storage device acquires a snapshot of the metadata of the target file, where the snapshot includes a logical address of the plurality of data blocks and a first write time, where the first write time refers to the record in the snapshot.
  • the time at which the data block is written to the storage device; from the logical address of the plurality of data blocks and the first write time, determining a logical address of the target data block and a first write time; according to the logic Obtaining, by the metadata of the target file, a second write time corresponding to the logical address, where the second write time refers to a time when the target data block is last written to the storage device, when When a write time and a second write time are the same, it is indicated that the target data block has not been modified after the snapshot, and then migrated to a pre-allocated continuous storage space, thereby achieving the purpose of defragmentation.
  • the target file in the migration process, is not locked, and the data block that has not been modified after the snapshot is obtained through the snapshot of the metadata of the target file, and the data block is migrated to the pre- Allocated in contiguous storage space, therefore
  • the file migration process of the embodiment of the present invention may not affect the user's access to the file, and improve the access efficiency of the file.
  • the target data block is written into the pre-allocated storage.
  • the target data block needs to be allocated a physical address in the storage space, and after the physical address is allocated, the target data block is written into the storage space corresponding to the physical address.
  • the file migration method shown in FIG. 5 may further include:
  • Step S304 The processor 118 saves the logical address of the target data block, the migrated physical address, and the time when the target data block is written into the storage space corresponding to the physical address in the B+ corresponding to the file. In the tree.
  • the time when the target data block is written in the storage space corresponding to the physical address that is, the time when the storage device is last written, that is, the second write time described earlier.
  • step S304 may specifically be: generating a new leaf node into the B+ tree corresponding to the file, and modifying the index of each level between the new leaf node and the root node of the B+ tree corresponding to the file.
  • the new leaf node is configured to save a new KV, where a Key field is used to save the logical address, the Value field is used to save the migrated physical address, and the target data block is written to the physical address
  • the time in the corresponding storage space may not be a time in a strict sense, but an assigned serial number or other form.
  • the method further includes:
  • the processor 118 performs a lock operation on the logical address and the second write time when obtaining the second write time corresponding to the logical address from the metadata of the target file according to the logical address, The logical address and the second write time are not allowed to be after the second write time corresponding to the obtaining the logical address until the physical address is allocated to the target data block in the storage space modify.
  • the performing the locking operation on the logical address and the second writing time may be: executing, in the B+ tree corresponding to the file, the leaf node where the KV corresponding to the logical address is located A locking operation whose purpose is to prevent the target data block from being modified.
  • the specific locking operation can be implemented by using various existing locking algorithms, which will not be discussed in detail herein.
  • the embodiment may further include: the processor 118 performing an unlocking operation on the logical address and the second writing time. After the unlock operation is performed, the target data block can be modified.
  • the embodiment does not limit the timing of the unlocking, and may be performed before the step S304 is performed, and may be performed before the processor 118 writes the target data block to the storage space corresponding to the physical address.
  • the processor 118 executes the target data block after writing to the storage space corresponding to the physical address.
  • Modification means that the target data block cannot be modified.
  • the processor 118 receives a modification request for modifying the target data block, the modification request will be suspended until the logical address and the second Write time to perform the unlock operation.
  • the modification request is only an example of an embodiment of the present invention, and other access requests, such as a read request, etc., will also be suspended.
  • the target data block cannot be modified during the locking operation to the logical address and the second write time to the unlocking period, the other target data blocks are excluded. Data blocks outside of it can still accept modification requests or other access requests. Because in the embodiment of the present invention, the locked object is the metadata of the target data block, and other data blocks are not affected thereby. This makes the file migration method of the embodiment of the present invention not affect the user access of the migrated file as much as possible, thereby improving the user experience.
  • the file migration method shown in FIG. 5 is described by taking one data block in the migration target file as an example. When all the data blocks in the target file are migrated in the same manner, the target file is used. The defragmentation for granularity is also complete.
  • the defragmentation of disk space can be either a file granularity or a directory granularity.
  • the directory-level defragmentation process is similar to the file-based defragmentation process shown in Figure 5, and is not described here.
  • the defragmentation of disk space can also be granular to all files stored in the storage device 20.
  • the method flow shown in Figure 5 can be cycled until all files have been migrated.
  • a snapshot of metadata of all files ie, a B+ tree corresponding to the file system shown in FIG. 4 may be acquired, and then each file recorded in the snapshot is sequentially acquired.
  • the KVs of the data blocks are all migrated until all the data blocks have been migrated.
  • the specific process is similar to the embodiment shown in FIG. 5, and details are not described herein again.
  • the file migration device provided by the embodiment of the present invention is described below with reference to FIG. 3, the device is located in a storage device, the storage device stores an object file, the object file includes a plurality of data blocks, and the file migration device and FIG.
  • the illustrated file system 210 has the same structure.
  • the file migration apparatus includes a defragmentation module 214, and the defragmentation module 214 includes a snapshot acquisition module 2140, an address mapping module 2145, and a migration module 2144.
  • the snapshot obtaining module 2140 is configured to acquire a snapshot of the metadata of the target file, where the snapshot includes a logical address of the multiple data blocks and a first write time of the multiple data blocks, where the first A write time refers to a time when the data block recorded in the snapshot is written to the storage device;
  • the address mapping module 2145 is configured to save a snapshot of the metadata of the target file and metadata of the target file.
  • the snapshot obtaining module 2140 is further configured to determine, from a logical address of the plurality of data blocks and a first write time of the plurality of data blocks, a logical address of the target data block and a number of the target data block a write time;
  • a migration module 2144 configured to obtain, according to a logical address of the target data block, a second write time corresponding to a logical address of the target data block from metadata of an object file saved by the address mapping module, where the target The metadata of the file includes the logical address and location of the target data block a second write time, where the second write time refers to the time when the target data block was last written to the storage device;
  • the migration module 2144 is further configured to: when the first write time is the same as the second write time, migrate the target data block into a pre-allocated continuous storage space.
  • the file migration apparatus further includes a space management module 212, configured to pre-allocate the contiguous storage space, where the size of the storage space is not less than a size of the target file.
  • a space management module 212 configured to pre-allocate the contiguous storage space, where the size of the storage space is not less than a size of the target file.
  • the migrating module 2144 is further configured to allocate a physical address to the target data block in the storage space, where the migration module 2144 is further configured to be the target data block in the storage space.
  • the time at which the physical address and the target data block are written to the storage space corresponding to the physical address after the physical address is allocated is saved in the metadata of the target file.
  • the migration module 2144 is further configured to perform a locking operation on the logical address of the target data block and the second write time, so that the logical address of the target data block and the second write The entry time is saved after the second write time corresponding to the logical address of the target data block is obtained, and the time when the physical address and the target data block are written into the storage space corresponding to the physical address is saved.
  • the metadata of the target file cannot be modified before.
  • the defragmentation module 214 further includes a trigger 2142;
  • the trigger 2142 is configured to set a preset time or receive a file migration instruction
  • the snapshot obtaining module 2140 is configured to acquire a snapshot of the metadata of the target file when a preset time arrives or when a file migration instruction is received.
  • FIG. 7 is a schematic diagram of a defragmentation process with file size.
  • the file described in the following steps may be the object file in the file migration process shown in FIG. 5, and the respective modules described in the following steps have the same definition and function as the respective modules shown in FIG.
  • the method includes:
  • Step S401 Timing triggers the defragmentation task.
  • the user can trigger a defragmentation task periodically through a timer, or the user manually starts the defragmentation task.
  • Step S402 The trigger 2142 sends an instruction to the collation control module 2143 to instruct to start the defragmentation task.
  • Step S403 The finishing control module 2143 sends a query instruction to the address mapping module 2145, and requests to find the metadata of the file in the address mapping tree saved by the address mapping module 2145.
  • the metadata of the file in the address mapping tree may be a B+ tree corresponding to the file shown in FIG. 4 or FIG. 6.
  • Step S404 The address mapping module 2145 returns information of the metadata of the file to the collation control module 2143, and the information may be location information of the metadata of the file in the file system, and the like.
  • Step S405 The finishing control module 2143 sends a snapshot generation instruction to the snapshot adapter 2141, requesting to generate a snapshot of the metadata of the file, and the snapshot generation instruction may include information of the metadata of the file.
  • Step S406 The snapshot adapter 2141 forwards the snapshot generation instruction to the snapshot module 211.
  • Step S407 The snapshot module 211 accesses the address mapping module 2145, generates a snapshot of the metadata of the file, and saves it in the address mapping module 2145.
  • the snapshot module 211 can find the metadata of the file in the address mapping module 2145 according to the information of the metadata of the file, and generate a snapshot.
  • the method for generating the method refer to the description in step S301A in the file migration process shown in FIG. 5, and details are not described herein again.
  • Step S408 The address mapping module 2145 returns a response request of the snapshot generation instruction to the snapshot module 211 to indicate that the snapshot of the metadata of the file has been generated and saved successfully.
  • the response request includes information of a snapshot
  • the information of the snapshot includes information such as an address of the snapshot stored in the address mapping module 2145.
  • Step S409 The snapshot module 211 returns a response request of the snapshot generation instruction to the snapshot adapter 2141 to indicate that the snapshot of the metadata of the file has been generated and saved successfully.
  • the response request includes information of the snapshot in step S408.
  • Step S410 The snapshot adapter 2141 saves the information of the snapshot.
  • Step S411 The snapshot adapter 2141 returns a response request of the snapshot generation instruction to the collation control module 2143 to indicate that the snapshot is generated and saved successfully.
  • Step S412 The finishing control module 2143 sends a file migration instruction to the migration module 2144.
  • Step S413 The migration module 2144 sends a space application instruction to the space management module 212 to apply for a continuous storage space, and the size of the continuous storage space is not less than the size of the file.
  • this step may refer to the description in step S303 in the file migration process shown in FIG. 5, and details are not described herein again.
  • Step S414 The space management module 212 returns a response request of the space application instruction to the migration module 2144 to indicate that the storage space allocation is successful.
  • Step S415 The migration module 2144 sends a scan request to the snapshot adapter 2141 requesting to scan the snapshot.
  • Step S416 The snapshot adapter 2141 sends a query instruction to the address mapping module 2145 to acquire the first KV.
  • the query instruction includes the information of the snapshot. Since the information of the snapshot includes an address stored in the address mapping module 2145, the address mapping module 2145 may use the file according to the address.
  • a snapshot of the metadata is sent to the snapshot adapter 2141. It can be seen from step S301A of the embodiment shown in FIG. 5 that the snapshot of the metadata of the file refers to the B+ tree corresponding to the snapshot, and the snapshot adapter 2141 can search from the root node of the B+ tree to obtain the KV of the first data block ( Referred to as the first KV). For the KV of the data block, reference may be made to the description of the KV corresponding to the target data block in step S301A of the file migration process shown in FIG. 5, and details are not described herein again.
  • Step S417 The snapshot adapter 2141 sends the first KV to the migration module 2144.
  • Step S418 The migration module 2144 performs a locking operation on the KV of the metadata of the file.
  • Step S419 The migration module 2144 sends a query instruction to the address mapping module 2145 to obtain the KV in the metadata of the file.
  • the migration module 2144 can query the address mapping module 2145 according to the logical address to obtain the KV in the metadata of the file corresponding to the logical address.
  • step S302 of the file migration process shown in FIG. 5 For details, refer to the description of step S302 of the file migration process shown in FIG. 5, and details are not described herein again.
  • Step S420 The address mapping module 2145 returns the KV in the metadata of the file corresponding to the obtained logical address to the migration module 2144.
  • Step S421 The migration module 2144 determines whether the first write time and the second write time are the same.
  • step S303 of the file migration process shown in FIG. 5 For details, refer to the description of step S303 of the file migration process shown in FIG. 5, and details are not described herein again.
  • Step S422 If they are the same, the migration module 2144 sends an update instruction to the address mapping module 2145 to update the metadata of the file.
  • step S304 of the file migration process shown in FIG. 5 For details, refer to the description of step S304 of the file migration process shown in FIG. 5, and details are not described herein again.
  • Step S423 The address mapping module 2145 returns a response request of the update instruction to the migration module 2144 to indicate that the update is successful.
  • Step S424 The migration module 2144 performs an unlocking operation on the KV of the metadata of the file.
  • step S305 of the file migration process shown in FIG. 5 For details, refer to the description of step S305 of the file migration process shown in FIG. 5, and details are not described herein again.
  • step S425 skipping the KV; and step S426: unlocking the KV.
  • steps S416 to S426 are performed cyclically until all KVs are processed.
  • step S427 the snapshot adapter 2141 sends an instruction to scan the completion of the scan to the migration module 2144.
  • Step S428 The migration module 2144 feeds back the file migration completion to the collation control module 2143.
  • Step S429 The finishing control module 2143 sends an instruction to delete the snapshot to the snapshot adapter 2141.
  • Step S430 The snapshot adapter 2141 forwards the instruction to delete the snapshot to the snapshot module 211 to delete the snapshot of the metadata of the file.
  • the storage device acquires a snapshot of the metadata of the target file, where the snapshot includes a logical address of the plurality of data blocks and a first write time, where the first write time refers to the record in the snapshot.
  • the time at which the data block is written to the storage device; from the logical address of the plurality of data blocks and the first write time, determining a logical address of the target data block and a first write time; according to the logic Obtaining, by the metadata of the target file, a second write time corresponding to the logical address, where the second write time refers to a time when the target data block is last written to the storage device, when When a write time and a second write time are the same, it is indicated that the target data block has not been modified after the snapshot, and then migrated to a pre-allocated continuous storage space, thereby achieving the purpose of defragmentation.
  • the target file is not locked, and the data block that has not been modified after the snapshot is obtained through the snapshot of the metadata of the target file, and the data block is migrated to the pre-
  • the file migration process of the embodiment of the present invention may not affect the user's access to the file, and improve the access efficiency of the file.
  • aspects of the present invention, or possible implementations of various aspects may be embodied as a system, method, or computer program product.
  • aspects of the invention, or possible implementations of various aspects may be in the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, etc.), or a combination of software and hardware aspects, They are collectively referred to herein as "circuits," “modules,” or “systems.”
  • aspects of the invention, or possible implementations of various aspects may take the form of a computer program product, which is a computer readable program code stored in a computer readable medium.
  • the computer readable medium can be a computer readable signal medium or a computer readable storage medium.
  • Computer readable storage media includes, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor System, device or device, or any suitable combination of the foregoing, such as random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), fiber optics, portable read only Memory (CD-ROM).
  • the processor in the computer reads the computer readable program code stored in the computer readable medium such that the processor is capable of performing the various functional steps specified in each step of the flowchart, or a combination of steps; A device that functions as specified in each block, or combination of blocks.
  • the computer readable program code can execute entirely on the user's computer, partly on the user's computer, as a separate software package, partly on the user's computer and partly on the remote computer, or entirely on the remote computer or server.
  • the functions noted in the various steps in the flowcharts or in the blocks in the block diagrams may not occur in the order noted. For example, two steps, or two blocks, shown in succession may be executed substantially concurrently or the blocks may be executed in the reverse order.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明实施例提供了一种文件迁移方法、装置和存储设备。其中,所述方法包括:存储设备获取所述目标文件的元数据的快照,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间;从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所述第二写入时间;确定所述第一写入时间与所述第二写入时间相同时,将所述目标数据块迁移到预先分配的连续的存储空间中。可以将目标文件迁移到预先分配的连续的存储空间中,由此达到磁盘碎片整理的目的。

Description

一种文件迁移方法、装置和存储设备 技术领域
本发明实施例涉及存储技术领域,特别是一种文件迁移方法、装置和存储设备。
背景技术
文件系统是一种存储和组织用户数据的数据结构,为用户提供了简单方便的数据访问。对于具有文件系统的存储设备来说,其磁盘上的存储空间对用户是透明的,用户不用关心数据存放在磁盘中的具体位置,仅通过访问目录或文件就可以访问数据。
写重定向(全称:Redirection On Write,简称:ROW)文件系统,是指采用写时重定向方式写数据的文件系统。当新的用户数据写入或者修改原有的用户数据时,新数据不会覆盖掉原来的旧数据,而是在存储设备上分配新的空间写入该数据,当新数据写成功后再释放旧数据的存储空间。然而,随着新数据的不断写入,存储设备上不停地分配新的存储空间,同时旧数据的存储空间不停地释放,而释放出的旧数据的存储空间也是离散的,无法再写入新的数据,那么就造成了磁盘上的存储空间碎片化的问题。因此,对存储空间进行碎片整理就变得必要,碎片整理是指将离散的小块空闲存储空间,整理成大块连续的存储空间。
发明内容
本发明实施例提供了一种文件迁移方法、装置和存储设备,可以将目标文件迁移到预先分配的连续的存储空间中,由此达到磁盘碎片整理的目的。
本发明实施例第一方面提供了一种文件迁移方法,所述方法应用于存储设备中,所述存储设备保存有目标文件,所述目标文件包括多个数据块,所述方法包括:
所述存储设备获取所述目标文件的元数据的快照,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间;
从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;
根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所述第二写入时间,所述第二写入时间是指所述目标数据块最近一次写入所述存储设备的时间;
确定所述第一写入时间与所述第二写入时间相同时,将所述目标数据块迁移到预先分配的连续的存储空间中。
结合第一方面,在第一种可能的实施方式中,所述方法还包括:
预先分配所述连续的存储空间,所述存储空间的大小不小于所述目标文件的大小。
结合第一方面,或者第一方面的第一种可能的实施方式,在第二种可能的实施方式中,所述方法还包括:
在所述存储空间中为所述目标数据块分配物理地址;
所述将所述目标数据块迁移到预先分配的连续的存储空间中包括:将所述目标数据块写入所述物理地址对应的存储空间中。
结合第一方面的第二种可能的实施方式,在第三种可能的实施方式中,在所述存储空间中为所述目标数据块分配物理地址之后,所述方法还包括:
将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中。
结合第一方面的第三种可能的实施方式,在第四种可能的实施方式中,在所述根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间时,所述方法还包括:
对所述目标数据块的逻辑地址和所述第二写入时间执行加锁操作,使得所述目标数据块的逻辑地址和所述第二写入时间在所述获得所述目标数据块的逻辑地址对应的第二写入时间之后至所述将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中之前不能被修改。
结合第一方面,或者第一方面的第一种至第一方面的第四种可能的实施方式,在本发明第五种可能的实施方式中,所述存储设备获取所述目标文件的元数据的快照包括:
当预设的时间到达时或者接收到文件迁移指令时,所述存储设备获取所述目标文件的元数据的快照。
本发明实施例第二方面提供了一种文件迁移装置,所述装置位于存储设备中,所述存储设备保存有目标文件,所述目标文件包括多个数据块,所述装置包括碎片整理模块,其中,所述碎片整理模块包括:
快照获取模块,用于获取所述目标文件的元数据的快照,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间;
地址映射模块,用于保存所述目标文件的元数据的快照以及目标文件的元数据;
所述快照获取模块,还用于从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;
迁移模块,用于根据所述目标数据块的逻辑地址从所述地址映射模块保存的所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所述第二写入时间,所述第二写入时间是指所述目标数据块的最近一次写入所述存储设备的时间;
所述迁移模块,还用于确定所述第一写入时间与所述第二写入时间相同时,将所述目标数据块迁移到预先分配的连续的存储空间中。
结合第二方面,在第一种可能的实施方式中,所述文件迁移装置还包括空间管理模块,用于预先分配所述连续的存储空间,所述存储空间的大小不小于所述目标文件的大小。
结合第二方面,或者第二方面的第一种可能的实施方式,在第二种可能的实施方式中,所述迁移模块,还用于在所述存储空间中为所述目标数据块分配物理地址;所述迁移模块具体用于:将所述目标数据块写入所述物理地址对应的存储空间中。
结合第二方面的第二种可能的实施方式,在第三种可能的实施方式中,所述迁移模块,还用于在所述存储空间中为所述目标数据块分配物理地址之后将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中。
结合第二方面的第三种可能的实施方式,在第四种可能的实施方式中,所述迁移模块,还用于对所述目标数据块的逻辑地址和所述第二写入时间执行加锁操作,使得所述目标数据块的逻辑地址和所述第二写入时间在所述获得所述目标数据块的逻辑地址对应的第二写入时间之后至所述将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中之前不能被修改。
结合第二方面,或者第二方面的第一种至第二方面的第四种可能的实施方式,在本发明第五种可能的实施方式中,所述碎片整理模块还包括触发器;
所述触发器,用于设置预设的时间,或者接收文件迁移指令;
所述快照获取模块,具体用于当预设的时间到达时或者接收到文件迁移指令时,获取所述目标文件的元数据的快照。
本发明实施例第三方面提供了一种存储设备,所述存储设备包括控制器和磁盘,所述控制器包括处理器和通信接口;
所述通信接口,用于与所述磁盘进行通信;
所述处理器,用于获取所述目标文件的元数据的快照,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述磁盘的时间;
从所述多个数据块的逻辑地址和第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;
根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所述第二写入时间,所述第二写入时间是指所述目标数据块最近一次写入所述磁盘的时间;
确定所述第一写入时间与所述第二写入时间相同时,将所述目标数据块迁移到预先分配的连续的存储空间中。
结合第三方面,在第一种可能的实施方式中,所述处理器,还用于预先分配所述连续的存储空间,所述存储空间的大小不小于所述目标文件的大小。
结合第三方面,或者第三方面的第一种可能的实施方式,在第二种可能的实施方式中,所述处理器,还用于在所述存储空间中为所述目标数据块分配物理地址;所述处理器具体用于将所述目标数据块写入所述物理地址对应的存储空间中。
结合第三方面的第二种可能的实施方式,在第三种可能的实施方式中,所述处理器,还用于在所述存储空间中为所述目标数据块分配物理地址之后将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中。
结合第三方面的第三种可能的实施方式,在第四种可能的实施方式中,所述处理器,还用于在所述根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间时,对所述 目标数据块的逻辑地址和所述第二写入时间执行加锁操作,使得所述目标数据块的逻辑地址和所述第二写入时间在所述获得所述目标数据块的逻辑地址对应的第二写入时间之后至所述将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中之前不能被修改。
结合第三方面,或者第三方面的第一种至第三方面的第四种可能的实施方式,在本发明第五种可能的实施方式中,所述处理器,具体用于当预设的时间到达时或者接收到文件迁移指令时,所述存储设备获取所述目标文件的元数据的快照。
在本发明实施例中,存储设备获取目标文件的元数据的快照,所述快照包括多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间;从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;根据所述逻辑地址从所述目标文件的元数据中获得所述逻辑地址对应的第二写入时间,所述第二写入时间是指所述目标数据块最近一次写入所述存储设备的时间,确定第一写入时间和第二写入时间相同时,说明所述目标数据块在快照之后没有被修改过,则将其迁移到预先分配的连续的存储空间中,由此可以将所述整个目标文件迁移到所述连续的存储空间中,达到磁盘碎片整理的目的。
附图说明
为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本发明实施例提供的存储系统的组成图;
图2是本发明实施例提供的控制器的硬件组成结构;
图3是本发明实施例提供的文件系统的逻辑结构示意图;
图4是本发明实施例提供的文件的元数据的B+树示意图;
图5是本发明实施例提供的文件迁移方法的流程示意图;
图6是本发明实施例提供的文件的元数据的快照的B+树示意图;
图7是本发明实施例提供的以文件为粒度的碎片整理流程示意图。
具体实施方式
本发明实施例提供了一种文件迁移方法、文件迁移装置和存储设备,能够将目标文件迁移到连续的存储空间中,达到对磁盘的存储空间进行碎片整理的目的。
现有技术中,在以文件为单位对存储空间进行碎片整理时,在迁移的过程中往往需要将该文件锁定,以避免用户对该文件进行修改。由于文件包含若干个数据块,因此在现有技术中,需要依次将每个数据块迁移完毕之后,才能对该文件解除锁定,这就会影响用户对该文件的访问。而本发明实施例不但能达到碎片整理的目的,并且在文件的迁移过程中,可以不将该文件锁定,而是通过获取所述文件的元数据的快照,进一步获得在快照之后没有被修改过的数据块,将其迁移到预先分配的连续的存储空间中,从而使得文件迁移过程对用户透明。
在本发明实施例中,文件的元数据是指描述文件信息的数据,包括所述文件包含的数据块的逻辑地址、物理地址、逻辑地址与物理地址之间的映射关系以及数据块写入存储设备的时间等信息。
下面开始对本发明实施例进行详细介绍:
图1描绘了本发明实施例提供的存储系统的组成图,图1所示的存储系统包括至少一个应用服务器10和至少一个存储设备20。所述应用服务器10可以包括当前技术已知的任何计算设备,如主机、服务器、台式计算机等等。应用服务器10中运行有应用程序(application)11,用户可以通过应用程序11向存储设备20发送各种文件处理请求。
所述存储设备20与所述应用服务器11之间可以通过网络中的NFS/CIFS协议进行数据传输,它可以是当前技术已知的任何包含文件系统的存储设备,如存储阵列、存储服务器等等。
存储设备20包括控制器21和若干个磁盘31。控制器21可以包括当前技术已知的任何计算设备,如服务器、台式计算机等等。在控制器内部,安装有文件系统210以及其他应用程序。控制器21用于执行文件处理请求的各种操作,例如创建文件操作、打开文件操作、读文件操作、写文件操作等等。存储设备20包含的若干个磁盘31用于提供存储空间保存文件。
下面介绍控制器21的硬件组成结构,请参考图2,图2是本发明实施例控制器21的结构示意图。如图2所示,控制器21主要包括处理器(processor)118、缓存(cache)120、存储器(memory)122、通信总线(简称总线)126以及通信接口(Communication Interface)128。处理器118、缓存120、存储器122以及通信接口128通过通信总线126完成相互间的通信。
通信接口128,用于与应用服务器10或磁盘31通信。
存储器122,用于存放程序124,存储器122可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。可以理解的是,存储器122可以为随机存储器(Random-Access Memory,RAM)、磁碟、硬盘、光盘、固态硬盘(Solid State Disk,SSD)或者非易失性存储器等各种可以存储程序代码的非短暂性的(non-transitory)机器可读介质。
程序124可以包括程序代码,所述程序代码包括文件系统210以及其他程序代码。
缓存120(Cache)用于缓存从应用服务器10接收的数据或从磁盘31中读取的数据。缓存120可以是RAM、ROM、闪存(Flash memory)或固态硬盘(Solid State Disk,SSD)等各种可以存储数据的非短暂性的(non-transitory)机器可读介质,在此不做限定。
另外,存储器122和缓存120可以合设或者分开设置,本发明实施例对此不做限定。
处理器118可能是一个中央处理器CPU,或者是特定集成电路ASIC(Application Specific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路。在本发明实施例中,处理器118可以用于接收来自应用服务器10的各种文件处理请求,并且通过文件系统210执行所述文件处理请求的各种操作,例如文件迁移操作、读文件操作、写文件操作等等。
文件系统210是一种存储和组织存储设备20中数据的方法,它使得对数据的访问和查找变得容易,文件系统210使用文件和树形目录的抽象逻辑概念代替了磁盘等物理设备使用的数据块的概念。存储设备20在使用文件系统210来保存数据后,用户不必关心数据实际保存在磁盘的地址为多少的数据块上,只需要记住这个文件的所属目录和文件名。同样的,在写入新数据之前,用户不必关心磁盘上的那个块地址没有被使用,磁盘上的存储空间管理(分配和释放)功能由文件系统210自动完成,用户只需要记住数据被写入到了哪个文件中。需要说明的是,虽然存储在存储设备20中的数据是以文件的形式呈现给用户的,然而文件在磁盘31中存储的单位仍然是数据块。因此,一个文件可以包含多个数据块。
本实施例中的文件系统210是写重定向(全称:Redirection On Write,简称:ROW)文件系统。当新的用户数据写入或者修改原有的用户数据时,新数据不会覆盖掉原来的旧数据,而是在存储设备20上分配新的空间写入新数据,当新数据写成功后再释放旧数据的存储空间。然而,随着新数据的不断写入,存储设备20上的磁盘空间不停地进行分配新的存储空间,原本连续的用户数据由于多次被修改就会变得离散,从而影响了该数据的访问性能。因此,在本实施例中的文件系统210中增加了碎片整理模块,以用于对存储设备20上的磁盘空间进行碎片整理。
下面介绍文件系统210的逻辑结构,请参考图3,图3是本发明实施例 文件系统210的逻辑结构示意图。如图3所示,文件系统210主要包括:碎片整理模块214和空间管理模块212。其中,碎片整理模块214用于对目标文件包含的数据块进行迁移;空间整理模块212用于预先分配一块连续的存储空间,以保存所述迁移后的数据块。
具体的,碎片整理模块214可以包括快照获取模块2140、地址映射模块2145和迁移模块2144。其中,快照获取模块2140用于获取所述目标文件的元数据的快照;地址映射模块2145用于保存所述目标文件的元数据的快照以及所述目标文件的元数据;迁移模块2144用于从地址映射模块2145中查找所述目标文件的元数据,并且,迁移模块2144还用于将所述目标文件包含的数据迁移至所述预先分配的连续的存储空间中。
进一步地,快照获取模块2140可以包括:整理控制模块2143和快照适配器2141。其中,整理控制模块2143,用于控制碎片整理的整个流程,通过协调其他几个模块的分工实现碎片整理功能;快照适配器2141可以用于生成所述目标文件的元数据的快照。然而,在某些场景下,文件系统210中已经包含用于生成快照的模块(例如,快照模块211)时,快照适配器2141可以仅用于与快照模块211进行数据交互,例如,向快照模块211发送快照请求,要求快照模块211生成快照并保存快照信息。
另外,可选的,碎片整理模块214还可以包括:触发器2142。触发器2142是启动碎片整理的入口,为文件系统210提供碎片整理的时机和策略。具体而言,触发器2142中可以设置定时器,当预设的时间到达时,启动碎片整理任务,或者设置其他触发条件,当预设的条件满足时,启动碎片整理任务。此外,触发器2142还可以用于接收文件迁移指令、碎片整理指令或者类似指令,以启动碎片整理任务。另外,触发器2142中配置有碎片整理的策略,例如以文件为单位进行碎片整理或者以目录为单位进行碎片整理或者以所有文件为单位进行碎片整理。
可选的,文件系统210中还可以包括数据IO模块213,用于实现对磁 盘31上存储的数据的读写功能,例如,当迁移模块2144确定出待迁移的数据块时,可以将该数据块发送给数据IO模块213,由将数据IO模块213将该数据块写入空间管理模块212预先分配的连续的存储空间中。当所述数据块写入成功之后,可以将新的元数据保存在地址映射模块2145中。这里的新的元数据包括所述数据块的逻辑地址、所述数据块写入的存储空间的物理地址,所述逻辑地址与所述物理地址之间的对应关系、以及数据块写入的时间等信息。需要说明的是,迁移前后所述数据块的物理地址发生变化,逻辑地址不变,然而由于物理地址是对应用服务器10屏蔽的,因此数据块乃至整个文件的迁移过程对应用服务器10是透明的。
可以理解的是,文件系统210还可以包括其他功能模块,本发明实施例暂时不做讨论。
需要说明的是,在图3所示的实施例中,文件系统210既包括了快照适配器2141,也包括了快照模块211,其中快照模块211用于执行生成快照的操作,快照适配器2141用于与快照模块211进行数据交互,要求快照模块211生成快照,以及保存快照信息等。然而,在某些场景中,快照模块211的功能可以集成在快照适配器2141中,由快照适配器2141执行生成快照的操作。总而言之,图3所示的文件系统210的模块划分只是本发明实施例的示例性说明,只要能完成上述功能的模块都在本发明实施例的保护范围以内。
在本实施例中,地址映射模块2145可以利用地址映射树(例如,B+树)管理逻辑地址和物理地址之间的映射关系。图4是文件系统对应的B+树的示意图,如图4所示:
需要说明的是,这里的文件系统对应的B+树是指用于管理所述存储设备中所有文件的元数据的B+树。所述B+树包括根节点,各级索引以及多个叶子节点,其中根节点是所述B+树的入口,通过根节点可以进入所述B+树。每个叶子节点保存一对键值(全称:Key-Value,简称KV)。在本实施例中, Key字段和Value字段的具体定义如下表:
Figure PCTCN2014087572-appb-000001
其中,Key字段用于保存逻辑地址,又称逻辑偏移或者逻辑起始地址;Value字段中保存了两部分内容,一部分是写入时间,另一部分是物理地址。物理地址是指所述逻辑地址指向的数据块存放在磁盘上的具体位置;写入时间是指所述逻辑地址指向的数据块写入磁盘的时间。所述写入时间的表现形式可以是一个64位的序列号或者体现先后顺序的数字或字母,或者其他方式,本发明实施例并不对写入时间的形式做任何限定。并且,可以理解的是,写入时间可以是在所述逻辑地址指向的数据块写入磁盘之前分配的时间,而不一定是所述数据块实际写入磁盘的时间。
由图4可知,由于Value字段中保存有物理地址,每个物理地址可以指向一个文件的元数据或者目录的元数据,因此由文件系统对应的B+树可以获得一个文件的子树(文件对应的B+树)。同样的,所述文件对应的B+树也包括各级索引和多个叶子节点,每个叶子节点保存一对KV,其中Key字段和Value字段的定义与上表相同。由于一个文件是由多个数据块组成的,因此该文件的子树中的Value字段保存的物理地址可以指向一个或多个数据块的元数据。
下面介绍本发明实施例文件迁移的方法流程,本发明实施例中的文件迁移方法可以应用在图2所示的存储设备中。图5是本发明实施例文件迁移方法的流程图,如图5所示,所述方法包括:
步骤S301A:处理器118获取目标文件的元数据的快照,所述目标文件包含多个数据块,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间。
参考图4所示的B+树,所述目标文件的元数据保存在文件对应的B+树中,所述B+树的每个叶子节点保存一对Key-Value(KV),其中Key字段作为检索值,用于保存每个数据块的逻辑地址,Value字段作为值,用于保存每个数据块的物理地址以及每个数据块写入存储设备20的时间。
可选的,步骤S301A可以在预设的时间到达时或者接收到文件迁移指令时执行,具体可参考图3的触发器2142以及相关描述,这里不再赘述。
在步骤S301A中,处理器118需要生成所述目标文件的元数据的快照。快照是指相应数据在某个写入时间(拷贝开始的写入时间)的映像。当快照生成以后,所述目标文件的元数据就可以生成一个被定格的映像,所述映像不会被修改。结合图4,所述目标文件的元数据是按照图4所示的文件对应的B+树组织起来的,所述目标文件的元数据的快照是指将所述文件对应的B+树定格下来的另一棵B+树,如图6所示。在所述快照刚生成时,由于暂时没有对数据块进行修改,所以所述目标文件的元数据对应的B+树(后面简称为文件对应的B+树)和所述快照对应的B+树虽然根节点不同,但可以共用叶子节点。
然而,在快照生成之后,处理器118可能会接收到对所述数据块的修改请求,所述修改请求用于对所述数据块进行修改,其修改方式是:为修改后的数据块新分配一块存储空间,将所述修改后的数据块写入新分配的存储空间中,待写入成功后再释放修改前的数据块所在的存储空间。
那么,相应的,处理器118可以根据所述修改请求生成KV,在所述文件对应的B+树中插入新的叶子节点,以保存所述新生成的KV。此时,所述新生成的KV中的Key字段仍然是所述被修改的数据块的所述逻辑地址,Value字段中的物理地址是修改后的数据块保存在新分配的存储空间中的地址,Value字段中的写入时间是所述修改后的数据块写入新分配的存储空间中的时间,由于逻辑地址不变,所以所述写入时间也就是所述逻辑地址所指向的数据块的最近一次写入时间。可以理解的是,所述新的叶子节点是所述 文件对应的B+树的叶子节点,不会和快照对应的B+树共用。因此,虽然文件对应的B+树和快照对应的B+树共用一些叶子节点,然而文件对应的B+树中的Value字段保存的写入时间和快照对应的B+树中保存的写入时间代表的含义不同。为了将两个写入时间区别开来,在本实施例中,将快照对应的B+树中保存的写入时间称为第一写入时间,将文件对应的B+树中保存的写入时间称为第二写入时间。其中,第一写入时间是指快照中记录的数据块写入所述存储设备的时间,而所述第二写入时间是指数据块的最近一次写入时间。
步骤S301B:处理器118从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间。
在本实施例中,为了方便以所述目标文件中的一个数据块举例说明迁移流程,将这个数据块称为目标数据块。可以理解的是,除所述目标数据块以外,所述目标文件中的其他数据块也是按照同样的方法进行迁移的。
由于快照对应的B+树中保存了所述目标文件包含的各个数据块的KV,因此在获取所述快照对应的B+树之后,也就获得了所述目标文件包含的各个数据块的KV,处理器118可以对所述各个数据块对应的KV进行扫描,获取目标数据块对应的KV。其中所述Key字段包括所述目标数据块的逻辑地址,所述Value字段包括所述目标数据块的第一写入时间。
步骤S302:处理器118根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所述第二写入时间,所述第二写入时间是指所述目标数据块最近一次写入所述存储设备的时间。
在步骤S302中,所述目标文件的元数据是指所述文件对应的B+树,由于在步骤S301A中得到所述目标数据块的逻辑地址,因此可以根据所述逻辑地址在所述文件对应的B+树中查找获得所述逻辑地址对应的KV。其中,所 述Key字段用于保存所述逻辑地址,Value字段用于保存第二写入时间(参见步骤S301A中的描述),因此可以进一步获得所述第二写入时间。
步骤S303:确定所述第一写入时间与所述第二写入时间相同时,处理器118将所述目标数据块迁移到预先分配的连续的存储空间中。
具体的,处理器118在获得第一写入时间和第二写入时间之后,可以判断二者是否相同,如果相同则说明所述目标数据块在生成快照之后没有被修改,因此可以将所述目标数据块迁移到预先分配的连续的存储空间中;如果不相同,则说明所述目标数据块在生成快照之后被修改过,并且修改后的数据块已经写入新的存储空间中,对于这样的目标数据块则不需要迁移。
所以预先分配的连续存储空间可以是在执行步骤S301A之前分配的,也可以是在执行步骤S301A之后步骤303之前分配的。具体的,所述连续的存储空间的大小需不小于所述目标文件的大小,以使得有足够的空间存储迁移后的所述目标文件的各个数据块,从而达到碎片整理的目的。其分配方式可以是,一次分配足够的存储空间,也可以是经过多次分配,其总共分配的存储空间的大小不小于所述目标文件的大小。
在本发明实施例中,存储设备获取目标文件的元数据的快照,所述快照包括多个数据块的逻辑地址和第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间;从所述多个数据块的逻辑地址和第一写入时间中,确定目标数据块的逻辑地址和第一写入时间;根据所述逻辑地址从所述目标文件的元数据中获得所述逻辑地址对应的第二写入时间,所述第二写入时间是指所述目标数据块最近一次写入所述存储设备的时间,当第一写入时间和第二写入时间相同时,说明所述目标数据块在快照之后没有被修改过,则将其迁移到预先分配的连续的存储空间中,由此达到磁盘碎片整理的目的。并且,本发明实施例在迁移过程中不需要对所述目标文件进行锁定,就可以通过所述目标文件的元数据的快照,获得在快照之后没有被修改过的数据块,将其迁移到预先分配的连续的存储空间中,因此 在一定程度上,本发明实施例的文件迁移过程可以不影响用户对文件的访问,提高了文件的访问效率。
在上述步骤S303中,由于所述预先分配的存储空间是一大块连续的存储空间,其大小不小于所述目标文件的大小,所以在将所述目标数据块写入所述预先分配的存储空间之前还需要在所述存储空间中为所述目标数据块分配物理地址,在分配所述物理地址之后,将所述目标数据块写入所述物理地址对应的存储空间中。
那么,相应地,在图5所示的文件迁移方法中还可以包括:
步骤S304:处理器118将所述目标数据块的逻辑地址、所述迁移后的物理地址以及所述目标数据块写入所述物理地址对应的存储空间中的时间保存在所述文件对应的B+树中。
可以理解的是,这里的所述目标数据块写入所述物理地址对应的存储空间中的时间即最近一次写入所述存储设备的时间,也就是前面描述的第二写入时间。
结合图6,步骤S304具体可以是生成一个新的叶子节点插入所述文件对应的B+树中,并修改所述新的叶子节点与所述文件对应的B+树的根节点之间的各级索引。所述新的叶子节点用于保存新的KV,其中Key字段用于保存所述逻辑地址,所述Value字段用于保存所述迁移后的物理地址以及所述目标数据块写入所述物理地址对应的存储空间中的时间。需要说明的是,这里的时间可以不是严格意义上的时间,而是分配的序列号或者其他形式。
进一步地,在图5所示的文件迁移方法中,还可以包括:
处理器118在根据所述逻辑地址从所述目标文件的元数据中获得所述逻辑地址对应的第二写入时间时,对所述逻辑地址和所述第二写入时间执行加锁操作,使得所述逻辑地址和所述第二写入时间在所述获得所述逻辑地址对应的第二写入时间之后至所述在所述存储空间中为所述目标数据块分配物理地址之前不能被修改。
在本实施例中,对所述逻辑地址和所述第二写入时间执行加锁操作具体可以是:在所述文件对应的B+树中,对所述逻辑地址对应的KV所在的叶子节点执行加锁操作,其目的是防止所述目标数据块被修改。具体的加锁操作可以利用现有的各种加锁算法实现,这里不做详细讨论。
相应地,本实施例还可以包括:处理器118对所述逻辑地址和第二写入时间执行解锁操作。执行解锁操作以后,所述目标数据块可以被修改。
需要说明的是,本实施例并不对解锁的时机做任何限定,只要步骤S304之后执行均可,可以在处理器118将目标数据块写入所述物理地址对应的存储空间之前执行,也可以在处理器118将目标数据块写入所述物理地址对应的存储空间之后执行。
可以理解的是,在对所述逻辑地址和所述第二写入时间执行加锁操作至解锁期间,所述逻辑地址和所述第二写入时间作为所述目标数据块的元数据不能被修改,那么意味着所述目标数据块也不能被修改。举例来说,当这段期间内,处理器118接收到用于对所述目标数据块进行修改的修改请求,所述修改请求将会被暂停执行,直至对所述逻辑地址和所述第二写入时间执行解锁操作。需要说明的是,修改请求只是本发明实施例的一个示例,其他访问请求,例如读取请求等也将被暂停执行。
然而,对于所述目标文件而言,虽然在对所述逻辑地址和所述第二写入时间执行加锁操作至解锁期间不能对所述目标数据块进行修改,但其他除所述目标数据块之外的数据块仍然可以接受修改请求或者其他访问请求。因为在本发明实施例中,被加锁的对象是所述目标数据块的元数据,其他数据块并不会因此受到影响。这就使得本发明实施例的文件迁移方法尽可能地不影响到被迁移文件的用户访问,提高了用户体验。
图5所示的文件迁移方法是以迁移目标文件中的一个数据块为例来进行说明的,当所述目标文件中的所有的数据块都以同样的方式迁移完成后,以所述目标文件为粒度的碎片整理工作也完成了。
磁盘空间的碎片整理工作可以以一个文件为粒度,也可以以一个目录为粒度,以目录为粒度的碎片整理流程与图5所示的以文件为粒度的碎片整理流程类似,这里不再赘述。
另外,磁盘空间的碎片整理工作还可以以存储设备20中保存的所有文件为粒度。在这种场景下,可以循环执行图5所示的方法流程,直至所有文件都迁移完成。或者,为了节省系统资源,可以在步骤S301A中,获取所有文件的元数据(即图4所示的文件系统对应的B+树)的快照,然后依次获取所述快照中记录的每个文件的每个数据块的KV,直至所有的数据块都迁移完毕,其具体流程与图5所示的实施例类似,这里不再赘述。
下面结合图3介绍本发明实施例提供的文件迁移装置,所述装置位于存储设备中,所述存储设备保存有目标文件,所述目标文件包括多个数据块,所述文件迁移装置与图3所示的文件系统210的结构相同。具体的,所述文件迁移装置包括碎片整理模块214,所述碎片整理模块214包括快照获取模块2140、地址映射模块2145和迁移模块2144。
其中,快照获取模块2140,用于获取所述目标文件的元数据的快照,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间;
地址映射模块2145,用于保存所述目标文件的元数据的快照以及目标文件的元数据;
所述快照获取模块2140,还用于从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;
迁移模块2144,用于根据所述目标数据块的逻辑地址从所述地址映射模块保存的目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所 述第二写入时间,所述第二写入时间是指所述目标数据块的最近一次写入所述存储设备的时间;
所述迁移模块2144,还用于确定所述第一写入时间与所述第二写入时间相同时,将所述目标数据块迁移到预先分配的连续的存储空间中。
可选的,所述文件迁移装置还包括空间管理模块212,用于预先分配所述连续的存储空间,所述存储空间的大小不小于所述目标文件的大小。
可选的,所述迁移模块2144,还用于在所述存储空间中为所述目标数据块分配物理地址;所述迁移模块2144,还用于在所述存储空间中为所述目标数据块分配物理地址之后将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中。
可选的,所述迁移模块2144,还用于对所述目标数据块的逻辑地址和所述第二写入时间执行加锁操作,使得所述目标数据块的逻辑地址和所述第二写入时间在所述获得所述目标数据块的逻辑地址对应的第二写入时间之后至所述将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中之前不能被修改。
可选的,所述碎片整理模块214还包括触发器2142;
所述触发器2142,用于设置预设的时间,或者接收文件迁移指令;
相应地,所述快照获取模块2140,具体用于当预设的时间到达时或者接收到文件迁移指令时,获取所述目标文件的元数据的快照。
下面将以一个具体的示例并结合图3来说明各个模块如何相互配合完成碎片整理工作的。
请参考图7,图7是以文件为粒度的碎片整理流程示意图。下面步骤中描述的文件可以是图5所示的文件迁移流程中的目标文件,并且下面步骤中描述的各个模块与图3所示的各个模块的定义与功能相同。如图7所示,所述方法包括:
步骤S401:定时触发碎片整理任务。
举例来说,用户可以通过定时器,定时触发碎片整理任务,或者用户手动开启碎片整理任务。
步骤S402:触发器2142向整理控制模块2143发送指令,以指示启动所述碎片整理任务。
步骤S403:整理控制模块2143向地址映射模块2145发送查询指令,要求查找地址映射模块2145保存的地址映射树中文件的元数据。
具体的,所述地址映射树中文件的元数据可以是图4或图6所示的文件对应的B+树。
步骤S404:地址映射模块2145向整理控制模块2143返回所述文件的元数据的信息,所述信息可以是所述文件的元数据在文件系统中的位置信息等。
步骤S405:整理控制模块2143向快照适配器2141发送快照生成指令,要求生成所述文件的元数据的快照,所述快照生成指令中可以包括所述文件的元数据的信息。
步骤S406:快照适配器2141向快照模块211转发所述快照生成指令。
步骤S407:快照模块211访问地址映射模块2145,生成所述文件的元数据的快照并保存在地址映射模块2145中。
具体的,所述快照模块211可以根据所述文件的元数据的信息在地址映射模块2145中查找到所述文件的元数据,并生成快照。其生成方式可参考图5所示的文件迁移流程中步骤S301A中的描述,这里不再赘述。
步骤S408:地址映射模块2145向快照模块211返回所述快照生成指令的响应请求,以说明所述文件的元数据的快照已生成并保存成功。
并且,所述响应请求中包含快照的信息,所述快照的信息包括所述快照保存在地址映射模块2145中的地址等信息。
步骤S409:快照模块211向快照适配器2141返回所述快照生成指令的响应请求,以说明所述文件的元数据的快照已生成并保存成功。
并且,所述响应请求中包含步骤S408中的快照的信息。
步骤S410:快照适配器2141保存所述快照的信息。
步骤S411:快照适配器2141向整理控制模块2143返回快照生成指令的响应请求,以指示快照生成并保存成功。
步骤S412:整理控制模块2143向迁移模块2144发送文件迁移指令。
步骤S413:迁移模块2144向空间管理模块212发送空间申请指令,以申请连续的存储空间,所述连续的存储空间的大小不小于所述文件的大小。
具体的,本步骤的实施可参考图5所示的文件迁移流程中步骤S303中的描述,这里不再赘述。
步骤S414:空间管理模块212向迁移模块2144返回所述空间申请指令的响应请求,以指示所述存储空间分配成功。
步骤S415:迁移模块2144向快照适配器2141发送扫描请求,要求扫描快照。
步骤S416:快照适配器2141向地址映射模块2145发送查询指令,以获取第一个KV。
具体的,所述查询指令中包括所述快照的信息,由于所述快照的信息中包含所述快照保存在地址映射模块2145中的地址,所以地址映射模块2145可以根据所述地址将所述文件的元数据的快照发送给快照适配器2141。由图5所示实施例的步骤S301A可知,所述文件的元数据的快照是指快照对应的B+树,快照适配器2141可以从B+树的根节点开始查找,获取第一个数据块的KV(简称为第一个KV)。关于数据块的KV,可参考图5所示的文件迁移流程的步骤S301A中关于目标数据块对应的KV的描述,这里不再赘述。
步骤S417:快照适配器2141将所述第一个KV发送给迁移模块2144。
步骤S418:迁移模块2144对所述文件的元数据的KV进行加锁操作。
步骤S419:迁移模块2144向地址映射模块2145发送查询指令,以获取文件的元数据中的KV。
由于所述第一KV中的Key字段保存有逻辑地址,所以迁移模块2144可以根据所述逻辑地址向地址映射模块2145查询,以获得所述逻辑地址对应的文件的元数据中的KV。
具体的,可参考图5所示的文件迁移流程的步骤S302的描述,这里不再赘述。
步骤S420:地址映射模块2145将所述获得的所述逻辑地址对应的文件的元数据中的KV返回给迁移模块2144。
步骤S421:迁移模块2144判断第一写入时间和第二写入时间是否相同。
具体的,可参考图5所示的文件迁移流程的步骤S303的描述,这里不再赘述。
步骤S422:若相同,则迁移模块2144向地址映射模块2145发送更新指令,以更新所述文件的元数据。
具体的,可参考图5所示的文件迁移流程的步骤S304的描述,这里不再赘述。
步骤S423:地址映射模块2145向迁移模块2144返回所述更新指令的响应请求,以指示更新成功。
步骤S424:迁移模块2144对所述文件的元数据的KV进行解锁操作。
具体的,可参考图5所示的文件迁移流程的步骤S305的描述,这里不再赘述。
另外,若第一写入时间和第二写入时间不相同,则执行步骤S425:跳过所述KV;以及步骤S426:对所述KV解锁。
需要说明的是,步骤S416至步骤S426是循环执行的,直至处理完所有KV。
当所有KV处理完毕之后,执行步骤S427:快照适配器2141向迁移模块2144发送扫描完成的指令。
步骤S428:迁移模块2144向整理控制模块2143反馈文件迁移完成。
步骤S429:整理控制模块2143向快照适配器2141发送删除快照的指令。
步骤S430:快照适配器2141向快照模块211转发删除快照的指令,以删除所述文件的元数据的快照。
在本发明实施例中,存储设备获取目标文件的元数据的快照,所述快照包括多个数据块的逻辑地址和第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间;从所述多个数据块的逻辑地址和第一写入时间中,确定目标数据块的逻辑地址和第一写入时间;根据所述逻辑地址从所述目标文件的元数据中获得所述逻辑地址对应的第二写入时间,所述第二写入时间是指所述目标数据块最近一次写入所述存储设备的时间,当第一写入时间和第二写入时间相同时,说明所述目标数据块在快照之后没有被修改过,则将其迁移到预先分配的连续的存储空间中,由此达到磁盘碎片整理的目的。并且,本发明实施例在迁移过程中不需要对所述目标文件进行锁定,就可以通过所述目标文件的元数据的快照,获得在快照之后没有被修改过的数据块,将其迁移到预先分配的连续的存储空间中,因此在一定程度上,本发明实施例的文件迁移过程可以不影响用户对文件的访问,提高了文件的访问效率。
本领域普通技术人员将会理解,本发明的各个方面、或各个方面的可能实现方式可以被具体实施为系统、方法或者计算机程序产品。因此,本发明的各方面、或各个方面的可能实现方式可以采用完全硬件实施例、完全软件实施例(包括固件、驻留软件等等),或者组合软件和硬件方面的实施例的形式,在这里都统称为“电路”、“模块”或者“系统”。此外,本发明的各方面、或各个方面的可能实现方式可以采用计算机程序产品的形式,计算机程序产品是指存储在计算机可读介质中的计算机可读程序代码。
计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质。计算机可读存储介质包含但不限于电子、磁性、光学、电磁、红外或半导体 系统、设备或者装置,或者前述的任意适当组合,如随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或者快闪存储器)、光纤、便携式只读存储器(CD-ROM)。
计算机中的处理器读取存储在计算机可读介质中的计算机可读程序代码,使得处理器能够执行在流程图中每个步骤、或各步骤的组合中规定的功能动作;生成实施在框图的每一块、或各块的组合中规定的功能动作的装置。
计算机可读程序代码可以完全在用户的计算机上执行、部分在用户的计算机上执行、作为单独的软件包、部分在用户的计算机上并且部分在远程计算机上,或者完全在远程计算机或者服务器上执行。也应该注意,在某些替代实施方案中,在流程图中各步骤、或框图中各块所注明的功能可能不按图中注明的顺序发生。例如,依赖于所涉及的功能,接连示出的两个步骤、或两个块实际上可能被大致同时执行,或者这些块有时候可能被以相反顺序执行。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。

Claims (18)

  1. 一种文件迁移方法,其特征在于,所述方法应用于存储设备中,所述存储设备保存有目标文件,所述目标文件包括多个数据块,所述方法包括:
    所述存储设备获取所述目标文件的元数据的快照,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间;
    从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;
    根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所述第二写入时间,所述第二写入时间是指所述目标数据块最近一次写入所述存储设备的时间;
    确定所述第一写入时间与所述第二写入时间相同时,将所述目标数据块迁移到预先分配的连续的存储空间中。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    预先分配所述连续的存储空间,所述存储空间的大小不小于所述目标文件的大小。
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:
    在所述存储空间中为所述目标数据块分配物理地址;
    所述将所述目标数据块迁移到预先分配的连续的存储空间中包括:将所述目标数据块写入所述物理地址对应的存储空间中。
  4. 根据权利要求3所述的方法,其特征在于,在所述存储空间中为所述目标数据块分配物理地址之后,所述方法还包括:
    将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中。
  5. 根据权利要求4所述的方法,其特征在于,在所述根据所述目标数 据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间时,所述方法还包括:
    对所述目标数据块的逻辑地址和所述第二写入时间执行加锁操作,使得所述目标数据块的逻辑地址和所述第二写入时间在所述获得所述目标数据块的逻辑地址对应的第二写入时间之后至所述将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中之前不能被修改。
  6. 根据权利要求1-5中任一所述的方法,其特征在于,所述存储设备获取所述目标文件的元数据的快照包括:
    当预设的时间到达时或者接收到文件迁移指令时,所述存储设备获取所述目标文件的元数据的快照。
  7. 一种文件迁移装置,其特征在于,所述装置位于存储设备中,所述存储设备保存有目标文件,所述目标文件包括多个数据块,所述装置包括碎片整理模块,其中,所述碎片整理模块包括:
    快照获取模块,用于获取所述目标文件的元数据的快照,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述存储设备的时间;
    地址映射模块,用于保存所述目标文件的元数据的快照以及目标文件的元数据;
    所述快照获取模块,还用于从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;
    迁移模块,用于根据所述目标数据块的逻辑地址从所述地址映射模块保存的所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所述第二写入时间,所述第二写入时间是指所述目标数据块的最近一次写入所 述存储设备的时间;
    所述迁移模块,还用于确定所述第一写入时间与所述第二写入时间相同时,将所述目标数据块迁移到预先分配的连续的存储空间中。
  8. 根据权利要求7所述的装置,其特征在于,所述文件迁移装置还包括空间管理模块,用于预先分配所述连续的存储空间,所述存储空间的大小不小于所述目标文件的大小。
  9. 根据权利要求7或8所述的装置,其特征在于,
    所述迁移模块,还用于在所述存储空间中为所述目标数据块分配物理地址;
    所述迁移模块具体用于:将所述目标数据块写入所述物理地址对应的存储空间中。
  10. 根据权利要求9所述的装置,其特征在于,
    所述迁移模块,还用于在所述存储空间中为所述目标数据块分配物理地址之后将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中。
  11. 根据权利要求10所述的装置,其特征在于,
    所述迁移模块,还用于对所述目标数据块的逻辑地址和所述第二写入时间执行加锁操作,使得所述目标数据块的逻辑地址和所述第二写入时间在所述获得所述目标数据块的逻辑地址对应的第二写入时间之后至所述将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中之前不能被修改。
  12. 根据权利要求7-11任一所述的装置,其特征在于,所述碎片整理模块还包括触发器;
    所述触发器,用于设置预设的时间,或者接收文件迁移指令;
    所述快照获取模块,具体用于当预设的时间到达时或者接收到文件迁移指令时,获取所述目标文件的元数据的快照。
  13. 一种存储设备,其特征在于,所述存储设备包括控制器和磁盘,所述控制器包括处理器和通信接口;
    所述通信接口,用于与所述磁盘进行通信;
    所述处理器,用于获取所述目标文件的元数据的快照,所述快照包括所述多个数据块的逻辑地址和所述多个数据块的第一写入时间,所述第一写入时间是指所述快照中记录的所述数据块写入所述磁盘的时间;
    从所述多个数据块的逻辑地址和所述多个数据块的第一写入时间中,确定目标数据块的逻辑地址和所述目标数据块的第一写入时间;
    根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间,其中所述目标文件的元数据包括所述目标数据块的逻辑地址和所述第二写入时间,所述第二写入时间是指所述目标数据块最近一次写入所述磁盘的时间;
    确定所述第一写入时间与所述第二写入时间相同时,将所述目标数据块迁移到预先分配的连续的存储空间中。
  14. 根据权利要求13所述的存储设备,其特征在于,
    所述处理器,还用于预先分配所述连续的存储空间,所述存储空间的大小不小于所述目标文件的大小。
  15. 根据权利要求13或14所述的存储设备,其特征在于,
    所述处理器,还用于在所述存储空间中为所述目标数据块分配物理地址;
    所述处理器具体用于将所述目标数据块写入所述物理地址对应的存储空间中。
  16. 根据权利要求15所述的存储设备,其特征在于,
    所述处理器,还用于在所述存储空间中为所述目标数据块分配物理地址之后将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中。
  17. 根据权利要求16所述的存储设备,其特征在于,
    所述处理器,还用于在所述根据所述目标数据块的逻辑地址从所述目标文件的元数据中获得所述目标数据块的逻辑地址对应的第二写入时间时,对所述目标数据块的逻辑地址和所述第二写入时间执行加锁操作,使得所述目标数据块的逻辑地址和所述第二写入时间在所述获得所述目标数据块的逻辑地址对应的第二写入时间之后至所述将所述物理地址以及所述目标数据块写入所述物理地址对应的存储空间的时间保存在所述目标文件的元数据中之前不能被修改。
  18. 根据权利要求13-17任一所述的存储设备,其特征在于,
    所述处理器,具体用于当预设的时间到达时或者接收到文件迁移指令时,所述存储设备获取所述目标文件的元数据的快照。
PCT/CN2014/087572 2014-09-26 2014-09-26 一种文件迁移方法、装置和存储设备 WO2016045096A1 (zh)

Priority Applications (5)

Application Number Priority Date Filing Date Title
EP14897428.0A EP3035197B1 (en) 2014-09-26 2014-09-26 File migration method and apparatus and storage device
JP2016549609A JP6122557B2 (ja) 2014-09-26 2014-09-26 ファイルマイグレーション方法及び装置、並びにストレージデバイス
CN201480037601.8A CN105637491B (zh) 2014-09-26 2014-09-26 一种文件迁移方法、装置和存储设备
PCT/CN2014/087572 WO2016045096A1 (zh) 2014-09-26 2014-09-26 一种文件迁移方法、装置和存储设备
US15/085,626 US10417186B2 (en) 2014-09-26 2016-03-30 File migration method and apparatus, and storage device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2014/087572 WO2016045096A1 (zh) 2014-09-26 2014-09-26 一种文件迁移方法、装置和存储设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/085,626 Continuation US10417186B2 (en) 2014-09-26 2016-03-30 File migration method and apparatus, and storage device

Publications (1)

Publication Number Publication Date
WO2016045096A1 true WO2016045096A1 (zh) 2016-03-31

Family

ID=55580143

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/087572 WO2016045096A1 (zh) 2014-09-26 2014-09-26 一种文件迁移方法、装置和存储设备

Country Status (5)

Country Link
US (1) US10417186B2 (zh)
EP (1) EP3035197B1 (zh)
JP (1) JP6122557B2 (zh)
CN (1) CN105637491B (zh)
WO (1) WO2016045096A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109359085A (zh) * 2018-08-23 2019-02-19 平安科技(深圳)有限公司 文件迁移方法、装置、计算机设备及存储介质
CN109725851A (zh) * 2017-10-27 2019-05-07 Netapp股份有限公司 智能快照分层
CN109918208A (zh) * 2019-02-28 2019-06-21 新华三技术有限公司成都分公司 一种io操作处理方法及装置
CN112214175A (zh) * 2020-10-21 2021-01-12 重庆紫光华山智安科技有限公司 数据处理方法、装置、数据节点及存储介质

Families Citing this family (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9881040B2 (en) * 2015-08-20 2018-01-30 Vmware, Inc. Tracking data of virtual disk snapshots using tree data structures
US11726979B2 (en) 2016-09-13 2023-08-15 Oracle International Corporation Determining a chronological order of transactions executed in relation to an object stored in a storage system
CN106648909A (zh) * 2016-10-13 2017-05-10 华为技术有限公司 一种磁盘锁的管理方法、装置和系统
US10860534B2 (en) 2016-10-27 2020-12-08 Oracle International Corporation Executing a conditional command on an object stored in a storage system
US10275177B2 (en) * 2016-10-31 2019-04-30 Oracle International Corporation Data layout schemas for seamless data migration
US10956051B2 (en) * 2016-10-31 2021-03-23 Oracle International Corporation Data-packed storage containers for streamlined access and migration
CN107229429B (zh) * 2017-06-27 2020-06-16 苏州浪潮智能科技有限公司 一种存储空间管理方法及装置
WO2019013775A1 (en) * 2017-07-12 2019-01-17 Hewlett-Packard Development Company, L.P. MIGRATION OF MEMORY DEVICES
US11194760B1 (en) * 2017-07-28 2021-12-07 EMC IP Holding Company LLC Fast object snapshot via background processing
KR102406666B1 (ko) 2017-09-20 2022-06-08 삼성전자주식회사 스냅샷 기능을 지원하는 키-밸류 스토리지 장치 및 상기 키-밸류 스토리지 장치의 동작 방법
CN107643880B (zh) * 2017-09-27 2021-06-29 郑州云海信息技术有限公司 基于分布式文件系统的文件数据迁移的方法及装置
CN110018988B (zh) * 2017-11-08 2023-04-04 阿里巴巴集团控股有限公司 快照删除方法、处理方法、装置及系统
CN108959486B (zh) * 2018-06-22 2023-04-18 平安科技(深圳)有限公司 审计字段信息获取方法、装置、计算机设备和存储介质
US10254996B1 (en) * 2018-08-10 2019-04-09 Cohesity, Inc. Fast migration of metadata
US10877849B2 (en) * 2018-08-25 2020-12-29 Vmware, Inc. System and method for managing different types of snapshots of storage objects
US10872059B2 (en) * 2018-08-25 2020-12-22 Vmware, Inc. System and method for managing snapshots of storage objects for snapshot deletions
CN111045857B (zh) * 2018-10-12 2023-11-28 伊姆西Ip控股有限责任公司 数据备份和恢复的方法、电子设备和计算机可读存储介质
CN111007990B (zh) * 2019-12-24 2023-09-19 曙光信息产业(北京)有限公司 一种对快照系统中数据块引用进行快速定位的定位方法
CN111723056B (zh) * 2020-06-09 2024-04-30 北京青云科技股份有限公司 小文件的处理方法、装置、设备和存储介质
CN111831752B (zh) * 2020-07-20 2024-06-04 北京百度网讯科技有限公司 分布式数据库的空间整理方法、装置、设备以及存储介质
CN111857593A (zh) * 2020-07-21 2020-10-30 星辰天合(北京)数据科技有限公司 提高快照数据和克隆数据读写速度的方法与装置
CN112463058B (zh) * 2020-11-27 2023-04-07 杭州海康威视系统技术有限公司 一种碎片数据整理方法、装置及存储节点
CN112988065B (zh) * 2021-02-08 2023-11-17 北京星网锐捷网络技术有限公司 数据迁移方法、装置、设备及存储介质
CN114356224B (zh) * 2021-12-15 2024-04-19 广州致存科技有限责任公司 文件地址优化方法、终端、服务器及计算机可读存储介质
CN115629716B (zh) * 2022-12-07 2023-04-11 广东睿江云计算股份有限公司 基于磁盘镜像文件的碎片整理方法及碎片整理系统

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101520743A (zh) * 2009-04-17 2009-09-02 杭州华三通信技术有限公司 基于写时拷贝的数据存储方法、系统及设备
US20130238907A1 (en) * 2011-09-15 2013-09-12 Maxim Integrated Products, Inc. Systems and methods for managing cryptographic keys in a secure microcontroller
CN103761053A (zh) * 2013-12-30 2014-04-30 华为技术有限公司 一种数据处理方法和装置

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5530850A (en) 1993-10-25 1996-06-25 International Business Machines Corporation Data storage library array with log-structured file system which allows simultaneous write and garbage collection
US7107385B2 (en) * 2002-08-09 2006-09-12 Network Appliance, Inc. Storage virtualization by layering virtual disk objects on a file system
JP4257785B2 (ja) * 2003-04-22 2009-04-22 株式会社日立製作所 キャッシュストレージ装置
US7822715B2 (en) * 2004-11-16 2010-10-26 Petruzzo Stephen E Data mirroring method
CN101369967A (zh) 2007-08-14 2009-02-18 华为技术有限公司 发送及接收数据的方法、基站、终端
CN101576890B (zh) 2008-05-08 2015-06-17 深圳市朗科科技股份有限公司 一种新型碎片整理方法和系统
JP5141402B2 (ja) 2008-06-26 2013-02-13 富士通株式会社 ストレージシステム,コピー制御方法およびコピー制御装置
JP5587884B2 (ja) 2008-08-06 2014-09-10 モービック・ネットワークス 無線アクセスネットワーク(ran)におけるコンテンツのキャッシング
US8285959B2 (en) 2010-01-25 2012-10-09 Netapp, Inc. Method for placement of virtual volume hot-spots in storage pools using ongoing load measurements and ranking
US8886900B2 (en) * 2010-11-22 2014-11-11 International Business Machines Corporation Legacy data management
US8639900B2 (en) * 2011-05-25 2014-01-28 International Business Machines Corporation Defragmentation of data storage pools
JP5550741B1 (ja) 2012-09-25 2014-07-16 株式会社東芝 ソリッドステートドライブにデータを再配置するストレージ装置、ストレージコントローラ及び方法
US10019459B1 (en) * 2012-12-19 2018-07-10 Springpath, LLC Distributed deduplication in a distributed system of hybrid storage and compute nodes
US9891860B1 (en) * 2013-06-28 2018-02-13 EMC IP Holding Company, LLC. Managing copying of data in storage systems
US9367395B1 (en) * 2014-03-31 2016-06-14 Emc Corporation Managing data inconsistencies in storage systems
CN104159249B (zh) 2014-07-30 2018-05-18 华为技术有限公司 一种业务数据管理的方法、装置及系统

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101520743A (zh) * 2009-04-17 2009-09-02 杭州华三通信技术有限公司 基于写时拷贝的数据存储方法、系统及设备
US20130238907A1 (en) * 2011-09-15 2013-09-12 Maxim Integrated Products, Inc. Systems and methods for managing cryptographic keys in a secure microcontroller
CN103761053A (zh) * 2013-12-30 2014-04-30 华为技术有限公司 一种数据处理方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3035197A4 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109725851A (zh) * 2017-10-27 2019-05-07 Netapp股份有限公司 智能快照分层
CN109725851B (zh) * 2017-10-27 2022-04-22 Netapp股份有限公司 智能快照分层
CN109359085A (zh) * 2018-08-23 2019-02-19 平安科技(深圳)有限公司 文件迁移方法、装置、计算机设备及存储介质
CN109918208A (zh) * 2019-02-28 2019-06-21 新华三技术有限公司成都分公司 一种io操作处理方法及装置
CN112214175A (zh) * 2020-10-21 2021-01-12 重庆紫光华山智安科技有限公司 数据处理方法、装置、数据节点及存储介质

Also Published As

Publication number Publication date
EP3035197B1 (en) 2019-03-20
JP6122557B2 (ja) 2017-04-26
EP3035197A4 (en) 2016-11-16
EP3035197A1 (en) 2016-06-22
CN105637491A (zh) 2016-06-01
US20160210302A1 (en) 2016-07-21
US10417186B2 (en) 2019-09-17
CN105637491B (zh) 2017-06-20
JP2016535910A (ja) 2016-11-17

Similar Documents

Publication Publication Date Title
WO2016045096A1 (zh) 一种文件迁移方法、装置和存储设备
US11487787B2 (en) System and method for near-synchronous replication for object store
US8751763B1 (en) Low-overhead deduplication within a block-based data storage
KR102440370B1 (ko) Ssd 내 핫 데이터 및 스트림을 식별하기 위한 시스템 및 방법
US8306950B2 (en) Managing data access requests after persistent snapshots
US8966188B1 (en) RAM utilization in a virtual environment
US8904136B2 (en) Optimized shrinking of virtual disks
TWI533152B (zh) 資料儲存裝置及方法
JP6976132B2 (ja) 記憶空間を解放するための分散データ並列方法
US10102211B2 (en) Systems and methods for multi-threaded shadow migration
JP2017021804A (ja) 不揮発性メモリ装置におけるデータ特性基盤データ配置を活用するためのインターフェイス提供方法及びシステム並びに不揮発性メモリ装置とそのデータ特性基盤データ配置方法
WO2019062574A1 (zh) 一种元数据查询方法及装置
TW201935243A (zh) 固態驅動器、分散式資料儲存系統和利用鍵值儲存的方法
US8572338B1 (en) Systems and methods for creating space-saving snapshots
US10922276B2 (en) Online file system check
US11995318B2 (en) Deallocated block determination
WO2018086075A1 (zh) 一种存储系统和系统垃圾回收方法
CN111522502B (zh) 数据去重方法、装置、电子设备及计算机可读存储介质
CA2896369A1 (en) Method for writing data into flash memory apparatus, flash memory apparatus, and storage system
CN113939796A (zh) 使用ReFS扩展文件系统以及扩展卷
US10394764B2 (en) Region-integrated data deduplication implementing a multi-lifetime duplicate finder
US9519590B1 (en) Managing global caches in data storage systems
US9009204B2 (en) Storage system
WO2018075676A1 (en) Efficient flash management for multiple controllers

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 2014897428

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2016549609

Country of ref document: JP

Kind code of ref document: A

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

Ref document number: 14897428

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE