Storage pool import method and apparatus
By monitoring the storage pool's locking status and heartbeat data consistency in the NAS cluster, the problem of data corruption caused by simultaneous imports from primary and backup nodes was resolved, thus achieving business continuity and data security.
Patent Information
- Application Number
- CN202111544981.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2041-12-16
AI Technical Summary
In a NAS cluster, if the primary and backup nodes lose their heartbeats and are simultaneously imported into the storage pool, it may lead to catastrophic data corruption. Existing locking mechanisms cannot effectively prevent business interruption when nodes malfunction.
By sending a heartbeat read command when a storage pool is detected to be locked, the consistency of heartbeat data is periodically monitored. If the data is consistent, it is imported into the storage pool; otherwise, it is forcibly imported and the heartbeat data is updated to avoid simultaneous import from multiple nodes.
It enables normal takeover of business operations in the event of node failure, avoiding business interruption, preventing data corruption, and ensuring data integrity.
Smart Images

Figure CN116266098B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage, in particular to a storage pool import method and device. BACKGROUND
[0002] Network Attached Storage (NAS) is connected to the network in the literal sense, and has data storage function, so it is also called network storage. It is a dedicated data storage server. It is data-centered, completely separates storage devices from servers, centrally manages data, and thus releases bandwidth, improves performance, and reduces total cost of ownership. Its cost is much lower than that of using server storage, and its efficiency is much higher than that of the latter.
[0003] Zettabyte File System (ZFS) is a new file system with 128-bit addressing capability. It has many advantages such as self-optimization, automatic data integrity verification, easy management of storage pool / volume system, and fast snapshot replication, and is often used as the underlying file system of NAS.
[0004] A NAS cluster is composed of several NAS nodes (hereinafter referred to as nodes). In order to meet the high availability requirements of users for storage, the NAS cluster usually runs in a master-slave mode. That is, one master node corresponds to one or more slave nodes, and when the master node fails, the slave node takes over the business of the master node and continues to work.
[0005] The master and slave nodes usually use a heartbeat mechanism to perceive the existence of each other. Once the heartbeat detection is abnormal, it is considered that the other party has failed, and the master and slave nodes may simultaneously compete for resources. For example, due to network reasons, the heartbeat is lost, and the master and slave nodes simultaneously import the storage pool. Since the master and slave nodes operate on the same storage pool, the data in the storage pool may be damaged, resulting in a catastrophic consequence of data corruption.
[0006] In order to avoid simultaneous import of multiple nodes, a locking mechanism can be used. That is, after one node locks the storage pool, other nodes cannot import the storage pool. However, in actual use, it is found that if the node that locks the storage pool abnormally during the import process, such as power failure shutdown, other nodes cannot normally take over the business of the abnormal node, resulting in business interruption. SUMMARY
[0007] Therefore, the present application provides a storage pool import method and device to ensure that the node normally takes over the business, and at the same time, avoids the catastrophic consequence of data corruption.
[0008] To achieve the above application purposes, the present application provides the following technical solutions:
[0009] In a first aspect, the present application provides a storage pool import method, applied to a node included in a NAS cluster, and the method comprises:
[0010] When detecting that a target logical unit number (LUN) in a storage pool has been locked, sending a heartbeat read command to a storage device at a preset time interval, the heartbeat read command comprising a pre-designated address segment for storing heartbeat data, so that the storage device reads the heartbeat data from the address segment and returns the heartbeat data to the node, wherein the address segment is updated by another node which is importing the storage pool.
[0011] If the preset read number is reached and each heartbeat data read is consistent, the storage pool is imported.
[0012] Optionally, the method further comprises:
[0013] If inconsistent heartbeat data is read before the preset read number is reached, the storage pool is not imported.
[0014] Optionally, the method further comprises:
[0015] During the process of importing the storage pool by the node, the following operations are performed at a preset time interval:
[0016] New heartbeat data is calculated according to a preset heartbeat algorithm;
[0017] A heartbeat update command is sent to the storage device, the heartbeat update command comprising the address segment and the new heartbeat data, so that the storage device writes the new heartbeat data into the address segment.
[0018] Optionally, the address segment is located in a Boot Header region included in a ZFS label of the target LUN.
[0019] Optionally, after the node imports the storage pool, the method further comprises:
[0020] An unlock command for the target LUN is sent to the storage device, so that the storage device performs an unlock operation on the target LUN.
[0021] In a second aspect, the present application provides a storage pool import device, applied to a node included in a NAS cluster, and the device comprises:
[0022] The sending unit is configured to send a heartbeat read command to the storage device at a preset time interval when it is detected that the target LUN in the storage pool is locked, the heartbeat read command including a pre-designated address segment for storing heartbeat data, so that the storage device reads the heartbeat data from the address segment and returns the heartbeat data to the node, wherein the address segment is updated by another node that is importing the storage pool.
[0023] The importing unit is configured to import the storage pool if the read times reach the preset read times and each of the read heartbeat data is consistent.
[0024] Optionally, the importing unit is further configured to not import the storage pool if inconsistent heartbeat data is read before the read times reach the preset read times.
[0025] Optionally, the apparatus further includes:
[0026] The computing unit is configured to calculate new heartbeat data according to a preset heartbeat algorithm at a preset time interval during the process in which the node imports the storage pool.
[0027] The sending unit is further configured to send a heartbeat update command to the storage device, the heartbeat update command including the address segment and the new heartbeat data, so that the storage device writes the new heartbeat data into the address segment.
[0028] Optionally, the address segment is located in a Boot Header region included in a ZFS label of the target LUN.
[0029] Optionally, the sending unit is further configured to send an unlock command for the target LUN to the storage device after the storage pool is imported, so that the storage device performs an unlock operation on the target LUN.
[0030] As can be seen from the above description, in the embodiments of the present application, the running state of the importing node is perceived by monitoring the importing node, and the node forcibly imports when it is determined that the importing node is abnormal, so as to ensure that the node normally takes over the business of the abnormal node and avoid business interruption. Meanwhile, since the original importing node is determined to stop importing before the node imports, i.e., no other node imports the same storage pool at the same time when the node imports, the disastrous consequences of data damage caused by multiple nodes importing at the same time can be effectively avoided. BRIEF DESCRIPTION OF DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced. Obviously, the drawings in the following description only constitute some embodiments of the present application. For those skilled in the art, other drawings can also be obtained from these drawings without creative effort.
[0032] Figure 1 is a storage pool import method flowchart shown in an embodiment of the present application;
[0033] Figure 2 is a heartbeat data update flowchart shown in an embodiment of the present application;
[0034] Figure 3 is a ZFS tag diagram of a LUN shown in an embodiment of the present application;
[0035] Figure 4 is a storage pool import device diagram shown in an embodiment of the present application. DETAILED DESCRIPTION
[0036] The exemplary embodiments will be described in detail herein with reference to the drawings. Whenever the descriptions turn to the drawings, the same numbers on the drawings represent the same or similar elements throughout every figure. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application.
[0037] The terminology used in the present application is merely for the purpose of describing particular embodiments and is not intended to limit the present application. As used in the present application, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "and / or", as used herein, refer to and encompass any or all possible combinations of one or more of the associated listed items.
[0038] It should be understood that, although the terms first, second, third, etc. can be used herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one piece of information from another piece of information of the same type. For example, without departing from the scope of the present application, negotiation information can also be referred to as second information, and similarly, second information can also be referred to as negotiation information. Depending on the context, the word "if" as used herein can be interpreted as "when" or "upon" or "in response to determining".
[0039] In order to make the purposes, technical solutions and advantages of the present application more clear, the present application will be described in detail below with reference to the drawings and specific embodiments:
[0040] Reference is made to Figure 1A storage pool import method flowchart is shown in the embodiments of the present application, and the flowchart is applied to nodes included in a NAS cluster.
[0041] As shown in Figure 1 The flowchart can include the following steps:
[0042] In step 101, when it is detected that a target LUN in a storage pool is locked, a heartbeat read command is sent to a storage device at a preset time interval.
[0043] Before importing a storage pool, a node needs to lock the storage pool to obtain the import permission of the storage pool.
[0044] The storage pool is composed of at least one LUN. The node sends a lock command to a target LUN in the storage pool to achieve the purpose of locking the storage pool. The target LUN can be any LUN in the storage pool designated in advance.
[0045] As an example, the target LUN can be the first LUN in the storage pool to improve the efficiency of the storage device traversing to the target LUN, thereby improving the locking and importing efficiency.
[0046] The lock command can be an atomic operation including read, compare, and write, such as a compare and write command based on the Small Computer System Interface (SCSI). The compare and write command usually includes an address segment to be operated, expected data, and new data to be written. When the data read from the address segment to be operated by the storage device is consistent with the expected data, the new data is written to the address segment to be operated; if not, the write operation is not performed.
[0047] In the embodiments of the present application, the address segment to be operated included in the lock command can be a pre-designated lock address segment, the expected data can be data indicating no locking (such as all 0), and the data to be written can be data indicating locking (such as all 1).
[0048] When the data read from the lock address segment by the storage device is consistent with the data indicating no locking (such as all 0), it indicates that the target LUN is not locked, and the data indicating locking (such as all 1) can be written to the lock address segment to achieve the locking of the target LUN, and a lock success message is returned to the node.
[0049] Conversely, when the data read from the lock address segment by the storage device is inconsistent with the data indicating no locking, it indicates that the target LUN is locked, and the storage device does not perform the write operation of the locking data to the lock address segment, and a lock failure message is returned to the node.
[0050] If the node receives the lock success message, the import storage pool can be executed. Conversely, if the node receives the lock failure message, it can be determined that the target LUN is currently locked by other nodes, and the import storage pool is executed.
[0051] At this time, the node can send a heartbeat read command to the storage device at a preset time interval (for example, 2 seconds), and the heartbeat read command includes a pre-designated address segment for storing heartbeat data.
[0052] Here, it should be noted that the heartbeat data in the address segment is updated by the node that is performing the import storage pool in a timely manner. That is, the heartbeat data in the address segment changes dynamically.
[0053] The storage device returns the heartbeat data read each time to the node.
[0054] In step 102, if the preset number of read times is reached and each heartbeat data read is consistent, the import storage pool is executed.
[0055] In the embodiment of the application, the node compares the periodically read heartbeat data.
[0056] If it is determined that there is inconsistent heartbeat data before the preset number of read times (for example, 3 times) is reached, that is, the heartbeat data is changing, it indicates that the node that is currently performing the import is running normally, and the node does not perform the import storage pool operation to avoid the catastrophic consequences of data damage caused by multiple nodes simultaneously importing.
[0057] Conversely, if the actual number of read times reaches the preset number of read times, and each heartbeat data read is consistent, it indicates that the node that is performing the import has not updated the heartbeat data for a long time, and the import node is running abnormally, and the node can forcibly import the storage pool to take over the business of the abnormal node and avoid business interruption.
[0058] At this point, the import storage pool is completed. Figure 1 The flowchart is shown.
[0059] As can be seen from the flowchart shown in Figure 1 In the embodiment of the application, by monitoring the node that is importing, the running state of the import node is perceived, and when it is determined that the import node is abnormal, the node performs forced import, thereby ensuring that the node normally takes over the business of the abnormal node and avoids business interruption. In addition, since the node has determined that the original import node stops importing (abnormal) before the node imports, that is, no other node simultaneously imports the same storage pool when the node imports, the catastrophic consequences of data damage caused by multiple nodes simultaneously importing can be effectively avoided.
[0060] As an embodiment, during the execution of the import storage pool in step 102, the node can also perform Figure 2The heartbeat data update process is shown below.
[0061] like Figure 2 As shown, the process may include the following steps:
[0062] Step 201: Calculate heartbeat data according to a preset heartbeat algorithm at preset time intervals.
[0063] That is, during the import process, this node needs to update the heartbeat data periodically.
[0064] Here, the preset heartbeat algorithm needs to ensure that the heartbeat data obtained in each calculation is different, that is, dynamically changing. For example, the preset heartbeat algorithm can be an incrementing algorithm, a decrementing algorithm, etc. This application embodiment does not limit the specific heartbeat algorithm.
[0065] Step 202: Send a heartbeat update command to the storage device. The heartbeat update command includes a pre-specified address range for storing heartbeat data and the calculated heartbeat data.
[0066] After obtaining new heartbeat data through step 201, the node sends a heartbeat update command to the storage device.
[0067] Based on the heartbeat update command, the storage device writes the heartbeat data calculated by the node into the address segment where the heartbeat data is stored, thereby updating the heartbeat data.
[0068] In this way, other nodes can determine whether their own node is malfunctioning based on changes in the central jump data of that address range, and thus determine whether a forced import is necessary.
[0069] This concludes the process. Figure 2 The process is shown below. Through Figure 2 The process shown implements the update of heartbeat data.
[0070] As an example, after importing the storage pool through step 102, this node can send an unlock command to the storage device for the target LUN. The unlock command includes the address range where the lock is located in the target LUN, the data indicating that it is locked, and the data for unlocking.
[0071] After receiving the unlock command, the storage device reads data from the address segment where the lock is located in the target LUN. It compares the read data with the data indicating that the lock is engaged (e.g., all 1s) in the unlock command. If they match, it writes the unlock data (e.g., all 0s) in the unlock command into the address segment where the lock is located, thus achieving the unlocking purpose.
[0072] This concludes the description of this implementation, enabling the storage pool to be unlocked.
[0073] As an example, the address segment for storing heartbeat data can be located in the Boot Header region included by the ZFS label of the target LUN. The Boot Header region is a reserved 8K size region.
[0074] Referring to Figure 3 , a ZFS label diagram of a LUN is shown in the embodiment of the present application. In the diagram, the LUN has four ZFS labels, L0-L3. L0 and L1 are located at the front end of the LUN, and L2 and L3 are located at the end of the LUN.
[0075] As an example, the address segment for storing heartbeat data can be located in the Boot Header region included by the first ZFS label (L0) of the target LUN, so that the storage device can quickly traverse to the address segment to perform heartbeat data reading and updating operations.
[0076] As an example, the address segment for storing heartbeat data and the address segment where the lock is located can both be located in the Boot Header region included by the first ZFS label of the target LUN, as shown in Figure 3 .
[0077] As an example, the address segment where the lock is located and the address segment for storing heartbeat data each occupy one sector size (512B) of the Boot Header region. Accordingly, the lengths of the lock data, the unlock data, and the heartbeat data are each one sector size.
[0078] Since a sector is the smallest unit of storage device operation, by operating the sectors in the Boot Header region, resource occupation can be effectively reduced, and processing efficiency can be improved.
[0079] Thus far, the description of the embodiment is completed. As can be seen, the embodiment uses the reserved region of the ZFS label to lock and unlock and record heartbeat data, which can effectively avoid affecting actual business data.
[0080] The above describes the method provided by the embodiment of the present application, and the following describes the device provided by the embodiment of the present application:
[0081] Referring to Figure 4 , a storage pool import device is shown in the embodiment of the present application, applied to a node included by a NAS cluster. The device includes a sending unit 401 and an import unit 402, wherein:
[0082] The sending unit 401 is configured to send a heartbeat reading command to the storage device at a preset time interval when it is detected that the target LUN in the storage pool is locked, the heartbeat reading command comprising a pre-designated address segment for storing heartbeat data, so that the storage device reads the heartbeat data from the address segment and returns the heartbeat data to the node, wherein the address segment is updated by another node which is importing the storage pool.
[0083] The importing unit 402 is configured to import the storage pool if the preset reading number is reached and each of the read heartbeat data is consistent.
[0084] As an embodiment, the importing unit 402 is further configured to not import the storage pool if inconsistent heartbeat data is read before the preset reading number is reached.
[0085] As an embodiment, the apparatus further comprises:
[0086] The computing unit is configured to calculate new heartbeat data according to a preset heartbeat algorithm at a preset time interval during the process that the node imports the storage pool.
[0087] The sending unit 401 is further configured to send a heartbeat updating command to the storage device, the heartbeat updating command comprising the address segment and the new heartbeat data, so that the storage device writes the new heartbeat data into the address segment.
[0088] As an embodiment, the address segment is located in a Boot Header region included in a ZFS label of the target LUN.
[0089] As an embodiment, the sending unit 401 is further configured to send an unlocking command for the target LUN to the storage device after the storage pool is imported, so that the storage device performs an unlocking operation on the target LUN.
[0090] Thus, the description of the apparatus is completed. Figure 4
[0091] As can be seen from the above description, in the embodiments of the present application, the running state of the importing node is monitored, and the node forcibly imports when it is determined that the importing node is abnormal, so that the node normally takes over the business of the abnormal node and avoids business interruption. Meanwhile, since the original importing node is determined to stop importing (abnormal) before the node imports, i.e., no other node imports the same storage pool at the same time when the node imports, the disastrous consequences of data damage caused by multiple nodes importing at the same time can be effectively avoided.
[0092] The above merely describes preferred embodiments of the present application, and is not used to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present application shall be included in the scope of protection of the present application.
Claims
1. A storage pool import method characterized by, The method applied to a node included in a network attached storage (NAS) cluster comprises: When detecting that a target logical unit number (LUN) in a storage pool has been locked, sending a heartbeat read command to a storage device at a preset time interval, the heartbeat read command comprising a pre-designated address segment for storing heartbeat data, so that the storage device reads the heartbeat data from the address segment and returns the heartbeat data to the node, wherein the heartbeat data in the address segment is triggered to be updated by another node that is importing the storage pool, and the address segment is located in a Boot Header region included in a Zettabyte File System (ZFS) label of the target LUN; If a preset read number is reached and each heartbeat data read is consistent, importing the storage pool.
2. The method of claim 1, wherein, The method further comprises: If inconsistent heartbeat data is read before the preset read number is reached, not importing the storage pool.
3. The method of claim 1, wherein, The method further comprises: During the process of importing the storage pool by the node, performing the following operations at a preset time interval: Calculating new heartbeat data according to a preset heartbeat algorithm; Sending a heartbeat update command to the storage device, the heartbeat update command comprising the address segment and the new heartbeat data, so that the storage device writes the new heartbeat data into the address segment.
4. The method of claim 1, wherein, After the node imports the storage pool, the method further comprises: Sending an unlock command for the target LUN to the storage device, so that the storage device performs an unlock operation on the target LUN.
5. A storage pool import apparatus characterized by comprising: The device applied to a node included in a network attached storage (NAS) cluster comprises: A sending unit configured to, when detecting that a target logical unit number (LUN) in a storage pool has been locked, send a heartbeat read command to a storage device at a preset time interval, the heartbeat read command comprising a pre-designated address segment for storing heartbeat data, so that the storage device reads the heartbeat data from the address segment and returns the heartbeat data to the node, wherein the heartbeat data in the address segment is triggered to be updated by another node that is importing the storage pool, and the address segment is located in a Boot Header region included in a Zettabyte File System (ZFS) label of the target LUN; An importing unit configured to, if a preset read number is reached and each heartbeat data read is consistent, import the storage pool.
6. The device of claim 5, wherein: The importing unit is further configured to, if inconsistent heartbeat data is read before the preset read number is reached, not import the storage pool.
7. The apparatus of claim 5, wherein, The device further comprises: A calculating unit configured to, during the process of importing the storage pool by the node, calculate new heartbeat data according to a preset heartbeat algorithm at a preset time interval; The sending unit is further configured to send a heartbeat update command to the storage device, the heartbeat update command comprising the address segment and the new heartbeat data, so that the storage device writes the new heartbeat data into the address segment.
8. The device of claim 5, wherein: The sending unit is further configured to send, after the storage pool is imported, an unlock command for the target LUN to the storage device, so that the storage device performs an unlock operation on the target LUN.
Citation Information
Patent Citations
Method for performing node switching in case of node fault and related equipment
CN112199240A
Managing concurrent file system accesses by multiple servers using locks
US20110179082A1