Host and volume mapping method, storage system, equipment and storage medium
By supporting multiple host and volume mapping relationships in the storage system, the problem of low host resource utilization in the prior art is solved, flexible mapping between host and volume is realized, and resource utilization and system ease of use are improved.
Patent Information
- Application Number
- CN202411028046.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2024-11-26
AI Technical Summary
There are strict restrictions on the mapping between host and volume in existing storage systems, which makes the host unable to flexibly map storage space, and the resource utilization rate is low, which increases the cost of deploying storage services, and may cause the host resources to be insufficient to cover all storage space, resulting in poor user experience. good.
A method of mapping between host and volume is proposed. By querying the linked list, it judges and establishes the mapping relationship between host and volume, supports multiple mapping relationships such as host and single volume, host group and single volume, host group and volume group, and improves resource utilization rate , meet the diversity needs of users.
It realizes flexible mapping of host resources, improves resource utilization, reduces the efficiency of the system when establishing new mapping relationships, reduces resource consumption, and improves the ease of system use.
Smart Images

Figure CN119025441A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of memory technology, and in particular to a method, storage system, device and storage medium for mapping a host to a volume. Background Art
[0002] A storage system usually includes multiple storage devices. The hosts connected to the storage devices that provide services to customers can provide services individually in a stand-alone form, or multiple hosts can form a host group to provide services to the outside in a clustered manner. For example, a group of servers can be used as a whole to provide resources to customers through software, and a single server is a node in the cluster. In actual applications, the storage space of the storage device needs to be mapped to each host. The method is to create multiple LUNs (Logical Unit Numbers) based on the storage space of all storage devices in the system, and then map the LUNs to the host or host group.
[0003] In order to avoid conflicts when mapping hosts and volumes, existing storage systems have imposed strict restrictions on the mapping of hosts and volumes, allowing a single host to be mapped to a single volume, or a host group to be mapped to a volume group to provide storage services. In addition, restrictions are also imposed on the host clustering method. For example, hosts in a host group can no longer map a single volume, and a host cannot join multiple host groups. This results in the host being unable to flexibly map storage space, and host resources cannot be fully utilized, increasing the cost of deploying storage services. In addition, for customers with limited host resources, there is a situation where the host resources are not enough to cover all storage space, resulting in a poor user experience. Summary of the invention
[0004] In view of this, the present application aims to propose a method, storage system, device and storage medium for mapping hosts and volumes, so as to realize flexible mapping between hosts and volumes, improve the utilization of host resources and meet the diverse needs of users.
[0005] To achieve the above purpose, the technical solution of this application is as follows:
[0006] A first aspect of an embodiment of the present application provides a method for mapping a host to a volume, the method being applied to a storage system, the storage system comprising at least two hosts and at least two volumes, including:
[0007] Upon receiving a first request sent by a user host, obtaining a target host, a target volume, and a target mapping relationship in the first request; the target mapping relationship is any one of the following: host-single-volume mapping, host-volume group mapping, host group-single-volume mapping, or host group-volume group mapping;
[0008] Querying the first linked list or the second linked list to determine whether a mapping relationship between the target host and the target volume can be established; the first linked list is used to store indexes of mapping data of the host to different volumes; the second linked list is used to store indexes of mapping data of the volume to different hosts;
[0009] If it is determined that a mapping relationship can be established, the target mapping relationship is established and corresponding mapping data is generated, and the mapping data is stored in a mapping array; the mapping data includes: a volume number, a host number, a host group number, and a mapping type; the mapping type is private or shared; the mapping array is used to store mapping relationships between all hosts and volumes in the system;
[0010] The index of the mapping data in the mapping array is stored in the first linked list and the second linked list respectively.
[0011] Optionally, when the mapping relationship is a host-to-single-volume mapping, determining whether a mapping relationship between the target host and the target volume can be established includes:
[0012] According to the host number of the target host, searching the first linked list to obtain the volume mapping chain of the target host;
[0013] Starting from the index of the first mapping data in the volume mapping chain, traverse the volume mapping chain to find out whether there is a volume number of the target volume;
[0014] If the volume number of the target volume exists, it is determined that the mapping relationship between the target host and the target volume cannot be established; and a first message is generated to indicate that the mapping relationship cannot be established;
[0015] If the volume number of the target volume does not exist, determining that a mapping relationship between the target host and the target volume can be established;
[0016] When generating mapping data, set the host group number to invalid and set the mapping type to private.
[0017] Optionally, when the mapping relationship is a host-volume group mapping, determining whether a mapping relationship between the target host and the target volume can be established includes:
[0018] Traversing the target volume group, taking each volume as a target volume, and searching the second linked table to obtain a host mapping chain of the target volume according to the volume number of the target volume;
[0019] Starting from the index of the first mapping data in the host mapping chain, traversing the host mapping chain to find whether there is a host number of the target host; if the host number of the target host exists, determining that a mapping relationship between the target host and the target volume group cannot be established; generating a first message to indicate that the mapping relationship cannot be established;
[0020] If the host number of the target host does not exist in the host mapping chain corresponding to each volume in the target volume group, it is determined that a mapping relationship between the target host and the target volume group can be established;
[0021] When generating mapping data, the host group number is set to be invalid, and the mapping type is set to be private.
[0022] Optionally, when the mapping relationship is a mapping between a host group and a single volume, determining whether a mapping relationship between the target host and the target volume can be established includes:
[0023] Traversing the target host group, taking each host in the target host group as a target host, and searching the first linked list to obtain a volume mapping chain of the target host according to the host number of the target host;
[0024] Starting from the index of the first mapping data in the volume mapping chain, traversing the volume mapping chain to find whether there is a volume number of the target volume; if there is a volume number of the target volume, determining that a mapping relationship between the target host group and the target volume cannot be established; generating a first message to indicate that the mapping relationship cannot be established;
[0025] If the volume number of the target volume does not exist in the volume mapping chain corresponding to each host in the target host group, it is determined that a mapping relationship between the target host group and the target volume can be established;
[0026] When generating mapping data, the host number is set to the number of the target host group, and the mapping type is set to private.
[0027] Optionally, when the mapping relationship is a mapping between a host group and a volume group, determining whether a mapping relationship between the target host and the target volume can be established includes:
[0028] Traversing the target volume group, taking each volume as a target volume, and searching the second linked table to obtain a host mapping chain of the target volume according to the volume number of the target volume;
[0029] Starting from the index of the first mapping data in the host mapping chain, traversing the host mapping chain to find whether there is a host number of any host in the target host group; if there is a host number of any host in the target host group, determining that a mapping relationship between the target host group and the target volume group cannot be established; generating a first message to indicate that a mapping relationship cannot be established;
[0030] If the host number of any host in the target host group does not exist in the host mapping chain corresponding to each volume in the target volume group, it is determined that a mapping relationship between the target host group and the target volume group can be established;
[0031] When generating mapping data, the host group number is set to the number of the target host group, and the mapping type is set to sharing.
[0032] Optionally, the host and volume mapping method further includes:
[0033] receiving a second request sent by a user host, where the second request is used to add a new host to the target host group;
[0034] Search the first linked list to obtain the volume numbers of all volume groups and single volumes that are currently mapped to the new host, and generate a first volume number group;
[0035] Obtain the volume numbers of all volume groups and single volumes that are currently mapped to each host in the target host group, calculate the intersection, and generate a second volume number group;
[0036] Comparing the first volume number group with the second volume number group to determine whether there are identical volume numbers;
[0037] If the same volume number exists, it is determined that the new host cannot be added;
[0038] If the same volume number does not exist, it is determined that the new host can be added; the new host is added to the target host group, and a mapping relationship between the new host and each volume in the second volume number group is established to generate corresponding mapping data.
[0039] Optionally, the host and volume mapping method further includes:
[0040] receiving a third request sent by a user host, wherein the third request is used to add a new volume to the target volume group;
[0041] Search the second linked list to obtain all host groups and host numbers that are currently mapped to the new volume, and generate a first host number group;
[0042] Obtain all host numbers that are currently mapped to each volume in the target volume group, calculate the intersection, and generate a second host number group;
[0043] Compare the first host number group with the second host number group to determine whether there are identical host numbers;
[0044] If the same host number exists, it is determined that the new volume cannot be added;
[0045] If the same host number does not exist, it is determined that the new volume can be added; the new volume is added to the target volume group, and a mapping relationship between the new volume and each host in the second host number group is established to generate corresponding mapping data.
[0046] Optionally, storing the index of the mapping data in the mapping array in the first linked list and the second linked list respectively includes:
[0047] Obtain the index of the mapping data in the mapping array as the target index;
[0048] According to the host number in the mapping data, searching the first linked list for a corresponding volume mapping chain;
[0049] Obtaining an empty position in the volume mapping chain as a first position to be stored;
[0050] Obtaining an index stored in an adjacent position of the first position to be stored, and generating first index information based on the target index and the index stored in the adjacent position of the first position to be stored;
[0051] storing the first index information in the first to-be-stored position, and updating the first index information stored in an adjacent position of the first to-be-stored position;
[0052] According to the volume number in the mapping data, searching the corresponding host mapping chain in the second linked list;
[0053] Obtaining an empty position in the host mapping chain as a second position to be stored;
[0054] Obtaining an index stored in an adjacent position of the second position to be stored, and generating second index information based on the target index and the index stored in the adjacent position of the second position to be stored;
[0055] The second index information is stored in the second to-be-stored position, and the second index information stored in the adjacent position of the second to-be-stored position is updated.
[0056] According to a second aspect of an embodiment of the present application, a storage system is provided, for implementing the method for host-volume mapping provided in the first aspect of the embodiment of the present application, the system comprising:
[0057] At least two hosts are configured to provide services to users in the form of a single host or a host group; wherein any host can join at least one host group;
[0058] At least two volumes are configured to provide storage services to each host in the form of a single volume or a volume group; wherein any volume can be added to at least one volume group; wherein at most one mapping relationship can be established between any volume and any host;
[0059] The judgment module is configured to, upon receiving a first request sent by a user host, obtain a target host, a target volume and a target mapping relationship in the first request; the target mapping relationship is any one of the following: host-single-volume mapping, host-volume group mapping, host group-single-volume mapping, or host group-volume group mapping; query the first linked list or the second linked list to determine whether a mapping relationship between the target host and the target volume can be established; the first linked list is used to store an index of mapping data of the host to different volumes; the second linked list is used to store an index of mapping data of the volume to different hosts;
[0060] A mapping module is configured to establish the target mapping relationship and generate corresponding mapping data when it is determined that the mapping relationship can be established; the mapping data includes: volume number, host number, host group number and mapping type; the mapping type is private or shared; the mapping array is used to store the mapping relationship between all hosts and volumes in the system;
[0061] The recording module is configured to store the mapping data in a mapping array; and store the index of the mapping data in the mapping array in the first linked list and the second linked list respectively.
[0062] According to a third aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the method for host-volume mapping as described in the first aspect of the embodiment of the present application are implemented.
[0063] According to a fourth aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the method for host-volume mapping as described in the first aspect of the embodiment of the present application are implemented.
[0064] Using the host and volume mapping method provided in the present application, after obtaining the target host and target volume specified by the user for which a mapping relationship needs to be established, the first linked list and the second linked list are searched to determine whether a mapping relationship between the target host and the volume can be established at present. If it is determined that a mapping relationship can be established, a mapping relationship between the target host and the target volume is established, and corresponding mapping data is generated. Four types of host and volume mapping relationships are provided in the present application, specifically including: host and single volume mapping, host and volume group mapping, host group and single volume mapping, or host group and volume group mapping. Through the method provided in the present application, flexible mapping of hosts and volumes can be achieved, the utilization rate of host resources can be improved, and the diverse needs of different users can be met.
[0065] In addition, the present application provides two different types of data structures for storing and querying mapping data. The mapping array is used to store the mapping data of all hosts and volumes in the system. The first linked list and the second linked list are used to store the index of the mapping data. Since the amount of data in the first linked list and the second linked list is much smaller than the amount of data in the mapping array, it is convenient to quickly search in the linked list to determine whether the current mapping relationship can be established before establishing a new mapping relationship, thereby avoiding mapping conflicts. Compared with the traditional method of traversing the mapping relationships of all hosts and volumes to determine whether the current mapping relationship can be established, the present application can improve the efficiency of establishing mapping relationships and enhance the ease of use of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0067] Figure 1 is a flow chart of a method for mapping a host to a volume proposed in an embodiment of the present application;
[0068] Figure 2 It is a schematic diagram of the host and volume mapping in the current storage system;
[0069] Figure 3 is a schematic diagram of mapping data indexes stored in the first linked list and the second linked list in one embodiment of the present application;
[0070] Figure 4 is a schematic diagram of the mapping between the host and the volume group in one embodiment of the present application;
[0071] Figure 5 is a schematic diagram of the mapping between a host group and a single volume in one embodiment of the present application;
[0072] Figure 6 is a schematic diagram of the mapping between host groups and volume groups in one embodiment of the present application;
[0073] Figure 7 is a schematic diagram of a storage system proposed in an embodiment of the present application;
[0074] Figure 8 It is a schematic diagram of an electronic device proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0075] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0076] It should be understood that the references to "one embodiment" or "an embodiment" throughout the specification mean that the specific features, structures, or characteristics associated with the embodiment are included in at least one embodiment of the present application. Therefore, the references to "in one embodiment" or "in an embodiment" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0077] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the following processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0078] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers 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 the present application. Instead, they are merely examples of devices and methods consistent with some aspects as detailed in the present application.
[0079] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application may be combined with each other.
[0080] Existing storage systems can only support volume-host, volume group-host group mapping, and to prevent conflicts between host and volume mapping, storage systems often restrict hosts in a host group from mapping a single volume (a volume not added to a volume group). A host cannot exist in multiple host groups, and a host cannot be mapped to a volume group. Figure 2 , Figure 2 This is a schematic diagram of the host and volume mapping in the current storage system. Figure 2(a) is a schematic diagram of the mapping between hosts and single volumes, where hosts host0-host2 are mapped to single volumes LUN0-LUN2 respectively; (b) is a schematic diagram of the mapping between host groups and volume groups, where each host in host groups host3-host5 is mapped to each volume in volume groups LUN3-LUN5. In the current storage system, each host (LUN3-LUN5) in a host group can no longer map a single volume (LUN0-LUN2), the hosts in each host group can no longer join other host groups, and a single host (such as host0) cannot map a LUN group. In addition, in existing storage systems, before establishing a mapping relationship between hosts and volumes, it is necessary to traverse all hosts and volumes to find out whether there is a mapping conflict. Establishing a new mapping relationship in a storage system with a large number of hosts and volumes is inefficient and consumes a lot of system resources.
[0081] In order to improve the utilization of host resources and realize flexible mapping between hosts and volumes, on the basis of ensuring that the same host and the same volume are not mapped repeatedly, this embodiment proposes four flexible mapping relationships, namely: host and single volume mapping, host and volume group mapping, host group and single volume mapping, or host group and volume group mapping. In addition, this embodiment supports one host to join multiple host groups, and the hosts in the host group can map other single volumes again. For a single volume, it supports joining multiple volume groups, and the volumes in the volume group can be mapped to other hosts again.
[0082] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments.
[0083] Figure 1 1 is a flowchart of a method for mapping a host to a volume according to an embodiment of the present application. The method is applied to a storage system, wherein the storage system includes at least two hosts and at least two volumes, such as Figure 1 As shown, the method includes:
[0084] S1: upon receiving a first request sent by a user host, obtaining a target host, a target volume and a target mapping relationship in the first request; the target mapping relationship is any one of the following: host to single volume mapping, host to volume group mapping, host group to single volume mapping, or host group to volume group mapping;
[0085] S2: querying the first linked list or the second linked list to determine whether a mapping relationship between the target host and the target volume can be established; the first linked list is used to store indexes of mapping data of the host to different volumes; the second linked list is used to store indexes of mapping data of the volume to different hosts;
[0086] S3: if it is determined that a mapping relationship can be established, establish the target mapping relationship and generate corresponding mapping data, and store the mapping data in a mapping array; the mapping data includes: volume number, host number, host group number and mapping type; the mapping type is private or shared; the mapping array is used to store the mapping relationships between all hosts and volumes in the system;
[0087] S4: Store the index of the mapping data in the mapping array in the first linked list and the second linked list respectively.
[0088] In this embodiment, two types of data structures are first constructed to store and manage the mapping relationship between hosts and volumes in the system. Specifically, a mapping array and two linked lists are constructed. The mapping array is used to store the complete mapping data between all hosts and volumes in the system. The mapping data is represented by an entry, and an entry includes: volume number (lun_id), host number (host_id), host group number (host_cluster_id) and mapping type (private / shared). Among them, except for the type of mapping between the host group and the volume group, which is shared, other forms of mapping types are private. In this embodiment, the size of the mapping array is set according to the maximum number of mapping data that can be generated between the hosts and volumes in the system to avoid setting the mapping array too large and wasting storage resources.
[0089] A first linked list (hlist) and a second linked list (vlist) are established to store the index of the mapping data in the mapping array, so as to quickly find whether a mapping relationship already exists before establishing a new mapping relationship between a host and a volume, and avoid mapping conflicts caused by repeated mapping. The first linked list is used to store the index of the mapping data of each host to different volumes, wherein each host has a corresponding volume mapping chain, and the index of the mapping data of all volumes mapped by the host is stored in the volume mapping chain. The second linked list is used to store the index of the mapping data of each volume to different hosts, wherein each volume has a corresponding host mapping chain, and the index of the mapping data of all hosts mapped by the volume is stored in the volume mapping chain.
[0090] When a mapping relationship needs to be established, the user sends a first request to instruct the establishment of a mapping relationship. The target host, target volume, and specific mapping relationship for which a mapping relationship needs to be established are specified in the first request. According to the first request, a search is performed in the first linked list or the second linked list to determine whether a mapping relationship exists between the target host and the target volume. If a mapping relationship already exists, it is determined that the mapping relationship between the target host and the target volume cannot be established. If it is determined that a mapping relationship can be established, a mapping between the two is established according to the target mapping relationship specified in the first request, and corresponding mapping data is generated according to the host number of the target host, the volume number of the target volume, the host group number, and the mapping type (private / shared), and stored in the mapping array.
[0091] In this embodiment, when storing the mapping data in the mapping array, an empty position is obtained in the mapping array, the mapping data is stored in the empty position, and the index of the mapping data is obtained. The index of the mapping data is stored in the first linked list and the second linked list respectively. When the first request sent by the user host is subsequently received, if the user specifies that the target host and the target volume are to be mapped, it can be found by searching in the first linked list and the second linked list that the mapping relationship already exists and cannot be mapped repeatedly. When searching in the first linked list or the second linked list, the corresponding volume mapping chain or host mapping chain can be found by the host number or volume number, and then the volume mapping chain and the host mapping chain can be queried by traversing.
[0092] In this embodiment, by establishing a mapping array to store the mapping relationships of all hosts and volumes, unified and standardized management of the mapping relationships of all hosts and volumes in the system is achieved, ensuring that the mapping relationships currently existing in the system can be queried. By storing the index of the mapping data in the mapping array separately in the first linked list and the second linked list, a quick query of the mapping relationship of the host or volume is achieved. Since the amount of data in the first linked list and the second linked list is much smaller than the amount of data in the mapping array, the system resources consumed by the query are reduced, and the efficiency of establishing a new mapping relationship is improved. Compared with the existing storage system that traverses all mapping relationships in the system before establishing a new mapping relationship to avoid mapping conflicts, this solution greatly improves the efficiency of establishing a new mapping relationship, saves system resources, and improves the ease of use of the system on the basis of meeting the needs of different users and realizing flexible mapping of hosts and volumes.
[0093] As an implementation manner of the present application, storing the index of the mapping data in the mapping array in the first linked list and the second linked list respectively includes:
[0094] Obtain the index of the mapping data in the mapping array as the target index;
[0095] According to the host number in the mapping data, searching the first linked list for a corresponding volume mapping chain;
[0096] Obtaining an empty position in the volume mapping chain as a first position to be stored;
[0097] Obtaining an index stored in an adjacent position of the first position to be stored, and generating first index information based on the target index and the index stored in the adjacent position of the first position to be stored;
[0098] storing the first index information in the first to-be-stored position, and updating the first index information stored in an adjacent position of the first to-be-stored position;
[0099] According to the volume number in the mapping data, searching the corresponding host mapping chain in the second linked list;
[0100] Obtaining an empty position in the host mapping chain as a second position to be stored;
[0101] Obtaining an index stored in an adjacent position of the second position to be stored, and generating second index information based on the target index and the index stored in the adjacent position of the second position to be stored;
[0102] The second index information is stored in the second to-be-stored position, and the second index information stored in the adjacent position of the second to-be-stored position is updated.
[0103] In one embodiment, after the new mapping data is stored in the mapping array, the index of the mapping data is obtained as the target index. Assuming that the storage system supports the maximum number of hosts MAX_HOSTS, the first linked list hlist needs to have MAX_HOSTS volume mapping chains, that is, hlist[MAX_HOSTS]. After the new mapping data is stored in the mapping array, the index (address) is stored in the volume mapping chain hlist[host_id], and the index of the adjacent position is also recorded. Assuming that the storage system supports the maximum number of volumes MAX_LUNS, the vlist needs to have MAX_LUNS host mapping chains, that is, vlist[MAX_LUNS]. After the new mapping data is stored in the mapping array, the index (address) is stored in the volume mapping chain vlist[lun_id], and the index of the adjacent position is also recorded.
[0104] According to the host number of the currently mapped host, the volume mapping chain corresponding to the host is found in the first linked list (hlist), and an empty position is found in the chain as the first position to be stored. The target index is filled in the first position to be stored. Figure 3 FIG. 1 is a schematic diagram of the mapping data index stored in the first linked list and the second linked list in an embodiment of the present application. Figure 3As shown, each position in the volume mapping chain records the index of the mapping data of the current position (entry_addr_index) and the indexes of the two adjacent positions of the position (host_list_prev, host_list_next). When filling in the index of the current mapping data, the current target index and the indexes of the two adjacent positions of the empty position are used together to generate the first index information, which is filled in the first position to be stored. If the adjacent position does not record index information, it is set to invalid. After filling in the current first index information, it is also necessary to update the first index information recorded in the adjacent position, and update the host_list_prev or host_list_next in the first index information recorded in the adjacent position from invalid to the current target index, thereby associating the index recorded in the first storage position with the index recorded in the adjacent position.
[0105] According to the volume number of the currently mapped volume, find the host mapping chain corresponding to the volume in the second linked list (vlist), and find an empty position in the chain as the second storage position. Fill the target index in the second storage position. Figure 3 As shown, each position in the host mapping chain records the index of the mapping data of the current position (entry_addr_index) and the indexes of the two adjacent positions of the position (lun_list_prev, lun_list_next). When filling in the index of the current mapping data, the current target index and the indexes of the two adjacent positions of the empty position are used together to generate the second index information, and the second position to be stored is filled in. If the adjacent position does not record the index information, it is set to invalid. After filling in the current second index information, it is also necessary to update the second index information recorded in the adjacent position, and update the lun_list_prev or lun_list_next in the second index information recorded in the adjacent position from invalid to the current target index, so as to associate the index recorded in the second storage position with the index recorded in the adjacent position.
[0106] In this embodiment, by filling in the index corresponding to the current mapping data and the index of the mapping data at the adjacent position in each position of the first linked list and the second linked list, the mapping data index at each position is associated with the mapping data index at the adjacent position, thereby improving the security of the index data in the linked list and reducing the risk of index data loss.
[0107] As an implementation manner of the present application, when the mapping relationship is a host-single-volume mapping, determining whether a mapping relationship between the target host and the target volume can be established includes:
[0108] According to the host number of the target host, searching the first linked list to obtain the volume mapping chain of the target host;
[0109] Starting from the index of the first mapping data in the volume mapping chain, traverse the volume mapping chain to find out whether there is a volume number of the target volume;
[0110] If the volume number of the target volume exists, it is determined that the mapping relationship between the target host and the target volume cannot be established; and a first message is generated to indicate that the mapping relationship cannot be established;
[0111] If the volume number of the target volume does not exist, determining that a mapping relationship between the target host and the target volume can be established;
[0112] When generating mapping data, set the host group number to invalid and set the mapping type to private.
[0113] In one embodiment, a user sends a first request to indicate the establishment of a mapping relationship between a single host and a single volume. In this case, according to the host number of the target host specified in the first request, the volume mapping chain corresponding to the host number is searched in the first linked list. In the volume mapping chain, it is searched whether there is an index of the volume number of the target volume specified in the first request, that is, it is searched whether there is an index of (lun_id, host_id). If so, it means that a mapping relationship already exists between the target host and the target volume, so it is determined that the mapping between the target host and the target volume cannot be repeatedly established. A first message is generated to prompt the user that a mapping relationship cannot be established between the current target host and the target volume. If the volume number of the target volume is not found in the volume mapping chain of the target host, it means that there is no mapping relationship between the target host and the target volume, so it is determined that the current mapping can be established.
[0114] Optionally, the host mapping chain corresponding to the volume number can be searched in the second linked list according to the volume number of the target volume specified in the first request. Check whether there is an index of the host number of the target host specified in the first request in the host mapping chain. If so, it means that there is already a mapping relationship between the target host and the target volume, so it is determined that the mapping between the target host and the target volume cannot be repeatedly established. Generate a first message to prompt the user that a mapping relationship cannot be established between the current target host and the target volume. If there is no index of the host number of the target host in the host mapping chain, it means that there is no mapping relationship between the target host and the target volume, so it is determined that the current mapping can be established.
[0115] According to the judgment result, a mapping relationship is established between the target host and the target volume, and the corresponding mapping data is generated. Since it is a host-to-single-volume mapping, the host number in the mapping data needs to be set to invalid, and the mapping type is set to private. The mapping data is stored in the mapping array, and the index of the mapping data is stored in the first linked list and the second linked list respectively.
[0116] In one embodiment, a linked list with a shorter chain length is selected for query. For example, there are 20 hosts and 100 volumes in the system. Since the number of volumes is large, the length of the volume mapping chain in the first linked list can reach 100, and the length of the host mapping chain in the second linked list can reach 20. Therefore, the second linked list is preferentially selected for traversal query, thereby reducing the amount of data that needs to be traversed. By selecting a linked list with a shorter chain length for query, the query speed can be further accelerated, the efficiency of establishing the mapping relationship can be improved, and system resources can be saved.
[0117] In one embodiment, the user sends a fourth request indicating that the mapping relationship between the target host and the target volume needs to be deleted. When the fourth request sent by the user host is received, the mapping relationship between the target host and the target volume needs to be determined first, and then the target object to be de-mapped is further determined, that is, a single host, a host group, a single volume or a volume group. According to the information of the target object, the first linked list, the second linked list and the mapping array are searched, and the corresponding mapping relationship and index are deleted.
[0118] If the mapping relationship is a single volume mapping, the index of the mapping data is directly found in the first linked list or the second linked list according to the host number of the target host or the volume number of the target volume, and the corresponding mapping data is deleted from the mapping array according to the index. Then, the corresponding index is deleted from the first linked list and the second linked list, and the index information recorded in the adjacent position is updated.
[0119] If the mapping relationship is a host group and a single volume mapping, first determine the host group where the target host is located, traverse all hosts in the host group, release the mapping relationship between all hosts and the target volume, delete the corresponding mapping data from the mapping array, delete the corresponding index from the first linked list and the second linked list, and update the index information recorded in the adjacent position.
[0120] If the mapping relationship is a host-volume group mapping, first determine the volume group where the target volume is located, traverse all volumes in the volume group, release the mapping relationship between all volumes and the target host, delete the corresponding mapping data from the mapping array, delete the corresponding index from the first linked list and the second linked list, and update the index information recorded in the adjacent position.
[0121] If the mapping relationship is a host group and volume group mapping, it is necessary to search the first linked list and the second linked list according to the host number of the target host and the volume number of the target volume, determine the host group where the target host is located, and the volume group where the target volume is located, traverse the host group and the volume group, release the mapping relationship between each host in the host group and each volume in the volume group, delete the corresponding mapping data from the mapping array, delete the corresponding index from the first linked list and the second linked list, and update the index information recorded in the adjacent position.
[0122] As an implementation manner of the present application, when the mapping relationship is a host-volume group mapping, determining whether a mapping relationship between the target host and the target volume can be established includes:
[0123] Traversing the target volume group, taking each volume as a target volume, and searching the second linked table to obtain a host mapping chain of the target volume according to the volume number of the target volume;
[0124] Starting from the index of the first mapping data in the host mapping chain, traversing the host mapping chain to find whether there is a host number of the target host; if the host number of the target host exists, determining that a mapping relationship between the target host and the target volume group cannot be established; generating a first message to indicate that the mapping relationship cannot be established;
[0125] If the host number of the target host does not exist in the host mapping chain corresponding to each volume in the target volume group, it is determined that a mapping relationship between the target host and the target volume group can be established;
[0126] When generating mapping data, the host group number is set to be invalid, and the mapping type is set to be private.
[0127] In one embodiment, the user instructs to establish a mapping relationship between the host and the volume group. The host is mapped to the volume group, which is a private mapping. The mapping method is similar to mapping a host to multiple single volumes. It is worth noting that after the mapping relationship is established, the target host cannot independently cancel the mapping relationship with some volumes in the target volume group.
[0128] The volume mapping chain corresponding to the target host is queried in the first linked list, the target volume group is traversed, and the volume number of any volume in the target volume group is found in the first linked list. If so, it is determined that a mapping relationship between the target host and some volumes already exists, and a first message is generated to prompt that the mapping cannot be established.
[0129] Optionally, traverse the target volume group, obtain the volume number of each volume therein, and search the second linked list to find out whether the host number of the target host exists in the host mapping chain of each volume. If so, it is determined that a mapping relationship between the target host and some volumes already exists, and a first message is generated to prompt that the mapping cannot be established.
[0130] If there is no mapping relationship between all volumes in the target volume group and the target host, it is determined that the mapping can be established. When generating mapping data, the mapping type is set to private and the host group number is set to invalid. Figure 4 shown. Figure 4This is a schematic diagram of the mapping between hosts and volume groups in an embodiment of the present application. Among them, the host host0 is mapped to two volume groups (volume group 1 and volume group 2), each of which includes two volumes. Volume group 1 includes LUN0 and LUN1; volume group 2 includes LUN2 and LUN3. The host host0 forms a mapping relationship with each volume in each volume group.
[0131] As an implementation manner of the present application, when the mapping relationship is a host group and a single volume mapping, determining whether a mapping relationship between the target host and the target volume can be established includes:
[0132] Traversing the target host group, taking each host in the target host group as a target host, and searching the first linked list to obtain a volume mapping chain of the target host according to the host number of the target host;
[0133] Starting from the index of the first mapping data in the volume mapping chain, traversing the volume mapping chain to find whether there is a volume number of the target volume; if there is a volume number of the target volume, determining that a mapping relationship between the target host group and the target volume cannot be established; generating a first message to indicate that the mapping relationship cannot be established;
[0134] If the volume number of the target volume does not exist in the volume mapping chain corresponding to each host in the target host group, it is determined that a mapping relationship between the target host group and the target volume can be established;
[0135] When generating mapping data, the host number is set to the number of the target host group, and the mapping type is set to private.
[0136] In one embodiment, the user instructs to establish a mapping relationship between a host group and a single volume. It is worth noting that after the mapping relationship is established, the target volume cannot be individually unmapped from some hosts in the target host group. Similar to establishing a mapping relationship between a host and a volume group, it is necessary to search the first linked list or the second linked list based on the host number of each host in the target host group and the volume number of the target volume to determine whether there is a mapping relationship between any host and the target volume. If so, a first message is generated to prompt that the mapping cannot be established. If not, a mapping is established between each host in the target host group and the target volume, and corresponding mapping data is generated. When generating the mapping data, the mapping type is set to private, and the host group number is set to the number of the target host group.
[0137] After establishing the mapping relationship, Figure 5 shown. Figure 5This is a schematic diagram of the mapping between host groups and single volumes in an embodiment of the present application. Host group 1 and host group 2 are both mapped to volume LUN0, that is, hosts host0 and host1 in host group 1, and hosts host2 and host3 in host group 2 are respectively mapped to volume LUN0.
[0138] As an implementation manner of the present application, when the mapping relationship is a mapping between a host group and a volume group, determining whether a mapping relationship between the target host and the target volume can be established includes:
[0139] Traversing the target volume group, taking each volume as a target volume, and searching the second linked table to obtain a host mapping chain of the target volume according to the volume number of the target volume;
[0140] Starting from the index of the first mapping data in the host mapping chain, traversing the host mapping chain to find whether there is a host number of any host in the target host group; if there is a host number of any host in the target host group, determining that a mapping relationship between the target host group and the target volume group cannot be established; generating a first message to indicate that a mapping relationship cannot be established;
[0141] If the host number of any host in the target host group does not exist in the host mapping chain corresponding to each volume in the target volume group, it is determined that a mapping relationship between the target host group and the target volume group can be established;
[0142] When generating mapping data, the host group number is set to the number of the target host group, and the mapping type is set to shared.
[0143] In one embodiment, the user instructs to establish a mapping relationship between a host group and a volume group. If the user's application requires multiple LUNs, and the application is deployed on a cluster consisting of multiple hosts, it is usually necessary to establish a LUN group to manage the LUNs, and to establish a host group to manage multiple hosts. First, to prevent repeated mapping between hosts and volumes, it is necessary to traverse all LUNs in the LUN group and all hosts in the host group to see whether there is a mapping relationship, including share mapping and private mapping. If a mapping relationship is found between any host in the host group and any volume in the volume group, the search is stopped, and it is determined that the mapping cannot be established, and a first message is generated to prompt the user.
[0144] If no mapping is found between any host and any volume, a mapping relationship between the host group and the volume group is established. Specifically, starting from the first volume of the target volume group, all volumes are traversed, and each volume is mapped to all hosts in the target host group. The host group number in the mapping data is set to the number of the target host group, and the mapping type is set to share. Figure 6 shown. Figure 6This is a schematic diagram of the mapping between host groups and volume groups in an embodiment of the present application. In which, host group 1 and host group 2 contain the same host host1, host group 1 is mapped to volume group 1, and host group 2 is mapped to volume group 2. Since host1 exists in two host groups at the same time, host1 forms a mapping relationship with each volume (LUN0, LUN1, LUN2, LUN3) in volume group 1 and volume group 2.
[0145] As an implementation manner of the present application, the method for mapping a host to a volume further includes:
[0146] receiving a second request sent by a user host, where the second request is used to add a new host to the target host group;
[0147] Search the first linked list to obtain the volume numbers of all volume groups and single volumes that are currently mapped to the new host, and generate a first volume number group;
[0148] Obtain the volume numbers of all volume groups and single volumes that are currently mapped to each host in the target host group, calculate the intersection, and generate a second volume number group;
[0149] Comparing the first volume number group with the second volume number group to determine whether there are identical volume numbers;
[0150] If the same volume number exists, it is determined that the new host cannot be added;
[0151] If the same volume number does not exist, it is determined that the new host can be added; the new host is added to the target host group, and a mapping relationship between the new host and each volume in the second volume number group is established respectively, and corresponding mapping data is generated.
[0152] In one embodiment, the user sends a second request to instruct to add a new host to the target host group. Since the target host group may have mapped a single volume or a volume group, and the new host may have mapped a single volume or a volume group, in order to avoid duplicate mapping, it is necessary to first determine whether there is a mapping conflict after the new host is added to the target host group.
[0153] First, the first linked list is searched according to the host number of the new host, the volume number of the volume mapped by the new host is obtained, and the first volume number group is generated. Then, the host number of each host in the target host group is traversed, and the first linked list is searched according to each host number to obtain the volume number of the volume mapped by each host in the target host group. The volume number mapped by each host in the target host group is intersected to determine the volume number mapped by the target host group, and a second volume number group is generated.
[0154] The first volume number group is compared with the second volume number group. If the same volume number exists, it is determined that there is a mapping conflict after the new host is added to the target host group. Therefore, a second message is generated to prompt the user that the new host cannot be added. If the first volume number group and the second volume number group do not have the same volume number, it is determined that there is no mapping conflict and the new host can be added.
[0155] After adding the new host to the target host group, the second volume number group is traversed to establish a mapping relationship between each volume and the new host.
[0156] In one embodiment, after being added to the target host group, the new host can map a single volume again. It only needs to query the first linked list to determine that there is no mapping relationship between the host and the target volume, and then establish the mapping between the host and the target volume. The specific process is the same as the mapping of a single host and a single volume, and will not be repeated in this embodiment.
[0157] This embodiment implements the flexible addition of new hosts to the host group that provides services normally, so that users can adjust the host cluster in the system according to business needs. The process of adding new hosts will not affect the normal operation of the business, and will not affect the normal mapping of other hosts and volumes in the host group, thus improving the stability and usability of the system and meeting the needs of users for flexible adjustment.
[0158] As an implementation manner of the present application, the method for mapping a host to a volume further includes:
[0159] receiving a third request sent by a user host, wherein the third request is used to add a new volume to the target volume group;
[0160] Search the second linked list to obtain all host groups and host numbers that are currently mapped to the new volume, and generate a first host number group;
[0161] Obtain all host numbers that are currently mapped to each volume in the target volume group, calculate the intersection, and generate a second host number group;
[0162] Compare the first host number group with the second host number group to determine whether there are identical host numbers;
[0163] If the same host number exists, it is determined that the new volume cannot be added;
[0164] If the same host number does not exist, it is determined that the new volume can be added; the new volume is added to the target volume group, and a mapping relationship between the new volume and each host in the second host number group is established to generate corresponding mapping data.
[0165] In one embodiment, the user sends a third request to instruct to add a new volume to the target volume group. Since the target volume group may be mapped to a host or a host group, and the new volume may be mapped to a host or a host group, in order to avoid duplicate mapping, it is necessary to first determine whether there is a mapping conflict after the new volume is added to the target volume group.
[0166] First, the second linked list is searched according to the volume number of the new volume, the host number of the host mapped to the new volume is obtained, and the first host number group is generated. Then, the volume number of each volume in the target volume group is traversed, and the second linked list is searched according to each volume number to obtain the host number of the host mapped to each volume in the target volume group. The host number mapped to each volume in the target volume group is intersected to determine the host number mapped to the target volume group, and the second host number group is generated.
[0167] The first host number group is compared with the second host number group. If the same host number exists, it is determined that there is a mapping conflict after the new volume is added to the target volume group. Therefore, a third message is generated to prompt the user that the new volume cannot be added. In the case that the first host number group and the second host number group do not have the same host number, it is determined that there is no mapping conflict and the new volume can be added.
[0168] After adding the new volume to the target volume group, the second host number group is traversed to establish a mapping relationship between each host and the new volume.
[0169] In one embodiment, the new volume added to the target volume group can be mapped to a single host again. It only needs to query the second linked list to determine that there is no mapping relationship between the volume and the target host, and then the mapping between the volume and the target host can be established. The specific process is the same as the single host and single volume mapping, and will not be repeated in this embodiment.
[0170] This embodiment realizes the flexible addition of new volumes to the volume groups that are normally operating in the system without affecting the normal operation of the business. The addition of new volumes does not affect the normal mapping of other volumes in the volume group and the host. There is no need to release the current volume group and then re-establish a new volume group based on the new volume as in the traditional way. This improves the usability of the system and meets the user's needs for flexible adjustment.
[0171] In one embodiment, the user sends a fifth request to query all volume groups currently mapped by the target host group. In this embodiment, the host group number and the mapping type are used as markers to achieve rapid screening of volume groups. Specifically, the host number of any host in the target host group is first obtained, and the first linked list is queried to obtain the indexes of all volumes mapped by the host. According to each index, the corresponding mapping data is obtained from the mapping array.
[0172] Then, all mapping data are filtered by mapping type, the mapping type in each mapping data is read, and mapping data with mapping type of share is filtered out. Further, the mapping data are filtered by host group number, and mapping data with host group number as the number of the target host group is filtered out, that is, the volume numbers of volumes in all volume groups mapped by the target host group are obtained.
[0173] In the process of querying the mapping relationship between the host group and the volume group, the query result is screened twice by setting the mark bit, so as to further save the system resources consumed by traversing each mapping data and improve the query efficiency.
[0174] Based on the same inventive concept, an embodiment of the present application provides a storage system. Figure 7 , Figure 7 FIG. 1 is a schematic diagram of a storage system 100 proposed in an embodiment of the present application. Figure 7 As shown, the system includes:
[0175] At least two hosts are configured to provide services to users in the form of a single host or a host group; wherein any host can join at least one host group;
[0176] At least two volumes are configured to provide storage services to each host in the form of a single volume or a volume group; wherein any volume can be added to at least one volume group; wherein at most one mapping relationship can be established between any volume and any host;
[0177] The judgment module 101 is configured to, upon receiving a first request sent by a user host, obtain a target host, a target volume and a target mapping relationship in the first request; the target mapping relationship is any one of the following: host-single-volume mapping, host-volume group mapping, host group-single-volume mapping, or host group-volume group mapping; query the first linked list or the second linked list to determine whether a mapping relationship between the target host and the target volume can be established; the first linked list is used to store an index of mapping data of the host to different volumes; the second linked list is used to store an index of mapping data of the volume to different hosts;
[0178] The mapping module 102 is configured to establish the target mapping relationship and generate corresponding mapping data when it is determined that the mapping relationship can be established; the mapping data includes: volume number, host number, host group number and mapping type; the mapping type is private or shared; the mapping array is used to store the mapping relationship between all hosts and volumes in the system;
[0179] The recording module 103 is configured to store the mapping data in a mapping array; and store the index of the mapping data in the mapping array in the first linked list and the second linked list respectively.
[0180] As an implementation manner of the present application, when the mapping relationship is a host-single-volume mapping, the determination module 101 is configured to determine whether a mapping relationship between the target host and the target volume can be established, specifically including:
[0181] According to the host number of the target host, searching the first linked list to obtain the volume mapping chain of the target host;
[0182] Starting from the index of the first mapping data in the volume mapping chain, traverse the volume mapping chain to find out whether there is a volume number of the target volume;
[0183] If the volume number of the target volume exists, it is determined that the mapping relationship between the target host and the target volume cannot be established; and a first message is generated to indicate that the mapping relationship cannot be established;
[0184] If the volume number of the target volume does not exist, determining that a mapping relationship between the target host and the target volume can be established;
[0185] The mapping module 102 is further configured to set the host group number to invalid and the mapping type to private when generating mapping data.
[0186] As an implementation manner of the present application, when the mapping relationship is a host-volume group mapping, the determination module 101 is configured to determine whether a mapping relationship between the target host and the target volume can be established, specifically including:
[0187] Traversing the target volume group, taking each volume as a target volume, and searching the second linked table to obtain a host mapping chain of the target volume according to the volume number of the target volume;
[0188] Starting from the index of the first mapping data in the host mapping chain, traversing the host mapping chain to find whether there is a host number of the target host; if the host number of the target host exists, determining that a mapping relationship between the target host and the target volume group cannot be established; generating a first message to indicate that the mapping relationship cannot be established;
[0189] If the host number of the target host does not exist in the host mapping chain corresponding to each volume in the target volume group, it is determined that a mapping relationship between the target host and the target volume group can be established;
[0190] The mapping module 102 is further configured to set the host group number to invalid and the mapping type to private when generating mapping data.
[0191] As an implementation manner of the present application, when the mapping relationship is a host group and a single volume mapping, the judgment module 101 is configured to judge whether a mapping relationship between the target host and the target volume can be established, specifically including:
[0192] Traversing the target host group, taking each host in the target host group as a target host, and searching the first linked list to obtain a volume mapping chain of the target host according to the host number of the target host;
[0193] Starting from the index of the first mapping data in the volume mapping chain, traversing the volume mapping chain to find whether there is a volume number of the target volume; if there is a volume number of the target volume, determining that a mapping relationship between the target host group and the target volume cannot be established; generating a first message to indicate that the mapping relationship cannot be established;
[0194] If the volume number of the target volume does not exist in the volume mapping chain corresponding to each host in the target host group, it is determined that a mapping relationship between the target host group and the target volume can be established;
[0195] The mapping module 102 is further configured to set the host number to the number of the target host group and set the mapping type to private when generating mapping data.
[0196] As an implementation manner of the present application, when the mapping relationship is a mapping between a host group and a volume group, the determination module 101 is configured to determine whether a mapping relationship between the target host and the target volume can be established, specifically including:
[0197] Traversing the target volume group, taking each volume as a target volume, and searching the second linked table to obtain a host mapping chain of the target volume according to the volume number of the target volume;
[0198] Starting from the index of the first mapping data in the host mapping chain, traversing the host mapping chain to find whether there is a host number of any host in the target host group; if there is a host number of any host in the target host group, determining that a mapping relationship between the target host group and the target volume group cannot be established; generating a first message to indicate that a mapping relationship cannot be established;
[0199] If the host number of any host in the target host group does not exist in the host mapping chain corresponding to each volume in the target volume group, it is determined that a mapping relationship between the target host group and the target volume group can be established;
[0200] The mapping module 102 is further configured to set the host group number to the number of the target host group and set the mapping type to sharing when generating mapping data.
[0201] As an implementation mode of the present application, the judgment module 101 is further configured to receive a second request sent by a user host, the second request being used to add a new host to the target host group; searching the first linked list, obtaining the volume numbers of all volume groups and single volumes that are currently mapped to the new host, and generating a first volume number group; obtaining the volume numbers of all volume groups and single volumes that are currently mapped to each host in the target host group, and calculating the intersection, and generating a second volume number group; comparing the first volume number group with the second volume number group to determine whether there are identical volume numbers; if there are identical volume numbers, determining that the new host cannot be added;
[0202] The mapping module 102 is further configured to determine that the new host can be added if the same volume number does not exist; add the new host to the target host group, and establish a mapping relationship between the new host and each volume in the second volume number group, and generate corresponding mapping data.
[0203] As an implementation mode of the present application, the judgment module 101 is further configured to receive a third request sent by a user host, the third request being used to add a new volume to a target volume group; searching the second linked list, obtaining all host groups and host numbers that are currently mapped to the new volume, and generating a first host number group; obtaining all host numbers that are currently mapped to each volume in the target volume group, and calculating the intersection, and generating a second host number group; comparing the first host number group with the second host number group to determine whether there are identical host numbers; if there are identical host numbers, determining that the new volume cannot be added;
[0204] The mapping module 102 is also configured to determine that the new volume can be added if the same host number does not exist; add the new volume to the target volume group, and establish a mapping relationship between the new volume and each host in the second host number group, and generate corresponding mapping data.
[0205] As an implementation manner of the present application, the recording module 103 is configured to store the index of the mapping data in the mapping array in the first linked list and the second linked list, respectively, specifically including:
[0206] Obtain the index of the mapping data in the mapping array as the target index;
[0207] According to the host number in the mapping data, searching the first linked list for a corresponding volume mapping chain;
[0208] Obtaining an empty position in the volume mapping chain as a first position to be stored;
[0209] Obtaining an index stored in an adjacent position of the first position to be stored, and generating first index information based on the target index and the index stored in the adjacent position of the first position to be stored;
[0210] storing the first index information in the first to-be-stored position, and updating the first index information stored in an adjacent position of the first to-be-stored position;
[0211] According to the volume number in the mapping data, searching the corresponding host mapping chain in the second linked list;
[0212] Obtaining an empty position in the host mapping chain as a second position to be stored;
[0213] Obtaining an index stored in an adjacent position of the second position to be stored, and generating second index information based on the target index and the index stored in the adjacent position of the second position to be stored;
[0214] The second index information is stored in the second to-be-stored position, and the second index information stored in the adjacent position of the second to-be-stored position is updated.
[0215] As an implementation manner of the present application, the storage system 100 further includes a deletion module configured to perform the following steps:
[0216] Based on the same inventive concept, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps in the method for mapping a host to a volume as described in any of the above embodiments of the present application are implemented.
[0217] Based on the same inventive concept, an embodiment of the present application provides a readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the method of host and volume mapping as described in any of the above embodiments of the present application are implemented.
[0218] Based on the same inventive concept, an embodiment of the present application provides an electronic device. Figure 8 Schematic diagram of an electronic device according to an embodiment of the present application. Figure 8 As shown, the electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the method for mapping a host to a volume as described in any of the above embodiments of the present application are implemented.
[0219] Regarding the system in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0220] 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 present application should be included in the protection scope of the present application.
[0221] For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and components involved are not necessarily required by the present application.
[0222] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0223] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0224] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0225] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0226] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the present application is interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0227] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0228] The host and volume mapping method, storage system, device and storage medium provided by the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for mapping a host to a volume, characterized in that: Applied to a storage system, the storage system includes at least two hosts and at least two volumes; the method includes: Upon receiving a first request sent by a user host, obtaining a target host, a target volume, and a target mapping relationship in the first request; the target mapping relationship is any one of the following: host-single-volume mapping, host-volume group mapping, host group-single-volume mapping, or host group-volume group mapping; Querying the first linked list or the second linked list to determine whether a mapping relationship between the target host and the target volume can be established; the first linked list is used to store indexes of mapping data of the host to different volumes; the second linked list is used to store indexes of mapping data of the volume to different hosts; If it is determined that a mapping relationship can be established, the target mapping relationship is established and corresponding mapping data is generated, and the mapping data is stored in a mapping array; the mapping data includes: a volume number, a host number, a host group number, and a mapping type; the mapping type is private or shared; the mapping array is used to store mapping relationships between all hosts and volumes in the system; The index of the mapping data in the mapping array is stored in the first linked list and the second linked list respectively.
2. The method for host-volume mapping according to claim 1, characterized in that: In the case where the mapping relationship is a host-to-single-volume mapping, determining whether a mapping relationship between the target host and the target volume can be established includes: According to the host number of the target host, searching the first linked list to obtain the volume mapping chain of the target host; Starting from the index of the first mapping data in the volume mapping chain, traverse the volume mapping chain to find out whether there is a volume number of the target volume; If the volume number of the target volume exists, it is determined that the mapping relationship between the target host and the target volume cannot be established; and a first message is generated to indicate that the mapping relationship cannot be established; If the volume number of the target volume does not exist, determining that a mapping relationship between the target host and the target volume can be established; When generating mapping data, set the host group number to invalid and set the mapping type to private.
3. The method for host-volume mapping according to claim 1, characterized in that: In the case where the mapping relationship is a host-volume group mapping, determining whether a mapping relationship between the target host and the target volume can be established includes: Traversing the target volume group, taking each volume as a target volume, and searching the second linked table to obtain a host mapping chain of the target volume according to the volume number of the target volume; Starting from the index of the first mapping data in the host mapping chain, traversing the host mapping chain to find whether there is a host number of the target host; if the host number of the target host exists, determining that a mapping relationship between the target host and the target volume group cannot be established; generating a first message to indicate that the mapping relationship cannot be established; If the host number of the target host does not exist in the host mapping chain corresponding to each volume in the target volume group, it is determined that a mapping relationship between the target host and the target volume group can be established; When generating mapping data, the host group number is set to be invalid, and the mapping type is set to be private.
4. The method for host-volume mapping according to claim 1, characterized in that: In a case where the mapping relationship is a host group to a single volume mapping, determining whether a mapping relationship between the target host and the target volume can be established includes: Traversing the target host group, taking each host in the target host group as a target host, and searching the first linked list to obtain a volume mapping chain of the target host according to the host number of the target host; Starting from the index of the first mapping data in the volume mapping chain, traversing the volume mapping chain to find whether there is a volume number of the target volume; if there is a volume number of the target volume, determining that a mapping relationship between the target host group and the target volume cannot be established; generating a first message to indicate that the mapping relationship cannot be established; If the volume number of the target volume does not exist in the volume mapping chain corresponding to each host in the target host group, it is determined that a mapping relationship between the target host group and the target volume can be established; When generating mapping data, the host number is set to the number of the target host group, and the mapping type is set to private.
5. The method for host-volume mapping according to claim 1, characterized in that: In the case where the mapping relationship is a mapping between a host group and a volume group, determining whether a mapping relationship between the target host and the target volume can be established includes: Traversing the target volume group, taking each volume as a target volume, and searching the second linked table to obtain a host mapping chain of the target volume according to the volume number of the target volume; Starting from the index of the first mapping data in the host mapping chain, traversing the host mapping chain to find whether there is a host number of any host in the target host group; if there is a host number of any host in the target host group, determining that a mapping relationship between the target host group and the target volume group cannot be established; generating a first message to indicate that a mapping relationship cannot be established; If the host number of any host in the target host group does not exist in the host mapping chain corresponding to each volume in the target volume group, it is determined that a mapping relationship between the target host group and the target volume group can be established; When generating mapping data, the host group number is set to the number of the target host group, and the mapping type is set to sharing.
6. The method for host-volume mapping according to claim 1, characterized in that: Also includes: receiving a second request sent by a user host, where the second request is used to add a new host to the target host group; Search the first linked list to obtain the volume numbers of all volume groups and single volumes that are currently mapped to the new host, and generate a first volume number group; Obtain the volume numbers of all volume groups and single volumes that are currently mapped to each host in the target host group, calculate the intersection, and generate a second volume number group; Comparing the first volume number group with the second volume number group to determine whether there are identical volume numbers; If the same volume number exists, it is determined that the new host cannot be added; If the same volume number does not exist, it is determined that the new host can be added; the new host is added to the target host group, and a mapping relationship between the new host and each volume in the second volume number group is established respectively, and corresponding mapping data is generated.
7. The method for host-volume mapping according to claim 1, characterized in that: Also includes: receiving a third request sent by a user host, wherein the third request is used to add a new volume to the target volume group; Search the second linked list to obtain all host groups and host numbers that are currently mapped to the new volume, and generate a first host number group; Obtain all host numbers that are currently mapped to each volume in the target volume group, calculate the intersection, and generate a second host number group; Compare the first host number group with the second host number group to determine whether there are identical host numbers; If the same host number exists, it is determined that the new volume cannot be added; If the same host number does not exist, it is determined that the new volume can be added; The new volume is added to the target volume group, and a mapping relationship between the new volume and each host in the second host number group is established to generate corresponding mapping data.
8. The method for host-volume mapping according to any one of claims 1 to 7, characterized in that: Storing the index of the mapping data in the mapping array in the first linked list and the second linked list respectively includes: Obtain the index of the mapping data in the mapping array as the target index; According to the host number in the mapping data, searching the first linked list for a corresponding volume mapping chain; Obtaining an empty position in the volume mapping chain as a first position to be stored; Obtaining an index stored in an adjacent position of the first position to be stored, and generating first index information based on the target index and the index stored in the adjacent position of the first position to be stored; storing the first index information in the first to-be-stored position, and updating the first index information stored in an adjacent position of the first to-be-stored position; According to the volume number in the mapping data, searching the corresponding host mapping chain in the second linked list; Obtaining an empty position in the host mapping chain as a second position to be stored; Obtaining an index stored in an adjacent position of the second position to be stored, and generating second index information based on the target index and the index stored in the adjacent position of the second position to be stored; The second index information is stored in the second to-be-stored position, and the second index information stored in the adjacent position of the second to-be-stored position is updated.
9. A storage system, characterized in that: Used to perform the method according to any one of claims 1 to 8, comprising: At least two hosts are configured to provide services to the user host in the form of a single host or a host group; wherein any host can join at least one host group; At least two volumes are configured to provide storage services to each host in the form of a single volume or a volume group; wherein any volume can be added to at least one volume group; wherein at most one mapping relationship can be established between any volume and any host; The judgment module is configured to, upon receiving a first request sent by a user host, obtain a target host, a target volume and a target mapping relationship in the first request; the target mapping relationship is any one of the following: host-single-volume mapping, host-volume group mapping, host group-single-volume mapping, or host group-volume group mapping; query the first linked list or the second linked list to determine whether a mapping relationship between the target host and the target volume can be established; the first linked list is used to store an index of mapping data of the host to different volumes; the second linked list is used to store an index of mapping data of the volume to different hosts; A mapping module is configured to establish the target mapping relationship and generate corresponding mapping data when it is determined that the mapping relationship can be established; the mapping data includes: volume number, host number, host group number and mapping type; the mapping type is private or shared; the mapping array is used to store the mapping relationship between all hosts and volumes in the system; The recording module is configured to store the mapping data in a mapping array; and store the index of the mapping data in the mapping array in the first linked list and the second linked list respectively.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in any one of the methods of claims 1-8 are implemented.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps in the method according to any one of claims 1 to 8 are implemented.
