A method and apparatus for ensuring data write consistency based on multi-level collaboration
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-23
- Publication Date
- 2026-08-14
AI Technical Summary
但是该方法中,如果日志备份一直进行,则每次写入过程必先写入日志空间,再写入成员盘,每份数据写入了两遍,如此带来性能的极大降低,尤其是对于大块写入过程,带宽性能下降更为明显;且用于备份数据的日志空间如果划分较少容易存在写满的情况,如果划分较多则会牺牲存储容量,增加成本
[0040]The data write consistency guarantee method and apparatus of this invention can solve the RAID write hole problem by setting up metadata space, persistent stripe mapping table, virtual device, memory mapping table, and memory bitmap. It does not rely on special hardware such as specific BBU or supercapacitor, and does not add new log disks. It achieves large data blocks being written only once, avoiding the waste of bandwidth resources caused by multiple data writes. It can not only achieve RAID power failure data protection and ensure data consistency, but also simplify hardware design, save costs by not adding new hard drives, and improve bandwidth performance, meeting the strict environmental adaptability and bandwidth performance requirements of large data writes in the field of ruggedized storage.
Smart Images

Figure CN122086334B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data storage technology, and specifically to a method and apparatus for ensuring data write consistency based on multi-level collaboration. Background Technology
[0002] RAID (Redundant Array of Independent Disks) is a technology that combines multiple physical disks into a single logical disk. It achieves fault tolerance through data redundancy (such as mirroring and parity checking) to prevent data loss due to the failure of a single disk. Its purpose is to improve data reliability, performance, or capacity. Common levels include RAID 0, RAID 1, RAID 5, RAID 6, and RAID 10.
[0003] Taking RAID 5 as an example, assuming RAID 5 has 3 disks, then the storage spaces of disk 1, disk 2, and disk 3 form physical stripe 1; the storage spaces of disk 1, disk 2, and disk 3 form physical stripe 2; and so on, with storage spaces of disk 1, disk 2, and disk 3 forming physical stripe n. Data is stored on RAID 5 in units of physical stripes.
[0004] Taking RAID 5's physical stripe 1 as an example, suppose a data 'a' consists of data a1 and data a2. Data a1 can be stored in storage space 1 of disk 1 (i.e., 1 / 3 of physical stripe 1), data a2 can be stored in storage space 1 of disk 2 (i.e., 1 / 3 of physical stripe 1), and storage space 1 of disk 3 (i.e., 1 / 3 of physical stripe 1) stores parity data a12. Parity data a12 is obtained by processing data a1 and data a2 (e.g., bitwise XOR). During use, if a disk fails, for example, disk 1 fails, then data a1 will be lost. In this case, data a1 can be reconstructed using data a2 and parity data a12, thereby improving data reliability.
[0005] However, a situation can arise where data 'a' in physical stripe 1 needs to be changed to data 'b'. Suppose a power outage occurs while data 'a1' has been changed to data 'b1' but data 'a2' has not. After power is restored, physical stripe 1 contains data 'b1', data 'a2', and parity data 'a12'. If, subsequently, a disk fails (e.g., disk 2 fails), data 'a2' will be lost. In this case, the data derived from data 'b1' and parity data 'a12' will not be the correct data 'a2', resulting in a RAID write hole problem.
[0006] Currently, there are two main approaches to addressing RAID write holes: one is based on hardware RAID solutions, which add a BBU (Block Buffer Unit) or supercapacitor to the RAID array. When the device suddenly loses power, it can promptly store any stripe data that hasn't been fully written to the member disks onto non-lossable media. After the device is powered on again, the data is recovered from the non-lossable media and rewritten to the member disks. However, this approach relies on hardware such as BBUs or supercapacitors, increasing hardware costs. Furthermore, BBUs or supercapacitors require regular maintenance, increasing maintenance costs, and are prone to causing serious accidents such as fires, posing safety hazards. This is especially problematic in hardened storage applications with stringent environmental requirements, where BBUs and similar hardware modules often fail high / low temperature and safety tests.
[0007] Another approach is to use a log method, where data is first backed up to the log space before being written to the member disk. When the device experiences a sudden power outage, the data is saved in the log disk. When the device powers on, the data is restored from the log disk and rewritten to the member disk. However, if log backups are continuous, each write operation must first write to the log space and then to the member disk, resulting in each data being written twice. This leads to a significant performance degradation, especially for large write operations where bandwidth performance drops more noticeably. Furthermore, if the log space used for backup data is divided into smaller partitions, it is prone to becoming full; if divided into larger partitions, storage capacity is sacrificed, increasing costs. Summary of the Invention
[0008] The purpose of this invention is to provide a method and apparatus for ensuring data write consistency based on multi-level collaboration, which can solve the RAID write hole problem without reducing bandwidth performance, and does not depend on specific hardware, thus avoiding excessive cost increases.
[0009] In a first aspect of the present invention, a method for ensuring data write consistency based on multi-level collaboration is provided, comprising:
[0010] In RAID, a metadata space is set up, which contains a persistent stripe mapping table;
[0011] When the system powers on and starts up, virtual devices are created. Once the virtual devices are created, they have a memory mapping table and a memory bitmap.
[0012] When the host initiates a write request, the virtual device determines the logical stripe based on the write request and determines the target physical stripe based on the logical stripe, the memory mapping table, and the memory bitmap. Based on the determined target physical stripe, the data is written to the RAID. After the data writing is completed, the memory mapping table and the memory bitmap are updated, and the memory mapping table is stored in the metadata space to complete the update of the persistent mapping table.
[0013] As a preferred embodiment of the present invention, setting up the metadata space in RAID specifically includes:
[0014] Create a 5- or 6-level RAID based on multiple physical disks;
[0015] Use the physical stripes at the beginning of the RAID as the metadata space.
[0016] As a preferred embodiment of the present invention, creating a virtual device specifically includes:
[0017] The kernel loads the virtual device driver module;
[0018] During the initialization of the virtual device driver module, a persistent stripe mapping table is loaded from the RAID metadata space into memory to form a memory mapping table, and a memory bitmap is reconstructed based on the memory mapping table.
[0019] Register the virtual block device with the kernel block device subsystem to complete the creation of the virtual device.
[0020] As a preferred embodiment of the present invention, reconstructing the memory bitmap based on the memory mapping table specifically includes:
[0021] Traverse the RAID to determine the number range of physical stripes, determine the bitmap number of each bit in the memory bitmap based on the physical stripe number, and set the bitmap status code of each bit in the memory bitmap to 0.
[0022] Traverse the memory-mapped table. When a physical stripe number exists in the memory-mapped table, find the bitmap number corresponding to the physical stripe number in the bitmap and set the bitmap status code of the bit where the bitmap number is located to 1.
[0023] As a preferred embodiment of the present invention, the virtual device determines logical stripes based on write requests and determines target physical stripes based on logical stripes, memory mapping tables, and memory bitmaps, specifically including:
[0024] The virtual device parses the write request to obtain the logical block address range, and determines the target logical stripe number based on the logical block address range;
[0025] The memory mapping table is queried based on the target logical stripe number, and the currently used physical stripe number for each target logical stripe number is recorded.
[0026] Based on the memory bitmap, allocate free target physical stripe numbers to the target logical stripe numbers.
[0027] As a preferred embodiment of the present invention, allocating free target physical stripe numbers to target logical stripe numbers based on memory bitmaps specifically includes:
[0028] Determine the number N of the target logic stripe numbers;
[0029] Traverse the bitmaps in ascending order of bitmap number, obtain the N bitmap numbers with bitmap status code 0, and determine the N idle target physical stripe numbers based on the N bitmap numbers.
[0030] As a preferred embodiment of the present invention, updating the memory mapping table and memory bitmap after data writing is completed specifically includes:
[0031] Based on the records, replace the used physical stripe number corresponding to the target logical stripe number in the memory mapping table with the target physical stripe number;
[0032] Based on the physical stripe number already used, determine the first bitmap number to be processed, and set the bitmap status code corresponding to the first bitmap number to be processed in the memory bitmap to 0; based on the target physical stripe number, determine the second bitmap number to be processed, and set the bitmap status code corresponding to the second bitmap number to be processed in the memory bitmap to 1.
[0033] In a second aspect of the present invention, a data write consistency guarantee device based on multi-level collaborative methods is provided, comprising:
[0034] The persistent stripe mapping table setting module is configured to set up a metadata space in RAID, and the metadata space has a persistent stripe mapping table.
[0035] The virtual device creation module is configured to create virtual devices when the system powers on and starts up. Once the virtual device is created, it has a memory mapping table and a memory bitmap.
[0036] The persistent stripe mapping table update module is configured such that when a write request is initiated by the host, the virtual device determines the logical stripe based on the write request, determines the target physical stripe based on the logical stripe, the memory mapping table, and the memory bitmap, writes the data to the RAID based on the determined target physical stripe, updates the memory mapping table and the memory bitmap after the data writing is completed, and stores the memory mapping table in the metadata space to complete the update of the persistent mapping table.
[0037] In a third aspect of the present invention, a computer program product is provided, including a computer program that, when executed by a processor, implements the method provided according to the first aspect.
[0038] In a fourth aspect of the present invention, an electronic device is provided, including one or more processors and a memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the method provided in the first aspect.
[0039] In summary, the present invention has the following beneficial effects:
[0040] The data write consistency guarantee method and apparatus of this invention can solve the RAID write hole problem by setting up metadata space, persistent stripe mapping table, virtual device, memory mapping table, and memory bitmap. It does not rely on special hardware such as specific BBU or supercapacitor, and does not add new log disks. It achieves large data blocks being written only once, avoiding the waste of bandwidth resources caused by multiple data writes. It can not only achieve RAID power failure data protection and ensure data consistency, but also simplify hardware design, save costs by not adding new hard drives, and improve bandwidth performance, meeting the strict environmental adaptability and bandwidth performance requirements of large data writes in the field of ruggedized storage.
[0041] Further or more detailed beneficial effects will be described in conjunction with specific embodiments in the detailed implementation. Attached Figure Description
[0042] Figure 1 A flowchart of a data write consistency guarantee method based on multi-level collaboration according to an embodiment of the present invention is shown;
[0043] Figure 2 A block diagram of a data write consistency guarantee device based on multi-level collaboration according to an embodiment of the present invention is shown;
[0044] Figure 3 A block diagram of an electronic device according to an embodiment of the present invention is shown. Detailed Implementation
[0045] Embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the invention.
[0046] In the description of embodiments of the present invention, the term "comprising" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0047] Figure 1 A flowchart of a multi-level collaborative data write consistency guarantee method 100 according to an embodiment of the present invention is shown. The method 100 includes:
[0048] Step 102. Set up the metadata space in the RAID, and set up a persistent stripe mapping table in the metadata space.
[0049] In this embodiment, setting up the metadata space in RAID specifically includes:
[0050] Create a 5- or 6-level RAID based on multiple physical disks;
[0051] Use the physical stripes at the beginning of the RAID as the metadata space.
[0052] Taking a 5-level RAID as an example, assuming the RAID includes 4 disks and 1 parity disk, each disk has a capacity of 100GB, and each stripe is 64KB in size, then there are a total of 6,553,600 physical stripes in the RAID. Each physical stripe is located on 4 disks. In this embodiment, the first 1000 physical stripes in the RAID can be used as the metadata space, which does not participate in user data storage. This embodiment will assign numbers to the other physical stripes. For example, the 1001st physical stripe can be set as physical stripe number 0, and the 1288th physical stripe can be set as physical stripe number 287. The number indicates which physical stripe it corresponds to. If the first 500 physical stripes in the RAID are used as the metadata space, then the 501st physical stripe can be set as physical stripe number 0. In addition, not all physical stripes remaining besides the metadata space need to be numbered; only the 6,000,000th stripe needs to be numbered.
[0053] The metadata space contains a persistent stripe mapping table. This table stores a one-to-one correspondence between logical stripe numbers and physical stripe numbers; for example, logical stripe number 8 corresponds to physical stripe number 11, and logical stripe number 18 corresponds to physical stripe number 5. The persistent stripe mapping table is not lost after a system power outage and restart, and its state remains the same after power-on as it was just before the power outage.
[0054] Step 104. When the system powers on and starts up, a virtual device is created. After the virtual device is created, it has a memory mapping table and a memory bitmap.
[0055] In this embodiment, creating a virtual device specifically includes:
[0056] The kernel loads the virtual device driver module. When the system powers on, the system triggers the kernel to load the virtual device driver module and call its initialization function via a command (such as insmodvdev.ko).
[0057] During the initialization of the virtual device driver module, a persistent stripe mapping table is loaded from the RAID metadata space into memory to form a memory mapping table, and a memory bitmap is reconstructed based on the memory mapping table.
[0058] The virtual block device is registered with the kernel block device subsystem to complete its creation. Specifically, this involves: allocating and initializing a gendisk structure to represent the virtual device; setting the device's operation function set and defining how to handle various I / O requests; configuring the request queue and specifying the I / O scheduling strategy; setting the device capacity and updating it via set_capacity; and calling the add_disk() function to register the virtual device with the kernel block device subsystem, making it visible to the outside world.
[0059] In this embodiment, reconstructing the memory bitmap based on the memory mapping table specifically includes:
[0060] The RAID is traversed to determine the range of physical stripe numbers. Based on the physical stripe numbers, the bitmap number for each bit in the memory bitmap is determined, and the bitmap status code for each bit in the memory bitmap is set to 0. Each bit in the memory bitmap includes a bitmap number and a bitmap status code. The number of bitmap numbers corresponds to the number of physical stripe numbers, and there is a one-to-one correspondence between the bitmap numbers and the physical stripe numbers. For example, bit... Figure 1 Bit 1 corresponds to physical stripe 1, and bit 88 corresponds to physical stripe 88. At this time, the bitmap status code of each bit in the memory bitmap is set to 0.
[0061] Traverse the memory-mapped table. When a physical stripe number exists in the memory-mapped table, find the bitmap number corresponding to the physical stripe number in the bitmap, and set the bitmap status code of the bit containing the bitmap number to 1. When the bitmap status code of a bit is 0, it indicates that the physical stripe corresponding to the bitmap number of that bit is free; when the bitmap status code of a bit is 1, it indicates that the physical stripe corresponding to the bitmap number of that bit is used.
[0062] Step 106. When the host initiates a write request, the virtual device determines the logical stripe based on the write request and determines the target physical stripe based on the logical stripe, the memory mapping table, and the memory bitmap. Based on the determined target physical stripe, the data is written to the RAID. After the data writing is completed, the memory mapping table and the memory bitmap are updated, and the memory mapping table is stored in the metadata space to complete the update of the persistent mapping table.
[0063] In this embodiment, the virtual device determines logical stripes based on write requests and determines target physical stripes based on logical stripes, memory mapping tables, and memory bitmaps, specifically including:
[0064] The virtual device parses the write request to obtain the logical block address range, and determines the target logical stripe number based on the logical block address range.
[0065] A write request includes the starting logical block address (LBA) and the size of the data to be written.
[0066] Assuming the starting logical block address is LBA100, the data size is 20,000 bytes, and each logical block is 4096 bytes, then a total of 5 logical blocks are used for writing data. Therefore, the logical block address range is LBA100 to LBA104. Each logical stripe consists of 16 logical blocks. 100 divided by 16 equals 6.25, so the starting logical stripe is the 7th logical stripe, and its number is 6 (the 1st logical stripe is numbered 0). 104 divided by 16 equals 6.5, so the ending logical stripe is also the 7th logical stripe, and its number is also 6. Therefore, the final target logical stripe number is 6.
[0067] Assuming the starting logical block address is LBA120, the data size is 40,000 bytes, and each logical block is 4096 bytes, then a total of 10 logical blocks are used for writing data. Therefore, the logical block address range is LBA120 to LBA129. Each logical stripe consists of 16 logical blocks. 120 divided by 16 equals 7.5, so the starting logical stripe is the 8th logical stripe, and its number is 7. 129 divided by 16 equals 8.0625, so the ending logical stripe is the 9th logical stripe, and its number is 8. Therefore, the target logical stripe numbers are 7 and 8.
[0068] The memory mapping table is queried based on the target logical stripe number, and the currently used physical stripe number for each target logical stripe number is recorded.
[0069] Suppose the memory-mapped table contains the following:
[0070] L0-W8; L1-W6; L2-W1; L3-W7; L4-W19; L5-W18; L6--; L7-W3; L8--; L9--; L10-W29;…
[0071] Assuming the target logical stripe numbers are 7 and 8, by querying the memory mapping table, we can see that the current used physical stripe number of target logical stripe number 7 (i.e., L7) is "3" (i.e., W3), and the current used physical stripe number of target logical stripe number 8 (i.e., L8) is "-". Therefore, we record "L7-W3; L8--".
[0072] Based on the memory bitmap, allocate free target physical stripe numbers to the target logical stripe numbers.
[0073] Assume the memory bitmap contains the following:
[0074] P0-0;P1-1;P2-0;P3-1;P4-0;P5-0;P6-1;P7-1;P8-1;P9-0;…
[0075] Specifically, allocating free target physical stripe numbers to target logical stripe numbers based on memory bitmaps includes:
[0076] Determine the number N of the target logic stripe numbers. In this embodiment, it is assumed that the number N of the target logic stripe numbers is 2.
[0077] Traverse the bitmaps in ascending order of bitmap number, obtaining N bitmap numbers with a status code of 0. Based on these N bitmap numbers, determine N idle target physical stripe numbers. First, obtain the two bitmap numbers with a status code of 0: P0 and P2. Then, based on these two bitmap numbers "0 and 2", determine the two idle target physical stripe numbers: W0 and W2.
[0078] Once the target physical stripe numbers "0 and 2" are determined, data can be written to physical stripe 0 and physical stripe 2 of the RAID. The specific method for writing data will directly adopt existing technology.
[0079] In this embodiment, updating the memory mapping table and memory bitmap after the data writing is completed specifically includes:
[0080] Based on the records, replace the used physical stripe number corresponding to the target logical stripe number in the memory-mapped table with the target physical stripe number. Replace "L7-W3" with "L7-W0" and "L8--" with "L8-W2".
[0081] At this point, the contents of the memory-mapped table become:
[0082] L0-W8; L1-W6; L2-W1; L3-W7; L4-W19; L5-W18; L6--; L7-W0; L8-W2; L9--; L10-W29;…
[0083] Based on the physical stripe number already used, determine the first bitmap number to be processed, and set the bitmap status code corresponding to the first bitmap number to be processed in the memory bitmap to 0; based on the target physical stripe number, determine the second bitmap number to be processed, and set the bitmap status code corresponding to the second bitmap number to be processed in the memory bitmap to 1.
[0084] In this embodiment, the physical stripe number is W3, so the first bitmap to be processed is P3, and the status code of the bitmap corresponding to P3 in the memory bitmap is set to 0. The target physical stripe numbers are W0 and W2, so the second bitmap to be processed are P0 and P2, and the status codes of the bitmaps corresponding to P0 and P2 in the memory bitmap are set to 1.
[0085] At this point, the contents of the memory bitmap become:
[0086] P0-1;P1-1;P2-1;P3-0;P4-0;P5-0;P6-1;P7-1;P8-1;P9-0;…
[0087] Once the memory-mapped table and memory bitmap are updated, the virtual device stores the memory-mapped table in the metadata space to complete the persistent update. Then, the virtual device sends a write request completion message to the host, allowing the host to know that the write request has been completed.
[0088] In this embodiment, step 102 only needs to be executed once, step 104 is executed every time the system is powered on (it may be the first power-on or it may be a power-on restart after a power outage), and step 106 is executed every time the host initiates a write request.
[0089] Suppose that during a certain execution of step 106, the target logical stripe numbers are already known to be L7 and L8, and the target physical stripe numbers are already known to be W0 and W2. Data is already being written to physical stripe 0 and physical stripe 2 of the RAID. A power failure occurs before the data writing is complete.
[0090] After the system powers on and restarts, step 104 will be executed again. At this point, the persistent stripe mapping table remains the same, and consequently, the memory mapping table and memory bitmap obtained are also the same. The memory mapping table still shows "L7-W3; L8--", and the memory bitmap still shows "P3-1". All data is accurate. Therefore, even if a disk fails, the data on the failed disk can be reconstructed from the other disks. Regarding the previous write request, since the host did not receive completion information, it knows that the write request was incomplete and can simply re-initiate the write request.
[0091] Figure 2 A block diagram of a multi-level collaborative data write consistency guarantee device 200 according to an embodiment of the present invention is shown. The device 200 includes:
[0092] The persistent stripe mapping table setting module 202 is configured to set up a metadata space in the RAID, and the metadata space has a persistent stripe mapping table set up.
[0093] The virtual device creation module 204 is configured to create a virtual device when the system powers on and starts up. After the virtual device is created, it has a memory mapping table and a memory bitmap.
[0094] The persistent stripe mapping table update module 206 is configured such that when the host initiates a write request, the virtual device determines the logical stripe based on the write request, determines the target physical stripe based on the logical stripe, the memory mapping table and the memory bitmap, writes the data to the RAID based on the determined target physical stripe, updates the memory mapping table and the memory bitmap after the data writing is completed, and stores the memory mapping table in the metadata space to complete the update of the persistent mapping table.
[0095] Figure 3 A block diagram of an electronic device 300 according to some embodiments of the present invention is shown. The device 300 includes a processor 301, which performs various appropriate actions and processes based on computer program instructions loaded into random access memory (RAM) 303 according to computer program instructions stored in read-only memory (ROM) 302. Various programs and data required for the operation of the device 300 may also be stored in RAM 303. The processor 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0096] The various processes and procedures described above, such as method 100, can be executed by processor 301. For example, in some embodiments, method 100 may be implemented as a software program tangibly contained in a machine-readable medium. In some embodiments, part or all of the software program may be loaded and / or installed on device 300 via ROM 302. When the software program is loaded into RAM 303 and executed by processor 301, one or more actions of method 100 described above may be performed.
[0097] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload programmable logic devices (CPLDs), and so on.
[0098] The program code used to implement the methods of the present invention can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code can be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0099] This invention can be a method, apparatus, system, and / or program product. The program product may include a machine-readable storage medium on which machine-readable program instructions for performing various aspects of the invention are loaded. The machine-readable program instructions described herein can be downloaded from the machine-readable storage medium to various computing / processing devices, or downloaded via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the machine-readable program instructions from the network and forwards them for storage in the machine-readable storage medium of the respective computing / processing device.
[0100] Machine program instructions used to perform the operations of this invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The machine-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing state information from the machine-readable program instructions. This electronic circuitry can execute the machine-readable program instructions to implement various aspects of the invention.
[0101] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. Furthermore, although the operations are depicted in a specific order, this should be understood as requiring that such operations be performed in the specific order shown or in sequential order, or requiring that all illustrated operations be performed to achieve the desired result. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the invention. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0102] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A data write consistency guarantee method based on multi-level collaboration, characterized in that, include: In RAID, a metadata space is set up, which contains a persistent stripe mapping table; When the system powers on and starts up, a virtual device is created. Once the virtual device is created, it has a memory mapping table and a memory bitmap. When the host initiates a write request, the virtual device determines the logical stripe based on the write request and determines the target physical stripe based on the logical stripe, the memory mapping table, and the memory bitmap. Based on the determined target physical stripe, the data is written to the RAID. After the data writing is completed, the memory mapping table and the memory bitmap are updated, and the memory mapping table is stored in the metadata space to complete the update of the persistent mapping table. Specifically, the creation of a virtual device includes: the kernel loading the virtual device driver module; during the initialization of the virtual device driver module, loading a persistent stripe mapping table from the RAID metadata space into memory to form a memory mapping table, and reconstructing a memory bitmap based on the memory mapping table; and registering the virtual block device with the kernel block device subsystem to complete the creation of the virtual device.
2. The method according to claim 1, characterized in that, Setting up the metadata space in RAID specifically includes: Create a 5- or 6-level RAID based on multiple physical disks; The metadata space is defined as several physical stripes at the beginning of the RAID array.
3. The method according to claim 1, characterized in that, Reconstructing the memory bitmap based on the memory mapping table specifically includes: Traverse the RAID to determine the number range of physical stripes, determine the bitmap number of each bit in the memory bitmap based on the physical stripe number, and set the bitmap status code of each bit in the memory bitmap to 0. Traverse the memory mapping table. When a physical stripe number exists in the memory mapping table, find the bitmap number corresponding to the physical stripe number in the bitmap and set the bitmap status code of the bit where the bitmap number is located to 1.
4. The method according to claim 1, characterized in that, The virtual device determines logical stripes based on write requests and then determines the target physical stripes based on the logical stripes, memory mapping tables, and memory bitmaps. Specifically, this includes: The virtual device parses the write request to obtain the logical block address range, and determines the target logical stripe number based on the logical block address range; The memory mapping table is queried based on the target logical stripe number, and the currently used physical stripe number is recorded for each target logical stripe number; Based on the memory bitmap, allocate free target physical stripe numbers to the target logical stripe numbers.
5. The method according to claim 4, characterized in that, The allocation of free target physical stripe numbers based on memory bitmaps specifically includes: Determine the number N of the target logic stripe numbers, where N is a positive integer greater than or equal to 1; Traverse the bitmaps in ascending order of bitmap number, obtain the N bitmap numbers with bitmap status code 0, and determine the N idle target physical stripe numbers based on the N bitmap numbers.
6. The method according to claim 5, characterized in that, After the data writing is complete, updating the memory mapping table and memory bitmap specifically includes: Based on the records, replace the used physical stripe number corresponding to the target logical stripe number in the memory mapping table with the target physical stripe number; Based on the physical stripe number already used, the first bitmap number to be processed is determined, and the bitmap status code corresponding to the first bitmap number to be processed in the memory bitmap is set to 0; based on the target physical stripe number, the second bitmap number to be processed is determined, and the bitmap status code corresponding to the second bitmap number to be processed in the memory bitmap is set to 1.
7. A data write consistency guarantee device based on multi-level collaboration, characterized in that, include: A persistent stripe mapping table setting module is configured to set up a metadata space in RAID, wherein the metadata space is configured with a persistent stripe mapping table; The virtual device creation module is configured to create a virtual device when the system powers on and starts up. After the virtual device is created, it has a memory mapping table and a memory bitmap. The persistent stripe mapping table update module is configured such that when the host initiates a write request, the virtual device determines the logical stripe based on the write request, determines the target physical stripe based on the logical stripe, the memory mapping table and the memory bitmap, writes the data to the RAID based on the determined target physical stripe, updates the memory mapping table and the memory bitmap after the data writing is completed, and stores the memory mapping table in the metadata space to complete the update of the persistent mapping table. Specifically, the creation of a virtual device includes: the kernel loading the virtual device driver module; during the initialization of the virtual device driver module, loading a persistent stripe mapping table from the RAID metadata space into memory to form a memory mapping table, and reconstructing a memory bitmap based on the memory mapping table; and registering the virtual block device with the kernel block device subsystem to complete the creation of the virtual device.
8. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1-6.
9. An electronic device, characterized in that, It includes one or more processors and memory associated with the one or more processors, the memory being used to store program instructions that, when read and executed by the one or more processors, perform the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
Method for implementing mixed hierarchical array, the hierarchical array and storage system
CN101458613A
Data writing method and device
CN110471615A