CN108255638B - Snapshot rollback method and device - Google Patents

Snapshot rollback method and device Download PDF

Info

Publication number
CN108255638B
CN108255638B CN201710512250.7A CN201710512250A CN108255638B CN 108255638 B CN108255638 B CN 108255638B CN 201710512250 A CN201710512250 A CN 201710512250A CN 108255638 B CN108255638 B CN 108255638B
Authority
CN
China
Prior art keywords
target
snapshot
file
data
metadata
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201710512250.7A
Other languages
Chinese (zh)
Other versions
CN108255638A (en
Inventor
李航
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou H3C Technologies Co Ltd
Original Assignee
Hangzhou H3C Technologies Co Ltd
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 Hangzhou H3C Technologies Co Ltd filed Critical Hangzhou H3C Technologies Co Ltd
Priority to CN201710512250.7A priority Critical patent/CN108255638B/en
Publication of CN108255638A publication Critical patent/CN108255638A/en
Application granted granted Critical
Publication of CN108255638B publication Critical patent/CN108255638B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1435Saving, restoring, recovering or retrying at system level using file system or storage system metadata
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • 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/119Details of migration of file systems
    • 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/13File access structures, e.g. distributed indices
    • G06F16/134Distributed indices
    • 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/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation
    • 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/18File system types
    • G06F16/182Distributed file systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Quality & Reliability (AREA)
  • Human Computer Interaction (AREA)
  • Library & Information Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a snapshot rollback method and a snapshot rollback device, wherein the method comprises the following steps: receiving a snapshot rollback instruction; locking the target directory; deleting the current metadata in the metadata node and the current data object in the data node corresponding to the target directory; according to the target snapshot, recovering metadata in metadata nodes and data objects in data nodes corresponding to the target directory; and when the snapshot rollback task is completed, releasing the lock aiming at the target directory. The embodiment of the invention can realize the snapshot rollback in the Ceph distributed file system.

Description

Snapshot rollback method and device
Technical Field
The invention relates to the technical field of data storage, in particular to a snapshot rollback method and device.
Background
The snapshot technology is a key technology in the field of data storage, can quickly restore a complete mirror image of data at a certain time point in the past when a disaster occurs in a system, and can also be used for restoring a document automatically arrived at a certain time point by a user.
Ceph is one of the most popular object-based distributed file systems at present, eliminates the dependence on a single central node of the system, and is very suitable for the requirements of modern large-scale data storage clusters due to the convenience that data positions acquire the positions of data objects through a CRUSH (Controlled Replication Under extensible Hashing) algorithm.
Practice shows that the technical scheme for realizing snapshot rollback in a distributed file system based on a Ceph distributed file system and other similar principles does not exist in the prior art.
Disclosure of Invention
The invention provides a snapshot rollback method and device, and aims to solve the problem that snapshot rollback cannot be performed in an existing Ceph distributed file system.
According to a first aspect of the embodiments of the present invention, there is provided a snapshot rollback method, applied to a distributed file system, the method including:
receiving a snapshot rollback instruction, wherein the snapshot rollback instruction carries an identifier of a target snapshot used for snapshot rollback; the target snapshot is established based on a target directory and comprises snapshot metadata and a snapshot data object corresponding to the target directory;
locking the target directory;
deleting the current metadata in the metadata node and the current data object in the data node corresponding to the target directory;
according to the target snapshot, recovering metadata in metadata nodes and data objects in data nodes corresponding to the target directory;
and when the snapshot rollback task is completed, releasing the lock aiming at the target directory.
According to a second aspect of the embodiments of the present invention, there is provided a snapshot rollback apparatus, applied to a distributed file system, the apparatus including:
a receiving unit, configured to receive a snapshot rollback instruction, where the snapshot rollback instruction carries an identifier of a target snapshot used for snapshot rollback, and the target snapshot is established based on a target directory and includes snapshot metadata and a snapshot data object corresponding to the target directory;
a locking unit for the target directory;
the snapshot rollback unit is used for deleting the current metadata in the metadata node and the current data object in the data node corresponding to the target directory;
the snapshot rollback unit is further configured to restore, according to the target snapshot, metadata in a metadata node and a data object in a data node that correspond to the target directory;
the locking unit is further configured to release the lock on the target directory when the snapshot rollback task is completed.
By applying the embodiment of the invention, the target directory is locked by receiving the snapshot rollback instruction, the current metadata in the metadata node and the current data object in the data node corresponding to the target directory are further deleted, the metadata in the metadata node and the data object in the data node corresponding to the target directory are restored according to the target snapshot, and when the snapshot rollback task is completed, the target directory is unlocked, so that the snapshot rollback in the Ceph distributed file system is realized.
Drawings
Fig. 1 is a schematic flowchart of a snapshot rollback method according to an embodiment of the present invention;
fig. 2A is a schematic diagram illustrating a principle of file metadata in a Ceph distributed file system according to an embodiment of the present invention;
FIG. 2B is a diagram illustrating a snapshot of the directory "/etc" shown in FIG. 2A according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a snapshot rollback apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of another snapshot rollback apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of another snapshot rollback apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions in the embodiments of the present invention better understood and make the above objects, features and advantages of the embodiments of the present invention more comprehensible, the technical solutions in the embodiments of the present invention are described in further detail below with reference to the accompanying drawings.
Referring to fig. 1, a schematic flow chart of a snapshot rollback method according to an embodiment of the present invention is provided, where the snapshot rollback method may be applied to a distributed file system, as shown in fig. 1, and the snapshot rollback method may include the following steps:
for convenience of description, the execution subject of steps 101 to 105 is taken as a storage device in a Ceph distributed file system as an example, but it should be noted that the snapshot rollback scheme provided in the embodiment of the present invention is not limited to be applied to the Ceph distributed file system, and may also be applied to other distributed file systems whose implementation principles are similar to those of the Ceph distributed file system.
Step 101, receiving a snapshot rollback instruction, wherein the snapshot rollback instruction carries an identifier of a target snapshot for performing snapshot rollback; the target snapshot is established based on the target directory and comprises snapshot metadata and a snapshot data object corresponding to the target directory.
In the embodiment of the present invention, when a user needs to perform snapshot rollback, a snapshot rollback instruction may be sent to the storage device, where the snapshot rollback instruction may carry an identifier of a snapshot (referred to as a target snapshot herein) used for performing snapshot rollback, such as a name of the target snapshot. The target snapshot is established based on the target directory and includes snapshot metadata and snapshot data objects (i.e., metadata and data objects of snap version) corresponding to the target directory.
When the storage device receives the snapshot rollback instruction, the corresponding target snapshot can be found according to the identification information of the target snapshot carried in the snapshot rollback instruction.
And step 102, locking the target directory.
In the embodiment of the invention, in order to avoid that data reading and writing influence the normal execution of the snapshot rollback task, the directory corresponding to the snapshot for snapshot rollback can be locked in the snapshot rollback task execution process, so that the directory is refused to provide access to the outside.
Accordingly, in the embodiment of the present invention, when the storage device receives the snapshot rollback instruction, the storage device may lock the directory (i.e., the target directory) corresponding to the target snapshot, so as to avoid that data reading and writing for the target directory affects normal execution of the snapshot rollback task.
And 103, deleting the current metadata in the metadata node corresponding to the target directory and the current data object in the data node.
In the embodiment of the present invention, in order to implement snapshot rollback, the storage device may first delete the current metadata in the metadata node and the current data object (i.e., the metadata and the data object of the head version) in the data node corresponding to the target directory. The head version is metadata and a data version number which are used by a user in a default mode currently.
And step 104, restoring the metadata in the metadata node and the data object in the data node corresponding to the target directory according to the target snapshot.
In the embodiment of the present invention, after the storage device deletes the metadata of the head version in the metadata node corresponding to the target directory and the data object of the head version in the data node, the storage device may copy the metadata (i.e., the metadata of the snap version) in the target snapshot to the metadata node under the snapshot directory according to the target snapshot, and copy the data object (i.e., the data object of the snap version) in the target snapshot to the data node corresponding to the target directory, so as to restore the metadata and the data object corresponding to the target directory to the metadata and the data object corresponding to the target directory when the target snapshot is created, so as to implement the snapshot rollback. The snap version is the version number of metadata and data in the snapshot file.
It should be noted that, in the embodiment of the present invention, in consideration of a case where no data modification occurs after the target snapshot is created, the data object of the head version corresponding to the target directory is the same as the data object of the snap version corresponding to the target snapshot; for the data object with data modification after the target snapshot is created, the data recorded in the data object of the head version corresponding to the target directory is modified data, and the data recorded in the data object of the snap version corresponding to the target snapshot is data before modification, so that when snapshot rollback is required, the storage device can delete the head version of the data object with data modification after the target snapshot is created by the target directory, and copy the data object of the snap version corresponding to the target snapshot into the corresponding data node, and for the data object without data modification, the data object of the head version does not need to be deleted, but only needs to modify the tag of the data object from the head version to the snap version, so that the data object can be restored to the data object corresponding to the target directory when the target snapshot is created.
And 105, when the snapshot rollback task is completed, unlocking the target directory.
In the embodiment of the invention, when the storage equipment finishes the snapshot rollback task, the locking of the target directory can be released, and further, the directory can normally provide access.
Further, in the embodiment of the present invention, it is considered that the snapshot rollback task may be stopped due to a crash of the storage device during the execution process, and when the snapshot rollback task needs to be restarted after the storage device is restarted, if the snapshot rollback task is directly executed from the beginning, many repeated tasks may be caused, which affects the snapshot rollback efficiency, so that the snapshot rollback task progress state may be recorded at some specific time during the snapshot rollback task execution process by the storage device, so that the storage device stops the snapshot rollback task due to the crash and the like, and when the snapshot rollback task is restarted after being restarted, the snapshot rollback task may be directly executed continuously according to the snapshot rollback task progress state recorded by the storage device without starting from the beginning, thereby improving the snapshot rollback efficiency.
Accordingly, in one embodiment of the present invention, after receiving the snapshot rollback instruction for the target snapshot, the method may further include:
recording the progress state of the snapshot rollback task;
before the snapshot rollback task is completed, the method further comprises the following steps:
and when the snapshot rollback task is restarted after stopping, continuously executing the snapshot rollback task according to the recorded latest snapshot rollback task progress state.
In this embodiment, in the process of executing the snapshot rollback task, the storage device may record the progress state of the snapshot rollback task at a specific time according to the task execution condition, for example, when the storage device locks the target directory corresponding to the target snapshot, the storage device may record the progress state of the snapshot rollback task (the progress state of the snapshot rollback task at this time is "the target directory corresponding to the locked target snapshot"); or, the storage device may record a snapshot rollback task progress state when the current metadata in the metadata node and the current data object in the data node corresponding to the target directory are deleted (the snapshot rollback task progress state at this time is "the current metadata in the metadata node and the current data object in the data node corresponding to the deleted target directory"); alternatively, the storage device may record the snapshot rollback task progress state in the process of restoring the metadata in the metadata node and the data object in the data node corresponding to the target directory according to the target snapshot, for example, may record the snapshot rollback task progress state once every time all the data objects in one file are restored, or may record the snapshot rollback task progress state once every time one data object in one file is restored.
When the storage device stops the snapshot rollback task due to the downtime and the like, and the storage device needs to restart to execute the snapshot rollback task after being restarted, the storage device can continue to execute the snapshot rollback task according to the latest snapshot rollback task progress state recorded by the storage device.
It should be noted that, in the embodiment of the present invention, the storage device may cover the last recorded progress state of the snapshot rollback task each time the storage device records the snapshot rollback task state, and in this case, the snapshot rollback task recorded by the storage device is always the latest progress state of the snapshot rollback task; or, the snapshot rollback task progress state recorded by the storage device each time may not cover the snapshot rollback task progress state recorded last time, in this case, when the storage device records the snapshot rollback task progress state each time, the storage device may stamp the current system timestamp for the snapshot rollback task progress state, and further, the storage device may determine the latest snapshot rollback task progress state according to the system timestamp of the snapshot rollback task progress state.
Further, in the embodiment of the present invention, in consideration of a situation that a certain file under a certain directory may be migrated to another directory under the same namespace in the Ceph distributed file system, this time, when a snapshot rollback needs to be performed on a directory in which the certain file exists before, if the file is directly restored under the directory, two files with the same inode _ number (index node number) will appear, and therefore, when a situation that a file under a directory that needs to be snapshot rolled back migrates to another directory under the same namespace occurs, special processing needs to be performed, and the file cannot be directly restored under the directory.
Accordingly, in an embodiment of the present invention, the restoring metadata in the metadata node and data in the data node corresponding to the target directory according to the target snapshot may include:
when the target file corresponding to the target directory is migrated to other directories under the same name space, generating an index node number of a target recovery file corresponding to the target file; the index node number of the target recovery file is different from the index node number of the target file;
and restoring other metadata of the target file except the index node number in the metadata node corresponding to the target directory according to the target snapshot, and copying the data object of the target file in the target snapshot to the data node corresponding to the target restoration file.
In the embodiment of the present invention, the target file does not refer to a fixed file, but may refer to any file in the target directory corresponding to the target snapshot, and the following description of the embodiment of the present invention is not repeated.
In this embodiment, since the snapshot rollback is performed to delete the metadata of the head version in the metadata node in the corresponding directory, when the storage device deletes the metadata in the metadata node in a directory and finds that the metadata of the head version of a file in the directory still exists (exists in other directories in the namespace), the storage device may determine that the file is migrated to other directories in the same namespace.
Correspondingly, when the storage device needs to perform snapshot rollback on a target directory corresponding to a target snapshot and finds that a target file in the target directory is migrated to another directory in the same name space, in order to avoid file restoration causing the target file to be migrated to another directory in the same name space, two files with the same index node number appear in the name space, the storage device needs to newly generate an index node number (different from the index node number of the target file) corresponding to a restored file (referred to as a target restored file herein) of the target file in the directory.
Furthermore, the storage device may restore, to a metadata node corresponding to a target directory corresponding to the target snapshot, other metadata, except for the index node number, in the metadata of the target file included in the target snapshot file, and copy a data object of the target file in the target snapshot to a data node corresponding to the target restoration file, so as to complete restoration of the target file.
In another embodiment of the present invention, the restoring metadata in the metadata node and the data object in the data node corresponding to the target directory according to the target snapshot includes:
when a target file in a target directory is migrated to other directories in the same name space, generating an index node number of a target recovery file corresponding to the target file, wherein the index node number of the target recovery file is different from the index node number of the target file;
restoring other metadata of the target file except the index node number in the metadata node corresponding to the target directory according to the target snapshot, pointing the target restoration file to the data object of the target file in the target snapshot, and adding a preset identifier to the target restoration file;
when data reading needs to be carried out on the data object of the target recovery file and the target recovery file is determined to be provided with a preset identifier, returning the data of the target file in the data object in the target snapshot to a data reading requester;
when data modification needs to be carried out on the data object of the target recovery file and the target recovery file is determined to have the preset identification, copying the data object of the target file in the target snapshot to the data node corresponding to the target recovery file, deleting the preset identification when the data object is copied, and carrying out data object modification operation.
In this embodiment, in order to improve snapshot rollback efficiency, when the storage device finds that a target file in a target directory corresponding to a target snapshot is migrated to another directory in the same namespace, the storage device generates an index node number of a target restore file corresponding to the target file, and after other metadata of the target file except the index node number is restored in a metadata node corresponding to the target directory according to the target snapshot, a data object of the target file in the target snapshot is not directly copied to the data node corresponding to the target restore file, but the data object of the target file in the target snapshot is executed by the target restore file, and a preset identifier is added to the target restore file. The preset identification indicates that real data does not exist in the data node corresponding to the target recovery file.
When data reading operation needs to be performed on the data object of the target recovery file, the data object of the target file in the target snapshot can be directly read.
When data modification (i.e., data writing) needs to be performed on a data object of the target recovery file, the storage device finds that the target recovery file is provided with the preset identifier, so that the storage device can copy the data object of the target file in the target snapshot to a data node corresponding to the target recovery file, delete the preset identifier of the target recovery file when the data object is copied, and perform data modification operation.
It can be seen that, in this embodiment, for a file migrated from one directory to another directory in the same namespace, when a file needs to be restored in the snapshot rollback process, a data object included in the file is not directly copied to a data node corresponding to the restored file, but the data object is copied only when data modification is needed, so that time consumption caused by copying the data object in the snapshot rollback process can be reduced, and the snapshot rollback efficiency is improved.
It should be noted that, in the embodiment of the present invention, in order to avoid that different files have the same index node number due to migration of the files in different directories of the same namespace during the snapshot rollback process, migration of the files in different directories of the same namespace may also be prohibited.
In order to enable those skilled in the art to better understand the technical solutions passed by the embodiments of the present invention, the technical solutions provided by the embodiments of the present invention are described below with reference to specific examples.
Referring to fig. 2A, a schematic diagram of a file metadata principle in a Ceph distributed file system according to an embodiment of the present invention is provided, where in this embodiment, a "password" file under a root directory "/" and a directory "/etc" is taken as an example, and as shown in fig. 2A, a metadata pool stores dentry (directory entry) of the root directory "/", the directory "/etc" and the file "/etc/password"; wherein, the directory entry is the connection of the index node (directory or file); the data pool stores data objects (i.e. data1, data2, data3 and data4) included in the file "/etc/password".
Referring to fig. 2B, which is a schematic diagram illustrating a snapshot of the directory "/etc" shown in fig. 2A according to an embodiment of the present invention, as shown in fig. 2B, a snapshot is first created for the "/etc" directory, and the system creates a directory snapshot node of the "/etc" in the hidden directory, where the node includes subdirectories and files under the "/etc" and has a version number of "snap 1".
When a Write operation is performed On the data object data1 in the file "/etc/password" in the target directory, an Object Storage Device (OSD) module of the storage device performs a Copy On Write (COW) operation to generate a data _ snap1 data object.
Similarly, when snapshot snap2 is created, a write operation is performed on data object data1 to generate a data1_ snap2 data object, and a write operation is performed on data object data2 to generate data2_ snap 2.
Based on fig. 2A and fig. 2B, the implementation of the snapshot rollback scheme provided by the embodiment of the present invention may be as follows:
when the "/etc" directory needs to be rolled back to the snapshot snap1 version mirror, it needs to be ensured that the head version of the metadata of the directory "/etc" (including subdirectories and files under that directory) and the metadata of snap1 remain consistent, and the head version of its data objects also needs to remain consistent with the data objects of snap 1. After the snapshot rollback is complete, the content the user sees under the original "/etc" directory will be exactly the same as before creating snap 1. The specific implementation process is as follows:
1. a user calls a ceph file system (ceph file system) interface to send a snapshot rollback instruction to an MDS (metadata server) process;
2. the MDS process analyzes the snapshot rollback instruction and acquires corresponding target snapshot information;
in this embodiment, take the target snapshot as an example of snap1 created for directory "/etc";
3. locking a target directory corresponding to the target snapshot and refusing to provide access;
in this embodiment, the MDS process may lock directory "/etc";
4. recording the progress state of the current snapshot rollback task;
5. delete subdirectories and files under directory "/etc" (i.e., delete head version metadata and data objects);
6. recording the progress state of the current snapshot rollback task;
7. copying metadata in snap1 created for the directory "/etc" to a metadata node under the directory "/etc";
8. recording the progress state of the current snapshot rollback task;
9. sending a data object recovery instruction to an OSD module, and copying the data object in the snap1 created by the directory "/etc" to the data node corresponding to each file under the directory "/etc" by the OSD module;
10. recording the progress state of the current snapshot rollback task;
11. when the snapshot rollback task is completed, the directory "/etc" is unlocked.
In this embodiment, when a file (assumed as the file "passswd 1") under the directory "/etc" is migrated to another directory (e.g., the directory "/etc 2"), an inode number of a restored file corresponding to "passswd 1" needs to be newly generated, metadata of "swd 1" other than the inode number is restored in a metadata node under the directory "/etc" according to the snap1 created for the directory "/etc", the restored file is pointed to a data object of "passswd 1" in the snap1, and a preset identifier (e.g., "clone identifier") is added to the restored file;
when data modification operation needs to be performed on the recovery file of the "password 1" with the "clone identifier", the data object of the "password 1" in the snap1 may be copied to the data node corresponding to the recovery file, and when the data object replication is completed, the clone identifier is deleted, and data modification operation is performed.
As can be seen from the above description, in the technical solution provided in the embodiment of the present invention, the target directory is locked by receiving the snapshot rollback instruction, and then the current metadata in the metadata node and the current data object in the data node corresponding to the target directory are deleted, and the metadata in the metadata node and the data object in the data node corresponding to the target directory are restored according to the target snapshot, and when the snapshot rollback task is completed, the target directory is unlocked, so that the snapshot rollback in the Ceph distributed file system is implemented.
Referring to fig. 3, a schematic structural diagram of a snapshot rollback apparatus according to an embodiment of the present invention is provided, where the apparatus may be applied to a storage device in the foregoing method embodiment, as shown in fig. 3, the snapshot rollback apparatus may include:
a receiving unit 310, configured to receive a snapshot rollback instruction, where the snapshot rollback instruction carries an identifier of a target snapshot used for snapshot rollback; the target snapshot is established based on a target directory and comprises snapshot metadata and a snapshot data object corresponding to the target directory;
a locking unit 320, configured to lock the target directory;
a snapshot rollback unit 330, configured to delete a current metadata in a metadata node and a current data object in a data node corresponding to the target directory;
the snapshot rollback unit 330 is further configured to restore, according to the target snapshot, metadata in a metadata node and a data object in a data node corresponding to the target directory;
the locking unit 320 is further configured to release the lock on the target directory when the snapshot rollback task is completed.
Referring to fig. 4 together, a schematic structural diagram of another snapshot rollback apparatus according to an embodiment of the present invention is shown in fig. 4, where on the basis of the snapshot rollback apparatus shown in fig. 3, the snapshot rollback apparatus shown in fig. 4 further includes:
the recording unit 340 is configured to record a progress state of the snapshot rollback task;
the snapshot rollback unit 330 is further configured to, when the snapshot rollback task is restarted after being stopped, continue to execute the snapshot rollback task according to the recorded latest snapshot rollback task progress state.
In an optional embodiment, the snapshot rollback unit 330 is specifically configured to generate an index node number of a target restore file corresponding to the target file when the target file in the target directory is migrated to another directory in the same namespace; the index node number of the target recovery file is different from the index node number of the target file; and restoring other metadata of the target file except the index node number in the metadata node corresponding to the target directory according to the target snapshot, and copying the data object of the target file in the target snapshot to the data node corresponding to the target restoration file.
In an optional embodiment, the snapshot rollback unit 330 is specifically configured to generate an index node number of a target restore file corresponding to the target file when the target file in the target directory is migrated to another directory in the same namespace; the index node number of the target recovery file is different from the index node number of the target file; restoring other metadata of the target file except for the index node number in a metadata node corresponding to the target directory according to the target snapshot, pointing the target restoration file to a data object of the target file in the target snapshot, and adding a preset identifier to the target restoration file;
accordingly, referring to fig. 5 together, a schematic structural diagram of another snapshot rollback apparatus according to an embodiment of the present invention is shown in fig. 5, where on the basis of the snapshot rollback apparatus shown in fig. 3, the snapshot rollback apparatus shown in fig. 5 further includes:
and the data processing unit 350 is configured to, when data reading needs to be performed on the data object of the target recovery file and it is determined that the target recovery file carries the preset identifier, return data of the target file in the data object of the target snapshot to a data reading requester.
In an optional embodiment, the snapshot rollback unit 330 is specifically configured to, when data modification needs to be performed on a data object of the target recovery file and it is determined that the target recovery file carries the preset identifier, copy the data object of the target file in the target snapshot to a data node corresponding to the target recovery file; when the data object is copied, deleting the preset identification;
the data processing unit 350 is further configured to perform data modification operations
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the invention. One of ordinary skill in the art can understand and implement it without inventive effort.
As can be seen from the above embodiments, the target directory is locked by receiving the snapshot rollback instruction, and then the current metadata in the metadata node and the current data object in the data node corresponding to the target directory are deleted, and the metadata in the metadata node and the data object in the data node corresponding to the target directory are restored according to the target snapshot.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

Claims (8)

1. A snapshot rollback method is applied to a distributed file system, and is characterized by comprising the following steps:
receiving a snapshot rollback instruction, wherein the snapshot rollback instruction carries an identifier of a target snapshot used for snapshot rollback; the target snapshot is established based on a target directory and comprises snapshot metadata and a snapshot data object corresponding to the target directory;
locking the target directory;
deleting the current metadata in the metadata node and the current data object in the data node corresponding to the target directory;
according to the target snapshot, recovering metadata in metadata nodes and data objects in data nodes corresponding to the target directory;
when the snapshot rollback task is completed, unlocking the target directory;
the restoring the metadata in the metadata node and the data object in the data node corresponding to the target directory according to the target snapshot includes:
when the target file under the target directory is migrated to other directories under the same name space, generating an index node number of a target recovery file corresponding to the target file; the index node number of the target recovery file is different from the index node number of the target file;
and restoring other metadata of the target file except the index node number in the metadata node corresponding to the target directory according to the target snapshot, and copying the data object of the target file in the target snapshot to the data node corresponding to the target restoration file.
2. The method of claim 1, wherein after receiving the snapshot rollback instruction, further comprising:
recording the progress state of the snapshot rollback task;
before the snapshot rollback task is completed, the method further comprises the following steps:
and when the snapshot rollback task is restarted after stopping, continuously executing the snapshot rollback task according to the recorded latest snapshot rollback task progress state.
3. The method of claim 1, wherein the restoring the metadata in the metadata node and the data object in the data node corresponding to the target directory according to the target snapshot comprises:
when the target file under the target directory is migrated to other directories under the same name space, generating an index node number of a target recovery file corresponding to the target file; the index node number of the target recovery file is different from the index node number of the target file;
restoring other metadata of the target file except for the index node number in a metadata node corresponding to the target directory according to the target snapshot, pointing the target restoration file to a data object of the target file in the target snapshot, and adding a preset identifier to the target restoration file;
and when the data object of the target recovery file needs to be subjected to data reading and the target recovery file is determined to have the preset identifier, returning the data of the target file in the data object of the target snapshot to a data reading requester.
4. The method according to claim 3, wherein after adding the preset identifier to the target restore file, further comprising:
when data modification needs to be carried out on the data object of the target recovery file and the target recovery file is determined to be provided with the preset identifier, copying the data object of the target file in the target snapshot to a data node corresponding to the target recovery file;
and when the data object is copied, deleting the preset identification and carrying out data modification operation.
5. A snapshot rollback apparatus applied to a distributed file system, the apparatus comprising:
the receiving unit is used for receiving a snapshot rollback instruction, wherein the snapshot rollback instruction carries an identifier of a target snapshot used for snapshot rollback; the target snapshot is established based on a target directory and comprises snapshot metadata and a snapshot data object corresponding to the target directory;
a locking unit for the target directory;
the snapshot rollback unit is used for deleting the current metadata in the metadata node and the current data object in the data node corresponding to the target directory;
the snapshot rollback unit is further configured to restore, according to the target snapshot, metadata in a metadata node and a data object in a data node that correspond to the target directory;
the locking unit is further used for unlocking the target directory when the snapshot rollback task is completed;
the snapshot rollback unit is specifically configured to generate an index node number of a target restore file corresponding to the target file when the target file in the target directory is migrated to another directory in the same namespace; the index node number of the target recovery file is different from the index node number of the target file; and restoring other metadata of the target file except the index node number in the metadata node corresponding to the target directory according to the target snapshot, and copying the data object of the target file in the target snapshot to the data node corresponding to the target restoration file.
6. The apparatus of claim 5, further comprising:
the recording unit is used for recording the progress state of the snapshot rollback task;
and the snapshot rollback unit is further used for continuing to execute the snapshot rollback task according to the recorded latest snapshot rollback task progress state when the snapshot rollback task is restarted after being stopped.
7. The apparatus of claim 5,
the snapshot rollback unit is specifically configured to generate an index node number of a target restore file corresponding to the target file when the target file in the target directory is migrated to another directory in the same namespace; the index node number of the target recovery file is different from the index node number of the target file; restoring other metadata of the target file except for the index node number in a metadata node corresponding to the target directory according to the target snapshot, pointing the target restoration file to a data object of the target file in the target snapshot, and adding a preset identifier to the target restoration file;
the device further comprises:
and the data processing unit is used for returning the data of the target file in the data object of the target snapshot to a data reading requester when the data reading of the data object of the target recovery file is required and the target recovery file is determined to be provided with the preset identifier.
8. The apparatus of claim 7,
the snapshot rollback unit is specifically configured to, when data modification needs to be performed on a data object of the target recovery file and it is determined that the target recovery file carries the preset identifier, copy the data object of the target file in the target snapshot to a data node corresponding to the target recovery file; when the data object is copied, deleting the preset identification;
the data processing unit is also used for carrying out data modification operation.
CN201710512250.7A 2017-06-29 2017-06-29 Snapshot rollback method and device Active CN108255638B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710512250.7A CN108255638B (en) 2017-06-29 2017-06-29 Snapshot rollback method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710512250.7A CN108255638B (en) 2017-06-29 2017-06-29 Snapshot rollback method and device

Publications (2)

Publication Number Publication Date
CN108255638A CN108255638A (en) 2018-07-06
CN108255638B true CN108255638B (en) 2021-05-28

Family

ID=62722248

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710512250.7A Active CN108255638B (en) 2017-06-29 2017-06-29 Snapshot rollback method and device

Country Status (1)

Country Link
CN (1) CN108255638B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108984779A (en) * 2018-07-25 2018-12-11 郑州云海信息技术有限公司 Distributed file system snapshot rollback metadata processing method, device and equipment
CN109344118B (en) * 2018-09-26 2021-10-15 郑州云海信息技术有限公司 Snapshot rollback recovery method, system, device and computer readable storage medium
CN109189614A (en) * 2018-10-19 2019-01-11 郑州云海信息技术有限公司 A kind of snapshot rollback method and device
CN109408294A (en) * 2018-11-13 2019-03-01 郑州云海信息技术有限公司 A kind of snapshot rollback method, device, equipment and storage medium
CN109271367A (en) * 2018-12-07 2019-01-25 浪潮(北京)电子信息产业有限公司 Distributed file system multinode snapshot rollback method and system
CN115878563B (en) * 2023-02-17 2023-06-02 北京大道云行科技有限公司 Method for realizing directory-level snapshot of distributed file system and electronic equipment

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104933133A (en) * 2015-06-12 2015-09-23 中国科学院计算技术研究所 Metadata snap storage and access method in distributed file system

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4668763B2 (en) * 2005-10-20 2011-04-13 株式会社日立製作所 Storage device restore method and storage device
CN103473258A (en) * 2013-06-01 2013-12-25 西安邮电大学 Cloud storage file system
CN103645967B (en) * 2013-11-26 2016-06-22 华为技术有限公司 A kind of read-only materialized view rollback method and device
CN104714755B (en) * 2013-12-13 2020-01-03 华为技术有限公司 Snapshot management method and device
US20150242282A1 (en) * 2014-02-24 2015-08-27 Red Hat, Inc. Mechanism to update software packages
CN104750573B (en) * 2014-12-17 2017-10-24 杭州斯凯网络科技有限公司 The global coherency backup-and-restore method of distributed data system back end
CN106814972B (en) * 2016-12-22 2018-04-17 北京华云网际科技有限公司 The rollback method and device of the snapshot node of distributed block storage

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104933133A (en) * 2015-06-12 2015-09-23 中国科学院计算技术研究所 Metadata snap storage and access method in distributed file system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Recycling-oriented production and assessment of Fuji Film one time use camera "Quick Snap";S. Ichino等;《institute of electrical and electronic engineers》;20020806;全文 *
云存储日志文件系统中快照的设计与实现;陈莉君等;《计算机应用与软件》;20130715;全文 *

Also Published As

Publication number Publication date
CN108255638A (en) 2018-07-06

Similar Documents

Publication Publication Date Title
CN108255638B (en) Snapshot rollback method and device
US11741048B2 (en) Distributed write journals that support fast snapshotting for a distributed file system
US9934104B2 (en) Metadata generation for incremental backup
US10956364B2 (en) Efficient data synchronization for storage containers
US11635908B2 (en) Managing digital assets stored as components and packaged files
US8738883B2 (en) Snapshot creation from block lists
US10146630B1 (en) Block changes framework for delta file incremental backup
US10146631B1 (en) Incremental forever backups for exchange
US10162555B2 (en) Deduplicating snapshots associated with a backup operation
US8606759B2 (en) Apparatus, system and method for recovering meta data using fragmentary information
US9223797B2 (en) Reparse point replication
US10102083B1 (en) Method and system for managing metadata records of backups
US20160124815A1 (en) Efficient backup of virtual data
KR101674176B1 (en) Method and apparatus for fsync system call processing using ordered mode journaling with file unit
US10223206B1 (en) Method and system to detect and delete uncommitted save sets of a backup
CN115098299A (en) Backup method, disaster recovery method, device and equipment for virtual machine
CN109753381B (en) Continuous data protection method based on object storage
CN113254394B (en) Snapshot processing method, system, equipment and storage medium
US10445183B1 (en) Method and system to reclaim disk space by deleting save sets of a backup
US20200409570A1 (en) Snapshots for any point in time replication
US10545829B2 (en) Using file system extended attributes to recover databases in hierarchical file systems
US10423494B2 (en) Trimming unused blocks from a versioned image backup of a source storage that is stored in a sparse storage
KR102089710B1 (en) Continous data mangement system and method
CN108958968B (en) File processing method and device
CN108376104B (en) Node scheduling method and device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant