Storage pool import method and apparatus

By locking the storage pool in the NAS cluster, the problem of data corruption caused by resource contention between primary and backup nodes is solved, and the storage pool is uniquely imported, ensuring data security.

CN116266099BActive Publication Date: 2025-11-21MACROSAN TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111547306.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-16
Publication Date
2025-11-21
Estimated Expiration
2041-12-16

AI Technical Summary

Technical Problem

In a NAS cluster, if the primary and backup nodes lose their heartbeats, they may simultaneously compete for storage pool resources, potentially leading to catastrophic data corruption.

Method used

By sending a locking command to the storage device, identifying the address range and data where the lock is located, the storage device writes the locked data only when the data is consistent, thus achieving unique locking of the storage pool and preventing multiple nodes from importing simultaneously.

Benefits of technology

This effectively avoids importing data from multiple nodes into the storage pool simultaneously, reducing the risk of data corruption and ensuring data integrity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116266099B_ABST
    Figure CN116266099B_ABST
Patent Text Reader

Abstract

The application provides a storage pool import method and device, which are applied to a node included in a NAS cluster. The method comprises the following steps: sending a locking command for a target LUN in a storage pool to a storage device, wherein the locking command comprises an address segment used for identifying a locking position, first data used for indicating that no locking is performed, and second data used for locking, so that the storage device writes the second data into the address segment when it is determined that the data in the address segment is consistent with the first data; and if a success message returned by the storage device based on the locking command is received, the storage pool is imported. It can be seen that in the application, the node realizes the locking of the storage pool through one instruction, the locking process cannot be interrupted by other nodes, and once a node succeeds in locking, other nodes cannot lock and import the storage pool, so that the simultaneous import of the storage pool by multiple nodes can be effectively avoided, and the risk of data damage of the storage pool is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of storage technology, and in particular to a storage pool import method and apparatus. Background Technology

[0002] Network Attached Storage (NAS), as the name suggests, is a device connected to a network that provides data storage capabilities. It is also known as network storage and is a type of dedicated data storage server. It is data-centric, completely separating storage devices from servers, centrally managing data, thereby freeing up bandwidth, improving performance, and reducing total cost of ownership. Its cost is far lower than using server storage, while its efficiency is far higher.

[0003] Zettabyte File System (ZFS) is a new type of 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 snapshot replication, and is often used as the underlying file system of NAS.

[0004] A NAS cluster consists of several NAS nodes (hereinafter referred to as nodes). To meet users' high availability requirements for storage, NAS clusters typically operate in a master-slave mode. That is, one master node corresponds to one or more slave nodes. When the master node fails, the slave node takes over the services of the master node and continues to operate.

[0005] Primary and backup nodes typically use a heartbeat mechanism to detect each other's presence. If a heartbeat detection fails, the other node is considered to have failed, and both nodes may simultaneously compete for resources. For example, if a heartbeat is lost due to network issues, both nodes may simultaneously import data into the same storage pool. Since both nodes are operating on the same storage pool, this could lead to data corruption and catastrophic consequences. Summary of the Invention

[0006] In view of this, this application proposes a storage pool import method and apparatus to minimize the catastrophic consequences of data corruption.

[0007] To achieve the above-mentioned objectives, this application provides the following technical solution:

[0008] Firstly, this application provides a storage pool import method, applied to nodes included in a NAS cluster, the method comprising:

[0009] Send a locking command to the storage device for a target logical unit number (LUN) in the storage pool. The locking command includes an address segment for identifying the location of the lock, first data for indicating that it is not locked, and second data for locking, so that when the storage device determines that there is already data in the address segment that is consistent with the first data, it writes the second data into the address segment.

[0010] If a successful locking message is received from the storage device based on the locking command, the storage pool is imported.

[0011] Optionally, the method further includes:

[0012] If a locking failure message is received from the storage device based on the locking command, the import into the storage pool will not be performed.

[0013] Optionally, after importing into the storage pool, the method further includes:

[0014] Send an unlock command to the storage device for the target LUN. The unlock command includes the address segment, the second data indicating that it is locked, and the first data for unlocking, so that when the storage device determines that there is already data in the address segment that matches the second data, it writes the first data into the address segment.

[0015] Optionally, the node and the storage device are connected via a Small Computer System Interface (SCSI) interface, and both the locking command and the unlocking command are based on the SCSI compare and write command.

[0016] Optionally, the address range is located in the Boot Header region included in the ZFS label of the target LUN.

[0017] Secondly, this application provides a storage pool import device, applied to nodes included in a NAS cluster, the device comprising:

[0018] The sending unit is configured to send a locking command to the storage device for a target LUN in the storage pool. The locking command includes an address segment for identifying the location of the lock, first data for indicating that it is not locked, and second data for locking, so that when the storage device determines that there is already data in the address segment that is consistent with the first data, it writes the second data into the address segment.

[0019] An import unit is configured to import the data into the storage pool if a successful locking message is received from the storage device based on the locking command.

[0020] Optionally, the import unit is further configured to not import the storage pool if it receives a locking failure message returned by the storage device based on the locking command.

[0021] Optionally, the sending unit is further configured to send an unlock command for the target LUN to the storage device. The unlock command includes the address segment, the second data indicating that it is locked, and the first data for unlocking, so that when the storage device determines that there is already data in the address segment that matches the second data, it writes the first data into the address segment.

[0022] Optionally, the node is connected to the storage device via a SCSI interface, and both the locking command and the unlocking command are constructed based on the SCSI compare and write command.

[0023] Optionally, the address range is located in the Boot Header region included in the ZFS label of the target LUN.

[0024] As can be seen from the above description, in this embodiment of the application, a node locks the storage pool through a single instruction. This locking process cannot be interrupted by other nodes, and once a node successfully locks the storage pool, other nodes will be unable to lock it or import the data into the storage pool. Therefore, this effectively avoids multiple nodes importing data into the storage pool at the same time, reducing the risk of data corruption in the storage pool. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1 This is a flowchart illustrating a storage pool import method according to an embodiment of this application;

[0027] Figure 2 This is a schematic diagram of a ZFS tag for a LUN as shown in an embodiment of this application;

[0028] Figure 3 This is a schematic diagram of a storage pool import device shown in an embodiment of this application. Detailed Implementation

[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application.

[0030] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the embodiments of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0031] It should be understood that although the terms first, second, third, etc., may be used to describe various information in the embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of the embodiments of this application, negotiated information may also be referred to as second information, and similarly, second information may also be referred to as negotiated information. Depending on the context, the word "if" as used herein can be interpreted as "when," "when," or "in response to a determination."

[0032] To make the objectives, technical solutions, and advantages of this application clearer, the application will be described in detail below with reference to the accompanying drawings and specific embodiments:

[0033] See Figure 1 The above is a flowchart illustrating a storage pool import method according to an embodiment of this application. This process is applied to nodes included in a NAS cluster.

[0034] like Figure 1 As shown, the process may include the following steps:

[0035] Step 101: Send a lock command to the storage device for the target LUN in the storage pool.

[0036] In this embodiment of the application, before a node imports into the storage pool, it needs to lock the storage pool to obtain unique access rights to the storage pool, that is, only one node is allowed to use the storage pool at any given time.

[0037] The storage pool consists of at least one LUN. In this embodiment, locking the storage pool is achieved by issuing a locking command to a target LUN within the storage pool. The target LUN can be any LUN within a pre-defined storage pool.

[0038] As an example, the target LUN can be the first LUN in the storage pool to improve the efficiency of the storage device traversing the target LUN, thereby improving the efficiency of subsequent locking and importing.

[0039] The locking command includes an address field that identifies the location of the lock in the target LUN, first data indicating that it is unlocked, and second data for locking. It is understood that the terms "first data" and "second data" are used merely for ease of distinction and are not intended to limit the scope of the lock.

[0040] After receiving a lock command, the storage device obtains the lock location address range, first data, and second data included in the lock command. Based on the lock location address range, it reads the data from the target LUN at that address range and compares the read data with the first data. If the read data matches the first data, it means that the storage pool to which the target LUN belongs has not yet been locked. The storage device can then write the second data into the lock location address range to lock the storage pool.

[0041] Conversely, if the read data is inconsistent with the first data, it means that the current storage pool is locked. In this case, the storage device will not write the second data to the target LUN (the address range where the lock is located), that is, it will not perform the locking operation.

[0042] Step 102: If a successful locking message is received from the storage device based on the locking command, execute the import into the storage pool.

[0043] It should be noted that if the storage device locks the storage pool based on the locking command, that is, writes the second data to the address range where the lock is located, it will return a locking success message to this node.

[0044] Based on the successful locking message, the node determines that it has obtained the right to use the storage pool, and then executes the import of the storage pool.

[0045] Conversely, if the storage device fails to lock the storage pool based on the locking command, that is, it does not write the second data to the address range where the lock is located, it returns a locking failure message to this node.

[0046] If a node determines that it has not obtained permission to use the storage pool based on the locking failure message, it will not execute the import of the storage pool.

[0047] This concludes the process. Figure 1 The process is shown below.

[0048] pass Figure 1As can be seen from the process shown, in this embodiment of the application, a node locks the storage pool through a single instruction. This locking process cannot be interrupted by other nodes, and once a node successfully locks, other nodes will be unable to lock or import data into the storage pool. Therefore, this effectively avoids multiple nodes importing data into the storage pool at the same time, reducing the risk of data corruption in the storage pool.

[0049] As an example, after performing step 102, if a node wants to relinquish its access to the storage pool, it can send an unlock command to the storage device for the target LUN. The unlock command includes an address field for identifying the location of the lock, second data for indicating that it is locked, and first data for unlocking.

[0050] After receiving the unlock command, the storage device obtains the lock location address segment, second data, and first data included in the unlock command. Based on the lock location address segment, it reads the data from the target LUN in that address segment and compares the read data with the second data. If the read data matches the second data, it indicates that the storage pool to which the target LUN belongs is currently locked. The storage device can then write the first data into the lock location address segment to unlock the storage pool.

[0051] This concludes the description of this embodiment. This embodiment demonstrates how to unlock the storage pool. After unlocking, other nodes can execute... Figure 1 The process shown involves locking the storage pool and importing data.

[0052] As an example, when a node is connected to a storage device via a SCSI interface, the node can construct lock and unlock commands based on the compare and write command.

[0053] It should be noted that the compare and write command is an atomic operation that instructs the receiving device to continuously perform data reading, comparison, and writing operations without being interrupted by other commands.

[0054] Specifically, the compare and write command includes the address range to be operated on, the expected data, and the data to be written. When the data read from the address range to be operated on matches the expected data, the data to be written is written to the address range to be operated on.

[0055] Therefore, when constructing a locking command based on the compare and write command, the address segment to be operated on in the compare and write command can be the address segment corresponding to the location of the lock, the expected data can be the first data used to indicate that the lock is not locked, such as all 0s; the data to be written can be the second data used to lock, such as all 1s.

[0056] Conversely, when constructing an unlock command based on the compare and write command, the compare and write command includes the address segment to be operated on as the address segment corresponding to the location of the lock, the expected comparison data as the second data used to indicate that it is locked, for example, all 1s; and the data to be written as the first data used to unlock, for example, all 0s.

[0057] This concludes the description of this embodiment. This embodiment demonstrates how to construct encryption / unlock commands using the SCSI-based compare and write command.

[0058] As one example, the address range used to identify the location of the lock can be located in the Boot Header area included in the ZFS label of the target LUN. This Boot Header area is a reserved 8K area.

[0059] In the ZFS file system, each LUN corresponds to two ZFS tags before and after it. See also Figure 2 This is a schematic diagram of the ZFS tag of a LUN as shown in an embodiment of this application. In this diagram, the LUN corresponds to 4 ZFS tags, namely L0 to L3, where L0 and L1 are located at the beginning of the LUN, and L2 and L3 are located at the end of the LUN.

[0060] As an example, in this application, the address range used to identify the location of the lock can be located in the Boot Header area included in the first ZFS tag (L0) of the target LUN, so that the storage device can quickly traverse to the address range and perform the corresponding encryption and unlocking operations.

[0061] Furthermore, as an example, the address segment used to identify the location of the lock can be one sector (512 bytes), and correspondingly, the lengths of the first and second data are both one sector. Since a sector is the smallest unit of storage device operation, locking and unlocking by operating on a single sector in the Boot Header area can effectively reduce resource consumption while improving locking and unlocking efficiency.

[0062] This concludes the description of this embodiment. It can be seen that this embodiment utilizes the reserved area for encryption and decryption of ZFS tags, effectively avoiding any impact on actual business data.

[0063] The methods provided in the embodiments of this application have been described above. The apparatus provided in the embodiments of this application is described below:

[0064] See Figure 3 This application illustrates a storage pool import device, applied to nodes within a NAS cluster. The device includes a sending unit 301 and an importing unit 302, wherein:

[0065] The sending unit 301 is configured to send a locking command to the storage device for a target LUN in the storage pool. The locking command includes an address segment for identifying the location of the lock, first data for indicating that it is not locked, and second data for locking, so that when the storage device determines that there is already data in the address segment that is consistent with the first data, it writes the second data into the address segment.

[0066] Import unit 302 is used to import the storage pool if it receives a successful locking message returned by the storage device based on the locking command.

[0067] As an example, the import unit 302 is further configured to not import the storage pool if it receives a locking failure message returned by the storage device based on the locking command.

[0068] As an example, the sending unit 301 is further configured to send an unlock command for the target LUN to the storage device. The unlock command includes the address segment, the second data indicating that it is locked, and the first data for unlocking, so that when the storage device determines that there is already data in the address segment that matches the second data, it writes the first data into the address segment.

[0069] As an example, the node is connected to the storage device via a SCSI interface, and both the locking and unlocking commands are built based on the SCSI compare and write commands.

[0070] As an example, the address range is located in the Boot Header region included in the ZFS label of the target LUN.

[0071] This concludes the process. Figure 3 Description of the device shown.

[0072] As can be seen from the above description, in this embodiment of the application, a node locks the storage pool through a single instruction. This locking process cannot be interrupted by other nodes, and once a node successfully locks, other nodes will be unable to lock or import data into the storage pool. Therefore, this effectively avoids multiple nodes importing data into the storage pool simultaneously, reducing the risk of data corruption in the storage pool.

[0073] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the embodiments of the present application should be included within 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: sending, to a storage device, a lock command for a target logical unit number (LUN) in a storage pool, the lock command being an atomic operation command, the lock command comprising an address segment for identifying a location of a lock, first data for indicating no lock, and second data for lock, so that the storage device writes the second data to the address segment when determining that data in the address segment is consistent with the first data; if a lock success message returned by the storage device based on the lock command is received, performing importing of the storage pool.

2. The method of claim 1, wherein, The method further comprises: if a lock failure message returned by the storage device based on the lock command is received, not performing importing of the storage pool.

3. The method of claim 1, wherein, After the importing of the storage pool is performed, the method further comprises: sending, to the storage device, an unlock command for the target LUN, the unlock command comprising the address segment, the second data for indicating that the lock is added, and the first data for unlock, so that the storage device writes the first data to the address segment when determining that data in the address segment is consistent with the second data.

4. The method of claim 1, wherein, The node and the storage device are connected through a small computer system interface (SCSI) interface, and the lock command is constructed based on a compare and write command of SCSI.

5. The method of claim 1, wherein, The address segment is located in a Boot Header region included in a Zettabyte File System (ZFS) tag of the target LUN.

6. 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 send, to a storage device, a lock command for a target logical unit number (LUN) in a storage pool, the lock command being an atomic operation command, the lock command comprising an address segment for identifying a location of a lock, first data for indicating no lock, and second data for lock, so that the storage device writes the second data to the address segment when determining that data in the address segment is consistent with the first data; an importing unit configured to, if a lock success message returned by the storage device based on the lock command is received, perform importing of the storage pool.

7. The device of claim 6, wherein: the importing unit is further configured to, if a lock failure message returned by the storage device based on the lock command is received, not perform importing of the storage pool.

8. The device of claim 6, wherein: the sending unit is further configured to send, to the storage device, an unlock command for the target LUN, the unlock command comprising the address segment, the second data for indicating that the lock is added, and the first data for unlock, so that the storage device writes the first data to the address segment when determining that data in the address segment is consistent with the second data.

9. The apparatus of claim 6, wherein, The node and the storage device are connected through a small computer system interface (SCSI) interface, and the lock command is constructed based on a compare and write command of SCSI.

10. The apparatus of claim 6, wherein, The address segment is located in a Boot Header region included in a Zettabyte File System (ZFS) label of the target LUN.

Citation Information

Patent Citations

  • Data protecting method based on high availability storage system

    CN104504348A

  • Lock resource control authority migration method and device

    CN108446337A

  • Implementation method and equipment for SCSI lock in distributed network storage system

    CN110489388A