An electronic device-based file search method and apparatus

By obtaining the hash value and inode number of the first information block of a file in an electronic device, and combining this with the load conditions, duplicate file search and deduplication are performed. This solves the problems of slow file deduplication speed and device lag in existing technologies, improves search and deduplication efficiency, and enhances user experience.

CN116821076BActive Publication Date: 2026-07-24HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210283183.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-22
Publication Date
2026-07-24
Estimated Expiration
2042-03-22

AI Technical Summary

Technical Problem

Existing technologies are slow in deduplication and do not take into account device load, resulting in a poor user experience.

Method used

By obtaining the hash value of the first information block of the file and combining it with the load of the electronic device, the hash value and inode number of the current file are obtained under heavy load, and the hash value and inode number of the stored file are obtained under light load. The corresponding relationship is stored using a key-value table to improve the efficiency of finding duplicate files and perform deduplication.

Benefits of technology

It improves the speed of finding duplicate files, enhances file deduplication efficiency, avoids device lag under heavy load, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116821076B_ABST
    Figure CN116821076B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a file searching method and device based on an electronic device, which can improve the searching speed of duplicate files and the efficiency of file deduplication. Specifically, the method comprises: determining the load degree of the electronic device; when it is determined that the load is heavy, obtaining a first hash value of a current read / write file and an inode number of the current read / write file; when it is determined that the load is light, obtaining a second hash value of at least one file stored in the electronic device and an inode number of the at least one file; wherein the first hash value is the hash value of the first information block of the current read / write file, and is used for the electronic device to search for duplicate files with the same first hash value; and the second hash value is the hash value of the first information block of the at least one file, and is used for the electronic device to search for duplicate files with the same second hash value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic technology, and more specifically, to a method and apparatus for file searching based on electronic devices. Background Technology

[0002] Mobile devices and similar devices store a large number of files. Some of these files are identical, causing duplicate files to repeatedly occupy storage space. Therefore, it's necessary to remove these duplicate files, a process known as file deduplication. Typically, file deduplication involves calculating the hash values ​​of multiple files, which is relatively slow. Summary of the Invention

[0003] This application provides a file search method and apparatus based on electronic devices, which can improve the search speed for duplicate files and improve the efficiency of file deduplication.

[0004] Firstly, a file search method based on an electronic device is provided, comprising: the electronic device determining its load level; when the load level of the electronic device is determined to be heavy, the electronic device obtains a first hash value of the currently read / written file and the inode number of the currently read / written file; when the load level of the electronic device is determined to be light, the electronic device obtains a second hash value of at least one file stored in the electronic device and the inode number of the at least one file; wherein, the first hash value is the hash value of the first information block of the currently read / written file, and is used by the electronic device to find duplicate files with the same first hash value; the second hash value is the hash value of the first information block of the at least one file, and is used by the electronic device to find duplicate files with the same second hash value. This method improves the efficiency of finding duplicate files by obtaining the hash value of the first information block of the file and the inode number of the file, and further improves the efficiency of file deduplication when the obtained data is used for deduplication by the electronic device. Simultaneously, by considering the load of the electronic device during file search, it avoids situations such as electronic device lag caused by deduplication under heavy load, thus improving the user experience.

[0005] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device determines its load level by: within a first time window, the electronic device calculates the amount of information read / written from the file to determine its load level. This method considers the load level of the electronic device within the first time window, facilitating file searching at appropriate search nodes, avoiding lag caused by deduplication, and improving the user experience.

[0006] In conjunction with the first aspect, in some implementations of the first aspect, when the load level of the electronic device is determined to be heavy load, the electronic device obtains the first hash value and the inode number of the currently read / written file, including: the electronic device obtains the inode number of the currently read / written file based on the filename of the currently read / written file; the electronic device reads or calculates the first hash value of the currently read / written file based on the inode number of the currently read / written file; and the electronic device stores the correspondence between the inode number and the first hash value of the currently read / written file. By obtaining the correspondence between the inode number and the first hash value of the currently read / written file under heavy load, the electronic device can find the corresponding file inode number based on the first hash value, thereby finding the specific data information of the file. Since files with the same first hash value are more likely to be duplicated, the efficiency of finding duplicate files is improved, facilitating the subsequent deduplication of duplicate files. Furthermore, under heavy load, considering the operating status of the electronic device, relevant information of the currently read / written file is statistically analyzed, reducing the possibility of electronic device lag and improving the user experience.

[0007] In conjunction with the first aspect, in some implementations of the first aspect, when the load level of the electronic device is determined to be light, the electronic device obtains the second hash value and the inode number of at least one file stored in the electronic device, including: the electronic device reading or calculating the inode number and the second hash value of the at least one file; and the electronic device storing the correspondence between the inode number and the second hash value of the at least one file. By obtaining the correspondence between the inode number and the second hash value of one or more files stored by the electronic device under light load, the corresponding file inode number can be found based on the second hash value, thereby finding the specific data information of the file. Since files with the same second hash value are more likely to be duplicated, the efficiency of finding duplicate files is improved, facilitating the subsequent deduplication of duplicate files. Furthermore, traversing the storage space of the electronic device under light load avoids large-scale search operations under heavy load, reduces the possibility of electronic device lag, and improves the user experience.

[0008] In conjunction with the first aspect, in certain implementations of the first aspect, the electronic device storing the correspondence between the inode number of the currently read / written file and the first hash value of the currently read / written file includes: the electronic device storing the correspondence between the inode number of the currently read / written file and the first hash value of the currently read / written file in a key-value table. Storing the above correspondence through a key-value table clearly represents the correspondence, facilitating subsequent lookups by the electronic device.

[0009] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device storing the correspondence between the inode numbers of the at least one file and the second hash values ​​of the at least one file includes: the electronic device storing the correspondence between the inode numbers of the at least one file and the second hash values ​​of the at least one file in a key-value table. Storing the above correspondence through a key-value table makes the correspondence clear and facilitates subsequent lookups by the electronic device.

[0010] In conjunction with the first aspect, in some implementations of the first aspect, the first time window is determined by the electronic device based on global variables. By defining the first time window based on global variables, the overall performance of the electronic device is taken into account, making it easier for the electronic device to select appropriate nodes to search for duplicate files, thereby improving the efficiency of duplicate file search.

[0011] In conjunction with the first aspect, in some implementations of the first aspect, when at least two files have the same first hash value, the electronic device determines that at least two files with the same first hash value are duplicate files; when at least two files have the same second hash value, the electronic device determines that at least two files with the same second hash value are duplicate files.

[0012] In conjunction with the first aspect, in some implementations of the first aspect, the first hash value and / or the second hash value are used by the electronic device to deduplicate the duplicate files.

[0013] Secondly, a file search device based on an electronic device is provided. The device includes: a first processing unit for determining the load level of the electronic device; a second processing unit for obtaining a first hash value of a currently read / written file and the inode number of the currently read / written file when the load level of the electronic device is determined to be heavy; and a third processing unit for obtaining a second hash value of at least one file stored in the electronic device and the inode number of the at least one file when the load level of the electronic device is determined to be light; wherein the first hash value is the hash value of the first information block of the currently read / written file, and is used by the electronic device to search for duplicate files with the same first hash value; the second hash value is the hash value of the first information block of the at least one file, and is used by the electronic device to search for duplicate files with the same second hash value.

[0014] In conjunction with the second aspect, in some implementations of the second aspect, the first processing unit is used to determine the load level of the electronic device. Specifically, the first processing unit is used to: within a first time window, the electronic device calculates the amount of information read / written from the file to determine the load level of the electronic device.

[0015] In conjunction with the second aspect, in some implementations of the second aspect, the second processing unit is used to obtain the first hash value of the currently read / write file and the inode number of the currently read / write file when it is determined that the load level of the electronic device is heavy load. Specifically, the second processing unit is used to: obtain the inode number of the currently read / write file according to the file name of the currently read / write file; read or calculate the first hash value of the currently read / write file according to the inode number of the currently read / write file; and save the correspondence between the inode number of the currently read / write file and the first hash value of the currently read / write file.

[0016] In conjunction with the second aspect, in some implementations of the second aspect, the third processing unit is used to obtain the second hash value of at least one file stored in the electronic device and the inode number of the at least one file when it is determined that the load level of the electronic device is light. Specifically, the third processing unit is used to: read or calculate the inode number of the at least one file and the second hash value of the at least one file; and save the correspondence between the inode number of the at least one file and the second hash value of the at least one file.

[0017] In conjunction with the second aspect, in some implementations of the second aspect, the second processing unit is used to store the correspondence between the inode number of the currently read / write file and the first hash value of the currently read / write file. Specifically, the second processing unit is used to: store the correspondence between the inode number of the currently read / write file and the first hash value of the currently read / write file into a key-value table.

[0018] In conjunction with the second aspect, in some implementations of the second aspect, the third processing unit is used to store the correspondence between the inode number of the at least one file and the second hash value of the at least one file. Specifically, the third processing unit is used to: store the correspondence between the inode number of the at least one file and the second hash value of the at least one file into a key-value table.

[0019] In conjunction with the second aspect, in some implementations of the second aspect, the first time window is determined based on global variables.

[0020] In conjunction with the second aspect, in some implementations of the second aspect, when at least two files have the same first hash value, the at least two files with the same first hash value are determined to be duplicate files; when at least two files have the same second hash value, the at least two files with the same second hash value are determined to be duplicate files.

[0021] In conjunction with the second aspect, in some implementations of the second aspect, the first hash value and / or the second hash value are used by the electronic device to deduplicate the duplicate files.

[0022] Thirdly, an electronic file retrieval device is provided, comprising at least one processor coupled to at least one memory, the at least one processor being configured to execute a computer program or instructions stored in the at least one memory to cause the device to perform the method described in the first aspect or any implementation thereof.

[0023] Fourthly, a chip is provided, including a processor and a communication interface, the communication interface being used to receive data and / or information and to transmit the received data and / or information to the processor, the processor processing the data and / or information according to the method described in the first aspect or any implementation thereof.

[0024] Fifthly, a computer-readable medium is provided that stores program code, which, when executed on a computer, causes the computer to perform the methods described in the first aspect or any possible execution method of the first aspect. Such computer-readable storage includes, but is not limited to, one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), flash memory, electrically EPROM (EEPROM), and hard drive.

[0025] In a sixth aspect, a computer program product is provided, comprising: computer program code, which, when run on a computer, causes the computer to perform the method described in the first aspect or any possible execution thereof. Attached Figure Description

[0026] Figure 1 This is a schematic diagram of the system architecture of an electronic device according to an embodiment of this application.

[0027] Figure 2 This is a schematic flowchart of a file search method based on an electronic device provided in an embodiment of this application.

[0028] Figure 3 This is a schematic flowchart of a file search method based on an electronic device provided in an embodiment of this application.

[0029] Figure 4 This is a schematic diagram of a module architecture for file searching based on an electronic device, provided in an embodiment of this application.

[0030] Figure 5 This is a schematic structural diagram of a file search device based on an electronic device provided in an embodiment of this application.

[0031] Figure 6 This is a schematic diagram of the hardware structure of a file search device based on an electronic device provided in an embodiment of this application. Detailed Implementation

[0032] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0033] Figure 1 A schematic diagram of a system architecture for an electronic device applicable to embodiments of this application is shown. For example... Figure 1As shown, the system architecture 100 of this electronic device includes an application program 101 in user space and a file system 102 and a disk 103 in kernel space. The application program 101 interacts with the user and has a visual user interface; the file system 102 manages and accesses the data required by the user, and therefore can interact with the application program; the disk 103 records relevant user data, and through the interaction between the file system and the disk, the disk can record relevant user data. The user can directly interact with the application program, while the file system and disk can indirectly manage and access the user's relevant data.

[0034] It should be understood that electronic devices with the above system architecture can be user equipment. Specifically, user equipment can be handheld devices with wireless communication capabilities, computing devices, in-vehicle devices, wearable devices, etc. For example, it can be a mobile phone, tablet computer, laptop computer, or other devices. This application does not limit this.

[0035] For ease of understanding, the relevant terms involved in the embodiments of this application are explained and described by way of example below. It should be understood that the following content is also included within the scope of protection claimed by the embodiments of this application.

[0036] A file system is a software component in an operating system responsible for managing and storing file information. Specifically, it's responsible for creating files for users, storing, reading, modifying, and dumping files, controlling file access, and deleting files when no longer needed. In other words, a file system primarily manages and stores file data and metadata. Most file systems allocate storage space for files or directories using an inode + datablock method. The inode stores the file or directory's metadata and its data block number, while the corresponding data blocks store the file or directory's content. Each file or directory has an inode, and the number of data blocks required depends on the file size.

[0037] An inode is a data structure in many Unix-like file systems that stores metadata about a file system object, but does not include the data content itself. This metadata, also known as inode information, primarily describes data attributes and supports functions such as indicating storage location, historical data, resource lookup, and file records. For example, metadata may include the hash value of the data.

[0038] Inode number: An inode number corresponds to a file. Even if the file name changes, the inode number remains the same. Since the system uses the inode number to find data internally, it can still find the data correctly even when the file name changes.

[0039] The inode table records the storage location of a file's inode on the disk. For example, the inode table includes the correspondence between inode numbers and file inodes, allowing you to find a file's inode using its inode number.

[0040] Hash value: A hash value can be calculated for a piece of data through a hash algorithm, similar to a data ID card. When two pieces of data have the same hash value, the two pieces of data are likely to be the same. Therefore, unlike the prior art, in the method and apparatus provided in the embodiments of this application, the hash value can be used to determine whether two pieces of data are the same, so as to find duplicate files.

[0041] Daemon threads: A thread is the smallest unit of computation that an operating system can schedule. It is contained within a process and is the actual unit of operation within a process. A thread refers to a single, sequential flow of control within a process. A process can have multiple threads running concurrently, each performing a different task. Daemon threads are special threads, typically used to provide services to other threads in the background.

[0042] When searching for file data on a disk through the file system, the file system first finds the inode number corresponding to the file name; then, it obtains the inode information of the file through the inode number and the inode table; finally, based on the inode information, it finds the data block where the file is located and reads the data.

[0043] Mobile devices often contain numerous files, some of which are identical but occupy valuable storage space. Therefore, deduplication is necessary. One approach is through the file system. However, file system deduplication typically involves calculating the hash value of the entire file, resulting in slow speeds. Furthermore, it doesn't consider device load, performing duplicate data searches on critical I / O paths, negatively impacting user experience.

[0044] Therefore, this application proposes a file search method based on electronic devices. By obtaining the hash value of the first information block of a file, duplicate files are searched, thereby removing duplicate files and improving the speed of duplicate file search. At the same time, the load of the electronic device is taken into account during the search, avoiding device lag caused by deduplication when the load is heavy, thus improving the user experience.

[0045] Figure 2 This illustration shows a schematic flowchart of a file search method based on an electronic device according to an embodiment of this application. Specifically, the method 200 includes:

[0046] S201, Electronic device determines the load level of the electronic device.

[0047] In one possible implementation, the electronic device can be a user device that manages files through a file system, such as a mobile phone or a tablet computer.

[0048] In this embodiment of the application, the first module in the electronic device can be used to determine whether the load level of the electronic device is light load or heavy load.

[0049] It should be understood that the first module can be a software module in an electronic device. For example, the first module can be a software module in a file system of an electronic device, or it can be a software module in an external component of a file system of an electronic device.

[0050] In the embodiments of this application, the first module may be called a load sensing module, or the first module may have other names, which are not limited in this application.

[0051] In one possible implementation, the electronic device can determine its load level by calculating the amount of information read / written by the electronic device within a first time window.

[0052] In this embodiment of the application, the electronic device can: determine the load level as light load when both the amount of information read and the amount of information written to the file by the electronic device are less than a first threshold value.

[0053] In this embodiment of the application, the electronic device can: determine the load level as a write heavy load when the amount of information read by the electronic device is less than a first threshold and the amount of information written by the electronic device is greater than or equal to the first threshold, and vice versa; determine the load level as a read / write heavy load when the amount of information read and written by the electronic device is greater than or equal to the first threshold.

[0054] In one possible implementation, the load level is determined to be read-heavy when the amount of information read by the electronic device is greater than or equal to a first threshold; and the load level is determined to be write-heavy when the amount of information written by the electronic device is greater than or equal to a second threshold. The first and second thresholds are different.

[0055] In another possible implementation, the load level can be determined as heavy load when the sum of the amount of information read and written by the electronic device is greater than or equal to a first threshold, and otherwise as light load. For example, when the sum of the number of times the file is read and the number of times it is written is greater than or equal to 100, the load level of the electronic device can be determined as heavy load.

[0056] It should be understood that write heavy load, read heavy load, and read / write heavy load can all be referred to as heavy load.

[0057] In the embodiments of this application, the amount of information that the electronic device reads / writes can be determined based on the number and size of the files being read / written.

[0058] In this embodiment, the first time window can be determined by the electronic device based on global variables. For example, it can be 5 seconds or 10 seconds.

[0059] S202, when it is determined that the load level of the electronic device is heavy load, the electronic device obtains the first hash value of the currently read / write file and the inode number of the currently read / write file. The first hash value is the hash value of the first information block of the currently read / write file, and is used by the electronic device to find duplicate files with the same first hash value.

[0060] In this embodiment of the application, when the load level of the electronic device is determined to be heavy load, the second module of the electronic device can be used to obtain the first hash value of the currently read / write file and the inode number of the currently read / write file. Then, the second module saves the first hash value to the inode of the electronic device and sends the first hash value and the inode number of the currently read / write file to the fourth module. The fourth module saves the first hash value of the currently read / write file and the inode number of the currently read / write file.

[0061] In the embodiments of this application, the second module and the fourth module can be software modules in an electronic device. For example, the second module and the fourth module can be software modules in a file system of an electronic device, or, for example, software modules in an external component of a file system of an electronic device. In the embodiments of this application, the second module can be called a front-end duplicate file search module, and the fourth module can be a deduplicatable information recording module, or the second module and the fourth module can have other names, which are not limited in this application.

[0062] In one possible implementation, the electronic device can obtain the inode number of the file being read / written based on its filename. Then, based on the inode number, it reads or calculates the first hash value of the file, and finally, the electronic device saves the correspondence between the inode number and the first hash value.

[0063] In this embodiment, the method by which the electronic device reads or calculates the first hash value of the currently read / written file based on the inode number of the file being read / written can be as follows: For reading a file, the second module of the electronic device determines whether the first hash value of the currently read file exists. If it exists, the second module of the electronic device reads the first hash value; if it does not exist, the second module of the electronic device calculates the first hash value. For writing a file, the second module of the electronic device can calculate the first hash value. In this embodiment, after the electronic device calculates the first hash value, it can save the first hash value to the inode.

[0064] In another possible implementation, the electronic device may not calculate the first hash value of the currently read / written file. If the first hash value for the currently read file does not exist, or if the currently written file is written, the electronic device does not calculate its corresponding first hash value.

[0065] It should be understood that the first hash value of the current file being read / written can be stored in the inode of the electronic device. The method to determine whether the first hash value exists can be that the electronic device determines whether the first hash value is stored in the inode.

[0066] S203, when the load level of the electronic device is determined to be light load, the electronic device obtains the second hash value of at least one file stored in the electronic device and the inode number of the at least one file. The second hash value is the hash value of the first information block of the at least one file and is used by the electronic device to find duplicate files with the same second hash value.

[0067] It should be understood that "at least one file" in step S203 refers to a file stored in the electronic device, while "currently read / written file" in step S202 refers to a file that the electronic device is currently reading or writing; the two are different. Furthermore, in this embodiment, "at least one file" in S203 and "currently read / written file" in S202 can respectively correspond to different parts of the electronic device's file system.

[0068] In this embodiment of the application, when the load level of the electronic device is determined to be light load, the third module of the electronic device obtains the second hash value of at least one file stored in the electronic device and the inode number of the at least one file, and the fourth module of the electronic device saves the second hash value of the at least one file and the inode number of the at least one file.

[0069] It should be understood that the second hash value can be the hash value of the first information block of at least one file. This means that at least one file corresponds to at least one second hash value, and any one of the files in the at least one file corresponds to a second hash value. It should also be understood that the aforementioned at least one file is a file stored in an electronic device, such as a file stored on the disk of an electronic device. Therefore, the electronic device can traverse the files on the disk to obtain the corresponding second hash value and inode number.

[0070] In this embodiment, the third module can be a software module in an electronic device. For example, the third module can be a software module in a file system of an electronic device, or it can be a software module in an external component of a file system of an electronic device. In this embodiment, the third module can be called a background duplicate file search module, or it can have other names, which are not limited in this application.

[0071] In one possible implementation, the electronic device can read or calculate the inode number of at least one file and the second hash value of at least one file, and then save the correspondence between the inode number of at least one file and the second hash value of at least one file.

[0072] In another possible implementation, the electronic device stores the inode number and first hash value of the currently read / written file, as well as the inode number and second hash value of at least one of the aforementioned files, which can be used for deduplication. For example, the electronic device stores a key-value table that records the correspondence between file inode numbers and the hash values ​​of the first information block. In the key-value table, the hash value of any first information block corresponds to one or more inode numbers, so that when multiple inode numbers are involved, the electronic device can perform deduplication on the files corresponding to those multiple inode numbers.

[0073] It should be understood that, in the embodiments of this application, a file may be stored in one or more data blocks, and an information block corresponding to a file may include at least one data block. For example, the first information block corresponding to a file may include the first data block of the file, or it may include the first and second data blocks of the file, etc., and this application does not limit this.

[0074] It should also be understood that, in the embodiments of this application, when the file in the electronic device is large, the above-mentioned "first hash value" may be the hash value of the Nth information block of the current read / write file, where N is a positive integer, for example, N is two.

[0075] In this embodiment of the application, when the file in the electronic device is large, the above-mentioned "second hash value" can be the hash value of the Mth information block of the current read / write file, where M is a positive integer, for example, M is two.

[0076] Therefore, by searching and retrieving information such as the hash value of the file's information blocks, the efficiency of finding duplicate files is improved, and when the retrieved results are used for deduplication, the efficiency of removing duplicate files is further improved.

[0077] The following, by way of example, combines Figure 3 and Figure 4 Taking the above method executed by the first module, second module, third module and fourth module in the electronic device as an example, this application provides a file search method based on an electronic device.

[0078] It should be noted that, Figure 3 and Figure 4 Some steps of the method shown are the same as those described above. Figure 2 Some of the steps are the same as those in the previous section, so they will not be repeated here.

[0079] Figure 3 This illustration shows a schematic flowchart of a file search method based on an electronic device according to an embodiment of this application. Specifically, the method 300 may include, but is not limited to:

[0080] S301, the first module determines whether the load level of the electronic device within the first time window is light load or heavy load.

[0081] In this embodiment of the application, the first module is a module in an electronic device.

[0082] For a detailed explanation of step S301 above, please refer to the relevant description in S201 of method 200 above, which will not be repeated here.

[0083] S302, when the first module determines that the load level of the electronic device is heavy load, the second module triggers the first operation, which includes obtaining the inode number and the first hash value of the currently read / write file, then recording the first hash value of the currently read / write file into the inode, and sending the inode number and the first hash value of the currently read / write file to the fourth module.

[0084] In this embodiment of the application, the second module and the fourth module are modules in an electronic device. The method by which the first module triggers the first operation of the second module may be that when the first module determines that the current load level is heavy load, it sends first information to the second module, which is used to indicate that the current load level is heavy load.

[0085] Regarding the first operation of step S302 above, the specific method for obtaining the first hash value of the current read / write file and the inode number of the current read / write file can be referred to the relevant introduction of step S202 in method 200 above, which will not be repeated here.

[0086] S303, when the first module determines that the load level of the electronic device is light load, the second operation of the third module is triggered. The second operation includes obtaining the inode number of at least one file stored in the first device and the second hash value of the at least one file, and sending the inode number of the at least one file and the second hash value of the at least one file to the fourth module.

[0087] In this embodiment of the application, the third module and the fourth module are modules in an electronic device. The method by which the first module triggers the second operation of the third module is that when the first module determines that the current load level is light load, it sends second information to the third module. The second information is used to indicate that the current load level is light load.

[0088] Regarding the second operation of step S303 above, the specific method for obtaining the inode number of at least one file and the second hash value of the at least one file can be referred to the relevant introduction of step S203 in method S200 above, which will not be repeated here.

[0089] In one possible implementation, during the initialization of the electronic device system, the electronic device creates a first daemon thread. The first daemon thread can be used by the third module to traverse the inode table of the file system when the device is idle, and obtain the inode number of at least one file and the hash value of the first information block stored in the inode of the at least one file.

[0090] In this embodiment, the device may be idle during a certain period of time late at night; for example, during a period when the electronic device confirms that the user is asleep through a wearable device. This application does not limit this to such a period. In other embodiments, the device may be idle during a period when the electronic device is charging or the screen is off.

[0091] S304, the fourth module receives and saves the inode number of the file sent by the second module and / or the third module, as well as the hash value of the first information block of the file.

[0092] It should be understood that the file in the above method S304 can be a currently read / written file in the electronic device, or at least one file stored in the electronic device.

[0093] In this embodiment, the fourth module records the file's inode number and the hash value of the file's first information block in a key-value table, which can also be called a deduplication table. The fourth module records the association information between hash values ​​and inode numbers from the second and third modules. In the key-value table, for the same hash value, there may be multiple corresponding inode numbers, allowing the electronic device to further deduplicate files with multiple inode numbers corresponding to the same hash value.

[0094] In one possible implementation, the key-value table can be as shown in Table 1 below. This key-value table includes two columns. The first column represents the hash value of the first information block, for example, key1, key2, key3...keyn represent the hash values ​​of the first information block of the file. The second column represents a list of inode numbers. For example, i-list1 can include inode1-inode3, indicating that the hash value of the first information block of the three files with inode numbers inode1-inode3 is the same, which is key1; i-list2 includes inode4, indicating that the hash value of the first information block of the file with inode number inode4 is key2; i-list3 can include inode5-inode6, indicating that the hash value of the first information block of the two files with inode numbers inode5-inode6 is the same, which is key3; i-listm can be understood by analogy and will not be elaborated here. Thus, the electronic device can deduplicate multiple files with the same hash value of the first information block. For example, the fifth module in the electronic device deduplicates multiple files with the same hash value of the first information block. In the embodiments of this application, the fifth module may be a deduplication module, or the fifth module may have other names, which are not limited in this application.

[0095] Table 1

[0096] The hash value of the first information block list of inode numbers key1 i-list1 key2 i-list2 key3 i-list3 … … keyn i-listm

[0097] Figure 4 This illustration shows a schematic diagram of a module architecture for file searching on an electronic device according to an embodiment of this application. This module architecture 400 can be used for deduplication in electronic devices. Specifically, the module architecture includes a load sensing module 401, a front-end duplicate file search module 402, a back-end duplicate file search module 403, a deduplicatable information recording module 404, and a deduplication module 405.

[0098] Modules (401, 402, 403, 404, 405) can all be software modules: Load sensing module 401 can obtain the running status of the application and determine the current load level of the device based on the running status of the application; when load sensing module 401 determines that the device is currently under heavy load, foreground duplicate file search module 402 can perform calculations, recording and other operations on the relevant information of the currently read / written data; when load sensing module 401 determines that the device is currently under light load, background duplicate file search module 403 can scan, calculate and record the relevant information of the stored data in the device; foreground duplicate file search module 402 and background duplicate file search module 403 send the relevant information of the acquired data to deduplicatable information recording module 404, which will save the relevant information; deduplication module 405 performs deduplication based on the information saved in deduplicatable information recording module 404.

[0099] It should be understood that modules (401, 402, 403, 404, 405) can be modules of the file system, or modules (401, 402, 403, 404, 405) can also be external plugins of the file system, providing services to the file system.

[0100] For details on the specific methods and functions that the above modules (401, 402, 403, 404, 405) can implement, please refer to the relevant descriptions in methods 200 and 300 above. They will not be repeated here.

[0101] The above combination Figures 2 to 4 The file search method based on electronic devices provided in the embodiments of this application has been described in detail. Below, in conjunction with... Figure 5 and Figure 6 The apparatus provided in the embodiments of this application will be described in detail. It should be understood that the description of the apparatus embodiments corresponds to the description of the method embodiments. Therefore, for content not described in detail, please refer to the method embodiments above. For the sake of brevity, it will not be repeated here.

[0102] Figure 5 A schematic structural diagram of a file search device based on an electronic device provided in an embodiment of this application is shown. Figure 5 The device 500 shown can perform the corresponding steps performed by the electronic device in the above method embodiments.

[0103] like Figure 5As shown, the device 500 may include a first processing unit 501, a second processing unit 502, and a third processing unit 503. The first processing unit 501 may be used to determine the load level of the electronic device; the second processing unit 502 may be used to obtain a first hash value of the currently read / written file and the inode number of the currently read / written file when the load level of the electronic device is determined to be heavy; the third processing unit 503 may be used to obtain a second hash value of at least one file stored in the electronic device and the inode number of the at least one file when the load level of the electronic device is determined to be light; wherein the first hash value is the hash value of the first information block of the currently read / written file, and is used by the electronic device to find duplicate files with the same first hash value; the second hash value is the hash value of the first information block of the at least one file, and is used by the electronic device to find duplicate files with the same second hash value.

[0104] The specific functions of the first processing unit, the second processing unit, and the third processing unit can be found in the relevant descriptions in the above method embodiments, and will not be repeated in detail here.

[0105] It should be understood that the device 500 provided in this application embodiment can be implemented by a central processing unit (CPU), an application-specific integrated circuit (ASIC), or a programmable logic device (PLD). The PLD can be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof. It can also be implemented in software. Figures 2 to 4 In the method shown, the device 500 and its various modules can also be software modules.

[0106] Figure 6 This is a schematic diagram of the hardware structure of a file search device 1000 based on an electronic device provided in an embodiment of this application.

[0107] like Figure 6As shown, the device 1000 includes a processor 1001, a memory 1002, an interface 1003, and a bus 1004. The interface 1003 can be implemented wirelessly or via a wired connection; specifically, it can be a network interface card (NIC). The processor 1001, memory 1002, and interface 1003 are connected via the bus 1004. The interface 1003 may specifically include a transmitter and a receiver for the device to perform the aforementioned transmission and reception. The processor 1001 is used to execute the processing performed by the device in the above embodiments. The memory 1002 includes an operating system 10021 and an application program 10022, used to store programs, code, or instructions. When the processor or hardware device executes these programs, code, or instructions, the processing procedures in the method embodiments can be completed. In this application embodiment, the memory 1002 may include read-only memory (ROM) and random access memory (RAM). The ROM includes a basic input / output system (BIOS) or an embedded system; the RAM includes application programs and the operating system. When device 1000 needs to be run, the system is booted through the BIOS embedded in ROM or the bootloader in the embedded system, and device 1000 enters normal operation. After device 1000 enters normal operation, the application program and operating system running in RAM complete the processing procedures involving device 1000 in the method embodiment. Figure 6 Only a simplified design of device 1000 is shown. In practical applications, the device can include any number of interfaces, processors, or memory.

[0108] In some implementations, the device 1000 may be a hardware structure diagram of the aforementioned device 500. In this case, the processor 1001 has the same function as the first processing unit 501 to the third processing unit 503.

[0109] This application also provides a computer-readable medium storing program code that, when executed on a computer, causes the computer to perform the method executed by the electronic device in the above-described method embodiments. Such computer-readable storage includes, but is not limited to, one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), flash memory, electrically EPROM (EEPROM), and hard drive.

[0110] This application also provides a chip system comprising: at least one processor, at least one memory, and an interface circuit. The interface circuit is responsible for information interaction between the chip system and the outside world. The at least one memory, the interface circuit, and the at least one processor are interconnected via circuits. The at least one memory stores instructions. The instructions are executed by the at least one processor to perform the operation of the electronic device described in the above-described aspects. In specific implementation, the chip system can be implemented in the form of a central processing unit (CPU), a microcontroller unit (MCU), a microprocessor (MPU), a digital signal processor (DSP), a system-on-chip (SoC), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or a programmable logic device (PLD).

[0111] This application also provides a computer program product applied in an electronic device. The computer program product includes a series of instructions that, when executed, perform the operation of the electronic device as described in the above-described aspects.

[0112] As used in this specification, the terms "component," "module," "system," etc., are used to refer to computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, and / or a computer. As illustrated, applications running on computing devices and computing devices can both be components. One or more components may reside in a process and / or an execution thread, and components may be located on a single computer and / or distributed among two or more computers. Furthermore, these components can be executed from various computer-readable media on which various data structures are stored. Components can communicate, for example, via local and / or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system, and / or a network, such as the Internet interacting with other systems via signals).

[0113] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0114] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0115] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0116] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0117] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0118] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0119] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A file search method based on electronic devices, characterized in that, The method includes: The electronic device determines the load level of the electronic device; When the electronic device is determined to be under heavy load, the electronic device obtains the first hash value of the currently read / written file and the inode number of the currently read / written file; When the load level of the electronic device is determined to be light, the electronic device obtains the second hash value of at least one file stored in the electronic device and the inode number of the at least one file; The first hash value is the hash value of the first information block of the current read / write file, and is used by the electronic device to find duplicate files with the same first hash value; The second hash value is the hash value of the first information block of the at least one file, and is used by the electronic device to find duplicate files with the same second hash value; When the load level of the electronic device is determined to be heavy, the electronic device obtains the first hash value of the currently read / written file and the inode number of the currently read / written file, including: The electronic device obtains the inode number of the currently read / written file based on the filename of the currently read / written file; The electronic device reads or calculates the first hash value of the currently read / written file based on the inode number of the currently read / written file. The electronic device stores the correspondence between the inode number of the currently read / written file and the first hash value of the currently read / written file; When the load level of the electronic device is determined to be light, the electronic device obtains the second hash value of at least one file stored in the electronic device and the inode number of the at least one file, including: The electronic device reads or calculates the inode number of the at least one file and the second hash value of the at least one file; The electronic device stores the correspondence between the inode number of the at least one file and the second hash value of the at least one file.

2. The method according to claim 1, characterized in that, The electronic device determines its load level by: Within the first time window, the electronic device calculates the amount of information read / written to determine the load level of the electronic device.

3. The method according to claim 1 or 2, characterized in that, The electronic device stores the correspondence between the inode number of the currently read / written file and the first hash value of the currently read / written file, including: The electronic device saves the correspondence between the inode number of the currently read / write file and the first hash value of the currently read / write file to a key-value table.

4. The method according to claim 1 or 2, characterized in that, The electronic device stores the correspondence between the inode number of the at least one file and the second hash value of the at least one file, including: The electronic device saves the correspondence between the inode number of the at least one file and the second hash value of the at least one file into a key-value table.

5. The method according to any one of claims 2-4, characterized in that, The first time window is determined by the electronic device based on global variables.

6. The method according to any one of claims 1-5, characterized in that, When at least two files have the same first hash value, the electronic device determines that at least two files with the same first hash value are duplicate files. When at least two files have the same second hash value, the electronic device determines that at least two files with the same second hash value are duplicate files.

7. The method according to any one of claims 1-6, characterized in that, The first hash value and / or the second hash value are used by the electronic device to deduplicate the duplicate files.

8. A file search device based on an electronic device, characterized in that, The device includes: The first processing unit is used to determine the load level of the electronic device; The second processing unit is used to obtain the first hash value of the currently read / write file and the inode number of the currently read / write file when it is determined that the load level of the electronic device is heavy load; The third processing unit is used to obtain the second hash value of at least one file stored in the electronic device and the inode number of the at least one file when it is determined that the load level of the electronic device is light load; The first hash value is the hash value of the first information block of the current read / write file, and is used by the electronic device to find duplicate files with the same first hash value; The second hash value is the hash value of the first information block of the at least one file, and is used by the electronic device to find duplicate files with the same second hash value; The second processing unit is used to obtain the first hash value of the currently read / written file and the inode number of the currently read / written file when the load level of the electronic device is determined to be heavy load. Specifically, the second processing unit is used to: Based on the filename of the currently read / written file, obtain the inode number of the currently read / written file; Based on the inode number of the currently read / written file, read or calculate the first hash value of the currently read / written file; Save the correspondence between the inode number of the currently read / written file and the first hash value of the currently read / written file; The second processing unit is used to store the correspondence between the inode number of the currently read / write file and the first hash value of the currently read / write file. Specifically, the second processing unit is used for: The correspondence between the inode number of the currently read / write file and the first hash value of the currently read / write file is saved to the key-value table.

9. The apparatus according to claim 8, characterized in that, The first processing unit is used to determine the load level of the electronic device, and specifically, the first processing unit is used to: Within the first time window, the electronic device calculates the amount of information read / written to determine the load level of the electronic device.

10. The apparatus according to claim 8 or 9, characterized in that, The second processing unit is used to store the correspondence between the inode number of the currently read / write file and the first hash value of the currently read / write file. Specifically, the second processing unit is used for: The correspondence between the inode number of the currently read / write file and the first hash value of the currently read / write file is saved to the key-value table.

11. The apparatus according to claim 8 or 9, characterized in that, The third processing unit is used to store the correspondence between the inode number of the at least one file and the second hash value of the at least one file. Specifically, the third processing unit is used for: The correspondence between the inode number of the at least one file and the second hash value of the at least one file is saved to the key-value table.

12. The apparatus according to any one of claims 9-11, characterized in that, The first time window is determined based on global variables.

13. The apparatus according to any one of claims 8-12, characterized in that, If at least two files have the same first hash value, the at least two files with the same first hash value are determined to be duplicate files. If at least two files have the same second hash value, then the at least two files with the same second hash value are determined to be duplicate files.

14. The apparatus according to any one of claims 8-13, characterized in that, The first hash value and / or the second hash value are used by the electronic device to deduplicate the duplicate files.

15. A file search device based on an electronic device, characterized in that, The device includes at least one processor coupled to at least one memory, the at least one processor being configured to execute a computer program or instructions stored in the at least one memory to cause the device to perform the method as described in any one of claims 1-7.

16. A chip, characterized in that, The device includes a processor and a communication interface, the communication interface being used to receive data and / or information and transmit the received data and / or information to the processor, the processor processing the data and / or information according to any one of claims 1-7.

17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on a computer, cause the method as described in any one of claims 1-7 to be implemented.

Citation Information

Patent Citations

  • Device and method for eliminating file duplication in a distributed storage system

    CN102834803A

  • Method and apparatus for recovering deleted file in ext file system

    CN105095025A