Data access method, device and electronic device based on distributed block storage
By designing a primary index tree and a secondary index tree in memory to directly map file and data block identifiers, the performance bottleneck caused by multi-level indirect addressing in traditional distributed block storage is solved, achieving fast and efficient access to data blocks. Retrieve.
Patent Information
- Application Number
- CN202411036978.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-30
AI Technical Summary
Performance bottlenecks caused by multi-level indirect addressing and frequent disk I/O in traditional distributed block storage systems, especially in environments that require high-speed data access, result in low data block retrieval efficiency and inability to quickly locate, read and write specific data. piece.
Design a two-level index tree in the memory. The primary index tree is used to quickly locate the storage address of the secondary index tree. The secondary index tree is used to quickly locate the storage address of the data block in the physical disk. By directly mapping the file identifier and the data block identification to reduce the number of disk I/O operations.
It achieves fast access to data blocks, reduces the number of disk I/O operations, improves the search speed of the storage address of data blocks in the physical disk, and solves the problems caused by multi-level indirect addressing and frequent disk I/O in traditional solutions. Performance bottleneck.
Smart Images

Figure CN118567577B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of block storage technology, and in particular, to a data access method, device, electronic device, and storage medium based on distributed block storage. Background Art
[0002] In distributed block storage systems, file systems are usually used as the underlying storage engine, such as EXT4 (Fourth Extended File System), XFS (eXtended File System), etc. Since the file system is designed for file storage, and some files are small in size, such as 1KB, flexible indexing methods such as multi-level linear tables are usually used to meet the management requirements of files of different sizes and improve storage space utilization.
[0003] In some embodiments, in order to access a file in a physical disk that uses three-level indirect addressing, it is first necessary to perform a disk I / O to access the index node of the file to obtain the address of the first-level indirect block; then, the physical disk is accessed according to the address of the first-level indirect block, and a second disk I / O is performed to read the content of the first-level indirect block, that is, the address of the second-level indirect block; then, the physical disk is accessed according to the address of the second-level indirect block, and a third disk I / O is performed to read the content of the second-level indirect block, that is, the address of the third-level indirect block; then, the physical disk is accessed according to the address of the third-level indirect block, and a fourth disk I / O is performed to read the content of the third-level indirect block, that is, the storage address of the file on the physical disk; finally, a fifth disk I / O is performed to access the file according to the storage address of the file on the physical disk. Summary of the invention
[0004] The present specification provides a data access method based on distributed block storage, wherein a primary index tree and a secondary index tree are stored in a memory, wherein the primary index tree is used to find the storage address of the secondary index tree in the memory, and each secondary index tree is used to find the storage address of a data block included in a file stored in a physical disk in the physical disk; wherein a node of the primary index tree stores a file identifier of a file stored in the physical disk and a storage address of a secondary index tree corresponding to the file in the memory; a node of the secondary index tree corresponding to the file stores a data block identifier of a data block included in the file and a storage address of the data block in the physical disk; the method comprises:
[0005] Receive a data block read request, wherein the data block read request includes a file identifier of a file to which a first data block to be read from a physical disk belongs and a data block identifier of the first data block;
[0006] According to the file identifier of the file to which the first data block belongs, searching the first-level index tree for a storage address in the memory of the second-level index tree corresponding to the file to which the first data block belongs;
[0007] According to the data block identifier of the first data block, searching for a storage address of the first data block in the physical disk in a secondary index tree corresponding to the file to which the first data block belongs;
[0008] The first data block is read from the physical disk according to the storage address of the first data block in the physical disk.
[0009] The present specification also provides a data access device based on distributed block storage, characterized in that a primary index tree and a secondary index tree are stored in the memory of the device, the primary index tree is used to find the storage address of the secondary index tree in the memory, and each secondary index tree is used to find the storage address of a data block included in a file stored in the physical disk in the physical disk; wherein a node of the primary index tree stores a file identifier of a file stored in the physical disk and a storage address of a secondary index tree corresponding to the file in the memory; a node of the secondary index tree corresponding to the file stores a data block identifier of a data block included in the file and the storage address of the data block in the physical disk; the device comprises:
[0010] A receiving unit, configured to receive a data block read request, wherein the data block read request includes a file identifier of a file to which a first data block to be read from a physical disk belongs and a data block identifier of the first data block;
[0011] A first search unit, configured to search the primary index tree for a storage address in the memory of a secondary index tree corresponding to the file to which the first data block belongs according to a file identifier of the file to which the first data block belongs;
[0012] A second search unit, configured to search, according to a data block identifier of the first data block, for a storage address of the first data block in the physical disk in a secondary index tree corresponding to a file to which the first data block belongs;
[0013] The reading unit is used to read the first data block from the physical disk according to the storage address of the first data block in the physical disk.
[0014] This specification also provides an electronic device, comprising a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are interconnected via the bus;
[0015] The memory stores machine-readable instructions, and the processor executes the above method by calling the machine-readable instructions.
[0016] This specification also provides a machine-readable storage medium, which stores machine-readable instructions. When the machine-readable instructions are called and executed by a processor, the above method is implemented.
[0017] Through the embodiments of the present specification, two layers of index trees are designed in the memory, namely the primary index tree and the secondary index tree; wherein the primary index tree is responsible for quickly locating the storage address in the memory of the secondary index tree corresponding to a specific file stored in the physical disk, and the primary index tree establishes a direct mapping between the file identifier and the storage address in the memory of the secondary index tree, and each file stored in the physical disk has a unique node in the primary index tree; the secondary index tree is responsible for quickly locating the storage address on the physical disk of a specific data block in a specific file stored in the physical disk, and the secondary index tree establishes a direct mapping between the data block identifier and the storage address of the data block in the physical disk for each data block included in the file stored in the physical disk.
[0018] Through the above method, this manual makes it possible to retrieve data blocks without going through multi-level indirect addressing on the disk, reduces the number of disk I / O operations, and improves the speed of finding the storage address of the data block in the physical disk, thereby achieving fast access to the data block, effectively solving the performance bottleneck caused by multi-level indirect addressing and frequent disk I / O in traditional solutions, and is suitable for distributed block storage environments that require high-speed data access. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0020] Figure 1 It is a schematic diagram of a multi-level linear table indexing method shown in an exemplary embodiment;
[0021] Figure 2 is a schematic diagram of an index tree stored in a memory, shown in an exemplary embodiment;
[0022] Figure 3 is a flowchart of a data access method based on block storage shown in an exemplary embodiment;
[0023] Figure 4 This is a schematic diagram of a memory index tree generation method shown in an exemplary embodiment;
[0024] Figure 5It is a schematic diagram of a memory storage data block bitmap shown in an exemplary embodiment;
[0025] Figure 6 is a hardware structure diagram of an electronic device shown in an exemplary embodiment;
[0026] Figure 7 It is a block diagram of a data access device based on distributed block storage, showing an exemplary embodiment. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0028] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0029] In distributed block storage systems, file systems are usually used as the underlying storage engine, such as EXT4 (Fourth Extended File System), XFS (eXtended File System), etc. Since the file system is designed for file storage, and some files are small in size, such as 1KB, flexible indexing methods such as multi-level linear tables are usually used to meet the management requirements of files of different sizes and improve storage space utilization.
[0030] See also Figure 1 , Figure 1 FIG. 1 is a schematic diagram of a multi-level linear table indexing method shown in an exemplary embodiment. Figure 1As shown in the figure, the index node structure of an EXT4 file system and its relationship with the data block are shown. The index node of EXT4 is located on the far left. It is one of the core components of the file system. It is used to store the basic attributes and metadata of the file, such as permissions, owners, modification time, etc., and contains pointers to the file data blocks. The index node contains direct blocks, which can directly point to some data blocks of the file. These data blocks can directly store part of the content of the file. The index node also contains primary indirect addressing, secondary indirect addressing and tertiary indirect addressing. Among them, the primary indirect addressing is used to point to the primary block, which points to the data block; the secondary indirect addressing is used to point to the primary block, which points to the secondary block, which points to the data block; the tertiary indirect addressing is used to point to the primary block, which points to the secondary block, which points to the tertiary block, which points to the data block, and the data block stores the actual file content. Through this multi-level indirect addressing, the file system can expand the management of storage space on demand, supporting file sizes from a few KB to several TB or even larger. This mechanism enables the file system to efficiently utilize storage space while maintaining fast access to file contents, especially when dealing with large files or file fragmentation issues.
[0031] For example, a file is stored in a physical disk using a multi-level linear table index. In order to access the file, you first need to perform a disk I / O to access the file's index node to obtain the address of the first-level indirect block; then access the physical disk based on the address of the first-level indirect block, and perform a second disk I / O to read the content of the first-level indirect block, that is, the address of the second-level indirect block; then access the physical disk based on the address of the second-level indirect block, and perform a third disk I / O to read the content of the second-level indirect block, that is, the address of the third-level indirect block; then access the physical disk based on the address of the third-level indirect block, and perform a fourth disk I / O to read the content of the third-level indirect block, that is, the storage address of the file on the physical disk; finally, perform a fifth disk I / O to access the file based on the storage address of the file on the physical disk.
[0032] However, this multi-level linear table indexing method may encounter some limitations, especially in block storage systems. Block storage usually serves applications that operate directly on data blocks, such as virtual machine disks, database storage, etc. These applications prefer to quickly locate and read and write specific data blocks. Data access usually requires high throughput and low latency, and the multi-level linear table indexing method is not efficient enough when processing fine-grained block-level requests. Based on the previous analysis, multi-level linear indexing involves multiple disk I / O operations (especially when accessing large files using multi-level indirect addressing). Each disk I / O operation takes time, which significantly increases data access latency and reduces overall system performance. This performance bottleneck is particularly obvious in random read and write intensive application scenarios.
[0033] In view of this, this specification aims to propose a technical solution for data block index deployment that can facilitate search and reduce disk I / O.
[0034] In some embodiments, a primary index tree and a secondary index tree are stored in a memory, wherein the primary index tree is used to search for a storage address of the secondary index tree in the memory, and each of the secondary index trees is used to search for a storage address of a data block included in a file stored in a physical disk in the physical disk; wherein a node of the primary index tree stores a file identifier of a file stored in the physical disk and a storage address of a secondary index tree corresponding to the file in the memory; a node of the secondary index tree corresponding to the file stores a data block identifier of a data block included in the file and a storage address of the data block in the physical disk; first, a data block read request is received, wherein the data block read request includes a file identifier of a file to which a first data block to be read from the physical disk belongs and a data block identifier of the first data block; then, according to the file identifier of the file to which the first data block belongs, the storage address of the secondary index tree corresponding to the file to which the first data block belongs in the primary index tree in the memory is searched; further, according to the data block identifier of the first data block, the storage address of the first data block in the physical disk is searched in the secondary index tree corresponding to the file to which the first data block belongs; finally, according to the storage address of the first data block in the physical disk, the first data block is read from the physical disk.
[0035] For example, see Figure 2 , Figure 2 FIG. 1 is a schematic diagram of an index tree stored in a memory according to an exemplary embodiment. Figure 2As shown, the first-level index tree has 4 nodes, which correspond to the stored files file4, file5, file7, and file9 in the physical disk. The node corresponding to the stored file file9 in the physical disk contains the file identifier of the stored file file9, such as file_id9, and the storage address of the second-level index tree corresponding to the stored file file9 in the memory, such as 0𝑥00401000. The stored file file9 currently has 4 data blocks stored in the physical disk. These 4 data blocks correspond to the four nodes contained in the second-level index tree. Each node contains a data block identifier of a data block, such as the offset address of this data block in the file (this data block belongs to the 8th block in the stored file file9), and the storage address of this data block in the physical disk (such as this data block is stored in the 5th sector of the 10th track). When a data block read request is received, the file identifier file_id9 of the file to which the first data block to be read from the physical disk belongs and the data block identifier block_id8 of the first data block contained in the data block read request can be obtained. Then, according to the file identifier file_id9 of the file to which the first data block belongs, the storage address 0𝑥00401000 in the memory of the secondary index tree corresponding to the file file9 to which the first data block belongs can be searched in the primary index tree; then, according to the data block identifier block_id8 of the first data block, the storage address of the first data block in the physical disk can be searched in the secondary index tree corresponding to the file file9 to which the first data block belongs (such as this data block is stored in the 5th sector of the 10th track); finally, according to the storage address of the first data block in the physical disk, the first data block is read in the physical disk.
[0036] In some embodiments, a primary index tree and at least one secondary index tree may be stored in the memory, wherein the number of trees in the secondary index tree may be equal to the number of nodes included in the primary index tree.
[0037] It can be seen that in the technical solution of this specification, two layers of index trees are designed in the memory, namely the primary index tree and the secondary index tree; wherein the primary index tree is responsible for quickly locating the storage address of the secondary index tree corresponding to the specific file stored in the physical disk in the memory, specifically, the primary index tree establishes a direct mapping between the file identifier and the storage address of the secondary index tree in the memory, and each file stored in the physical disk has a unique node in the primary index tree; the secondary index tree is responsible for quickly locating the storage address of the specific data block in the specific file stored in the physical disk in the physical disk, specifically, the secondary index tree establishes a direct mapping between the data block identifier and the storage address of the data block in the physical disk for the data block included in each file stored in the physical disk. When it is necessary to read the data block, the storage engine of the block storage system first uses the file identifier contained in the data block read request to find the storage address of the secondary index tree of the corresponding file in the memory in the primary index tree, and then finds the storage address of the data block to be read in the physical disk in the secondary index tree according to the data block identifier contained in the data block read request, and finally reads the data block from the physical disk based on the address.
[0038] Through the above method, the storage engine designed in this specification makes it possible to retrieve data blocks without going through multi-level indirect addressing on the disk, thereby reducing the number of disk I / O operations and improving the speed of finding the storage address of the data block in the physical disk, thereby achieving fast access to data blocks, effectively solving the performance bottleneck caused by multi-level indirect addressing and frequent disk I / O in traditional solutions, and is suitable for distributed block storage environments that require high-speed data access.
[0039] The present specification is described below through specific embodiments in combination with specific application scenarios.
[0040] See also Figure 3 , Figure 3 The flowchart of a data access method based on block storage is shown in an exemplary embodiment. The method can perform the following steps:
[0041] Step 302: Receive a data block read request, wherein the data block read request includes a file identifier of a file to which a first data block to be read from a physical disk belongs and a data block identifier of the first data block.
[0042] For example, Figure 2 As shown, when a data block read request is received, the file identifier file_id9 of the file to which the first data block to be read from the physical disk belongs and the data block identifier block_id8 of the first data block contained in the data block read request can be obtained.
[0043] Among them, data access refers to the process of interaction between a program or user and data in a computer system, including operations such as reading and writing data. File identifiers are used to uniquely identify different files. File identifiers are usually file IDs or file names. This specification does not limit the specific content of file identifiers. When the storage engine of the block storage system receives a data block read request, it first quickly locates the target file through the file identifier. Inside each file stored on the physical disk, data is usually divided into fixed-size data blocks for management and storage, and each data block has a unique identifier, namely the data block identifier. In the above embodiment, according to the data block identifier of the data block to be read included in the data block read request, the block storage engine can accurately locate specific data in the file (for example, the data block identifier block_id8 refers to the 8th data block in the file), which is crucial for direct access and efficient reading of specific data blocks.
[0044] It should be noted that Figure 2 The schematic diagram of accessing the data block with the data block identifier block_id 8 contained in the file file9 is only described in an exemplary manner, and no special limitation is made on accessing other data blocks contained in the file file9 or accessing data blocks contained in other files. For example, the data block with the data block identifier block_id3 contained in the file file9 or the data block with the data block identifier block_id5 contained in the file file4 can also be accessed, which will not be described in detail here.
[0045] Step 304: According to the file identifier of the file to which the first data block belongs, search the first-level index tree for a storage address in the memory of the second-level index tree corresponding to the file to which the first data block belongs.
[0046] For example, Figure 2 As shown, the storage address 0𝑥00401000 in the memory of the secondary index tree corresponding to the file file9 to which the first data block belongs can be searched in the primary index tree according to the file identifier file_id9 of the file to which the first data block belongs.
[0047] Among them, the primary index tree and the secondary index tree are both index trees, and the index tree is a data structure used for fast retrieval, insertion and deletion operations. The index tree types of the primary index tree and the secondary index tree can be binary trees, red-black trees, etc., and this specification does not limit the specific index tree types.
[0048] Step 306: According to the data block identifier of the first data block, search for the storage address of the first data block in the physical disk in the secondary index tree corresponding to the file to which the first data block belongs.
[0049] For example, Figure 2As shown, according to the data block identifier block_id8 of the first data block, the storage address of the first data block in the physical disk is searched in the secondary index tree corresponding to the file file9 to which the first data block belongs (such as this data block is stored in the 5th sector of the 10th track).
[0050] Among them, taking the example that both the primary index tree and the secondary index tree are red-black trees, the search process of the red-black tree usually has the following three steps: first, find the root node of the red-black tree. If it is empty, it means that there is no element to be found and the search fails; if it is not empty, compare the key to be found with the key of the current node. If the key to be found is equal to the key of the current node, it means that the target has been found and the search is successful; if the key to be found is less than the key of the current node, move to the left subtree, set the left child of the current node as the new current node, and continue to compare the key to be found with the key of the current node; if the key to be found is greater than the key of the current node, move to the right subtree, set the right child of the current node as the new current node, and continue to compare the key to be found with the key of the current node. The above comparison and movement process will be performed recursively until a matching key is found, or the current node is empty (indicating that the key to be found does not exist in the tree).
[0051] Step 308: Read the first data block from the physical disk according to the storage address of the first data block in the physical disk.
[0052] For example, according to the storage address of the first data block in the physical disk (such as the data block is stored in the 5th sector of the 10th track), the first data block is read from the physical disk.
[0053] Once the storage address of the data block in the physical disk is determined, the storage engine of the block storage system will initiate a disk I / O operation to directly read the content of the data block into the memory. This process may be completed efficiently through methods such as DMA (Direct Memory Access). The read data block is then transferred to the process or service that issued the data block read request to complete the data delivery.
[0054] It should be noted that the multi-level linear table index method may aggravate the write amplification problem in scenarios directly facing block storage, especially when it comes to double log writing, because the traditional block storage system uses the file system that comes with the operating system as the storage engine, so that each disk I / O operation will trigger two log records: one is the storage engine to ensure the atomicity, consistency, isolation, and persistence of the operation, and needs to record the operation in its own transaction log; the other is the file system to ensure data integrity (the file system is not specially designed for block storage systems, and the file system itself has logs and generally cannot be turned off). This double-layer log mechanism will undoubtedly increase the burden of write operations and cause write amplification.
[0055] In this embodiment, since the block storage system can be directly called, only one log record of the block storage system is triggered, which avoids the traditional block storage system using the file system that comes with the operating system as the storage engine, so that each disk I / O operation will trigger two log records (one is recorded by the storage engine in its own log to ensure the atomicity, consistency, isolation, and persistence of the operation; the other is the log recorded by the file system itself. This is because the file system is not specially designed for the block storage system, and the file system itself also has a log and generally cannot be turned off), resulting in the write amplification problem, thereby optimizing the log writing method.
[0056] In one embodiment shown, a file index table is stored in a physical disk, and the file index table is used to record the file identifiers of files stored in the physical disk and the storage addresses of data index tables in the physical disk that correspond one-to-one to the files stored in the physical disk; the method also includes: loading the file index table into the memory; loading the data index table that corresponds one-to-one to the files stored in the physical disk into the memory according to the storage addresses of the data index table in the physical disk that correspond one-to-one to the files stored in the physical disk; generating a secondary index tree that corresponds one-to-one to the files stored in the physical disk in the memory according to the data index table that corresponds one-to-one to the files stored in the physical disk; generating the primary index tree in the memory according to the file identifiers of the files stored in the physical disk recorded in the file index table and the storage addresses in the memory of the secondary index tree generated in the memory that corresponds one-to-one to the files stored in the physical disk.
[0057] For example, see Figure 4 , Figure 4 FIG. 1 is a schematic diagram of a method for generating a memory index tree according to an exemplary embodiment. Figure 4As shown, a file index table is stored in the physical disk, and the file index table is used to record the file identifiers of files file4, file5, file7, and file9 stored in the physical disk (for example, file_id4, file_id5, file_id7, and file_id9, the specific content of which is not shown in the figure) and the storage addresses of the data index tables corresponding to the files stored in the physical disk in the physical disk (for example, the storage address of the data index table corresponding to file4 in the physical disk is track number 6 and sector number 2, the storage address of the data index table corresponding to file5 in the physical disk is track number 7 and sector number 3, the storage address of the data index table corresponding to file7 in the physical disk is track number 9 and sector number 3, and the storage address of the data index table corresponding to file9 in the physical disk is track number 1). 0 and sector number 5, the specific content is not shown in the figure); the file index table is loaded into the memory, and according to the content recorded in the file index table in the memory, the storage address of the data index table corresponding to the files file4, file5, file7, and file9 stored in the physical disk can be known, and these data index tables are loaded into the memory to generate secondary index trees corresponding to the stored files file4, file5, file7, and file9 (a total of 4 secondary index trees, only one secondary index tree corresponding to file9 is shown in the figure); finally, based on the storage address of the generated secondary index tree in the memory and the file identifiers file_id4, file_id5, file_id7, and file_id9 of the files stored in the physical disk recorded in the file index table, a primary index tree is generated.
[0058] It should be noted that Figure 4 The diagram only describes the schematic diagram of the generation method of the secondary index tree corresponding to file9 in the memory and the schematic diagram of the generation method of the primary index tree, and does not specifically limit the generation method of the secondary index tree corresponding to other files in the memory. For example, the secondary index tree corresponding to file4 is generated after the data index table corresponding to file4 is loaded into the memory, which will not be described one by one here.
[0059] The file index table is an index structure used to store file metadata. It records the file identifier of each file and the storage address of the data index table corresponding to the file on the physical disk. Through the file index table, the storage engine of the block storage system can quickly find the actual storage location of the data index table corresponding to the file on the disk according to the file identifier.
[0060] The data index table is more focused on data block level positioning. The data index table is often used to record the physical location of each data block in the file (that is, the storage address in the physical disk) to facilitate on-demand loading and processing of data blocks. After the data index table is loaded into the memory, the memory will dynamically allocate the storage address of the data index table in the memory. Therefore, the storage address of the data index table in the memory needs to be known after the data index table is loaded into the memory.
[0061] In one embodiment shown, the file index table includes array elements, each array element contains a file identifier of a file stored in a physical disk and a storage address of a data index table corresponding to the stored file in the physical disk, wherein the array elements included in the file index table are stored in the order in which the corresponding stored files are written to the physical disk.
[0062] For example, Figure 4 As shown, four files have been stored in the physical disk, namely file4, file5, file7, and file9, then the file index table includes four array elements, each array element contains a file identifier of a file stored in the physical disk and the storage address of the data index table corresponding to the stored file in the physical disk, such as the first array element of the file index table contains the file identifier file_id4 of file4 and the storage address of the data index table corresponding to file4 in the physical disk: track number 6 and sector number 2; the second array element of the file index table contains the file identifier file_id5 of file5 and the storage address of the data index table corresponding to file5 in the physical disk: track number 7 and sector number 3; the third array element of the file index table contains the file identifier file_id7 of file7 and the storage address of the data index table corresponding to file7 in the physical disk: track number 9 and sector number 3; the fourth array element of the file index table contains the file identifier file_id9 of file9 and the storage address of the data index table corresponding to file9 in the physical disk: track number 10 and sector number 5. The four files stored in the physical disk are file4, file5, file7, and file9 in order of storage time, so the array elements included in the file index table are stored in the order of file4, file5, file7, and file9.
[0063] It should be noted that in traditional file systems, file index tables (such as B-trees and B+ trees) are usually stored in an ordered structure on a physical disk. When adding a node to a B-tree or B+ tree, the splitting of the B-tree or B+ tree may be triggered, resulting in one node adding operation triggering multiple disk I / Os. In this embodiment, new elements are added to the file index table in the form of an array in an appended manner, so each time a new element is added to the file index table, only one disk I / O is triggered. In this way, when writing files multiple times in a row, the file index table is updated in an appended manner, reducing disk I / O. When the file index table is subsequently written back to the physical disk, it is also written in a sequential I / O manner, which has higher performance.
[0064] In one embodiment shown, a data index table corresponding one-to-one to files stored in a physical disk includes array elements, each array element contains a data block identifier of a data block stored in the physical disk and a storage address of the data block in the physical disk, wherein the array elements included in the data index table corresponding one-to-one to files stored in the physical disk are stored in the order in which the corresponding data blocks are written to the physical disk.
[0065] For example, Figure 4 As shown, the data index table corresponding to the files file4, file5, file7, and file9 stored in the physical disk includes array elements, each array element contains a data block identifier of a data block stored in the physical disk and the storage address of the data block in the physical disk. For example, the data index table corresponding to file9 includes 4 array elements, that is, file9 contains 4 data blocks stored in the physical disk, and the data block identifiers of these 4 data blocks are block_id4, block_id5, block_id6, and block_id8, respectively, and the corresponding storage addresses in the physical disk are track number 5 and sector number 2, track number 6 and sector number 3, track number 7 and sector number 3, and track number 8 and sector number 4, respectively. The specific content is not shown in the figure). The data block identifiers of the four data blocks stored in the physical disk contained in file9 are block_id4, block_id5, block_id6, and block_id8 in the order of storage time. Therefore, the array elements included in the data index table corresponding to file9 are stored in the order of data block identifiers block_id4, block_id5, block_id6, and block_id8.
[0066] The data index table stores data indexes in the form of an array, and each array element in the array contains a data block identifier of a data block stored in the physical disk and the storage address of the data block in the physical disk, so that the data index table contains all the data block identifiers of the data blocks stored in the physical disk and the storage addresses of the data blocks in the physical disk. The array elements included in the data index table are stored in the order in which the corresponding data blocks are written to the physical disk. A possible storage method is that the data blocks written to the physical disk first are located at the front of the array, and the data blocks written to the physical disk later are located at the back of the array, or vice versa, which is not limited in this specification.
[0067] It should be noted that in traditional file systems, data index tables (such as B-trees and B+ trees) are similar to file index tables and are usually stored on disk in an ordered structure. When adding nodes to B-trees and B+ trees, the splitting of B-trees and B+ trees may be triggered, resulting in multiple disk I / Os being triggered for one node addition operation. In this embodiment, new elements are added to the data index table in the form of an array in an appended manner, so each time a new element is added to the data index table, only one disk I / O is triggered. In this way, when file data blocks are written multiple times in a row, the data index table is updated in an appended manner, reducing disk I / O. When the data index table is subsequently written back to the physical disk, it is also written in a sequential I / O manner, which has higher performance.
[0068] In one embodiment shown, the method also includes: determining the storage address of the data block stored in the physical disk according to the file index table and the data index table corresponding to the files stored in the physical disk; generating and saving the data block bitmap in the memory according to the storage address of the data block stored in the physical disk; wherein the bits in the data block bitmap correspond one-to-one to the block storage units divided in the physical disk, the storage capacity of each block storage unit divided by the physical disk is the same, and the storage capacity of each block storage unit is not less than 1MB; the bits in the data block bitmap are set to a first value, indicating that the block storage unit corresponding to the bit has stored the data block, and the bits in the data block bitmap are set to a second value, indicating that the block storage unit corresponding to the bit does not store the data block.
[0069] For example, see Figure 5 , Figure 5 FIG. 1 is a schematic diagram of a memory storage data block bitmap shown in an exemplary embodiment. Figure 5As shown, the storage capacity of each block storage unit (such as each small square in the table of physical disk allocation in the figure) divided by the physical disk is the same, and the storage capacity of each block storage unit is not less than 1MB. If a disk configuration table, a file index table or other data objects are stored in any block storage unit divided by the physical disk, it is considered that this block storage unit has been allocated and can no longer store new data content. According to the file index table, the storage address of the data index table corresponding to the files stored in the physical disk on the physical disk can be obtained. According to the data index table corresponding to the files stored in the physical disk, the storage address of each data block stored in the physical disk contained in the files stored in the physical disk can be obtained. Then, the allocation of each block storage unit in the physical disk is determined, and then the corresponding data block bitmap is generated in the memory. Each bit in the data block bitmap corresponds to each block storage unit divided by the physical disk. When a bit in the data block bitmap is set to 1, it means that the block storage unit corresponding to the bit has stored the data block. When a bit in the data block bitmap is set to 0, it means that the block storage unit corresponding to the bit does not store the data block.
[0070] Among them, the disk configuration table is used to record the format data of the physical disk, such as the size of the file index table and the storage address of the file index table in the physical disk, the storage address and size of the block storage unit divided by the physical disk, and other information. When the storage engine is initialized, it is usually necessary to load the disk configuration table into the memory for scanning, obtain the storage address of the file index table in the physical disk, and then load the file index table into the memory, and then perform the technical solution disclosed in this specification. Considering that the storage content of the disk configuration table and the file index table is limited, they are usually stored in a fixed position in the head of the physical disk, such as the 0-1MB fixed storage disk configuration table in the head of the physical disk, and the 1-2MB fixed storage file index table in the head of the physical disk (the file index table in this solution is in array form, each array element contains a file identifier (8 bytes, i.e. 8Byte, abbreviated as 8B) and the storage address of the file data index table in the physical disk (also 8B), so each array element occupies a total of 16 bytes, 1MB÷16=64KB, that is, 64,000 files can be stored. It can be seen that a 1MB file index table is sufficient to record the information of each file stored in the physical disk). The physical disk also stores the data index table corresponding to each file and several data blocks stored in the physical disk contained in each file, which are respectively stored in the block storage units divided by the physical disk. This specification does not limit the value and meaning of the bit set value in the data block bitmap.
[0071] In this embodiment, considering that the capacity of a file in distributed block storage is very large, usually more than 10GB, the size of the data block split from each file data can be increased, and a larger block storage unit, such as at least 1MB, can be set to meet the characteristics of block storage (i.e., small number and large volume, which is completely opposite to the characteristics of file storage). This setting has the following three advantages: first, it can reduce the fragmentation of the physical disk storage space and reduce the randomness of the data address when reading and writing data blocks; second, dividing the physical disk space into block storage units of equal size is also convenient for division and for the unified management of the physical disk storage space by the storage engine of the block storage system; finally, since each block storage unit has a large storage capacity and the physical disk can accommodate limited data blocks, the indexes of these data blocks can be stored in the memory for easy search, instead of loading the indexes into the memory when needed and releasing them when the memory is insufficient, which increases the disk I / O, like an ordinary file system.
[0072] Since ordinary file systems store a data block bitmap on the disk, when a new data block is allocated, the data block bitmap information needs to be updated to the disk, resulting in additional disk I / O. However, the physical disk of the present disclosure does not store the data block bitmap, and only needs to update the data block bitmap in the memory, thus reducing unnecessary disk I / O.
[0073] In one embodiment shown, the method also includes: receiving a data block write request, the data block write request including a file identifier of a file to which a second data block to be written to the physical disk belongs and a data block identifier of the second data block; allocating a block storage unit for storing the second data block from a storage area of the physical disk where no data blocks are stored, according to the data block bitmap; writing the second data block to the physical disk according to the block storage unit allocated to the second data block; if the file identifier of the file to which the second data block belongs exists in the primary index tree, adding a node corresponding to the second data block in the secondary index tree corresponding to the file to which the second data block belongs, according to the data block identifier of the second data block and the block storage unit allocated to the second data block.
[0074] For example, a data block write request is received, and the file identifier file_id9 of the file file9 to which the second data block to be written to the physical disk belongs and the data block identifier block_id3 of the second data block are obtained. It can be known that the second data block to be written is the third data block of the file file9 with the file identifier file_id9; according to the data block bitmap, a block storage unit for storing the second data block to be written is allocated from the storage area where no data blocks are stored, and the second data block is written to the physical disk. Figure 4The primary index tree shown contains the file identifier file_id9 of the file file9 to which the second data block belongs. According to the data block identifier block_id3 of the second data block and the block storage unit allocated to the second data block, a node corresponding to the second data block is added to the secondary index tree corresponding to the file to which the second data block belongs.
[0075] Among them, the data block bitmap is an efficient data structure used in file management to track the usage of data blocks on the disk. Each bit in the bitmap corresponds to a data block on the disk, and the value of the bit (usually 0 or 1) indicates whether the corresponding data block is occupied or free. The storage area of the physical disk that does not store data blocks refers to the part of the space on the physical disk that has not been occupied by any data block. In order to effectively utilize the physical disk space and ensure data continuity, this part of the free space needs to be managed and allocated to new data blocks when needed. An index node is created in the secondary index tree for the newly written data block. This node stores the data block identifier and the actual storage address of the data block on the physical disk (that is, the allocated block storage unit). The purpose of this is to be able to quickly find its storage address on the physical disk based on the data block identifier in the future, so as to achieve efficient access to the data block.
[0076] In one embodiment shown, the method also includes: if the file identifier of the file to which the second data block belongs does not exist in the first-level index tree, allocating the storage address in the memory of the second-level index tree corresponding to the file to which the second data block belongs; based on the data block identifier of the second data block and the storage address of the second data block in the physical disk, creating in the memory a secondary index tree corresponding to the file to which the second data block belongs, and adding a node corresponding to the second data block in the secondary index tree corresponding to the file to which the second data block belongs; based on the file identifier of the file to which the second data block belongs and the storage address in the memory of the secondary index tree corresponding to the file to which the second data block belongs, adding a node corresponding to the file to which the second data block belongs in the first-level index tree.
[0077] For example, a data block write request is received, and the file identifier file_id10 of the file file10 to which the second data block to be written to the physical disk belongs and the data block identifier block_id3 of the second data block are obtained. It can be known that the second data block to be written is the third data block of the file file10 with the file identifier file_id10; according to the data block bitmap, a block storage unit for storing the second data block to be written is allocated from the storage area where no data blocks are stored (for example, the second data block is stored in the 5th sector of the 8th track), and the second data block is written to the physical disk. Figure 4The file identifier file_id10 of the file file10 to which the second data block belongs does not exist in the shown primary index tree, and the storage address 0𝑥00401234 in the memory of the secondary index tree corresponding to the file file10 to which the second data block belongs is allocated; based on the data block identifier block_id3 of the second data block and the storage address of the second data block in the physical disk (track number 8 and sector number 5), a secondary index tree corresponding to the file file10 to which the second data block belongs is created in the memory, and a node corresponding to the second data block is added to the secondary index tree corresponding to the file to which the second data block belongs; based on the file identifier file_id10 of the file file10 to which the second data block belongs and the storage address in the memory of the secondary index tree corresponding to the file file10 to which the second data block belongs (for example, the storage address dynamically allocated in the memory for the secondary index tree corresponding to file10 is 0𝑥00401234), a node corresponding to the file file10 to which the second data block belongs is added to the primary index tree.
[0078] Among them, when the storage engine of the block storage system tries to write the data block of a new file (such as the data block of file10), it first searches for the file identifier (file_id10) in the primary index tree. If it cannot be found (that is, the file has not been indexed before), it indicates that this is the first time to allocate storage space and create an index for the file. Since there is no index specifying file file10 in the primary index tree, the storage engine of the block storage system dynamically allocates a space in the memory (for example, address 0𝑥00401234) to create a secondary index tree for the file (file10). This shows that the index structure is dynamically extended and can grow as new files are added. Then a new secondary index tree is created at the dynamically allocated address in the memory, which is specifically used to manage the data block index of file10. This index tree will be built based on the data block identifier (such as block_id3) and the physical address of the data block on the disk (track number 8 and sector number 5) to ensure that the data block can be quickly located through the index later. Finally, based on the file identifier file_id10 of the new file and the address of its secondary index tree in memory (0𝑥00401234), a new node is added to the primary index tree to index this file. This step ensures that the corresponding secondary index tree can be efficiently found through the file identifier in the future, and then all data blocks of the file can be accessed.
[0079] Corresponding to the above-mentioned embodiment of the data access method based on block storage, this specification also provides an embodiment of a data access device based on block storage.
[0080] See also Figure 6 , Figure 6It is a hardware structure diagram of an electronic device shown in an exemplary embodiment. At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, a memory 608 and a non-volatile memory 610, and of course may also include other required hardware. One or more embodiments of this specification can be implemented based on software, such as the processor 602 reading the corresponding computer program from the non-volatile memory 610 into the memory 608 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0081] See also Figure 7 , Figure 7 FIG. 7 is a block diagram of a data access device based on distributed block storage according to an exemplary embodiment. The data access device based on distributed block storage 700 can be applied to Figure 6 In the electronic device shown, the technical solution of this specification is implemented. The memory of the device stores a primary index tree and a secondary index tree, the primary index tree is used to find the storage address of the secondary index tree in the memory, and each secondary index tree is used to find the storage address of a data block included in a file stored in the physical disk in the physical disk; wherein a node of the primary index tree stores a file identifier of a file stored in the physical disk and the storage address of the secondary index tree corresponding to the file in the memory; a node of the secondary index tree corresponding to the file stores a data block identifier of a data block included in the file and the storage address of the data block in the physical disk; the device comprises:
[0082] A receiving unit 702 is configured to receive a data block read request, wherein the data block read request includes a file identifier of a file to which a first data block to be read from a physical disk belongs and a data block identifier of the first data block;
[0083] A first search unit 704 is configured to search, according to a file identifier of the file to which the first data block belongs, for a storage address in the memory of a secondary index tree corresponding to the file to which the first data block belongs in the primary index tree;
[0084] A second search unit 706 is configured to search, according to a data block identifier of the first data block, for a storage address of the first data block in the physical disk in a secondary index tree corresponding to a file to which the first data block belongs;
[0085] The reading unit 708 is configured to read the first data block from the physical disk according to the storage address of the first data block in the physical disk.
[0086] In some embodiments, a file index table is stored in the physical disk of the device, and the file index table is used to record the file identifiers of the files stored in the physical disk and the storage addresses of the data index tables corresponding to the files stored in the physical disk in a one-to-one manner in the physical disk; the device further includes:
[0087] A first loading unit, used for loading the file index table into a memory;
[0088] A second loading unit, configured to load the data index table corresponding to the files stored in the physical disk one by one into the memory according to the storage address of the data index table corresponding to the files stored in the physical disk in the physical disk;
[0089] A first generating unit, configured to generate in a memory a secondary index tree corresponding one-to-one to the files stored in the physical disk according to a data index table corresponding one-to-one to the files stored in the physical disk;
[0090] The second generating unit is used to generate the primary index tree in the memory according to the file identifier of the file stored in the physical disk recorded in the file index table, and the storage address in the memory of the secondary index tree generated in the memory and corresponding one-to-one to the file stored in the physical disk.
[0091] In some embodiments, the file index table includes array elements, each array element contains a file identifier of a file stored in a physical disk and a storage address of a data index table corresponding to the stored file in the physical disk, wherein the array elements included in the file index table are stored in the order in which the corresponding stored files are written to the physical disk.
[0092] In some embodiments, a data index table corresponding one-to-one to files stored in a physical disk includes array elements, each array element contains a data block identifier of a data block stored in the physical disk and a storage address of the data block in the physical disk, wherein the array elements included in the data index table corresponding one-to-one to files stored in the physical disk are stored in the order in which the corresponding data blocks are written to the physical disk.
[0093] In some embodiments, the apparatus further comprises:
[0094] A determination unit, configured to determine the storage address of the data block stored in the physical disk in the physical disk according to the file index table and the data index table corresponding to the files stored in the physical disk;
[0095] The third generating unit is used to generate and save a data block bitmap in the memory according to the storage address of the data block stored in the physical disk in the physical disk; wherein the bits in the data block bitmap correspond one-to-one to the block storage units divided in the physical disk, the storage capacity of each block storage unit divided by the physical disk is the same, and the storage capacity of each block storage unit is not less than 1MB; the bits in the data block bitmap are set to a first value, indicating that the block storage unit corresponding to the bit has stored the data block, and the bits in the data block bitmap are set to a second value, indicating that the block storage unit corresponding to the bit does not store the data block.
[0096] In some embodiments, the apparatus further comprises:
[0097] A receiving unit, configured to receive a data block write request, wherein the data block write request includes a file identifier of a file to which a second data block to be written to the physical disk belongs and a data block identifier of the second data block;
[0098] A first allocation unit, configured to allocate a block storage unit for storing the second data block from a storage area of the physical disk where no data blocks are stored, according to the data block bitmap;
[0099] a writing unit, configured to write the second data block into a physical disk according to the block storage unit allocated for the second data block;
[0100] A first adding unit is used to add a node corresponding to the second data block in a secondary index tree corresponding to the file to which the second data block belongs, according to the data block identifier of the second data block and the block storage unit allocated to the second data block, if the file identifier of the file to which the second data block belongs exists in the primary index tree.
[0101] In some embodiments, the apparatus further comprises:
[0102] A second allocation unit is configured to allocate a storage address in the memory of a secondary index tree corresponding to the file to which the second data block belongs if the file identifier of the file to which the second data block belongs does not exist in the primary index tree;
[0103] A second adding unit is used to create a secondary index tree corresponding to the file to which the second data block belongs in the memory based on the data block identifier of the second data block and the storage address of the second data block in the physical disk, and add a node corresponding to the second data block in the secondary index tree corresponding to the file to which the second data block belongs;
[0104] The third adding unit is used to add a node corresponding to the file to which the second data block belongs in the primary index tree based on the file identifier of the file to which the second data block belongs and the storage address in the memory of the secondary index tree corresponding to the file to which the second data block belongs.
[0105] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0106] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. Ordinary technicians in this field can understand and implement it without paying creative work.
[0107] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0108] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0109] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0110] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0111] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0112] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0113] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0114] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "one", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0115] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0116] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A data access method based on distributed block storage, characterized in that: A primary index tree and a secondary index tree are stored in the memory, wherein the primary index tree is used to find the storage address of the secondary index tree in the memory, and each secondary index tree is used to find the storage address of a data block included in a file stored in the physical disk in the physical disk; wherein a node of the primary index tree stores a file identifier of a file stored in the physical disk and a storage address of a secondary index tree corresponding to the file in the memory; a node of the secondary index tree corresponding to the file stores a data block identifier of a data block included in the file and a storage address of the data block in the physical disk; a file index table is stored in the physical disk, wherein the file index table is used to record the file identifier of the file stored in the physical disk and the storage address of the data index table corresponding to the file stored in the physical disk in a one-to-one manner in the physical disk; the method comprises: Loading the file index table into memory; According to the storage address of the data index table corresponding to the files stored in the physical disk, the data index table corresponding to the files stored in the physical disk is loaded into the memory; According to the data index table corresponding to the files stored in the physical disk, a secondary index tree corresponding to the files stored in the physical disk is generated in the memory; Generate the primary index tree in the memory according to the file identifiers of the files stored in the physical disk recorded in the file index table and the storage addresses in the memory of the secondary index trees generated in the memory and corresponding to the files stored in the physical disk one by one; Receive a data block read request, wherein the data block read request includes a file identifier of a file to which a first data block to be read from a physical disk belongs and a data block identifier of the first data block; According to the file identifier of the file to which the first data block belongs, searching the first-level index tree for a storage address in the memory of the second-level index tree corresponding to the file to which the first data block belongs; According to the data block identifier of the first data block, searching for a storage address of the first data block in the physical disk in a secondary index tree corresponding to the file to which the first data block belongs; The first data block is read from the physical disk according to the storage address of the first data block in the physical disk.
2. The method according to claim 1, characterized in that The file index table includes array elements, each array element contains a file identifier of a file stored in a physical disk and a storage address of a data index table corresponding to the stored file in the physical disk, wherein the array elements included in the file index table are stored in the order in which the corresponding stored files are written to the physical disk.
3. The method according to claim 1, characterized in that The data index table corresponding one-to-one to the files stored in the physical disk includes array elements, each array element contains a data block identifier of a data block stored in the physical disk and the storage address of the data block in the physical disk, wherein the array elements included in the data index table corresponding one-to-one to the files stored in the physical disk are stored in the order in which the corresponding data blocks are written to the physical disk.
4. The method according to claim 1, characterized in that: The method further comprises: Determine the storage address of the data block stored in the physical disk in the physical disk according to the file index table and the data index table corresponding to the files stored in the physical disk; A data block bitmap is generated and saved in a memory according to the storage addresses of the data blocks stored in the physical disk; wherein the bits in the data block bitmap correspond one-to-one to the block storage units divided in the physical disk, the storage capacity of each block storage unit divided by the physical disk is the same, and the storage capacity of each block storage unit is not less than 1MB; the bits in the data block bitmap are set to a first value, indicating that the block storage unit corresponding to the bit has stored the data block, and the bits in the data block bitmap are set to a second value, indicating that the block storage unit corresponding to the bit does not store the data block.
5. The method according to claim 4, characterized in that The method further comprises: receiving a data block write request, wherein the data block write request includes a file identifier of a file to which a second data block to be written to the physical disk belongs and a data block identifier of the second data block; Allocating a block storage unit for storing the second data block from a storage area of the physical disk that does not store data blocks according to the data block bitmap; Writing the second data block to a physical disk according to the block storage unit allocated for the second data block; If the file identifier of the file to which the second data block belongs exists in the primary index tree, a node corresponding to the second data block is added in the secondary index tree corresponding to the file to which the second data block belongs according to the data block identifier of the second data block and the block storage unit allocated to the second data block.
6. The method according to claim 5, characterized in that The method further comprises: If the file identifier of the file to which the second data block belongs does not exist in the primary index tree, allocating a storage address in the memory of the secondary index tree corresponding to the file to which the second data block belongs; Based on the data block identifier of the second data block and the storage address of the second data block in the physical disk, create a secondary index tree corresponding to the file to which the second data block belongs in the memory, and add a node corresponding to the second data block in the secondary index tree corresponding to the file to which the second data block belongs; Based on the file identifier of the file to which the second data block belongs and the storage address in the memory of the secondary index tree corresponding to the file to which the second data block belongs, a node corresponding to the file to which the second data block belongs is added in the primary index tree.
7. A data access device based on distributed block storage, characterized in that: The memory of the device stores a primary index tree and a secondary index tree, wherein the primary index tree is used to find the storage address of the secondary index tree in the memory, and each secondary index tree is used to find the storage address of a data block included in a file stored in the physical disk in the physical disk; wherein a node of the primary index tree stores a file identifier of a file stored in the physical disk and a storage address of a secondary index tree corresponding to the file in the memory; a node of the secondary index tree corresponding to the file stores a data block identifier of a data block included in the file and a storage address of the data block in the physical disk; a file index table is stored in the physical disk, wherein the file index table is used to record the file identifier of the file stored in the physical disk and the storage address of the data index table corresponding to the file stored in the physical disk in a one-to-one manner in the physical disk; the device comprises: A first loading unit, used for loading the file index table into a memory; A second loading unit, configured to load the data index table corresponding to the files stored in the physical disk one by one into the memory according to the storage address of the data index table corresponding to the files stored in the physical disk in the physical disk; A first generating unit, configured to generate in a memory a secondary index tree corresponding one-to-one to the files stored in the physical disk according to a data index table corresponding one-to-one to the files stored in the physical disk; A second generating unit is used to generate the primary index tree in the memory according to the file identifiers of the files stored in the physical disk recorded in the file index table and the storage addresses in the memory of the secondary index trees generated in the memory and corresponding to the files stored in the physical disk one by one; A receiving unit, configured to receive a data block read request, wherein the data block read request includes a file identifier of a file to which a first data block to be read from a physical disk belongs and a data block identifier of the first data block; A first search unit, configured to search the primary index tree for a storage address in the memory of a secondary index tree corresponding to the file to which the first data block belongs according to a file identifier of the file to which the first data block belongs; A second search unit, configured to search, according to a data block identifier of the first data block, for a storage address of the first data block in the physical disk in a secondary index tree corresponding to a file to which the first data block belongs; The reading unit is used to read the first data block from the physical disk according to the storage address of the first data block in the physical disk.
8. An electronic device, characterized in that: It includes a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are interconnected via the bus; The memory stores machine-readable instructions, and the processor executes the method according to any one of claims 1 to 6 by calling the machine-readable instructions.
9. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-readable instructions, and when the machine-readable instructions are called and executed by a processor, the method according to any one of claims 1 to 6 is implemented.
