Method for realizing file recycle bin based on NFS-Ganesha
By implementing the file recycle bin function in the VFS layer of NFS-Ganesha, it solves the problem of difficulty in recovering files after deletion in the NFS environment, provides a transparent recycle bin service, improves data security and reduces the risk of data loss, and realizes Quick recovery function after file deletion in NFS environment.
Patent Information
- Application Number
- CN202410971178.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-10-01
AI Technical Summary
In an NFS environment, it is difficult to recover files after they are deleted, and the lack of a built-in recycle bin mechanism results in higher risks of data security and accidental deletion.
The file recycle bin function is implemented in the VFS layer of NFS-Ganesha. Through the FSAL_VFS module and FSAL_RECYCLE_VFS module, it is judged whether to put deleted files or directories into the recycle bin based on the recycle bin configuration information, providing transparent recycle bin services and reducing the impact on server performance. influence.
It implements the function of quickly recovering files after deletion in an NFS environment, improves data security, reduces the risk of data loss, and provides a more robust and secure file service for enterprise-level data storage.
Smart Images

Figure CN118740862A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method for realizing a file recycling station based on NFS-Ganesha, which is a method for computer network storage, file processing and data security. Background Art
[0002] With the rapid development of information technology and the rapid expansion of data volume, data storage and management have become increasingly important. Among many data storage solutions, the Network File System (NFS) is widely used in enterprises and cloud computing environments due to its cross-platform, high efficiency, and easy management. NFS-Ganesha is a user-mode file system that supports protocols such as NFSv3, NFSv4, and NFSv4.1. It interacts with the underlying storage system through the VFS (Virtual File System) layer and supports a variety of back-end storage, such as XFS and Ceph.
[0003] Although NFS provides convenient remote file access, data security and accidental deletion are still issues of great concern to users and enterprises. In traditional file systems, the Recycle Bin mechanism can serve as a buffer layer to protect users from the consequences of accidentally deleting important files. However, in NFS environments, such mechanisms are usually not built-in, and once a file is deleted, even if it is unintentional, it is often difficult to recover it. How to quickly recover deleted files in an NFS environment is a problem that needs to be solved. Summary of the invention
[0004] In order to overcome the problems of the prior art, the present invention proposes a method for implementing a file recycle bin based on NFS-Ganesha. The device and method provide a solution that does not require modification of the client and minimizes the impact on server performance. The recycle bin function will be transparently integrated into the NFS-Ganesha server and can provide services to all NFS clients connected to the server.
[0005] The object of the present invention is achieved as follows: a method for realizing a file recycling bin based on NFS-Ganesha, wherein the system for realizing a file recycling bin based on NFS-Ganesha used in the method comprises: a plurality of NFS clients mounted through the NFS protocol, each of the NFS clients is connected to an NFS-Ganesha server through a network, the NFS-Ganesha server is connected to an XFS file subsystem for performing operations, the NFS-Ganesha server is provided with: an FSAL_VFS module for deleting files and a shared configuration file with recycling bin configuration information, and an FSAL_RECYCLE_VFS module for judging whether the deleted item meets all configurations for being placed in the recycling bin; The shared configuration file includes: Recycle: contains all recycle bin configurations; repository: Set the recycle bin path; keeptree: Set whether to keep the original path when the deleted items are put into the recycle bin; versions: Set whether to rename the deleted item to a new file if there is a file with the same file name when the deleted item is put into the recycle bin; touch_mtime: Set whether to modify the modification time of the file when the deleted item is placed in the recycle bin; minsize: Sets the maximum value of deleted items that can be placed in the Recycle Bin; maxsize: Sets the minimum size of deleted items that can be put into the Recycle Bin; exclude_file: Set the name of the deleted file that cannot be put into the recycle bin; exclude_dir: Set the directory name that cannot be put into the recycle bin; The steps of the method are as follows: Step 1, receiving a file deletion instruction: the NFS client sends a file deletion instruction, and after the NFS-Ganesha client receives the file deletion operation sent by the NFS client, it starts processing on the NFS-Ganesha server; Step 2, determine whether the deletion configuration is met: the NFS-Ganesha server sends the deletion operation to the FSAL_VFS module, the FSAL_VFS module reads the shared configuration file and calls the FSAL_RECYCLE_VFS module, and processes whether the deleted item enters the recycle bin according to the recycle bin configuration information. If "yes", the deleted item is put into the recycle bin, if "no", the file deletion operation is directly executed; The FSAL_RECYCLE_VFS module identification process includes the following sub-steps: Sub-step 1, generating a recycle bin path: generating a recycle bin path and corresponding directories and sub-directories; Sub-step 2, whether it belongs to the recycle bin directory: determine whether the deleted item belongs to the recycle bin directory, if "yes", directly delete the deleted item, if "no", proceed to the next sub-step; Sub-step 3: Is it too large: Determine whether the size of the deleted item is larger than the maximum value allowed by the Recycle Bin. If "yes", delete it directly; if "no", proceed to the next sub-step; Sub-step 4: Is it too small?: Determine whether the size of the deleted item is smaller than the minimum size allowed by the Recycle Bin. If yes, delete it directly. If no, proceed to the next sub-step. Sub-step 5: Whether it is in the exclusion rule: First determine whether the deleted item is a directory or a file. If it is a directory, determine whether the deleted directory is in the exclusion list. If "yes", delete it directly. If "no", go to the next sub-step; if it is not a directory but a file, determine whether the deleted file is in the exclusion list. If "yes", delete it directly. If "no", go to the next sub-step; Sub-step 6: Whether to keep the directory structure: Determine whether the deleted items are put into the recycle bin according to the original directory structure. If "yes", generate a new directory according to the directory structure. If "no", go to the next sub-step; Sub-step 7: Create a Recycle Bin Directory: Check whether the Recycle Bin directory exists. If not, create the Recycle Bin directory. If it does exist, proceed to the next sub-step. Sub-step 8, whether there is the same deleted item: check whether a new version of the same file is generated. If so, determine whether the file exists in the recycle bin. If so, generate a new file name; Sub-step 9, moving deleted items: perform a file rename operation and move the deleted items to the Recycle Bin directory. If the move fails, delete the file directly; Sub-step 10, whether to update access time: check whether to update access time, if "yes" then update the access time of the deleted item, if "no" then go to step 3; Step 3, End: If all the above rules are not met, the file will be deleted directly. If it is met, the deleted item will be retained in the Recycle Bin and the recycling will end.
[0006] The advantages and beneficial effects of the present invention are as follows: The present invention aims to provide a solution that does not require modification of the client and minimizes the impact on server performance by implementing the recycle bin function in the VFS layer of NFS-Ganesha. The NFS-Ganesha server is provided with a recycle bin function, which allows that when a file or directory is deleted, it is not permanently removed but moved to a predefined "recycle bin" directory, so that users or administrators can restore mistakenly deleted files from the recycle bin, thereby improving data security and reducing the risk of data loss. The recycle bin function will be transparently integrated into the NFS-Ganesha server and can provide services for all NFS clients connected to the server, providing a more robust and secure file service solution for enterprise-level data storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0008] Figure 1 is a system block diagram of an embodiment of the present invention to implement the method; Figure 2 It is a schematic diagram of a recycle bin configuration item added to an original NFS_Ganesha configuration file according to the method described in an embodiment of the present invention; Figure 3 It is a roadmap of the method described in the embodiment of the present invention. DETAILED DESCRIPTION
[0009] Embodiment 1: This embodiment is a method for implementing a file recycle bin based on NFS-Ganesha. This embodiment aims to provide a solution that does not require client modification and minimizes the impact on server performance by implementing the recycle bin function at the VFS layer of NFS-Ganesha. The recycle bin function is transparently integrated into the NFS-Ganesha server and can provide services to all NFS clients connected to the server. The system for implementing a file recycle bin based on NFS-Ganesha used in the method is as follows: Figure 1 shown.
[0010] The recycle bin system of the method described in this embodiment includes: multiple NFS clients mounted through the NFS protocol, each of the NFS clients is connected to the NFS-Ganesha server through the network, the NFS-Ganesha server is connected to the XFS file subsystem that performs operations, and the NFS-Ganesha server is provided with: a FSAL_VFS module for deleting files and a shared configuration file with recycle bin configuration information, and a FSAL_RECYCLE_VFS module for determining whether the deleted item meets all configurations for being placed in the recycle bin.
[0011] NFS-Ganesha is a user-mode file system implementation that provides support for the Network File System (NFS) protocol. Compared with traditional kernel-mode NFS implementations, NFS-Ganesha has many significant advantages, making it particularly outstanding in terms of flexibility and convenience.
[0012] First, NFS-Ganesha runs in user space, which means it does not need to be deeply integrated with the kernel, thus avoiding the complexity and risk of modifying the operating system kernel. This design makes NFS-Ganesha easier to update and maintain, and can quickly adapt to new requirements and fix vulnerabilities without having to wait for the operating system kernel to be updated.
[0013] Secondly, NFS-Ganesha supports a variety of backend storage systems, not just traditional file systems. For example, it can be seamlessly integrated with object storage (such as Ceph, Swift), block storage (such as iSCSI), distributed file systems (such as GlusterFS, Lustre), and XFS local file systems. This diverse backend support makes NFS-Ganesha extremely advantageous in heterogeneous storage environments and can meet the complex storage needs of different enterprises.
[0014] The current NFS-Ganesha does not natively support the file recycle bin function. If the recycle bin function interface is implemented for different backend storages, it will not only cause functional overlap, but also increase the complexity of the system. By implementing the recycle bin function at the virtual file system (VFS) layer, a unified interface can be provided to simplify management and reduce redundancy.
[0015] The "deleted items" described in this embodiment include: deleted files or directories.
[0016] Client, NFS Client: Mounts as an NFS client using the NFS protocol.
[0017] The NFS Client does not require additional modification. When a file or directory is deleted (remove) through the client, it will be sent to the NFS Server through the network for processing.
[0018] Server: NFS_Ganesha Server: After the NFS_Ganesha Server receives the file or directory delete (remove) operation sent by the NFS Client, it will process it inside NFS-Ganesha. The specific process is as follows: NFS-Ganesha sends file delete (remove) operations to the existing FSAL_VFS module.
[0019] The shared configuration file of NFS_Ganesha is read in the FSAL_VFS module. If a recycle bin is configured, the custom FSAL_RECYCLE_VFS module is called to process whether the file is entered into the recycle bin or directly deleted according to the recycle bin configuration information. Otherwise, the file deletion (remove) operation is directly performed.
[0020] The custom FSAL_RECYCLE_VFS module mainly compares the incoming file information with the configuration information of the recycle bin one by one to determine whether all the configurations for the file to be placed in the recycle bin are met. If so, the file is placed in the directory of the recycle bin through the rename operation. Otherwise, the file delete (remove) operation in the existing FSAL_VFS module is called to delete the file.
[0021] The XFS file system is a file system that specifically performs operations, and the operation in step 203 will eventually be performed through commands of the XFS file system.
[0022] Customized FSAL_RECYCLE_VFS module: The main function of this module is to perform a series of checks on files. By comparing the file information with the configuration information of the Recycle Bin, if the Recycle Bin configuration information is met, a rename operation is performed to move the file to the Recycle Bin path. Otherwise, a file delete operation is performed to directly delete the file.
[0023] Because the original NFS_Ganesha does not support the function of putting deleted files into the recycle bin, it is necessary to customize the recycle bin configuration item in the original configuration file. Figure 2 Contents shown: The shared configuration file includes: Recycle: contains all recycle bin configurations; repository: Set the recycle bin path; the default is / .recycle.
[0024] keeptree: Set whether to keep the original path when the deleted item is put into the recycle bin; the default value is true.
[0025] versions: Sets whether to rename the deleted item to a new file if there is a file with the same file name when the deleted item is put into the recycle bin; the default is true.
[0026] touch_mtime: Set whether to modify the modification time of the file when the deleted item is placed in the Recycle Bin; the default value is false.
[0027] minsize: Sets the maximum value of deleted items that can be placed in the Recycle Bin. Deleted items larger than this value will not be placed in the Recycle Bin. The default value can be set to 0, which means that all deleted items, including directories or files, will be placed in the Recycle Bin.
[0028] maxsize: Sets the minimum size of deleted items that can be put into the Recycle Bin. Deleted items smaller than this size will not be put into the Recycle Bin. This value can be set to 0 by default, which means that all deleted items, including directories and files, are put into the Recycle Bin.
[0029] exclude_file: Set the name of the deleted file that cannot be put into the recycle bin; This name should support numbers, letters, symbols and wildcards. You can set this file name to be empty by default, that is, all deleted items can be put into the Recycle Bin.
[0030] exclude_dir: Set the directory name that cannot be put into the recycle bin; This name should support numbers, letters, symbols and wildcards. The directory name can be set to empty by default, which means that all directories can be put into the Recycle Bin.
[0031] The steps of the method are as follows: Figure 3 As shown: The method described in this embodiment implements the file recycling bin function of the VFS layer in NFS_ganesha. This recycling bin function describes that deleted files can enter the recycling bin, which is similar to the Windows recycling bin function. Different from the Windows recycling bin function, the method described in this embodiment is implemented on the network, that is, the files or directories are not deleted in the local system, but deleted on the server side of NFS_ganesha, so the NFS_ganesha recycling bin is set on the server side of NFS_ganesha.
[0032] Step 1, receiving a file deletion instruction: the NFS client sends a file deletion instruction, and after the NFS-Ganesha client receives the file deletion operation sent by the NFS client to be deleted, it starts processing on the NFS-Ganesha server.
[0033] The deletion command is issued by the NFS client and needs to be executed by the NFS-Ganesha server.
[0034] Step 2, determine whether the deletion configuration is met: the NFS-Ganesha server sends the deletion operation to the FSAL_VFS module, the FSAL_VFS module reads the shared configuration file and calls the FSAL_RECYCLE_VFS module, and processes whether the deleted item enters the recycle bin according to the recycle bin configuration information. If "yes", the deleted item is placed in the recycle bin, if "no", the file deletion operation is performed directly.
[0035] The FSAL_RECYCLE_VFS module identification process includes the following sub-steps: Sub-step 1, generate the recycle bin path: generate the recycle bin path and the corresponding directories and sub-directories.
[0036] The generated path is as follows: / <repository> / <username>, where "repository" is the basic path set in the recycle bin configuration information, username is converted from "anonuid" in the original configuration, and the recycle bin path variable is tentatively set to: repository.
[0037] Sub-step 2, whether it belongs to the Recycle Bin directory; determine whether the deleted item belongs to the Recycle Bin directory, if "yes" then delete the deleted item directly, if "no" then proceed to the next sub-step.
[0038] If the deleted items passed in are in the directory or subdirectory generated in substep 1, delete the files or directories directly, because files or directories deleted from the Recycle Bin will not be put back into the Recycle Bin.
[0039] Sub-step 3: Is it too large? Determine whether the size of the deleted item is larger than the maximum value allowed by the Recycle Bin. If "yes", delete it directly. If "no", proceed to the next sub-step.
[0040] Based on the file size (obtained from the file attribute st_size), determine whether the file size is larger than the maximum value allowed by the recycle bin (see maxsize in the load configuration). If it is larger, delete the file directly; otherwise, continue.
[0041] Sub-step 4: Is it too small? Determine whether the size of the deleted item is smaller than the minimum size allowed by the Recycle Bin. If "yes", delete it directly. If "no", proceed to the next sub-step.
[0042] Based on the file size (obtained from the file attribute st_size), determine whether the file size is smaller than the minimum value allowed by the recycle bin (see maxsize in the load configuration). If it is smaller, delete the file directly; otherwise, continue.
[0043] Sub-step 5: Whether it is within the exclusion rules: First determine whether the deleted item is a directory or a file. If it is a directory, determine whether the deleted directory is in the exclusion list. If "yes", delete it directly. If "no", go to the next sub-step; if it is not a directory but a file, determine whether the deleted file is in the exclusion list. If "yes", delete it directly. If "no", go to the next sub-step.
[0044] First, determine the file type based on the attributes of the file to see if it is a file or a directory. If it is a directory, determine whether the directory name is in the exclusion list. Otherwise, determine whether the file is in the exclusion list (see exclude_file and exclude_dir in the loading configuration), and then continue. Here you need to implement a custom exclusion matching interface.
[0045] Sub-step 6: Whether to keep the directory structure: Determine whether the deleted items are placed in the Recycle Bin according to the original directory structure. If "yes", generate a new directory according to the directory structure. If "no", go to the next sub-step.
[0046] By reading the configuration value, it is determined whether the deleted project is put into the recycle bin according to the directory structure (see keeptree in loading configuration). If so, a new directory is generated according to the directory structure. The new directory is the concatenation of the recycle bin directory repository and the file directory. Otherwise, the new directory is the recycle bin directory. The new directory variable of the file is temporarily set to: tmp_dir_name, and then continue.
[0047] Sub-step 7: Create a Recycle Bin directory: Check whether the Recycle Bin directory exists. If not, create the Recycle Bin directory. If it exists, proceed to the next sub-step.
[0048] Check whether the new directory (tmp_dir_name) exists. If the directory does not exist, you need to create it and then continue. Here you need to implement a custom directory creation interface.
[0049] Sub-step 8, whether there are identical deleted items: Check whether a new version of the identical file is generated. If so, determine whether the file exists in the Recycle Bin. If so, generate a new file name.
[0050] See versions in the loading configuration. If yes, check whether the file exists in the recycle bin. If yes, generate a new file name. The new file name format is as follows: recycle_## <num> _ <basename>, where num ranges from 1 to 65536, basename is the name of the file, otherwise continue. Here you need to implement a custom interface for generating new file names.
[0051] Sub-step 9, moving deleted items: Execute the file rename operation and move the deleted items to the Recycle Bin directory. If the move fails, delete the file directly.
[0052] Sub-step 10, whether to update the access time: check whether to update the access time, if "yes" then update the access time of the deleted item, if "no" then go to step 3.
[0053] By reading the configuration value: whether to update the file access time (see touch_mtime in loading configuration), if yes, update the file access time, otherwise continue. Here you need to implement a custom interface for updating file access time.
[0054] Step 3, End: If all the above rules are not met, the file will be deleted directly. If it is met, the deleted item will be retained in the Recycle Bin and the recycling will end.
[0055] The deleted items are deleted after the above judgment. Please note that this is to meet the requirements of the NFS-Ganesha server. The above restrictions must be made during the use of the NFS-Ganesha server due to various network requirements.
[0056] Finally, it should be noted that the above is only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred arrangement scheme, a person skilled in the art should understand that the technical solution of the present invention (such as the configuration of the system, special requirements for deleted items, the sequence of steps, etc.) can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.< / basename> < / num> < / username> < / repository>
Claims
1. A method for implementing a file recycle bin based on NFS-Ganesha, wherein the system for implementing a file recycle bin based on NFS-Ganesha used in the method comprises: A plurality of NFS clients mounted via NFS protocol, each of the NFS clients being connected to an NFS-Ganesha server via a network, the NFS-Ganesha server being connected to an XFS file subsystem for performing operations, the NFS-Ganesha server being provided with: an FSAL_VFS module for deleting files, a shared configuration file with recycle bin configuration information, and an FSAL_RECYCLE_VFS module for determining whether the deleted item satisfies all configurations for being placed in the recycle bin; It is characterized in that The shared configuration file includes: Recycle: contains all recycle bin configurations; repository: Set the recycle bin path; keeptree: Set whether to keep the original path when the deleted items are put into the recycle bin; versions: Set whether to rename the deleted item to a new file if there is a file with the same file name when the deleted item is put into the recycle bin; touch_mtime: Set whether to modify the modification time of the file when the deleted item is placed in the recycle bin; minsize: Sets the maximum value of deleted items that can be placed in the Recycle Bin; maxsize: Sets the minimum size of deleted items that can be put into the Recycle Bin; exclude_file: Set the name of the deleted file that cannot be put into the recycle bin; exclude_dir: Set the directory name that cannot be put into the recycle bin; The steps of the method are as follows: Step 1, receiving a file deletion instruction: the NFS client sends a file deletion instruction, and after the NFS-Ganesha client receives the file deletion operation sent by the NFS client, it starts processing on the NFS-Ganesha server; Step 2, determine whether the deletion configuration is met: the NFS-Ganesha server sends the deletion operation to the FSAL_VFS module, the FSAL_VFS module reads the shared configuration file and calls the FSAL_RECYCLE_VFS module, and processes whether the deleted item enters the recycle bin according to the recycle bin configuration information. If "yes", the deleted item is put into the recycle bin, if "no", the file deletion operation is directly executed; The FSAL_RECYCLE_VFS module identification process includes the following sub-steps: Sub-step 1, generating a recycle bin path: generating a recycle bin path and corresponding directories and sub-directories; Sub-step 2, whether it belongs to the recycle bin directory; determine whether the deleted item belongs to the recycle bin directory, if "yes" then delete the deleted item directly, if "no" then proceed to the next sub-step; Sub-step 3: Is it too large: Determine whether the size of the deleted item is larger than the maximum value allowed by the Recycle Bin. If "yes", delete it directly; if "no", proceed to the next sub-step; Sub-step 4: Is it too small?: Determine whether the size of the deleted item is smaller than the minimum size allowed by the Recycle Bin. If yes, delete it directly. If no, proceed to the next sub-step. Sub-step 5: Whether it is in the exclusion rule: First determine whether the deleted item is a directory or a file. If it is a directory, determine whether the deleted directory is in the exclusion list. If "yes", delete it directly. If "no", go to the next sub-step; if it is not a directory but a file, determine whether the deleted file is in the exclusion list. If "yes", delete it directly. If "no", go to the next sub-step; Sub-step 6: Whether to keep the directory structure: Determine whether the deleted items are put into the recycle bin according to the original directory structure. If "yes", generate a new directory according to the directory structure. If "no", go to the next sub-step; Sub-step 7: Create a Recycle Bin Directory: Check whether the Recycle Bin directory exists. If not, create the Recycle Bin directory. If it does exist, proceed to the next sub-step. Sub-step 8, whether there are identical deleted items: check whether a new version of the identical file is generated, if so, determine whether the file exists in the Recycle Bin, if so, generate a new file name; Sub-step 9, moving deleted items: perform a file rename operation and move the deleted items to the Recycle Bin directory. If the move fails, delete the file directly; Sub-step 10, whether to update access time: check whether to update access time, if "yes" then update the access time of the deleted item, if "no" then go to step 3; Step 3, End: If all the above rules are not met, the file will be deleted directly. If it is met, the deleted item will be retained in the Recycle Bin and the recycling will end.
Citation Information
Cited By
Method and equipment for quickly deleting catalogs and files
CN121681475A
