Path equipment status detection method and device
By dynamically adjusting the detection interval of path devices and using multi-threaded detection, the problems of repeated detection and insufficient detection interval in path device detection are solved, achieving rapid response and efficient fault identification.
Patent Information
- Application Number
- CN202511404882.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-09-29
AI Technical Summary
In existing technologies, the detection of path devices cannot identify common fault sources, leading to repeated detections. Furthermore, the detection interval lacks flexibility and cannot be dynamically adjusted according to the actual condition or fault characteristics.
By scanning the volumes mapped to the host, the path devices are identified, and the detection interval is dynamically adjusted based on the device status and scaling factor. Multi-threading is used for status detection, and when link components are found to be abnormal, other devices are uniformly treated as abnormal.
Simplify fault diagnosis logic, reduce detection pressure, respond quickly to status changes, and improve detection efficiency and accuracy.
Smart Images

Figure CN120896873B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and particularly relates to a path equipment state detection method and equipment. BACKGROUND
[0002] The related art has two deficiencies: one is that the detection of the path equipment is performed one by one, and the path equipment with a common fault source cannot be identified, leading to repeated detection of the common fault; and the other is that the user state uses a fixed detection interval for the path equipment in a normal state and an abnormal state, and lacks the ability to dynamically adjust the detection interval according to the actual state or fault characteristics, and the flexibility is insufficient.
[0003] Therefore, in view of the shortcomings of the prior art, the present application provides a path equipment state detection method. SUMMARY
[0004] The present application provides a path equipment state detection method and equipment to at least solve the problems of repeated detection of the common fault and untimely detection.
[0005] The present application provides a path equipment state detection method, which comprises the following steps: scanning to obtain at least one volume mapped to a host, and determining at least one path equipment according to the at least one volume, wherein one path equipment corresponds to one link; collecting historical detection data in a preset period through a sliding window, and determining a current detection interval duration corresponding to different equipment states in combination with the equipment states, the number of path equipments and a proportion factor, wherein the equipment states include a normal state and an abnormal state; performing state detection on the path equipment in different equipment states through a plurality of detection threads according to the current detection interval duration, to determine a user state detection result of the at least one path equipment, wherein the user state detection result includes the equipment state and an abnormal component type, and the abnormal component type includes a link component and an equipment component; in response to the abnormal component type of the path equipment being the link component, determining at least one target path equipment corresponding to the link component, and synchronizing the equipment state of the at least one target path equipment to the abnormal state.
[0006] The application further provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the following steps when executing the computer program: obtaining at least one volume mapped to a host through scanning, determining at least one path device according to the at least one volume, wherein one path device corresponds to one link; collecting historical detection data in a preset period through a sliding window, determining a current detection interval duration corresponding to different device states in combination with device states, a number of path devices and a proportion factor, wherein the device states include a normal state and an abnormal state; performing state detection on the path devices in different device states through a plurality of detection threads according to the current detection interval duration, and determining a user state detection result of the at least one path device, wherein the user state detection result includes the device states and an abnormal component type, and the abnormal component type includes a link component and a device component; in response to the abnormal component type of the path device being the link component, determining at least one target path device corresponding to the link component, and synchronizing the device state of the at least one target path device to the abnormal state.
[0007] According to the application, at least one volume mapped to a host is obtained through scanning, at least one path device is determined according to the at least one volume, wherein one path device corresponds to one link; historical detection data in a preset period is collected through a sliding window, a current detection interval duration corresponding to different device states is determined in combination with device states, a number of path devices and a proportion factor, wherein the device states include a normal state and an abnormal state; state detection is performed on the path devices in different device states through a plurality of detection threads according to the current detection interval duration, and a user state detection result of the at least one path device is determined, wherein the user state detection result includes the device states and an abnormal component type, and the abnormal component type includes a link component and a device component; in response to the abnormal component type of the path device being the link component, at least one target path device corresponding to the link component is determined, and the device state of the at least one target path device is synchronized to the abnormal state, so that when one of the path devices using the same link component is abnormal, other associated devices are also regarded as being in the abnormal state, thereby simplifying fault judgment logic, and through dynamic adjustment of the interval time of each round of state detection, the detection pressure is reduced and the state change of the path device can be responded to more quickly. BRIEF DESCRIPTION OF DRAWINGS
[0008] In order to more clearly illustrate the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort.
[0009] Figure 1 A flowchart of a path device state detection method provided by an embodiment of the present application;
[0010] Figure 2 A multi-path architecture schematic diagram of a path equipment state detection method provided by an embodiment of the application is shown in FIG. 1.
[0011] Figure 3 A structural block diagram of a path equipment state detection device provided by an embodiment of the application is shown in FIG. 2.
[0012] Figure 4 An internal structure diagram of an electronic device provided by an embodiment of the application is shown in FIG. 3. DETAILED DESCRIPTION
[0013] The technical solutions in the embodiments of the application will be described clearly and completely below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only some of the embodiments of the application, but not all the embodiments of the application. Based on the embodiments in the application, any other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the application.
[0014] It should be noted that, in the description of the application, the terms “comprise”, “contain” or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. The terms “first”, “second” and the like in the application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0015] It should be noted that the terms “S1”, “S2” and the like are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the application. They are only used to facilitate the description of the method of the application, and cannot be understood as indicating the sequence of the steps. In addition, the technical solutions of each embodiment can be combined with each other, but it must be based on the realization of a person of ordinary skill in the art. When the combination of technical solutions contradicts each other or cannot be realized, it should be considered that the combination of technical solutions does not exist, nor is it within the protection scope of the application.
[0016] In order for those skilled in the art to better understand the application, the application will be further described in detail below with reference to the drawings and specific embodiments.
[0017] The embodiments of the application provide a path equipment state detection method. The method is described in detail in combination with the execution flow of the path equipment state detection method.
[0018] S101: Scan to obtain at least one volume mapped to the host, determine at least one path device according to the at least one volume, wherein one path device corresponds to one link.
[0019] Here, in the Linux system, the path device is a device name allocated by the kernel for a block storage device (such as a hard disk, an SSD (Solid State Drive), an NVMe disk, or a virtual disk, etc.), usually in the form of sdX.
[0020] Here, the volume refers to a logical storage unit managed by an operating system or a storage system, which is independent and addressable.
[0021] Here, the link is a communication channel between the host and the path device, used for information exchange between the host and the path device.
[0022] Here, the link can be FC-SCSI (Fibre Channel-Small Computer System Interface). Among them, the SCSI protocol is encapsulated on the Fibre Channel network; FC is a high-speed network technology (usually running on optical fiber or copper cable), designed for storage network, providing high bandwidth, low latency and reliable block-level data transmission; SCSI is a protocol standard that defines the command and data transmission rules between the host (such as a server) and the path device (such as a hard disk, a tape drive).
[0023] Among them, one volume corresponds to at least one path device.
[0024] Among them, the execution subject can be the host.
[0025] Specifically, when the storage system maps the LUN to the host, the SCSI intermediate layer of the host will automatically create path devices (such as / dev / sdb, / dev / sdc) under the trigger of new LUN events reported by the underlying FC driver (such as qla2xxx) or through automatic scanning by system timing tasks (such as rescan-scsi-bus.sh).
[0026] S102: Collect historical detection data in a preset period through a sliding window, determine the current detection interval length corresponding to different device states in combination with the device state, the number of path devices, and the scaling factor, wherein the device state includes a normal state and an abnormal state.
[0027] Among them, the number of path devices refers to the number of devices corresponding to the current host, not the number of historical devices.
[0028] Among them, the preset period can be one hour.
[0029] The detection interval length is the rest time after detecting all path devices corresponding to the thread.
[0030] The current detection interval length is dynamically changed as the historical detection data collected is changed according to the sliding window.
[0031] The normal state of the path device can be a running state, that is, it can bear I / O (Input / Output), and the abnormal state of the path device can be a failed state, that is, it cannot bear I / O.
[0032] The current detection interval length corresponding to different device states can include the current detection interval length of the normal state and the current detection interval length of the abnormal state. Different device states correspond to different current detection interval lengths.
[0033] The detection interval length at different times can be different.
[0034] S103: According to the current detection interval length, the state of the path device in different device states is detected by multiple detection threads to determine the user state detection result of at least one path device, wherein the user state detection result includes device state and abnormal component type, and the abnormal component type includes link component and device component.
[0035] Here, the user state is a restricted execution environment provided by the operating system for application programs (or user programs).
[0036] Here, the link component is a collection of all hardware components responsible for establishing, maintaining and managing physical connections and logical data transmission in the data communication path, which can include FC cards, switches, controllers and optical fibers, etc.
[0037] Here, multi-threading refers to a technology of executing multiple threads concurrently.
[0038] The device state of the path device is also modified to the device state corresponding to the detection result.
[0039] Specifically, during the initial detection, the state of all path devices is considered to be a normal state, and the normal state and the abnormal state are divided by initial detection.
[0040] S104: In response to the abnormal component type of the path device being a link component, at least one target path device corresponding to the link component is determined, and the device state of the at least one target path device is synchronized to the abnormal state.
[0041] Specifically, when it is found that a certain link component is abnormal, all path devices related to the component are set to an abnormal state.
[0042] It should be noted that when one of the path devices of the same link component has an exception in the present application, the other associated devices are also uniformly regarded as an abnormal state, thereby simplifying the fault judgment logic, and at the same time, by dynamically adjusting the interval time of each round of state detection, the detection pressure is reduced, and the state change of the path device can be responded faster.
[0043] In some embodiments, at least one volume mapped to the host is scanned, and at least one path device is determined according to the at least one volume, including:
[0044] By logging into the host, a port identifier in the host is obtained;
[0045] By logging into the storage system, the host is created and at least one volume is created according to the port identifier;
[0046] At least one volume is mapped to the host;
[0047] By logging into the host again, at least one volume mapped to the host is scanned, and at least one path device is determined according to the at least one volume.
[0048] Here, the identifier of the host can be a fiber channel global port name (i.e. WWPN, World Wide Port Name) port_name, representing the port name of each FC card. At least one port_name can be included in a host.
[0049] Wherein, only the port_name of the FC card with port_state (i.e. port state) as Online (i.e. online) is collected.
[0050] Specifically, by logging into the host, all subdirectories hostX under the directory / sys / class / fc_host / can be queried, and for each subdirectory, port_state and port_name can be obtained.
[0051] Specifically, the host resource can be created by the fiber channel global port name in the storage system. For example, by logging into the storage system, the host resource is created using the command line mkhost -fcwwpn {WWPN1}:{WWPN2} -name{HOST_NAME}, and one host resource represents one real host. Wherein, the host includes two port names.
[0052] Wherein, the parameters of the volume can include the corresponding storage pool, I / O group, capacity size, unit of capacity size, and name of the volume, etc.
[0053] Specifically, a volume represents a piece of storage space by logging into the storage system and using the command line mkvdisk-mdiskgrp{MDISK_GRP}–iogrp{IOGRP}-size{SIZE}-unit{UNIT}-name{NAME}.
[0054] Specifically, a host resource is created by logging into the storage system and using the command line mkvdiskhostmap-host {HOST_NAME} -name{VDISK_NAME}, and this command is executed once for each volume.
[0055] Here, the multiple path devices are aggregated to obtain an aggregated device dm-Y, which is managed by Device Mapper (such as LVM, encrypted volume, RAID).
[0056] Among them, the multi-path software aggregates the scanned physical paths ( / dev / sdb, / dev / sdc) to obtain an aggregated device (such as / dev / mapper / dm-Y).
[0057] For example, each volume corresponds to 8 path devices on the host, as shown in Table 1:
[0058] Table 1
[0059]
[0060] Among them, the path devices sdb~sdi belong to the volume vdisk1 and are aggregated into the aggregated device dm-1, and the path devices sdj~sdq belong to the volume vdisk2 and are aggregated into the aggregated device dm-2.
[0061] In this way, through WWPN authentication and LUN mapping, the security of storage access and data isolation in a multi-host environment are ensured; by using the dual-redundancy feature of the FC architecture and the multi-path software, single-point failures can be avoided, and the end-to-end reliability of the data center can be improved.
[0062] In some specific embodiments, the historical detection data in a preset period is collected through a sliding window, and the current detection interval time corresponding to different device states is determined in combination with the device state, the number of path devices, and a proportion factor, including:
[0063] The first historical detection time consumption and / or the second historical detection time consumption of at least one path device in a normal state and / or in an abnormal state in a preset period are obtained through a sliding window;
[0064] The first current detection interval time and the second current detection interval time of the at least one path device are determined according to the first historical detection time consumption, the second historical detection time consumption, the number of path devices, and the proportion factor.
[0065] The one path device can collect data once or collect data corresponding to different times.
[0066] For example, the detection time of the path device in the normal state and the abnormal state can be as shown in Table 2:
[0067] Table 2
[0068]
[0069] The detection time of the normal state and the abnormal state corresponding to each time is the time of one path device. Different times correspond to different path devices. For example, the detection object of time 1 can be sdb, the detection object of time 2 can be sdc, and the detection object of time 3 can be sdd.
[0070] In one embodiment, a collection period is determined, which can be a fixed time such as one hour, or a dynamically adjusted collection period calculated by a sliding window mean. The detection time of all path devices in two states is collected once every collection period. Assuming that the device state of the device in the collection period does not change, the mean value of each state can be continuously updated by moving average (cumulative average) or exponential weighted moving average (EWMA).
[0071] In some specific embodiments, the first current detection interval length and the second current detection interval length of at least one path device are determined according to the first historical detection time, the second historical detection time, and the number of path devices, comprising:
[0072] Select an initial scaling factor;
[0073] Perform a test loop according to the initial scaling factor and collect index data, wherein the index includes state update delay, central processing unit usage rate, and system stability;
[0074] Analyze the index data and optimize the scaling factor according to the analysis result to obtain the first scaling factor corresponding to the path device in the normal state and the second scaling factor corresponding to the path device in the abnormal state;
[0075] Obtain the number of path devices, and determine the first number of path devices in the normal state and the second number of path devices in the abnormal state according to the device state of the path device;
[0076] According to the first historical detection time of at least one path device in the normal state, the first detection time mean of at least one path device in the normal state is calculated;
[0077] determining a first current detection interval length of the at least one path device in the normal state according to the first detection time mean, the first number and the first scale factor;
[0078] calculating a second detection time mean of the at least one path device in the abnormal state according to the second historical detection time of the at least one path device in the abnormal state;
[0079] determining a second current detection interval length of the at least one path device in the abnormal state according to the second detection time mean, the second number and the second scale factor.
[0080] The scale factor is used to adjust the length of the rest time according to the device state. The detection time of the device in the normal state is shorter, so a larger scale factor (such as 1000) is used to make the rest time longer, thereby reducing the detection frequency; the detection time of the device in the abnormal state is longer, so a smaller scale factor (such as 10) is used to make the rest time shorter, thereby increasing the detection frequency of abnormal recovery.
[0081] Specifically, different scale factors can be tried in a production environment or a test environment, and the following indicators can be monitored: state update delay: the time from device recovery to detection; CPU usage: the impact of thread running frequency on CPU; system stability: avoiding thread starvation caused by too short rest time. Adjust one scale factor at a time, observe the effect, and record the results, and use a feedback loop to optimize the value. For example, if the recovery delay of the device in the abnormal state is too high, gradually reduce the scale factor (such as from 10 to 5) until the delay is acceptable. If the detection of the device in the normal state occupies too many resources, gradually increase the scale factor (such as from 1000 to 1500).
[0082] When the device state of the path device is first distinguished, the device state of all path devices is considered to be the normal state.
[0083] The time mean can be calculated by the following formula: wherein, represents the mean value of the i-th state, i is 1 and 2, 1 represents the normal state, and 2 represents the abnormal state, represents the j-th sampling value of the i-th state, and n is the number of samples.
[0084] Specifically, according to the data in Table 2, the mean value can be calculated as shown in Table 3:
[0085] Table 3
[0086]
[0087] The detection time of the normal state is 2.49 ms, and the detection time of the abnormal state is 58.39 s.
[0088] Specifically, the first current detection interval length can be calculated by the following formula: first current detection interval length = first number × first detection time mean × first proportion factor. For example, assuming that the current first number is 8, the first detection time mean is 2.49 ms, and the first proportion factor is 1000, the first current detection interval length = 8 × 2.49 × 1000 = 19.92 s.
[0089] Specifically, the second current detection interval length can be calculated by the following formula: second current detection interval length = second number × second detection time mean × second proportion factor. For example, assuming that the current second number is 8, the first detection time mean is 58.39 ms, and the second proportion factor is 10, the second current detection interval length = 8 × 58.39 × 10 = 4.67 s.
[0090] In an embodiment, when the detection time fluctuates greatly, the percentile can be used instead of the mean to avoid the influence of outliers.
[0091] In this way, when the detection time is long and the number of devices is large, the interval can be appropriately extended to avoid the detection task itself becoming a performance bottleneck of the system, ensuring smooth operation of the main business, and when the detection time is short and the number of devices is small, the interval can be appropriately shortened to obtain the system state more frequently without consuming too many resources, thereby achieving "on-demand allocation" of computing resources and network resources, significantly improving overall resource utilization efficiency and reducing operating costs; improving the detection frequency of path devices in abnormal state and improving the abnormal response speed.
[0092] In an embodiment, a cost parameter can also be collected, the cost parameter including a detection cost, a cost of undetected abnormality (such as device downtime loss, safety risk), and a cost of undetected recovery, a cost model is constructed, and the minimum cost rate is solved by a numerical method (such as gradient descent) according to the cost model, thereby dynamically adjusting the current detection interval length. The detection cost is the resource (such as time, energy, labor cost) consumed by each detection; the cost of undetected abnormality is the loss (such as production loss, safety risk) caused per unit of time when the device is abnormal but not detected in time; and the cost of undetected recovery is the opportunity cost (such as production revenue loss) caused per unit of time when the device has recovered but not detected in time.
[0093] In some specific embodiments, according to the current detection interval length, the state of the path device in different device states is detected by a plurality of detection threads to determine the user-mode detection result of at least one path device, including:
[0094] According to a preset interval duration, at least one link component in the link corresponding to the path device is detected by the first detection thread to obtain a first detection result;
[0095] According to the first current detection interval duration, at least one path device in a normal state is detected by the second detection thread to obtain a second detection result;
[0096] According to the second current detection interval duration, at least one path device in an abnormal state is detected by the third detection thread to obtain a third detection result;
[0097] According to the first detection result, the second detection result and the third detection result, a user mode detection result is obtained.
[0098] The current detection interval duration is the rest time after detecting all path devices corresponding to the thread.
[0099] The first detection result, the second detection result and the third detection result influence each other.
[0100] In an embodiment, when multiple threads simultaneously modify the state of the same path device, a state conflict occurs. This can be solved by creating a mutex, multiple threads acquiring the mutex, determining the priority of the multiple threads, and when multiple threads simultaneously request to modify the state of the same device, the lock mechanism allocates permissions according to the priority. Before each state modification, the device ID, the original state and the target state are recorded to a memory log queue, and if a thread crashes (such as a detection logic exception) when modifying the state, other threads restore the original state through the log.
[0101] The granularity of the lock is device level, which does not affect the detection of other devices, and a timeout time for acquiring the lock is set to avoid deadlock.
[0102] The priority of the first detection thread is first, the priority of the third detection thread is second, and the priority of the second detection thread is third.
[0103] Specifically, if the first detection thread and the second detection thread simultaneously compete for the device sdb, the first detection thread acquires the lock first.
[0104] In this way, the lock mechanism and the priority strategy can solve the problem of concurrent state modification and ensure the robustness of the system.
[0105] In this way, the multi-thread detection architecture through responsibility separation and dynamic frequency adjustment realizes the optimization balance of monitoring efficiency and system overhead.
[0106] In some embodiments, according to a preset interval duration, at least one link component in the link corresponding to the path device is detected by the first detection thread to obtain a first detection result, including:
[0107] The at least one link component in the link is detected in sequence;
[0108] In response to the existence of at least one link component in an abnormal state, at least one path device corresponding to the link component is determined, and the device state of the at least one path device is synchronized to the abnormal state.
[0109] The preset interval duration is a fixed duration, which can be 1 second.
[0110] Specifically, for the FC card, detection can be performed through a physical indicator light, an operating system internal check, or a special management tool. The operating system internal check can include checking whether the FC card is recognized, whether the port state is online, and whether there are related errors of the FC card in the kernel log through a command.
[0111] Specifically, for the switch, detection can be performed through a physical indicator light, a switch command line interface, or a switch web management interface. The switch command line interface can include checking the port state and the error counter of the port (such as signal loss, coding error, link error, etc.) through a command.
[0112] Specifically, the controller can be detected through a physical indicator light or storage management software. The checking content of the storage management software can include system event logs, host port states, host connectivity, etc.
[0113] Specifically, the optical fiber can be detected through physical inspection. This can include optical power measurement, link inspection, visual inspection, etc.
[0114] Specifically, assuming that the link components in the system include controller 0, controller 1, switch 0, switch 1, FC card 0, and FC card 1, controller 0, controller 1, switch 0, switch 1, FC card 0, and FC card 1 are detected in sequence.
[0115] Specifically, when it is detected that the FC card 0 is in an abnormal state, the states of the path devices using the FC card 0 are all set to the abnormal state; when it is detected that there is a switch 0 in an abnormal state, the states of the path devices using the switch 0 are all set to the abnormal state; when it is detected that there is a controller 0 in an abnormal state, the states of the path devices using the controller 0 are all set to the abnormal state; when it is detected that there is an optical fiber line 0 in an abnormal state, the states of the path devices using the optical fiber line 0 are all set to the abnormal state.
[0116] For example, according to Table 1, if FC card 0 is in an abnormal state, the device states of sdb, sdc, sdd, sde, sdj, sdk, sdl, and sdm are all modified to be abnormal states; if switch 0 is in an abnormal state, the device states of sdb, sdc, sdf, sdg, sdj, sdk, sdn, and sdo are all modified to be abnormal states; and if controller 0 is in an abnormal state, the device states of sdb, sdd, sdf, sdh, sdj, sdl, sdn, and sdp are all modified to be abnormal states.
[0117] In this way, the number of detection tasks to be performed is greatly reduced, and network bandwidth, computing resources, and detection time are saved.
[0118] In some embodiments, according to a first current detection interval, at least one path device in a normal state is detected by a second detection thread to obtain a second detection result, including:
[0119] In response to the device state of the path device in the normal state not changing, the device state of the path device is maintained as the normal state;
[0120] In response to the device state of the path device in the normal state changing to an abnormal state, the device state of the path device is modified to be the abnormal state;
[0121] The path device whose device state is modified to be the abnormal state is detected to determine that the abnormal component type is a link component or a device component;
[0122] In response to the abnormal component type being the device component, the device state of the path device is modified to be the abnormal state.
[0123] Specifically, when it is detected that the path device maintains the normal state, the status quo is maintained; when it is detected that the path device is abnormal, the state thereof is set to be abnormal, and the abnormal component type is further subdivided; when the abnormal component type is a link component (i.e., a common error), all path devices related to the abnormal link component are set to be abnormal states according to the abnormal link component; and when the device is abnormal, no further processing is required. The device abnormality can include a medium error, a disk damage, a read / write error, and data inconsistency.
[0124] In some embodiments, according to a second current detection interval, at least one path device in an abnormal state is detected by a third detection thread to obtain a third detection result, including:
[0125] In response to the device state of the path device in the abnormal state not changing, the device state of the path device is maintained as the abnormal state;
[0126] When the device state of the path device in response to the abnormal state changes to the normal state, the device state of the path device is modified to the normal state.
[0127] Specifically, when it is detected that the path device maintains the abnormal state, the status quo is maintained; when it is detected that the path device changes to the normal state, the state thereof is set to the normal state, and no other operation is performed.
[0128] In some embodiments, the at least one target path device corresponding to the link component is determined, and the device state of the at least one target path device is synchronized to the abnormal state, including:
[0129] According to the link component in the abnormal state, at least one link corresponding to the link component in the abnormal state is determined;
[0130] According to the at least one link corresponding to the link component, at least one target path device corresponding to the at least one link is determined, and the device state of the at least one target path device is determined to be the abnormal state.
[0131] Specifically, as shown in Table 1, it is assumed that the FC card 0 is in the abnormal state, and the link including the FC card 0, i.e., the link of sdb, sdc, sdd, sde, sdj, sdk, sdl, and sdm, is obtained, and the states of sdb, sdc, sdd, sde, sdj, sdk, sdl, and sdm are determined to be the abnormal state.
[0132] Specifically, as shown in Table 1, sdb and sdj belong to the same link “FC card 0----Switch 0----Controller 0”. As can be seen, when any one of the FC card, the switch, and the controller on the link fails, the entire link is unavailable, and the states of sdb and sdj become the abnormal state.
[0133] In some embodiments, the method further includes:
[0134] In response to the existence of the input / output request, a processing result of at least one path device in the normal state is obtained;
[0135] In response to the processing result of the path device in the normal state being normal completion, the device state of the path device is maintained to be the normal state, and a kernel state detection result is obtained;
[0136] In response to the processing result of the path device in the normal state being abnormal completion, the device state of the path device is updated to be the abnormal state;
[0137] The path device updated to be the abnormal state is detected, and the abnormal component type is determined to be a link component or a device component, and a kernel state detection result is obtained.
[0138] Here, the kernel state is a high-privilege, trusted CPU (Central Processing Unit) execution state of an operating system kernel. When the CPU is in the kernel state, the code being executed can unrestrictedly access all hardware resources and memory space of the entire computer system, and can execute all instructions in the CPU instruction set.
[0139] Among them, the operating system running state is generally divided into user state and kernel state, which belong to two different privilege levels and have different execution permissions. When an application needs to perform some privileged operations or interact with the operating system, it needs to switch from the user state to the kernel state through the system call.
[0140] Among them, the path device that keeps the state and the path device that changes the state are obtained to obtain the kernel state detection result.
[0141] Specifically, when the I / O on a certain path device is normally completed, that is, it can be normally read and written, and returns success, the path device keeps the current state, that is, the normal state; when the I / O on a certain path device is not normally completed, that is, it cannot be normally read and written, or returns an error, the state of the path device is set to an abnormal state, and an abnormal component is determined.
[0142] For example, as shown in Table 1, if the I / O on the path device sdb returns an FC card error, then sdc, sdd, sde, sdj, sdk, sdl, and sdm are all set to failed.
[0143] In this way, the method of refreshing the path device state by means of the I / O completion result instead of active detection realizes near-zero-delay fault perception and near-zero-extra-resource-consumption ultimate efficiency, can timely reflect the abnormality at the business level, and avoids the false appearance of "the device is normal but the business has been interrupted".
[0144] In some specific embodiments, the method further comprises:
[0145] In response to the state modification existing in the user state detection result, the state modification is synchronized to the kernel state detection result;
[0146] In response to the state modification existing in the kernel state detection result, the state modification is synchronized to the user state detection result.
[0147] Among them, for the user state, the state modification can include modifying the normal state to the abnormal state and modifying the abnormal state to the normal state, and for the kernel state, the state modification includes modifying the normal state to the abnormal state.
[0148] Specifically, after the kernel state modifies the path device in normal state to abnormal state, it needs to be synchronized to the user state; correspondingly, after the user state modifies the path device in normal state to abnormal state or modifies the path device in abnormal state to normal state, it needs to be synchronized to the kernel state.
[0149] In this way, the efficient synchronization of the state modification of the path device between the user state and the kernel state can guarantee the consistency and reliability of the system control over the path device, and avoid the abnormal behavior of the path device or the system crash caused by the state difference.
[0150] In one embodiment, Figure 2 For the multi-path architecture in the embodiments of the present application, as shown in the figure, Figure 2 The multi-path architecture in the present application includes: virtual disk 1, controller 0, controller 1, switch 0, switch 1, FC card 0, FC card 1 and SCSI protocol, and the path device includes path device 1, path device 2, path device 3, path device 4, path device 5, path device 6, path device 7 and path device 8.
[0151] It should be understood that, although Figure 1 and 2 the flowcharts in the steps are displayed in sequence according to the arrows, these steps are not necessarily executed in sequence according to the arrows. Unless otherwise specified herein, the execution of these steps has no strict order limitation, and these steps can be executed in other orders. Moreover, Figure 1 and 2 at least part of the steps can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with other steps or at least part of the sub-steps or stages of other steps.
[0152] From the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases the former is a better embodiment.
[0153] The embodiment of the application further provides a path device state detection device, which comprises: a first processing module 301, configured to scan to obtain at least one volume mapped to a host, and determine at least one path device according to the at least one volume, wherein one path device corresponds to one link; a second processing module 302, configured to collect historical detection data in a preset period through a sliding window, and determine a current detection interval duration corresponding to different device states in combination with a device state, a number of path devices and a proportion factor, wherein the device state comprises a normal state and an abnormal state; a third processing module 303, configured to perform state detection on path devices in different device states through a plurality of detection threads according to the current detection interval duration, and determine a user state detection result of the at least one path device, wherein the user state detection result comprises the device state and an abnormal component type, and the abnormal component type comprises a link component and a device component; and a fourth processing module 304, configured to determine at least one target path device corresponding to the link component in response to the abnormal component type of the path device being the link component, and synchronize the device state of the at least one target path device to the abnormal state.
[0154] As a preferred implementation, in the embodiment of the application, the first processing module 301 is specifically configured to: log in to the host to obtain a port identifier in the host; log in to the storage system to create the host and create at least one volume according to the port identifier; map the at least one volume to the host; and scan to obtain the at least one volume mapped to the host by re-logging in to the host, and determine the at least one path device according to the at least one volume.
[0155] As a preferred implementation, in the embodiment of the application, the second processing module 302 is specifically configured to: obtain a first historical detection time consumption of the at least one path device in the normal state and / or a second historical detection time consumption of the at least one path device in the abnormal state in a preset period through a sliding window; and determine a first current detection interval duration and a second current detection interval duration of the at least one path device according to the first historical detection time consumption, the second historical detection time consumption, the number of path devices and the proportion factor.
[0156] As a preferred implementation, in the embodiment of the present application, the second processing module 302 is specifically further configured to: select an initial scaling factor; perform a test loop according to the initial scaling factor and collect index data, wherein the index includes state update delay, central processing unit usage rate and system stability; obtain a first scaling factor corresponding to the path device in the normal state and a second scaling factor corresponding to the path device in the abnormal state; obtain the number of path devices, and according to the device state of the path device, determine the first number of path devices in the normal state and the second number of path devices in the abnormal state; calculate the first detection time consumption average of at least one path device in the normal state according to the first historical detection time consumption of at least one path device in the normal state; determine the first current detection interval time length of at least one path device in the normal state according to the first detection time consumption average, the first number and the first scaling factor; calculate the second detection time consumption average of at least one path device in the abnormal state according to the second historical detection time consumption of at least one path device in the abnormal state; and determine the second current detection interval time length of at least one path device in the abnormal state according to the second detection time consumption average, the second number and the second scaling factor.
[0157] As a preferred implementation, in the embodiment of the present application, the third processing module 303 is specifically configured to: according to the preset interval time length, detect at least one link component in the link corresponding to the path device through the first detection thread to obtain a first detection result; according to the first current detection interval time length, detect at least one path device in the normal state through the second detection thread to obtain a second detection result; according to the second current detection interval time length, detect at least one path device in the abnormal state through the third detection thread to obtain a third detection result; and obtain the user mode detection result according to the first detection result, the second detection result and the third detection result.
[0158] As a preferred implementation, in the embodiment of the present application, the third processing module 303 is specifically further configured to: detect the at least one link component in the link in turn; in response to the existence of at least one link component in the abnormal state, determine at least one path device corresponding to the link component, and synchronize the device state of at least one path device to the abnormal state.
[0159] As a preferred implementation, in the embodiment of the present application, the third processing module 303 is specifically further configured to: in response to the device state of the path device in the normal state not changing, keeping the device state of the path device as the normal state; in response to the device state of the path device in the normal state changing to the abnormal state, modifying the device state of the path device to the abnormal state; detecting the path device whose device state is modified to the abnormal state, determining the abnormal component type as the link component or the device component; in response to the abnormal component type being the device component, modifying the device state of the path device to the abnormal state.
[0160] As a preferred implementation, in the embodiment of the present application, the third processing module 303 is specifically further configured to: in response to the device state of the path device in the normal state not changing, keeping the device state of the path device as the normal state; in response to the device state of the path device in the normal state changing to the abnormal state, modifying the device state of the path device to the abnormal state; detecting the path device whose device state is modified to the abnormal state, determining the abnormal component type as the link component or the device component; in response to the abnormal component type being the device component, modifying the device state of the path device to the abnormal state.
[0161] As a preferred implementation, in the embodiment of the present application, the device further comprises a fifth processing module, which is specifically configured to: in response to the existence of an input / output request, obtaining the processing result of at least one path device in the normal state; in response to the processing result of the path device in the normal state being normal completion, keeping the device state of the path device as the normal state to obtain the kernel state detection result; in response to the processing result of the path device in the normal state being not normal completion, updating the device state of the path device to the abnormal state; detecting the path device updated to the abnormal state, determining the abnormal component type as the link component or the device component to obtain the kernel state detection result.
[0162] The features of the embodiment of the path device state detection device can be referred to the related description of the embodiment of the path device state detection method, which will not be repeated here.
[0163] The embodiment of the present application further provides an electronic device, comprising a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above path device state detection method embodiments.
[0164] The electronic device can be a server, and its internal structure diagram can be as shown in Figure 4The computer device includes a processor, a memory, a network interface and a database connected by a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to store path equipment state detection data. The network interface of the computer device is configured to communicate with an external terminal through a network connection. The computer program is configured to be executed by the processor to implement a path equipment state detection method.
[0165] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program. The computer program is configured to perform the steps in any of the path equipment state detection method embodiments when executed by a processor.
[0166] In an example embodiment, the computer readable storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0167] The embodiments of the present application also provide a computer program product, which includes a computer program. The computer program is configured to perform the steps in any of the path equipment state detection method embodiments when executed by a processor.
[0168] The embodiments of the present application also provide another computer program product, which includes a non-volatile computer readable storage medium. The non-volatile computer readable storage medium stores a computer program. The computer program is configured to perform the steps in any of the path equipment state detection method embodiments when executed by a processor.
[0169] Those skilled in the art will further appreciate that the functions implemented by particular examples described herein can be implemented in electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various examples can be described generally in terms of their functionality, without limitation to the particular examples described. Skilled persons can implement particular examples with different hardware and software configurations without departing from the scope of the present application. Skilled persons can also implement an example described herein as a combination of hardware and software without departing from the scope of the present application.
[0170] The above describes in detail a path device state detection method, an electronic device, a storage medium, and a computer program product provided by the present application. The principles and implementation manners of the present application are described by applying specific examples in this paper, and the above description of the embodiments is only applicable to help understand the method of the present application and its core idea. It should be pointed out that, for those skilled in the art, without departing from the principles of the present application, the present application can be improved and modified in several ways, and these improvements and modifications also fall within the protection scope of the present application.
Claims
1. A method of detecting a state of a path device, characterized by, The method comprises: scanning to obtain at least one volume mapped to a host, determining at least one path device according to the at least one volume, wherein the one path device corresponds to one link; acquiring historical detection data in a preset period through a sliding window, combining device states, the number of path devices and a proportion factor to determine current detection interval durations corresponding to different device states, wherein the device states include a normal state and an abnormal state; performing state detection on path devices in different device states through multiple detection threads according to the current detection interval durations to determine user state detection results of the at least one path device, wherein the user state detection results include device states and abnormal component types, and the abnormal component types include link components and device components; in response to the abnormal component type of the path device being a link component, determining at least one target path device corresponding to the link component, and synchronizing the device state of the at least one target path device to an abnormal state.
2. The path equipment state detection method according to claim 1, characterized by, The scanning to obtain at least one volume mapped to a host, and determining at least one path device according to the at least one volume, comprises: logging in a host to obtain a port identifier in the host; logging in a storage system to create a host and at least one volume according to the port identifier; mapping the at least one volume to the host; re-logging in the host to scan to obtain at least one volume mapped to a host, and determining at least one path device according to the at least one volume.
3. The path equipment state detection method according to claim 1, characterized by, The acquiring historical detection data in a preset period through a sliding window, combining device states, the number of path devices and a proportion factor to determine current detection interval durations corresponding to different device states, comprises: acquiring, through a sliding window, a first historical detection time consumption of the at least one path device in a normal state and / or a second historical detection time consumption of the at least one path device in an abnormal state in a preset period; determining a first current detection interval duration and a second current detection interval duration of the at least one path device according to the first historical detection time consumption, the second historical detection time consumption, the proportion factor and the number of path devices.
4. The path equipment state detection method according to claim 3, characterized by, The determining a first current detection interval duration and a second current detection interval duration of the at least one path device according to the first historical detection time consumption, the second historical detection time consumption, the proportion factor and the number of path devices, comprises: selecting an initial proportion factor; performing a test loop according to the initial proportion factor and acquiring index data, wherein the indexes include state update delay, central processing unit usage and system stability; analyzing the index data and optimizing the proportion factor according to an analysis result to obtain a first proportion factor corresponding to path devices in a normal state and a second proportion factor corresponding to path devices in an abnormal state; acquiring the number of path devices, and determining a first number of path devices in a normal state and a second number of path devices in an abnormal state according to device states of the path devices; According to the first historical detection time of at least one path device in a normal state, a first detection time average of the at least one path device in the normal state is calculated; According to the first detection time average, the first quantity and the first scale factor, a first current detection interval length of the at least one path device in the normal state is determined; According to the second historical detection time of at least one path device in an abnormal state, a second detection time average of the at least one path device in the abnormal state is calculated; According to the second detection time average, the second quantity and the second scale factor, a second current detection interval length of the at least one path device in the abnormal state is determined.
5. The path equipment state detection method according to claim 4, characterized by, According to the current detection interval length, state detection of path devices in different device states is performed by a plurality of detection threads to determine a user state detection result of the at least one path device, including: According to a preset interval length, at least one link component in a link corresponding to the path device is detected by a first detection thread to obtain a first detection result; According to the first current detection interval length, at least one path device in the normal state is detected by a second detection thread to obtain a second detection result; According to the second current detection interval length, at least one path device in the abnormal state is detected by a third detection thread to obtain a third detection result; According to the first detection result, the second detection result and the third detection result, the user state detection result is obtained.
6. The path equipment state detection method according to claim 5, characterized by, According to the preset interval length, at least one link component in a link corresponding to the path device is detected by a first detection thread to obtain a first detection result, including: The at least one link component in the link is detected in sequence; In response to at least one link component being in an abnormal state, at least one path device corresponding to the link component is determined, and the device state of the at least one path device is synchronized to the abnormal state.
7. The path equipment state detection method according to claim 5, characterized by, According to the first current detection interval length, at least one path device in the normal state is detected by a second detection thread to obtain a second detection result, including: In response to the device state of the path device in the normal state not changing, the device state of the path device is kept as the normal state; In response to the device state of the path device in the normal state changing to the abnormal state, the device state of the path device is modified to the abnormal state; The path device whose device state is modified to the abnormal state is detected to determine an abnormal component type as a link component or a device component; In response to the abnormal component type being the device component, the device state of the path device is modified to the abnormal state.
8. The path equipment state detection method according to claim 5, characterized by, According to the second current detection interval length, at least one path device in the abnormal state is detected by a third detection thread to obtain a third detection result, including: In response to the device state of the path device in the abnormal state not changing, the device state of the path device is kept as the abnormal state; In response to the device state of the path device in the abnormal state changing to the normal state in response to the abnormal state, the device state of the path device is modified to the normal state.
9. The path equipment state detection method of claim 1, wherein, The method further comprises: In response to the existence of an input / output request, a processing result of at least one path device in the normal state is obtained; In response to the processing result of the path device in the normal state being a normal completion, the device state of the path device is maintained as the normal state, and a kernel state detection result is obtained; In response to the processing result of the path device in the normal state being an abnormal completion, the device state of the path device is updated to the abnormal state; The path device updated to the abnormal state is detected, and the abnormal component type is determined to be a link component or a device component, and a kernel state detection result is obtained.
10. An electronic device, comprising: Comprise: A memory for storing a computer program; A processor for executing the computer program to implement the steps of the path device state detection method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Path scanning for the detection of anomalous subgraphs, anomaly / change detection and network situational awareness
CN104303153A
Multi-path equipment detection method and device, equipment and storage medium
CN115202580A