Method and device for eliminating repeated data, storage medium and electronic equipment
By establishing hard links and reverse indexes, the problem of poor flexibility of electronic devices in eliminating duplicate data is solved, independent updates of files are achieved, storage space is saved, and system performance is improved.
Patent Information
- Application Number
- CN202310350085.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2024-10-01
AI Technical Summary
When the existing technology eliminates duplicate data, electronic devices have poor flexibility and cannot independently modify different files, resulting in large storage space usage and performance impact.
By establishing hard links and reverse indexes, two files are allowed to share the same data blocks, and the reverse index is stored in the index node, so that even if the index node of a file is deleted, its independent index node can be restored, realizing the file's Independently updated.
It improves the flexibility of electronic devices to eliminate duplicate data, saves storage space, and allows files to be updated independently, improving user experience and system performance.
Smart Images

Figure CN118732928A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic equipment, and in particular to a method, device, storage medium and electronic equipment for eliminating duplicate data. Background Art
[0002] As the usage time increases, electronic devices store a large number of duplicate files. For example, users may make multiple copies based on a file, so there are files with different file names, which actually contain the same data. These duplicate data occupy a large amount of storage space and are likely to affect the performance of electronic devices. Therefore, the data of one file can be retained and the duplicate data of other files can be eliminated. In the related art, although different files containing the same data can be linked to the data of one file by establishing a hard link, and the duplicate data of other files can be deleted, when the user modifies the data of one file, the data of other files will also be passively modified. That is, in the related art, after deleting the duplicate data, different files cannot be modified independently, so the flexibility of electronic devices to delete duplicate data is poor. Summary of the invention
[0003] The embodiments of the present application provide a method, device, storage medium and electronic device for eliminating duplicate data, which can improve the flexibility of electronic devices in eliminating duplicate data.
[0004] In a first aspect, an embodiment of the present application provides a method for eliminating duplicate data, the method comprising:
[0005] If the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, obtaining a second directory entry of the second file, a second index node of the second file, and a first index node of the first file;
[0006] Establishing a hard link from the second directory entry to the first index node;
[0007] storing a reverse index in the extended information of the first index node, wherein the reverse index points to the second file and includes information of the second directory entry and the second index node;
[0008] The data blocks of the second file and the second index node are deleted.
[0009] In a second aspect, an embodiment of the present application provides a device for eliminating duplicate data, the device comprising:
[0010] an acquisition module, if the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, then acquiring a second directory entry of the second file, a second index node of the second file, and a first index node of the first file;
[0011] A first creation module, used for establishing a hard link from the second directory entry to the first index node;
[0012] A storage module, configured to store a reverse index in the extended information of the first index node, wherein the reverse index points to the second file and includes information of the second directory entry and the second index node;
[0013] A deletion module is used to delete the data block of the second file and the second index node.
[0014] In a third aspect, an embodiment of the present application provides a storage medium on which a computer program is stored. When the computer program is executed on a computer, the computer executes the method provided by the embodiment of the present application.
[0015] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the processor is used to execute the method provided in the embodiment of the present application by calling a computer program stored in the memory.
[0016] In the embodiment of the present application, if the data blocks of the second file are identical to the data blocks of the first file in a one-to-one correspondence, that is, the data of the first file and the second file are repeated, the data blocks of the first file can be retained, and a hard link pointing to the first index node from the second directory entry can be established to correspond the first file and the second file to the first index node, so that the second file can share the data blocks of the first file, and then the data blocks and the second index node of the second file are deleted, thereby saving storage space of the electronic device. Moreover, in the embodiment of the present application, a reverse index pointing to the second file is stored in the first index node, and the reverse index includes information of the second directory item and the second index node. Therefore, even if the second index node is deleted, a new index node of the second file can be restored based on the stored reverse index, and the second directory item can be pointed to the new index node, so that the first file and the second file can be restored to correspond to different index nodes respectively, wherein the first file corresponds to the first index node, and the second file corresponds to the new index node. It can be understood that the first index node and the new index node can correspond to different data blocks as needed. When it is necessary to modify the data of the first file, the data block corresponding to the first index node can be modified independently without synchronously modifying the data block corresponding to the new index node. Similarly, when it is necessary to modify the data of the second file, the data block corresponding to the new index node can be modified independently without synchronously modifying the data block corresponding to the first index node. Therefore, the embodiment of the present application stores a reverse index in the first index node, which provides a basis for the first file and the second file to independently update data, so that the first file and the second file can independently update data. Therefore, the embodiment of the present application can improve the flexibility of electronic devices to eliminate duplicate data. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The technical solution and beneficial effects of the present application will be made apparent by describing in detail the specific implementation modes of the present application in conjunction with the accompanying drawings.
[0018] Figure 1 This is a first flow chart of the method for eliminating duplicate data provided in an embodiment of the present application.
[0019] Figure 2 A schematic diagram of the data structure of a first file and a second file before deduplication of data is provided in an embodiment of the present application.
[0020] Figure 3 A schematic diagram of a first data structure of a first file and a second file after eliminating duplicate data is provided in an embodiment of the present application.
[0021] Figure 4 A second flow chart of the method for eliminating duplicate data provided in the embodiment of the present application. '
[0022] Figure 5 A schematic diagram of modifying data of a first file and data of a second file after eliminating duplicate data provided in an embodiment of the present application.
[0023] Figure 6 A schematic diagram of the data structure of the first file and the second file when the second index node is called after deduplication of data provided in an embodiment of the present application.
[0024] Figure 7 A schematic diagram of a second data structure of a first file and a second file after eliminating duplicate data provided in an embodiment of the present application.
[0025] Figure 8 A schematic diagram of the data structure of multiple files before deduplication provided in an embodiment of the present application.
[0026] Fig. 9 A schematic diagram of the data structure of multiple files after deduplication provided in an embodiment of the present application.
[0027] Fig.10 A schematic diagram of modifying data of multiple files after eliminating duplicate data provided in an embodiment of the present application.
[0028] Fig.11 A first structural diagram of the device for deduplicating data provided in an embodiment of the present application.
[0029] Fig.12 A second structural diagram of the device for deduplicating data provided in an embodiment of the present application.
[0030] Fig.13 A first structural schematic diagram of an electronic device provided in an embodiment of the present application.
[0031] Fig.14 A second structural diagram of an electronic device provided in an embodiment of the present application DETAILED DESCRIPTION
[0032] Please refer to the drawings, where the same component symbols represent the same components. The principle of the present application is illustrated by implementing it in an appropriate computing environment. The following description is based on the illustrated specific embodiments of the present application, which should not be considered as limiting other specific embodiments of the present application that are not described in detail herein.
[0033] It is understandable that the execution subject of the embodiments of the present application may be an electronic device such as a smart phone or a tablet computer.
[0034] See also Figure 1 , Figure 1 This is a schematic diagram of a first process flow of a method for deduplicating data provided by an embodiment of the present application. The process flow of the method for deduplicating data may include:
[0035] In 101, if the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, a second directory entry of the second file, a second index node of the second file, and a first index node of the first file are obtained.
[0036] In 102, a hard link is created from the second directory entry to the first index node.
[0037] As the usage time increases, electronic devices store a large number of duplicate files. For example, users may make multiple copies of a file, resulting in files with different file names that actually contain the same data. These duplicate data take up a lot of storage space and can easily affect the performance of the electronic device. Therefore, it is necessary to eliminate the duplicate data.
[0038] Among them, the data of the file can be stored in units of data blocks. A file can include multiple data blocks. The size of a data block can be, for example, 1KB, 2KB, 4KB, etc. The electronic device can scan the stored files. For example, the data blocks of the files can be scanned and detected. If it is detected that the data blocks of two or more files are one-to-one corresponding to each other, deduplication of data can be triggered.
[0039] When scanning the stored files in the embodiment of the present application, if the data blocks of the second file are identical to the data blocks of the first file in a one-to-one correspondence, the second directory entry of the second file, the second index node of the second file, and the first index node of the first file are obtained.
[0040] Exemplarily, the file names of the first file and the second file may be different, or the file paths in which the first file and the second file are stored may be different, but the first file and the second file contain the same data blocks, and for the user, the same data is returned by accessing the first file or the second file.
[0041] It should be noted that the Linux file system allocates two data structures for each file: inode and dentry. The inode is used to record the file's meta information, such as the inode number, file size, access rights, creation time, modification time, storage address of data blocks, etc. Each inode has a unique inode number, which is the unique identifier of the file. One inode corresponds to one file. The inode is also stored on the disk, so it also occupies storage space.
[0042] A directory entry describes the correspondence between a file name and an index node, as well as the hierarchical association with other directory entries. Multiple directory entries are associated to form a directory structure, but the difference between a directory entry and an index node is that a directory entry is a data structure maintained by the kernel and is not stored on disk, but cached in memory.
[0043] Since the index node uniquely identifies a file and the directory entry records the file name, by establishing hard links from multiple directory entries to the index node, it is possible to use multiple files with different file names to share the data blocks of a file. Therefore, the relationship between directory entries and index nodes can be many-to-one, that is, based on the established hard links, through any file name, you can obtain the index node pointed to by the directory entry, thereby reading the file data corresponding to the index node.
[0044] Please refer to Figure 2 , Figure 2 A schematic diagram of the data structure of a first file and a second file before deduplication of data is provided in an embodiment of the present application.
[0045] For example, the file name of the first file is file A, and the file name of the second file is file B. The index node of file A is inode A, and the index node of file B is inode B. The directory entry of file A is dentry A, and the directory entry of file B is dentry B. Dentry B records the correspondence between file B and inode B, that is, dentry B points to inode B, and inode B stores the data block storage address of file B. When reading file B, the data block storage address of file B can be found according to inode B, and then the data block corresponding to file B can be read from the storage address. Similarly, dentry A records the correspondence between file A and inode A, that is, dentry A points to inode A, and inode A stores the data block storage address of file A. When reading file A, the data block storage address of file A can be found according to inode A, and then the data block corresponding to file A can be read from the storage address.
[0046] In the embodiment of the present application, if the data blocks of the second file are identical to the data blocks of the first file in a one-to-one correspondence, the base file can be determined from the first file or the second file, and the data blocks of the base file can be retained. For example, if the first file is determined to be the base file, the data blocks of the first file are retained, and a hard link pointing to the first index node is established in the second directory entry. Based on the established hard link, the second file can share the data blocks of the first file. Please refer to Figure 3 , Figure 3A schematic diagram of the data structure of the first file and the second file after deduplication is provided for an embodiment of the present application. For example, file A contains 3 data blocks, and file B also contains 3 data blocks. If the 3 data blocks contained in file B correspond to the 3 data blocks contained in file A one-to-one, for example, the 3 data blocks are: data block 1, data block 2 and data block 3, then it can be considered that the data of the first file and the second file are repeated. For example, file A is determined to be the base file, and based on the established hard link, dentry B of file B points to inode A. When reading file B, the data block storage address of file A can be found based on inode A, and then the data block corresponding to file A can be read from the storage address, so that when reading file B or reading file A, the data block of file A can be read. Therefore, based on the established hard link, file B can share the data block of file A.
[0047] In 103, a reverse index is stored in the extended information of the first index node, the reverse index points to the second file, and the reverse index includes information of the second directory entry and the second index node.
[0048] In 104, the data block of the second file and the index node of the second file are deleted.
[0049] In addition to establishing a hard link from the second directory entry to the first index node, in the embodiment of the present application, a reverse index is stored in the extended attributes of the first index node, the reverse index points to the second file, and the reverse index includes information about the second directory entry and the second index node.
[0050] The data blocks of the first file are the same as the data blocks of the second file. By establishing a hard link from the second directory entry to the first index node, when a user accesses the second file, the data blocks of the first file can be accessed. The second file can share the data blocks of the first file. Therefore, the data blocks of the second file can be deleted to save storage space of the electronic device.
[0051] Since the second directory entry points to the first index node, the second directory entry no longer needs to point to the second index node. It is understandable that the index node will also occupy storage space. Therefore, the embodiment of the present application will further delete the second index node of the second file to further release more storage space.
[0052] The reverse index includes the information of the second directory entry and the second index node, that is, before deleting the second index node, the information of the second directory entry and the second index node will be backed up, wherein the information of the index node includes, for example, the index node number, file size, access rights, creation time, modification time, etc. It should be noted that the data block of the second file has been deleted, and the second file and the first file share the same data block, which can also be understood as the address of the data block of the second file is the same as the address of the data block of the first file, therefore, the information of the second index node does not need to include the original data block address of the second file.
[0053] After establishing a hard link from the second directory entry to the first index node, both the first file and the second file are associated with the first index node, so that the first file and the second file can share data blocks. However, in the related art, after deleting the second index node, although the first file and the second file are different files, they always correspond to the same index node. When it is necessary to modify the data of the first file or the second file, essentially the data blocks corresponding to the same index node are modified. Therefore, the first file and the second file can only update data synchronously, and cannot update data independently.
[0054] In the embodiment of the present application, a reverse index pointing to the second file is stored in the first index node, and the reverse index includes information of the second directory entry and the second index node. Therefore, even if the second index node is deleted, a new index node of the second file can be restored based on the reverse index stored in the first index node. For example, the number of the new index node can be the same as the number of the second index node, and the second directory entry can be pointed to the new index node, so that the first file and the second file can be restored to correspond to different index nodes respectively, wherein the first file corresponds to the first index node, and the second file corresponds to the new index node. It can be understood that the first index node and the new index node can correspond to different data blocks as needed. When it is necessary to modify the data of the first file, the data block corresponding to the first index node can be modified independently without synchronously modifying the data block corresponding to the new index node. Similarly, when it is necessary to modify the data of the second file, the data block corresponding to the new index node can be modified independently without synchronously modifying the data block corresponding to the first index node. Therefore, the reverse index stored in the first index node in the embodiment of the present application provides a basis for the first file and the second file to independently update data, so that the first file and the second file can independently update data. Therefore, in the embodiment of the present application, different files can be mapped to the same index node so that different files share the same data, and different files can be restored to correspond to different index nodes as needed, so that different files have a basis for independently updating data. Therefore, the embodiment of the present application can improve the flexibility of electronic devices in eliminating duplicate data.
[0055] Please refer to Figure 4 , Figure 4 A second flow chart of the method for eliminating duplicate data provided in an embodiment of the present application.
[0056] In 201, if the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, a second directory entry of the second file, a second index node of the second file, and a first index node of the first file are obtained.
[0057] In 202, a data block of a first file is set to a read-only state.
[0058] In 203, a hard link is created from the second directory entry to the first index node.
[0059] The data of a file may be stored in units of data blocks. A file may include multiple data blocks. The size of a data block may be, for example, 1KB, 2KB, 4KB, etc. The electronic device may scan the stored files.
[0060] In the embodiment of the present application, the stored files can be scanned, and if the data blocks of the second file are identical to the data blocks of the first file in a one-to-one correspondence, the second directory entry of the second file, the second index node of the second file, and the first index node of the first file are obtained. Among them, the file names of the first file and the second file can be different, or the file paths in which the first file and the second file are stored can be different, but the data blocks contained in the first file and the second file are the same. For the user, by reading the first file or the second file, the same data is returned. For example, file A contains 3 data blocks, and file B also contains 3 data blocks. If the 3 data blocks contained in file B are identical to the 3 data blocks contained in file A in a one-to-one correspondence, for example, the 3 data blocks are: data block 1, data block 2 and data block 3, then it can be considered that the data blocks of file B and file A are identical in a one-to-one correspondence.
[0061] In the embodiment of the present application, if the data blocks of the second file are identical to the data blocks of the first file in a one-to-one correspondence, the second directory entry of the second file, the second index node of the second file, and the first index node of the first file are obtained. Among them, the first directory entry records that the first file corresponds to the first index node, and the first index node stores the data block storage address of the first file, and the second directory entry records that the second file corresponds to the second index node, and the second index node stores the data block storage address of the second file. Please refer to Figure 2 For example, the first file is named file A, the second file is named file B, the data blocks of file A and file B are the same, the index node of file A is inode A, the index node of file B is inode B, the directory entry of file A is dentry A, and the directory entry of file B is dentry B. Then dentry B records the correspondence between file B and inode B, that is, dentry B points to inode B, and inode B stores the data block storage address of file B. When reading file B, the data block storage address of file B can be found according to inode B, and then the data block corresponding to file B can be read from the storage address. Similarly, dentry A records the correspondence between file A and inode A, that is, dentry A points to inode A, and inode A stores the data block storage address of file A. When reading file A, the data block storage address of file A can be found according to inode A, and then the data block corresponding to file A can be read from the storage address.
[0062] Exemplarily, in the embodiment of the present application, if the data blocks of the second file are identical to the data blocks of the first file in a one-to-one correspondence, the base file can be determined from the first file or the second file, and the data blocks of the base file can be retained. For example, if the first file is determined to be the base file, the data blocks of the first file are retained, the data blocks of the first file are set to a read-only state, and then a hard link is established for the second directory entry to point to the first index node. Based on the established hard link, the second file can share the data blocks of the first file. It can be understood that even if the data blocks of the second file are scanned to be identical to the data blocks of the first file in a one-to-one correspondence, if the data blocks of the first file are changed before the hard link is established, then after the hard link is established, the second file shares the data blocks of the first file after the change, that is, the data of the second file will also be passively changed, so the data of the second file cannot be kept consistent before and after the hard link is established. Therefore, in an embodiment of the present application, when the data blocks of the second file are scanned and correspond one-to-one with the data blocks of the first file, in order to ensure that the data blocks of the first file are not updated before the hard link is established, the data blocks of the first file can be set to a read-only state, and then a hard link pointing to the first index node is established in the second directory entry until the hard link is established, and then the data blocks of the first file are restored to a read-write state to ensure that the data of the second file can maintain consistency.
[0063] Please refer to Figure 3 , the data blocks of file A and file B are the same: data block 1, data block 2 and data block 3. For example, determine file A as the basic file, freeze the data blocks of file A, and then create a hard link from dentry B of file B to inodeA. When reading file B, you can find the data block storage address of file A according to inode A, and then read the data block corresponding to file A from the storage address. Therefore, when reading file B or reading file A, you can read the data block of file A. Therefore, based on the established hard link, file B can share the data block of file A.
[0064] In 204, a reverse index is stored in the extended information of the first index node, the reverse index points to the second file, and the reverse index includes information of the second directory entry and the second index node.
[0065] In 205, the data block and the second index node of the second file are deleted.
[0066] In addition to establishing a hard link from the second directory entry to the first index node, in the embodiment of the present application, a reverse index is stored in the extended attributes of the first index node, the reverse index points to the second file, and the reverse index includes information about the second directory entry and the second index node.
[0067] The data blocks of the first file are the same as the data blocks of the second file. By establishing a hard link from the second directory entry to the first index node, when a user accesses the second file, the data blocks of the first file can be accessed. The second file can share the data blocks of the first file. Therefore, the data blocks of the second file can be deleted to save storage space of the electronic device.
[0068] Since the second directory entry points to the first index node, the second directory entry does not need to point to the second index node. It is understandable that the index node will also occupy storage space. Therefore, the embodiment of the present application will further delete the second index node of the second file to further release more storage space. Please continue to refer to Figure 3 , Figure 3 A hard link from dentryB to inodeA is established, and information about dentry B and inode A is stored in the extended attributes of inode A. The data blocks corresponding to inode B and file B are deleted to eliminate duplicate data between file B and file A and save storage space of the electronic device.
[0069] The reverse index includes the information of the second directory entry and the second index node, that is, before deleting the second index node, the information of the second directory entry and the second index node will be backed up, wherein the information of the index node includes, for example, the index node number, file size, access rights, creation time, modification time, etc. It should be noted that the data block of the second file has been deleted, and the second file and the first file share the same data block, which can also be understood as the address of the data block of the second file is the same as the address of the data block of the first file, therefore, the information of the second index node does not need to include the original data block address of the second file.
[0070] In 206, when the data of the first file or the second file is modified, a third index node corresponding to the second file is created according to the reverse index, the number of the third index node is the same as the number of the second index node, and the second directory entry is updated to point to the third index node.
[0071] In 207, the data block to be modified is copied to the second file, the address of the copied data block is stored in the third index node, and the data block to be modified in the first file and / or the data block to be modified in the second file is modified.
[0072] Before deleting the second index node, the embodiment of the present application will store a reverse index pointing to the second file in the extended attribute of the first index node. Therefore, even if the second index node is deleted, when the user needs to modify the first file or the second file independently, the third index node of the second file can be created according to the reverse index stored in the first file index node, and the second directory entry can be updated to point to the third index node, so that the first file and the second file can be restored to be associated with different index nodes respectively, wherein the first file corresponds to the first index node and the second file corresponds to the third index node. Exemplarily, the information of the second index node in the reverse index is, for example, the number of the second index node, the file size, access rights, creation time, modification time and other information, so the number of the created third index node can be the same as the number of the second index node, so that the initial data structure of the second file can be restored.
[0073] When a data block needs to be modified, the data block to be modified can be copied to the second file, the address of the copied data block can be stored in the third index node, and the data block to be modified in the first file and / or the data block to be modified in the second file can be modified. Exemplarily, the embodiment of the present application uses a copy-on-write (COW) method to modify the data block to be modified in the first file and / or the data block to be modified in the second file. Only when the data block is modified, it is necessary to copy the data block to be modified to the second file, and there is no need to copy the data block that does not need to be modified.
[0074] Please refer to Figure 5 , Figure 5 A schematic diagram of modifying the data of a first file and a second file after deduplication is provided in an embodiment of the present application. For example, when a user needs to modify data block 2 of file A, a third index node inode B' having the same number as inode B is created based on dentry B and inode B information stored in inode A, data block 2 is copied, and the address of the copied data block 2 is stored in inode B', so when the user modifies data block 2 of file A to data block 2', data block 2 in file B will not be affected. For another example, when a user needs to modify data block 3 of file B, data block 3 is copied, and the address of the copied data block 3 is stored in inode B', so when the user modifies data block 3 of file B to data block 3', data block 3 in file A will not be affected.
[0075] Therefore, in the embodiment of the present application, if the data of the second file is the same as the data of the first file, the second file and the first file can both be made to correspond to the first index node so that the second file shares the data of the first file, and the data block and the second index node of the second file are deleted to save the storage space of the electronic device. However, when it is necessary to modify the data of the first file and / or the data of the second file, a third index node with the same number as the second index node can be restored according to the reverse index stored in the first index node, and the second directory entry can be pointed to the third index node, so that the first file and the second file can be restored to correspond to different index nodes respectively, wherein the first file corresponds to the first index node and the second file corresponds to the third index node. By copying the data block to be modified and storing the address of the copied data block in the third index node, the first file and the second file respectively include the data blocks to be modified at different addresses, and the data blocks to be modified of the first file and / or the data blocks to be modified of the second file can be modified, that is, the data of the first file and the data of the second file can be updated independently. When one of the files is modified, the other file will not be modified synchronously, thereby improving the flexibility of the electronic device to eliminate duplicate data.
[0076] In one embodiment, after a third index node having the same number as the second index node is recovered based on the reverse index, the second directory entry points to the third index node, and the third index node stores the address of the copied data block. The reverse index is no longer needed, and the reverse index can be deleted from the extended information of the first index node to update the extended information of the first index node.
[0077] In one implementation, after modifying the data blocks to be modified in the first file and / or the data blocks to be modified in the second file, a new first file and a new second file can be obtained. If some data blocks of the new first file and the new second file are the same, the first index node is stored in the extended attribute of the third index node, that is, a dependency relationship between the third index node and the first index node is established, and the first index node and the third index node can store different data block addresses respectively. Please continue to refer to Figure 5For example, file A modifies data block 2 to obtain data block 2', and file B modifies data block 3 to obtain data block 3', but neither file A nor file B modifies data block 1. Then file A and file B still have the same data block 1, and inode A can be stored in the extended attributes of the generated third index node inode B', where the addresses of data block 1, data block 2' and data block 3 are stored in inode A, and the addresses of data block 2 and data block 3' are stored in inode B'. It should be noted that inode B' only needs to store inode A in the extended attributes to establish a dependency relationship between inode B' and inode A. Inode A stores the address of data block 1, and inode B' does not need to store the address of data block 1.
[0078] When reading the new second file, the first storage address of the data block of the new second file that is different from the new first file is searched according to the third index node, and the data block corresponding to the first storage address is read, and the second storage address of the data block of the new second file that is the same as the new first file is searched according to the first index node, and the data block corresponding to the second storage address is read. For example, when the user reads the data of file B, the data of file B includes data block 1, data block 2 and data block 3', and the effective addresses of data block 2 and data block 3' can be found in inode B', so that data block 2 and data block 3' are read, but the effective address of data block 1 cannot be found in inode B', then it is learned from the extended attribute of inode B' that inode B' depends on inode A, and then the effective address of data block 1 is found from inode A, so that data block 1 is read. Exemplarily, the addresses of data blocks can be stored in order in the index node, and the storage address of the first data block in inode A is the address of data block 1.
[0079] In one embodiment, since the first file and the second file can be independently modified in the embodiment of the present application, when the data block to be modified in one of the files is modified, the data block to be modified in the other file will not be modified synchronously. Therefore, after the data block to be modified in the first file and / or the data block to be modified in the second file is modified, the new first file and the new second file correspond to different index nodes and include different data blocks. The new first file and the new second file can be encrypted separately, meeting the requirement of one key for one file, supporting file-level encryption methods, such as the FBE encryption method, and improving the security of the first file and the second file.
[0080] For example, please refer to Figure 2Before deduplication, the first file and the second file are two independent files. You can encrypt the first file and the second file separately to meet the requirement of one key for one file. For example, the key of the first file is Key1 and the key of the second file is Key2. Please refer to Figure 3 After deduplication, the first file and the second file both point to the first index node, and the first file and the second file share the same data block. At this time, the first file and the second file can share the same key, such as Key1. Please refer to Figure 5 When the data of the first file or the second file is modified, the new first file corresponds to the first index node, and the new second file corresponds to the third index node. The new first file and the new second file can be encrypted separately, and the requirement of one file and one key is met. For example, the key of the first file is Key1, and the key of the second file is Key2.
[0081] It should be noted that the embodiments of the present application can modify only the data blocks to be modified of the first file, or can modify only the data blocks to be modified of the second file, or can modify both the data blocks to be modified of the first file and the data blocks to be modified of the second file separately. It can be understood that as long as the data of the first file or the second file is modified, even if the data of the first file or the second file is not changed, the address of the data block of the second file, the hard link of the second directory entry pointing to the first index node, and the extended information of the second index node will change. Therefore, it can be considered that as long as the data of the first file or the second file is modified, a new first file and a new second file will be obtained.
[0082] In one embodiment, the information of the second index node includes the number of the second index node. After deleting the data block of the second file and the second index node, if an instruction to call the second index node is received, a fourth index node corresponding to the second file is created based on the stored second directory entry and the information of the second index node, so that the fourth index node is called, wherein the number of the fourth index node is the same as the number of the second index node, and the data block address stored in the fourth index node is the same as the data block address stored in the first index node.
[0083] It can be understood that the data block of the first file is the same as the data block of the second file. After establishing a hard link of the second directory entry pointing to the first index node and deleting the second index node, although the first file and the second file are different files, they always correspond to the same index node. When an instruction to call the second index node is received, in the related technology, the second index node cannot be found, and thus the relevant information of the second index node cannot be returned normally. That is, after deduplicating data, some historical index nodes are deleted, resulting in the inability to call these deleted historical index nodes normally. For example, when the program calls the second index node, the information of the second index node cannot be returned normally, but the relevant information of the first index node is returned, or it may directly cause the program to run incorrectly. Therefore, the user can perceive that after deduplicating the file, the index node corresponding to the file bag has changed.
[0084] In the present application embodiment, please refer to Figure 6 , Figure 6 A schematic diagram of the data structure of the first file and the second file when the second index node is called after deduplication is provided for an embodiment of the present application. In the embodiment of the present application, a reverse index pointing to the second file is stored in the first index node, and the reverse index includes information of the second directory entry and the second index node. Therefore, even if the second index node is deleted, if an instruction to call the second index node is received, the fourth index node inode B" with the same information as the second index node can be restored based on the stored reverse index, wherein the number of inode B" can be the same as the number of inode B, and the data block address stored in inode B" is the same as the data block address stored in inode A, so that when the instruction to call inode B is received, since the number of inode B" can be the same as the number of inode B, inode B" can be called normally. Therefore, after deduplication, even if some historical index nodes are deleted in the embodiment of the present application, the historical index nodes can be called normally, and the user will not perceive that the corresponding index node has changed after deduplication of the file, thereby improving the user experience.
[0085] It should be noted that the generated fourth index node is stored in the memory. In order to avoid the fourth index node in the memory being cleared after the system is restarted, when the second index node is called again, it is necessary to generate a new fourth index node based on the reverse index of the first index node so that the second index node can be called normally. Therefore, after the fourth index node is generated, it is only necessary to point the second directory entry to the fourth index node, but the reverse index of the first index node can be retained.
[0086] It can be understood that even if the data blocks of the second file are scanned to be identical to the data blocks of the first file in a one-to-one correspondence, the first file is determined to be the base file, and the data blocks of the first file are set to read-only status. However, in order to avoid updates to the data blocks of the first file or the data blocks of the second file during the scanning process, the embodiment of the present application can further compare the data blocks of the second file with the data blocks of the first file one by one again. If it is found that the data blocks of the first file are partially identical to the data blocks of the second file, the first index node is stored in the extended attributes of the second index node; and the data blocks in the second file that are identical to those in the first file are deleted.
[0087] That is, in order to ensure the accuracy of file data, the embodiment of the present application can scan the data blocks of the second file and the data blocks of the first file twice. The first time, the data blocks of the second file are compared one-to-one with the data blocks of the first file. After determining that the data blocks of the second file and the data blocks of the first file are identical one-to-one, the base file is set to a read-only state to freeze the data blocks of the base file, such as freezing the data blocks of the first file. The data blocks of the second file are compared one-to-one with the data blocks of the frozen first file again for the second time. If the second scan finds that the data blocks of the second file are not exactly the same as the data blocks of the frozen first file, the second file can retain data blocks different from the first file, establish a dependency relationship between the second index node and the first index node, and delete the data blocks that are identical to the first file.
[0088] When reading the second file, according to the second index node, the third storage address of the data block of the second file that is different from the first file is searched, and the data block corresponding to the third storage address is read; and according to the first index node, the fourth storage address of the data block of the second file that is the same as the first file is searched, and the data block corresponding to the fourth storage address is read.
[0089] For example, please refer to Figure 7 , Figure 7A second data structure diagram of the first file and the second file after deduplication is provided in an embodiment of the present application. Data block 2 and data block 3 of the second file are the same as those of the first file, but data block 1' of the second file is different from data block 1 of the first file, then data block 2 and data block 3 can be deleted, inode A is stored in inode B, and a dependency relationship between inode B and inode A is established. When a user reads data from file B, where the data from file B includes data block 1', data block 2, and data block 3, the valid address of data block 1' can be found in inode B, thereby reading data block 1, but the valid addresses of data block 2 and data block 3 cannot be found in inode B. From the extended attributes of inode B, it is learned that inode B depends on inode A, and then the valid addresses of data block 2 and data block 3 are found in inode A, thereby reading data block 2 and data block 3. Exemplarily, the addresses of data blocks can be stored in order in the index node, the address of the second data block in inode A is the address of data block 2, and the address of the third data block is the address of data block 3.
[0090] In one embodiment, if it is determined in the first scan that the data block of the second file is partially identical to the data block of the first file, deduplication will not be triggered. Only after it is determined in the first scan that the data block of the second file is identical to the data block of the first file in one-to-one correspondence, deduplication will be triggered, so that the embodiment of the present application can achieve deduplication at the file level. For example, after deleting the data block of the second file, a reverse index pointing to the second file can be stored in the first index node. When reading the second file, it is only necessary to find the address of the data block from the first index node, so that it can not only eliminate duplicate data and save the storage space of the electronic device, but also read the data block of the second file quickly and maintain good system performance. It can be understood that if the data block of the second file is only partially identical to the data block of the first file during the first scan, deduplication is performed, then a large number of files need to be deduplicated, and when reading the file, a large number of files need to find the address of the data block from different index nodes, so that although the storage space of the electronic device is saved, it also leads to slower reading of the file, affecting the performance of the system. It should be noted that, in the embodiment of the present application, even if the data blocks of the first file or the data blocks of the second file are changed during the first scanning process, the same data blocks in the first file and the second file can be eliminated. In addition, the embodiment of the present application adopts a method for eliminating duplicate data at the file level, rather than a method for eliminating duplicate data at the data block level. It can be understood that the method for eliminating duplicate data at the file level only needs to store reverse indexes pointing to the file level. The reverse index has a small amount of data and occupies a small storage space, while the method for eliminating duplicate data at the data block level needs to store reverse indexes pointing to the data block level, that is, it is necessary to maintain reverse indexes for each data block. A large number of reverse indexes also occupy more storage space. When reading a file, it is also necessary to find each data block of the file from a large number of reverse indexes, resulting in a slower reading speed. Therefore, the method for eliminating duplicate data at the file level in the embodiment of the present application can save storage space of the electronic device and read the second file faster.
[0091] It should be noted that the above embodiments are based on the data of the first file and the data of the second file being the same to illustrate the method of eliminating duplicate data. It is understandable that there may be multiple files with the same data in the electronic device, and the embodiments of the present application do not limit the number. For example, there may be 3, 5, 10 files with the same data. For example, please refer to Figure 8 , Fig. 9 and Fig.10 , Figure 8 A schematic diagram of the data structure of multiple files before deduplication provided in an embodiment of the present application, Fig. 9 A schematic diagram of the data structure of multiple files after deduplication provided in an embodiment of the present application, Fig.10A schematic diagram of modifying data of multiple files after eliminating duplicate data provided in an embodiment of the present application.
[0092] If it is determined that the data of multiple files are the same, the basic file is determined from the multiple files, and the data blocks of the basic file are frozen. For example, if the data blocks of the first file, the second file and the third file are exactly the same, the first index node inode A of the first file, the second directory item dentry B of the second file, the second index node inodeB of the second file, the third directory item dentry C of the third file and the third index node inode C of the third file can be obtained. For example, the first file is determined to be the basic file, the data blocks of the first file are frozen, and hard links from dentry B and dentry C to inode A are established respectively, so that the second file and the third file both point to inode A, the data blocks of the first file can be shared, and the first reverse index pointing to the second file and the second reverse index pointing to the third file are stored in the extended attributes of inode A, that is, two reverse indexes are stored in the extended attributes of inode A: 1. Information of dentry B and inode B; 2. Information of dentry C and inode C; the data blocks of the second file and the third file are deleted, and inode B and inode C are deleted to save storage space of the electronic device.
[0093] When modifying the data of the first file, for example, modifying the data block 2 in the first file, create inode B' with the same number as inode B and inode C' with the same number as inode C according to the two reverse indexes stored in inode A, and update dentry B to point to inode B', and update dentry C to point to inode C'; copy the data block 2 to be modified to the second file once, and store the address of the copied data block 2 in inode B', and copy the data block 2 to be modified to the third file again, and store the address of the copied data block 2 in inode C', so that inodeA, inode B', and inode C' correspond to data blocks 2 with different addresses respectively, and modify the data block 2 to be modified in the first file to obtain data block 2', which will not affect the data block 2 in the second file and the data block 2 in the third file.
[0094] When modifying the data of the second file, for example, modifying the data block 3 in the second file, based on the reverse index pointing to the second file stored in inode A, create inode B' with the same information as inode B, and update dentry B to point to inode B', copy the data block 3 to be modified to the second file, store the addresses of the copied data block 3 to inode B', modify the data block 3 to be modified in the second file to obtain data block 3', and will not affect the data block 3 of the first file and the data block 3 of the third file. Similarly, when modifying the data of the third file, for example, modifying the data block 1 in the third file, based on the reverse index pointing to the third file stored in inode A, create inode C' with the same information as inode C, and update dentry C to point to inode C', copy the data block 1 to be modified to the third file, store the addresses of the copied data block 1 to inode C', modify the data block 1 to be modified in the third file to obtain data block 1', and will not affect the data block 1 of the first file. The third file and the first file share data block 1, so the third file will not be affected. That is, if there are multiple files with the same data, the data block to be modified needs to be copied to all other files only when the basic file data needs to be updated, so as to prevent the data blocks of other files from being passively modified. When the data of other files needs to be updated, it is only necessary to copy the data block to be modified to the file to be modified, and the unmodified file can continue to share the data block with the basic file. That is, the embodiment of the present application adopts the copy-on-write (COW) method to modify the data block of the file, so that no duplicate data is generated, saving storage space of the electronic device.
[0095] See also Fig.11 and Fig.12 , Fig.11 This is a schematic diagram of the first structure of the deduplication device provided in the embodiment of the present application. Fig.12 , Fig.12 A second structural diagram of a data deduplication device provided in an embodiment of the present application. The data deduplication device 300 may include an acquisition module 301 , a first creation module 302 , a storage module 303 , and a deletion module 304 .
[0096] The acquisition module 301 is used to: if the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, acquire the second directory entry of the second file, the second index node of the second file, and the first index node of the first file;
[0097] The first creation module 302 is used to: establish a hard link from the second directory entry to the first index node;
[0098] The first storage module 303 is used to: store a reverse index in the extended information of the first index node, the reverse index points to the second file, and the reverse index includes the second directory entry and the information of the second index node;
[0099] The deletion module 304 is used to delete the data block and the second index node of the second file.
[0100] In one implementation, the first creation module 302 may be used to:
[0101] Setting the data block of the first file to a read-only state;
[0102] A hard link is created from the second directory entry to the first index node.
[0103] In one embodiment, the data deduplication device 300 also includes a second creation module 305, which can be used to: when modifying data of the first file or the second file, create a third index node corresponding to the second file according to the reverse index, the number of the third index node is the same as the number of the second index node, and update the second directory entry to point to the third index node; copy the data block to be modified to the second file, store the address of the copied data block to the third index node, and modify the data block to be modified in the first file and / or the data block to be modified in the second file.
[0104] In one embodiment, the second creation module 305 can be used to obtain a new first file and a new second file. The data deduplication device 300 also includes a second storage module 306, which can be used to store the first index node in the extended attribute of the third index node if some data blocks of the new first file are the same as those of the new second file.
[0105] In one embodiment, the data deduplication device 300 also includes a reading module 307, which can be used to: when reading a new second file, find the first storage address of a data block of the new second file that is different from the new first file according to the third index node, and read the data block corresponding to the first storage address; and find the second storage address of a data block of the new second file that is the same as the new first file according to the first index node, and read the data block corresponding to the second storage address.
[0106] In one embodiment, the data deduplication device 300 further includes an encryption module 308, and the encryption module 308 is used to encrypt the new first file and the new second file respectively.
[0107] In one implementation, the deletion module 304 is used to delete the reverse index from the extended information of the first index node.
[0108] In one embodiment, the deduplication data device 300 also includes a third creation module 309, and the third creation module 308 is used to: if an instruction to call the second index node is received, create a fourth index node corresponding to the second file based on the reverse index so that the fourth index node is called, wherein the number of the fourth index node is the same as the number of the second index node, and the data block address stored in the fourth index node is the same as the data block address stored in the first index node.
[0109] In one embodiment, the deduplication device 300 also includes a third storage module 310, which can be used to store the first index node in the extended attribute of the second index node if the data block of the first file is partially identical to the data block of the second file; the deletion module 304 is used to delete the data block in the second file that is identical to the first file.
[0110] In one embodiment, the reading module 306 can be used to: when reading the second file, search for the third storage address of the data block of the second file that is different from the first file according to the second index node, and read the data block corresponding to the third storage address, and search for the fourth storage address of the data block of the second file that is the same as the first file according to the first index node, and read the data block corresponding to the fourth storage address.
[0111] The application embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed on a computer, the computer executes the process in the method for eliminating duplicate data provided in this embodiment.
[0112] An embodiment of the present application also provides an electronic device, including a memory and a processor, wherein the processor is used to execute the process in the method for eliminating duplicate data provided in the present embodiment by calling a computer program stored in the memory.
[0113] For example, the electronic device may be a mobile terminal such as a tablet computer or a smart phone. Fig.13 , Fig.13 A first structural schematic diagram of an electronic device provided in an embodiment of the present application.
[0114] The electronic device 400 may include components such as a memory 402 and a processor 401. Those skilled in the art will appreciate that Figure 5 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0115] The memory 402 may be used to store applications and data. The applications stored in the memory 402 include executable codes. The applications may be composed of various functional modules. The processor 401 executes various functional applications and data processing by running the applications stored in the memory 402. The processor 401 is electrically connected to the memory 402.
[0116] The processor 401 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing applications stored in the memory 402 and calling data stored in the memory 402, thereby monitoring the electronic device as a whole.
[0117] In this embodiment, the processor 401 in the electronic device loads the executable code corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application program stored in the memory 402, thereby executing:
[0118] If the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, obtaining a second directory entry of the second file, a second index node of the second file, and a first index node of the first file;
[0119] Establish a hard link from the second directory entry to the first index node;
[0120] Storing a reverse index in the extended information of the first index node, the reverse index pointing to the second file, and the reverse index including information of the second directory entry and the second index node;
[0121] The data block and the second inode of the second file are deleted.
[0122] See also Fig.14 , Fig.14 A second structural diagram of an electronic device provided in an embodiment of the present application. The electronic device 400 further includes components such as a radio frequency circuit 403, a display screen 404, a control circuit 405, an input unit 406, an audio circuit 407, a sensor 408, and a power supply 409. The processor 401 is electrically connected to the radio frequency circuit 403, the display screen 404, the control circuit 405, the input unit 406, the audio circuit 407, the sensor 408, and the power supply 409, respectively.
[0123] The radio frequency circuit 403 is used to send and receive radio frequency signals to communicate with network devices or other electronic devices through wireless communication.
[0124] The display screen 404 may be used to display information input by a user or information provided to a user and various graphical user interfaces of the electronic device. These graphical user interfaces may be composed of images, texts, icons, videos and any combination thereof.
[0125] The control circuit 405 is electrically connected to the display screen 404 and is used to control the display screen 404 to display information.
[0126] The input unit 406 can be used to receive input numbers, character information or user feature information (such as fingerprints), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. The input unit 406 can include a fingerprint recognition module.
[0127] The audio circuit 407 can provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 407 includes a microphone. The microphone is electrically connected to the processor 401. The microphone is used to receive voice information input by the user.
[0128] The sensor 408 is used to collect external environment information. The sensor 408 may include one or more sensors such as an environment brightness sensor, an acceleration sensor, and a gyroscope.
[0129] The power supply 409 is used to supply power to various components of the electronic device 400. In some embodiments, the power supply 409 may be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, power consumption, and other functions.
[0130] Although not shown in the figure, the electronic device 400 may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0131] In this embodiment, the processor 401 in the electronic device 400 will load the executable code corresponding to the process of one or more applications into the memory 402 according to the following instructions, and the processor 401 will run the application stored in the memory 402 to execute:
[0132] If the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, obtaining a second directory entry of the second file, a second index node of the second file, and a first index node of the first file;
[0133] Establish a hard link from the second directory entry to the first index node;
[0134] Storing a reverse index in the extended information of the first index node, the reverse index pointing to the second file, and the reverse index including information of the second directory entry and the second index node;
[0135] The data block and the second inode of the second file are deleted.
[0136] In one implementation, in establishing a hard link from the second directory entry to the first index node, the processor 401 sets the data block of the first file to a read-only state; and establishes a hard link from the second directory entry to the first index node.
[0137] In one embodiment, after the information of the second index node includes the number of the second index node and the data block of the second file and the second index node are deleted, the processor 401 executes when modifying the data of the first file or the data of the second file, creating a third index node corresponding to the second file according to the reverse index, the number of the third index node is the same as the number of the second index node, and updating the second directory entry to point to the third index node; copying the data block to be modified to the second file, storing the address of the copied data block to the third index node, and modifying the data block to be modified in the first file and / or the data block to be modified in the second file.
[0138] In one embodiment, after modifying the data blocks to be modified in the first file and / or the data blocks to be modified in the second file, the processor 401 executes to obtain a new first file and a new second file; if the new first file is identical to some data blocks of the new second file, the first index node is stored in the extended attribute of the third index node.
[0139] In one embodiment, after storing the first index node in the extended attribute of the third index node, the processor 401 executes, when reading the new second file, searching for the first storage address of the data block of the new second file that is different from the new first file according to the third index node, and reading the data block corresponding to the first storage address, and searching for the second storage address of the data block of the new second file that is the same as the new first file according to the first index node, and reading the data block corresponding to the second storage address.
[0140] In one implementation, after creating the third index node corresponding to the second file, the processor 401 deletes the reverse index from the extended information of the first index node.
[0141] In one embodiment, the information of the second index node includes the number of the second index node. After deleting the data block and the second index node of the second file, if the processor 401 receives an instruction to call the second index node, it creates a fourth index node corresponding to the second file according to the reverse index so that the fourth index node is called, wherein the number of the fourth index node is the same as the number of the second index node, and the data block address stored in the fourth index node is the same as the data block address stored in the first index node.
[0142] In one embodiment, after deleting the data block and the second index node of the second file, the processor 401 executes if the data block of the first file is partially identical to the data block of the second file, storing the first index node in the extended attribute of the second index node; and deleting the data block in the second file that is identical to the first file.
[0143] In one embodiment, after deleting the data blocks in the second file that are identical to those in the first file, the processor 401 executes, when reading the second file, searching, according to the second index node, for the third storage address of the data blocks of the second file that are different from those in the first file, and reading the data blocks corresponding to the third storage address, and searching, according to the first index node, for the fourth storage address of the data blocks of the second file that are identical to those in the first file, and reading the data blocks corresponding to the fourth storage address.
[0144] In the above embodiments, the description of each embodiment has its own emphasis. For the part that is not described in detail in a certain embodiment, please refer to the detailed description of the method for eliminating duplicate data above, and will not be repeated here.
[0145] The deduplication device provided in the embodiment of the present application belongs to the same concept as the deduplication method in the above embodiment. Any method provided in the deduplication method embodiment can be run on the deduplication device. The specific implementation process is detailed in the deduplication method embodiment, which will not be repeated here.
[0146] It should be noted that, for the deduplication method of the embodiment of the present application, ordinary technicians in the field can understand that the whole or part of the process of the deduplication method of the embodiment of the present application can be completed by controlling the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, such as a memory, and executed by at least one processor, and the execution process may include the process of the embodiment of the deduplication method. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), etc.
[0147] For the deduplication device of the embodiment of the present application, each functional module can be integrated into a processing chip, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of software functional modules. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium, such as a read-only memory, a disk or an optical disk.
[0148] The above is a detailed introduction to the method, device, storage medium and electronic device for eliminating duplicate data provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for eliminating duplicate data, characterized in that: The method comprises: If the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, obtaining a second directory entry of the second file, a second index node of the second file, and a first index node of the first file; Establishing a hard link from the second directory entry to the first index node; storing a reverse index in the extended information of the first index node, wherein the reverse index points to the second file and includes information of the second directory entry and the second index node; The data blocks of the second file and the second index node are deleted.
2. The method for eliminating duplicate data according to claim 1, characterized in that: The step of establishing a hard link from the second directory entry to the first index node includes: Setting the data block of the first file to a read-only state; A hard link is created from the second directory entry to the first index node.
3. The method for eliminating duplicate data according to claim 1, characterized in that: The information of the second index node includes the number of the second index node. After deleting the data block of the second file and the second index node, the method further includes: When data of the first file or the second file is modified, a third index node corresponding to the second file is created according to the inverted index, the number of the third index node is the same as the number of the second index node, and the second directory entry is updated to point to the third index node; The data block to be modified is copied to the second file, the address of the copied data block is stored in the third index node, and the data block to be modified in the first file and / or the data block to be modified in the second file is modified.
4. The method for eliminating duplicate data according to claim 3, characterized in that: After modifying the data block to be modified in the first file and / or the data block to be modified in the second file, the method further includes: Obtain a new first file and a new second file; If some data blocks of the new first file are identical to those of the new second file, the first index node is stored in the extended attribute of the third index node.
5. The method for eliminating duplicate data according to claim 4, characterized in that: After storing the first index node in the extended attribute of the third index node, the method further includes: When reading the new second file, according to the third index node, the first storage address of the data block of the new second file that is different from the new first file is searched, and the data block corresponding to the first storage address is read; and according to the first index node, the second storage address of the data block of the new second file that is the same as the new first file is searched, and the data block corresponding to the second storage address is read.
6. The method for eliminating duplicate data according to claim 3, characterized in that: After modifying the data block to be modified in the first file and / or the data block to be modified in the second file, the method further includes: Obtain a new first file and a new second file; The new first file and the new second file are encrypted respectively.
7. The method for eliminating duplicate data according to claim 3, characterized in that: After creating the third index node corresponding to the second file, the method further includes: The reverse index is deleted from the extended information of the first index node.
8. The method for eliminating duplicate data according to claim 1, characterized in that: The information of the second index node includes the number of the second index node. After deleting the data block of the second file and the second index node, the method further includes: If an instruction to call the second index node is received, a fourth index node corresponding to the second file is created according to the reverse index so that the fourth index node is called, wherein the number of the fourth index node is the same as the number of the second index node, and the data block address stored in the fourth index node is the same as the data block address stored in the first index node.
9. The method for eliminating duplicate data according to claim 1, characterized in that: After deleting the data block and the second index node of the second file, the method further includes: If the data block of the first file is partially identical to the data block of the second file, storing the first index node in the extended attribute of the second index node; Delete the data blocks in the second file that are identical to those in the first file.
10. The method for eliminating duplicate data according to claim 9, characterized in that: After deleting the data blocks in the second file that are identical to those in the first file, the method further includes: When reading the second file, according to the second index node, the third storage address of the data block of the second file that is different from the first file is searched, and the data block corresponding to the third storage address is read; and according to the first index node, the fourth storage address of the data block of the second file that is the same as the first file is searched, and the data block corresponding to the fourth storage address is read.
11. A device for eliminating duplicate data, characterized in that: The device comprises: an acquisition module, if the data blocks of the second file are identical to the data blocks of the first file in one-to-one correspondence, then acquiring a second directory entry of the second file, a second index node of the second file, and a first index node of the first file; A first creation module, used for establishing a hard link from the second directory entry to the first index node; A storage module, configured to store a reverse index in the extended information of the first index node, wherein the reverse index points to the second file and includes information of the second directory entry and the second index node; A deletion module is used to delete the data block of the second file and the second index node.
12. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed on a computer, the computer is caused to execute the method according to any one of claims 1 to 10.
13. An electronic device, comprising a memory and a processor, characterized in that: The processor is configured to execute the method according to any one of claims 1 to 10 by calling the computer program stored in the memory.
