A method of operating a request processing and related apparatus
Patent Information
- Application Number
- CN202110732615.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-29
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2041-06-29
AI Technical Summary
直接在已经成熟的数据库系统中,引入段页式存储方式,会造成软件系统结构的破坏,并且很难兼容
[0047]本申请实施例提供了一种操作请求处理方法,所述方法应用于硬盘控制器,所述硬盘控制器用于为硬盘的存储空间分配逻辑地址,其中,所述逻辑地址包括目标段segment,所述目标段segment被划分为多个区extent,每个extent被划分为多个block;所述方法包括:获取目标操作请求,所述目标操作请求包括目标逻辑地址,所述目标逻辑地址用于指示所述多个block中的目标block;根据所述目标逻辑地址,通过地址映射关系,确定所述目标block的目标物理地址,对所述目标物理地址所在的存储空间进行数据操作。本申请基于目标block的目标逻辑地址以及目标逻辑地址到物理地址的映射来寻址,也就是可以基于目标逻辑地址来确定目标block的物理地址,并进行数据操作,在smgr层以上的代码都不需要修改或者修改幅度很小,减少了对原有代码侵入式修改,大大降低了软件开发的风险,也不用修改页面格式,避免了兼容性问题,易于在基于PG的数据库系统中实现
Smart Images

Figure CN115543992B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to an operation request processing method and related apparatus. Background Technology
[0002] This application relates to storage formats in database storage engines. Currently, PostgreSQL (hereinafter referred to as PG) and PG-based databases use paged heap storage. Each table, partition, or index has a separate physical file. This is simple to implement and makes it easier to manage heap metadata, such as table free space maps. However, when the number of tables and partitions becomes too large, the number of physical files also increases dramatically.
[0003] To address the issue of a surge in physical files, segmented paging storage can be used. Segmented paging storage means that all tables and indexes are stored in the same file(s), with each table and index's data forming a segment, and each segment further divided into several data pages (blocks).
[0004] However, data storage method is a fundamental design element in database software. From the executor onwards, PostgreSQL's code defaults to low-level storage, where each table occupies its own physical file, and table data can be accessed using consecutive page numbers starting from 0. Introducing segmented paging directly into an already mature database system would disrupt the software system structure and would be difficult to achieve compatibility. Summary of the Invention
[0005] In a first aspect, embodiments of this application provide an operation request processing method, the method being applied to a hard disk controller, wherein the hard disk controller can be a controller implemented based on PG;
[0006] The hard disk controller is used to allocate logical addresses to the storage space of the hard disk, wherein the logical address includes a target segment, the target segment is divided into multiple extents, and each extent is divided into multiple blocks;
[0007] A segment can correspond to an object, such as an index or a data table. A segment can be divided into multiple extents, and each extent can include contiguous blocks. Optionally, the storage space size corresponding to a block can be 8KB.
[0008] The method includes: obtaining a target operation request, the target operation request including a target logical address, the target logical address being used to indicate a target block among the plurality of blocks;
[0009] In traditional PG-based storage systems, data operations (such as read and write operations) on physical files are performed through the smgr (storage manager) layer. A data block's location is represented by the information "segment's relfilenode, block number," where relfilenode is the filename of the file corresponding to that segment, and block number is the offset of the data block within that segment. Since each segment in existing PG-based storage systems occupies a dedicated physical file, the block number is essentially the physical address of the data block. Therefore, to read or write a data block within a file, the storage engine passes the necessary information to the smgr layer.<relfilenode,block number> The smgr layer calls the relevant system calls. For example, during a sequential scan, the storage engine will traverse the block number starting from 0 to read all data blocks of that segment.
[0010] Based on the target logical address, the target physical address of the target block is determined through address mapping, and data operations are performed on the storage space where the target physical address is located.
[0011] In a PG-based database system, since each physical file corresponds to a segment, physical addressing can be used directly. The physical address can include the filename and the physical number within the segment corresponding to that filename. The filename directly corresponds to a specific segment, and the physical number is the position of the block within that segment. Since only one physical file corresponds to a segment, the segment can be traversed sequentially from 0 until the physical number is reached. However, in segmented paging, each physical file can be assigned to multiple segments. In the existing approach, to introduce segmented paging into the PG database implementation, a large amount of code needs to be modified in the smgr layer. This is to ensure that after obtaining the physical number, traversal cannot start from 0, but rather the starting position of the physical file corresponding to that physical number within the segment needs to be determined, and then traversal can begin from that starting position until the block corresponding to the physical number is reached. This code requires extensive modifications. In this embodiment, addressing is not based directly on the physical address, but rather on a logical address as an intermediate address. This eliminates the need for extensive code modifications in the smgr layer; only the physical address provided in the smgr layer needs to be replaced with a logical address. The logical address indicates the specific location of the block within the segment, and addressing is performed based on the mapping from logical address to logical address. Specifically, addressing can be based on the target logical address of the target block and the mapping from the target logical address to the physical address. In other words, the physical address of the target block can be determined based on the target logical address, and data operations can be performed. All modifications can be concentrated below the smgr layer, with minimal changes to the code above the smgr layer. This minimizes disruption to the existing PG-related code structure, reducing intrusive modifications to the original code and significantly lowering the risk of software development. Furthermore, it eliminates the need to modify page formats, improving compatibility and facilitating implementation in PG-based database systems.
[0012] In one possible design, the target logical address includes first indication information and second indication information. The first indication information is used to indicate the target segment, and the second indication information is used to indicate the position of the target block in the target segment. The first indication information may include a relfilenode field, and the second indication information may include the logical page number of the target block in the target segment.
[0013] Specifically, from the top-level perspective, each segment still occupies its own file, and the block number of the data blocks ranges from 0 to n-1, where n is the total number of data blocks in that segment. The storage engine still transmits...<relfilenode,block number> In the smgr layer, the page number can be called a logical page number. The storage manager can translate the logical page number into a specific physical address for data operations without modifying the data format of the operation request, improving compatibility and making it easier to implement in PG-based database systems.
[0014] In one possible implementation, determining the target physical address of the target block based on the target logical address and through an address mapping relationship includes: determining the target extent among the plurality of extents based on the logical page number, and the offset of the target block relative to the starting block of the target extent within the target extent; obtaining the first physical address of the starting block of the target extent through an address mapping relationship based on the target extent; and obtaining the target physical address of the target block based on the first physical address and the offset.
[0015] Since the expansion method of extents within a segment is fixed, given the logical page number of the target extent, the corresponding extent and its offset within that extent (i.e., the offset of the target block relative to the starting block of the target extent) can be calculated based on that logical page number. For example, taking the extent allocation rules described in Table 1 as an example, if the logical page number of the target extent is 516, which is between 128 and 16384, it belongs to Group 2. Since Group 1 occupies a total of 128 page numbers, the target extent belongs to the (516–128) / 128 = 3rd (counting from 0) extent in Group 2, and the offset is the (516–128)%128 = 4th extent. Here, the operator " / " indicates rounding the result of division, and the operator "%" indicates modulo.
[0016] In this embodiment, the corresponding extent and its offset within that extent can be calculated based on the logical page number of the target extent. Therefore, by finding the first physical address of the starting block of each extent, i.e., constructing an address mapping relationship from extent ID to physical address (e.g., physical page number), the conversion from logical page number to physical page number can be achieved. Optionally, this address mapping relationship can be implemented based on an array, where the extent id is the array index and the first physical address of the starting block of the extent is the array value. After obtaining the first physical address of the starting block of the target extent and the offset of the target block within the target extent relative to the starting block of the target extent, the target physical address of the target block can be obtained based on the first physical address and the offset.
[0017] In one possible design, the address mapping relationship may include a first-level mapping relationship and a second-level mapping relationship; based on the target extent, the target extent to which it belongs, and the second-level mapping relationship corresponding to the target extent group, can be determined through the first-level mapping relationship; wherein, the first-level mapping relationship is used to indicate multiple extent groups and the second-level mapping relationship corresponding to each extent group, and based on the target extent, the first physical address of the starting block of the target extent is determined through the second-level mapping relationship corresponding to the target extent group; the second-level mapping relationship is used to indicate the physical address of the starting block of each extent in the target extent group.
[0018] Storing the physical address of the starting block of each extent requires a certain amount of storage space (e.g., 4 bytes). Taking the segment shown in Table 1 as an example, there are 255 extents for 64K, 1M, and 8M extents, so they can be directly stored in the segment's header page. The metadata size is 255 * 4 bytes = 1KB. For 64MB extents, there is no upper limit to the number. Assuming a single table size is 32TB, approximately 32TB / 64MB = 512K extents are needed, with a metadata size of 2MB. A single segment header page cannot store all of these, and reserving such a large space in advance would be wasteful. Therefore, a two-level block map tree (BMT) can be used to store the above address mapping relationship. The two levels of the BMT can include a first-level mapping relationship (also referred to as Level 0 index page in this embodiment) and a second-level mapping relationship (also referred to as Level 1 index page in this embodiment). Each unit in the Level 0 index page corresponds to the starting physical address of an extent. Each Level 0 index page can be stored in one physical page. Taking 4 bytes per starting physical address as an example, one physical page can store 8K / 4 = 2K elements. The operator " / " represents division. It should be understood that this physical page can also be directly called a Level 0 index page. Since there are a maximum of 512K extents, a Level 1 index page only needs 512K / 2k = 256 slots. The operator " / " represents division. Therefore, it can be stored in the physical pages of the segment header. When the extents in a segment expand beyond the currently allocated space of the segment header, the number of physical pages in the segment header can be expanded without reserving a large number of segment headers in advance, reducing resource waste.
[0019] In one possible implementation, the plurality of extents includes a first extent and a second extent, wherein the first extent is closer to the starting block of the target segment than the second extent, the first extent is an idle extent, and the second extent is an occupied extent; the method further includes:
[0020] Modify the physical address of the starting block of the first extent in the address mapping relationship to the physical address of the starting block of the second extent.
[0021] One problem with segmented paging is its susceptibility to gaps. Even if a data table is deleted (e.g., via a drop or truncate operation), the occupied file storage space is not released. To reclaim physical space, the still-used data blocks need to be moved to the beginning of the segmented file, then a file resizing (ftruncate) operation needs to be performed, and the unused portion at the end of the segment needs to be released. In existing PG-based storage systems, physical addresses are used, so the physical address index needs to be rebuilt when moving data, significantly increasing I / O overhead. In this embodiment, since the upper layer sees only logical addresses, and the logical addresses can remain unchanged during the move, it is only necessary to move the extents near the end of the segment to the beginning of the file and update the address mapping relationship. Because the address mapping relationship also stores logical addresses, it is not necessary to rebuild the entire segment index during this process, thus greatly reducing the I / O overhead of the shrinking process. Specifically, the extent near the end of the segment can be the second extent, and the first extent is a free extent. That is, the first extent is a free extent that has not been allocated a physical file (for example, the physical data of the extent has been deleted). It can be moved at the extent level. The second extent is moved to the first extent. That is, the logical address of the first extent is not changed, but the physical address of the starting block of the first extent in the address mapping relationship is modified to the physical address of the starting block of the second extent.
[0022] In one possible implementation, the storage space corresponding to each segment is used to store multiple physical files, and the storage space corresponding to M extents of the multiple extents is used to store the target physical file, and the storage space corresponding to the M extents is of the same size.
[0023] Segmented paging storage is prone to fragmentation of free space because it allocates extents of different sizes within the same physical file. For example, existing PostgreSQL-based database systems divide a segment into extents of 64KB, 1MB, 8MB, and 64MB, requiring that later extents within the same segment be at least as large as earlier extents. This can result in a file containing numerous 64KB free extents, but failing to allocate contiguous 64MB extents. In this embodiment, allocating only extents of the same size to a physical file reduces the amount of fragmentation in free space.
[0024] In one possible implementation, the data operations include at least one of the following operation types: add operation, delete operation, modify operation, and query operation.
[0025] Secondly, this application provides an operation request processing apparatus applied to a hard disk controller, the hard disk controller being used to allocate logical addresses for the storage space of the hard disk, wherein the logical address includes a target segment, the target segment is divided into multiple extents, and each extent is divided into multiple blocks, the apparatus comprising:
[0026] The acquisition module is used to acquire a target operation request, wherein the target operation request includes a target logical address, and the target logical address is used to indicate a target block among the plurality of blocks;
[0027] The determination module is used to determine the target physical address of the target block based on the target logical address and through address mapping relationships.
[0028] The data operation module performs data operations on the storage space where the target physical address is located.
[0029] In one possible implementation, the target logical address includes first indication information and second indication information, wherein the first indication information is used to indicate the target segment and the second indication information is used to indicate the position of the target block within the target segment.
[0030] In one possible implementation, the first indication information includes the relfilenode field.
[0031] In one possible implementation, the second indication information includes the logical page number of the target block within the target segment.
[0032] In one possible implementation, the determining module is specifically configured to determine, based on the logical page number, a target extent among the plurality of extents, and the offset of the target block relative to the starting block of the target extent within the target extent;
[0033] Based on the target extent, the first physical address of the starting block of the target extent is obtained through the address mapping relationship;
[0034] The target physical address of the target block is obtained based on the first physical address and the offset.
[0035] In one possible implementation, the address mapping relationship includes a first-level mapping relationship and a second-level mapping relationship; the determining module is specifically used to determine, based on the target extent, the target extent to which the target extent belongs, and the second-level mapping relationship corresponding to the target extent group, through the first-level mapping relationship; wherein, the first-level mapping relationship is used to indicate multiple extent groups, and the second-level mapping relationship corresponding to each extent group.
[0036] Based on the target extent, the first physical address of the starting block of the target extent is determined through the second-level mapping relationship corresponding to the target extent group; the second-level mapping relationship is used to indicate the physical address of the starting block of each extent in the target extent group.
[0037] In one possible implementation, the plurality of extents includes a first extent and a second extent, wherein the first extent is closer to the starting block of the target segment than the second extent, the first extent is an idle extent, and the second extent is an occupied extent; the apparatus further includes:
[0038] The address modification module is used to modify the physical address of the starting block of the first extent in the address mapping relationship to the physical address of the starting block of the second extent.
[0039] In one possible implementation, the storage space corresponding to each segment is used to store multiple physical files.
[0040] In one possible implementation, the storage space corresponding to M of the plurality of extents is used to store the target physical file, and the storage space corresponding to the M extents is of the same size.
[0041] In one possible implementation, the data operations include at least one of the following operation types: add operation, delete operation, modify operation, and query operation.
[0042] Thirdly, this application provides an operation request processing apparatus, which may include a processor and a memory coupled together. The memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the first aspect and any of the methods described above are implemented. For details of the steps executed by the processor in various possible implementations of the first aspect, please refer to the first aspect; they will not be repeated here.
[0043] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform any of the methods described in the first aspect above.
[0044] Fifthly, this application provides a circuit system including a processing circuit configured to perform the methods described in the first aspect and any of the methods described above.
[0045] Sixthly, this application provides a computer program that, when run on a computer, causes the computer to perform any of the methods described in the first aspect above.
[0046] Seventhly, this application provides a chip system including a processor for implementing the functions involved in the foregoing aspects, such as transmitting or processing data and / or information involved in the foregoing methods. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for a server or communication device. This chip system may be composed of chips or may include chips and other discrete devices.
[0047] This application provides an operation request processing method applied to a hard disk controller. The hard disk controller allocates logical addresses to the storage space of the hard disk. The logical address includes a target segment, which is divided into multiple extents, and each extent is divided into multiple blocks. The method includes: obtaining a target operation request, which includes a target logical address indicating a target block among the multiple blocks; determining the target physical address of the target block based on the target logical address and an address mapping relationship; and performing data operations on the storage space where the target physical address is located. This application addresses based on the target logical address of the target block and the mapping from the target logical address to the physical address. This means that the physical address of the target block can be determined based on the target logical address, and data operations can be performed. Code above the smgr layer requires little or no modification, reducing intrusive modifications to existing code, significantly lowering software development risks, and avoiding compatibility issues by eliminating the need to modify page formats. It is also easy to implement in PG-based database systems. Attached Figure Description
[0048] Figure 1A This is a schematic diagram of the architecture of a database system;
[0049] Figure 1B A schematic diagram of the architecture of a distributed database system provided in an embodiment of this application;
[0050] Figure 1C This is another schematic diagram of the architecture of the distributed database system provided in the embodiments of this application;
[0051] Figure 1D This application provides an example of an application architecture.
[0052] Figure 1E This application provides a system illustration as an embodiment of the present application;
[0053] Figure 2 A flowchart illustrating an operation request processing method provided in an embodiment of this application;
[0054] Figure 3 A schematic diagram of a segment structure provided in an embodiment of this application;
[0055] Figure 4 A schematic diagram of a segment structure provided in an embodiment of this application;
[0056] Figure 5 This is a schematic diagram illustrating an address mapping relationship in an embodiment of this application;
[0057] Figure 6 This is a schematic diagram of a shrink operation provided in an embodiment of this application;
[0058] Figure 7 A schematic diagram of the structure of an operation request processing device provided in this application;
[0059] Figure 8 A schematic diagram of a computer-readable storage medium provided in this application;
[0060] Figure 9 A schematic diagram of a computer device provided in this application. Detailed Implementation
[0061] The embodiments of this application are described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. As those skilled in the art will recognize, with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0062] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or modules is not necessarily limited to those explicitly listed, but may include other steps or modules not explicitly listed or inherent to such processes, methods, products, or apparatus. The naming or numbering of steps appearing in this application does not imply that the steps in the method flow must be performed in the chronological or logical order indicated by the naming or numbering. The execution order of named or numbered process steps can be changed according to the desired technical purpose, as long as the same or similar technical effect is achieved.
[0063] The method provided in the embodiments of this application can be applied to... Figure 1A In the database system 100 shown, the database system 100 is communicatively connected to the application server 300 to provide database services to the application server 300. The application server 300 is communicatively connected to the client 200, which is typically an application deployed on a user's device. The client 200 initiates service requests to the application server 300 to achieve specific functions, such as downloading or uploading data. The data related to the client 200 is stored in the database system 100. When the application server 300 needs to manipulate the client 200's data (such as querying, adding, updating, and deleting data) during the process of responding to the client 200's service requests, it can do so by sending operation requests to the database system 100.
[0064] Figure 1A This illustrates a typical logical architecture of database system 100, based on Figure 1A Database system 100 includes database 110 and database management system (DBMS) 130.
[0065] Database 110 is an organized collection of data stored in data storage 120; that is, a related collection of data organized, stored, and used according to a specific data model. Depending on the data model used to organize the data, the data can be divided into various types, such as relational data, graph data, and time series data. Relational data is data modeled using a relational model, usually represented as a table, where rows represent a set of related values for an object or entity. Graph data, simply called a "graph," is used to represent relationships between objects or entities, such as social relationships. Time series data is a series of data columns recorded and indexed in chronological order, used to describe the state changes of an object over time.
[0066] The database management system 130 is the core of the database system, serving as system software for organizing, storing, and maintaining data. Clients 200 can access the database 110 through the database management system 130, and database administrators also use the database management system for database maintenance. The database management system 130 provides various functions for clients 200 to create, modify, and query the database. Clients 200 can be applications or user devices running applications. The functions provided by the database management system 130 may include, but are not limited to, the following: (1) Data definition function: The database management system 130 provides a data definition language (DDL) to define the structure of the database 110. The DDL is used to describe the database framework and can be stored in the data dictionary; (2) Data access function: The database management system 130 provides a data manipulation language (DML) to implement basic access operations on the database 110, such as retrieval, insertion, modification and deletion; (3) Database operation management function: The database management system 130 provides data control function to effectively control and manage the operation of the database 110 to ensure that the data is correct and valid; (4) Database creation and maintenance function: including loading the initial data of the database, database dumping, recovery, reorganization, system performance monitoring and analysis, etc.; (5) Database transmission: The database management system provides data transmission to realize communication between the client and the database management system, which is usually coordinated with the operating system.
[0067] Database storage 120 includes, but is not limited to, solid-state drives (SSDs), disk arrays, cloud storage, or other types of non-transient computer-readable storage media.
[0068] In this embodiment, client 200 can initiate a service request to application server 300. Application server 300 has a data service deployed on it to respond to the service request initiated by client 200. In one embodiment, the data service deployed on application server 300 can verify the legitimacy of client 200's access. After successful verification, the session is recorded, and the service request initiated by client 200 is transformed into a data operation request to database 110, such as a query statement. Furthermore, the data service can perform real-time statistics and control on the system resources used by different clients 200.
[0069] It should be understood that those skilled in the art can comprehend that a database system may include more than Figure 1A The components shown are fewer or more components, or include those with Figure 1A The components shown are different components. Figure 1A Only components more relevant to the implementation disclosed in the embodiments of the present invention are shown.
[0070] The following is combined Figure 1B This application introduces an embodiment of an application server 300.
[0071] The application server 300 implements functions including, but not limited to, access control, session management, data management, resource monitoring, and storage management. Access control manages the legitimacy of client access and bandwidth. Session management manages the sessions of successfully connected clients. Data management translates client service requests into database operation requests. Resource monitoring provides real-time statistics and control over system resources used by different clients. Storage management translates database operation requests into database system-supported or executable operation requests, such as database query statements (referred to as "queries"), which can be Structured Query Language (SQL) queries. It should be noted that the application server 300 can translate service requests into database system-supported or executable queries in one go or in multiple stages; the specific translation process is within the scope of existing technology in this field.
[0072] The database system provided in this application embodiment can be a distributed database system (DDBS), such as a database system with a massively parallel processor (MPP) architecture. The following is in conjunction with... Figure 1C and Figure 1D Introducing DDBS.
[0073] Figure 1CThis diagram illustrates a distributed database system (DDBS) employing a shared-storage architecture. It includes one or more coordinator nodes (CNs) and multiple data nodes (DNs). This DDBS may also include other components, such as a global transaction manager (GTM). CNs and DNs communicate via a network channel. A CN can generate an execution plan for a received query, such as one from an application server, and then distribute the query to the appropriate DN for execution based on the execution plan. The CN can also generate query results based on the execution results from the DNs. In one embodiment, the network channel can consist of network devices such as switches, routers, and gateways. CNs and DNs jointly implement the functions of the database management system, providing clients with services such as database retrieval, insertion, modification, and deletion. In one embodiment, a database management system is deployed on each CN and DN. The shared data storage contains data that can be shared by multiple DNs, and DNs can perform read and write operations on the data in the data storage via the network channel. The shared data storage can be a shared disk array. In a distributed database system, the CN and DN can be physical machines, such as database servers, or virtual machines (VMs) or containers running on abstract hardware resources. In one embodiment, the CN and DN are VMs or containers, and the network channel is a virtual switching network, which includes virtual switches. The database management system deployed in the CN and DN is a DBMS instance, which can be a process or a thread. These DBMSs work together to perform the functions of the database relational system. In another embodiment, the CN and DN are physical machines, and the network channel includes one or more switches, such as storage area network (SAN) switches, Ethernet switches, fiber optic switches, or other physical switching devices.
[0074] Figure 1D This diagram illustrates a distributed database system employing a shared-nothing architecture. Each Data Domain (DN) has its own dedicated hardware resources (such as CPU, memory, and data storage). Communication between the Data Domain (CN) and DNs occurs via a network channel, which can be found in the above diagram. Figure 1C Please refer to the relevant introductions for understanding. In this system, data is allocated to various Data Domains (DNs) based on the database model and application characteristics. Query tasks are divided into several parts by the Data Center (CN), executed in parallel on multiple DNs, and collaboratively computed to provide database services as a whole. All communication functions are implemented on a high-bandwidth network interconnection system. (Similar to...) Figure 1CSimilar to the distributed database system with the described shared-storage architecture, CN and DN here can be either physical machines or virtual machines.
[0075] In all embodiments of this application, the data storage of the database system includes, but is not limited to, solid-state drives (SSDs), disk arrays, or other types of non-transient computer-readable media. Figures 1C-1D Although a database is not shown, it should be understood that a database is stored in a data storage device. Those skilled in the art will understand that a database system may include more than [a certain number of data storage devices]. Figures 1A-1D The components shown are fewer or more components, or include those with Figures 1A-1D The components shown are different components. Figures 1A-1D Only components more relevant to the implementation disclosed in the embodiments of this application are shown. However, those skilled in the art will understand that a distributed database system can contain any number of CNs and DNs. The database management system functions of each CN and DN can be implemented by appropriate combinations of software, hardware, and / or firmware running on each CN and DN.
[0076] In this embodiment, the distributed database system can provide application developers with application (APP) deployment services. Specifically, the application can be deployed on nodes in the distributed database system, such as virtual machines. A virtual machine can include one or more data nodes (DNs) and corresponding data storage (e.g., a virtual machine can be...). Figure 1C The shared data storage in the middle can also be Figure 1D In a distributed database system (data store), applications can send service requests to the application server. The application server processes these requests, for example, by transforming the application's service request into one or more data operation requests (referred to as "operation requests") that are supported or executable by the database system, and then sending the data operation requests to the distributed database system. In response to the data operation requests, the DN corresponding to the application in the distributed database system operates on the data in the data store.
[0077] Figure 1E This application illustrates a server provided in an embodiment, specifically, as shown in the example below. Figure 1E As shown, the operation request processing method of this application embodiment can be stored in the storage engine module of the database system in the form of program code (specifically, it can be...). Figure 1EIn this embodiment, the storage engine module (which is a segmented paging storage module) can be referred to as a hard disk controller. During runtime, the program code runs in the server's host memory to manage the database system's access to data on physical files. The segmented paging storage module can accept file read / write requests from the smgr layer, translate logical addresses (e.g., logical page numbers) into physical addresses (e.g., physical page numbers), and then read / write physical files at the corresponding physical addresses. Furthermore, the segmented paging storage module can utilize existing storage engine modules such as buffer, xlog, and checkpoint to achieve metadata persistence and consistency within the segmented paging module.
[0078] Figure 2 A flowchart illustrating an operation request processing method provided in this application embodiment is shown below. Figure 2 As shown, the operation request processing method provided in this application embodiment includes:
[0079] 201. Obtain a target operation request, wherein the target operation request includes a target logical address, and the target logical address is used to indicate a target block among the plurality of blocks.
[0080] This application embodiment can be applied to a hard disk controller, wherein the hard disk controller can be a controller implemented based on PG. The hard disk controller is used to allocate logical addresses for the storage space of the hard disk. The logical address can be divided into multiple segments (including target segments), each segment in the multiple segments can be divided into multiple extents, and each extent is divided into multiple blocks.
[0081] Reference Figure 3 As shown, Figure 3 This diagram illustrates a logical address partitioning of storage space. A segment can correspond to an object, such as an index or a data table. A segment can be divided into multiple extents, and each extent can include contiguous blocks. The storage space size corresponding to a block can be 8KB. Because extents may not be contiguous, linked list pointers can be set on the page to chain different extents of the same segment together (for example, these pointers could be left and right sibling pointers of a B+ tree) to support sequential scanning.
[0082] The following describes the process of creating a data table using a storage manager, specifically for the aforementioned segment:
[0083] When a storage manager creates a data table, it allocates a data block as the segment head. The block number of this data block is recorded in a system table, acting as a relfilenode. Each time data is inserted into the table, it searches for a free data block as the insertion target. If no free block is found, a new extent is allocated and attached to the table's segment. When a data table is first created, the corresponding segment contains zero data blocks. Initially, the extents added to the segment are small, for example, 64KB; as the table grows, the size of each newly added extent also increases.
[0084] Reference Figure 4 , Figure 4 This is a schematic diagram of a segment structure according to this application. The segment is divided into four sizes of extents. The first 16 extents of a segment can be 64KB each, the next 127 extents can be 1MB each, the next 112 extents can be 8MB each, and all subsequent extents can be 64MB each. The specific allocation strategy is shown in Table 1 below, where the extent count refers to which extent is in a segment. The first 16 extents belong to Group 1, each 64KB in size, for a total of 1MB. The 17th to 143rd extents belong to Group 2, each 1MB in size. The 144th to 255th extents belong to Group 3, each 8MB in size. Extents starting from the 256th extent belong to Group 4, and all are 64MB in size. This approach achieves a good balance between space utilization and allocation frequency. Allocating large extents from the beginning would result in wasted storage space. If the table becomes large later on, a small extent will cause frequent extent allocation, reducing efficiency. Furthermore, a large extent is more conducive to sequential I / O.
[0085] Table 1
[0086] 1 64K [1,16] 1M 2 1M [17,143] 128M 3 8M [144,255] 1G 4 64M [256,…] …
[0087] In this embodiment of the application, the storage controller can obtain a target operation request, wherein the target operation request is used to indicate the block (target block) to be operated on.
[0088] In traditional PG-based storage systems, data operations (such as read and write operations) on physical files are performed through the smgr (storage manager) layer. A data block's location can be represented by "segment's relfilenode, block number," where relfilenode is the filename of the file corresponding to that segment, and block number is the offset of the data block within that segment. Since each segment in existing PG-based storage systems occupies a dedicated physical file, the block number is essentially the physical address of the data block. Therefore, to read or write a data block within a file, the storage engine passes the necessary information to the smgr layer.<relfilenode,block number> The smgr layer calls the relevant system calls. For example, during a sequential scan, the storage engine will traverse the block number starting from 0 to read all data blocks of that segment.
[0089] In this embodiment of the application, the target operation request includes a target logical address, which is used to indicate the target block among the multiple blocks. The physical address of the target block can be determined based on the target logical address, and data operations can be performed. All modifications are concentrated below the smgr layer, and the damage to the existing PG-related code structure is minimal.
[0090] In one possible design, the target logical address includes first indication information and second indication information. The first indication information is used to indicate the target segment, and the second indication information is used to indicate the position of the target block in the target segment. The first indication information may include a relfilenode field, and the second indication information may include the logical page number of the target block in the target segment.
[0091] Specifically, from the top-level perspective, each segment still occupies its own file, and the block number of the data blocks ranges from 0 to n-1, where n is the total number of data blocks in that segment. The storage engine still transmits...<relfilenode,block number> In the smgr layer, the page number can be called a logical page number. The storage manager can translate the logical page number into a specific physical address for data operations.
[0092] This application uses logical addressing, so no code above the smgr layer needs to be modified. This reduces intrusive modifications to the original code, greatly reduces the risk of software development, and avoids compatibility issues by not modifying the page format. It is also easy to implement in a PG-based database system.
[0093] 202. Based on the target logical address, determine the target physical address of the target block through the address mapping relationship.
[0094] In one possible design, the target extent among the plurality of extents, and the offset of the target block relative to the starting block of the target extent, can be determined based on the logical page number.
[0095] In this embodiment, since the expansion method of extents in a segment is fixed, given the logical page number of the target extent, the corresponding extent and its offset within that extent (that is, the offset of the target block relative to the starting block of the target extent) can be calculated based on that logical page number. For example, taking the extent allocation rules described in Table 1 as an example, if the logical page number of the target extent is 516, which is between 128 and 16384, it belongs to Group 2. Group 1 occupies a total of 128 page numbers, so the target extent belongs to the (516–128) / 128 = 3rd (counting from 0) extent in Group 2, and the offset is the (516–128)%128 = 4th extent. Here, the operator " / " indicates rounding the result of division, and the operator "%" indicates taking the remainder.
[0096] In one possible design, the first physical address of the starting block of the target extent can be obtained through address mapping based on the target extent.
[0097] In this embodiment, the corresponding extent and its offset within that extent can be calculated based on the logical page number of the target extent. Therefore, by finding the first physical address of the starting block of each extent, i.e., constructing an address mapping relationship from extent ID to physical address (e.g., physical page number), the conversion from logical page number to physical page number can be achieved. Optionally, this address mapping relationship can be implemented based on an array, where the extent id is the array index and the first physical address of the starting block of the extent is the array value.
[0098] In this embodiment of the application, after obtaining the first physical address of the starting block of the target extent and the offset of the target block relative to the starting block of the target extent, the target physical address of the target block can be obtained based on the first physical address and the offset.
[0099] The following describes the storage method for the above address mapping relationship:
[0100] In one possible design, the address mapping relationship may include a first-level mapping relationship and a second-level mapping relationship; based on the target extent, the target extent to which it belongs, and the second-level mapping relationship corresponding to the target extent group, can be determined through the first-level mapping relationship; wherein, the first-level mapping relationship is used to indicate multiple extent groups and the second-level mapping relationship corresponding to each extent group, and based on the target extent, the first physical address of the starting block of the target extent is determined through the second-level mapping relationship corresponding to the target extent group; the second-level mapping relationship is used to indicate the physical address of the starting block of each extent in the target extent group.
[0101] Storing the physical address of the starting block of each extent requires a certain amount of storage space (e.g., 4 bytes). Taking the segment shown in Table 1 as an example, there are 255 extents for 64K, 1M, and 8M extents, so they can be directly stored in the segment's header page. The metadata size is 255 * 4 bytes = 1KB. For 64MB extents, there is no upper limit to the number. Assuming a single table size is 32TB, approximately 32TB / 64MB = 512K extents are needed, with a metadata size of 2MB. A single segment header page cannot store all of these, and reserving such a large space in advance would be wasteful. Therefore, a two-level block map tree (BMT) can be used to store the above address mapping relationship. The two levels of the BMT can include a first-level mapping relationship (also referred to as Level 0 index page in this embodiment) and a second-level mapping relationship (also referred to as Level 1 index page in this embodiment). Each unit in the Level 0 index page corresponds to the starting physical address of an extent. Each Level 0 index page can be stored in one physical page. Taking 4 bytes per starting physical address as an example, one physical page can store 8K / 4 = 2K elements. The operator " / " represents division. It should be understood that this physical page can also be directly called a Level 0 index page. Since there are a maximum of 512K extents, a Level 1 index page only needs 512K / 2k = 256 slots. The operator " / " represents division. Therefore, it can be stored in the physical pages of the segment header. When the extents in a segment expand beyond the currently allocated space of the segment header, the number of physical pages in the segment header can be expanded without reserving a large number of segment headers in advance, reducing resource waste.
[0102] Reference Figure 5 , Figure 5 This is a storage method for the address mapping relationship of segments in Table 1. The starting physical address of 8K, 16k, and 8M extents is directly obtained from the Level 0 index table stored in the segment header. However, for a 64M extent, the starting physical address needs to be found through the mapping from the Level 1 index table to the Level 0 index table. Therefore, at most two levels of addressing are required to locate the starting physical address of an extent.
[0103] The plurality of extents includes a first extent and a second extent. The first extent is closer to the starting block of the target segment than the second extent. The first extent is an idle extent, and the second extent is an occupied extent. When performing an index shrinking operation, the physical address of the starting block of the first extent in the address mapping relationship can be modified to the physical address of the starting block of the second extent.
[0104] One problem with segmented paging is its susceptibility to gaps. Even if a data table is deleted (e.g., via a drop or truncate operation), the occupied file storage space is not released. To reclaim physical space, the still-used data blocks need to be moved to the beginning of the segmented file, then a file resizing (ftruncate) operation needs to be performed, and the unused portion at the end of the segment needs to be released. In existing PG-based storage systems, physical addresses are used, so the physical address index needs to be rebuilt when moving data, significantly increasing I / O overhead. In this embodiment, since the upper layer sees only logical addresses, and the logical addresses can remain unchanged during the move, it is only necessary to move the extents near the end of the segment to the beginning of the file and update the address mapping relationship. Because the address mapping relationship also stores logical addresses, it is not necessary to rebuild the entire segment index during this process, thus greatly reducing the I / O overhead of the shrinking process. Specifically, the extent near the end of the segment can be the second extent, and the first extent is a free extent. That is, the first extent is a free extent that has not been allocated a physical file (for example, the physical data of the extent has been deleted). It can be moved at the extent level. The second extent is moved to the first extent. That is, the logical address of the first extent is not changed, but the physical address of the starting block of the first extent in the address mapping relationship is modified to the physical address of the starting block of the second extent.
[0105] In one possible design, the storage space corresponding to each segment can be used to store multiple physical files, and the storage space corresponding to M extents among the multiple extents in the target segment is used to store the target physical file, and the storage space corresponding to the M extents is the same size.
[0106] Segmented paging storage is prone to fragmentation of free space because it allocates extents of different sizes within the same physical file. For example, existing PostgreSQL-based database systems divide a segment into extents of 64KB, 1MB, 8MB, and 64MB, requiring that later extents within the same segment be at least as large as earlier extents. This can result in a file containing numerous 64KB free extents, but failing to allocate contiguous 64MB extents. In this embodiment, allocating only extents of the same size to a physical file reduces the amount of fragmentation in free space.
[0107] 203. Perform data operations on the storage space where the target physical address is located.
[0108] In one possible implementation, the data operations include at least one of the following operation types: add operation, delete operation, modify operation, and query operation.
[0109] The results of this application embodiment compared with the prior art can be referred to Table 2:
[0110] Table 2
[0111] Estimated amount of code modifications required. >50,000 <1000 Do you want to modify the page format? yes no Data migration granularity during Shrink surface Data blocks Should the index be rebuilt during Shrink? yes no
[0112] This application provides an operation request processing method applied to a hard disk controller. The hard disk controller is used to allocate logical addresses for the storage space of the hard disk. The logical address includes a target segment, which is divided into multiple extents, and each extent is divided into multiple blocks. The method includes: obtaining a target operation request, which includes a target logical address, which indicates a target block among the multiple blocks; determining the target physical address of the target block based on the target logical address through an address mapping relationship; and performing data operations on the storage space where the target physical address is located. In a PG-based database system, since each physical file corresponds to a segment, physical addressing can be used directly. The physical address can include the filename and the physical number within the segment corresponding to that filename. The filename directly corresponds to a specific segment, and the physical number is the position of the block within that segment. Since only one physical file corresponds to a segment, the segment can be traversed sequentially from 0 until the physical number is reached. However, in segmented paging, each physical file can be assigned to multiple segments. In the existing approach, to introduce segmented paging into the PG database implementation, a large amount of code needs to be modified in the smgr layer. This is to ensure that after obtaining the physical number, traversal cannot start from 0, but rather the starting position of the physical file corresponding to that physical number within the segment needs to be determined, and then traversal can begin from that starting position until the block corresponding to the physical number is reached. This code requires extensive modifications. In this embodiment, addressing is not based directly on the physical address, but rather on a logical address as an intermediate address. This eliminates the need for extensive code modifications in the smgr layer; only the physical address provided in the smgr layer needs to be replaced with a logical address. The logical address indicates the specific location of the block within the segment, and addressing is performed based on the mapping from logical address to logical address. Specifically, addressing can be based on the target logical address of the target block and the mapping from the target logical address to the physical address. In other words, the physical address of the target block can be determined based on the target logical address, and data operations can be performed. All modifications can be concentrated below the smgr layer, with minimal changes to the code above the smgr layer. This minimizes disruption to the existing PG-related code structure, reducing intrusive modifications to the original code and significantly lowering the risk of software development. Furthermore, it eliminates the need to modify page formats, improving compatibility and facilitating implementation in PG-based database systems.
[0113] The above text combined Figures 2 to 6The operation request processing method provided in the embodiments of this application has been described in detail. The operation request processing device provided in the embodiments of this application will be described below from the perspective of functional units in conjunction with the accompanying drawings.
[0114] Reference Figure 7 , Figure 7 This application provides a schematic diagram of the structure of an operation request processing device, wherein the device 700 can be applied to a hard disk controller, the hard disk controller being used to allocate logical addresses for the storage space of the hard disk, wherein the logical address includes a target segment, the target segment being divided into multiple extents, and each extent being divided into multiple blocks, the device comprising:
[0115] The acquisition module 701 is used to acquire a target operation request, the target operation request including a target logical address, the target logical address being used to indicate a target block among the plurality of blocks;
[0116] For a detailed description of the acquisition module 701, please refer to the description of step 201 in the above embodiments, which will not be repeated here.
[0117] The determining module 702 is used to determine the target physical address of the target block based on the target logical address and through address mapping relationships;
[0118] For a detailed description of the determination module 702, please refer to the description of step 202 in the above embodiments, which will not be repeated here.
[0119] The data operation module 703 performs data operations on the storage space where the target physical address is located.
[0120] For a detailed description of the data operation module 703, please refer to the description of step 203 in the above embodiment, which will not be repeated here.
[0121] In one possible implementation, the target logical address includes first indication information and second indication information, wherein the first indication information is used to indicate the target segment and the second indication information is used to indicate the position of the target block within the target segment.
[0122] In one possible implementation, the first indication information includes the relfilenode field.
[0123] In one possible implementation, the second indication information includes the logical page number of the target block within the target segment.
[0124] In one possible implementation, the determining module 702 is specifically configured to determine, based on the logical page number, the target extent among the plurality of extents, and the offset of the target block relative to the starting block of the target extent within the target extent;
[0125] Based on the target extent, the first physical address of the starting block of the target extent is obtained through the address mapping relationship;
[0126] The target physical address of the target block is obtained based on the first physical address and the offset.
[0127] In one possible implementation, the address mapping relationship includes a first-level mapping relationship and a second-level mapping relationship; the determining module is specifically used to determine, based on the target extent, the target extent to which the target extent belongs, and the second-level mapping relationship corresponding to the target extent group, through the first-level mapping relationship; wherein, the first-level mapping relationship is used to indicate multiple extent groups, and the second-level mapping relationship corresponding to each extent group.
[0128] Based on the target extent, the first physical address of the starting block of the target extent is determined through the second-level mapping relationship corresponding to the target extent group; the second-level mapping relationship is used to indicate the physical address of the starting block of each extent in the target extent group.
[0129] In one possible implementation, the plurality of extents includes a first extent and a second extent, wherein the first extent is closer to the starting block of the target segment than the second extent, the first extent is an idle extent, and the second extent is an occupied extent; the apparatus further includes:
[0130] The address modification module 704 is used to modify the physical address of the starting block of the first extent in the address mapping relationship to the physical address of the starting block of the second extent.
[0131] In one possible implementation, the storage space corresponding to each segment is used to store multiple physical files.
[0132] In one possible implementation, the storage space corresponding to M of the plurality of extents is used to store the target physical file, and the storage space corresponding to the M extents is of the same size.
[0133] In one possible implementation, the data operations include at least one of the following operation types: add operation, delete operation, modify operation, and query operation.
[0134] Reference Figure 8 This application also provides a computer-readable storage medium, in some embodiments of which the above-described... Figure 2 The disclosed method can be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or on other non-transitory media or articles of art. Figure 8 A conceptual partial view of an example computer program product arranged according to at least some embodiments shown herein is schematically illustrated. The example computer program product includes a computer program for executing computer processes on a computing device. In one embodiment, the example computer program product 800 is provided using a signal carrying medium 801. The signal carrying medium 801 may include one or more program instructions 802 that, when executed by one or more processors, can provide the above-described instructions for… Figure 2 The described function or part of the function. Therefore, for example, refer to... Figure 2 In the embodiment shown, one or more features of steps 201 to 203 can be performed by one or more instructions associated with the signal carrying medium 801. Furthermore, Figure 8 The program instruction 802 in the document also describes example instructions.
[0135] In some examples, signal-bearing medium 801 may include computer-readable medium 803, such as, but not limited to, hard disk drives, CDs, digital video optical discs (DVDs), digital magnetic tapes, memory, read-only memory (ROM), or random access memory (RAM), etc. In some embodiments, signal-bearing medium 801 may include computer-recordable medium 804, such as, but not limited to, memory, read / write (R / W) CDs, R / W DVDs, etc. In some embodiments, signal-bearing medium 801 may include communication medium 805, such as, but not limited to, digital and / or analog communication media (e.g., fiber optic cables, waveguides, wired communication links, wireless communication links, etc.). Therefore, for example, signal-bearing medium 801 may be conveyed by wireless communication medium 805 (e.g., wireless communication media conforming to the IEEE 802.11 standard or other transmission protocols). One or more program instructions 802 may be, for example, computer-executable instructions or logical implementation instructions. In some examples, the computing device can be configured to provide various operations, functions, or actions in response to program instructions 802 conveyed to the computing device via one or more of a computer-readable medium 803, a computer-recordable medium 804, and / or a communication medium 805. It should be understood that the arrangements described herein are merely for illustrative purposes. Therefore, those skilled in the art will understand that other arrangements and other elements (e.g., machines, interfaces, functions, sequences, and functional groups, etc.) can be used instead, and some elements can be omitted depending on the desired result. Furthermore, many of the described elements are functional entities that can be implemented as discrete or distributed components, or in any suitable combination and location in conjunction with other components.
[0136] Figure 9 The diagram shown illustrates a possible logical structure of the computer device 90 described in the above embodiments of this application. The computer device 90 can be... Figure 8 The computer device 90 includes an operation request processing apparatus. The computer device 90 may include a processor 901, a communication interface 902, a memory 903, and a bus 904. The processor 901, communication interface 902, and memory 903 are interconnected via the bus 904. In embodiments of this application, the processor 901 is used to execute... Figure 2 The steps 201 to 203 in the embodiment are described. The communication interface 902 is used to support communication by the computer device 90; for example, the communication interface 902 can perform the steps related to receiving or sending in the above method embodiments. The memory 903 is used to store the program code and data of the database server.
[0137] The processor 901 can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, etc. The bus 904 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 9 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0138] In another embodiment of this application, a chip system is also provided, the chip system including a processor for supporting means for injecting timing data or means for querying timing data to implement the above. Figure 2 The embodiment describes an operation request processing method. In one possible design, the chip system may further include a memory for managing the necessary program instructions and data for the application. This chip system may consist of chips or may include chips and other discrete devices.
[0139] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0140] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0141] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0142] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0143] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0144] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of this application, essentially, or the parts that contribute to the prior art, or parts of the technical solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0145] The above are merely specific embodiments of this application, but the protection scope of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be included within the protection scope of this application. Therefore, the protection scope of this application should be determined by the scope of the claims.
Claims
1. A method for processing operation requests, characterized in that, The method is applied to a hard disk controller, which allocates logical addresses to the storage space of the hard disk. The hard disk controller is a controller implemented based on PG. The logical address includes a target segment, which is divided into multiple regions. Each region is further divided into multiple data blocks. One target segment corresponds to one object, which includes an index or a data table. The multiple regions contain regions of different sizes. As the target segment expands, the additional regions become larger. The storage space corresponding to each target segment is used to store multiple physical files. M regions among the multiple regions correspond to storage spaces used to store target physical files, and the storage spaces corresponding to the M regions are of the same size. The method includes: Obtain a target operation request, the target operation request including a target logical address, the target logical address being used to indicate a target data block among the plurality of data blocks; Based on the target logical address, the target physical address of the target data block is determined through the address mapping relationship; Perform data operations on the storage space where the target physical address is located.
2. The method according to claim 1, characterized in that, The target logical address includes first indication information and second indication information. The first indication information is used to indicate the target segment, and the second indication information is used to indicate the position of the target data block in the target segment.
3. The method according to claim 2, characterized in that, The first indication information includes the relfilenode field.
4. The method according to claim 2, characterized in that, The second indication information includes the logical page number of the target data block in the target segment.
5. The method according to claim 4, characterized in that, The step of determining the target physical address of the target data block based on the target logical address and through address mapping relationships includes: Based on the logical page number, determine the target area among the plurality of areas, and the offset of the target data block in the target area relative to the starting data block of the target area; Based on the target area, the first physical address of the starting data block of the target area is obtained through the address mapping relationship; The target physical address of the target data block is obtained based on the first physical address and the offset.
6. The method according to claim 5, characterized in that, The address mapping relationship includes a first-level mapping relationship and a second-level mapping relationship; obtaining the first physical address of the starting data block of the target area according to the target area through the address mapping relationship includes: Based on the target area, the target area group to which the target area belongs and the second-level mapping relationship corresponding to the target area group are determined through the first-level mapping relationship; wherein, the first-level mapping relationship is used to indicate multiple area groups and the second-level mapping relationship corresponding to each area group. Based on the target area, the first physical address of the starting data block of the target area is determined through the second-level mapping relationship corresponding to the target area group; the second-level mapping relationship is used to indicate the physical address of the starting data block of each area in the target area group.
7. The method according to claim 5 or 6, characterized in that, The plurality of zones includes a first zone and a second zone, wherein the first zone is closer to the starting data block of the target segment than the second zone, the first zone is a free zone, and the second zone is an occupied zone; the method further includes: Modify the physical address of the starting data block of the first region in the address mapping relationship to the physical address of the starting data block of the second region.
8. The method according to any one of claims 1 to 6, characterized in that, The data operations include at least one of the following operation types: add operation, delete operation, modify operation, and query operation.
9. An operation request processing apparatus, characterized in that, The device is applied to a hard disk controller, which allocates logical addresses to the storage space of the hard disk. The hard disk controller is a controller implemented based on PG. The logical address includes a target segment, which is divided into multiple regions. Each region is divided into multiple data blocks. One target segment corresponds to one object, which includes an index or a data table. The multiple regions contain regions of different sizes. As the target segment expands, the additional regions become larger. The storage space corresponding to each target segment is used to store multiple physical files. M regions among the multiple regions correspond to storage spaces used to store target physical files, and the storage spaces corresponding to the M regions are of the same size. The device includes: An acquisition module is used to acquire a target operation request, wherein the target operation request includes a target logical address, and the target logical address is used to indicate a target data block among the plurality of data blocks; The determination module is used to determine the target physical address of the target data block based on the target logical address and through address mapping relationships. The data operation module performs data operations on the storage space where the target physical address is located.
10. The apparatus according to claim 9, characterized in that, The target logical address includes first indication information and second indication information. The first indication information is used to indicate the target segment, and the second indication information is used to indicate the position of the target data block in the target segment.
11. The apparatus according to claim 10, characterized in that, The first indication information includes the relfilenode field.
12. The apparatus according to claim 10, characterized in that, The second indication information includes the logical page number of the target data block in the target segment.
13. The apparatus according to claim 12, characterized in that, The determining module is specifically used to determine the target area among the plurality of areas based on the logical page number, and the offset of the target data block in the target area relative to the starting data block of the target area; Based on the target area, the first physical address of the starting data block of the target area is obtained through the address mapping relationship; The target physical address of the target data block is obtained based on the first physical address and the offset.
14. The apparatus according to claim 13, characterized in that, The address mapping relationship includes a first-level mapping relationship and a second-level mapping relationship; the determining module is specifically used to determine the target area group to which the target area belongs, and the second-level mapping relationship corresponding to the target area group, based on the target area and through the first-level mapping relationship; wherein, the first-level mapping relationship is used to indicate multiple area groups, and the second-level mapping relationship corresponding to each area group. Based on the target area, the first physical address of the starting data block of the target area is determined through the second-level mapping relationship corresponding to the target area group; the second-level mapping relationship is used to indicate the physical address of the starting data block of each area in the target area group.
15. The apparatus according to claim 13 or 14, characterized in that, The plurality of zones includes a first zone and a second zone, wherein the first zone is closer to the starting data block of the target segment than the second zone; the first zone is a free zone, and the second zone is an occupied zone; the device further includes: The address modification module is used to modify the physical address of the starting data block of the first region in the address mapping relationship to the physical address of the starting data block of the second region.
16. The apparatus according to any one of claims 9 to 14, characterized in that, The data operations include at least one of the following operation types: add operation, delete operation, modify operation, and query operation.
17. An operation request processing apparatus, characterized in that, The apparatus includes at least one processor, a memory, and instructions stored in the memory and executable by the at least one processor, characterized in that the at least one processor executes the instructions to implement the steps of the method according to any one of claims 1 to 8.
18. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a computer, implements the method described in any one of claims 1 to 8.
19. A computer program product, characterized in that, Includes computer-readable instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Database management method and system
CN103473321A
Flash Translation Layer (FTL) address mapping method and device
CN106326134A
Data storage method and device
CN106354431A