A Disk Scanning Acceleration Method and Device for Ext File System
By identifying the device type and converting it into a single-partition device, combining parallel processing technology, and scanning the Ext file system based on inode number, the problems of low disk scanning efficiency and high resource consumption are solved, and efficient and accurate disk scanning is achieved.
Patent Information
- Application Number
- CN202510199356.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-24
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-02-24
AI Technical Summary
Disk scanning of Ext file system is inefficient on large-capacity disks, has high resource consumption, lacks parallelism optimization, affecting system performance.
By obtaining the device type, if it is a single partition device, the scanning will be accelerated directly. If it is a multi-partition device, it will be converted into a single partition device for scanning. Using the metadata structure characteristics of the file system, combined with parallel processing technology, the entire file system is scanned based on inode numbering, and memory resources are released after the scan is completed.
It significantly improves disk scanning efficiency, reduces system resource consumption, ensures comprehensiveness and accuracy of scanning, is suitable for different devices and scenarios, and reduces application costs and technical thresholds.
Smart Images

Figure CN119690913B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer file systems, and particularly to a method and device for accelerating disk scanning for the Ext file system. Background Art
[0002] Linux Ext series file systems (such as Ext3 and Ext4) are widely used file systems in the Linux system and have long been trusted by users due to their good stability and high performance. Although the usage rates of modern file systems such as XFS and Btrfs have gradually increased, Ext4, as a classic and mature file system, is still widely adopted today due to its reliability and applicability. However, disk scanning, as a key task in file system management, shows performance bottlenecks in the following scenarios: Low scanning efficiency: For large-capacity disks, the scanning operation takes a long time, especially when the disk health is poor or the fragmentation is severe. High resource consumption: During the disk scanning process, the occupancy rates of CPU and I / O resources are relatively high, affecting the normal operation of other system tasks. Lack of parallelism optimization: Traditional disk scanning schemes adopt a linear scanning method and do not fully utilize the structural characteristics of the Ext file system (such as log, block group, and bitmap information) and the multi-core parallel processing capabilities of modern hardware.
[0003] To solve the above problems, a method and device for accelerating disk scanning for the Ext file system are proposed, which utilize the characteristics of the file system's metadata structure and combine parallel processing technology to significantly improve the disk scanning efficiency and reduce system resource consumption. Summary of the Invention
[0004] The purpose of the present invention is to provide a method and device for accelerating disk scanning for the Ext file system, aiming to solve the above problems.
[0005] The present invention provides a method for accelerating disk scanning for the Ext file system, including:
[0006] Obtain the device type. If the device type is a single-partition device, directly perform disk scanning acceleration; if the device type is a multi-partition device, convert the multi-partition device into a single-partition device for disk scanning;
[0007] When performing disk scanning, obtain the device path where the file system partition is located through a system call, and open the device file to be scanned in the file system partition;
[0008] Read the key metadata of the file system superblock;
[0009] Based on the key metadata, start from the root directory and sequentially scan the entire file system according to the inode number;
[0010] After the scanning is completed, release the occupied memory resources and close the scanned files in the file system.
[0011] Preferably, if the device type is a multi-partition device, convert the multi-partition device into a single-partition device for disk scanning, including:
[0012] If the device type is a multi-partition device, obtain the support situation of the physical disk for parallel I / O;
[0013] Convert the multi-partition device into a single-partition device for disk scanning according to the support situation of the physical disk for parallel I / O;
[0014] The support situation of the physical disk for parallel I / O includes: physical disk capabilities, driver support, and system configuration status.
[0015] Preferably, the key metadata includes: block information, inode information, descriptor information, and feature identifiers.
[0016] Preferably, the block information includes: block size, number of blocks per block group;
[0017] The inode information includes: number of inodes per block group, inode size;
[0018] The descriptor information includes: block group descriptor size and location;
[0019] The feature identifiers include: enabled status of sparse superblocks, enabled status of elastic block groups, and enabled status of meta block groups.
[0020] Preferably, based on the key metadata, starting from the root directory, recursively scan the entire file system according to the inode number, including:
[0021] Determine the storage offset position of the inode in the file system and the group descriptor table according to the inode number;
[0022] Parse the inode information and extract the basic attributes of the file;
[0023] Parse the block information, and according to the storage method of the block, use the corresponding method to parse the block information and extract the file content or the structural information of the folder;
[0024] Parse the folder according to the structural information of the folder, obtain the inode numbers of the subdirectories and files, and recursively scan the directory tree layer by layer.
[0025] Preferably, determining the storage offset position of the inode in the file system and the group descriptor table according to the inode number includes:
[0026] Block group calculation:
[0027] File block group number = (inode number - 1) / number of inodes per block group;
[0028] Group descriptor block location:
[0029] Group descriptor block = block group number / (block size / group descriptor size);
[0030] Offset within group descriptor block:
[0031] Index of group descriptor within block = block group number % (block size / group descriptor size);
[0032] Index of inode within block group:
[0033] Index of inode in its block group = (inode number - 1) % number of inodes per block group;
[0034] Calculation of index table location:
[0035] Offset of inode within index table block = inode index / (block size / inode size);
[0036] Calculation of inode physical location:
[0037] Actual address of inode = (index table offset location + offset of inode within index table block) × block size.
[0038] Preferably, the basic attributes of a file include: file type, file size, file permissions, and timestamp.
[0039] Preferably, when parsing inode information to extract the basic attributes of a file, it also includes: filtering out inodes that are not files or directories if they exist.
[0040] Preferably, the method for parsing block information is the direct / indirect block addressing method and the extended tree method.
[0041] The present invention also discloses a disk scanning acceleration device for the Ext file system, which is used to apply the above-mentioned disk scanning acceleration method for the Ext file system, and includes:
[0042] Device acquisition unit, used to acquire the device type. If the device type is a single-partition device, it directly performs disk scanning acceleration; if the device type is a multi-partition device, it converts the multi-partition device into a single-partition device for disk scanning;
[0043] Opening unit, used to obtain the device path where the file system partition is located through a system call and open the device file to be scanned in the file system partition when performing disk scanning;
[0044] A reading unit for reading key metadata of a file system superblock;
[0045] A scanning unit for recursively scanning the entire file system starting from the root directory based on the inode number according to the key metadata;
[0046] A closing unit for releasing the occupied memory resources and closing the scanned file of the file system after the scanning is completed.
[0047] Compared with the prior art, the beneficial effects of the present invention are as follows: By utilizing the characteristics of the metadata structure of the file system and combining parallel processing technology, the present invention significantly improves the disk scanning efficiency and reduces the consumption of system resources. Different device types are treated differently. For single-partition devices, the scanning is directly accelerated, and for multi-partition devices, they are converted into single-partition devices for scanning, avoiding complex multi-partition scanning processes, greatly improving the scanning speed, saving a large amount of time cost, and being particularly suitable for scenarios where file system information needs to be obtained quickly. By obtaining the device path through system calls and opening the device file to be scanned, the file system partition can be accurately located, and the key metadata of the file system superblock can be read. Based on this, recursive scanning is performed from the root directory according to the inode number, ensuring the comprehensiveness and accuracy of the scanning, and ensuring that all files and directories in the file system can be effectively scanned. After the scanning is completed, the occupied memory resources are released in a timely manner and the scanned file is closed, effectively avoiding memory leaks and resource waste, enabling the system resources to be quickly utilized by other processes after the scanning task ends, and improving the overall performance and resource utilization rate of the system. This method is designed for the Ext file system and can be well compatible with existing devices and systems based on the Ext file system. Disk scanning acceleration can be achieved without large-scale transformation of the file system, reducing the application cost and technical threshold, and facilitating popularization and application in different devices and scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only the embodiments of the present invention, and those of ordinary skill in the art can also obtain other drawings according to the provided drawings without creative efforts.
[0049] Figure 1 It is a flowchart of a method for accelerating disk scanning for an Ext file system according to the present invention;
[0050] Figure 2 It is a functional block diagram of a device for accelerating disk scanning for an Ext file system according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0051] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0052] With the development of science and technology, the emergence of solid-state drives has greatly improved the speed and efficiency of data storage and access, and has gradually developed into one of the mainstream storage devices. However, the traditional serial I / O scanning method cannot fully utilize the hardware performance, which easily leads to a decrease in user satisfaction.
[0053] On the one hand, although emerging storage technologies such as solid-state drives (SSDs) are becoming increasingly popular, mechanical hard drives still have a place in providing large-capacity storage solutions and cost-effectiveness. Especially in the fields of data centers, cloud storage, and security monitoring, the irreplaceability of mechanical hard drives still exists. In such application scenarios of big data storage, the time-consuming of full disk scanning will be further deteriorated.
[0054] The present invention provides an efficient disk scanning acceleration method, which reduces the disk scanning time and simultaneously reduces the system resource occupancy rate by combining technologies such as parallel scanning and metadata parsing.
[0055] As Figure 1 shown, the present invention provides a disk scanning acceleration method for the Ext file system, including:
[0056] Obtain the device type. If the device type is a single-partition device, directly perform disk scanning acceleration; if the device type is a multi-partition device, convert the multi-partition device into a single-partition device for disk scanning;
[0057] When performing disk scanning, obtain the device path where the file system partition is located through system calls, and open the device file to be scanned in the file system partition;
[0058] Read the key metadata of the file system superblock;
[0059] Based on the key metadata, starting from the root directory, recursively scan the entire file system according to the inode number;
[0060] After the scanning is completed, release the occupied memory resources and close the scanning file of the file system.
[0061] Through parallel scanning technology, the present invention significantly improves the speed of disk scanning, especially when dealing with large-capacity storage devices. At the same time, by accurately parsing the key metadata of the file system superblock, it ensures the accuracy and integrity of the scanning, avoiding unnecessary scanning overhead. In addition, the strategy of converting multi-partition devices into single-partition devices for scanning simplifies the scanning process and further improves the scanning efficiency. After completing the scanning task, it promptly releases memory resources and closes the scanned files, effectively managing system resources and ensuring the stability and reliability of the system. In summary, the present invention provides an efficient and accurate acceleration method for disk scanning of the Ext file system, which is of great significance for improving data storage and access performance.
[0062] To further elaborate on the present invention, the following explains the professional terms in the present invention:
[0063] Index node (inode): A structured record for describing the metadata of files or directories in the Ext file system. Each file or directory has an inode number in the file system, which is used for unique identification.
[0064] Block: The basic unit of storage allocation in the Ext file system. A block is a collection composed of multiple clusters, with a size between 1KB and 64KB. By default, the block size = 4KB. By default, the file system can manage up to 2^32 blocks at most. However, when the 64-bit feature is specified, it can manage up to 2^64 blocks at most.
[0065] Block group: Multiple blocks combined together are called a block group. Each block group stores the superblock, group descriptor, block bitmap, and inode bitmap of this block group.
[0066] Super block: The super block records a large amount of information about the entire file system, such as the number of data blocks, the number of inodes, supported features, management information, etc.
[0067] Group descriptors: Each block group in the file system corresponds to a group descriptor, which is the second content group in the block group. The group descriptor records the location information of the bitmap and inode table.
[0068] Block bitmap / Inode bitmap: The block bitmap tracks the usage of data blocks in the block group. The inode bitmap tracks the usage of inodes in the block group. Each bit Figure 1 represents the usage of a data block, and each bit is represented by 0 or 1 for the usage of a data block in the block group or an inode in the inode table.
[0069] Index node table (inode table): used to store inode information of files.
[0070] In some embodiments of the present application, if the device type is a multi - partition device, the multi - partition device is converted into a single - partition device for disk scanning, including: if the device type is a multi - partition device, obtain the support situation of the physical disk for parallel I / O; convert the multi - partition device into a single - partition device for disk scanning according to the support situation of the physical disk for parallel I / O; the support situation of the physical disk for parallel I / O includes: physical disk capabilities, driver support, and system configuration status.
[0071] In this embodiment, when it is detected that the device type is a multi - partition device, in order to improve the efficiency and accuracy of disk scanning, this technical solution proposes a method of converting a multi - partition device into a single - partition device for disk scanning. The specific steps are as follows: First, the system will detect whether the current device is a multi - partition device. If so, the system will perform the following steps:
[0072] Obtain the support situation of the physical disk for parallel I / O: This step involves evaluating the hardware capabilities of the physical disk, whether the currently installed driver supports parallel I / O operations, and whether the system configuration allows parallel I / O operations. According to the support situation of the physical disk for parallel I / O, convert the multi - partition device into a single - partition device for disk scanning: If the physical disk supports parallel I / O operations, the system will adjust the partition settings to merge multiple partitions into a single partition. This can reduce the number of I / O operations during disk scanning because scanning a single partition is usually more efficient than scanning multiple partitions. If the physical disk does not support parallel I / O operations, the system may take other optimization measures or perform disk scanning according to the traditional multi - partition scanning method.
[0073] The support situation of the physical disk for parallel I / O includes but is not limited to the following points:
[0074] Physical disk capabilities: including hardware characteristics such as the interface type of the disk (such as SATA, SAS, etc.), transfer rate, cache size, etc., which will affect the performance of parallel I / O. For example, if the SATA interface is the SATA 3.0 version, it theoretically supports a higher parallel transfer rate; the number and architecture of the processing cores inside the device, a storage device with a multi - core architecture has stronger capabilities in processing parallel I / O requests; and the maximum I / O queue depth supported by the device, the larger the depth, the more I / O requests the device can process simultaneously, and the stronger the parallel processing ability.
[0075] Driver Support: The disk driver installed in the operating system must support parallel I / O operations. Otherwise, even if the hardware supports it, parallel I / O cannot be achieved. The implementation method and optimization level of the driver for parallel I / O functions are crucial. Some high-performance drivers will adopt technologies such as multi-threading or asynchronous I / O to improve parallel processing efficiency. At the same time, the I / O modes supported by the driver, such as Direct I / O, Scatter - Gather I / O, etc., have different impacts on parallel I / O performance in different application scenarios.
[0076] System Configuration Status: Configurations such as the I / O scheduler settings and system resource allocation policies of the operating system determine whether the system allows parallel I / O operations and how to optimize these operations. Relevant configuration parameters at the system level, such as the setting of the I / O scheduling algorithm in kernel parameters, choosing different scheduling algorithms such as Deadline, CFQ, etc., will directly affect the processing order and efficiency of the system for parallel I / O requests. The system resource allocation policy, including the size of the memory allocated to the I / O cache, etc., will also have an important impact on the performance of parallel I / O.
[0077] Through the above steps, this technical solution can intelligently select the most suitable disk scanning strategy according to the specific situation of the device, thereby improving the efficiency and performance of disk scanning.
[0078] It can be understood that the present invention can effectively improve the disk scanning efficiency of multi-partition devices on the Ext file system. By converting the multi-partition device into a single-partition device for scanning, the scanning process can be simplified, and the time overhead of partition switching and data processing can be reduced. At the same time, by converting according to the support of the physical disk for parallel I / O, the parallel processing ability of the physical disk can be fully utilized to further improve the scanning speed.
[0079] In some embodiments of the present application, the key metadata includes: block information, inode information, descriptor information, and feature identifiers.
[0080] In some embodiments of the present application, the block information includes: block size, the number of blocks contained in each block group; the inode information includes: the number of inodes in each block group, inode size; the descriptor information includes: block group descriptor size and location; the feature identifiers include: the enabled status of the sparse superblock, the enabled status of the elastic block group, and the enabled status of the meta block group.
[0081] In this embodiment, the definition and content of the key metadata are elaborated in detail to ensure the efficient management of the file system and the accurate storage of data. The key metadata includes several main parts: block information, inode information, descriptor information, and feature identifiers.
[0082] Specifically, the block information provides detailed configuration about data blocks, which includes the block size, i.e., the storage capacity of each data block, and the number of blocks contained in each block group, which determines the overall storage capacity of each block group. With this information, the system can effectively organize and access the storage space. The inode information focuses on the inode of the file, which includes the number of inodes in each block group, which determines the number of files that each block group can support, and the inode size, i.e., the storage space occupied by each inode. The inode is a key structure in the file system for storing file metadata, including information such as file permissions, owner, size, and pointers to data blocks. The descriptor information provides detailed information about the block group descriptor, including the size and location of the block group descriptor. The block group descriptor is a data structure in the file system for describing the status and attributes of each block group, and it is crucial for the overall layout and management of the file system. Finally, the feature identification section includes several key system feature statuses, such as the enabled status of the sparse superblock, the enabled status of the elastic block group, and the enabled status of the meta block group. These feature identifications allow system administrators to enable or disable specific advanced functions as needed to optimize performance or enhance data reliability. For example, the sparse superblock can reduce the redundancy of the superblock, the elastic block group can provide better data recovery capabilities, and the meta block group can optimize the storage and access efficiency of metadata.
[0083] It can be understood that by precisely identifying and extracting these key metadata, this technical solution can more efficiently organize and process the data information required during the disk scanning process. Specifically, the block information provides the basic layout of the disk blocks for the scanning process, enabling the scanning to proceed orderly according to the size and distribution of the blocks; the inode information associates the mapping relationship between files and disk blocks and is the key to locating file data; the descriptor information ensures that the relevant information of each block group can be accurately found and read during the scanning process; and the feature identification reflects the specific functions and optimization options of the Ext file system, which helps to optimize the scanning strategy to adapt to different file system configurations.
[0084] The present invention significantly improves the pertinence and efficiency of disk scanning. By precisely identifying and extracting key metadata, it reduces unnecessary data reading and processing, thus accelerating the scanning process. At the same time, this technical solution also has strong adaptability and flexibility, and can be intelligently adjusted according to different Ext file system configurations and physical disk characteristics to ensure the efficiency and accuracy of the scanning process.
[0085] In some embodiments of the present application, based on the key metadata, starting from the root directory, the entire file system is recursively scanned according to the inode number, including: determining the storage offset position of the inode in the file system and the group descriptor table according to the inode number; parsing the inode information to extract the basic attributes of the file; parsing the block information, and according to the storage method of the block, adopting a corresponding method to parse the block information to extract the file content or the structure information of the folder; parsing the folder according to the structure information of the folder to obtain the inode numbers of the subdirectories and files, and recursively scanning the directory tree layer by layer.
[0086] In this embodiment, starting from the root directory of the file system, first, the inode number of the root directory needs to be obtained, which is the unique identifier of each file and directory in the file system. Next, this inode number is used to determine its storage offset position in the file system and the group descriptor table to which it belongs. The group descriptor table contains the metadata information for managing data blocks and inodes in the file system. Once the inode number and storage location are available, the inode information can be parsed. The inode contains the basic attributes of the file, such as file type, permissions, owner, size, timestamp, and pointers to the file data blocks. By parsing this information, the metadata of the file can be extracted. For the extraction of file content, the block information associated with the inode needs to be parsed. A block is the basic unit for storing file data in the file system. According to the storage method of blocks in the file system (e.g., direct blocks, indirect blocks, etc.), different methods will be adopted to parse this block information. Direct blocks directly point to the physical locations storing the file content, while indirect blocks point to blocks containing more block pointers, which allows the file system to store larger files. If the currently parsed entity is a folder, we need to obtain its structure information. The structure information of the folder includes the inode numbers of all subdirectories and files within the folder. Through these inode numbers, each subdirectory can be recursively parsed, repeating the above scanning and parsing process. This process will continue until all subdirectories and files have been traversed, thus completing the scanning of the entire directory tree. The entire process requires careful handling of various metadata and data structures in the file system to ensure that the hierarchical structure and content of the file system can be accurately reconstructed.
[0087] When parsing a folder according to the structure information of the folder, in the traditional folder layout, all sub-item information is stored in a linear structure. However, this linear layout has the problem of low overall traversal performance when dealing with large directories. For this reason, the Ext3 file system introduced an innovative Hash tree layout to improve performance by combining hash indexing and a hierarchical structure. Therefore, when parsing a folder, it is necessary to support both the linear layout and the Hash tree layout to ensure compatibility and avoid potential problems.
[0088] It is understandable that by taking the inode number as the core, the deep traversal and precise scanning of the file system are realized. In this process, not only the comprehensiveness and accuracy of the scanning are ensured, but also the scanning efficiency is greatly improved. By directly locating the file data according to the inode number, the redundant searches and invalid accesses that may exist in the traditional scanning methods are avoided, thus significantly shortening the scanning time. At the same time, this technical solution can also intelligently process the structure information of the folder, scan the directory tree layer by layer, ensure that no file or subdirectory is missed, and provide strong support for disk maintenance and data recovery.
[0089] In some embodiments of the present application, determining the storage offset position and group descriptor table of the inode in the file system according to the inode number includes:
[0090] Block group calculation:
[0091] File block group number = (inode number - 1) / number of inodes per block group;
[0092] Group descriptor block position:
[0093] Group descriptor block = block group number / (block size / group descriptor size);
[0094] Group descriptor offset within block:
[0095] Group descriptor index within block = block group number % (block size / group descriptor size);
[0096] Inode index within block group:
[0097] Inode index in the block group where it is located = (inode number - 1) % number of inodes per block group;
[0098] Index table position calculation:
[0099] Inode offset within the block of the index table = inode index / (block size / inode size);
[0100] Inode physical position calculation:
[0101] Inode actual address = (index table offset position + inode offset within the block of the index table) × block size.
[0102] In this embodiment, in these calculation methods, "%" is the modulo operator, also called the remainder operator. Its function is to calculate the remainder after dividing two numbers.
[0103] Taking "Group descriptor index within block = block group number % (block size / group descriptor size)" as an example, this formula is used to determine the specific index position of the group descriptor within its containing block. By dividing the block group number by "block size / group descriptor size", the quotient obtained is the block number where the group descriptor is located, and the remainder (i.e., the result of the "%" operation) is the index of the group descriptor within that block, thus enabling precise positioning of the group descriptor within the block.
[0104] Similarly, in "inode index within its block group = (inode number - 1) % number of inodes per block group", the "%" operation divides the result of subtracting 1 from the inode number by the number of inodes per block group and takes the remainder to obtain the index of the inode within its block group, facilitating the quick finding of a specific inode within the block group.
[0105] It can be understood that through precise calculation steps, the actual storage location of the inode on the disk can be quickly located, thereby greatly improving the efficiency of disk scanning. Compared with traditional scanning methods, this method reduces unnecessary searching and traversal processes, enabling the file system to respond and process more quickly during maintenance and repair. In addition, this technical solution also optimizes memory usage, reduces performance bottlenecks caused by frequent disk access, and provides strong guarantees for the stability and efficiency of the Ext file system.
[0106] In some embodiments of the present application, the basic attributes of a file include: file type, file size, file permissions, and timestamp.
[0107] In some embodiments of the present application, when parsing inode information to extract the basic attributes of a file, it further includes: filtering out inodes that are not files or directories.
[0108] It can be understood that by filtering out inodes that are not files or directories, the amount of data to be processed during disk scanning can be further reduced, thereby improving the scanning efficiency. This filtering mechanism ensures that only inodes directly related to the file system structure and user data are included in the processing scope, avoiding unnecessary data traversal and analysis. In addition, this beneficial effect is also reflected in the effective utilization of system resources. By reducing unnecessary processing steps, the CPU and memory occupancy rates are reduced, enabling the file system to execute scanning tasks more smoothly and efficiently.
[0109] In some embodiments of the present application, the methods for parsing block information are direct / indirect block addressing methods and extended tree methods.
[0110] In this embodiment, the methods for parsing block information are the direct / indirect block addressing method and the extended tree method. The direct / indirect block addressing method is a technique used to locate and access data blocks in a file system. In direct addressing, the file system directly maps the starting part of a file to physical blocks on the disk. Usually, the first few blocks of a file can be directly accessed through direct pointers in the file control block (FCB) or inode. If a file is large, direct pointers may not be sufficient to cover the entire file, and in this case, indirect addressing is needed. The indirect addressing method extends the addressing ability of a file through one or more indirect blocks. In single indirect addressing, the file control block contains a pointer that points to an indirect block, and the indirect block contains pointers to the actual data blocks. If the file grows further, double indirect addressing or even triple indirect addressing may be required, where the pointer points to an indirect block that in turn points to other indirect blocks, forming a chain of pointers to access more data blocks. The extended tree method, such as the B-tree or B+-tree, is a more complex data structure used to manage data blocks on the disk. The B-tree is a balanced tree that allows for fast insertion, deletion, and searching of data. In a file system, each node of the B-tree can contain multiple key-value pairs, and each key-value pair corresponds to a data block. The non-leaf nodes of the B-tree contain pointers to child nodes and keys that separate the key values, while the leaf nodes contain pointers to the actual data blocks or the data itself. The B+-tree is a variant of the B-tree that stores all data records in the leaf nodes, and the internal nodes are only used for indexing, which makes the B+-tree more efficient for sequential access. Each of these two methods has its own advantages and disadvantages. The direct / indirect block addressing method is simple and intuitive, but may lead to performance degradation when dealing with large files because multiple indirect blocks need to be accessed. The extended tree method, especially the B-tree and B+-tree, provides better performance and space utilization when dealing with a large amount of data and frequent searching, insertion, and deletion operations, but is also more complex to implement.
[0111] It can be understood that by adopting the direct / indirect block addressing method and the extended tree method to parse block information, the data blocks in the Ext file system can be accessed and processed efficiently. Direct block addressing allows for quick positioning to the physical blocks where file data is located, while indirect block addressing and the extended tree method provide effective management of large files or complex directory structures. This technical solution that combines multiple block addressing methods not only improves the speed of disk scanning but also enhances the flexibility and scalability of the file system.
[0112] As Figure 2 shown, the present invention also discloses a disk scanning acceleration device for the Ext file system, which is used to apply the above-mentioned disk scanning acceleration method for the Ext file system, and includes:
[0113] A device acquisition unit, configured to acquire the device type. If the device type is a single - partition device, disk scanning acceleration is directly performed; if the device type is a multi - partition device, the multi - partition device is converted into a single - partition device for disk scanning;
[0114] An opening unit, configured to, when performing disk scanning, obtain the device path where the file system partition is located through system calls, and open the device file to be scanned in the file system partition;
[0115] A reading unit, configured to read the key metadata of the file system superblock;
[0116] A scanning unit, configured to, based on the key metadata, start from the root directory and recursively scan the entire file system according to the inode number;
[0117] A closing unit, configured to, when the scanning is completed, release the occupied memory resources and close the scanning file of the file system.
[0118] Through optimizing the disk scanning process, the present invention significantly improves the scanning efficiency of the Ext file system. Especially when dealing with multi - partition devices, by converting them into single - partition devices for scanning, it effectively avoids the problem of decreased scanning speed caused by multi - partitions in the traditional scanning method. In addition, the device also realizes fast recursive scanning starting from the root directory by accurately reading the key metadata of the file system superblock, further improving the accuracy and efficiency of scanning. At the same time, after the scanning is completed, the occupied memory resources are released in a timely manner and the scanning file is closed, ensuring the stability of the system and the efficient utilization of resources.
[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that they can still modify or equivalently replace the technical solutions of the present invention, and these modifications or equivalent replacements cannot make the modified technical solutions deviate from the spirit and scope of the technical solutions of the present invention.
[0120] For the system provided in the above - mentioned embodiments, only the above - mentioned division of each functional module is used for illustration. In practical applications, the above - mentioned functions can be allocated to different functional modules according to needs, that is, the modules or steps in the embodiments of the present invention can be further decomposed or combined. For example, the modules in the above - mentioned embodiments can be combined into one module, or further split into multiple sub - modules to complete all or part of the functions described above. For the names of the modules and steps involved in the embodiments of the present invention, they are only used to distinguish each module or step and are not regarded as an improper limitation of the present invention.
[0121] Those skilled in the art should be able to realize that the modules and method steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. The programs corresponding to the software modules and method steps can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field. To clearly illustrate the interchangeability of electronic hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in the form of electronic 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 to exceed the scope of the present invention.
Claims
1. A method for accelerating disk scanning of the Ext file system, characterized in that, Include: Obtain the device type. If the device type is a single - partition device, directly perform disk scan acceleration; If the device type is a multi - partition device, convert the multi - partition device into a single - partition device for disk scanning; When performing disk scanning, obtain the device path where the file system partition is located through system calls, and open the device file to be scanned in the file system partition; Read the key metadata of the file system superblock; Based on the key metadata, starting from the root directory, sequentially scan the entire file system according to the inode number; After completing the scan, release the occupied memory resources and close the scan file of the file system; If the device type is a multi - partition device, converting the multi - partition device into a single - partition device for disk scanning includes: If the device type is a multi - partition device, obtain the support situation of the physical disk for parallel I / O; Convert the multi - partition device into a single - partition device for disk scanning according to the support situation of the physical disk for parallel I / O; if the physical disk supports parallel I / O operations, the system will adjust the partition settings to merge multiple partitions into a single partition; The support situation of the physical disk for parallel I / O includes: physical disk capabilities, driver support, and system configuration status; Based on the key metadata, starting from the root directory, sequentially scan the entire file system according to the inode number, including: Determine the storage offset position of the inode in the file system and the group descriptor table according to the inode number; Parse the inode information and extract the basic attributes of the file; Parse the block information. According to the storage method of the block, use the corresponding method to parse the block information and extract the file content or the structure information of the folder; Parse the folder according to the structure information of the folder, obtain the inode numbers of sub - directories and files, and sequentially scan the directory tree layer by layer; Determine the storage offset position of the inode in the file system and the group descriptor table according to the inode number, including: Block group calculation: File - located block group number = (inode number - 1) / number of inodes per block group; Group descriptor block position: Group descriptor - located block = block group number / (block size / group descriptor size); Offset within the group descriptor block: Index of the group descriptor within the block = block group number % (block size / group descriptor size); Inode index within the block group: Index of the inode within the block group where it is located = (inode number - 1) % number of inodes per block group; Index table position calculation: Offset of the inode within the block in the index table = inode index / (block size / inode size); Inode physical position calculation: Actual address of the inode = (index table offset position + offset of the inode within the block in the index table) × block size.
2. The disk scanning acceleration method for the Ext file system according to claim 1, characterized in that The key metadata includes: block information, inode information, descriptor information, and feature identification.
3. The disk scan acceleration method for the Ext file system according to claim 2, wherein The block information includes: block size, number of blocks per block group; The inode information includes: number of inodes per block group, inode size; The descriptor information includes: group descriptor size and position; The feature identifiers include: the enabled status of the sparse superblock, the enabled status of the elastic block group, and the enabled status of the metadata block group.
4. The disk scanning acceleration method for the Ext file system according to claim 3, characterized in that, The basic attributes of a file include: file type, file size, file permissions, and timestamp.
5. The disk scanning acceleration method for the Ext file system according to claim 4, wherein When parsing inode information to extract the basic attributes of a file, it also includes: filtering out inodes that are not files or directories if they exist.
6. The disk scanning acceleration method for the Ext file system according to claim 5, wherein The methods for parsing block information are the direct / indirect block addressing method and the extended tree method.
7. A disk scan acceleration device for the Ext file system, which is used to apply the disk scan acceleration method for the Ext file system as described in any one of claims 1-6, characterized in that, It includes: A device acquisition unit, which is used to acquire the device type. If the device type is a single-partition device, disk scanning acceleration is directly performed; If the device type is a multi-partition device, the multi-partition device is converted into a single-partition device for disk scanning; An opening unit, which is used to obtain the device path where the file system partition is located through a system call and open the device file to be scanned in the file system partition when disk scanning is performed; A reading unit, which is used to read the key metadata of the file system superblock; A scanning unit, which is used to scan the entire file system starting from the root directory according to the inode number incrementally based on the key metadata; A closing unit, which is used to release the occupied memory resources and close the scanned file of the file system when the scanning is completed.
Citation Information
Patent Citations
Multi-partition-table inquiring and processing method and device
CN105975617A
Deep analysis EXT4 file backup recovery method and system and storage medium
CN114185719A