CN103729265B - A kind of guard method storing data and device - Google Patents
A kind of guard method storing data and device Download PDFInfo
- Publication number
- CN103729265B CN103729265B CN201310744238.0A CN201310744238A CN103729265B CN 103729265 B CN103729265 B CN 103729265B CN 201310744238 A CN201310744238 A CN 201310744238A CN 103729265 B CN103729265 B CN 103729265B
- Authority
- CN
- China
- Prior art keywords
- snapshot
- file
- read
- materialized view
- level attribute
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/11—File system administration, e.g. details of archiving or snapshots
- G06F16/128—Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Storage Device Security (AREA)
Abstract
本发明公开了一种存储数据的保护方法及装置,属于网络连接存储领域。所述方法包括:接收属性设置指令,所述属性设置指令请求设置文件系统中文件的文件快照级别属性;根据所述属性设置指令设置所述文件的文件快照级别属性;接收快照创建指令,所述快照创建指令中携带需要保护的文件的文件快照级别属性参数;根据所述快照创建指令为所述文件系统创建采用写时重定向ROW技术的ROW只读快照,所述ROW只读快照的只读快照级别属性根据所述文件快照级别属性参数设置。本发明对该文件快照级别属性进行设置,并在对系统文件创建只读快照时指定该只读快照需要保护的文件的快照级别,根据应用场景决定该为文件系统的哪些文件创建快照,控制快照的使用空间,降低只读快照占用的文件系统的空间。
The invention discloses a method and device for protecting stored data, belonging to the field of network connection storage. The method includes: receiving an attribute setting instruction, the attribute setting instruction requests to set the file snapshot level attribute of the file in the file system; setting the file snapshot level attribute of the file according to the attribute setting instruction; receiving the snapshot creation instruction, the The file snapshot level attribute parameter of the file to be protected is carried in the snapshot creation instruction; according to the snapshot creation instruction, a ROW read-only snapshot using redirection-on-write ROW technology is created for the file system, and the read-only snapshot of the ROW read-only snapshot is The snapshot level attribute is set according to the file snapshot level attribute parameter. The present invention sets the snapshot level attribute of the file, and specifies the snapshot level of the file to be protected by the read-only snapshot when creating a read-only snapshot for the system file, and decides which files in the file system to create snapshots for according to the application scenario, and controls the snapshot reduce the space used by read-only snapshots in the file system.
Description
技术领域technical field
本发明涉及网络连接存储领域,特别涉及一种存储数据的保护方法及装置。The invention relates to the field of network connection storage, in particular to a method and device for protecting stored data.
背景技术Background technique
在NAS(Network Attached Storage,网络连接存储)领域,对FS(File System,文件系统)整体创建采用ROW(Redirect-on-write,写时重定向)技术的ROW只读快照是实现存储数据保护的主流技术。FS的ROW只读快照直接保护FS的写前数据块,即ROW只读快照将占用分配给FS的可用空间。目前对FS创建ROW只读快照的技术都是针对FS整体,当对FS频繁修改后,ROW只读快照会占据FS大量空间。例如一个总可用空间为100MB的FS,写入一个17.94MB的文件1,创建一个ROW只读快照,然后覆盖写入前面的文件1,如此反复4次,ROW只读快照累积独占空间将达到53.89MB,而原FS的可用空间降到28.1MB。当再向该FS写入一个37MB的文件时,就会出现FS空间不足、不能写入的错误。因此需要一种存储数据的保护方法,以解决ROW只读快照占用源文件系统过多空间的缺陷。In the field of NAS (Network Attached Storage, network-attached storage), creating ROW read-only snapshots using ROW (Redirect-on-write) technology for FS (File System, file system) as a whole is the key to realize storage data protection. mainstream technology. The ROW read-only snapshot of FS directly protects the pre-write data blocks of FS, that is, the ROW read-only snapshot will occupy the available space allocated to FS. At present, the technology of creating ROW read-only snapshots for FS is aimed at the whole FS. When the FS is frequently modified, the ROW read-only snapshots will occupy a large amount of space in the FS. For example, in an FS with a total available space of 100MB, write a 17.94MB file 1, create a ROW read-only snapshot, and then overwrite and write the previous file 1, repeat this 4 times, the accumulated exclusive space of the ROW read-only snapshot will reach 53.89 MB, while the available space of the original FS drops to 28.1MB. When writing a 37MB file to the FS again, there will be an error that the FS space is insufficient and cannot be written. Therefore, a method for protecting stored data is needed to solve the defect that the ROW read-only snapshot occupies too much space in the source file system.
现有技术提出了几种降低只读快照占用空间的存储数据的保护方法:方法一、配置FS ROW只读快照预留,但ROW只读快照空间可超这个预留;方法二、配置FS自动扩容;方法三、配置FS自动删除ROW只读快照。The existing technology proposes several protection methods for storing data that reduce the space occupied by read-only snapshots: method 1, configure FS ROW read-only snapshot reservation, but the ROW read-only snapshot space can exceed this reservation; method 2, configure FS automatic Capacity expansion; Method 3: Configure FS to automatically delete ROW read-only snapshots.
现有技术至少存在以下问题:There are at least the following problems in the prior art:
ROW只读快照占用大量FS可用空间,导致FS不可用,直接影响位于关键路径的FS的重要业务;针对上述问题的措施,不能从根本上解决ROW只读快照大量占用FS可用空间的问题。ROW read-only snapshots occupy a large amount of FS available space, resulting in FS unavailability, directly affecting the important business of FS on the critical path; measures for the above problems cannot fundamentally solve the problem of ROW read-only snapshots occupying a large amount of FS available space.
发明内容Contents of the invention
本发明提供了一种存储数据的保护方法及装置,技术方案如下。The invention provides a method and device for protecting stored data, and the technical solution is as follows.
第一方面,提供了存储数据的保护方法,所述方法包括:接收属性设置指令,所述属性设置指令请求设置文件系统中文件的文件快照级别属性;根据所述属性设置指令设置所述文件的文件快照级别属性;接收快照创建指令,所述快照创建指令中携带需要保护的文件的文件快照级别属性参数;根据所述快照创建指令为所述文件系统创建ROW只读快照,所述ROW只读快照的只读快照级别属性根据所述文件快照级别属性参数设置;在对指定文件进行修改时,判断所述指定文件的文件快照级别属性与已创建的ROW只读快照的只读快照级别属性是否匹配,并在匹配时根据所述已创建的ROW只读快照对所述指定文件进行写前保护。In a first aspect, a method for protecting stored data is provided, the method comprising: receiving an attribute setting instruction, the attribute setting instruction requesting setting of a file snapshot level attribute of a file in a file system; setting the file's snapshot level attribute according to the attribute setting instruction File snapshot level attribute; receive a snapshot creation instruction, the snapshot creation instruction carries the file snapshot level attribute parameter of the file to be protected; create a ROW read-only snapshot for the file system according to the snapshot creation instruction, and the ROW read-only The read-only snapshot level attribute of the snapshot is set according to the file snapshot level attribute parameter; match, and when matching, perform pre-write protection on the specified file according to the created ROW read-only snapshot.
结合第一方面,在第一方面的第一种可能的实现方式中,根据所述快照创建指令为所述文件系统创建只读快照,包括:通过与所述文件系统共享根的方式创建所述ROW只读快照;根据所述文件快照级别属性设置所述ROW只读快照的只读快照级别属性;根据所述只读快照级别属性设置所述文件系统的系统快照级别属性。With reference to the first aspect, in a first possible implementation manner of the first aspect, creating a read-only snapshot for the file system according to the snapshot creation instruction includes: creating the ROW read-only snapshot; set the read-only snapshot level attribute of the ROW read-only snapshot according to the file snapshot level attribute; set the system snapshot level attribute of the file system according to the read-only snapshot level attribute.
结合第一方面或第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述系统快照级别属性包括快照级别-逻辑时间点对的集合,其中所述快照级别表示所述ROW只读快照保护的文件的快照级别,所述逻辑时间点表示创建所述ROW只读快照的逻辑时间点;所述只读快照级别属性包括快照级别-逻辑时间点对的集合,其中所述快照级别表示需要保护的文件的快照级别,所述逻辑时间点表示创建所述ROW只读快照的逻辑时间点。With reference to the first aspect or the first possible implementation of the first aspect, in the second possible implementation of the first aspect, the system snapshot level attribute includes a set of snapshot level-logical time point pairs, where the The snapshot level represents the snapshot level of the file protected by the ROW read-only snapshot, and the logical time point represents the logical time point at which the ROW read-only snapshot is created; the read-only snapshot level attribute includes a snapshot level-logical time point pair , wherein the snapshot level represents the snapshot level of the file to be protected, and the logical time point represents the logical time point for creating the ROW read-only snapshot.
结合第一方面,在第一方面的第三种可能的实现方式中,所述快照创建指令还携带快照名称;所述根据所述快照创建指令为所述文件系统创建只读快照之后,还包括:根据所述快照名称命名所述ROW只读快照。With reference to the first aspect, in a third possible implementation manner of the first aspect, the snapshot creation instruction also carries a snapshot name; after creating a read-only snapshot for the file system according to the snapshot creation instruction, further includes : Name the ROW read-only snapshot according to the snapshot name.
结合第一方面的第二种可能的实现方式,在第一方面的第四种可能的实现方式中,所述根据所述快照创建指令为所述文件系统创建只读快照之后,还包括:接收访问所述ROW只读快照的请求;输出文件快照级别属性的值与所述ROW只读快照的只读快照级别属性的快照级别的值相等的文件。With reference to the second possible implementation of the first aspect, in a fourth possible implementation of the first aspect, after creating a read-only snapshot for the file system according to the snapshot creation instruction, further includes: receiving A request to access the ROW read-only snapshot; output a file whose snapshot level attribute value is equal to the snapshot level value of the read-only snapshot level attribute of the ROW read-only snapshot.
结合第一方面的第二种可能的实现方式,在第一方面的第五种可能的实现方式中,所述在对指定文件进行修改时,判断所述指定文件的文件快照级别属性与已创建的ROW只读快照的只读快照级别属性是否匹配,并在匹配时根据所述已创建的ROW只读快照对所述指定文件进行写前保护,包括:接收所述指定文件的修改数据;根据所述修改数据修改所述指定文件的数据,并将修改后的所述指定文件的新数据保存到新的磁盘位置;判断已创建的所述文件系统的只读快照中,是否存在只读快照级别属性的快照级别的值与所述指定文件的文件快照级别属性的值相等的只读快照;若存在,保留所述指定文件修改前的旧数据,并将所述ROW只读快照的根指向所述指定文件的旧数据;否则,删除所述指定文件修改前的旧数据。With reference to the second possible implementation of the first aspect, in the fifth possible implementation of the first aspect, when the specified file is modified, it is determined whether the file snapshot level attribute of the specified file is consistent with the created Whether the read-only snapshot level attribute of the ROW read-only snapshot matches, and when matching, carry out pre-write protection to the specified file according to the created ROW read-only snapshot, including: receiving the modification data of the specified file; The modification data modifies the data of the specified file, and saves the new data of the specified file after modification to a new disk location; judging whether there is a read-only snapshot in the created read-only snapshot of the file system A read-only snapshot in which the value of the snapshot level of the level attribute is equal to the value of the file snapshot level attribute of the specified file; if it exists, keep the old data of the specified file before modification, and point the root of the ROW read-only snapshot to The old data of the specified file; otherwise, delete the old data of the specified file before modification.
第二方面,提供了一种存储数据的保护装置,所述装置包括:接收单元,用于接收属性设置指令,所述属性设置指令请求设置文件系统中文件的文件快照级别属性,,以及用于接收快照创建指令,所述快照创建指令中携带需要保护的文件的文件快照级别属性参数;设置单元,用于根据所述接收单元接收的属性设置指令设置所述文件的文件快照级别属性;快照创建单元,用于根据所述接收单元接收的快照创建指令为所述文件系统创建只读快照,根据所述文件快照级别属性参数设置所述ROW只读快照的只读快照级别属性;文件保护单元,用于在对指定文件进行修改时,判断所述指定文件的文件快照级别属性与已创建的ROW只读快照的只读快照级别属性是否匹配,并在匹配时根据所述已创建的ROW只读快照对所述指定文件进行写前保护。In a second aspect, a device for protecting stored data is provided, the device comprising: a receiving unit, configured to receive an attribute setting instruction, the attribute setting instruction requesting setting of a file snapshot level attribute of a file in the file system, and for Receiving a snapshot creation instruction, the snapshot creation instruction carries a file snapshot level attribute parameter of the file to be protected; a setting unit is used to set the file snapshot level attribute of the file according to the attribute setting instruction received by the receiving unit; snapshot creation A unit, configured to create a read-only snapshot for the file system according to the snapshot creation instruction received by the receiving unit, and set the read-only snapshot level attribute of the ROW read-only snapshot according to the file snapshot level attribute parameter; the file protection unit, It is used to determine whether the file snapshot level attribute of the specified file matches the read-only snapshot level attribute of the created ROW read-only snapshot when modifying the specified file, and when matching, according to the created ROW read-only The snapshot protects the specified file before writing.
结合第二方面,在第二方面的第一种可能的实现方式中,所述快照创建单元包括:创建模块,用于通过与所述文件系统共享根的方式创建所述ROW只读快照;设置模块,用于在所述创建模块创建所述ROW只读快照之后,根据所述文件快照级别属性设置所述ROW只读快照的只读快照级别属性,以及根据所述只读快照级别属性设置所述文件系统的系统快照级别属性。With reference to the second aspect, in a first possible implementation manner of the second aspect, the snapshot creation unit includes: a creation module configured to create the ROW read-only snapshot by sharing the root with the file system; A module configured to set the read-only snapshot level attribute of the ROW read-only snapshot according to the file snapshot level attribute after the creation module creates the ROW read-only snapshot, and set the read-only snapshot level attribute according to the read-only snapshot level attribute System snapshot level attributes for the file system described above.
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述记录模块,还用于将所述系统快照级别属性记录为包括快照级别-逻辑时间点对的集合,其中所述快照级别表示所述ROW只读快照保护的文件的快照级别,所述逻辑时间点表示创建所述ROW只读快照的逻辑时间点;将所述只读快照级别属性记录为包括快照级别-逻辑时间点对的集合,其中所述快照级别表示需要保护的文件的快照级别,所述逻辑时间点表示创建所述ROW只读快照的逻辑时间点。With reference to the first possible implementation of the second aspect, in a second possible implementation of the second aspect, the recording module is further configured to record the system snapshot level attribute as including snapshot level-logical time A collection of point pairs, wherein the snapshot level represents the snapshot level of the file protected by the ROW read-only snapshot, and the logical time point represents the logical time point for creating the ROW read-only snapshot; the read-only snapshot level attribute Recorded as a set including snapshot level-logical time point pairs, wherein the snapshot level indicates the snapshot level of the file to be protected, and the logical time point indicates the logical time point for creating the ROW read-only snapshot.
结合第二方面,在第二方面的第三种可能的实现方式中,所述接收单元,还用于接收携带快照名称的快照创建指令;所述创建模块,还用于根据所述接收单元接收的快照创建指令中携带的快照名称命名所述ROW只读快照。With reference to the second aspect, in a third possible implementation manner of the second aspect, the receiving unit is further configured to receive a snapshot creation instruction carrying a snapshot name; The snapshot name carried in the snapshot creation command names the ROW read-only snapshot.
结合第二方面的第二种可能的实现方式,在第二方面的第四种可能的实现方式中,所述接收单元,还用于在所述快照创建单元创建所述ROW只读快照之后,接收所述用户访问所述ROW只读快照的请求;所述装置还包括:输出单元,用于根据所述接收单元接收的请求输出文件快照级别属性的值与所述ROW只读快照的只读快照级别属性中的快照级别的值相等的文件。With reference to the second possible implementation manner of the second aspect, in a fourth possible implementation manner of the second aspect, the receiving unit is further configured to, after the snapshot creating unit creates the ROW read-only snapshot, Receive the request from the user to access the ROW read-only snapshot; the device also includes: an output unit, configured to output the value of the file snapshot level attribute and the read-only value of the ROW read-only snapshot according to the request received by the receiving unit Files whose snapshot-level values in the snapshot-level attribute are equal.
结合第二方面、第二方面的第一种、第二种、第三种或第四种可能的实现方式,在第二方面第五种可能的实现方式中,所述接收单元,还用于接收所述文件系统中指定文件的修改数据;所述装置还包括:修改模块,用于根据所述接收单元接收的修改数据修改所述指定文件的数据,并将修改后的所述指定文件的新数据保存到新的磁盘位置;判断模块,用于在所述修改模块将修改后的所述指定文件的新数据保存到新的磁盘位置之后,判断已创建的所述文件系统的只读快照中,是否存在只读快照级别属性的快照级别的值与所述指定文件的文件快照级别属性的值相等的只读快照;根模块,用于在所述判断模块判断存只读快照级别属性与所述指定文件的文件快照级别属性相匹配的ROW只读快照时,将所述ROW只读快照的根指向所述指定文件的旧数据;删除模块,用于在所述判断模块判断不存只读快照级别属性与所述指定文件的文件快照级别属性相匹配的只读快照时,删除所述指定文件修改前的旧数据。With reference to the second aspect, the first, the second, the third or the fourth possible implementation manner of the second aspect, in a fifth possible implementation manner of the second aspect, the receiving unit is further configured to receiving modification data of a designated file in the file system; the device further includes: a modification module, configured to modify data of the designated file according to the modification data received by the receiving unit, and modify the modified data of the designated file The new data is saved to a new disk location; the judging module is used to judge the created read-only snapshot of the file system after the modification module saves the modified new data of the specified file to the new disk location Among them, whether there is a read-only snapshot whose value of the snapshot level attribute of the read-only snapshot level attribute is equal to the value of the file snapshot level attribute of the specified file; the root module is used to determine whether the judgment module stores the read-only snapshot level attribute and When the file snapshot level attribute of the specified file matches the ROW read-only snapshot, the root of the ROW read-only snapshot points to the old data of the specified file; the deletion module is used to judge whether there is only When reading a read-only snapshot whose snapshot level attribute matches the file snapshot level attribute of the specified file, delete the old data of the specified file before modification.
本发明实施例提供的技术方案可以通过增加文件的文件快照级别属性,对该文件快照级别属性进行设置,可以将不同的文件设置成不同的快照级别,同时在对系统文件创建ROW只读快照时指定该ROW只读快照需要保护的文件的快照级别,让ROW只读快照只保护那些需要保护的重要文件,能够有效降低ROW只读快照对FS空间的占用。The technical solution provided by the embodiment of the present invention can set the file snapshot level attribute by increasing the file snapshot level attribute of the file, different files can be set to different snapshot levels, and at the same time when creating a ROW read-only snapshot for the system file Specify the snapshot level of the files to be protected by the ROW read-only snapshot, and let the ROW read-only snapshot only protect those important files that need to be protected, which can effectively reduce the FS space occupied by the ROW read-only snapshot.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings that need to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. Additional drawings can also be derived from these drawings.
图1是本发明实施例一提供的存储数据的保护方法流程图;FIG. 1 is a flowchart of a method for protecting stored data provided by Embodiment 1 of the present invention;
图2是本发明实施例二提供的存储数据的保护方法流程图;FIG. 2 is a flowchart of a method for protecting stored data provided by Embodiment 2 of the present invention;
图3是本发明实施例二的fs1的文件的快照级别属性示意图;FIG. 3 is a schematic diagram of snapshot level attributes of files of fs1 in Embodiment 2 of the present invention;
图4是本发明实施例二为fs1创建指定快照级别的ROW只读快照示意图;FIG. 4 is a schematic diagram of creating a ROW read-only snapshot of a specified snapshot level for fs1 in Embodiment 2 of the present invention;
图5是本发明实施例二中修改不被快照保护的file1的示意图;FIG. 5 is a schematic diagram of modifying file1 not protected by snapshots in Embodiment 2 of the present invention;
图6是本发明实施例二中修改被快照保护的file2的示意图;FIG. 6 is a schematic diagram of modifying file2 protected by snapshots in Embodiment 2 of the present invention;
图7是本发明实施例三提供的存储数据的保护方法流程图;FIG. 7 is a flowchart of a method for protecting stored data provided by Embodiment 3 of the present invention;
图8是本发明实施例三中创建多个只读快照的示意图;FIG. 8 is a schematic diagram of creating multiple read-only snapshots in Embodiment 3 of the present invention;
图9是本发明实施例四提供的一种存储数据的保护装置的结构示意图;FIG. 9 is a schematic structural diagram of a protection device for storing data provided by Embodiment 4 of the present invention;
图10是本发明实施例五提供的一种存储数据的保护装置的结构示意图。FIG. 10 is a schematic structural diagram of a protection device for storing data provided by Embodiment 5 of the present invention.
具体实施方式detailed description
本发明的发明人在降低只读快照占用FS过多空间的研究过程中发现,在FS中并不是所有文件都值得用其只读快照保护起来,因此如果控制FS的只读快照选择性的保护FS中的重要文件,便可以解决只读快照大量占用FS可用空间的问题,进而让位于关键路径的FS业务尽量可用。The inventor of the present invention found in the research process of reducing the excessive space occupied by read-only snapshots in the FS that not all files in the FS are worth protecting with their read-only snapshots, so if the selective protection of the read-only snapshots of the FS is controlled Important files in FS can solve the problem that read-only snapshots occupy a large amount of FS free space, and then make FS services on the critical path as available as possible.
为了实现对只读快照的保护对象进行控制,本发明对FS的所有文件(包括目录)增加一个属性:文件快照级别属性,该属性也可以由用户设置;为创建FS只读快照的指令增加一个选项:文件快照级别属性参数,创建的这个FS只读快照将只保护FS中设置了与该文件快照级别属性参数匹配的文件快照级别属性的文件,即该文件快照级别属性的值与该文件快照级别属性参数的值相同;为FS新增系统快照级别属性;为只读快照新增只读快照级别属性。In order to control the protection object of the read-only snapshot, the present invention adds an attribute to all files (including directories) of the FS: a file snapshot level attribute, which can also be set by the user; an instruction for creating a FS read-only snapshot is added Option: file snapshot level attribute parameter, the FS read-only snapshot created will only protect the files in FS that have the file snapshot level attribute matching the file snapshot level attribute parameter, that is, the value of the file snapshot level attribute is the same as that of the file snapshot The values of the level attribute parameters are the same; add a system snapshot level attribute for FS; add a read-only snapshot level attribute for read-only snapshots.
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。In order to make the object, technical solution and advantages of the present invention clearer, the implementation manner of the present invention will be further described in detail below in conjunction with the accompanying drawings.
实施例一Embodiment one
本实施例提供一种存储数据的保护方法,请参阅图1,方法流程包括:This embodiment provides a method for protecting stored data, please refer to Figure 1, the method flow includes:
101、接收属性设置指令,所述属性设置指令请求设置文件系统中文件的文件快照级别属性;101. Receive an attribute setting instruction, where the attribute setting instruction requests to set a file snapshot level attribute of a file in the file system;
102、根据所述属性设置指令设置所述文件的文件快照级别属性;102. Set the file snapshot level attribute of the file according to the attribute setting instruction;
103、接收快照创建指令,所述快照创建指令中携带需要保护的文件的文件快照级别属性参数;103. Receive a snapshot creation instruction, where the snapshot creation instruction carries a file snapshot level attribute parameter of the file to be protected;
104、根据所述快照创建指令为所述文件系统创建只读快照,所述ROW只读快照的只读快照级别属性根据所述文件快照级别属性参数设置;104. Create a read-only snapshot for the file system according to the snapshot creation instruction, and the read-only snapshot level attribute of the ROW read-only snapshot is set according to the file snapshot level attribute parameter;
105、在对指定文件进行修改时,判断所述指定文件的文件快照级别属性与已创建的ROW只读快照的只读快照级别属性是否匹配,并在匹配时根据所述已创建的ROW只读快照对所述指定文件进行写前保护。105. When modifying the specified file, judge whether the file snapshot level attribute of the specified file matches the read-only snapshot level attribute of the created ROW read-only snapshot, and when matching, according to the created ROW read-only The snapshot protects the specified file before writing.
具体的,所述的写前保护是指对所述指定文件修改前的数据进行映像或保留。Specifically, the pre-write protection refers to mapping or preserving the data of the specified file before modification.
进一步的,所述根据所述快照创建指令为所述文件系统创建只读快照,包括:Further, the creating a read-only snapshot for the file system according to the snapshot creation instruction includes:
通过与所述文件系统共享根的方式创建所述ROW只读快照;Create the ROW read-only snapshot by sharing the root with the file system;
根据所述文件快照级别属性设置所述ROW只读快照的只读快照级别属性;Set the read-only snapshot level attribute of the ROW read-only snapshot according to the file snapshot level attribute;
根据所述只读快照级别属性设置所述文件系统的系统快照级别属性。Setting the system snapshot level attribute of the file system according to the read-only snapshot level attribute.
具体的,文件系统或只读快照的根是一个磁盘地址,通过这个地址,可以访问到文件系统或ROW只读快照的所有目录、文件数据;由于文件系统或只读快照的目录、文件都被抽象成一个个的Objects(对象),所有这些Objects组成文件系统或只读快照的Objset(对象集),Objset以树的形式组织,树有一个ObjsetRoot(树根)地址,通过这个Objset Root可以访问到文件系统/只读快照的所有Objects,所以文件系统或只读快照根又叫Objset Root。Specifically, the root of a file system or read-only snapshot is a disk address through which all directories and file data in the file system or ROW read-only snapshot can be accessed; since the directories and files of the file system or read-only snapshot are all Abstracted into individual Objects (objects), all these Objects form the Objset (object set) of the file system or read-only snapshot, the Objset is organized in the form of a tree, and the tree has an ObjsetRoot (tree root) address, which can be accessed through this Objset Root All Objects to the file system/read-only snapshot, so the file system or read-only snapshot root is also called Objset Root.
通过与所述文件系统共享根的方式创建所述ROW只读快照,是指创建ROW只读快照时,将ROW只读快照的根指向文件系统的根。在ROW只读快照创建时,由于尚未对文件系统中的文件进行修改,而ROW只读快照直接保护FS的写前数据(即修改前的数据),因此,此时ROW只读快照的根指向文件系统的根。Creating the ROW read-only snapshot by sharing the root with the file system refers to pointing the root of the ROW read-only snapshot to the root of the file system when creating the ROW read-only snapshot. When the ROW read-only snapshot is created, because the files in the file system have not been modified, and the ROW read-only snapshot directly protects the data before writing (that is, the data before modification) of the FS. Therefore, at this time, the root of the ROW read-only snapshot points to The root of the file system.
进一步的,所述系统快照级别属性及所述只读快照级别属性包括[快照级别-逻辑时间点]对的集合,其中所述快照级别表示所述ROW只读快照保护的文件的快照级别,逻辑时间点表示创建所述ROW只读快照的逻辑时间点;Further, the system snapshot level attribute and the read-only snapshot level attribute include a set of [snapshot level-logical time point] pairs, wherein the snapshot level represents the snapshot level of the file protected by the ROW read-only snapshot, logical The time point represents the logical time point for creating the ROW read-only snapshot;
所述只读快照级别属性包括[快照级别-逻辑时间点]对的集合,其中所述快照级别表示需要保护的文件的快照级别,所述逻辑时间点表示创建所述ROW只读快照的逻辑时间点。The read-only snapshot level attribute includes a set of [snapshot level-logical time point] pairs, wherein the snapshot level represents the snapshot level of the file to be protected, and the logical time point represents the logical time for creating the ROW read-only snapshot point.
进一步的,所述快照创建指令还携带快照名称;Further, the snapshot creation instruction also carries a snapshot name;
所述根据所述快照创建指令为所述文件系统创建只读快照之后,还包括:After creating a read-only snapshot for the file system according to the snapshot creation instruction, it further includes:
根据所述快照名称命名所述ROW只读快照。Name the ROW read-only snapshot according to the snapshot name.
进一步的,所述根据所述快照创建指令为所述文件系统创建只读快照之后,还包括:Further, after creating a read-only snapshot for the file system according to the snapshot creation instruction, the method further includes:
接收访问所述ROW只读快照的请求;receiving a request to access the ROW read-only snapshot;
输出文件快照级别属性的值与所述ROW只读快照的只读快照级别属性的快照级别的值相等的文件。output the file whose snapshot level attribute value is equal to the snapshot level value of the read-only snapshot level attribute of the ROW read-only snapshot.
进一步的,所述在对指定文件进行修改时,判断所述指定文件的文件快照级别属性与已创建的ROW只读快照的只读快照级别属性是否匹配,并在匹配时根据所述已创建的ROW只读快照对所述指定文件进行写前保护,包括:Further, when the specified file is modified, it is judged whether the file snapshot level attribute of the specified file matches the read-only snapshot level attribute of the created ROW read-only snapshot, and when matching, according to the created ROW read-only snapshots protect the specified files before writing, including:
接收所述文件系统中指定文件的修改数据;receiving modification data of a specified file in the file system;
判断已创建的所述文件系统的只读快照中,是否存在只读快照级别属性的快照级别的值与所述指定文件的文件快照级别属性的值相等的只读快照;Judging whether there is a read-only snapshot in which the value of the snapshot level of the read-only snapshot level attribute is equal to the value of the file snapshot level attribute of the specified file in the created read-only snapshot of the file system;
若存在,保留所述指定文件修改前的旧数据,并将所述ROW只读快照的根指向所述指定文件的旧数据;否则,删除所述指定文件修改前的旧数据。If it exists, keep the old data of the specified file before modification, and point the root of the ROW read-only snapshot to the old data of the specified file; otherwise, delete the old data of the specified file before modification.
本实施例提供的存储数据的保护方法,通过增加文件的文件快照级别属性,对该文件快照级别属性进行设置,可以将不同的文件设置成不同的快照级别,同时在对系统文件创建ROW只读快照时指定该ROW只读快照需要保护的文件的快照级别,从而让ROW只读快照只保护那些需要保护的重要文件,也可让用户参与到ROW只读快照的控制,由用户根据应用场景去决定该为FS的哪些文件创建快照,尽可能控制快照的使用空间,降低ROW只读快照占用的FS的空间,使位于关键路径的FS尽可能可用,提升产品的竞争力。In the protection method for stored data provided in this embodiment, by increasing the file snapshot level attribute of the file and setting the file snapshot level attribute, different files can be set to different snapshot levels, and at the same time, when creating a ROW read-only system file When taking a snapshot, specify the snapshot level of the files to be protected by the ROW read-only snapshot, so that the ROW read-only snapshot only protects those important files that need to be protected, and also allows users to participate in the control of the ROW read-only snapshot, which is determined by the user according to the application scenario Decide which files in the FS should be created as snapshots, control the space used by the snapshots as much as possible, reduce the FS space occupied by ROW read-only snapshots, make the FS on the critical path as available as possible, and improve the competitiveness of the product.
实施例二Embodiment two
本实施例提供一种存储数据的保护方法,该方法以ROW只读快照为例进行说明。请参阅图2,方法流程包括:This embodiment provides a method for protecting stored data, and the method is described by taking a ROW read-only snapshot as an example. Please refer to Figure 2, the method flow includes:
201、接收用户输入的请求将fs1中的文件2(file2)的文件快照级别属性的值设置为1的属性设置指令。201. Receive an attribute setting instruction input by a user to request that the value of the file snapshot level attribute of file 2 (file2) in fs1 be set to 1.
具体的,fs1中的文件1(file1)、file2均设有文件快照级别属性:sanpLevel。Specifically, both files 1 (file1) and file2 in fs1 have a file snapshot level attribute: sanpLevel.
sanpLevel:文件的快照级别,默认为未设置(none)。sanpLevel: The snapshot level of the file, the default is not set (none).
202、根据该属性设置指令将file2的文件快照级别属性的值设置为1。202. Set the value of the file snapshot level attribute of file2 to 1 according to the attribute setting instruction.
具体的,根据该属性设置指令完成对file2的文件快照级别属性的设置之后,fs1的文件的快照级别属性示意图,请参阅图3。Specifically, after completing the setting of the file snapshot level attribute of file2 according to the attribute setting instruction, please refer to FIG. 3 for a schematic diagram of the snapshot level attribute of the file of fs1.
文件系统fs1设有四个与ROW只读快照相关的属性:The file system fs1 has four attributes related to ROW read-only snapshots:
prevSnap(前一快照):指向FS的前一个ROW只读快照;prevSnap (previous snapshot): points to the previous ROW read-only snapshot of FS;
nextSnap(下一快照):指向FS的下一个ROW只读快照;nextSnap (next snapshot): Point to the next ROW read-only snapshot of FS;
snapLevels系统快照级别:包含一个[key-value]对即[快照级别-逻辑时间点]对的集合,key为只读快照要保护的文件的快照级别,value为创建只读快照的逻辑时间点,未创建ROW只读快照时默认为[none];snapLevels system snapshot level: Contains a [key-value] pair, that is, a set of [snapshot level-logical time point] pairs, the key is the snapshot level of the file to be protected by the read-only snapshot, and the value is the logical time point when the read-only snapshot is created. Defaults to [none] when no ROW read-only snapshot is created;
FS Root(FS的根):指向fs1所有文件数据的根。FS Root (the root of FS): points to the root of all file data in fs1.
由于用户选择将file2的文件快照级别属性的值设置为1,因此本步骤完成用户的属性设置指令之后file2的sanpLevel=1,file1的sanpLevel=none。Since the user chooses to set the value of the file snapshot level attribute of file2 to 1, sanpLevel=1 of file2 and sanpLevel=none of file1 after completing the user's attribute setting instruction in this step.
203、接收用户输入的为fs1创建名称为snap1的只保护sanpLevel的值设置为1的文件的快照创建指令。203. Receive a snapshot creation instruction input by a user to create a file named snap1 for fs1 that only protects a file whose value of sanpLevel is set to 1.
具体的,该快照创建指令可采用如下格式:Specifically, the snapshot creation command can use the following format:
Snapshot create fs1snap1snapLevel=1Snapshot create fs1snap1snapLevel=1
具体的,Snapshot create:表示创建快照;Specifically, Snapshot create: means to create a snapshot;
fs1:表示给文件系统fs1创建快照;fs1: means to create a snapshot for the file system fs1;
snap1:表示快照的名字是snap1;snap1: indicates that the name of the snapshot is snap1;
snapLevel=1:表示只给文件系统中设置了级别为1的文件创建快照,即只保护文件快照级别属性值为1的文件。snapLevel=1: Indicates that snapshots are only created for files whose level is set to 1 in the file system, that is, only files whose snapshot level attribute value is 1 are protected.
204、根据该快照创建指令创建名为snap1的ROW只读快照。204. Create a ROW read-only snapshot named snap1 according to the snapshot creation instruction.
具体的,本步骤创建名为snap1的ROW只读快照,并使该快照共享文件系统的根。为fs1创建指定快照级别的ROW只读快照示意图,请参阅图4。Specifically, this step creates a ROW read-only snapshot named snap1, and makes the snapshot share the root of the file system. Refer to Figure 4 for a schematic diagram of creating a ROW read-only snapshot with a specified snapshot level for fs1.
创建完成后,fs1及snap1的相关属性设置如下:After the creation is complete, the relevant properties of fs1 and snap1 are set as follows:
fs1的snapLevels设置了一个key-value对:“1-10”,表示文件系统fs1在逻辑时间点为10的时候创建了一个只保护文件快照级别属性值为1的文件(即表示创建了一个快照级别为1的ROW只读快照);The snapLevels of fs1 sets a key-value pair: "1-10", indicating that the file system fs1 created a file with a snapshot level attribute value of 1 at the logical time point of 10 (that is, a snapshot was created ROW read-only snapshot with level 1);
snap1的snapLevels设置了一个key-value对:“1-10”,表示创建该snap1的逻辑时间点为10,其只保护逻辑时间点10之前的,文件快照级别属性值为1的文件。The snapLevels of snap1 is set with a key-value pair: "1-10", which means that the logical time point of creating the snap1 is 10, and it only protects the files whose file snapshot level attribute value is 1 before the logical time point 10.
fs1的prevSnap指向快照snap1;sanp1的nextSnap指向fs1;The prevSnap of fs1 points to snapshot snap1; the nextSnap of sanp1 points to fs1;
sanp1的Snap Root快照的根直接共享文件系统fs1的根:FS Root。The root of the Snap Root snapshot of sanp1 directly shares the root of the file system fs1: FS Root.
具体的,如果此时收到用户访问snap1的请求,将过滤掉与sanp1的snapLevels的不匹配的文件,而输出与所述ROW只读快照的快照级别匹配的文件,即ROW只读快照只输出snapLevel的值与自身的snapLevels的快照级别key的取值相同的文件。Specifically, if a request from a user to access snap1 is received at this time, files that do not match the snapLevels of sanp1 will be filtered out, and files that match the snapshot level of the ROW read-only snapshot will be output, that is, the ROW read-only snapshot will only output The value of snapLevel is the same as the value of the snapshot level key of its own snapLevels.
205、接收对file1进行修改的修改数据;205. Receive modification data for modifying file1;
206、根据该修改数据修改file1的数据,将修改后的file1的新数据保存到新的磁盘位置;206. Modify the data of file1 according to the modified data, and save the modified new data of file1 to a new disk location;
207、判断snap1的snapLevels与file1的snapLevel与不匹配,删除file1的旧数据。207. Determine that the snapLevels of snap1 do not match the snapLevels of file1, and delete old data of file1.
具体的,判断snap1的snapLevels与file1的snapLevel是否匹配,主要根据snapLevel的值与snapLevels的key的值是否相等,若相等则判断两者匹配,否则判断两者不匹配。本实施例中file1的snapLevel值为none,snap1的snapLevels的key值为1,两者不匹配。Specifically, judging whether the snapLevels of snap1 matches the snapLevel of file1 mainly depends on whether the value of snapLevel is equal to the value of the key of snapLevels. In this embodiment, the snapLevel value of file1 is none, and the key value of snapLevels of snap1 is 1, and the two do not match.
具体的,修改不被快照保护的file1的示意图,请参阅图5,图中“X”表示数据被删除。修改file1之后,遵循ROW原则,file1的新数据总是写到新的磁盘位置;而file1的旧数据因为file1的snapLevel=none而不被snap1保护,将被直接删除;此时fs1的根指向file1的新数据及file2的数据,而snap1的根则指向file2的数据。本步骤中,file1的旧数据被删除,将不再占用文件系统fs1的可用空间,从而降低了ROW只读快照对源FS可用空间的占用。Specifically, for a schematic diagram of modifying file1 that is not protected by the snapshot, please refer to FIG. 5 , where "X" in the figure indicates that data is deleted. After modifying file1, following the ROW principle, the new data of file1 is always written to the new disk location; while the old data of file1 is not protected by snap1 because file1's snapLevel=none, and will be deleted directly; at this time, the root of fs1 points to file1 The new data of and the data of file2, while the root of snap1 points to the data of file2. In this step, the old data of file1 is deleted, which will no longer occupy the available space of the file system fs1, thereby reducing the occupation of the available space of the source FS by the ROW read-only snapshot.
208、接收对file2进行修改的修改数据;208. Receive modification data for modifying file2;
209、根据该修改数据修改file2的数据,将修改后的file2的新数据保存到新的磁盘位置;209. Modify the data of file2 according to the modified data, and save the modified new data of file2 to a new disk location;
210、判断snap1的snapLevelsl与file2的snapLeve匹配,保留file2的旧数据。210. Determine that the snapLevelsl of snap1 matches the snapLeve of file2, and keep the old data of file2.
具体的,修改被快照保护的file2的示意图,请参阅图6。遵循ROW原则,file2的新数据总是写到新的磁盘位置;而file2的旧数据因为file2的snapLevel=1而被snap1保护,不会被删除。此时,fs1的根指向file1的新数据与file2的新数据,而snap1的根则指向file2的旧数据。Specifically, for a schematic diagram of modifying file2 protected by a snapshot, please refer to FIG. 6 . Following the ROW principle, the new data of file2 is always written to the new disk location; while the old data of file2 is protected by snap1 because the snapLevel=1 of file2 will not be deleted. At this point, the root of fs1 points to the new data of file1 and the new data of file2, while the root of snap1 points to the old data of file2.
具体的,本实施例的执行主体可以是存储管理系统。Specifically, the execution subject of this embodiment may be a storage management system.
本实施例提供的存储数据的保护方法,为文件系统中的文件增加了文件快照级别属性,由用户通过对文件快照级别属性进行设置,将不同的文件设置成不同的快照级别,同时用户可以在对系统文件创建ROW只读快照时指定需要保护的文件的快照级别,当对文件进行修改后,根据是否存在只读快照级别属性与被修改的文件的文件快照级别属性匹配的ROW只读快照确定是否对该文件进行快照保护,如果存在则保留该文件修改前的旧数据,否则删除该文件修改前的旧数据,从而让用户参与到ROW只读快照的控制,由用户根据应用场景去决定该为FS的哪些文件创建快照,尽可能控制快照的使用空间,降低只读快照占用的FS的空间,使位于关键路径的FS尽可能可用,提升产品的竞争力。The method for protecting stored data provided by this embodiment adds a file snapshot level attribute to files in the file system, and the user sets different files to different snapshot levels by setting the file snapshot level attribute, and the user can at the same time When creating a ROW read-only snapshot for a system file, specify the snapshot level of the file to be protected. After the file is modified, it is determined based on whether there is a ROW read-only snapshot whose read-only snapshot level attribute matches the file snapshot level attribute of the modified file. Whether to perform snapshot protection on the file, if it exists, keep the old data of the file before modification, otherwise delete the old data of the file before modification, so that users can participate in the control of ROW read-only snapshots, and the user decides according to the application scenario Create snapshots for which files in the FS, control the space used by the snapshot as much as possible, reduce the space occupied by the read-only snapshot, and make the FS on the critical path as available as possible to improve the competitiveness of the product.
实施例三Embodiment three
本实施例提供了一种存储数据的保护方法。本实施例中文件系统fs1包含多个文件,文件名依次为file1、file2…file6,该多个文件的文件快照级别属性默认为snapLevel=none。请参阅图7,方法流程包括:This embodiment provides a method for protecting stored data. In this embodiment, the file system fs1 includes multiple files, and the file names are file1, file2...file6 in sequence, and the file snapshot level attribute of the multiple files is snapLevel=none by default. Please refer to Figure 7, the method flow includes:
701、接收用户输入的将文件系统fs1中的文件file2、file5的文件快照级别属性的值设置为1的属性设置指令。701. Receive an attribute setting instruction input by a user to set the value of the file snapshot level attribute of files file2 and file5 in the file system fs1 to 1.
702、根据该属性设置指令将file2、file5的文件快照级别属性设置为snapLvel=1。702. Set the file snapshot level attributes of file2 and file5 to snapLvel=1 according to the attribute setting instruction.
703、接收用户输入的携带snapLevel=1的快照创建指令,该快照创建指令要求创建一个快照级别为1,名称为sanp1的ROW只读快照。703. Receive a snapshot creation instruction with snapLevel=1 input by a user, and the snapshot creation instruction requires creation of a ROW read-only snapshot with a snapshot level of 1 and a name of sanp1.
704、在逻辑时间点为10时,创建名为snap1的快照级别为1的ROW只读快照。704. When the logical time point is 10, create a ROW read-only snapshot named snap1 with snapshot level 1.
705、接收用户输入的将文件系统fs1中的文件file3、file4的文件快照级别属性的值设置为2的属性设置指令。705. Receive an attribute setting instruction input by the user to set the value of the file snapshot level attribute of the files file3 and file4 in the file system fs1 to 2.
706、根据该属性设置指令将file3、file4的文件快照级别属性设置为snapLevel=2。706. Set the file snapshot level attributes of file3 and file4 to snapLevel=2 according to the attribute setting instruction.
707、接收用户输入的携带snapLevel=2的快照创建指令,该快照创建指令要求创建一个快照级别为2,名称为sanp2的快照。707. Receive a snapshot creation instruction with snapLevel=2 input by the user, where the snapshot creation instruction requires creation of a snapshot with a snapshot level of 2 and named sanp2.
708、在逻辑时间点为20时,创建名为snap2的快照级别为2的ROW只读快照。708. When the logical time point is 20, create a ROW read-only snapshot named snap2 with snapshot level 2.
具体的,请参阅图7,创建完成后,fs1的系统快照级别属性snapLevels记录为:[1-10,2-20],表示在逻辑时间点为10的时候创建了一个快照级别为1的Row只读快照,在逻辑时间点为20的时候创建了一个快照级别为2的Row只读快照;snap1的只读快照级别属性snaLevels记录为:[1-10],表示该只读快照的只保护快照级别为1的文件,其保护逻辑时间点10之前的数据;snap2的只读快照级别属性snapLevels记录为:[2-20],表示该只读快照的只保护快照级别为2的文件,其保护逻辑时间点20之前的数据。sanp1、sanp2与fs1共享根。而,文件系统fs1的文件file1、file6由于其文件快照级别为none,将不被任何ROW只读快照保护。Specifically, please refer to Figure 7. After the creation is completed, the system snapshot level attribute snapLevels of fs1 is recorded as: [1-10, 2-20], indicating that a Row with a snapshot level of 1 was created at the logical time point of 10 For read-only snapshots, a Row read-only snapshot with snapshot level 2 is created at logical time point 20; the read-only snapshot level attribute snaLevels of snap1 is recorded as: [1-10], indicating that the read-only snapshot is only protected Files with a snapshot level of 1 protect data before logical time point 10; the read-only snapshot level attribute snapLevels of snap2 is recorded as: [2-20], which means that the read-only snapshot only protects files with a snapshot level of 2, and its Protect data before logical time point 20. sanp1, sanp2 share root with fs1. However, the files file1 and file6 of the file system fs1 will not be protected by any ROW read-only snapshot because their file snapshot level is none.
具体的,对snap1、snap2的访问及修改fs1的文件时,对各文件的处理方法与前述实施例相同此处不再赘述。Specifically, when accessing snap1 and snap2 and modifying the file of fs1, the processing method for each file is the same as that of the foregoing embodiment and will not be repeated here.
本实施例提供的存储数据的保护方法,为文件系统中的文件增加了文件快照级别属性,由用户通过对文件快照级别属性进行设置,将不同的文件设置成不同的快照级别,同时用户可以在对系统文件创建只读快照时指定需要保护的文件的快照级别,因此在对文件系统的文件进行修改时,ROW只读快照只保护用户指定的文件,对于未指定的文件将不进行ROW只读快照保护,能够有效地节省文件系统的空间。The method for protecting stored data provided by this embodiment adds a file snapshot level attribute to files in the file system, and the user sets different files to different snapshot levels by setting the file snapshot level attribute, and the user can at the same time When creating read-only snapshots for system files, specify the snapshot level of the files to be protected. Therefore, when modifying files in the file system, ROW read-only snapshots only protect the files specified by the user, and ROW read-only will not be performed for unspecified files. Snapshot protection can effectively save the space of the file system.
实施例四Embodiment Four
参见图9,本实施例提供了一种存储数据的保护装置,该装置包括:Referring to Figure 9, this embodiment provides a protection device for storing data, which includes:
接收单元901,用于属性设置指令,所述属性设置指令请求设置文件系统中文件的文件快照级别属性;The receiving unit 901 is used for an attribute setting instruction, the attribute setting instruction requests to set the file snapshot level attribute of the file in the file system;
设置单元902,用于根据所述接收单元901接收的属性设置指令设置所述文件的文件快照级别属性;The setting unit 902 is configured to set the file snapshot level attribute of the file according to the attribute setting instruction received by the receiving unit 901;
所述接收单元901,还用于接收快照创建指令,所述快照创建指令中携带需要保护的文件的文件快照级别属性参数;The receiving unit 901 is further configured to receive a snapshot creation instruction, and the snapshot creation instruction carries a file snapshot level attribute parameter of the file to be protected;
快照创建单元903,用于根据所述接收单元901接收的快照创建指令为所述文件系统创建指定快照级别的ROW只读快照,根据所述文件快照级别属性参数设置所述ROW只读快照的只读快照级别属性;The snapshot creation unit 903 is configured to create a ROW read-only snapshot of a specified snapshot level for the file system according to the snapshot creation instruction received by the receiving unit 901, and set the ROW read-only snapshot according to the file snapshot level attribute parameter. Read snapshot level attributes;
文件保护单元904,用于在对指定文件进行修改时,判断所述指定文件的文件快照级别属性与已创建的ROW只读快照的只读快照级别属性是否匹配,并在匹配时根据所述已创建的ROW只读快照对所述指定文件进行写前保护。The file protection unit 904 is configured to determine whether the file snapshot level attribute of the specified file matches the read-only snapshot level attribute of the created ROW read-only snapshot when modifying the specified file, and when matching, according to the established The created ROW read-only snapshot performs pre-write protection on the specified file.
进一步的,所述快照创建单元903包括:Further, the snapshot creation unit 903 includes:
创建模块,用于通过与所述文件系统共享根的方式创建所述ROW只读快照;Create a module for creating the ROW read-only snapshot by sharing the root with the file system;
设置模块,用于在所述创建模块创建所述ROW只读快照之后,根据所述文件快照级别属性设置所述ROW只读快照的只读快照级别属性,以及根据所述只读快照级别属性设置所述文件系统的系统快照级别属性。A setting module, configured to set the read-only snapshot level attribute of the ROW read-only snapshot according to the file snapshot level attribute after the creation module creates the ROW read-only snapshot, and set the read-only snapshot level attribute according to the System snapshot level attributes for the file system in question.
进一步的,所述记录模块,还用于将所述系统快照级别属性记录为包括[快照级别-逻辑时间点]对的集合,其中所述快照级别表示创建的所述ROW只读快照保护的文件的快照级别的快照级别,逻辑时间点表示创建所述ROW只读快照的逻辑时间点;将所述只读快照级别属性记录为包括[快照级别-逻辑时间点]对的集合,其中所述快照级别表示需要保护的文件的快照级别,所述逻辑时间点表示创建所述ROW只读快照的逻辑时间点。Further, the recording module is also configured to record the system snapshot level attribute as a set including [snapshot level-logical time point] pairs, wherein the snapshot level represents the created file protected by the ROW read-only snapshot The snapshot level of the snapshot level, the logical time point represents the logical time point at which the ROW read-only snapshot is created; the read-only snapshot level attribute is recorded as a set including the pair of [snapshot level-logical time point], wherein the snapshot The level indicates the snapshot level of the file to be protected, and the logical time point indicates the logical time point for creating the ROW read-only snapshot.
进一步的,所述接收单元901,还用于接收携带快照名称的快照创建指令;Further, the receiving unit 901 is also configured to receive a snapshot creation instruction carrying a snapshot name;
所述创建模块,还用于根据所述接收单元901接收的快照创建指令中携带的快照名称命名所述ROW只读快照。The creation module is further configured to name the ROW read-only snapshot according to the snapshot name carried in the snapshot creation instruction received by the receiving unit 901 .
进一步的,所述接收单元901,还用于在所述快照创建单元创建所述ROW只读快照之后,接收访问所述ROW只读快照的请求;Further, the receiving unit 901 is further configured to receive a request for accessing the ROW read-only snapshot after the snapshot creation unit creates the ROW read-only snapshot;
所述装置还包括:The device also includes:
输出单元,用于输出文件快照级别属性的值与所述ROW只读快照的只读快照级别属性中的快照级别的值相等的文件。The output unit is configured to output a file whose snapshot level attribute value is equal to the snapshot level value in the read-only snapshot level attribute of the ROW read-only snapshot.
进一步的,所述接收单元901,还用于接收所述文件系统中指定文件的修改数据;Further, the receiving unit 901 is also configured to receive modification data of a specified file in the file system;
所述装置还包括:The device also includes:
修改模块,用于根据所述接收单元901接收的修改数据修改所述指定文件的数据,并将修改后的所述指定文件的新数据保存到新的磁盘位置;A modification module, configured to modify the data of the specified file according to the modification data received by the receiving unit 901, and save the modified new data of the specified file to a new disk location;
判断模块,用于在所述修改模块将修改后的所述指定文件的新数据保存到新的磁盘位置之后,判断已创建的所述文件系统的ROW只读快照中,是否存在只读快照级别属性的快照级别的值与所述指定文件的文件快照级别属性的值相等的ROW只读快照;A judging module, configured to judge whether there is a read-only snapshot level in the created ROW read-only snapshot of the file system after the modification module saves the modified new data of the specified file to a new disk location The ROW read-only snapshot whose snapshot level value of the attribute is equal to the value of the file snapshot level attribute of the specified file;
根模块,用于在所述判断模块判断存只读快照级别属性与所述指定文件的文件快照级别属性相匹配的ROW只读快照时,将所述ROW只读快照的根指向所述指定文件的旧数据;The root module is used to point the root of the ROW read-only snapshot to the specified file when the judging module determines that the ROW read-only snapshot whose level attribute matches the file snapshot level attribute of the specified file is stored. the old data;
删除模块,用于在所述判断模块判断不存只读快照级别属性与所述指定文件的文件快照级别属性相匹配的ROW只读快照时,删除所述指定文件修改前的旧数据。The deletion module is used to delete the old data of the specified file before modification when the judging module determines that there is no ROW read-only snapshot whose read-only snapshot level attribute matches the file snapshot level attribute of the specified file.
本实施例存储数据的保护装置,通过增加文件的文件快照级别属性,对该文件快照级别属性进行设置,可以将不同的文件设置成不同的快照级别,同时在对系统文件创建ROW只读快照时指定该ROW只读快照需要保护的文件的快照级别,从而让ROW只读快照只保护那些需要保护的重要文件。在此基础上也可让用户参与到ROW只读快照的控制,由用户根据应用场景去决定该为FS的哪些文件创建快照,尽可能控制快照的使用空间,降低ROW只读快照占用的FS的空间,使位于关键路径的FS尽可能可用,提升产品的竞争力。In the protection device for storing data in this embodiment, by increasing the file snapshot level attribute of the file and setting the file snapshot level attribute, different files can be set to different snapshot levels, and at the same time when creating a ROW read-only snapshot for the system file Specify the snapshot level of the files to be protected by the ROW read-only snapshot, so that the ROW read-only snapshot only protects those important files that need to be protected. On this basis, users can also participate in the control of ROW read-only snapshots. Users can decide which files to create snapshots for FS according to application scenarios, control the space used by snapshots as much as possible, and reduce the FS occupied by ROW read-only snapshots. Space, make the FS on the critical path as available as possible, and improve the competitiveness of the product.
实施例五Embodiment five
请参阅图10,本实施例提供了一种存储数据的保护装置,该装置包括:Referring to Figure 10, this embodiment provides a protection device for storing data, which includes:
接收机1001,用于接收属性设置指令,所述属性设置指令请求设置文件系统中文件的文件快照级别属性;The receiver 1001 is configured to receive an attribute setting instruction, the attribute setting instruction requests to set a file snapshot level attribute of a file in the file system;
处理器1002,用于根据所述接收机接收的属性设置指令设置所述文件的文件快照级别属性;Processor 1002, configured to set the file snapshot level attribute of the file according to the attribute setting instruction received by the receiver;
所述接收机1001,还用于接收快照创建指令,所述快照创建指令中携带需要保护的文件的文件快照级别属性参数;The receiver 1001 is further configured to receive a snapshot creation instruction, where the snapshot creation instruction carries a file snapshot level attribute parameter of the file to be protected;
所述处理器1002,还用于根据所述接收机1001接收的快照创建指令为所述文件系统创建ROW只读快照,根据所述文件快照级别属性参数设置所述ROW只读快照的只读快照级别属性;以及用于在对指定文件进行修改时,判断所述指定文件的文件快照级别属性与已创建的ROW只读快照的只读快照级别属性是否匹配,并在匹配时根据所述已创建的ROW只读快照对所述指定文件进行写前保护。The processor 1002 is further configured to create a ROW read-only snapshot for the file system according to the snapshot creation instruction received by the receiver 1001, and set a read-only snapshot of the ROW read-only snapshot according to the file snapshot level attribute parameter level attribute; and used to determine whether the file snapshot level attribute of the specified file matches the read-only snapshot level attribute of the created ROW read-only snapshot when modifying the specified file, and when matching, according to the created The ROW read-only snapshot of the specified file is protected before writing.
进一步的,所述处理器1002,还用于通过与所述文件系统共享根的方式创建所述ROW只读快照;根据所述文件快照级别属性设置所述ROW只读快照的只读快照级别属性,以及根据所述只读快照级别属性设置所述文件系统的系统快照级别属性。Further, the processor 1002 is further configured to create the ROW read-only snapshot by sharing the root with the file system; set the read-only snapshot level attribute of the ROW read-only snapshot according to the file snapshot level attribute , and setting the system snapshot level attribute of the file system according to the read-only snapshot level attribute.
进一步的,所述处理器1002,还用于将所述系统快照级别属性记录为包括[快照级别-逻辑时间点]对的集合,其中所述快照级别表示创建的所述ROW只读快照的快照级别,逻辑时间点表示创建所述ROW只读快照的逻辑时间点;将所述只读快照级别属性记录为包括[快照级别-逻辑时间点]对的集合,其中所述快照级别表示需要保护的文件的快照级别,所述逻辑时间点表示创建所述ROW只读快照的逻辑时间点。Further, the processor 1002 is further configured to record the system snapshot level attribute as a set including [snapshot level-logical time point] pairs, where the snapshot level represents the created snapshot of the ROW read-only snapshot level, the logical time point represents the logical time point for creating the ROW read-only snapshot; the read-only snapshot level attribute is recorded as a set including [snapshot level-logical time point] pairs, wherein the snapshot level represents the required protection The snapshot level of the file, and the logical time point indicates the logical time point when the ROW read-only snapshot is created.
进一步的,所述接收机,还用于接收携带快照名称的快照创建指令;Further, the receiver is also configured to receive a snapshot creation instruction carrying a snapshot name;
所述处理器,还用于根据所述接收机接收的快照创建指令中携带的快照名称命名所述ROW只读快照。The processor is further configured to name the ROW read-only snapshot according to the snapshot name carried in the snapshot creation instruction received by the receiver.
进一步的,所述接收机1001,还用于在所述处理器1002创建所述ROW只读快照之后,接收访问所述ROW只读快照的请求;Further, the receiver 1001 is further configured to receive a request for accessing the ROW read-only snapshot after the processor 1002 creates the ROW read-only snapshot;
所述装置还包括:The device also includes:
发送机,用于根据所述接收机1002接收的请求输出文件快照级别属性的值与所述ROW只读快照的只读快照级别属性中的快照级别的值相等的文件。The sender is configured to output, according to the request received by the receiver 1002, a file whose snapshot level attribute value is equal to the snapshot level value in the read-only snapshot level attribute of the ROW read-only snapshot.
进一步的,所述接收机1001,还用于接收对所述文件系统中指定文件的进行修改的修改数据;Further, the receiver 1001 is also configured to receive modification data for modifying a specified file in the file system;
所述处理器1002,还用于根据所述接收机接收的修改数据修改所述指定文件的数据,并将修改后的所述指定文件的新数据保存到新的磁盘位置;判断已创建的所述文件系统的ROW只读快照中,是否存在只读快照级别属性的快照级别的值与所述指定文件的文件快照级别属性的值相等的ROW只读快照,若存在,则保留所述指定文件修改前的旧数据,并将所述ROW只读快照的根指向所述指定文件的旧数据,若不存在,则删除所述指定文件修改前的旧数据。The processor 1002 is further configured to modify the data of the specified file according to the modification data received by the receiver, and save the modified new data of the specified file to a new disk location; In the ROW read-only snapshot of the file system, whether there is a ROW read-only snapshot whose snapshot level value of the read-only snapshot level attribute is equal to the value of the file snapshot level attribute of the specified file, if it exists, the specified file is retained The old data before modification, and point the root of the ROW read-only snapshot to the old data of the specified file, if it does not exist, delete the old data of the specified file before modification.
本实施例提供的存储数据的保护装置,通过增加文件的文件快照级别属性,对该文件快照级别属性进行设置,可以将不同的文件设置成不同的快照级别,同时在对系统文件创建ROW只读快照时指定该ROW只读快照需要保护的文件的快照级别,从而让ROW只读快照只保护那些需要保护的重要文件,可有效降低ROW只读快照占用的FS的空间,使位于关键路径的FS尽可能可用,提升产品的竞争力。The protection device for storing data provided by this embodiment, by increasing the file snapshot level attribute of the file, setting the file snapshot level attribute, different files can be set to different snapshot levels, and at the same time when creating a ROW read-only system file When taking a snapshot, specify the snapshot level of the files to be protected by the ROW read-only snapshot, so that the ROW read-only snapshot only protects those important files that need to be protected, which can effectively reduce the FS space occupied by the ROW read-only Available as much as possible to enhance the competitiveness of products.
综上所述,本发明实施例提供的存储数据的保护方法及装置,为文件系统中的文件增加了文件快照级别属性,通过对文件快照级别属性进行设置,将不同的文件设置成不同的快照级别,并且可以在对系统文件创建ROW只读快照时指定需要保护的文件的快照级别,当对文件进行修改时,根据被修改的文件的文件快照级别属性是否与创建的ROW只读快照的只读快照级别属性是否匹配确定是否对该文件进行快照保护,如果匹配则保留该文件修改前的旧数据,否则删除该文件修改前的旧数据,从而能够让用户参与到ROW只读快照的控制,由用户根据应用场景去决定该为FS的哪些文件创建快照,尽可能控制快照的使用空间,降低ROW只读快照占用的FS的空间,使位于关键路径的FS尽可能可用,提升产品的竞争力。To sum up, the method and device for protecting stored data provided by the embodiments of the present invention add file snapshot level attributes to files in the file system, and set different files into different snapshots by setting the file snapshot level attributes. level, and you can specify the snapshot level of the file to be protected when creating a ROW read-only snapshot for the system file. Whether the attribute of the read snapshot level matches determines whether to perform snapshot protection on the file. If it matches, the old data before the modification of the file is retained, otherwise, the old data before the modification of the file is deleted, so that users can participate in the control of ROW read-only snapshots. It is up to the user to decide which files of the FS to create snapshots according to the application scenario, to control the space used by the snapshot as much as possible, to reduce the space occupied by the ROW read-only snapshot, to make the FS on the critical path as available as possible, and to enhance the competitiveness of the product .
需要说明的是:上述实施例提供的存储数据的保护装置,在实现对存储数据的保护时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的存储数据的保护装置与存储数据的保护方法实施属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that: when the protection device for stored data provided by the above-mentioned embodiments realizes the protection of stored data, the above-mentioned functional modules are only used as an example for illustration. In practical applications, the above-mentioned functions can be allocated by Completion of different functional modules means that the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the implementation of the device for protecting stored data provided by the above embodiments and the method for protecting stored data belong to the same concept, and the specific implementation process thereof can be found in the method embodiments for details, and will not be repeated here.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present invention are for description only, and do not represent the advantages and disadvantages of the embodiments.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps for implementing the above embodiments can be completed by hardware, and can also be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium. The above-mentioned The storage medium mentioned may be a read-only memory, a magnetic disk or an optical disk, and the like.
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection of the present invention. within range.
Claims (12)
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201310744238.0A CN103729265B (en) | 2013-12-30 | 2013-12-30 | A kind of guard method storing data and device |
| PCT/CN2014/088940 WO2015101083A1 (en) | 2013-12-30 | 2014-10-20 | Method and device for protecting stored data |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201310744238.0A CN103729265B (en) | 2013-12-30 | 2013-12-30 | A kind of guard method storing data and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN103729265A CN103729265A (en) | 2014-04-16 |
| CN103729265B true CN103729265B (en) | 2017-01-04 |
Family
ID=50453348
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201310744238.0A Active CN103729265B (en) | 2013-12-30 | 2013-12-30 | A kind of guard method storing data and device |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN103729265B (en) |
| WO (1) | WO2015101083A1 (en) |
Families Citing this family (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103729265B (en) * | 2013-12-30 | 2017-01-04 | 华为技术有限公司 | A kind of guard method storing data and device |
| CN109032507B (en) * | 2018-06-28 | 2021-11-19 | 郑州云海信息技术有限公司 | Method, system and related assembly for generating source volume storage snapshot |
| CN208638229U (en) * | 2018-08-03 | 2019-03-22 | 瑞声科技(新加坡)有限公司 | Vibrating motor |
| CN110888779B (en) * | 2019-11-18 | 2023-07-07 | 上海新炬网络信息技术股份有限公司 | File system read-only judging method based on analog writing |
| CN115509991A (en) * | 2022-10-10 | 2022-12-23 | 中电云数智科技有限公司 | Domain-based object snapshot management method |
| CN119106019A (en) * | 2023-06-08 | 2024-12-10 | 华为技术有限公司 | A method and device for setting file attributes |
| CN120223704A (en) * | 2023-12-27 | 2025-06-27 | 华为技术有限公司 | File attribute setting method, client, storage server, device and system |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101183383A (en) * | 2007-12-17 | 2008-05-21 | 中国科学院计算技术研究所 | A kind of snapshot system and using method thereof |
| CN101246458A (en) * | 2008-02-29 | 2008-08-20 | 中国科学院计算技术研究所 | Disk data protection method and system |
| CN103473277A (en) * | 2013-08-27 | 2013-12-25 | 华为技术有限公司 | Snapshot method and device for file systems |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7010553B2 (en) * | 2002-03-19 | 2006-03-07 | Network Appliance, Inc. | System and method for redirecting access to a remote mirrored snapshot |
| KR100439675B1 (en) * | 2002-10-24 | 2004-07-14 | 한국전자통신연구원 | An efficient snapshot technique for shated large storage |
| CN101661415B (en) * | 2009-09-21 | 2012-07-11 | 中兴通讯股份有限公司 | Method for memorizing snapshot data and system for memorizing snapshot |
| CN103729265B (en) * | 2013-12-30 | 2017-01-04 | 华为技术有限公司 | A kind of guard method storing data and device |
-
2013
- 2013-12-30 CN CN201310744238.0A patent/CN103729265B/en active Active
-
2014
- 2014-10-20 WO PCT/CN2014/088940 patent/WO2015101083A1/en active Application Filing
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101183383A (en) * | 2007-12-17 | 2008-05-21 | 中国科学院计算技术研究所 | A kind of snapshot system and using method thereof |
| CN101246458A (en) * | 2008-02-29 | 2008-08-20 | 中国科学院计算技术研究所 | Disk data protection method and system |
| CN103473277A (en) * | 2013-08-27 | 2013-12-25 | 华为技术有限公司 | Snapshot method and device for file systems |
Also Published As
| Publication number | Publication date |
|---|---|
| CN103729265A (en) | 2014-04-16 |
| WO2015101083A1 (en) | 2015-07-09 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN103729265B (en) | A kind of guard method storing data and device | |
| JP5514903B2 (en) | File level hierarchical storage management system, method, and apparatus | |
| EP3317805B1 (en) | A policy aware unified file system | |
| US8135677B2 (en) | File management system and method | |
| US10509701B2 (en) | Performing data backups using snapshots | |
| US7707178B2 (en) | Systems and methods for classifying and transferring information in a storage network | |
| US7979478B2 (en) | Data management method | |
| US20120005307A1 (en) | Storage virtualization | |
| US20150006581A1 (en) | Method for a Storage Device Accessing a File and Storage Device | |
| JP2010191647A (en) | File sharing system, file server, and method for managing file | |
| US20080215836A1 (en) | Method of managing time-based differential snapshot | |
| US10642817B2 (en) | Index table update method, and device | |
| WO2018121454A1 (en) | Method of managing file access control list, associated device and system | |
| CN103064637A (en) | Network disk cache synchronizing method and system | |
| US20170286442A1 (en) | File system support for file-level ghosting | |
| US9015526B2 (en) | Restoring method and computer system | |
| CN114048185B (en) | Method for transparently packaging, storing and accessing massive small files in distributed file system | |
| US8046391B2 (en) | Storage apparatus and its file control method and storage system | |
| US20100058023A1 (en) | Efficiently managing modular data storage systems | |
| US20070174360A1 (en) | Storage system embedding database | |
| JP2009245004A (en) | Bidirectional data arrangement system, access analysis server, data movement server, bidirectional data arrangement method and program | |
| CN107566405B (en) | A storage resource pooling method for fast access and copying | |
| CN111741107A (en) | Hierarchical method and device based on file storage system, and electronic device | |
| CN108304142A (en) | A kind of data managing method and device | |
| CN101438287B (en) | Method and apparatus for migrating content from a storage system |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant |