CN113342741B - Snapshot implementation method and device, electronic equipment and computer readable storage medium - Google Patents

Snapshot implementation method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN113342741B
CN113342741B CN202110867353.1A CN202110867353A CN113342741B CN 113342741 B CN113342741 B CN 113342741B CN 202110867353 A CN202110867353 A CN 202110867353A CN 113342741 B CN113342741 B CN 113342741B
Authority
CN
China
Prior art keywords
snapshot
entry
node
version number
directory entry
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
CN202110867353.1A
Other languages
Chinese (zh)
Other versions
CN113342741A (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.)
Lenovo Netapp Technology Ltd
Original Assignee
Lenovo Netapp Technology 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 Lenovo Netapp Technology Ltd filed Critical Lenovo Netapp Technology Ltd
Priority to CN202110867353.1A priority Critical patent/CN113342741B/en
Publication of CN113342741A publication Critical patent/CN113342741A/en
Application granted granted Critical
Publication of CN113342741B publication Critical patent/CN113342741B/en
Priority to PCT/CN2022/105946 priority patent/WO2023005688A1/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/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/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices

Abstract

A snapshot implementation method and device, electronic equipment and a computer-readable storage medium are provided. The method comprises the following steps: selecting at least one directory entry from the plurality of directory entry entries as a target directory entry based on the target version number, a first edit version number contained in the native directory entry, and a first snapshot version number contained in the snapshot directory entry; determining at least one node entry corresponding to each target directory entry; selecting a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, a second edition version number contained in the native node entry and a second snapshot version number contained in the snapshot node entry; and obtaining the snapshot to be accessed based on the target directory entry and the target node entry, wherein the metadata of the snapshot to be accessed comprises the target directory entry and the target node entry. The method ensures that the logical relationship constraint is not performed between the snapshots, thereby simplifying the complexity of the snapshots and the metadata logic.

Description

Snapshot implementation method and device, electronic equipment and computer readable storage medium
Technical Field
Embodiments of the present disclosure relate to a snapshot implementation method and apparatus for a file system, an electronic device, and a computer-readable storage medium.
Background
In the storage field, the importance of data backup is gradually highlighted with the increasing volume of data. It is the most fundamental function and requirement for a storage system to store data and secure the data. The snapshot is a data backup method, and can be instantly completed to realize zero-window backup of data, so that the snapshot becomes a common and basic data backup technology in a plurality of data backup technologies.
A snapshot refers to a fully available copy of a given data set that includes an image of the corresponding data at some point in time (the point in time at which the copy began). The primary role of the snapshot is to enable data backup and recovery. When the application failure or file damage occurs to the storage device, the data can be quickly recovered, and the data can be recovered to the state of a certain available time point, so that the requirements of enterprises on service continuity and data reliability can be met.
Disclosure of Invention
At least one embodiment of the present disclosure provides a snapshot implementation method for a file system, wherein metadata of the file system includes a plurality of directory entry items and a plurality of node entry items, the plurality of directory entry items include at least one native directory entry item and at least one snapshot directory entry item, the native directory entry item records current organization information of the file system, the native directory entry item includes a first edit version number, the snapshot directory entry records organization information that does not exist currently in the file system and exists when a snapshot is generated, the snapshot directory entry item includes a first snapshot version number, the plurality of node entry items include at least one native node entry and at least one snapshot node entry, the native node entry records current file attribute information of the file system, the native node entry includes a second edit version number, the snapshot node entry records current absence, or location of the file system, File attribute information existing when a snapshot is generated, wherein a snapshot node entry comprises a second snapshot version number, and the method comprises the following steps: selecting at least one directory entry from the plurality of directory entry items as a target directory entry item based on the target version number, a first editing version number contained in the native directory entry, and a first snapshot version number contained in the snapshot directory entry, wherein the target version number is a version number corresponding to the snapshot to be accessed; determining at least one node entry corresponding to each target directory entry; selecting a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, a second edition version number contained in the native node entry and a second snapshot version number contained in the snapshot node entry; and obtaining the snapshot needing to be accessed based on the target directory entry and the target node entry, wherein the metadata of the snapshot needing to be accessed comprises the target directory entry and the target node entry.
For example, in a method provided by an embodiment of the present disclosure, selecting at least one directory entry from a plurality of directory entry entries as a target directory entry based on a target version number, a first edit version number included in a native directory entry, and a first snapshot version number included in a snapshot directory entry includes: for a native directory entry in the plurality of directory entry items, selecting the native directory entry of which the first edition version number is smaller than the target version number as a target directory entry; for a snapshot directory entry of the plurality of directory entry entries, a snapshot directory entry having a first snapshot version number comprising a target version number is selected as the target directory entry.
For example, in a method provided by an embodiment of the present disclosure, each of a plurality of directory entry entries and a plurality of node entries includes a node identification; determining at least one node entry corresponding to each target directory entry, including: for each target directory entry, selecting a node entry having the same node identification as the target directory entry from the plurality of node entries as at least one node entry corresponding to the target directory entry according to the node identification in the target directory entry.
For example, in the method provided in an embodiment of the present disclosure, selecting a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, the second edit version number included in the native node entry, and the second snapshot version number included in the snapshot node entry, includes: for a native node entry in the node entries corresponding to each target directory entry, selecting a native node entry of which the second edition version number is smaller than the target version number as a target node entry; for snapshot node entries in the node entries corresponding to each target directory entry, a snapshot node entry whose second snapshot version number contains the target version number is selected as the target node entry.
For example, in the method provided in an embodiment of the present disclosure, the first snapshot version number and the second snapshot version number are both recorded in a form of a numerical interval, the numerical interval includes a starting point number and an end point number, and the starting point number is less than or equal to the end point number.
For example, in the method provided in an embodiment of the present disclosure, the value interval is a half-open and half-closed interval, the starting point number does not belong to the value interval, and the ending point number belongs to the value interval.
For example, an embodiment of the present disclosure provides a method further including: a plurality of directory entry entries and a plurality of node entries are processed.
For example, in a method provided by an embodiment of the present disclosure, processing a plurality of directory entry entries and a plurality of node entries includes: for the operation of the newly-built file, a native directory entry and a native node entry corresponding to the newly-built file are created, and the current system version number is used as a first edition version number of the native directory entry and a second edition version number of the native node entry; for the operation of deleting the file, copying a native directory entry and a native node entry corresponding to the file to be deleted, creating a snapshot directory entry and a snapshot node entry corresponding to the file to be deleted based on the copied content, and deleting the native directory entry and the native node entry corresponding to the file to be deleted; for the operation of modifying the file, copying a native node entry corresponding to the file to be modified, creating a snapshot node entry corresponding to the file to be modified based on the copied content, and updating the native node entry corresponding to the file to be modified based on the modified content.
For example, in a method provided by an embodiment of the present disclosure, the metadata of the file system further includes a global snapshot count that is incremented each time an operation of creating a snapshot is performed to implement the count.
For example, in a method provided by an embodiment of the present disclosure, for a delete file operation, copying a native directory entry and a native node entry corresponding to a file to be deleted, and creating a snapshot directory entry and a snapshot node entry corresponding to the file to be deleted based on copied contents includes: taking a numerical value interval formed by a first edition version number of a primary directory entry and a current global snapshot count as a first snapshot version number of a snapshot directory entry, and taking organization information recorded in the primary directory entry as organization information of the snapshot directory entry; and taking a numerical value interval formed by the second edition version number of the native node entry and the current global snapshot count as the second snapshot version number of the snapshot node entry, and taking the file attribute information recorded in the native node entry as the file attribute information of the snapshot node entry.
For example, in a method provided by an embodiment of the present disclosure, for a modify file operation, copying a native node entry corresponding to a file to be modified, creating a snapshot node entry corresponding to the file to be modified based on copied content, and updating the native node entry corresponding to the file to be modified based on modified content, the method includes: taking a numerical value interval formed by a second edition version number of a primary node entry corresponding to the file to be modified and the current global snapshot count as a second snapshot version number of the snapshot node entry, and taking file attribute information recorded in the primary node entry corresponding to the file to be modified as file attribute information of the snapshot node entry; and modifying the native node entry corresponding to the file to be modified based on the modification content, and taking the current system version number as a second editing version number of the native node entry so as to update the native node entry.
For example, in the method provided in an embodiment of the present disclosure, a plurality of directory entry entries and a plurality of node entry entries are stored in a key value storage manner.
For example, in a method provided by an embodiment of the present disclosure, for a plurality of directory entry entries, a snapshot identifier is used to distinguish a native directory entry from a snapshot directory entry in the plurality of directory entry entries, where the snapshot directory entry includes the snapshot identifier, and the snapshot identifier is not present in the native directory entry; for the plurality of node entries, a snapshot identifier is used to distinguish a native node entry from a snapshot node entry in the plurality of node entries, the snapshot node entry includes the snapshot identifier, and the snapshot identifier is absent from the native node entry.
At least one embodiment of the present disclosure further provides a snapshot implementation apparatus for a file system, wherein metadata of the file system includes a plurality of directory entry entries and a plurality of node entries, the plurality of directory entry entries includes at least one native directory entry and at least one snapshot directory entry, the native directory entry records current organization information of the file system, the native directory entry includes a first edit version number, the snapshot directory entry records organization information that does not exist currently in the file system and exists when a snapshot is generated, the snapshot directory entry includes a first snapshot version number, the plurality of node entries includes at least one native node entry and at least one snapshot node entry, the native node entry records current file attribute information of the file system, the native node entry includes a second edit version number, the snapshot node entry records current absence, and location of the file system, File attribute information existing at the time of generating a snapshot, a snapshot node entry including a second snapshot version number, the apparatus comprising: the first determining unit is configured to select at least one directory entry from the plurality of directory entry items as a target directory entry item based on the target version number, a first editing version number contained in the native directory entry, and a first snapshot version number contained in the snapshot directory entry, wherein the target version number is a version number corresponding to a snapshot to be accessed; a second determining unit configured to determine at least one node entry corresponding to each target directory entry; the third determining unit is configured to select a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, a second editing version number contained in the native node entry, and a second snapshot version number contained in the snapshot node entry; and the access unit is configured to obtain the snapshot needing to be accessed based on the target directory entry and the target node entry, wherein the metadata of the snapshot needing to be accessed comprises the target directory entry and the target node entry.
At least one embodiment of the present disclosure further provides an electronic device, including a snapshot implementation apparatus for a file system provided in any embodiment of the present disclosure.
At least one embodiment of the present disclosure also provides an electronic device including: a processor; a memory including one or more computer program modules; wherein one or more computer program modules are stored in the memory and configured to be executed by the processor, the one or more computer program modules comprising instructions for implementing a snapshot implementation method for a file system provided by any embodiment of the present disclosure.
At least one embodiment of the present disclosure also provides a computer-readable storage medium for storing non-transitory computer-readable instructions, which when executed by a computer, are used for implementing a snapshot implementation method for a file system provided in any one embodiment of the present disclosure.
Drawings
To more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly introduced below, and it is apparent that the drawings in the following description relate only to some embodiments of the present disclosure and are not limiting to the present disclosure.
FIG. 1 is a schematic diagram of a directory entry of a file system;
fig. 2A to fig. 2D are schematic diagrams illustrating entry contents of metadata of a file system according to some embodiments of the present disclosure;
FIG. 3 is a flowchart illustrating a snapshot implementation method for a file system according to some embodiments of the present disclosure;
FIG. 4 is a schematic flowchart of step S11 in FIG. 3;
FIG. 5 is a schematic flowchart of step S13 in FIG. 3;
fig. 6A to 6B are schematic diagrams of metadata of a file system according to some embodiments of the present disclosure;
FIG. 7 is a flowchart illustrating another snapshot implementation method for a file system according to some embodiments of the present disclosure;
FIG. 8 is a schematic flowchart of step S15 in FIG. 7;
FIG. 9 is a schematic flowchart of step S152 in FIG. 8;
fig. 10 is a schematic diagram illustrating a metadata processing manner for a delete file operation in a snapshot implementation method according to some embodiments of the present disclosure;
FIG. 11 is a flowchart illustrating step S153 in FIG. 8;
fig. 12 is a schematic diagram illustrating a metadata processing manner for a delete file operation and a modify file operation in a snapshot implementation method according to some embodiments of the present disclosure;
fig. 13 is a schematic diagram of a snapshot access performed by the snapshot implementation method according to the embodiment of the present disclosure;
FIG. 14 is a schematic block diagram of a snapshot implementation apparatus for a file system according to some embodiments of the present disclosure;
fig. 15 is a schematic block diagram of an electronic device provided by some embodiments of the present disclosure;
fig. 16 is a schematic block diagram of another electronic device provided by some embodiments of the present disclosure; and
fig. 17 is a schematic diagram of a computer-readable storage medium according to some embodiments of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings of the embodiments of the present disclosure. It is to be understood that the described embodiments are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the described embodiments of the disclosure without any inventive step, are within the scope of protection of the disclosure.
Unless otherwise defined, technical or scientific terms used herein shall have the ordinary meaning as understood by one of ordinary skill in the art to which this disclosure belongs. The use of "first," "second," and similar terms in this disclosure is not intended to indicate any order, quantity, or importance, but rather is used to distinguish one element from another. Also, the use of the terms "a," "an," or "the" and similar referents do not denote a limitation of quantity, but rather denote the presence of at least one. The word "comprising" or "comprises", and the like, means that the element or item listed before the word covers the element or item listed after the word and its equivalents, but does not exclude other elements or items. The terms "connected" or "coupled" and the like are not restricted to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "upper", "lower", "left", "right", and the like are used merely to indicate relative positional relationships, and when the absolute position of the object being described is changed, the relative positional relationships may also be changed accordingly.
Snapshots are typically used in file systems, which result in more complex snapshot implementations due to the file system having complex metadata, data, etc. information. For example, when a snapshot is generated, a cascade relationship between snapshots cannot be realized, that is, when a snapshot is made in the directory, the subdirectory cannot be snapshot any more, which limits the implementation of the snapshot and causes inconvenience in use.
At least one embodiment of the present disclosure provides a snapshot implementation method and apparatus for a file system, an electronic device, and a computer-readable storage medium. According to the method, the snapshot logic is abstractly described, so that the logical relationship constraint is not performed between snapshots, the complexity of the snapshots is simplified, the metadata related logic is simplified, and the method is easy to implement in a file system.
Hereinafter, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings. It should be noted that the same reference numerals in different figures will be used to refer to the same elements that have been described.
At least one embodiment of the present disclosure provides a snapshot implementation method for a file system. The metadata of the file system includes a plurality of directory entry entries and a plurality of node entries. The plurality of directory entry entries includes at least one native directory entry and at least one snapshot directory entry. The native directory entry records current organization information of the file system, and the native directory entry includes a first edit version number. The snapshot directory entry records organization information which does not exist in the file system at present and exists when the snapshot is generated, and the snapshot directory entry comprises a first snapshot version number. The plurality of node entries includes at least one native node entry and at least one snapshot node entry. The native node entry records the current file attribute information of the file system, and the native node entry comprises a second edition version number. The snapshot node entry records file attribute information which does not exist in the file system at present and exists when the snapshot is generated, and the snapshot node entry comprises a second snapshot version number.
The method comprises the following steps: selecting at least one directory entry from the plurality of directory entry items as a target directory entry item based on the target version number, a first editing version number contained in the native directory entry, and a first snapshot version number contained in the snapshot directory entry, wherein the target version number is a version number corresponding to the snapshot to be accessed; determining at least one node entry corresponding to each target directory entry; selecting a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, a second edition version number contained in the native node entry and a second snapshot version number contained in the snapshot node entry; and obtaining the snapshot to be accessed based on the target directory entry and the target node entry, wherein the metadata of the snapshot to be accessed comprises the target directory entry and the target node entry.
For example, a file system typically includes data and metadata. Metadata is data (data about data) for describing data, and mainly describes information of data attributes, and is used for supporting functions such as indicating storage locations, history data, resource searching, file recording and the like. The metadata of the file system includes, for example, a directory entry (entry) and an index node (inode). Directory entries are used to describe the organization of files (or folders) in a file system, and index nodes are attribute information of the files (or folders). In the file system, each file corresponds to an index node as a unique number of the file, and the file system accesses information of the index node through an index node number (inodeid).
For example, the directory entries in the metadata record information such as file names and upper directories, and a tree structure reflecting file system organization information can be formed by connecting all directory entries in a parent directory/child directory manner. For example, as shown in fig. 1, a tree structure reflecting organization information of the file system may be obtained by using directory entries of the file system, and then information of corresponding index nodes is obtained by using index node numbers of files (or folders) dir1, dir2, dir3, file1, and file2, so that complete information of the file system may be read. For example, in this example, dir1, dir2, dir3 represent folders, and file1, file2 represent files.
For example, the metadata of the file system provided by the embodiment of the present disclosure includes a plurality of directory entry entries and a plurality of node entries. For example, the directory entry is the above-mentioned directory entry (entry), and the node entry is the above-mentioned index node (inode).
The plurality of directory entry includes at least one native directory entry and at least one snapshot directory entry, that is, the plurality of directory entry is divided into two types, a native directory entry and a snapshot directory entry.
The native directory entry records the current organization information of the file system, and the native directory entry comprises a first edition version number. For example, the first edit version number refers to the system version number when the native directory entry was created. The system version number is determined according to the number of times of generating snapshots, that is, if a snapshot generating operation is performed on the file system 4 times, the file system has 4 versions, and accordingly, the system version number may be any one of (1) to (4).
The snapshot directory entry records organization information which does not exist in the file system at present and exists when the snapshot is generated, and the snapshot directory entry comprises a first snapshot version number. For example, the first snapshot version number refers to the snapshot to which versions the snapshot directory entry corresponds. For example, the first snapshot version number may be described in the form of a numerical interval including a start point number and an end point number, the start point number being less than or equal to the end point number. For example, the value interval is a half-open and half-closed interval, the starting point number does not belong to the value interval, and the end point number belongs to the value interval. The starting point number is the initial version of the snapshot, and the end point number is the ending version of the snapshot. For example, the value interval of the first snapshot version number may include a plurality of sub-intervals, each sub-interval is also an independent value interval, and the sub-intervals may be connected to each other or spaced from each other, thereby representing diversified version numbers.
For example, taking an example of taking 4 snapshot generating operations performed on a file system, where the system version number is any one of (1) - (4), and if the snapshot directory entry is created in version (3), the first snapshot version number of the snapshot directory entry is (0, 3), that is, an object (which may be a file or a folder) corresponding to the snapshot directory entry exists when a snapshot is generated from 1 st to 3 rd times.
The plurality of node entries include at least one native node entry and at least one snapshot node entry, that is, the plurality of node entries are divided into two types, a native node entry and a snapshot node entry.
The native node entry records the current file attribute information of the file system, and the native node entry comprises a second edition version number. For example, the second edit version number refers to a system version number when the native node entry is created or modified, and the meaning of the system version number is as described above and is not described herein again.
The snapshot node entry records file attribute information which does not exist in the file system at present and exists when the snapshot is generated, and the snapshot node entry comprises a second snapshot version number. For example, the second snapshot version number refers to the snapshots to which versions the snapshot node entry corresponds. For example, the second snapshot version number may be described in the form of a numerical interval including a starting point number and an ending point number, the starting point number being less than or equal to the ending point number. For example, the value interval is a half-open and half-closed interval, the starting point number does not belong to the value interval, and the end point number belongs to the value interval. The starting point number is the initial version of the snapshot, and the end point number is the ending version of the snapshot. For example, the value interval of the second snapshot version number may include a plurality of sub-intervals, each sub-interval is also an independent value interval, and the sub-intervals may be connected to each other or spaced from each other, thereby representing diversified version numbers.
For example, taking an example that a snapshot operation is performed 4 times on a file system, a system version number is any one of (1) - (4), and if the snapshot node entry is created in the version (3), a second snapshot version number of the snapshot node entry is (0, 3).
It should be noted that, the first snapshot version number and the second snapshot version number both refer to which versions of snapshots the corresponding snapshot entry corresponds, and here, "first" and "second" are only used to distinguish the version numbers in different types of snapshot entries, and do not indicate any format, order, number, and importance. Similarly, the first edit version number and the second edit version number both refer to the system version number at the time the corresponding entry is created, and here, "first" and "second" are merely for distinguishing the version numbers in different types of native entries and do not indicate any format, order, number, importance.
In the embodiment of the present disclosure, both the first snapshot version number and the second snapshot version number are recorded in a form of a numerical range. When the number of starting points of the value interval is equal to the number of end points, the value interval represents a single value, which is equal to the number of starting points and also equal to the number of end points. Therefore, the first snapshot version number and the second snapshot version number may be intervals including a plurality of values, or may be only one value.
For example, the metadata of the file system may be stored in any manner, such as Key-Value storage (KV). In the following description, the content and format of each entry of the embodiment of the present disclosure are described by taking key value storage as an example in conjunction with fig. 2A to 2D, but this does not constitute a limitation to the embodiment of the present disclosure. The data format and the numerical value in fig. 2A to 2D are schematic, and in practical applications, the data format and the numerical value corresponding to each item of content may be determined according to actual requirements.
For example, the native directory entry is stored in the format Key: parent _ inodeid/dname, Value: inodeid, v 1. parent _ inodeid denotes an inode number of a parent directory, dname denotes a name of an object corresponding to the entry, inodeid denotes an inode number of the object, and v1 denotes a first edition version number. As shown in FIG. 2A, this example represents the contents of one native directory entry, parent _ inodeid is D001, dname is dir1.1, inodeid is 0xD003, and v1 is (2). It should be noted that the storage format is only illustrative and is used to indicate what contents are stored in the native directory entry, and does not indicate the format of the actual data structure.
For example, the storage format of the snapshot directory entry is Key: s/parent _ inodeid/dname, Value: inodeid, k 1. S is a snapshot identifier for distinguishing a native directory entry from a snapshot directory entry in the plurality of directory entry. For example, the snapshot directory entry includes a snapshot identifier, whereas no snapshot identifier exists in the native directory entry, thereby distinguishing between the two. Of course, the snapshot identifier may adopt any suitable symbol or character, not limited to S above, which may be determined according to practical requirements, and the embodiments of the present disclosure are not limited thereto. parent _ inodeid represents an index node number of a parent directory, dname represents a name of an object corresponding to the entry, inodeid represents the index node number of the object, k1 represents a first snapshot version number, and k1 is a numerical range. As shown in FIG. 2B, this example shows the contents of a snapshot directory entry, the parent _ inodeid is A000, the dname is dir1, the inodeid is 0xD001, the starting point number of the numerical interval of k1 is 1, and the end point number is 2, that is, k1 is 1~ 2. Since the snapshot identifier S exists in the entry, the entry may be identified as a snapshot directory entry. It should be noted that the storage format is merely illustrative and is used to indicate what contents are stored in the snapshot directory entry, and does not indicate the format of the actual data structure.
For example, the storage format of the native node entry is Key: inodeid, Value: inodeid, v 2. inodeid indicates the inode number of the object corresponding to the entry, and v2 indicates the second edit version number. As shown in fig. 2C, this example shows the content of one native node entry, inodeid is D001, v2 is (3), and in addition, the entry stores attribute information (represented by inode) of the object. It should be noted that the storage format is merely illustrative and is used to indicate what contents are stored in the native node entry, and does not indicate the format of the actual data structure.
For example, the storage format of the snapshot node entry is Key: s/inodeid, Value: inode, k 2. S is a snapshot identifier for distinguishing a native node entry from a snapshot node entry of the plurality of node entries. For example, the snapshot node entry includes a snapshot identifier, while the snapshot identifier is not present in the native node entry, so that the two can be distinguished. Of course, the snapshot identifier may adopt any suitable symbol or character, not limited to S above, which may be determined according to practical requirements, and the embodiments of the present disclosure are not limited thereto. inodeid indicates the index node number of the object, inode indicates the attribute information of the object, k2 indicates the second snapshot version number, and k2 is a numerical range. As shown in FIG. 2D, this example shows the content of a snapshot node entry, inodeid is D004, the starting point number of the numerical interval of k2 is 1, and the end point number is 5, that is, k2 is 1~ 5. Since the snapshot identifier S exists in the entry, the entry can be identified as a snapshot node entry. It should be noted that the storage format is merely illustrative and is used to indicate what contents are stored in the snapshot node entry, and does not indicate the format of the actual data structure.
It should be noted that, in the embodiment of the present disclosure, the snapshot identifier is used to distinguish a native directory entry from a snapshot directory entry in the plurality of directory entry entries, and the snapshot identifier is used to distinguish a native node entry from a snapshot node entry in the plurality of node entries, where the snapshot directory entry and the snapshot node entry include the snapshot identifier, and the snapshot identifier is not present in the native directory entry and the native node entry. Of course, the embodiments of the present disclosure are not limited thereto, and the native entries and the snapshot entries may be distinguished in other manners, which may be determined according to actual needs.
It should be noted that, in the embodiment of the present disclosure, the plurality of directory entry entries and the plurality of node entries may both be stored in a key value storage manner, but this does not limit the embodiment of the present disclosure. For example, the storage modes adopted by the native directory entry, the snapshot directory entry, the native node entry, and the snapshot node entry are not limited to the key value storage mode, and may be any suitable storage mode. The formats shown in fig. 2A to 2D are only schematic, whether each item of content is stored in a key field or a value field may be adjusted according to actual needs, and the specific format of each item of content may also be determined according to actual needs, which is not limited by the embodiment of the disclosure.
Fig. 3 is a flowchart illustrating a snapshot implementation method for a file system according to some embodiments of the present disclosure. For example, the method may be used with the file system described above in connection with fig. 1, 2A-2D. The file system is stored in, for example, a Network Attached Storage (NAS) system or any other system that needs to implement a snapshot, which is not limited in this respect by the embodiments of the present disclosure. For example, in some embodiments, as shown in FIG. 3, the method includes the following operations.
Step S11: selecting at least one directory entry from the plurality of directory entry items as a target directory entry item based on the target version number, a first editing version number contained in the native directory entry, and a first snapshot version number contained in the snapshot directory entry, wherein the target version number is a version number corresponding to the snapshot to be accessed;
step S12: determining at least one node entry corresponding to each target directory entry;
step S13: selecting a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, a second edition version number contained in the native node entry and a second snapshot version number contained in the snapshot node entry;
step S14: and obtaining the snapshot to be accessed based on the target directory entry and the target node entry, wherein the metadata of the snapshot to be accessed comprises the target directory entry and the target node entry.
For example, in step S11, the target version number is the version number corresponding to the snapshot that needs to be accessed. For example, in some examples, assuming that 4 snapshot-generating operations are performed on the file system, the system version number may be (1) - (4), and the target version number may be any one of (1) - (4). And selecting from the plurality of directory entry items according to the target version number and based on a first edition version number contained in a native directory entry in the file system and a first snapshot version number contained in a snapshot directory entry, thereby obtaining at least one directory entry as a target directory entry.
Fig. 4 is a schematic flowchart of step S11 in fig. 3. As shown in fig. 4, in some examples, step S11 in fig. 3 may further include the following operations.
Step S111: for a native directory entry in the plurality of directory entry items, selecting the native directory entry of which the first edition version number is smaller than the target version number as a target directory entry;
step S112: for a snapshot directory entry of the plurality of directory entry entries, a snapshot directory entry having a first snapshot version number comprising a target version number is selected as the target directory entry.
For example, in step S111, a native directory entry in all directory entry entries may be traversed, and a native directory entry with a first edit version number smaller than the target version number is selected, and the resulting native directory entry is selected as the target directory entry. For example, the target version number is a version number corresponding to a snapshot that needs to be accessed, and if a first edit version number of a certain native directory entry is smaller than the target version number, it indicates that the native directory entry is created before the snapshot corresponding to the target version number is generated, and therefore, the snapshot corresponding to the target version number should include the native directory entry, and the native directory entry is selected as the target directory entry. For example, the target directory entry is used to access the snapshot corresponding to the target version number.
For example, in step S112, a snapshot directory entry in all directory entry may be traversed, and a snapshot directory entry whose first snapshot version number includes a target version number is selected, and the obtained snapshot directory entry is selected as the target directory entry. For example, the target version number is a version number corresponding to a snapshot to be accessed, and if a first snapshot version number of a snapshot directory entry includes the target version number, it indicates that the snapshot directory entry exists when a snapshot corresponding to the target version number is generated, so that the snapshot corresponding to the target version number should include the snapshot directory entry, and the snapshot directory entry is selected as the target directory entry. For example, the target directory entry is used to access the snapshot corresponding to the target version number.
Returning to fig. 3, for example, in step S12, since each of the plurality of directory entry entries and the plurality of node entries includes a node identification (i.e., the aforementioned inodeid), each of the target directory entry entries also includes a node identification. Determining at least one node entry corresponding to each target directory entry may include: for each target directory entry, selecting a node entry having the same node identification as the target directory entry from the plurality of node entries according to the node identification in the target directory entry as at least one node entry corresponding to the target directory entry. That is, by determining whether the node identifiers are the same, at least one node entry corresponding to each target directory entry may be determined. When the node identification of a certain node entry is the same as the node identification of the target directory entry, the node entry is determined to correspond to the target directory entry. It should be noted that the determined node entries may be one or more, and may include a native node entry and/or a snapshot node entry.
For example, in step S13, a selection is made among at least one node entry corresponding to each target directory entry according to the target version number and based on the second edit version number included in the native node entry and the second snapshot version number included in the snapshot node entry in the file system, and the selected node entry is used as the target node entry.
Fig. 5 is a schematic flowchart of step S13 in fig. 3. As shown in fig. 5, in some examples, step S13 in fig. 3 may further include the following operations.
Step S131: for a native node entry in the node entries corresponding to each target directory entry, selecting a native node entry of which the second edition version number is smaller than the target version number as a target node entry;
step S132: for snapshot node entries in the node entries corresponding to each target directory entry, a snapshot node entry whose second snapshot version number contains the target version number is selected as the target node entry.
For example, in step S131, the native node entry in the node entries obtained in step S12 may be traversed, and a native node entry with a second edit version number smaller than the target version number may be selected, and the obtained native node entry may be selected as the target node entry. For example, the target version number is a version number corresponding to a snapshot that needs to be accessed, and if a second editing version number of a certain native node entry is smaller than the target version number, it indicates that the native node entry is created or modified before the snapshot corresponding to the target version number is generated, so that the snapshot corresponding to the target version number should include the native node entry, and the native node entry is selected as the target node entry. For example, the target node entry is used to access the snapshot corresponding to the target version number.
For example, in step S132, the snapshot node entry in the node entries obtained in step S12 may be traversed, and the snapshot node entry whose second snapshot version number includes the target version number is selected, and the obtained snapshot node entry is selected as the target node entry. For example, the target version number is a version number corresponding to a snapshot that needs to be accessed, and if a second snapshot version number of a certain snapshot node entry includes the target version number, it indicates that the snapshot node entry exists when the snapshot corresponding to the target version number is generated, so that the snapshot corresponding to the target version number should include the snapshot node entry, and the snapshot node entry is selected as the target node entry. For example, the target node entry is used to access the snapshot corresponding to the target version number.
Returning to fig. 3, for example, in step S14, a snapshot to be accessed is obtained based on the target directory entry and the target node entry. For example, the metadata of the snapshot to be accessed includes a target directory entry and a target node entry, and the snapshot to be accessed can be obtained by reading the information covered by these entries.
Fig. 6A to 6B are schematic diagrams of metadata of a file system according to some embodiments of the present disclosure, where fig. 6A shows directory entry information (e.g., organization information) in the metadata, and fig. 6B shows inode information (e.g., file attribute information) in the metadata. An exemplary description of how the snapshot is accessed through the above steps is provided below in conjunction with fig. 6A-6B.
For example, as shown in FIG. 6A, the file system includes files/folders dir0, dir1, dir2, dir3, file1, file2, and file3, each of which corresponds to a directory entry. For example, dir0, dir1, file1, dir3, and file3 correspond to native directory entry entries, respectively, indicating that these files/folders are contained in the current file system. dir2, file2 correspond to snapshot directory entry entries indicating that these files/folders do not exist in the current file system, but exist in some version of the file system at one time, such as some snapshot version. For example, the first edit version number in the native directory entry of each of dir0, dir1, and file1 is (0), and the first edit version number in the native directory entry of each of dir3 and file3 is (1). The first snapshot version number in the respective snapshot directory entry of dir2 and file2 is (0, 3). it is assumed that snapshots of 1-4 versions have been made for the file system, the snapshot versions made for the folder dir0 are 1, 3, 4, and the snapshot version made for the folder dir1 is 2.
When the current file system needs to be accessed, only the native directory entry needs to be accessed, and the directory information corresponding to the current file system can be obtained. Since the information described in the access to the native directory entry is basically the same as that in a normal file system, the access method does not change.
When a snapshot of a certain version needs to be accessed, assuming that a snapshot of version 3 needs to be accessed, the judgment and selection need to be performed according to a certain rule, for example, the selection is performed according to the operations of steps S111-S112. For example, for a native directory entry, if its first edit version number is less than 3, it should be selected. For a snapshot directory entry, if its first snapshot version number contains 3, it should be selected. Therefore, according to the rule, dir0, dir1, file1, dir3 and file3 can be selected, and the first edition version number of the native directory entry corresponding to the files/folders is less than 3, which indicates that the files/folders exist when the snapshot of the 3 rd version is generated; according to the rule, dir2 and file2 can be selected, and the first snapshot version number of the snapshot directory entry corresponding to the files/folders contains 3, which indicates that the files/folders exist when the 3 rd version snapshot is generated.
After the directory information as shown in fig. 6A is obtained, that is, after the existing files/folders are determined, file attribute information corresponding to the directory information is continuously acquired in a manner described below.
For example, as shown in FIG. 6B, in the file system, it is assumed that the file1 is modified at version 3, so that there are two node entries for the file1, one being a native node entry whose second edit version number is (3), the other being a snapshot node entry (denoted by file1 ' in the figure), whose second snapshot version number is (0, 3 ]. the file3 is modified at version 4, so that for the file3, there are two node entries, one being a native node entry whose second edit version number is (4), the other being a snapshot node entry (denoted by file3 ' in the figure), whose second snapshot version number is (1, 4 ]. the folder dir3 is modified at version 3, so that for the folder dir3, there are two node entries, one being a native node entry whose second edit snapshot version number is (3), the other being a node entry (denoted by dir3 ' in the figure), its second snapshot version number is (1, 3 ].
When the current file system needs to be accessed, the file attribute information corresponding to the current file system can be obtained only by accessing the native node entry, and the operation is basically the same as the operation of accessing the current file system, so that the method can be compatible with a common access mode. Since the information described in the access to the native node entry is substantially the same as that in a normal file system, the access method does not change.
When it is required to access the snapshot of a certain version, it is assumed that the snapshot of version 3 needs to be accessed, and the judgment and selection need to be performed according to a certain rule, for example, the selection is performed according to the operations of steps S131 to S132. For example, for a native node entry, if its second edit version number is less than 3, it should be selected. For a snapshot node entry, if its second snapshot version number contains 3, it should be selected. Therefore, according to the rule, dir0 and dir1 can be selected, and the second edition version number of the native node entry corresponding to the files/folders is less than 3, which indicates that the files/folders exist when the 3 rd version snapshot is generated; according to the rule, dir2, file2, file1 ', dir3 ' and file3 ' can be selected, and the second snapshot version numbers of the snapshot node entries corresponding to the files/folders contain 3, which indicates that the files/folders exist when the 3 rd version snapshot is generated.
Thus, through the above operations, the directory entry shown in fig. 6A is obtained first, and then the node entry shown in fig. 6B is obtained, so that the required directory information and file attribute information can be obtained, and further, a snapshot to be accessed can be generated.
Fig. 7 is a flowchart illustrating another snapshot implementation method for a file system according to some embodiments of the present disclosure. For example, in some examples, as shown in fig. 7, in addition to including steps S11-S14, the method provided by this embodiment further includes step S15. Steps S11-S14 in this embodiment are substantially the same as steps S11-S14 in the method shown in fig. 3, and reference is made to the foregoing for related descriptions, which are not repeated herein.
Step S15: a plurality of directory entry entries and a plurality of node entries are processed.
For example, in step S15, in order to make the information described in the directory entry and the node entry reflect the respective versions and current states of the file system, the directory entry and the node entry need to be processed for different operations of the file system.
Fig. 8 is a flowchart illustrating step S15 in fig. 7. As shown in fig. 8, in some examples, step S15 in fig. 7 may further include the following operations.
Step S151: for the operation of the newly-built file, a native directory entry and a native node entry corresponding to the newly-built file are created, and the current system version number is used as a first edition version number of the native directory entry and a second edition version number of the native node entry;
step S152: for the operation of deleting the file, copying a native directory entry and a native node entry corresponding to the file to be deleted, creating a snapshot directory entry and a snapshot node entry corresponding to the file to be deleted based on the copied content, and deleting the native directory entry and the native node entry corresponding to the file to be deleted;
step S153: for the operation of modifying the file, copying a native node entry corresponding to the file to be modified, creating a snapshot node entry corresponding to the file to be modified based on the copied content, and updating the native node entry corresponding to the file to be modified based on the modified content.
For example, in step S151, when a new file operation is performed (the operation may be to create a file or a folder), a native directory entry and a native node entry corresponding to the newly created file are created, and the system version number at the time of creation is taken as the first edit version number of the native directory entry and the second edit version number of the native node entry. Thus, it is possible to record at which version of the file system the corresponding entry was created by the first edit version number or the second edit version number. For example, a newly created file may refer to a file or a folder, and the embodiment of the present disclosure is not limited thereto.
For example, in step S152, when a delete file operation is performed (the operation may delete a file or may delete a folder), a native directory entry and a native node entry corresponding to the file to be deleted are copied, a snapshot directory entry and a snapshot node entry corresponding to the file to be deleted are created based on the copied contents, and then the native directory entry and the native node entry corresponding to the file to be deleted are deleted. That is, if the original directory entry and the original node entry corresponding to the file to be deleted are directly deleted, when the snapshot needs to be accessed, the information of the file to be deleted cannot be obtained, so that the snapshot directory entry and the snapshot node entry need to be created based on the information of the file to be deleted, and then the deletion operation is performed, so that the information of the file to be deleted can be obtained when the snapshot is subsequently accessed. For example, the file to be deleted may refer to a file or a folder, and the embodiment of the present disclosure is not limited thereto.
For example, the metadata of the file system also includes a global snapshot count. The global snapshot count may record the number of snapshots the file system has made, and the corresponding value may be the system version number of the file system. For example, each time an operation is performed to create a snapshot, the global snapshot count is incremented, e.g., incremented by 1, to achieve a count.
Fig. 9 is a schematic flowchart of step S152 in fig. 8. As shown in fig. 9, in some examples, step S152 in fig. 8 may further include the following operations.
Step S1521: taking a numerical value interval formed by a first edition version number of a primary directory entry and a current global snapshot count as a first snapshot version number of a snapshot directory entry, and taking organization information recorded in the primary directory entry as organization information of the snapshot directory entry;
step S1522: and taking a numerical value interval formed by the second edition version number of the native node entry and the current global snapshot count as the second snapshot version number of the snapshot node entry, and taking the file attribute information recorded in the native node entry as the file attribute information of the snapshot node entry.
For example, in step S1521, since the native directory entry exists from the time of creation to the time before deletion, the value of the corresponding snapshot version is greater than the first editing version number and less than or equal to the current global snapshot count, and thus, a value interval (for example, a front-to-back closed interval) formed by the first editing version number and the current global snapshot count may be used as the first snapshot version number of the snapshot directory entry. And taking the organization information recorded in the original directory entry as the organization information of the snapshot directory entry. Thus, a corresponding snapshot directory entry is created.
For example, in step S1522, since the native node entry exists from the creation time to the deletion time, the value of the corresponding snapshot version is greater than the second edition version number and less than or equal to the current global snapshot count, and thus, a value interval (for example, a front-to-back closed interval) formed by the second edition version number and the current global snapshot count may be used as the second snapshot version number of the snapshot node entry. And taking the file attribute information recorded in the original node entry as the file attribute information of the snapshot node entry. Thus, a corresponding snapshot node entry is created.
After steps S1521 and S1522 are performed, the native directory entry and the native node entry corresponding to the file to be deleted may be deleted.
Fig. 10 is a schematic diagram of a metadata processing manner for a delete file operation in a snapshot implementation method according to some embodiments of the present disclosure. For example, in some examples, as shown in fig. 10, when it is necessary to delete dir2 and file2, it is necessary to copy the native directory entry and the native node entry of dir2 and file2, create the corresponding snapshot directory entry and snapshot node entry based on the copied contents, and then delete the native directory entry and the native node entry of dir2 and file2. For example, this process may be referred to as generating a snapshot database record (COW).
Returning to fig. 8, for example, in step S153, when the modify file operation is performed, the native node entry corresponding to the file to be modified is copied, then the snapshot node entry corresponding to the file to be modified is created based on the copied content, and then the native node entry corresponding to the file to be modified is updated based on the modified content. That is, if the native node entry corresponding to the file to be modified is directly modified, when the snapshot needs to be accessed, the information of the file to be modified before modification cannot be obtained, so that the snapshot node entry needs to be created based on the information of the file to be modified, and then the modification operation is executed, so that the information of the file to be modified before modification can be obtained when the snapshot is subsequently accessed. For example, the file to be modified may refer to a file or a folder, and the embodiment of the present disclosure is not limited thereto. It should be noted that, when the operation of modifying the file is performed, the native directory entry corresponding to the file to be modified does not need to be modified, because the operation of modifying the file does not cause the directory entry to change.
Fig. 11 is a flowchart illustrating step S153 in fig. 8. As shown in fig. 11, in some examples, step S153 in fig. 8 may further include the following operations.
Step S1531: taking a numerical value interval formed by a second edition version number of a primary node entry corresponding to the file to be modified and the current global snapshot count as a second snapshot version number of the snapshot node entry, and taking file attribute information recorded in the primary node entry corresponding to the file to be modified as file attribute information of the snapshot node entry;
step S1532: and modifying the native node entry corresponding to the file to be modified based on the modification content, and taking the current system version number as a second editing version number of the native node entry so as to update the native node entry.
For example, in step S1531, since the native node entry exists from the time of creation to before modification, the value of the snapshot version corresponding to the native node entry is greater than the second editing version number and less than or equal to the current global snapshot count, and thus, a value interval (for example, a front-to-back closed interval) formed by the second editing version number and the current global snapshot count may be used as the second snapshot version number of the snapshot node entry. And taking the file attribute information recorded in the original node entry as the file attribute information of the snapshot node entry. Thus, a corresponding snapshot node entry is created. Even if the file to be modified is modified later, the information before modification is recorded in the snapshot node entry, so that the snapshot node entry can be used for subsequent snapshot access.
For example, in step S1532, after the corresponding snapshot node entry is created, the native node entry corresponding to the file to be modified is modified based on the modification content, and the current system version number is used as the second editing version number of the native node entry to indicate in which version the native node entry is modified, thereby implementing the update of the native node entry.
Fig. 12 is a schematic diagram of a metadata processing manner for a delete file operation and a modify file operation in a snapshot implementation method according to some embodiments of the present disclosure. For example, as shown in FIG. 12, in this example, it is necessary to delete dir2, file2 and modify dir3, file 3. The operation manner for deleting dir2 and file2 is similar to the example shown in fig. 10, and is not described here again. When dir3 and file3 need to be modified, the original node entries of dir3 and file3 need to be copied, corresponding snapshot node entries are created based on the copied contents, and then the original node entries of dir3 and file3 need to be modified to realize updating. At this time, since the directory entries corresponding to dir3 and file3 are not modified, the native directory entry entries of dir3 and file3 do not need to be modified.
Fig. 13 is a schematic diagram of performing snapshot access by using the snapshot implementation method provided in the embodiment of the present disclosure. For example, in this example, as shown in FIG. 13, the table in the upper left corner is a key-value-store-based metadata store table, each row of the table represents one directory entry, with snapshot identifier S being a snapshot directory entry, and without snapshot identifier S being a native directory entry. For example, in the table in the upper left corner of fig. 13, the row 3, row 6, row 10 behavior snapshot directory entry entries, and other behavior native directory entry entries. The first column of the table is the index node number of the parent directory, the second column of the table is the name of the object corresponding to the entry, and the first column and the second column are both information stored in the key field. The third column of the table is the starting point number of the first snapshot version number or the first edition version number, and when the entry is a snapshot directory entry, the starting point number of the first snapshot version number, that is, the snapshot starting version, and when the entry is a native directory entry, the first edition version number. The fourth column of the table is the number of endpoints of the first snapshot version number. The numerical range of the first snapshot version number can be determined using the number of start points and the number of end points. The fifth column of the table is the global snapshot count. The sixth column of the table is the index node number corresponding to the entry. Specific numerical values in the table at the upper left corner of fig. 13 are not listed any more, and the explanation for each row and each column of the table can be referred to above.
For example, by using the entries of the native directory entries, the organization information of the current file of the file system, that is, the tree structure of the current file, can be obtained. For example, as shown in FIG. 13, the tree structure of the current file includes folders fs0, dir1, dir1.2, dir2, and also includes files file1.a, file2.a, file 0. By using the native directory entry and the snapshot node entry in these entries, the organization information of the snapshot of version 1 (i.e., snapshot 1) can be obtained, for example, the organization information of snapshot 1 includes folder dir1.1 and file1.1. a. By using the native directory entry and the snapshot node entry in these entries, the organization information of the snapshot of version 2 (i.e., snapshot 2) can also be obtained, for example, the organization information of snapshot 2 includes folders dir1 and dir1.1, and also includes files file1.1.a and file 1.a. Thus, access to the current file and to the snapshot of either version can be achieved.
In the method provided by the embodiment of the present disclosure, the snapshot logic is abstractly described, and the directory entry information (entry) and the index node information (inode) are separated, so as to implement the snapshot (snap) protection logic. By recording snapshot configuration information and version information, the complexity of the snapshot can be simplified, and the implementation in a file system is facilitated. The snapshot metadata is uniformly described according to the original file system metadata interface, metadata related logic is simplified, logic relation constraint is not performed between snapshots, so that the quantity of the snapshots cannot influence the original file system, and snapshot logic is optimized. The snapshot directory entry and snapshot node entry may be constructed in a native file manner to enable access. Metadata associated with the snapshot and non-snapshot metadata may be stored in a unified manner, thereby simplifying the design of the file system with respect to metadata storage.
It should be noted that the snapshot implementation method provided by the embodiment of the present disclosure is not limited to the steps described above, and may also include further steps. The order of execution of the various steps is not limited, and although the various steps are described above in a particular order, this is not to be construed as a limitation on embodiments of the disclosure.
At least one embodiment of the present disclosure further provides a snapshot implementation apparatus for a file system, where the snapshot implementation apparatus abstractly describes snapshot logic, so that logical relationship constraint is not performed between snapshots, thereby simplifying snapshot complexity, simplifying metadata related logic, and facilitating implementation in the file system.
Fig. 14 is a schematic block diagram of a snapshot implementation apparatus for a file system according to some embodiments of the present disclosure. As shown in fig. 14, the snapshot realization apparatus 100 includes a first determination unit 110, a second determination unit 120, a third determination unit 130, and an access unit 140.
For example, the snapshot realization apparatus 100 is used for a file system whose metadata includes a plurality of directory entry entries and a plurality of node entries. The plurality of directory entry entries includes at least one native directory entry and at least one snapshot directory entry. The native directory entry records current organization information of the file system, and the native directory entry includes a first edit version number. The snapshot directory entry records organization information which does not exist in the file system at present and exists when the snapshot is generated, and the snapshot directory entry comprises a first snapshot version number. The plurality of node entries includes at least one native node entry and at least one snapshot node entry. The native node entry records the current file attribute information of the file system, and the native node entry comprises a second edition version number. The snapshot node entry records file attribute information which does not exist in the file system at present and exists when the snapshot is generated, and the snapshot node entry comprises a second snapshot version number.
For example, the first determining unit 110 is configured to select at least one directory entry among the plurality of directory entry entries as the target directory entry based on the target version number, the first edit version number included in the native directory entry, and the first snapshot version number included in the snapshot directory entry. For example, the target version number is a version number corresponding to the snapshot to be accessed. For example, the first determination unit 110 may perform step S11 of the snapshot implementation method as shown in fig. 3.
For example, the second determining unit 120 is configured to determine at least one node entry corresponding to each target directory entry. The second determining unit 120 may perform step S12 of the snapshot implementing method as shown in fig. 3.
For example, the third determining unit 130 is configured to select a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, the second edition version number included in the native node entry, and the second snapshot version number included in the snapshot node entry. The third determining unit 130 may perform step S13 of the snapshot implementing method as shown in fig. 3.
For example, the accessing unit 140 is configured to obtain a snapshot to be accessed based on the target directory entry and the target node entry. The metadata of the snapshot to be accessed includes a target directory entry and a target node entry. For example, the access unit 140 may perform step S14 of the snapshot implementation method as shown in fig. 3.
For example, the first determining unit 110, the second determining unit 120, the third determining unit 130 and the accessing unit 140 may be hardware, software, firmware and any feasible combination thereof. For example, the first determining unit 110, the second determining unit 120, the third determining unit 130 and the accessing unit 140 may be dedicated or general circuits, chips or devices, and may also be a combination of a processor and a memory. As to specific implementation forms of the first determining unit 110, the second determining unit 120, the third determining unit 130 and the accessing unit 140, embodiments of the present disclosure are not limited thereto.
It should be noted that, in the embodiment of the present disclosure, each unit of the snapshot implementing apparatus 100 corresponds to each step of the snapshot implementing method, and for the specific function of the snapshot implementing apparatus 100, reference may be made to the description related to the snapshot implementing method, and details are not described here again. The components and structure of the snapshot realization device 100 shown in fig. 14 are only exemplary and not limiting, and the snapshot realization device 100 may further include other components and structures as needed.
At least one embodiment of the present disclosure further provides an electronic device, which includes the snapshot implementation apparatus for a file system provided in any embodiment of the present disclosure. The electronic equipment abstractly describes the snapshot logic, so that logical relationship constraint is not performed between snapshots, the complexity of the snapshots is simplified, metadata related logic is simplified, and the implementation in a file system is easy.
Fig. 15 is a schematic block diagram of an electronic device provided in some embodiments of the present disclosure. As shown in fig. 15, the electronic device 200 includes a snapshot implementation apparatus 210, and the snapshot implementation apparatus 210 may be the snapshot implementation apparatus 100 shown in fig. 14. For example, the electronic device 200 may be a distributed NAS system or any other system that needs to implement a snapshot, and the embodiments of the present disclosure are not limited thereto. For the related description of the electronic device 200, reference may be made to the above description of the snapshot implementing apparatus 100, and details are not repeated here.
At least one embodiment of the present disclosure also provides an electronic device including a processor and a memory, one or more computer program modules being stored in the memory and configured to be executed by the processor, the one or more computer program modules including a snapshot implementation method for implementing a file system provided by any one of the embodiments of the present disclosure. The electronic equipment abstractly describes the snapshot logic, so that logical relationship constraint is not performed between snapshots, the complexity of the snapshots is simplified, metadata related logic is simplified, and the implementation in a file system is easy.
Fig. 16 is a schematic block diagram of another electronic device provided by some embodiments of the present disclosure. As shown in fig. 16, the electronic device 300 includes a processor 310 and a memory 320. Memory 320 is used to store non-transitory computer readable instructions (e.g., one or more computer program modules). The processor 310 is configured to execute non-transitory computer readable instructions, which when executed by the processor 310 may perform one or more of the steps of the snapshot implementation method for a file system described above. The memory 320 and the processor 310 may be interconnected by a bus system and/or other form of connection mechanism (not shown).
For example, the processor 310 may be a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a Digital Signal Processor (DSP) or other form of processing unit having data processing capabilities and/or program execution capabilities, such as a Field Programmable Gate Array (FPGA), or the like; for example, the Central Processing Unit (CPU) may be an X86 or ARM architecture or the like. The processor 310 may be a general-purpose processor or a special-purpose processor that may control other components in the electronic device 300 to perform desired functions.
For example, memory 320 may include any combination of one or more computer program products that may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. Volatile memory can include, for example, Random Access Memory (RAM), cache memory (or the like). The non-volatile memory may include, for example, Read Only Memory (ROM), a hard disk, an Erasable Programmable Read Only Memory (EPROM), a portable compact disc read only memory (CD-ROM), USB memory, flash memory, and the like. One or more computer program modules may be stored on the computer-readable storage medium and executed by processor 310 to implement various functions of electronic device 300. Various applications and various data, as well as various data used and/or generated by the applications, and the like, may also be stored in the computer-readable storage medium.
It should be noted that, in the embodiment of the present disclosure, reference may be made to the above description on the snapshot implementation method for the file system for specific functions and technical effects of the electronic device 300, and details are not described here again.
At least one embodiment of the present disclosure also provides a computer-readable storage medium for storing non-transitory computer-readable instructions, which when executed by a computer, implement a snapshot implementation method for a file system provided in any one embodiment of the present disclosure. By using the computer readable storage medium, abstract description can be carried out on snapshot logic, so that logical relationship constraint is not carried out between snapshots, the complexity of the snapshots is simplified, metadata related logic is simplified, and the implementation in a file system is easy.
Fig. 17 is a schematic diagram of a computer-readable storage medium according to some embodiments of the present disclosure. As shown in fig. 17, the computer-readable storage medium 400 is used to store non-transitory computer-readable instructions 410. The non-transitory computer readable instructions 410, when executed by a computer, are for performing one or more steps in a snapshot implementation method for a file system in accordance with the foregoing, for example.
For example, the computer-readable storage medium 400 may be applied to the electronic device described above. The computer-readable storage medium 400 may be, for example, the memory 320 in the electronic device 300 shown in fig. 16. For example, the related description of the computer-readable storage medium 400 can refer to the corresponding description of the memory 320 in the electronic device 300 shown in fig. 16, and will not be repeated here.
The following points need to be explained:
(1) the drawings of the embodiments of the disclosure only relate to the structures related to the embodiments of the disclosure, and other structures can refer to common designs.
(2) Without conflict, embodiments of the present disclosure and features of the embodiments may be combined with each other to arrive at new embodiments.
The above description is only a specific embodiment of the present disclosure, but the scope of the present disclosure is not limited thereto, and the scope of the present disclosure should be subject to the scope of the claims.

Claims (17)

1.A snapshot implementation method for a file system, wherein metadata of the file system comprises a plurality of directory entry entries and a plurality of node entries,
the plurality of directory entry entries include at least one native directory entry that documents current organization information of the file system, the native directory entry including a first edit version number, and at least one snapshot directory entry that documents organization information that does not currently exist in the file system, that exists at the time a snapshot is generated, the snapshot directory entry including a first snapshot version number,
the plurality of node entries includes at least one native node entry that documents current file attribute information of the file system, the native node entry includes a second edit version number, and at least one snapshot node entry that documents file attribute information that does not currently exist in the file system, that exists when a snapshot is generated, the snapshot node entry includes a second snapshot version number,
the method comprises the following steps:
selecting at least one directory entry from the plurality of directory entry entries as a target directory entry based on a target version number, a first editing version number contained in the native directory entry, and a first snapshot version number contained in the snapshot directory entry, wherein the target version number is a version number corresponding to a snapshot to be accessed;
determining at least one node entry corresponding to each target directory entry;
selecting a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, a second edition version number contained in the native node entry and a second snapshot version number contained in the snapshot node entry;
and obtaining the snapshot needing to be accessed based on the target directory entry and the target node entry, wherein the metadata of the snapshot needing to be accessed comprises the target directory entry and the target node entry.
2. The method of claim 1, wherein selecting at least one directory entry in the plurality of directory entry entries as the target directory entry based on the target version number, a first edit version number contained by the native directory entry, and a first snapshot version number contained by the snapshot directory entry comprises:
for a native directory entry of the plurality of directory entry entries, selecting a native directory entry having a first edit version number less than the target version number as the target directory entry;
for a snapshot directory entry of the plurality of directory entry entries, selecting a snapshot directory entry having a first snapshot version number that includes the target version number as the target directory entry.
3. The method of claim 1, wherein each of the plurality of directory entry entries and the plurality of node entries includes a node identification;
determining at least one node entry corresponding to each target directory entry, including:
for each target directory entry, selecting a node entry having the same node identification as the target directory entry from the plurality of node entries as at least one node entry corresponding to the target directory entry according to the node identification in the target directory entry.
4. The method of claim 1, wherein selecting the target node entry from the at least one node entry corresponding to each target directory entry based on the target version number, the second edit version number included in the native node entry, and the second snapshot version number included in the snapshot node entry comprises:
for a native node entry in the node entries corresponding to each target directory entry, selecting a native node entry having a second edit version number smaller than the target version number as the target node entry;
for snapshot node entries in the node entries corresponding to each target directory entry, selecting a snapshot node entry whose second snapshot version number contains the target version number as the target node entry.
5. The method of claim 2 or 4, wherein the first snapshot version number and the second snapshot version number are each recorded in a numerical interval, the numerical interval including a start point number and an end point number, the start point number being less than or equal to the end point number.
6. The method of claim 5, wherein the value interval is a half-open and half-closed interval, the starting point number does not belong to the value interval, and the end point number belongs to the value interval.
7. The method according to any one of claims 1-4, further comprising:
processing the plurality of directory entry entries and the plurality of node entries.
8. The method of claim 7, wherein processing the plurality of directory entry entries and the plurality of node entries comprises:
for the operation of a newly-built file, a native directory entry and a native node entry corresponding to the newly-built file are created, and the current system version number is used as a first editing version number of the native directory entry and a second editing version number of the native node entry;
for the operation of deleting the file, copying a native directory entry and a native node entry corresponding to the file to be deleted, creating a snapshot directory entry and a snapshot node entry corresponding to the file to be deleted based on the copied content, and deleting the native directory entry and the native node entry corresponding to the file to be deleted;
for the operation of modifying the file, copying a native node entry corresponding to the file to be modified, creating a snapshot node entry corresponding to the file to be modified based on copied content, and updating the native node entry corresponding to the file to be modified based on modified content.
9. The method of claim 8, wherein the metadata of the file system further comprises a global snapshot count that is incremented each time a snapshot creation operation is performed to implement the count.
10. The method according to claim 9, wherein for the delete file operation, copying a native directory entry and a native node entry corresponding to the file to be deleted, and creating a snapshot directory entry and a snapshot node entry corresponding to the file to be deleted based on copied contents comprises:
taking a numerical value interval formed by a first edition version number of the native directory entry and the current global snapshot count as a first snapshot version number of the snapshot directory entry, and taking organization information recorded in the native directory entry as organization information of the snapshot directory entry;
and taking a numerical value interval formed by the second edition version number of the native node entry and the current global snapshot count as the second snapshot version number of the snapshot node entry, and taking the file attribute information recorded in the native node entry as the file attribute information of the snapshot node entry.
11. The method of claim 9, wherein for the modify file operation, copying a native node entry corresponding to the file to be modified, creating a snapshot node entry corresponding to the file to be modified based on copied contents, and updating the native node entry corresponding to the file to be modified based on the modified contents, comprises:
taking a numerical value interval formed by a second edition version number of a native node entry corresponding to the file to be modified and the current global snapshot count as a second snapshot version number of the snapshot node entry, and taking file attribute information recorded in the native node entry corresponding to the file to be modified as file attribute information of the snapshot node entry;
and modifying the native node entry corresponding to the file to be modified based on the modification content, and taking the current system version number as a second editing version number of the native node entry so as to update the native node entry.
12. The method of any of claims 1-4, wherein the plurality of directory entry entries and the plurality of node entries are stored using key-value storage.
13. The method of any of claims 1-4, wherein a snapshot identifier is used to distinguish a native directory entry from a snapshot directory entry in the plurality of directory entry, wherein the snapshot directory entry comprises the snapshot identifier, and wherein the snapshot identifier is not present in the native directory entry;
for the plurality of node entries, distinguishing a native node entry and a snapshot node entry of the plurality of node entries using the snapshot identifier, the snapshot node entry including the snapshot identifier, the snapshot identifier not present in the native node entry.
14. A snapshot enabling apparatus for a file system, wherein metadata of the file system includes a plurality of directory entry entries and a plurality of node entries,
the plurality of directory entry entries include at least one native directory entry that documents current organization information of the file system, the native directory entry including a first edit version number, and at least one snapshot directory entry that documents organization information that does not currently exist in the file system, that exists at the time a snapshot is generated, the snapshot directory entry including a first snapshot version number,
the plurality of node entries includes at least one native node entry that documents current file attribute information of the file system, the native node entry includes a second edit version number, and at least one snapshot node entry that documents file attribute information that does not currently exist in the file system, that exists when a snapshot is generated, the snapshot node entry includes a second snapshot version number,
the device comprises:
a first determining unit, configured to select at least one directory entry from the plurality of directory entry entries as a target directory entry based on a target version number, a first editing version number included in the native directory entry, and a first snapshot version number included in the snapshot directory entry, where the target version number is a version number corresponding to a snapshot to be accessed;
a second determining unit configured to determine at least one node entry corresponding to each target directory entry;
a third determining unit, configured to select a target node entry from at least one node entry corresponding to each target directory entry based on the target version number, a second editing version number included in the native node entry, and a second snapshot version number included in the snapshot node entry;
and the accessing unit is configured to obtain the snapshot needing to be accessed based on the target directory entry and the target node entry, wherein metadata of the snapshot needing to be accessed comprises the target directory entry and the target node entry.
15. An electronic device, characterized in that it comprises snapshot enabling means for a file system as claimed in claim 14.
16. An electronic device, characterized in that the electronic device comprises:
a processor;
a memory including one or more computer program modules;
wherein the one or more computer program modules are stored in the memory and configured to be executed by the processor, the one or more computer program modules comprising instructions for implementing the snapshot implementation method for the file system of any of claims 1-13.
17. A computer-readable storage medium storing non-transitory computer-readable instructions for implementing the snapshot implementation method for a file system of any one of claims 1-13 when executed by a computer.
CN202110867353.1A 2021-07-30 2021-07-30 Snapshot implementation method and device, electronic equipment and computer readable storage medium Active CN113342741B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110867353.1A CN113342741B (en) 2021-07-30 2021-07-30 Snapshot implementation method and device, electronic equipment and computer readable storage medium
PCT/CN2022/105946 WO2023005688A1 (en) 2021-07-30 2022-07-15 Snapshot implementation method and apparatus, electronic device, and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110867353.1A CN113342741B (en) 2021-07-30 2021-07-30 Snapshot implementation method and device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN113342741A CN113342741A (en) 2021-09-03
CN113342741B true CN113342741B (en) 2021-10-12

Family

ID=77480472

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110867353.1A Active CN113342741B (en) 2021-07-30 2021-07-30 Snapshot implementation method and device, electronic equipment and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN113342741B (en)
WO (1) WO2023005688A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342741B (en) * 2021-07-30 2021-10-12 联想凌拓科技有限公司 Snapshot implementation method and device, electronic equipment and computer readable storage medium
CN115185891B (en) * 2022-09-14 2023-01-17 联想凌拓科技有限公司 Data management method and device of file system, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101140536A (en) * 2007-05-21 2008-03-12 中兴通讯股份有限公司 Snapshot system supporting cascades snapshot and snapshot processing method thereof
CN101162469A (en) * 2007-11-09 2008-04-16 清华大学 Fine grit document and catalogs version management method based on snapshot
CN102722536A (en) * 2012-05-22 2012-10-10 中兴通讯股份有限公司 Method and device for realizing snapshot based on distributed file system
CN103577329A (en) * 2013-10-18 2014-02-12 华为技术有限公司 Snapshot management method and device
CN104933133A (en) * 2015-06-12 2015-09-23 中国科学院计算技术研究所 Metadata snap storage and access method in distributed file system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4439960B2 (en) * 2004-03-22 2010-03-24 株式会社日立製作所 Storage device
US9886349B2 (en) * 2015-09-21 2018-02-06 International Business Machines Corporation Point-in-time copy on write for golden image
US11119978B2 (en) * 2016-06-08 2021-09-14 Red Hat Israel, Ltd. Snapshot version control
US11204892B2 (en) * 2019-03-21 2021-12-21 Microsoft Technology Licensing, Llc Techniques for snapshotting scalable multitier storage structures
CN113342741B (en) * 2021-07-30 2021-10-12 联想凌拓科技有限公司 Snapshot implementation method and device, electronic equipment and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101140536A (en) * 2007-05-21 2008-03-12 中兴通讯股份有限公司 Snapshot system supporting cascades snapshot and snapshot processing method thereof
CN101162469A (en) * 2007-11-09 2008-04-16 清华大学 Fine grit document and catalogs version management method based on snapshot
CN102722536A (en) * 2012-05-22 2012-10-10 中兴通讯股份有限公司 Method and device for realizing snapshot based on distributed file system
CN103577329A (en) * 2013-10-18 2014-02-12 华为技术有限公司 Snapshot management method and device
CN104933133A (en) * 2015-06-12 2015-09-23 中国科学院计算技术研究所 Metadata snap storage and access method in distributed file system

Also Published As

Publication number Publication date
WO2023005688A1 (en) 2023-02-02
CN113342741A (en) 2021-09-03

Similar Documents

Publication Publication Date Title
CN104714755B (en) Snapshot management method and device
US10936547B2 (en) Filesystem replication using a minimal filesystem metadata changelog
US8250033B1 (en) Replication of a data set using differential snapshots
US9946716B2 (en) Distributed file system snapshot
US7680836B2 (en) Systems and methods for a snapshot of data
US7680842B2 (en) Systems and methods for a snapshot of data
JP5247202B2 (en) Read / write implementation on top of backup data, multi-version control file system
US7882071B2 (en) Systems and methods for a snapshot of data
JP6430499B2 (en) POSIX-compatible file system, method for generating file list, and storage device
US8131691B1 (en) System and method for updating a search engine index based on which files are identified in a file change log
US10303363B2 (en) System and method for data storage using log-structured merge trees
US8874517B2 (en) Summarizing file system operations with a file system journal
EP2154617A1 (en) Data management method
US20120084272A1 (en) File system support for inert files
WO2023005688A1 (en) Snapshot implementation method and apparatus, electronic device, and computer readable storage medium
CN115185891B (en) Data management method and device of file system, electronic equipment and storage medium
US20120030439A1 (en) Data Sharing for File Clones Using Reverse Ditto References
US20090254585A1 (en) Method for Associating Administrative Policies with User-Definable Groups of Files
US20070156778A1 (en) File indexer
WO2021129151A1 (en) File backup method and apparatus, and terminal device
CN112800019A (en) Data backup method and system based on Hadoop distributed file system
CN113448946A (en) Data migration method and device and electronic equipment
CN114356849B (en) Data management method and device of file system, electronic equipment and storage medium
WO2008021528A2 (en) Systems and methods for a snapshot of data
AU2019245775B2 (en) Multiprotocol data migration

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40061779

Country of ref document: HK