Index management method, distributed block storage system, storage medium and product
Patent Information
- Application Number
- CN202611063897.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-17
- Publication Date
- 2026-08-18
AI Technical Summary
这种“先读索引、再读数据”的机制导致一次读IO需要经历两次磁盘读取操作,因此读IO时系统性能受限且延迟较高
[0016] In the technical solution of this application, the distributed block storage system divides the logical storage space into multiple data blocks of a set granularity: according to the number of data blocks, an index space with matching capacity is allocated in memory; all first index entries of the logical storage space are stored in the index space; wherein, the first index entry corresponds one-to-one with the data block, and the first index entry is used to record the physical address of the corresponding data block on the physical storage medium. Thus, this embodiment decouples the index from the number of writes, and constructs index entries based on data blocks, ensuring that the number of indexes and the memory space occupied by the indexes can be predetermined according to the number of data blocks, so that the indexes can all be stored in memory. When executing a read request, only the physical storage medium needs to be read once, significantly reducing read request latency and improving the system's read performance.
Smart Images

Figure CN122593710A_ABST
Abstract
Description
Technical Field
[0001] This application relates to distributed storage technology, and more particularly to an index management method, a distributed block storage system, a storage medium, and a product. Background Technology
[0002] In distributed block storage systems, an append-only write model is typically used to improve storage performance. In this model, write I / O (Input / Output) data is sequentially appended to the end of the disk, effectively improving disk write throughput compared to a random write model. However, because data is written append-only, there is no fixed correspondence between the physical and logical addresses of data on the disk. Therefore, an index layer is needed to record the mapping between the logical and physical addresses of valid data, allowing read I / O to quickly locate the actual position of the data on the disk based on the logical address.
[0003] In related technologies, the index layer is typically implemented using a Log-Structured Merge-Tree (LSM-Tree). LSM-Tree employs a hierarchical storage architecture, where index data is organized in memory as MemTables and sequentially written to disk in batches to form Sorted String Table (SSTable) files. Because write operations are converted into sequential disk writes, LSM-Tree is well-suited to the IO characteristics of append-only write models. LSM-Tree organizes and manages the index in key-value (KV) pairs, where the key is a logical block address (LBA) and the value is the physical address of the data on disk. Since each write IO requires recording the index, the amount of index data grows with the number of writes; therefore, index data is typically persistently stored on a larger capacity disk.
[0004] However, when using LSM-Tree to manage indexes, during read I / O, the index data in the LSM-Tree needs to be read from the disk first to obtain the physical address corresponding to the logical address, and then the actual data content needs to be read from the disk based on that physical address. This "read index first, then read data" mechanism results in a single read I / O requiring two disk read operations, thus limiting system performance and causing high latency during read I / O. Summary of the Invention
[0005] In view of this, embodiments of this application provide an index management method, a distributed block storage system, a storage medium, and a product.
[0006] The technical solution of this application embodiment is implemented as follows: In a first aspect, embodiments of this application provide an index management method applied to a distributed block storage system, the method comprising: Divide the logical storage space into multiple data blocks with defined granularity: Based on the number of data blocks, allocate an index space of matching capacity in memory; Store all first index entries of the logical storage space in the index space; The first index entry corresponds one-to-one with the data block, and the first index entry is used to record the physical address of the corresponding data block on the physical storage medium.
[0007] The method in the above scheme further includes: In response to a received write request, determine the corresponding data block to be written; The data requested in the write request is appended to the physical storage medium, and the corresponding physical address for writing is obtained; The physical address to be written is recorded in the first index entry corresponding to the data block to be written.
[0008] The method in the above scheme further includes: In response to a received read request, determine the corresponding data block to be read; Read the first index entry corresponding to the read data block from the index space and determine the physical address of the record. Read the stored data from the physical address of the physical storage medium.
[0009] The method in the above scheme further includes: Store all the second index entries of the logical storage space in the index space; The second index item corresponds one-to-one with the data block. The second index item is used to record the order of the data segment to which the corresponding data block belongs in the existing data segments. The data segment has a writable state or a read-only state. The method further includes: Based on the second index entry, garbage collection is performed on the data blocks in the read-only data segment.
[0010] The method in the above scheme further includes: The data segment to which the corresponding data block belongs is determined based on the bit position of the set value in the second index entry; The second index entry includes at least one bit, which corresponds to an existing data segment and is arranged according to the order of the corresponding data segments. The set value represents the data segment to which the data block belongs.
[0011] The method in the above scheme further includes: Based on the value of the second index item, determine the data segment to which the corresponding data block belongs; The second index entry includes a single byte, the value of which represents the order of the data segment to which the data block belongs.
[0012] The method in the above scheme further includes: The first index entries stored in the index space are written asynchronously in batches to the physical storage medium.
[0013] In a second aspect, embodiments of this application provide a distributed block storage system, including: a processor and a memory for storing a computer program capable of running on the processor, wherein the processor, when running the computer program, performs the steps of the method described in the first aspect.
[0014] Thirdly, embodiments of this application provide a storage medium storing a computer program, which, when executed by a processor, implements the steps of the method described in the first aspect.
[0015] Fourthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described in the first aspect.
[0016] In the technical solution of this application, the distributed block storage system divides the logical storage space into multiple data blocks of a set granularity: according to the number of data blocks, an index space with matching capacity is allocated in memory; all first index entries of the logical storage space are stored in the index space; wherein, the first index entry corresponds one-to-one with the data block, and the first index entry is used to record the physical address of the corresponding data block on the physical storage medium. Thus, this embodiment decouples the index from the number of writes, and constructs index entries based on data blocks, ensuring that the number of indexes and the memory space occupied by the indexes can be predetermined according to the number of data blocks, so that the indexes can all be stored in memory. When executing a read request, only the physical storage medium needs to be read once, significantly reducing read request latency and improving the system's read performance. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating the index management method according to an embodiment of this application; Figure 2 This is a flowchart illustrating the request processing process for an embodiment of this application. Figure 3 This is a flowchart illustrating the write and read request processing in an embodiment of this application. Figure 4 This is a first schematic diagram of the second index item in an embodiment of this application; Figure 5This is a second schematic diagram of the second index item in the embodiments of this application; Figure 6 This is a schematic diagram of the structure of the index management device according to an embodiment of this application; Figure 7 This is a schematic diagram of the structure of the distributed block storage system according to an embodiment of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] Here, a distributed block storage system is a storage system that pools storage resources from multiple physical storage media to form logical storage spaces and provides them to clients. Based on a distributed storage architecture, the distributed block storage system achieves unified management and flexible expansion of storage resources. Furthermore, through resource pooling, clients do not need to concern themselves with the distribution and specific location of the underlying physical storage media; they only need to access the logical storage space to complete data read and write operations on the corresponding physical storage media.
[0020] In distributed block storage systems, the physical storage media, also known as disks, typically include hard disk drives (HDDs) and solid-state drives (SSDs). Non-volatile memory express solid-state drives (NVMe SSDs), with their advantages of low latency, high throughput, and high input / output operations per second (IOPS), have become the primary storage medium choice for high-performance distributed block storage systems. To fully leverage the high throughput of NVMe SSDs, distributed block storage engine architectures typically employ a logical storage space distribution approach, distributing logically contiguous I / O concurrently across different NVMe SSDs to achieve overall high system throughput.
[0021] It's important to note that in distributed block storage systems, disks typically carry replicas of data from multiple replication groups simultaneously. When multiple replication groups within a single NVMe SSD concurrently write data, these I / O streams alternate, resulting in random write requests to the disk. For example, with two replication groups, if the data is partitioned and written to the NVMe SSD—for instance, writing data from replica A to addresses 100-103 and data from replica B to addresses 200-203—the disk would need to write data sequentially according to addresses 100, 200, 101, 201… This discontinuous physical addressing introduces frequent seek overhead and write amplification, hindering the full utilization of the NVMe SSD's peak performance. Therefore, when multiple I / O streams are written concurrently, they are typically merged into a single continuous I / O stream, and an append-only write model is used. Append-only writes all data to be written sequentially to the end of the disk according to the order of reception, ensuring continuous and ordered write positions without frequent seeks. For example, data from multiple I / O streams can be sequentially appended to a contiguous space of addresses 200-207, with data from replica A and replica B being written to disk alternately and continuously. This effectively reduces addressing overhead and fully leverages the peak performance of the NVMe SSD.
[0022] It's important to note that while append-only write models can improve overall system write performance, the physical address of the data is determined by the write order, not by the logical address of the logical storage space. Therefore, an index layer is needed to record the mapping between the logical and physical addresses of the data, allowing read I / O to quickly locate the actual location of the data on the disk. In related technologies, the index layer is typically implemented using an LSM-Tree.
[0023] Here, LSM-Tree is an index data structure that combines memory and disk, improving write performance through batch sequential writes. LSM-Tree employs a hierarchical storage architecture. Index data is organized in memory as a MemTable and then written to disk in batches sequentially to form an ordered string table (SSTable) file. Because write operations are converted into sequential disk writes, LSM-Tree effectively reduces the addressing overhead of random writes and adapts to the IO characteristics of append-only write models. LSM-Tree organizes and manages the index in key-value pairs, where the key is a logical address and the value is the physical address of the data on disk corresponding to that logical address.
[0024] It's important to note that, based on the append-only write model, an index needs to be recorded for each data write, causing the total amount of index data to grow with each write operation. Since the total index data increases with the number of writes, storing all index data in memory would lead to a continuous increase in memory costs. Therefore, LSM-Tree typically persists index data to larger, lower-cost disks. However, when managing indexes using LSM-Tree, performing a read I / O requires first reading the index data from the LSM-Tree from disk, obtaining the physical address corresponding to the logical address from the index data, and then reading the actual data content from disk based on that physical address. This means that performing a single read I / O requires two disk read operations. Therefore, this "read index first, then read data" disk read mechanism results in high latency for read I / O in distributed block storage systems.
[0025] Based on this, this application provides an index management method for distributed block storage systems, aiming to achieve full-memory index storage, thereby reducing read request latency and improving system read performance.
[0026] For example, the index management method provided in the embodiments of this application is as follows: Figure 1 As shown, the method includes: Step 101: Divide the logical storage space into multiple data blocks with a set granularity.
[0027] Step 102: Allocate an index space in memory with a matching capacity based on the number of data blocks.
[0028] Step 103: Store all first index entries of the logical storage space in the index space.
[0029] The first index entry corresponds one-to-one with a data block, and the first index entry is used to record the physical address of the corresponding data block on the physical storage medium.
[0030] Here, logical storage space refers to the storage resources created for clients in a distributed block storage system. Specifically, it refers to storage units that are visible and writable to the client, but not actual physical storage resources. Instead, it is a logical abstraction of the underlying physical storage media. Logical storage spaces typically include, but are not limited to, logical volumes (LVs), logical unit numbers (LUNs), and cloud disks. The capacity of the logical storage space is allocated by the distributed block storage system according to client needs, and corresponding logical address ranges are pre-allocated for each logical storage space. When performing read and write operations on the logical storage space, the client only needs to address it using the corresponding logical address, without needing to concern itself with the distribution and specific location of the underlying physical storage media.
[0031] Here, a data block is a basic unit obtained by dividing the logical storage space according to a set granularity, and each data block corresponds to a continuous logical address range of the logical storage space. In this embodiment, all data blocks are of the same fixed size. By dividing the logical storage space into fixed-size data blocks, the logical storage space can be uniformly managed and organized using data blocks as the basic unit.
[0032] Here, the physical storage medium refers to the hardware device that actually stores data in a distributed block storage system, used for persistent storage of data written by the client. In this embodiment, the physical storage medium is described as a disk, which may include an SSD, such as an NVMe SSD, or an HDD. It should be noted that the disk is only an example of a physical storage medium, and the physical storage medium in this embodiment is not limited to the form of a disk.
[0033] Understandably, since logical storage space is a logical abstraction of the storage resources of physical storage media, all read and write operations performed by the client on logical storage space will ultimately be mapped and implemented on the corresponding physical storage media. Specifically, when the client performs read and write operations on logical storage space, the corresponding read / write request carries the logical address to be operated on. The system queries the index based on the logical address to determine the physical address corresponding to the logical address on the physical storage media, and then completes the data read / write operation on that physical address.
[0034] Here, memory refers to the local memory resources of a distributed block storage system, used for temporary storage of running programs and data. Typically, the latency for accessing memory is on the order of nanoseconds, while the latency for accessing physical storage media is on the order of microseconds or even milliseconds. Therefore, storing data in memory can significantly reduce data access latency and improve data access speed.
[0035] It should be noted that although storing the entire index data in memory with faster access speed can significantly improve the system's read speed, the index layer in related technologies usually directly maintains the mapping relationship between logical addresses and physical addresses. Therefore, each write operation will generate a new index entry, causing the total amount of index data to continue to grow with the number of writes. Since the limited memory capacity cannot accommodate the continuously growing index data, it is necessary to store the index data on a disk with slower access speed but larger capacity.
[0036] To address the aforementioned issue of mismatch between memory capacity and total index data, this application embodiment reconstructs the index entries of the logical storage space based on the mapping relationship between data blocks and physical addresses. This decouples the number of index entries from the number of writes, ensuring that the number of index entries can be predetermined. Consequently, the entire index data is stored in memory with limited capacity to improve read speed.
[0037] It should be noted that the smallest unit for reading and writing physical storage media such as SSDs is a page, which is typically 4KB in size. To ensure data read and write speed, in distributed block storage systems, read and write requests are usually aligned to 4KB, meaning that the starting logical address of each I / O operation falls on an integer multiple of 4KB. Based on this characteristic, this embodiment divides the logical storage space into multiple data blocks that match the read and write granularity. Each data block corresponds to a continuous logical address segment, and the smallest mapping unit between logical addresses and physical addresses in the index is replaced with the mapping relationship between data blocks and physical addresses.
[0038] In some embodiments, the granularity is set to the minimum unit size for SSD read and write, which is 4KB.
[0039] Specifically, in this embodiment, each data block corresponds to only one unique first index entry. Each first index entry has one index slot, which is used to record the physical address corresponding to valid data. In the LSM-Tree scheme, due to the append-only write method, data update or deletion operations append new index entries to the index layer, resulting in both valid and invalid index entries existing on the disk, causing the index data volume to continuously grow. In this application, the first index entry uses an overwrite update method. After each data update, the index slot only retains the mapping relationship with the physical address of valid data, and no longer records invalid data addresses, thus avoiding the accumulation of invalid indexes and interference with queries. Correspondingly, each write request records the index according to the set granularity of the data block, recording the physical address of the current write in the index slot of the corresponding first index entry, while each read request directly obtains the physical address information based on the corresponding first index entry.
[0040] It is understandable that, since the first index entry corresponds one-to-one with a data block, the number of first index entries is equal to the number of data blocks. That is, the number of first index entries can be predetermined by the capacity of the logical storage space. For example, if the capacity of the logical storage space is 32TB and the data block granularity is 4KB, then the number of data blocks is 32TB / 4KB. Correspondingly, the number of first index entries in the logical storage space is 32TB / 4KB, and this number will not change as data is written.
[0041] It is understood that the embodiments of this application, based on the read / write characteristics of a distributed block storage system, construct a first index entry between the data blocks obtained after the logical storage space is divided and the physical storage medium. Since the number of the first index entries can be predetermined based on the capacity of the logical storage space and does not increase with the number of writes, the memory space occupied by the first index entry is a finite value related to the capacity of the logical storage space, rather than an uncontrollable value related to the number of writes. Based on this, an index space matching the number of index entries can be pre-allocated in memory, and this index space does not need to be dynamically expanded during system operation. This ensures that memory usage is predictably controllable and avoids the problem of insufficient memory due to the growth of index data, allowing the entire index to be stored in memory.
[0042] It is understood that the embodiments of this application decouple the index from the number of writes and construct index items based on data blocks, ensuring that the number of indexes and the memory space occupied by the indexes can be predetermined according to the number of data blocks, so that the indexes can be stored in memory. When a read request is executed, the physical storage medium only needs to be read once, which significantly reduces the read request latency and improves the read performance of the system.
[0043] For example, the method further includes: in response to a received write request, determining a corresponding write data block; appending the data of the write request to the physical storage medium and obtaining the corresponding write physical address; and recording the write physical address in a first index entry corresponding to the write data block.
[0044] Here, a write request is a request from the client to write data to the logical storage space, including but not limited to write I / O.
[0045] The write request carries information such as the data to be written, the starting logical address of this write operation, and the data length.
[0046] Accordingly, in response to the received write request, the corresponding write data block is determined, including: determining the logical address segment to be written this time based on the received write request; and determining the corresponding write data block based on the logical address segment to be written this time.
[0047] The logical address range to be written is determined based on the starting logical address and data length carried in the write request. For example, if the starting logical address is 1000 (with 512 bytes as the basic unit of logical address) and the data length is 4KB, then this write corresponds to 8 logical addresses (1000 to 1007). Alternatively, if the data length is 16KB, then it corresponds to 32 logical addresses (1000 to 1031).
[0048] It is understandable that, since each data block corresponds to a continuous range of logical addresses in the logical storage space, the data block to which the logical address range to be written can be determined based on the address range covered by the logical address range being written. For example, if the logical address range corresponding to the write request is 1000 to 1007, then the 126th data block in the logical storage space corresponding to this address range can be determined, thus identifying the 126th data block as being written.
[0049] Here, appending the requested data to the physical storage medium specifically refers to using an append-write model to write the requested data to the physical storage medium. The append-write model means that the data to be written is sequentially written to the end of the physical storage medium. Each write operation is performed after the end of the currently written data, and the write positions are consecutive and ordered, eliminating the need for address seeking before writing. For example, if the end of the currently written data on the physical storage medium is address 999, and the length of the data in this write request is 4KB, then the data will be written starting from address 1000. After the write is completed, the end position will be updated to address 1007, and the next write request will continue writing from this updated end position.
[0050] It should be noted that in distributed block storage systems, the append-write model can merge multiple I / O streams into a single continuous stream, allowing the physical storage medium to operate in sequential write mode. This effectively reduces addressing overhead and write amplification, fully leveraging the peak throughput performance of high-performance storage media such as NVMe SSDs.
[0051] Here, the obtained write physical address is used to indicate the storage location of the data on the physical storage medium. This location can be represented in the form of a physical address or in the form of an address offset.
[0052] It should be noted that after the data requested for the write request is written to the physical storage medium, a new mapping relationship is formed between the written data block and the physical address of the write operation. Accordingly, recording the physical address in the first index entry corresponding to the written data block specifically means recording the physical address in the index slot of the first index entry of the written data block. Specifically, if the written data block has not been written to before this write operation (i.e., the index slot of the corresponding first index entry is empty), the physical address of the write operation is directly recorded in the index slot. If the written data block has been written to before this write operation (i.e., the index slot of the corresponding first index entry already records the physical address), the physical address of the write operation replaces the previously recorded physical address in the index slot. This ensures that the written data block maps to the newly written valid data, and guarantees that the number of first index entries is consistent with the number of data blocks, not increasing with the number of writes, thus achieving full-memory indexed storage.
[0053] In one example of this application, the process of a distributed block storage system updating an in-memory storage index in response to write I / O is as follows: Figure 2 As shown. For a logical volume visible to the client, the number of first index entries (i.e., the number of data blocks (Pages) in the volume divided into 4KB granularities) can be pre-calculated based on the volume's capacity. Then, index space matching the capacity is pre-allocated in memory based on the number of first index entries (Page indexes). Taking a write request with a data length of 16KB as an example, after writing the data to disk based on the append write model, the address offset (offset_in_storage) representing the physical address of the write is obtained, and the corresponding Page index is updated according to the write position of the write request in the Volume.
[0054] For example, the method further includes: in response to a received read request, determining a corresponding read data block; reading a first index entry corresponding to the read data block from the index space, and determining the read physical address of the record; and reading the stored data from the read physical address of the physical storage medium.
[0055] Here, a read request is a request from a client to read data from logical storage space, including but not limited to read I / O.
[0056] The read request carries information such as the starting logical address and data length for this read.
[0057] Accordingly, in response to a received read request, the corresponding read data block is determined, including: determining the logical address segment to be read in this read based on the received read request; and determining the corresponding read data block based on the logical address segment to be read in this read.
[0058] The logical address range read in this instance is determined based on the starting logical address and data length carried in the read request. For example, if the starting logical address of this read is 1000 (with 512 bytes as the basic unit of logical address) and the data length is 4KB, then this read corresponds to 8 logical addresses (1000 to 1007).
[0059] Understandably, since each data block corresponds to a continuous range of logical addresses in the logical storage space, the data block to which the logical address range to be read can be determined based on the address range covered by the logical address range being read. For example, if the logical address range corresponding to the read request is 1000 to 1007, then the 126th data block in the logical storage space corresponding to this address range can be determined, thus identifying the 126th data block as being read.
[0060] Understandably, since the first index entry records the physical address corresponding to the most recent write to the data block (i.e., the physical address of the valid data), the read physical address obtained from the index slot is the actual location of the valid data being read on the physical storage medium. Subsequently, the data stored in the physical storage medium is read according to this read physical address, completing the read request processing.
[0061] Understandably, since the entire index space is stored in memory, a read request only needs to access memory to obtain the first index entry during execution, without needing to access the disk to obtain the index. Therefore, data reading can be completed with only one disk read operation, resulting in low read latency.
[0062] Understandably, since the entire index space is stored in memory, a read request accesses memory to retrieve the first index entry during execution, without needing to access the disk to retrieve the index. Therefore, only one disk read operation (reading data from the physical storage medium) is required to complete the data read. Compared to the LSM-Tree scheme in related technologies, which requires two disk read operations—"reading the index first, then reading the data"—this embodiment of the application moves the index access process from the disk to memory, eliminating the disk index access step in the read request path. This significantly reduces the latency of read requests and improves the read performance of the distributed block storage system.
[0063] In one example of this application, the processing flow of the distributed block storage system responding sequentially to a first write request, a second write request, and a read request is as follows: Figure 3As shown in the diagram. The first write request is a 16KB write request. The system writes the data to the end of the disk using an append-only model and then updates the corresponding first page index based on the address offset of the written physical address. The second write request is a 4KB write request, and the logical address range operated on by the second write request is a subset of the logical address range operated on by the first write request. The system sequentially writes the data of the second write request to the end of the disk using an append-only model and then updates the corresponding page index based on the address offset of the written physical address. Since each data block corresponds to only one unique page index, the newly written physical address will overwrite the previously recorded physical address of that data block; that is, only the physical address corresponding to the most recently written data is retained in memory. For a 16KB read request, when the logical address range operated on by the read request is the same as that operated on by the first write request, the system directly reads the corresponding page index from memory. Since the second write request has overwritten and updated some data blocks, the page index corresponding to those data blocks now points to the physical address where the second write request wrote the data. The page indexes corresponding to the remaining uncovered data blocks still point to the physical address where the first write request wrote the data. The system reads the corresponding data from the disk according to the physical address recorded in each page index to complete this read request.
[0064] For example, the method also includes: performing waste recycling.
[0065] It should be noted that when writing data using the append-only model, the physical address of the data is unrelated to the corresponding logical address or data block. The data is sequentially written to the end of the physical storage medium. Therefore, when the same logical address range is repeatedly written, the older data written earlier becomes invalid data, and the physical storage space occupied by this invalid data cannot be overwritten in subsequent writing processes. Based on this, the embodiments of this application perform garbage collection on the physical storage space to release reusable physical storage space.
[0066] Here, garbage collection (GC) is the process of moving valid data to a new physical storage space and releasing the physical storage space occupied by invalid data. In a distributed block storage system, the amount of redundant data written to the physical storage space is periodically checked to see if it has reached a preset recycling threshold. If the recycling threshold is reached, garbage collection is triggered to release the storage space occupied by invalid data, ensuring that storage resources can be reused.
[0067] However, during garbage collection, valid data is typically moved from the physical storage space to be reclaimed to a new physical storage space. If a new write request and a garbage collection operation simultaneously initiate data writing to the same physical storage space during the moving process, a data write conflict may occur, i.e., double write. Double write may lead to some data being incorrectly overwritten or lost. To solve the above problem, in this embodiment of the application, the method further includes: configuring data segments for the logical storage space. The data segments have a writable state or a read-only state.
[0068] Accordingly, the method also includes garbage collection of data blocks in read-only data segments.
[0069] Here, a data segment is the management unit of logical storage space. Each data segment includes multiple data blocks, and each data segment is assigned a status identifier, which includes, but is not limited to, writable and read-only states. The writable state indicates that the data segment currently supports receiving new write requests and writing data; the read-only state indicates that the data segment currently does not support receiving new write requests, but only supports receiving read requests and reading data.
[0070] Here, a data segment is initially created in a writable state. As write requests continue to be written, the written data blocks are sequentially filled into the writable data segment. That is, the written data blocks belong to the data segment currently in the writable state. When the writable data segment reaches the preset capacity or meets other switching conditions, the data segment switches from the writable state to the read-only state. At the same time, the system configures a new writable data segment to receive subsequent write requests.
[0071] It is understood that this embodiment of the application spatially isolates the write operation of write requests from the garbage collection operation by setting data segments and configuring them with writable or read-only states. Specifically, write requests can only be written to data segments in the writable state, and garbage collection is only performed on data segments in the read-only state. This avoids the dual-write conflict caused by garbage collection and write requests operating on the same physical storage space simultaneously. Furthermore, by using data segments as the basic unit of garbage collection, when garbage collection is needed on read-only data segments, the system performs garbage collection on a segment-by-segment basis, eliminating the need to clean up invalid data line by line, thus improving the efficiency of garbage collection.
[0072] It should be noted that the ownership relationship between data blocks and data segments is not pre-defined statically, but dynamically determined based on the logical address segment indicated by the write request and the data segment currently in a writable state. Therefore, in order to determine the data segment to which a data block belongs during subsequent garbage collection, an index layer needs to be constructed to record the ownership relationship between data blocks and data segments. Accordingly, in this embodiment, the method further includes: storing all second index entries of the logical storage space in the index space. Each second index entry corresponds one-to-one with a data block, and the second index entry is used to record the ownership relationship between the corresponding data block and data segment.
[0073] Accordingly, garbage collection is performed on the data blocks in the read-only data segment, including: garbage collection is performed on the data blocks in the read-only data segment according to the second index entry.
[0074] It is understood that, by storing the full set of second index entries in the memory index space, this application embodiment enables write requests to quickly complete the query directly in memory before determining the ownership relationship between data blocks and data segments without accessing the disk, thereby reducing write request latency. Simultaneously, during garbage collection, the second index entries can quickly determine which data blocks in a read-only data segment are still valid and which are invalid, thus reducing the scanning scope of invalid data during garbage collection and further improving garbage collection efficiency.
[0075] It should be noted that as write requests continue to be written, new data segments are constantly created and used to receive subsequent write requests. Therefore, the number of data segments gradually increases, and the segment ID or number used to uniquely identify each data segment also increments. This requires using multiple bits to record the segment ID, such as 16 bits or 32 bits to record the continuously incrementing segment ID. Taking a 32TB logical storage space as an example, the number of data blocks after partitioning this logical storage space is 32TB / 4KB. Correspondingly, the number of second index entries for the logical storage space is 32TB / 4KB. If the second index entries are recorded based on the segment ID, such as using 16 bits, then the memory index space needs to provide 16GB (32TB / 4KB × 16bit / 8) of capacity to store all second index entries. If the logical storage space has a longer lifespan and requires 32 bits to record the segment ID, then the index space needs to provide 32GB of capacity to store all second index entries. Therefore, although the number of second index entries can be predetermined, recording the mapping relationship between data blocks and data segments by storing data segment identifiers will bring high cost pressure to full memory index storage.
[0076] Based on this, in order to reduce the memory cost of the second index item, the embodiments of this application configure the second index item to record the order of the data segment to which the corresponding data block belongs in the existing data segments, so as to compress the data volume of the second index item.
[0077] It should be noted that after garbage collection of a data segment in a read-only state, the data segment is released entirely and will no longer participate in subsequent data writing, data reading, or garbage collection. Therefore, in this embodiment, the existing data segment refers to data segments created in the current system that have not yet been reclaimed and released, including data segments in a writable state and data segments in a read-only state, but excluding released invalid data segments. As write requests continue, new data segments are continuously created and added to the existing data segment set; data segments that have completed garbage collection are removed from the existing data segment set after being released. Therefore, the existing data segment set is a dynamically changing set of data segments, rather than a fixed set.
[0078] Since garbage collection continuously releases read-only data segments that have been reclaimed, when the speed of garbage collection matches the write speed of write requests, the number of existing data segments in the system can usually be kept within a small range. Therefore, the second index entry can effectively compress the amount of data in the second index entry and reduce memory usage costs by recording the order of the data segment to which the data block belongs in the existing data segments instead of directly recording the data segment identifier.
[0079] In this application embodiment, two methods are provided for recording the second index entry according to the order of the data segment to which the data block belongs in the existing data segments, which will be described in detail below.
[0080] In some embodiments, the method further includes: determining the data segment to which the corresponding data block belongs based on the bit position of a set value in the second index entry.
[0081] The second index item includes at least one bit, the number of bits being the same as the number of existing data segments, and the bits corresponding to existing data segments and arranged according to the order of the corresponding data segments. The set value represents the data segment to which the data block belongs.
[0082] It should be noted that, in order to compress the data volume of the second index entry, the second index entry in the above embodiment uses a bitmap to record the ownership relationship between data blocks and data segments. The ownership relationship between each data block and each data segment is represented by a single bit, and whether a data block belongs to a corresponding data segment is determined by whether the corresponding bit is a set value. For example, if the bit value is 1, it indicates that the corresponding data block belongs to the corresponding data segment; if the bit value is 0, it indicates that the corresponding data block does not belong to the corresponding data segment. Furthermore, this embodiment uses the bit position in the second index entry to indicate the order of the corresponding data segment among the existing data segments, thereby simplifying the recording method of the data segment order in the second index entry. For example, if there are currently three existing data segments, with corresponding data segment identifiers of 100, 101, and 102, then the second index entry for a data block includes three bits, each corresponding to data segments 100-102 in sequence; where, if the second index entry is 010, it indicates that the data block belongs to data segment 101.
[0083] A comparison example of using Segment ID records versus bitmap records for the second index entry is as follows: Figure 4 As shown. It is understandable that, taking a logical storage space with a capacity of 32TB as an example, if a bitmap is used to record the second index item, the memory requirement for the second index item is 1GB*N, where N represents the number of existing data segments in the current system; if the garbage collection speed of the segment matches the data writing speed, the number of segments can be maintained at 1-2, which is much smaller than the 16GB or even 32GB of memory space required to record the second index item using the segment ID.
[0084] In one example, each data segment is configured with a bitmap, where each bit corresponds to a data block, indicating whether the data block belongs to that data segment. After a write request is executed, the system updates the bitmap of the currently writable data segment, setting the bit corresponding to the data block being written to a first preset value to indicate that the data block belongs to the current data segment. When a read request is executed, the system locates the corresponding data block based on its logical address and then searches in reverse order from the latest data segment for the data segment whose corresponding bit is set to the first preset value. Since the data segment identifier in the append-write model increments, the first data segment found is the data segment to which the data block currently belongs. When a data segment is full or other switching conditions are met, the data segment switches to read-only mode and awaits garbage collection. During garbage collection, the system moves the valid data from the read-only data segment to a new data segment, updates the corresponding first and second index entries, and then releases the read-only data segment and its corresponding bitmap. This data segment no longer participates in subsequent data access.
[0085] In some embodiments, the method further includes: determining the data segment to which the corresponding data block belongs based on the value of the second index entry.
[0086] The second index entry consists of a single byte, the value of which represents the order of the data segment to which the data block belongs.
[0087] It should be noted that in the first second index item configuration scheme, the data volume of the second index item is directly related to the number of existing data segments. Since garbage collection has a lower processing priority than write requests, a surge in write requests in a few scenarios can cause low-priority garbage collection processes to fail, leading to a significant increase in the number of existing data segments in a short period, resulting in a sharp increase in the memory requirements of the second index item. To avoid the situation where insufficient index space capacity prevents the creation of new data segments in this scenario, this embodiment also provides a second second index item configuration scheme. In this scheme, the second index item uses a slot map to record the relationship between data blocks and data segments. Specifically, the system maintains a slot map to record the correspondence between slot identifiers and data segment identifiers. Slot identifiers are represented by a single byte, while data segment identifiers are represented by 16 bits or 32 bits. The second index item records the slot identifier, not the data segment identifier. The corresponding data segment identifier can be determined by querying the slot map using the slot identifier. For example, there are currently 16 existing data segments, with corresponding data segment identifiers from 100 to 115. If the single byte value of the second index entry of a data block is 5, it means that the data block belongs to data segment 105.
[0088] A comparison example of using Segment ID records versus Slot map records for the second index entry is as follows: Figure 5 As shown. It's understandable that, since the second index entry is set to single-byte data, it can identify the data block ownership of up to 256 data segments. Taking a 32TB logical storage space as an example, if a slot map is used to record the second index entry, the memory requirement for the second index entry is 8GB. This is far less than the 16GB or even 32GB of memory required to record the second index entry using Segment ID.
[0089] Understandably, compared to the first second index item configuration scheme, the second second index item configuration scheme decouples the amount of data in the second index item from the number of existing data segments. The memory requirement is only related to the capacity of the logical storage space. Furthermore, each segment created occupies a slot, and each segment reclaimed releases a slot. The circular second index item model constructed by this slot map is suitable for second index item records during peak business periods.
[0090] In another example, each data segment corresponds to a slot ID in the slot map. The slot ID is represented by a single byte, and the slot map records the correspondence between slot IDs and data segment IDs. The second index entry records the slot ID, not the data segment ID, and the second index entry for each data block is a single byte of data. After a write request is executed, the system records the second index entry corresponding to the data block being written as the slot ID corresponding to the current data segment. When a read request is executed, the system queries the slot map based on the slot ID recorded in the second index entry to obtain the corresponding data segment ID, thereby determining the data segment to which the data block belongs. When a new data segment is created, the system allocates a free slot ID from the slot map and establishes a correspondence between that slot ID and the new data segment ID; when a data segment is reclaimed and released, the system releases the slot ID corresponding to that data segment and sets it to a free state for subsequent reuse. Since the second index entry only needs 1 byte to record the slot identifier, compared with directly using 4 bytes to record the data segment identifier, the memory usage is significantly reduced. In addition, the total number of slot identifiers in the slot mapping table is fixed (e.g., 256). The memory usage of this method is only related to the capacity of the logical storage space and is not affected by garbage collection speed or sudden traffic. The memory usage can be planned and determined in advance.
[0091] It is understandable that the two second index item configuration schemes described above can be switched according to the actual operating status. For example, when write request traffic is stable and garbage collection can be performed in a timely manner, the bitmap scheme can be used to further reduce memory usage; when write request traffic surges, which may lead to a significant increase in the number of existing data segments, the slot mapping table scheme can be switched to ensure controllable memory usage and stable system operation. This application embodiment does not limit the specific switching conditions between the two schemes; for example, switching can be performed based on one or more factors such as write request traffic, the number of existing data segments, and memory usage.
[0092] For example, the method further includes: asynchronously writing a batch of first index entries stored in the index space to the physical storage medium.
[0093] For example, the method further includes: in response to system startup or fault recovery, using a full data segment concurrent scan method, reconstructing the first index entry based on the data in the physical storage medium, and storing it in the index space.
[0094] It is understandable that a full-memory index requires index reconstruction during system startup or fault recovery, and its loading time is related to the amount of index data. In related technologies, LSM-Tree index data is persistently stored on disk, and index loading can be completed simply by reading the index file on disk during system startup or fault recovery, resulting in a short loading time. However, in this embodiment, since the entire index is stored in memory, the index needs to be reconstructed based on the data in the physical storage medium during system startup or fault recovery. To accelerate index reconstruction, this embodiment uses a batch asynchronous flushing mode to persist the first index entry in the index space to the physical storage medium during normal operation, and coordinates with a full data segment concurrent scan mode during system startup or fault recovery to quickly read data from the physical storage medium and build the memory index, thereby shortening the index loading time and improving the system's fault recovery efficiency.
[0095] In order to implement the method of the embodiments of this application, the embodiments of this application also provide an index management device, which corresponds to the above-described index management method, and the steps in the above-described index management method embodiments are also fully applicable to the embodiments of this device.
[0096] like Figure 6 As shown, the index management device in this embodiment includes a partitioning module 601, an allocation module 602, and a storage module 603. The partitioning module 601 is used to divide the logical storage space into multiple data blocks of a predetermined granularity. The allocation module 602 is used to allocate index spaces of matching capacity in memory according to the number of data blocks. The storage module 603 is used to store all first index entries of the logical storage space in the index space. Each first index entry corresponds one-to-one with a data block, and the first index entry records the physical address of the corresponding data block on the physical storage medium.
[0097] In some embodiments, the index management device further includes a determining module 604 and a writing module 605. The determining module 604 is configured to determine the corresponding write data block in response to a received write request. The writing module 605 is configured to append the data requested in the write request to the physical storage medium and obtain the corresponding write physical address.
[0098] In some embodiments, the storage module 603 is further configured to: record the physical address to be written in the first index entry corresponding to the data block to be written.
[0099] In some embodiments, the determining module 604 is further configured to: determine the corresponding read data block in response to the received read request.
[0100] In some embodiments, the index management device further includes a reading module 606, which is used to read the first index entry corresponding to the read data block from the index space and determine the read physical address of the record; and read the stored data from the read physical address of the physical storage medium.
[0101] In some embodiments, the storage module 603 is further configured to: store all second index entries of the logical storage space in the index space. The second index entry corresponds one-to-one with a data block, and the second index entry is used to record the order of the data segment to which the corresponding data block belongs among the existing data segments. The data segment has a writable state or a read-only state.
[0102] In some embodiments, the storage module 603 is further configured to: perform garbage collection on data blocks in a read-only data segment according to a second index entry.
[0103] In some embodiments, the determining module 604 is further configured to: determine the data segment to which the corresponding data block belongs based on the bit position of the set value in the second index entry. The second index entry includes at least one bit, each bit corresponding to an existing data segment and arranged sequentially according to the order of the corresponding data segments, and the set value characterizes the data segment to which the data block belongs.
[0104] In some embodiments, the determining module 604 is further configured to: determine the data segment to which the corresponding data block belongs based on the value of the second index entry; wherein the second index entry includes a single byte, and the value of the single byte represents the order of the data segment to which the data block belongs.
[0105] In some embodiments, the write module 605 is further configured to: asynchronously write the first index entries stored in the index space in batches to the physical storage medium.
[0106] It should be noted that the index management device provided in the above embodiments is only illustrated by the division of the above program modules when performing index management. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. In addition, the index management device provided in the above embodiments and the video display method embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0107] Based on the hardware implementation of the above program modules, and in order to implement the index management method of this application embodiment, this application embodiment also provides a distributed block storage system, such as... Figure 7As shown, the distributed block storage system 700 includes at least one processor 701, a memory 702, a user interface 703, and at least one network interface 704. The various components in the distributed block storage system 700 are coupled together via a bus system 705. It can be understood that the bus system 705 is used to implement communication between these components. In addition to a data bus, the bus system 705 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 7 The general labeled all buses as Bus System 705.
[0108] The user interface 703 may include a monitor, keyboard, mouse, trackball, click wheel, buttons, touchpad, or touch screen.
[0109] The memory 702 in this embodiment is used to store various types of data to support the operation of the distributed block storage system 700. Examples of such data include any computer program used to operate on the distributed block storage system 700.
[0110] The index management method disclosed in this application can be applied to or implemented by the processor 701. The processor 701 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the index management method can be completed by the integrated logic circuitry in the hardware of the processor 701 or by instructions in software form. The processor 701 can be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 701 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in a storage medium, specifically in memory 702. The processor 701 reads information from memory 702 and, in conjunction with its hardware, completes the steps of the index management method provided in the embodiments of this application.
[0111] In an exemplary embodiment, the distributed block storage system 700 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), FPGAs, general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned index management method.
[0112] It is understood that memory 702 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), EEPROM, ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Sync Link Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM). The memory 702 described in this application embodiment is intended to include, but is not limited to, these and any other suitable types of memory.
[0113] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 702 that stores a computer program. This computer program can be executed by the processor 701 of the distributed block storage system 700 to complete the steps described in the index management method of this application embodiment. The computer-readable storage medium can be a ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM, etc.
[0114] In an exemplary embodiment, this application also provides a computer program product, including a computer program that can be executed by a processor 701 of a distributed block storage system 700 to perform the steps described in the method of this application embodiment.
[0115] It should be noted that terms such as "first" and "second" are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0116] Furthermore, the technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.
[0117] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. An index management method, characterized in that, Applied to a distributed block storage system, the method includes: Divide the logical storage space into multiple data blocks with defined granularity: Based on the number of data blocks, allocate an index space of matching capacity in memory; Store all first index entries of the logical storage space in the index space; The first index entry corresponds one-to-one with the data block, and the first index entry is used to record the physical address of the corresponding data block on the physical storage medium.
2. The method according to claim 1, characterized in that, The method further includes: In response to a received write request, determine the corresponding data block to be written; The data requested in the write request is appended to the physical storage medium, and the corresponding physical address for writing is obtained; The physical address to be written is recorded in the first index entry corresponding to the data block to be written.
3. The method according to claim 1, characterized in that, The method further includes: In response to a received read request, determine the corresponding data block to be read; Read the first index entry corresponding to the read data block from the index space and determine the physical address of the record. Read the stored data from the physical address of the physical storage medium.
4. The method according to claim 1, characterized in that, The method further includes: Store all the second index entries of the logical storage space in the index space; The second index item corresponds one-to-one with the data block. The second index item is used to record the order of the data segment to which the corresponding data block belongs in the existing data segments. The data segment has a writable state or a read-only state. The method further includes: Based on the second index entry, garbage collection is performed on the data blocks in the read-only data segment.
5. The method according to claim 4, characterized in that, The method further includes: The data segment to which the corresponding data block belongs is determined based on the bit position of the set value in the second index entry; The second index entry includes at least one bit, which corresponds to an existing data segment and is arranged according to the order of the corresponding data segments. The set value represents the data segment to which the data block belongs.
6. The method according to claim 4, characterized in that, The method further includes: Based on the value of the second index item, determine the data segment to which the corresponding data block belongs; The second index entry includes a single byte, the value of which represents the order of the data segment to which the data block belongs.
7. The method according to claim 1, characterized in that, The method further includes: The first index entries stored in the index space are written asynchronously in batches to the physical storage medium.
8. A distributed block storage system, characterized in that, include: A processor and a memory for storing a computer program capable of running on the processor, wherein the processor, when running the computer program, performs the steps of the method according to any one of claims 1 to 7.
9. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.