A snapshot data retrieval method, system, device and computer storage medium
By establishing a mapping data table in the Samba service server, using data identifiers and timestamps to generate snapshot data names, and directly searching for the target snapshot path, the problem of poor snapshot data retrieval performance in the Samba service is solved, and fast and accurate snapshot data retrieval is achieved.
Patent Information
- Application Number
- CN202210879819.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-25
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-07-25
AI Technical Summary
In the prior art, the Samba service has low performance when retrieving snapshot data of the volume shadow copy service, and it is difficult to quickly and accurately determine the target snapshot data.
By establishing a mapping data table in the Samba service server, the snapshot data name is generated by combining the data identifier and the timestamp, and the target snapshot path is directly searched in the mapping data table, thus avoiding the timestamp conversion and comparison operations.
It improves the retrieval efficiency of snapshot data, reduces the time spent on snapshot timestamps by about 90%, and significantly improves retrieval speed and accuracy.
Smart Images

Figure CN115145866B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of volume shadow copy services, and more specifically, to a snapshot data retrieval method, system, device, and computer storage medium. Background Art
[0002] Volume Shadow Copy Service (VSS) is a Windows operating system service that allows Windows systems to automatically or manually create snapshots of the current state of disk partitions. This service is also supported by the SMB (Server Message Block) file sharing service. Currently, the main tool that provides SMB file sharing services on the Linux side is the Samba service; Samba also added processing for volume shadow copy-related protocols in the server-side implementation of the SMB protocol.
[0003] Samba's support for volume shadow copies primarily enables viewing and restoring historical snapshot versions. The essence of these processes is that the client accesses a snapshot directory or file with a timestamp. When the Samba server receives an open operation for a directory or file with a timestamp attribute, it converts and compares the timestamps to find the correct historical version and returns it to the client.
[0004] Samba handles timestamps on shadow copy directories in two ways: First, the snapshot directory name is displayed in the standard GMT (Universal Time) timestamp format, allowing clients to directly access the corresponding snapshot version. Second, an additional snapshot time extended attribute is added to each snapshot directory to record the UNIX time value corresponding to the snapshot time. When a client request arrives, the snapshot time extended attribute value is read from each specific snapshot directory within the snapshot directory. When the timestamp matches the client request, the corresponding snapshot version is found. However, both methods have a certain performance degradation in snapshot retrieval.
[0005] In summary, how to quickly retrieve snapshot data of the volume shadow copy service is a problem that needs to be solved urgently by those skilled in the art. Summary of the Invention
[0006] The purpose of this application is to provide a snapshot data retrieval method, which can to some extent solve the technical problem of how to quickly retrieve snapshot data of the volume shadow copy service. This application also provides a snapshot data retrieval system, device and computer-readable storage medium.
[0007] In order to achieve the above objectives, this application provides the following technical solutions:
[0008] A snapshot data retrieval method, applied to a server on which a Samba service is installed, comprises:
[0009] Obtaining a retrieval request from a client for target snapshot data, wherein the target snapshot data includes snapshot data obtained through a volume shadow copy service;
[0010] Determining a target data identifier and a target timestamp in the retrieval request;
[0011] Determine the target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table;
[0012] The target snapshot data is determined based on the target snapshot path.
[0013] Preferably, determining the target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table includes:
[0014] Combining the target data identifier and the target timestamp in the format of data identifier@GMT-timestamp to obtain the target snapshot data name;
[0015] In the mapping data table, the target snapshot path corresponding to the target data name is determined.
[0016] Preferably, before determining the target snapshot path corresponding to the target data identifier and the target timestamp in the pre-stored mapping data table, the method further includes:
[0017] Determine the data identifier and timestamp of the snapshot data;
[0018] Generate a snapshot data name based on the data identifier and the timestamp;
[0019] Determine the snapshot path corresponding to the snapshot data name;
[0020] The mapping data table is generated based on the snapshot data name and the snapshot path.
[0021] Preferably, determining the snapshot path corresponding to the snapshot data name includes:
[0022] Based on the data identifier, determining a parent directory path of the snapshot data;
[0023] Perform an opendir operation on the parent directory path to obtain a dir handle;
[0024] Call the readdir interface to read the dir handle and obtain the subdirectories under the parent directory path;
[0025] Obtaining the extended attribute snapshot time value of each subdirectory based on the getattr interface;
[0026] Determine a subdirectory path of the subdirectory corresponding to the extended attribute snapshot time value and the timestamp value;
[0027] The snapshot path is generated based on the parent directory path and the child directory path.
[0028] Preferably, after generating the mapping data table based on the snapshot data name and the snapshot path, the method further includes:
[0029] Generate a timer corresponding to the snapshot data name;
[0030] Determining the generation time of the snapshot data name;
[0031] If the generation duration exceeds the time range of the timer, the mapping information of the snapshot data name is deleted from the mapping data table.
[0032] Preferably, determining the target data identifier and target timestamp in the search request includes:
[0033] Locating the name offset position of the SMB data packet corresponding to the search request, and extracting the target data identifier from the name offset position;
[0034] The extended field offset position of the SMB data packet is located, and the value of the TWRP extended field in the extended field offset position is used as the target timestamp.
[0035] Preferably, after determining the target snapshot data based on the target snapshot path, the method further includes:
[0036] Open the target snapshot data and obtain a target handle of the target snapshot data;
[0037] The target handle is sent to the client, so that the client operates the target snapshot data based on the target handle.
[0038] A snapshot data retrieval system is applied to a server on which a Samba service is installed, comprising:
[0039] A first acquisition module is configured to acquire a retrieval request from a client for target snapshot data, wherein the target snapshot data includes snapshot data obtained through a volume shadow copy service;
[0040] A first determining module, configured to determine a target data identifier and a target timestamp in the search request;
[0041] A second determining module is configured to determine a target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table;
[0042] The third determining module is configured to determine the target snapshot data based on the target snapshot path.
[0043] A snapshot data retrieval device, comprising:
[0044] memory for storing computer programs;
[0045] A processor is configured to implement the steps of any of the above-mentioned snapshot data retrieval methods when executing the computer program.
[0046] A computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-mentioned snapshot data retrieval methods.
[0047] The present application provides a snapshot data retrieval method, which is applied to a server with a Samba service installed, to obtain a client's retrieval request for target snapshot data, where the target snapshot data includes snapshot data obtained through a volume shadow copy service; to determine a target data identifier and a target timestamp in the retrieval request; to determine a target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table; and to determine the target snapshot data based on the target snapshot path. In the present application, after obtaining a retrieval request, the server with a Samba service installed can determine a target snapshot path corresponding to the target data identifier and the target timestamp in the retrieval request in a pre-stored mapping data table, and then can determine the target snapshot data based on the target snapshot path. There is no need to convert, compare, or perform other operations on the timestamp of the target snapshot data, and the target snapshot data can be quickly determined, thereby improving the efficiency of snapshot data retrieval. The present application provides a snapshot data retrieval system, device, and computer-readable storage medium that also solve corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0049] Figure 1 A first flow chart of a snapshot data retrieval method provided in an embodiment of the present application;
[0050] Figure 2 A second flow chart of a snapshot data retrieval method provided in an embodiment of the present application;
[0051] Figure 3 A schematic diagram of a snapshot data retrieval method provided in an embodiment of the present application;
[0052] Figure 4 Another schematic diagram of a snapshot data retrieval method provided in an embodiment of the present application;
[0053] Figure 5 A schematic diagram of the structure of a snapshot data retrieval system provided in an embodiment of the present application;
[0054] Figure 6 A schematic diagram of the structure of a snapshot data retrieval device provided in an embodiment of the present application;
[0055] Figure 7 Another structural schematic diagram of a snapshot data retrieval device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0057] Volume Shadow Copy Service (VSS) is a Windows operating system service that allows Windows systems to automatically or manually create snapshots of the current state of disk partitions. This service is also supported by the SMB (Server Message Block) file sharing service. Currently, the main tool that provides SMB file sharing services on the Linux side is the Samba service; Samba also added processing for volume shadow copy-related protocols in the server-side implementation of the SMB protocol.
[0058] The support of Samba for volume shadow copy is mainly to provide viewing and restoration of historical snapshot versions. The essence of the snapshot viewing and restoration process is that the client accesses the snapshot directory or file with a timestamp attribute. When the Samba server receives the directory or file opening operation with the timestamp attribute, the correct historical version is found through the comparison of the timestamp conversion, and returned to the client. Samba has two ways to handle the timestamp of the volume shadow copy directory. The first way is to display the snapshot directory name directly according to the standard GMT (Universal Time) timestamp format. In this way, the client directly matches the corresponding snapshot version when accessing. The second way is to add an additional snapshot time extension attribute to each version of the snapshot directory, which is used to record the UNIX time value corresponding to the snapshot time. When the client request arrives, the snapshot time extension attribute value of each specific snapshot directory under the snapshot directory is read. When the timestamp requested by the client is matched, the corresponding snapshot version is found. However, these two ways have a certain decline in the performance of retrieving snapshots. The snapshot data retrieval scheme provided in the present application can quickly retrieve snapshot data of the volume shadow copy service.
[0059] Please refer to Figure 1 , Figure 1 The first flowchart of the snapshot data retrieval method provided by the embodiment of the present application.
[0060] The snapshot data retrieval method provided by the embodiment of the present application is applied to a server installed with a Samba service, and can include the following steps:
[0061] Step S101: Obtain a retrieval request of a target snapshot data from a client, the target snapshot data including snapshot data obtained through a volume shadow copy service.
[0062] In actual application, the server can first obtain the retrieval request of the target snapshot data from the client, and the target snapshot data is the snapshot data obtained through the volume shadow copy service. The type and content of the target snapshot data can be determined according to actual needs, such as the target snapshot data can be a snapshot directory, a snapshot file, etc.
[0063] In a specific application scenario, the information interaction between the server and the client can be based on the SMB (Server Message Block) protocol, etc., which is not limited in the present application. It should be noted that the SMB protocol in the present application refers to a shared transmission protocol between different network nodes.
[0064] Step S102: Determine the target data identifier and the target timestamp in the retrieval request.
[0065] In actual applications, because the volume shadow copy service may obtain multiple different types of snapshot data, and the same type of snapshot data may have multiple versions, for example, snapshot data has two types A and B, and snapshot data A has three versions, each corresponding to a different timestamp, etc., if the search is only based on the snapshot type, it is difficult to accurately determine the target snapshot data. Therefore, in order to accurately retrieve the target snapshot data, after obtaining the client's retrieval request for the target snapshot data, the server can determine the target data identifier and target timestamp in the retrieval request, so as to accurately determine the target snapshot data based on the target data identifier and target timestamp.
[0066] In a specific application scenario, when the server and the client interact through the SMB protocol, the server can locate the name offset position of the SMB data packet corresponding to the retrieval request based on the SMB protocol layer in the process of determining the target data identifier and target timestamp in the retrieval request, and extract the target data identifier in the name offset position; locate the extended field offset position of the SMB data packet, and use the value of the TWRP extended field in the extended field offset position as the target timestamp, so as to quickly determine the target data identifier and target timestamp.
[0067] Step S103: Determine the target snapshot path corresponding to the target data identifier and the target timestamp in the pre-stored mapping data table.
[0068] Step S104: determining target snapshot data based on the target snapshot path.
[0069] In actual applications, after determining the target data identifier and target timestamp in the retrieval request, the server can determine the target snapshot path corresponding to the target data identifier and target timestamp in the pre-stored mapping data table, and quickly determine the target snapshot data based on the target snapshot path.
[0070] In a specific application scenario, in the process of determining the target snapshot path corresponding to the target data identifier and the target timestamp in the pre-stored mapping data table, the server can combine the target data identifier and the target timestamp according to the format of data identifier@GMT-timestamp to obtain a target snapshot data name; in the mapping data table, the target snapshot path corresponding to the target snapshot data name is determined to quickly determine the target snapshot path. It should be noted that the format of data identifier@GMT-timestamp can be further adjusted for applicability according to specific needs, such as being adjusted to: filename@GMT-%Y.%m.%d-%H.%M.%S, etc., where filename represents the data identifier, %Y represents the year, %m represents the month, %d represents the day, %H represents the hour, %M represents the minute, %S represents the second, etc., which is not limited in the present application. Specifically, the server can determine the target snapshot path by means of its own SMB virtual file system layer, for example, after the SMB virtual file system layer receives the target snapshot data name, it can first judge whether the timestamp in the target snapshot data name conforms to the standard GMT timestamp format, if so, the target timestamp and the target data identifier are directly taken out, and in the mapping data table, the corresponding target snapshot path is found.
[0071] In specific application scenarios, after determining the target snapshot data based on the target snapshot path, the server can also open the target snapshot data and obtain the target handle of the target snapshot data. The target handle is then sent to the client, allowing the client to perform operations on the target snapshot data based on the target handle. For example, after successfully opening the target snapshot data, the server obtains the target handle and returns it to the client. The client uses this target handle to initiate an SMB GETINFO request to obtain snapshot directory attributes such as size and capacity. The client completes the processing and closes the target snapshot, thus completing access to the target snapshot data. Note that since only the file handle is passed in, this closing process is the same as closing a normal file. Currently, the client can also restore the target snapshot data based on the target handle. For example, the client can initiate an open operation on the shadow copy source file and obtain the target handle of the target snapshot file. The open operation at this time is the same as the open operation method for directly viewing the snapshot information. A brief keyword is obtained from the target handle of the target snapshot file through an SMB IOCTL (get keyword) operation; the target location to be restored is determined, that is, the directory for viewing the shadow copy information, and a target file handle is created in the directory; if the target file already exists, the target file is opened in overwrite mode; otherwise, the target file is opened in create mode; based on the obtained brief keyword of the shadow copy source file and the target handle of the target file handle, the client initiates an SMB IOCTL (block copy) operation, and the copy request includes the offset information to be copied; the server processes the request and directly completes the reading of the shadow copy source file and the writing of the target file on the server; the client initiates two SMB CLOSE requests to the server to close the shadow copy source file and the target file respectively.
[0072] The present application provides a snapshot data retrieval method, which is applied to a server with a Samba service installed, to obtain a client's retrieval request for target snapshot data, where the target snapshot data includes snapshot data obtained through a volume shadow copy service; to determine a target data identifier and a target timestamp in the retrieval request; to determine a target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table; and to determine the target snapshot data based on the target snapshot path. In the present application, after obtaining a retrieval request, the server with a Samba service installed can determine a target snapshot path corresponding to the target data identifier and the target timestamp in the retrieval request in a pre-stored mapping data table, and then can determine the target snapshot data based on the target snapshot path. This method eliminates the need to convert or compare the timestamp of the target snapshot data, and can quickly determine the target snapshot data, thereby improving the efficiency of snapshot data retrieval.
[0073] See also Figure 2 , Figure 2 This is a second flow chart of a snapshot data retrieval method provided in an embodiment of the present application.
[0074] An embodiment of the present application provides a snapshot data retrieval method, which is applied to a server where a Samba service is installed, and may include the following steps:
[0075] Step S201: Determine the data identifier and timestamp of the snapshot data.
[0076] Step S202: Generate a snapshot data name based on the data identifier and timestamp.
[0077] Step S203: Determine the snapshot path corresponding to the snapshot data name.
[0078] Step S204: Generate a mapping data table based on the snapshot data name and the snapshot path.
[0079] In actual applications, when the server needs to generate a mapping data table, such as when pre-generating a mapping data table, it can determine the data identifier and timestamp of the snapshot data; generate the snapshot data name based on the data identifier and timestamp; determine the snapshot path corresponding to the snapshot data name; and generate a mapping data table based on the snapshot data name and the snapshot path. Of course, when the server needs to add or update a mapping relationship for a mapping data table, it can also determine the data identifier and timestamp of the snapshot data, generate the snapshot data name based on the data identifier and timestamp, determine the snapshot path corresponding to the snapshot data name, and finally add or update the snapshot data name and snapshot path to the mapping data table. Specifically, the mapping data table can be a mapping data hash table, and the snapshot data name can be used as the key value and the snapshot path can be used as the value to generate the mapping data hash table, etc. This application does not make specific restrictions here.
[0080] In a specific application scenario, in the process of determining the snapshot path corresponding to the snapshot data name, the parent directory path of the snapshot data, "parent directory / .snap", can be determined based on the data identifier; an opendir operation is performed on the parent directory path to obtain a dir handle; the readdir interface is called to read the dir handle to obtain each subdirectory under the parent directory path; the extended attribute snapshot time value of each subdirectory is obtained based on the getattr interface; the subdirectory path of the subdirectory corresponding to the extended attribute snapshot time value and the timestamp value is determined; and a snapshot path is generated based on the parent directory path and the subdirectory path, for example, the snapshot path can be "parent directory / .snap / snapshot subdirectory", etc.
[0081] For specific application scenarios, please refer to Figure 3 and Figure 4Because Samba supports the creation and destruction of timers, after generating a mapping data table based on the snapshot data name and snapshot path, a timer corresponding to the snapshot data name can also be generated. Each subsequent generation of new mapping information requires a corresponding timer. The generation duration of the snapshot data name is determined. If the generation duration exceeds the timer's range, the mapping information for the snapshot data name is deleted from the mapping data table. This allows for time-sensitive management of the mapping data table, preventing the mapping information in the mapping data table from becoming invalid and preventing the mapping information in the mapping data table from occupying memory for a long time.
[0082] It should be noted that in a specific application scenario, in order to facilitate the server to manage the corresponding timers of the mapping information table, an independent linked list corresponding to the timer can be maintained inside Samba, and the timer linked list can be processed in each EPOLL cycle. The processing process can be as follows: when adding a mapping relationship to the mapping data table, a single Samba timer is started and added to the timer linked list; in each EPOLL cycle, it is determined whether each timer in the timer linked list has reached the timing end time, for example, the number of seconds of the system startup time is obtained, and it is detected whether the second value exceeds the time range of the timer. If it exceeds, it is considered that the timer has reached the timing end time, otherwise it is considered that the timer has not reached the timing end time; if the timing end time is reached, it means that the corresponding mapping information in the mapping data table has reached the aging time. At this time, the mapping information is automatically deleted from the mapping data table and the timer is released; if the timer has not reached the timing end time, the next timer in the timer linked list can be tested until all timers in the timer linked list are tested.
[0083] It should also be noted that the timing duration and timing method of the timer in this application can be determined according to actual needs. For example, the timing duration of the timer can be set to 1 minute, and the 1 minute can be converted into a second value relative to the startup of the server system, and finally the second value can be used as the timing result of the timer, etc. This application does not make specific limitations here.
[0084] Step S205: obtaining a retrieval request for target snapshot data from the client, where the target snapshot data includes snapshot data obtained through the volume shadow copy service.
[0085] Step S206: Determine the target data identifier and target timestamp in the search request.
[0086] Step S207: Determine the target snapshot path corresponding to the target data identifier and the target timestamp in the pre-stored mapping data table.
[0087] Step S208: determining target snapshot data based on the target snapshot path.
[0088] To facilitate understanding of the retrieval effect of the present invention, assuming that the client is a Windows client and the server is a Samba server, the existing snapshot data retrieval method is now described, which may include the following steps:
[0089] The Windows client initiates an open operation on the subdirectory. The Samba server responds to the open request and returns a file handle in GUID format to the Windows client.
[0090] The Windows client holds the file handle and initiates a snapshot query operation. After receiving the snapshot query request, the Samba server traverses the .snap subdirectory under the current directory, further queries each specific snapshot subdirectory under the .snap directory, and packages the final result and returns it to the Windows client.
[0091] The Windows client obtains the snapshot query results and displays the historical versions at each time point in the properties window;
[0092] The Windows client initiates a close operation on the above directory to complete the snapshot viewing process;
[0093] The Windows client initiates an open operation on the snapshot directory and adds a UTC timestamp of the shadow copy in the extended attribute field of the SMB CREATE protocol packet.
[0094] The Samba server parses the SMB CREATE data packet and performs a name conversion operation. If the UTC timestamp of the shadow copy is parsed, a new composite file name will be converted. The format of the new composite file name is "file name@timestamp". After the composite file name enters each standard file API interface call, the following basic actions are performed when the combination of "file name@timestamp" is encountered: extract the timestamp from the composite file name; use the timestamp to find the corresponding snapshot directory, that is, traverse and read each snapshot subdirectory under the .snap directory. After reading a snapshot subdirectory, open the snapshot subdirectory and obtain the UNIX timestamp in the extended attributes it carries; compare the previously extracted timestamp with the UNIX timestamp in the extended attributes of each snapshot subdirectory. When they match, the target snapshot file name is found; and execute the standard file API interface for the target snapshot file name.
[0095] In all the above processes, when access to the snapshot file name in the combined form is required, complete timestamp processing is required, and the snapshot subdirectory is read for timestamp matching, all processes are added together, and the time consumption is greatly increased; among them, for the file opening operation, a complete SMB opening operation includes operations such as obtaining the real path, obtaining the state information, ACL (Access Control Lists) permission verification, file permission opening, and the like, and some operations such as obtaining the state information are called multiple times, and each conversion undergoes a complete conversion of the combined file name to the target snapshot name; for the directory opening operation, a complete SMB directory query operation also includes operations such as obtaining the real path, obtaining the state information, ACL permission verification, file permission opening, and the like, and when each file under the directory is read, the same snapshot timestamp conversion action is performed on the subfile due to the obtaining of the state information of the subfile. That is, the existing process needs to convert the snapshot timestamp multiple times in a single SMB process, and needs to compare the snapshot timestamp multiple times to determine the snapshot data required for the operation, which is low in efficiency. The present application saves the correspondence between the snapshot data name and the snapshot path through the mapping data table, and subsequently only needs to quickly determine the snapshot path by looking up the table, which can reduce the snapshot timestamp time consumption ratio by about 90% for a single SMB request process, which is very obvious for the optimization effect of a complex snapshot directory structure, and the mapping relationship of the aging mechanism is established through the timer, which can greatly improve the processing speed of the snapshot opening and restoration without affecting the memory consumption.
[0096] Please refer to Figure 5 , Figure 5 A structure diagram of a snapshot data retrieval system provided by an embodiment of the present application.
[0097] The snapshot data retrieval system provided by the embodiment of the present application is applied to a server installed with a Samba service, and can include:
[0098] The first obtaining module 101 is configured to obtain a retrieval request of a target snapshot data of a client, and the target snapshot data includes snapshot data obtained through a volume shadow copy service;
[0099] The first determining module 102 is configured to determine a target data identifier and a target timestamp in the retrieval request;
[0100] The second determining module 103 is configured to determine a target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table;
[0101] The third determining module 104 is configured to determine the target snapshot data based on the target snapshot path.
[0102] An embodiment of the present application provides a snapshot data retrieval system, which is applied to a server where a Samba service is installed. The second determination module may include:
[0103] The first combining unit is used to combine the target data identifier and the target timestamp in the format of data identifier@GMT-timestamp to obtain the target snapshot data name;
[0104] The first determining unit is configured to determine a target snapshot path corresponding to a target data name in a mapping data table.
[0105] The snapshot data retrieval system provided in an embodiment of the present application is applied to a server where a Samba service is installed, and may further include:
[0106] a fourth determining module configured to determine the data identifier and the timestamp of the snapshot data before the second determining module determines the target snapshot path corresponding to the target data identifier and the target timestamp in the pre-stored mapping data table;
[0107] A first generating module, configured to generate a snapshot data name based on the data identifier and the timestamp;
[0108] A fifth determining module, configured to determine a snapshot path corresponding to the snapshot data name;
[0109] The second generating module is used to generate a mapping data table based on the snapshot data name and the snapshot path.
[0110] An embodiment of the present application provides a snapshot data retrieval system, which is applied to a server where a Samba service is installed. The fifth determination module may include:
[0111] A second determining unit is configured to determine a parent directory path of the snapshot data based on the data identifier;
[0112] The first operation unit is used to perform an opendir operation on the parent directory path to obtain a dir handle;
[0113] The first calling unit is used to call the readdir interface to read the dir handle and obtain each subdirectory under the parent directory path;
[0114] The first acquiring unit is configured to acquire the extended attribute snapshot time value of each subdirectory based on the getattr interface;
[0115] A third determining unit is configured to determine a subdirectory path of a subdirectory corresponding to the extended attribute snapshot time value and the timestamp value;
[0116] The third generating unit is configured to generate a snapshot path based on the parent directory path and the subdirectory path.
[0117] The snapshot data retrieval system provided in an embodiment of the present application is applied to a server where a Samba service is installed, and may further include:
[0118] A fourth generating unit, configured to generate a timer corresponding to the snapshot data name after the second generating module generates the mapping data table based on the snapshot data name and the snapshot path;
[0119] The fourth determining unit is configured to determine a generation duration of the snapshot data name; if the generation duration exceeds a time range of the timer, the mapping information of the snapshot data name is deleted from the mapping data table.
[0120] An embodiment of the present application provides a snapshot data retrieval system, which is applied to a server where a Samba service is installed. The first determination module may include:
[0121] A first positioning unit is configured to locate a name offset position of an SMB data packet corresponding to the search request and extract a target data identifier from the name offset position;
[0122] The second positioning unit is used to locate the extension field offset position of the SMB data packet and use the value of the TWRP extension field in the extension field offset position as the target timestamp.
[0123] The snapshot data retrieval system provided in an embodiment of the present application is applied to a server where a Samba service is installed, and may further include:
[0124] a first opening module, configured to open the target snapshot data and obtain a target handle of the target snapshot data after the third determining module determines the target snapshot data based on the target snapshot path;
[0125] The first sending module is configured to send the target handle to the client, so that the client can operate the target snapshot data based on the target handle.
[0126] The present application also provides a snapshot data retrieval device and a computer-readable storage medium, both of which have the corresponding effects of the snapshot data retrieval method provided in the embodiments of the present application. Figure 6 , Figure 6 A schematic structural diagram of a snapshot data retrieval device provided in an embodiment of the present application.
[0127] An embodiment of the present application provides a snapshot data retrieval device, including a memory 201 and a processor 202. The memory 201 stores a computer program, and the processor 202 performs the following steps when executing the computer program:
[0128] Obtaining a retrieval request from a client for target snapshot data, where the target snapshot data includes snapshot data obtained through a volume shadow copy service;
[0129] Determine the target data identifier and target timestamp in the retrieval request;
[0130] In the pre-stored mapping data table, determine the target snapshot path corresponding to the target data identifier and the target timestamp;
[0131] The target snapshot data is determined based on the target snapshot path.
[0132] A snapshot data retrieval device provided in an embodiment of the present application includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the following steps are implemented: a target data identifier and a target timestamp are combined in a format of data identifier@GMT-timestamp to obtain a target snapshot data name; and a target snapshot path corresponding to the target data name is determined in a mapping data table.
[0133] A snapshot data retrieval device provided in an embodiment of the present application includes a memory 201 and a processor 202. A computer program is stored in the memory 201. When the processor 202 executes the computer program, the following steps are implemented: before determining the target data identifier and the target snapshot path corresponding to the target timestamp, the data identifier and timestamp of the snapshot data are determined; a snapshot data name is generated based on the data identifier and timestamp; the snapshot path corresponding to the snapshot data name is determined; and a mapping data table is generated based on the snapshot data name and the snapshot path.
[0134] An embodiment of the present application provides a snapshot data retrieval device, including a memory 201 and a processor 202. The memory 201 stores a computer program, and when the processor 202 executes the computer program, the following steps are implemented: determining the parent directory path of the snapshot data based on a data identifier; performing an opendir operation on the parent directory path to obtain a dir handle; calling a readdir interface to read the dir handle to obtain each subdirectory under the parent directory path; obtaining an extended attribute snapshot time value of each subdirectory based on a getattr interface; determining the subdirectory path of the subdirectory corresponding to the extended attribute snapshot time value and the timestamp value; and generating a snapshot path based on the parent directory path and the subdirectory path.
[0135] A snapshot data retrieval device provided in an embodiment of the present application includes a memory 201 and a processor 202. A computer program is stored in the memory 201, and when the processor 202 executes the computer program, the following steps are implemented: after generating a mapping data table based on the snapshot data name and the snapshot path, a timer corresponding to the snapshot data name is generated; the generation duration of the snapshot data name is determined; if the generation duration exceeds the time range of the timer, the mapping information of the snapshot data name is deleted from the mapping data table.
[0136] An embodiment of the present application provides a snapshot data retrieval device, including a memory 201 and a processor 202. The memory 201 stores a computer program, and when the processor 202 executes the computer program, it implements the following steps: locating the name offset position of the SMB data packet corresponding to the retrieval request, and extracting the target data identifier in the name offset position; locating the extension field offset position of the SMB data packet, and using the value of the TWRP extension field in the extension field offset position as the target timestamp.
[0137] A snapshot data retrieval device provided in an embodiment of the present application includes a memory 201 and a processor 202. A computer program is stored in the memory 201. When the processor 202 executes the computer program, the following steps are implemented: after determining the target snapshot data based on the target snapshot path, the target snapshot data is opened to obtain a target handle of the target snapshot data; and the target handle is sent to the client so that the client can operate on the target snapshot data based on the target handle.
[0138] See also Figure 7 Another snapshot data retrieval device provided in an embodiment of the present application may further include: an input port 203 connected to the processor 202 for transmitting commands inputted from the outside to the processor 202; a display unit 204 connected to the processor 202 for displaying the processing results of the processor 202 to the outside world; and a communication module 205 connected to the processor 202 for enabling communication between the snapshot data retrieval device and the outside world. The display unit 204 may be a display panel, a laser scanning display, etc. The communication method adopted by the communication module 205 includes, but is not limited to, mobile high-definition link technology (HML), universal serial bus (USB), high-definition multimedia interface (HDMI), wireless connection: wireless fidelity technology (WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, and communication technology based on IEEE802.11s.
[0139] An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the following steps are implemented:
[0140] Obtaining a retrieval request from a client for target snapshot data, where the target snapshot data includes snapshot data obtained through a volume shadow copy service;
[0141] Determine the target data identifier and target timestamp in the retrieval request;
[0142] In the pre-stored mapping data table, determine the target snapshot path corresponding to the target data identifier and the target timestamp;
[0143] The target snapshot data is determined based on the target snapshot path.
[0144] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: a target data identifier and a target timestamp are combined in a format of data identifier@GMT-timestamp to obtain a target snapshot data name; and in a mapping data table, a target snapshot path corresponding to the target data name is determined.
[0145] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: before determining the target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table, the data identifier and timestamp of the snapshot data are determined; a snapshot data name is generated based on the data identifier and the timestamp; the snapshot path corresponding to the snapshot data name is determined; and a mapping data table is generated based on the snapshot data name and the snapshot path.
[0146] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: determining a parent directory path of snapshot data based on a data identifier; performing an opendir operation on the parent directory path to obtain a dir handle; calling a readdir interface to read the dir handle to obtain each subdirectory under the parent directory path; obtaining an extended attribute snapshot time value of each subdirectory based on a getattr interface; determining a subdirectory path of a subdirectory corresponding to the extended attribute snapshot time value and a timestamp value; and generating a snapshot path based on the parent directory path and the subdirectory path.
[0147] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: after generating a mapping data table based on the snapshot data name and the snapshot path, a timer corresponding to the snapshot data name is generated; the generation duration of the snapshot data name is determined; if the generation duration exceeds the time range of the timer, the mapping information of the snapshot data name is deleted from the mapping data table.
[0148] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: locating the name offset position of the SMB data packet corresponding to the retrieval request, and extracting the target data identifier in the name offset position; locating the extension field offset position of the SMB data packet, and using the value of the TWRP extension field in the extension field offset position as the target timestamp.
[0149] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: after determining target snapshot data based on a target snapshot path, opening the target snapshot data and obtaining a target handle of the target snapshot data; and sending the target handle to a client so that the client can operate on the target snapshot data based on the target handle.
[0150] The computer-readable storage medium involved in this application includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium known in the technical field.
[0151] For descriptions of the relevant portions of the snapshot data retrieval system, device, and computer-readable storage medium provided in the embodiments of this application, please refer to the detailed description of the corresponding portions of the snapshot retrieval method provided in the embodiments of this application, and will not be repeated here. In addition, portions of the above-mentioned technical solutions provided in the embodiments of this application that are consistent with the implementation principles of corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.
[0152] It should also be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0153] The above description of the disclosed embodiments will enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A snapshot data retrieval method, characterized in that: The server where the Samba service is installed includes: Obtaining a retrieval request from a client for target snapshot data, wherein the target snapshot data includes snapshot data obtained through a volume shadow copy service; Determining a target data identifier and a target timestamp in the retrieval request; Determine the target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table; determining the target snapshot data based on the target snapshot path; Among them, also include: Based on the data identifier, determine the parent directory path of the snapshot data; Perform an opendir operation on the parent directory path to obtain a dir handle; Call the readdir interface to read the dir handle and obtain the subdirectories under the parent directory path; Obtaining the extended attribute snapshot time value of each subdirectory based on the getattr interface; Determine a subdirectory path of the subdirectory corresponding to the extended attribute snapshot time value and the timestamp value; Generate a snapshot path based on the parent directory path and the subdirectory path; After determining the target snapshot data based on the target snapshot path, the method further includes: Open the target snapshot data and obtain a target handle of the target snapshot data; Sending the target handle to the client, so that the client uses the target handle to initiate an SMB GETINFO request to obtain attribute information of the snapshot directory, completes the processing and closes the target snapshot, or causes the client to obtain a brief keyword from the target handle of the target snapshot file through an SMBIOCTL operation, determine the target location to be restored, open the target file in overwrite mode if the target file already exists, otherwise open the target file in create mode, and initiate a block copy operation based on the obtained brief keyword of the shadow copy source file and the target handle of the target file handle; Process the block copy operation initiated by the client, complete the reading of the shadow copy source file and the writing of the target file on the server side; respond to two SMB CLOSE requests initiated by the client, and close the shadow copy source file and target file respectively.
2. The method according to claim 1, characterized in that Determining the target snapshot path corresponding to the target data identifier and the target timestamp in the pre-stored mapping data table includes: Combining the target data identifier and the target timestamp in the format of data identifier@GMT-timestamp to obtain the target snapshot data name; In the mapping data table, the target snapshot path corresponding to the target data name is determined.
3. The method according to claim 2, characterized in that Before determining the target snapshot path corresponding to the target data identifier and the target timestamp in the pre-stored mapping data table, the method further includes: Determine the data identifier and timestamp of the snapshot data; Generate a snapshot data name based on the data identifier and the timestamp; Determine the snapshot path corresponding to the snapshot data name; The mapping data table is generated based on the snapshot data name and the snapshot path.
4. The method according to claim 3, characterized in that After generating the mapping data table based on the snapshot data name and the snapshot path, the method further includes: Generate a timer corresponding to the snapshot data name; Determining the generation time of the snapshot data name; If the generation duration exceeds the time range of the timer, the mapping information of the snapshot data name is deleted from the mapping data table.
5. The method according to any one of claims 1 to 4, characterized in that Determining the target data identifier and target timestamp in the search request includes: Locating the name offset position of the SMB data packet corresponding to the search request, and extracting the target data identifier from the name offset position; The extended field offset position of the SMB data packet is located, and the value of the TWRP extended field in the extended field offset position is used as the target timestamp.
6. A snapshot data retrieval system, characterized in that: The server where the Samba service is installed includes: A first acquisition module is configured to acquire a retrieval request from a client for target snapshot data, wherein the target snapshot data includes snapshot data obtained through a volume shadow copy service; A first determining module, configured to determine a target data identifier and a target timestamp in the search request; A second determining module is configured to determine a target snapshot path corresponding to the target data identifier and the target timestamp in a pre-stored mapping data table; a third determining module, configured to determine the target snapshot data based on the target snapshot path; Among them, also include: a second determining unit, configured to determine a parent directory path of the snapshot data based on the data identifier; The first operation unit is used to perform an opendir operation on the parent directory path to obtain a dir handle; The first calling unit is used to call the readdir interface to read the dir handle and obtain each subdirectory under the parent directory path; A first acquiring unit is configured to acquire a snapshot time value of an extended attribute of each subdirectory based on a getattr interface; a third determining unit, configured to determine a subdirectory path of the subdirectory corresponding to the extended attribute snapshot time value and the timestamp value; A third generating unit, configured to generate the snapshot path based on the parent directory path and the subdirectory path; The first opening module is configured to, after the third determining module determines the target snapshot data based on the target snapshot path, open the target snapshot data and obtain a target handle of the target snapshot data; send the target handle to the client so that the client uses the target handle to initiate an SMB GETINFO request to obtain attribute information of the snapshot directory, complete the processing and close the target snapshot, or enable the client to obtain a brief keyword from the target handle of the target snapshot file through an SMB IOCTL operation, determine the target location to be restored, open the target file in overwrite mode if the target file already exists, otherwise open the target file in create mode, initiate a block copy operation based on the obtained brief keyword of the shadow copy source file and the target handle of the target file handle; process the block copy operation initiated by the client, complete the reading of the shadow copy source file and the writing of the target file on the server side; respond to two SMB CLOSE requests initiated by the client, and close the shadow copy source file and the target file respectively.
7. A snapshot data retrieval device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the snapshot data retrieval method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the snapshot data retrieval method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Data processing method and device and shared memory device
CN103544077A