Physical volume access method and device, computer equipment and storage medium
By storing the mapping relationship files between volume groups and physical volumes in the memory file system, we can quickly obtain and access related physical volumes, which solves the problem of low LVM command execution efficiency and significantly improves the efficiency of physical volume access and LVM command execution.
Patent Information
- Application Number
- CN202310191319.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-22
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2043-02-22
AI Technical Summary
When using Logical Volume Manager (LVM), the more block devices in the system, the longer it takes to directly access the block devices for reading and writing, resulting in slow execution of LVM commands and slow return of execution results.
Store the mapping relationship file between the volume group and the physical volume in the memory file system. Quickly access the mapping relationship file through the volume group identification information in the LVM command, obtain the identification information of the physical volume and only access the relevant physical volume, reducing the need for blocks. The number of visits to the device.
It effectively reduces the time required for physical volume access and greatly improves the access efficiency of physical volumes and the execution efficiency of LVM commands.
Smart Images

Figure CN118568013A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of disk storage, and in particular to a physical volume access method, device, computer equipment and storage medium. Background Art
[0002] Logical Volume Manager (LVM) is a mechanism for managing disk partitions in Linux environment. When using LVM, users can adjust the usage of each disk partition without stopping the system, and can also solve many problems that the size of disk partitions cannot be flexibly adjusted, and can allocate and use disk space more reasonably. LVM commands learn how logical volumes (LV) are established on physical volumes (PV) by parsing LVM metadata, and then notify the Linux kernel to establish a mapping device object corresponding to the logical volume. However, executing LVM commands requires scanning and querying all block devices in the system. Therefore, if there are more block devices in the system, the time consumed by directly accessing block devices for reading and writing will be longer, and the access pressure of reading and writing on the physical volume will be greater, resulting in slow execution of LVM commands and slow return of execution results. Therefore, how to improve the execution efficiency of LVM commands is an urgent problem to be solved. Summary of the invention
[0003] The embodiments of the present invention provide a physical volume access method, apparatus, computer equipment and storage medium, aiming to improve the execution efficiency of LVM commands.
[0004] In a first aspect, an embodiment of the present invention provides a physical volume access method, comprising:
[0005] According to the first identification information of the volume group in the currently executed LVM command, obtaining the second identification information of the physical volume involved in executing the LVM command from a mapping relationship file stored in the memory file system, wherein the mapping relationship file is used to describe the mapping relationship between the volume group and the physical volume;
[0006] Access the physical volume corresponding to the second identification information.
[0007] In a second aspect, an embodiment of the present invention further provides a physical volume access device, including:
[0008] An acquisition module, configured to obtain, according to first identification information of a volume group in a currently executed LVM command, second identification information of a physical volume involved in executing the LVM command from a mapping relationship file stored in a memory file system, wherein the mapping relationship file is used to describe a mapping relationship between a volume group and a physical volume;
[0009] An access module is used to access the physical volume corresponding to the second identification information.
[0010] In a third aspect, an embodiment of the present invention further provides a computer device, comprising a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the physical volume access method described in the first aspect is realized.
[0011] In a fourth aspect, an embodiment of the present invention further provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the physical volume access method as described in the first aspect.
[0012] The embodiment of the present invention provides a physical volume access method, device, computer equipment and storage medium. The mapping relationship file between the volume group and the physical volume in the embodiment of the present invention is stored in the memory file system. In this way, when executing an LVM command, according to the first identification information of the volume group in the LVM command, the mapping relationship file in the memory file system can be quickly accessed to quickly obtain the second identification information of the physical volume involved in the execution of the LVM command from the mapping relationship file, and only the physical volume corresponding to the obtained second identification information is accessed, that is, only the physical volume involved in the execution of the LVM command is accessed, so that the number of times the LVM command accesses the block device in the system can be effectively reduced, the time required for accessing the physical volume is reduced, and the access efficiency of the physical volume and the execution efficiency of the LVM command are greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] 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 will be briefly introduced below. Obviously, the drawings described below are 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 work.
[0014] Figure 1 It is a flow chart of a physical volume access method provided by an embodiment of the present invention;
[0015] Figure 2 is a schematic diagram of the directory hierarchy structure of the mapping relationship file in an embodiment of the present invention;
[0016] Figure 3 It is a flowchart of another physical volume access method provided by an embodiment of the present invention;
[0017] Figure 4It is a flowchart of another physical volume access method provided by an embodiment of the present invention;
[0018] Figure 5 is another schematic diagram of the directory hierarchy structure of the mapping relationship file in an embodiment of the present invention;
[0019] Figure 6 is another schematic diagram of the directory hierarchy structure of the mapping relationship file in the embodiment of the present invention;
[0020] Figure 7 is a schematic block diagram of a physical volume access device provided by an embodiment of the present invention;
[0021] Figure 8 It is a schematic block diagram of the structure of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0024] It should be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0025] The Logical Volume Manager (LVM) is a mechanism for managing disk partitions in the Linux environment. When using LVM, users can adjust the usage of each disk partition without stopping the system, and can also solve many problems that the disk partition size cannot be flexibly adjusted, and can allocate and use disk space more reasonably. The LVM command parses the LVM metadata to learn how the logical volume (LV) is established on the physical volume (PV), and then notifies the Linux kernel to establish a mapping device object corresponding to the logical volume. However, executing LVM commands requires scanning and querying all block devices in the system. Therefore, if the system has more block devices, the time consumed by directly accessing the block devices for reading and writing will be longer, and the access pressure on the physical volume for reading and writing will be greater, resulting in slow execution of LVM commands and slow return of execution results.
[0026] To solve the above problems, an embodiment of the present invention provides a physical volume access method, device, computer equipment and storage medium. The mapping relationship file between the volume group and the physical volume in the embodiment of the present invention is stored in the memory file system, so that when executing the LVM command, according to the first identification information of the volume group in the LVM command, the mapping relationship file in the memory file system can be quickly accessed to quickly obtain the second identification information of the physical volume involved in the execution of the LVM command from the mapping relationship file, and only access the physical volume corresponding to the obtained second identification information, that is, only access the physical volume involved in the execution of the LVM command, so that the number of times the LVM command accesses the block device in the system can be effectively reduced, the time required to access the physical volume is reduced, and the access efficiency of the physical volume and the execution efficiency of the LVM command are greatly improved.
[0027] The physical volume access method can be applied to a computer device to improve the efficiency of the computer device accessing a physical volume through an LVM. The computer device may include a mobile phone, a camera, a tablet computer, a wearable device, an in-vehicle device, an augmented reality (AR) / virtual reality (VR) device, a laptop, a personal computer (PC), a netbook, a personal digital assistant (PDA), and a server. The server may be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0028] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0029] See also Figure 1 , Figure 1 It is a flow chart of a physical volume access method provided by an embodiment of the present invention.
[0030] like Figure 1 As shown, the physical volume access method includes steps S101 to S102.
[0031] Step S101: According to the first identification information of the volume group in the currently executed LVM command, obtain the second identification information of the physical volume involved in executing the LVM command from the mapping relationship file stored in the memory file system.
[0032] In this embodiment, the physical volume (PV) is at the bottom layer in the logical volume manager (LVM). It can be a partition on an actual physical hard disk or the entire physical hard disk. A volume group (VG) is established on the physical volume. The volume group includes at least one physical volume. After the volume group is established, a physical volume can be dynamically added to the volume group. The logical volume management system can include one volume group or multiple volume groups.
[0033] The LVM command is a command for controlling the logical volume manager (Logical Volume Manager, LVM) to perform related operations, and the LVM command is triggered by an upper layer application. For example, the LVM command may be a command for related operations including physical volumes, commands for related operations of volume groups, or commands for related operations of logical volumes. The commands for related operations of physical volumes may include lvmdiskscan, pvcreate, pvs, pvscan, pvdisplay, pvchange, or pvmove, etc., the commands for related operations of volume groups may include vgcreate, vgs, vgscan, vgdisplay, vgrename, vgchange, vgmove, vgextend, or vgreduce, etc., and the commands for related operations of logical volumes may include lvcreate, lvs, lvscan, lvdisplay, lvchange, lvextend, or lvreduce, etc.
[0034] Among them, the memory file system is a file system based on memory. The directory of the memory file system is placed in the memory, not in the disk. In this way, the mapping relationship file between the volume group and the physical volume can be quickly queried through the memory file system. The memory file system includes at least one of tmpfs (temporary file system), ramfs (file system based on random access memory), shmfs (shared memory file system) and hugetlbfs (memory file system based on huge pages). Before using the memory file system, the memory file system can be mounted to a preset directory in the memory. After mounting the memory file system, the memory file system can provide higher file reading, writing and access efficiency, and improve performance. For example, mount tmpfs to the / dev / shm directory of the memory.
[0035] In this embodiment, the mapping relationship file is a mapping relationship file between a volume group and a physical volume, and the mapping relationship file is used to describe the mapping relationship between the volume group and the physical volume. The mapping relationship file includes the first identification information of the volume group, the second identification information of the physical volume, and the mapping relationship between the first identification information and the second identification information (i.e., the mapping relationship between the volume group and the physical volume). Among them, the first identification information of the volume group is used to uniquely identify the volume group, and the first identification information can be the name of the volume group or the number of the volume group. The second identification information of the physical volume is used to uniquely identify the physical volume, and the second identification information can include the name of the physical volume or the second identification information can include the name and access path of the physical volume. In the case where the mapping relationship file exists in the memory file system, the second identification information of the physical volume involved in executing the LVM command can be queried from the mapping relationship file through the first identification information.
[0036] In some embodiments, the mapping relationship file between the volume group and the physical volume is stored in the form of a linked list. The mapping relationship file between the volume group and the physical volume is stored in the memory in the form of a linked list, so that the second identification information of the physical volume involved in executing the LVM command can be quickly obtained through the linked list. For example, Figure 2 As shown, tmpfs is mounted on the top-level directory / dev / shm, and the mapping relationship file between volume groups and physical volumes is stored in the / dev / shm directory, and the mapping relationship file includes the mapping relationship between VG_A and PV_A and PV_B (the mapping relationship between volume group A and physical volumes A and B) and the mapping relationship between VG_B and PV_C and PV_D (the mapping relationship between volume group B and physical volumes C and D). The physical volume linked list corresponding to VG_A (volume group A) is stored in the / dev / shm / VG_A directory, and the physical volume linked list includes PV_Name_A_Path_A and PV_Name_B_Path_B, which means that volume group A corresponds to physical volume A and physical volume B, and the access path of physical volume A is Path_A, and the access path of physical volume B is Path_B. Similarly, the physical volume linked list corresponding to VG_B (volume group B) is stored in the directory / dev / shm / VG_B. The physical volume linked list includes PV_Name_C_Path_C and PV_Name_C_Path_C, which means that volume group B corresponds to physical volume C and physical volume D, and the access path of physical volume C is Path_C, and the access path of physical volume D is Path_D.
[0037] Step S102: Access the physical volume corresponding to the second identification information.
[0038] In this embodiment, after obtaining the second identification information of the physical volume involved in executing the LVM command, the access path of the physical volume involved in executing the LVM command can be obtained through the second identification information, and the physical volume involved in executing the LVM command can be accessed through the access path.
[0039] In one embodiment, the second identification information includes the name and access path of the physical volume involved in executing the LVM command. When the name and access path of the physical volume involved in executing the LVM command are obtained, the physical volume can be quickly accessed through the name and access path of the physical volume, which can effectively reduce the number of times the LVM command accesses the block device in the system, greatly improving the access efficiency of the physical volume and the execution efficiency of the LVM command.
[0040] For example, assuming that the first identification information is VG_B, the mapping relationship file between the volume group and the physical volume is as follows: Figure 2As shown, when the LVM command containing VG_B is executed, the physical volume linked list corresponding to VG_B can be found in the directory / dev / shm / VG_B of the memory file system. The physical volume linked list corresponding to VG_B includes the name and access path of physical volume C (PV_Name_C_Path_C) and the name and access path of physical volume D (PV_Name_C_Path_C). Volume group B corresponds to physical volume C and physical volume D, and the access path of physical volume C is Path_C, and the access path of physical volume D is Path_D. In this way, when the LVM command containing VG_B is executed, physical volume C can be quickly accessed through the name and access path of physical volume C, and physical volume D can be quickly accessed through the name and access path of physical volume D.
[0041] In some embodiments, Figure 3 As shown, before step S101, the following steps are also included:
[0042] Step S103: When the currently executed LVM command includes the first identification information of the volume group, determine whether there is a mapping relationship file between the volume group and the physical volume in the memory file system.
[0043] In this embodiment, the method for determining whether there is a mapping relationship file between the volume group and the physical volume in the memory file system can be: when the currently executed LVM command includes the first identification information of the volume group, determining whether there is a mapping relationship file between the volume group and the physical volume in a preset directory, and the memory file system is mounted in the preset directory; when there is a mapping relationship file between the volume group and the physical volume in the preset directory, determining whether there is a mapping relationship file between the volume group and the physical volume in the memory file system; when there is a mapping relationship file between the volume group and the physical volume in the preset directory, determining that there is no mapping relationship file between the volume group and the physical volume in the memory file system.
[0044] Step S104: if no mapping relationship file exists in the memory file system, generate a mapping relationship file between the volume group and the physical volume, and store the generated mapping relationship file between the volume group and the physical volume in the memory file system.
[0045] When there is no mapping relationship file between the volume group and the physical volume in the memory file system, a mapping relationship file is generated and stored in the memory file system. When there is a mapping relationship file in the memory file system, step S101 is executed, that is, according to the first identification information of the volume group in the currently executed LVM command, the second identification information of the physical volume involved in the execution of the LVM command is obtained from the mapping relationship file stored in the memory file system, and then the physical volume corresponding to the second identification information is accessed, thereby greatly improving the execution efficiency of the LVM command and the access efficiency of the physical volume.
[0046] In some embodiments, the method of generating a mapping relationship file between a volume group and a physical volume can be: scanning all block devices to obtain the status identifier of each block device; for each block device, when the status identifier of the block device is a first preset identifier, determining that the block device is a physical volume in a logical volume manager (Logical Volume Manager, LVM), and when the status identifier of the block device is a second preset identifier, determining that the block device is not a physical volume in a logical volume manager (Logical Volume Manager, LVM); obtaining the second identification information of each determined physical volume, and determining the first identification information of the volume group to which the physical volume belongs; generating a mapping relationship file between a volume group and a physical volume based on the second identification information of each determined physical volume and the first identification information of the volume group to which each physical volume belongs. Among them, the first preset identifier and the second preset identifier can be set based on actual conditions, and the embodiment of the present invention does not specifically limit this.
[0047] In some embodiments, Figure 4 As shown, before step S101, the following steps are also included:
[0048] Step S105: When the currently executed LVM command includes the first identification information of the volume group, query the second identification information of the physical volume involved in executing the LVM command from the mapping relationship file stored in the memory file system according to the first identification information.
[0049] For example, assuming that the first identification information is VG_B, the mapping relationship file between the volume group and the physical volume is as follows: Figure 2 As shown, when executing the LVM command containing VG_B, Figure 2 In the mapping relationship file shown in the figure, check whether there is a physical volume linked list corresponding to VG_B. Figure 2 The physical volume linked list corresponding to VG_B can be queried in the mapping relationship file shown, and the physical volume linked list includes the name and access path of physical volume C (PV_Name_C_Path_C) and the name and access path of physical volume D (PV_Name_C_Path_C).
[0050] For another example, assuming that the first identification information is VG_B, the mapping relationship file between the volume group and the physical volume is as follows: Figure 5 As shown, when executing the LVM command containing VG_B, Figure 5 In the mapping relationship file shown in the figure, check whether there is a physical volume linked list corresponding to VG_B. Figure 5 The physical volume linked list corresponding to VG_B is not found in the mapping relationship file shown, that is, the second identification information of the physical volume corresponding to VG_B cannot be found.
[0051] Step S106: If the second identification information of the physical volume involved in executing the LVM command is not found according to the first identification information, regenerate the mapping relationship file between the volume group and the physical volume, and replace the current mapping relationship file in the memory file system with the regenerated mapping relationship file.
[0052] In this embodiment, when the second identification information of the physical volume involved in executing the LVM command is not queried, it can be known that there is an error in the current mapping relationship file. The erroneous mapping relationship file can be corrected by regenerating the mapping relationship file between the volume group and the physical volume, and replacing the current mapping relationship file in the memory file system with the regenerated mapping relationship file. This makes it convenient to quickly query the physical volume involved in executing the LVM command through the correct mapping relationship file when executing the LVM command later, thereby improving the access efficiency of the physical volume and the execution efficiency of the LVM command.
[0053] In some embodiments, when the second identification information of the physical volume involved in executing the LVM command is queried based on the first identification information, step S101 is executed, that is, based on the first identification information of the volume group in the currently executed LVM command, the second identification information of the physical volume involved in executing the LVM command is obtained from the mapping relationship file stored in the memory file system, and then the physical volume corresponding to the second identification information is accessed.
[0054] For example, assuming that the first identification information is VG_B, the mapping relationship file between the volume group and the physical volume is as follows: Figure 5 As shown in the figure, when executing the LVM command containing VG_B, VG_B cannot be Figure 5 The physical volume link table corresponding to VG_B is obtained by querying the mapping relationship file shown in the figure. In this case, the mapping relationship file between the volume group and the physical volume is regenerated. The mapping relationship file between the regenerated volume group and the physical volume is as follows Figure 6 As shown, when executing an LVM command involving VG_B, VG_B can be Figure 6 The physical volume linked list corresponding to VG_B is queried in the mapping relationship file shown. The physical volume linked list corresponding to VG_B includes the name and access path of physical volume C (PV_Name_C_Path_C) and the name and access path of physical volume D (PV_Name_C_Path_C).
[0055] In some embodiments, the mapping relationship file between the volume group and the physical volume can be regenerated in the following manner: when the second identification information of the physical volume involved in the execution of the LVM command is not queried according to the first identification information, the status information of each physical volume is obtained; when it is determined that each physical volume is in an activated state according to the status information of each physical volume, the mapping relationship file between the volume group and the physical volume is regenerated. Wherein, when the status information of the physical volume is the first status information, it can be determined that the physical volume is in an activated state, and when the status information of the physical volume is the second status information, it can be determined that the physical volume is in a lost state. By regenerating the mapping relationship file between the volume group and the physical volume when it is determined that each physical volume is in an activated state, that is, when there is no inaccessible or lost physical volume, it can be ensured that the generated mapping relationship file can contain the mapping relationship between all volume groups and physical volumes in the system, so that when the LVM command is executed later, the physical volume involved in the execution of the LVM command can be quickly queried through the correct mapping relationship file, thereby improving the access efficiency of the physical volume and the execution efficiency of the LVM command.
[0056] In some embodiments, the manner of regenerating the mapping relationship file between the volume group and the physical volume may be: when the second identification information of the physical volume involved in executing the LVM command is not queried according to the first identification information, the status information of each physical volume is obtained; when it is determined according to the status information of each physical volume that at least one physical volume is in a lost state, the status information of at least one physical volume is obtained at a preset interval; when it is determined according to the status information of at least one physical volume that the state of at least one physical volume changes from a lost state to an activated state, the mapping relationship file between the volume group and the physical volume is regenerated. Wherein, the preset interval time can be set based on actual conditions, and the embodiment of the present invention does not specifically limit this. For example, the preset interval time is 5 seconds. By periodically obtaining the status information of the physical volume in the lost state when it is determined that a physical volume is in a lost state, and when it is determined that the state of the physical volume changes from a lost state to an activated state, the mapping relationship file between the volume group and the physical volume is regenerated, it can be ensured that the generated mapping relationship file can contain all the mapping relationships between the volume groups and the physical volumes in the system, so that when the LVM command is subsequently executed, the physical volume involved in the execution of the LVM command can be quickly queried through the correct mapping relationship file, thereby improving the access efficiency of the physical volume and the execution efficiency of the LVM command.
[0057] For example, assuming that only physical volume A is in a lost state among all physical volumes, the status information of physical volume A can be obtained after 5 seconds. If it is determined based on the status information of physical volume A that physical volume A is still in a lost state, the status information of physical volume A can continue to be obtained after 5 seconds. If it is determined based on the status information of physical volume A that the lost state of physical volume A changes to an activated state, the mapping relationship file between the volume group and the physical volume can be regenerated.
[0058] The physical volume access method provided by the above embodiment, since the mapping relationship file between the volume group and the physical volume is stored in the memory file system, when executing the LVM command, according to the first identification information of the volume group in the LVM command, the mapping relationship file in the memory file system can be quickly accessed to quickly obtain the second identification information of the physical volume involved in the execution of the LVM command from the mapping relationship file, and only the physical volume corresponding to the obtained second identification information is accessed, that is, only the physical volume involved in the execution of the LVM command is accessed, which can effectively reduce the number of times the LVM command accesses the block device in the system, reduce the time required to access the physical volume, and greatly improve the access efficiency of the physical volume and the execution efficiency of the LVM command.
[0059] See also Figure 7 , Figure 7 It is a schematic block diagram of a physical volume access device provided by an embodiment of the present invention.
[0060] like Figure 7 As shown, the physical volume access device 200 includes:
[0061] The acquisition module 210 is used to obtain, according to the first identification information of the volume group in the currently executed LVM command, the second identification information of the physical volume involved in executing the LVM command from a mapping relationship file stored in the memory file system, wherein the mapping relationship file is used to describe the mapping relationship between the volume group and the physical volume;
[0062] The access module 220 is used to access the physical volume corresponding to the second identification information.
[0063] In one embodiment, the mapping relationship file is stored in the form of a linked list.
[0064] In one embodiment, the physical volume access device 200 further includes:
[0065] A determination module, used for determining whether there is a mapping relationship file between the volume group and the physical volume in the memory file system when the currently executed LVM command includes the first identification information of the volume group;
[0066] The file generation module is used to generate a mapping relationship file between the volume group and the physical volume when the mapping relationship file does not exist in the memory file system, and store the generated mapping relationship file between the volume group and the physical volume in the memory file system.
[0067] In one embodiment, the physical volume access device 200 further includes:
[0068] A query module, configured to query, when the currently executed LVM command includes first identification information of a volume group, second identification information of a physical volume involved in executing the LVM command from a mapping relationship file stored in a memory file system according to the first identification information;
[0069] The file generation module is further used to regenerate a mapping relationship file between the volume group and the physical volume when the second identification information of the physical volume involved in executing the LVM command is not queried according to the first identification information;
[0070] The file replacement module is used to replace the current mapping relationship file in the memory file system with the regenerated mapping relationship file.
[0071] In one embodiment, the file generation module is further used to:
[0072] If the second identification information of the physical volume involved in executing the LVM command is not found according to the first identification information, obtaining status information of each physical volume;
[0073] When it is determined according to the status information of each physical volume that each physical volume is in an activated state, a mapping relationship file between the volume group and the physical volume is regenerated.
[0074] In one embodiment, the file generation module is further used to:
[0075] When it is determined according to the status information of each physical volume that at least one physical volume is in a lost state, acquiring the status information of the at least one physical volume at a preset interval;
[0076] When it is determined according to the status information of the at least one physical volume that the status of the at least one physical volume changes from the lost status to the activated status, a mapping relationship file between the volume group and the physical volume is regenerated.
[0077] In one embodiment, the memory file system includes at least one of tmpfs, ramfs, shmfs and hugetlbfs.
[0078] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and each module and unit can refer to the corresponding process in the aforementioned fraud identification method embodiment, and will not be repeated here.
[0079] The apparatus provided in the above embodiment may be implemented in the form of a computer program. The computer program may be Figure 8 Runs on the computer device shown.
[0080] See also Figure 8 , Figure 8 It is a schematic block diagram of the structure of a computer device provided by an embodiment of the present invention.
[0081] like Figure 8 As shown, the computer device 300 includes a processor 301 and a memory 302 , and the processor 301 and the memory 302 are connected via a bus 303 , such as an I2C (Inter-integrated Circuit) bus.
[0082] Specifically, the processor 301 is used to provide computing and control capabilities to support the operation of the entire computer device. The processor 301 can be a central processing unit (CPU), and the processor 301 can also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0083] Specifically, the memory 302 may be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a mobile hard disk.
[0084] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the embodiment of the present invention, and does not constitute a limitation on the computer device to which the embodiment of the present invention is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0085] The processor 301 is used to run the computer program stored in the memory 302, and implement any one of the physical volume access methods provided by the embodiments of the present invention when executing the computer program.
[0086] In one embodiment, the processor 301 is used to run a computer program stored in the memory, and implement the following steps when executing the computer program:
[0087] According to the first identification information of the volume group in the currently executed LVM command, obtaining the second identification information of the physical volume involved in executing the LVM command from a mapping relationship file stored in the memory file system, wherein the mapping relationship file is used to describe the mapping relationship between the volume group and the physical volume;
[0088] Access the physical volume corresponding to the second identification information.
[0089] In one embodiment, the mapping relationship file is stored in the form of a linked list.
[0090] In one embodiment, before obtaining, from a mapping relationship file stored in a memory file system, second identification information of a physical volume involved in executing the LVM command according to first identification information of a volume group in the currently executed LVM command, the processor 301 is further configured to implement:
[0091] In a case where the currently executed LVM command includes the first identification information of the volume group, determining whether there is a mapping relationship file between the volume group and the physical volume in the memory file system;
[0092] In the case that the mapping relationship file does not exist in the memory file system, a mapping relationship file between the volume group and the physical volume is generated, and the generated mapping relationship file between the volume group and the physical volume is stored in the memory file system.
[0093] In one embodiment, before obtaining, from a mapping relationship file stored in a memory file system, second identification information of a physical volume involved in executing the LVM command according to first identification information of a volume group in the currently executed LVM command, the processor 301 is further configured to implement:
[0094] In a case where the currently executed LVM command includes first identification information of the volume group, querying second identification information of the physical volume involved in executing the LVM command from a mapping relationship file stored in the memory file system according to the first identification information;
[0095] If the second identification information of the physical volume involved in executing the LVM command is not found according to the first identification information, the mapping relationship file between the volume group and the physical volume is regenerated, and the current mapping relationship file in the memory file system is replaced with the regenerated mapping relationship file.
[0096] In one embodiment, when regenerating the mapping relationship file between the volume group and the physical volume, the processor 301 is used to implement:
[0097] If the second identification information of the physical volume involved in executing the LVM command is not found according to the first identification information, obtaining status information of each physical volume;
[0098] When it is determined according to the status information of each physical volume that each physical volume is in an activated state, a mapping relationship file between the volume group and the physical volume is regenerated.
[0099] In one embodiment, after obtaining the status information of each physical volume, the processor 301 is further configured to implement:
[0100] When it is determined according to the status information of each physical volume that at least one physical volume is in a lost state, acquiring the status information of the at least one physical volume at a preset interval;
[0101] When it is determined according to the status information of the at least one physical volume that the status of the at least one physical volume changes from the lost status to the activated status, a mapping relationship file between the volume group and the physical volume is regenerated.
[0102] In one embodiment, the memory file system includes at least one of tmpfs, ramfs, shmfs and hugetlbfs.
[0103] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the computer device described above can refer to the corresponding process in the aforementioned physical volume access method embodiment, and will not be repeated here.
[0104] An embodiment of the present invention further provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement any physical volume access method provided in the description of the embodiment of the present invention.
[0105] The storage medium may be an internal storage unit of the computer device described in the above embodiment, such as a hard disk or memory of the computer device. The storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device.
[0106] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware embodiment, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0107] It should be understood that the term "and / or" used in the present specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system including the element.
[0108] The serial numbers of the embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments. The above description is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A physical volume access method, characterized in that: include: According to the first identification information of the volume group in the currently executed LVM command, obtaining the second identification information of the physical volume involved in executing the LVM command from a mapping relationship file stored in the memory file system, wherein the mapping relationship file is used to describe the mapping relationship between the volume group and the physical volume; Access the physical volume corresponding to the second identification information.
2. The physical volume access method according to claim 1, characterized in that: The mapping relationship file is stored in the form of a linked list.
3. The physical volume access method according to claim 1, characterized in that: Before obtaining the second identification information of the physical volume involved in executing the LVM command from the mapping relationship file stored in the memory file system according to the first identification information of the volume group in the currently executed LVM command, the method further includes: In a case where the currently executed LVM command includes the first identification information of the volume group, determining whether there is a mapping relationship file between the volume group and the physical volume in the memory file system; In the case that the mapping relationship file does not exist in the memory file system, a mapping relationship file between the volume group and the physical volume is generated, and the generated mapping relationship file between the volume group and the physical volume is stored in the memory file system.
4. The physical volume access method according to any one of claims 1 to 3, characterized in that: Before obtaining the second identification information of the physical volume involved in executing the LVM command from the mapping relationship file stored in the memory file system according to the first identification information of the volume group in the currently executed LVM command, the method further includes: In a case where the currently executed LVM command includes first identification information of the volume group, querying second identification information of the physical volume involved in executing the LVM command from a mapping relationship file stored in the memory file system according to the first identification information; If the second identification information of the physical volume involved in executing the LVM command is not found according to the first identification information, the mapping relationship file between the volume group and the physical volume is regenerated, and the current mapping relationship file in the memory file system is replaced with the regenerated mapping relationship file.
5. The physical volume access method according to claim 4, characterized in that: The regenerating the mapping relationship file between the volume group and the physical volume includes: If the second identification information of the physical volume involved in executing the LVM command is not found according to the first identification information, obtaining status information of each physical volume; When it is determined according to the status information of each physical volume that each physical volume is in an activated state, a mapping relationship file between the volume group and the physical volume is regenerated.
6. The physical volume access method according to claim 5, characterized in that: After obtaining the status information of each physical volume, the method further includes: When it is determined according to the status information of each physical volume that at least one physical volume is in a lost state, acquiring the status information of the at least one physical volume at a preset interval; When it is determined according to the status information of the at least one physical volume that the status of the at least one physical volume changes from the lost status to the activated status, a mapping relationship file between the volume group and the physical volume is regenerated.
7. The physical volume access method according to any one of claims 1 to 3, characterized in that: The memory file system includes at least one of tmpfs, ramfs, shmfs and hugetlbfs.
8. A physical volume access device, characterized in that: include: An acquisition module, configured to obtain, according to first identification information of a volume group in a currently executed LVM command, second identification information of a physical volume involved in executing the LVM command from a mapping relationship file stored in a memory file system, wherein the mapping relationship file is used to describe a mapping relationship between a volume group and a physical volume; An access module is used to access the physical volume corresponding to the second identification information.
9. A computer device, characterized in that: The computer device includes a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the computer program is executed by the processor, the steps of the physical volume access method according to any one of claims 1 to 7 are realized.
10. A storage medium for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the physical volume access method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Hierarchical memory system and logical volume management method thereof
CN101840308A
Storage pool building method and system
CN106201357A
Method for storing file and mobile terminal
CN106775488A
Physical bare computer disk storage management method based on Go language
CN113312003A
Relaying storage operation requests to storage systems using underlying volume identifiers
CN113821298A
