A user-mode disk partitioning method based on rocksdb and spdk
By using rocksdb and spdk user disk partitioning methods in the SPDK user state driver scenario, the NVME disk partitioning problem is solved, and the unlimited partition creation, data reliability and GC efficiency are achieved to ensure the availability of partitioned data after power loss.
Patent Information
- Application Number
- CN202311703009.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-12
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2043-12-12
AI Technical Summary
In the prior art, in the scenario of using the SPDK user state driver, the partitioning operation of the NVME disk cannot be effectively performed, and the traditional partitioning method affects the global GC efficiency and data reliability.
Using user-state disk partitioning methods based on rocksdb and spdk, the nvme disk data is scanned through the spdk interface and persisted into rocksdb. Users can create and manage partitions, and partition information is persisted in rocksdb to ensure data reliability and partition availability. .
Supports unlimited partition creation, avoid formatting disks, maintains IO read and write efficiency and gc efficiency, and does not affect existing partitions, ensuring the availability of data after the machine powered down.
Smart Images

Figure CN117724657B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed storage technology, and more specifically, to a user-mode disk partitioning method based on rocksdb and spdk. Background Art
[0002] In storage systems that pursue extreme performance and latency, spdk's nvme user-mode driver is usually used to take over access to the disk. In storage systems, it is often necessary to divide an nvme-ssd disk into multiple disk partitions according to different disk functions or storage performance requirements.
[0003] There are two traditional solutions: one is the namespace function of the nvme disk itself, but not all manufacturers' disks support the namespace function, and the namespace of a disk is limited. The division of namespace requires formatting the entire disk; after being converted into a namespace, it will also affect the GC function of the nvme-ssd disk. Multiple namespaces make the global GC become local GC, and the GC effect is not good; the other is to use the partition command of the operating system for logical partitioning, but because spdk is used to take over the nvme-ssd disk, it is also impossible to perform partition operations through system commands; for example, the patent with application publication number CN114237957A discloses a method and device for processing abnormal disk partitions, and another example is the patent with application publication number CN112347044A discloses an object storage optimization method based on SPDK; all of them are partitioning schemes based on the participation of the operating system, and do not solve the partition problem of the nvme disk in the user scenario of using spdk;
[0004] In view of this, the present invention proposes a user-mode disk partitioning method based on rocksdb and spdk to solve the above problems. Summary of the invention
[0005] In order to overcome the above defects of the prior art and to achieve the above objectives, the present invention provides the following technical solutions: a user-mode disk partitioning method based on rocksdb and spdk, comprising:
[0006] S1: Create partitions according to the user's request to create partitions;
[0007] S2: After the partitions are created, data is loaded into each partition;
[0008] S3: After data loading is complete, read and write IO for each partition.
[0009] Furthermore, the partition creation method includes:
[0010] S101: Scan all nvme disks on the host through the spdk interface to obtain disk data; persist the disk data to rocksdb;
[0011] S102: The user initiates a partition creation request, and the partition creation request includes partition information;
[0012] S103: Determine whether to create a partition according to the user's request to create a partition.
[0013] Furthermore, the disk data in step S101 includes a disk serial number, a disk storage capacity, and a logical block address.
[0014] Furthermore, the partition information in step S102 includes a designated disk serial number, a partition name, a starting address and an ending address of the partition on the disk, a partition size, and a partition type.
[0015] Furthermore, the method for determining whether to create a partition in step S103 includes:
[0016] Check whether the remaining capacity of the disk meets the partition information;
[0017] If the remaining capacity of the disk satisfies the partition information, a specified partition is divided from the remaining space of the disk, the partition is formatted, the super block information is written in the first 4K space of the created partition, and the partition information is persisted in rocksdb.
[0018] Furthermore, the super block information includes metadata information and key parameters of the file storage system, and the metadata information includes the structure and organization of the file storage system.
[0019] Furthermore, the method of loading data by partition includes:
[0020] S201: Restart the computer and load all disk data and partition information from rocksdb;
[0021] S202: recalculating the capacity parameters of each disk according to the disk data and partition information;
[0022] S203: Load the super block information of each partition and verify the correctness of the super block information.
[0023] Furthermore, the capacity parameters in step S202 include the disk's used capacity and the disk's remaining capacity.
[0024] Furthermore, the method for the user to read and write the IO of the partition according to the required data includes:
[0025] S301: The user requests to call the read / write IO interface to read and write the required data, and sends the user parameters;
[0026] S302: After receiving the user request, the computer management process searches for partition information from rocksdb according to the user parameters;
[0027] S303: Convert the partition information and user parameters into disk operation parameters.
[0028] Furthermore, the user parameters in step S301 include a partition name, a logical block address of the required data in the partition, and the number of logical blocks of the required data.
[0029] Technical effects and advantages of a user-mode disk partitioning method based on rocksdb and spdk in the present invention:
[0030] 1. Support nvme-ssd disk partition in the scenario of spdk-nvme.
[0031] 2. By deploying rocksdb in the system disk and persisting the information of logical partitions in rocksdb, data reliability is guaranteed; when the machine is powered off and restarted, the partition information is restored from rocksdb to ensure the availability of partition data; and by operating rocksdb to add, delete, modify, and query operations, partitions can be added, deleted, modified, and queried.
[0032] 3. There is no upper limit on the number of partitions that can be created, and creating partitions does not require formatting the disk. It will not affect the IO read and write of the created partitions, nor will it affect the GC efficiency of the overall disk. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 This is a schematic diagram of a user-mode disk partitioning method based on rocksdb and spdk in Example 1 of the present invention;
[0034] Figure 2 This is a schematic diagram of the partition layout of Example 1 of the present invention;
[0035] Figure 3 This is a schematic diagram of an electronic device according to Embodiment 2 of the present invention;
[0036] Figure 4 This is a schematic diagram of a storage medium according to Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Example 1
[0039] See also Figure 1 As shown, the user-mode disk partitioning method based on rocksdb and spdk described in this embodiment includes:
[0040] S1: Create partitions according to the user's request to create partitions;
[0041] The methods for creating partitions include:
[0042] S101: Scan all nvme disks on the computer through the spdk interface to obtain disk data; persist the disk data to rocksdb;
[0043] S102: The user initiates a partition creation request, and the partition creation request includes partition information;
[0044] S103: judging whether to create a partition according to the user's request to create a partition;
[0045] Exemplarily, first scan all nvme disks on the computer to obtain disk data, as shown in Table 1;
[0046]
[0047] Table 1
[0048] Then execute the command to create a partition to create a disk partition;
[0049] create partition--name=test_pt--size=4G--sn=SN1
[0050] Then check the created partition information, as shown in Table 2;
[0051] pt_name SerialNumber PciCode Namespace Begin End test_pt SH1 0000:66:00.0 1 0 4294967296
[0052] Table 2
[0053] Finally read and write partition data;
[0054] Write 4K data, offset is 0;
[0055] WritePartition("test_pt",0,4096,data)
[0056] In step S101, the disk data includes the disk serial number, the disk storage capacity and the logical block address; the logical block address is an addressing method used for disk storage, and the data blocks on the disk are numbered as logical block addresses;
[0057] The purpose of persisting disk data to RocksDB is to store disk data in a reliable and efficient database so that disk data can be quickly written and read later. RocksDB is a high-performance embedded key-value storage engine, including in-memory database, persistent storage, distributed storage, etc. It also provides a flexible data model and rich data operation interfaces to facilitate data query, analysis and management.
[0058] The partition information in step S102 includes a designated disk serial number, a partition name, a starting address and an ending address of the partition on the disk, a partition size, and a partition type; the disk serial number is used to identify each disk; the partition name is a name corresponding to each partition; the starting address and the ending address of the partition on the disk determine the location range of the partition; the partition size is the size of the disk space occupied by the partition; the partition type is, for example, a data partition, a log partition, a metadata partition, etc., and different partition types can be bound and associated, for example, a data partition is bound and associated with a log partition and a metadata partition;
[0059] The method for determining whether to create a partition in step S103 includes:
[0060] Check whether the remaining capacity of the disk meets the partition information;
[0061] If the remaining capacity of the disk meets the partition information, a specified partition is divided from the remaining space of the disk, the partition is formatted, the super block information is written in the first 4K space of the created partition, and the partition information is persisted in rocksdb;
[0062] If the remaining capacity of the disk does not meet the partition information, the partition will not be created;
[0063] The super block information includes the metadata information and key parameters of the file storage system. The metadata information includes the structure and organization of the file storage system, such as the size of the file storage system, the starting position of the inode table, the starting position of the data block bitmap, etc. The file storage system is an organization method for computer storage data, which has the functions of organizing and managing data, storing and accessing data, protecting data, and managing resources.
[0064] The purpose of writing super block information in the first 4K space of the created partition is to create the basic structure of the file storage system and ensure the normal operation of the file storage system.
[0065] It should be noted that a disk can create multiple partitions, and each partition has a 4M isolation space. When the remaining disk space is less than 128M, there is no longer enough space to store additional partition tables and management information, so no more partitions can be created.
[0066] For the layout of the partitions, see Figure 2 As shown;
[0067] S2: After the partitions are created, data is loaded into each partition;
[0068] Methods for loading data by partition include:
[0069] S201: Restart the computer and load all disk data and partition information from rocksdb;
[0070] S202: recalculating the capacity parameters of each disk according to the disk data and partition information;
[0071] S203: Load the super block information of each partition and verify the correctness of the super block information;
[0072] In step S202, the capacity parameters include the used capacity of the disk and the remaining capacity of the disk;
[0073] The method for verifying the correctness of the super block information in step S203 includes, for example, checking whether the metadata information of the file storage system in the super block matches the actual disk data; for each partition, the integrity of the disk data can be verified by reading the checksum in the super block; checking whether the timestamp and version information in the super block are consistent with the expected values to ensure that the data has not been tampered with or damaged; according to the characteristics of the file storage system, a specific verification algorithm can be executed, such as scanning and verifying the file system structure;
[0074] S3: After data loading is completed, users read and write IO of the partition according to the required data;
[0075] The methods for users to read and write IO of partitions according to the required data include:
[0076] S301: The user requests to call the read / write IO interface to read and write the required data, and sends the user parameters;
[0077] S302: After receiving the user request, the computer management process searches for partition information from rocksdb according to the user parameters;
[0078] S303: Converting the partition information and user parameters into disk operation parameters;
[0079] In step S301, the user parameters include the partition name, the logical block address of the required data in the partition, and the number of logical blocks of the required data; according to the user parameters, the location of the required data in the partition can be found;
[0080] The management process in step S302 is a specific process in the computer that is responsible for coordinating and managing other processes and resources. It is usually responsible for monitoring the allocation and use of computer resources, processing tasks and scheduling to ensure the normal operation of the computer and the efficient use of resources. In different application scenarios, the management process has different functions and responsibilities, such as processing request scheduling, resource allocation, error handling, performance monitoring, etc.
[0081] The operation parameters in step S303 include the read / write operation type, the name of the target disk, the logical block address of the target disk, the number of logical blocks of the required data, etc. For example, the user requests to write 10 logical blocks to the partition, and by querying the partition information, it is known that the starting logical block address of the partition is 10000. The management process will convert the user request into the number of logical blocks on the disk, that is, 10000+10=10010.
[0082] This embodiment can support nvme-ssd disk partitioning in the spdk-nvme scenario; it ensures data reliability by deploying rocksdb in the system disk and persisting the information of logical partitions in rocksdb; when the machine is powered off and restarted, the availability of partition data is guaranteed by restoring the partition information from rocksdb; there is no upper limit on the number of partitions created, and creating partitions does not require formatting the disk, which will not affect the IO reading and writing of the created partitions, nor will it affect the GC efficiency of the overall disk.
[0083] Example 2
[0084] See also Figure 3 As shown, according to another aspect of the present application, an electronic device 500 is also provided. The electronic device 500 may include one or more processors and one or more memories. The memories store computer readable codes, and when the computer readable codes are executed by one or more processors, a user-mode disk partitioning method based on rocksdb and spdk as described above may be executed.
[0085] The method or system according to the embodiment of the present application can also be used by Figure 3 The electronic device architecture shown in FIG. Figure 3 As shown, the electronic device 500 may include a bus 501, one or more CPUs 502, a read-only memory (ROM) 503, a random access memory (RAM) 504, a communication port 505 connected to a network, an input / output 506, a hard disk 507, etc. The storage device in the electronic device 500, such as ROM 503 or hard disk 507, may store a user-mode disk partitioning method based on rocksdb and spdk provided in the present application. Furthermore, the electronic device 500 may also include a user interface 508. Of course, Figure 3 The architecture shown is only exemplary and can be omitted according to actual needs when implementing different devices. Figure 3 One or more components of an electronic device are shown.
[0086] Example 3
[0087] See also Figure 4 As shown, a computer-readable storage medium 600 according to an embodiment of the present application is shown. Computer-readable instructions are stored on the computer-readable storage medium 600. When the computer-readable instructions are executed by the processor, a user-mode disk partitioning method based on rocksdb and spdk according to an embodiment of the present application described with reference to the above figures can be executed. The storage medium 600 includes, but is not limited to, for example, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and cache memory (cache), etc. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc.
[0088] In addition, according to the implementation of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the present application provides a non-transitory machine-readable storage medium, which stores machine-readable instructions, and the machine-readable instructions can be executed by a processor to execute instructions corresponding to the method steps provided in the present application, for example: a user-mode disk partitioning method based on rocksdb and spdk. When the computer program is executed by a central processing unit (CPU), the above functions defined in the method of the present application are executed.
[0089] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center through a wired network or a wireless network. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0090] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0091] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0092] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only one, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0093] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0094] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0095] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
[0096] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A user-mode disk partitioning method based on rocksdb and spdk, characterized in that: include: S1: Create partitions according to the user's request to create partitions; The partition creation method includes: S101: Scan all nvme disks on the host through the spdk interface to obtain disk data; persist the disk data to rocksdb; S102: The user initiates a request to create a partition, and the partition request includes partition information; S103: judging whether to create a partition according to the user's request to create a partition; The disk data in step S101 includes the disk serial number, the disk storage capacity and the logical block address; The partition information in step S102 includes a designated disk serial number, a partition name, a starting address and an ending address of the partition on the disk, a partition size, and a partition type; The method for determining whether to create a partition in step S103 includes: Check whether the remaining capacity of the disk meets the partition information; If the remaining capacity of the disk meets the partition information, a specified partition is divided from the remaining space of the disk, the partition is formatted, the super block information is written in the first 4K space of the created partition, and the partition information is persisted in rocksdb; S2: After the partitions are created, data is loaded into each partition; Methods for loading data by partition include: S201: Restart the computer and load all disk data and partition information from rocksdb; S202: recalculating the capacity parameters of each disk according to the disk data and partition information; S203: Load the super block information of each partition and verify the correctness of the super block information; The capacity parameters in step S202 include the used capacity of the disk and the remaining capacity of the disk; S3: After data loading is complete, read and write IO for each partition.
2. According to claim 1, a user-mode disk partitioning method based on rocksdb and spdk is characterized in that: The super block information includes metadata information and key parameters of the file storage system, and the metadata information includes the structure and organization of the file storage system.
3. According to claim 2, a user-mode disk partitioning method based on rocksdb and spdk is characterized in that: The method for the user to read and write the IO of the partition according to the required data includes: S301: The user requests to call the read / write IO interface to read and write the required data, and sends the user parameters; S302: After receiving the user request, the computer management process searches for partition information from rocksdb according to the user parameters; S303: Convert the partition information and user parameters into disk operation parameters.
4. According to claim 3, a user-mode disk partitioning method based on rocksdb and spdk is characterized in that: The user parameters in step S301 include the partition name, the logical block address of the required data in the partition, and the number of logical blocks of the required data.
Citation Information
Patent Citations
Object storage optimization method based on SPDK
CN112347044A
Method and device for processing abnormal disk partition
CN114237957A
Method and device for constructing virtual magnetic disk and processing data
CN106598496A
Storage system, data management method and storage medium
CN110764706A
Magnetic array management method and device based on volume-level RAID
CN111090394A
