Physical volume access method and device, computer device and storage medium
By storing a mapping file between volume groups and physical volumes in the memory file system, the required physical volume can be quickly accessed using the volume group identification information, thus solving the problem of slow LVM command execution and improving efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZTE CORP
- Filing Date
- 2023-02-22
- Publication Date
- 2026-05-15
AI Technical Summary
In a Linux environment, the LVM command needs to scan and query all block devices in the system, resulting in long execution time and high access pressure, which affects execution efficiency.
The mapping relationship file between volume groups and physical volumes is stored in the memory file system. The mapping relationship file in the memory file system can be quickly accessed through the volume group identification information of LVM commands, and only the required physical volumes are accessed, reducing the number of accesses to system block devices.
It improves the efficiency of physical volume access and LVM command execution, and reduces the time spent accessing physical volumes.
Smart Images

Figure CN118568013B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of disk storage, and more particularly to a physical volume access method, apparatus, computer device, and storage medium. Background Technology
[0002] Logical Volume Manager (LVM) is a mechanism for managing disk partitions in Linux environments. Using LVM, users can adjust the usage of individual disk partitions without system downtime, and it also solves many problems related to the inflexibility of disk partition size adjustment, enabling more rational allocation and use of disk space. LVM commands parse LVM metadata to understand how logical volumes (LVs) are built on top of physical volumes (PVs), and then instruct the Linux kernel to create the corresponding mapping device object for the logical volume. However, executing LVM commands requires scanning and querying all block devices in the system. Therefore, the more block devices the system has, the longer the time consumed by directly accessing block devices for read and write operations, and the greater the access pressure on the physical volume, resulting in slow LVM command execution and slow return of results. Therefore, improving the execution efficiency of LVM commands is a pressing issue that needs to be addressed. Summary of the Invention
[0003] This invention provides a physical volume access method, apparatus, computer device, and storage medium, aiming to improve the execution efficiency of LVM commands.
[0004] In a first aspect, embodiments of the present invention provide a physical volume access method, including:
[0005] Based on the first identifier information of the volume group in the currently executed LVM command, the second identifier information of the physical volume involved in executing the LVM command is obtained from the mapping relationship file stored in the memory file system. 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] Secondly, embodiments of the present invention also provide a physical volume access device, comprising:
[0008] The acquisition module is used to obtain 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, based on the first identification information of the volume group in the currently executed LVM command. The mapping relationship file is used to describe the mapping relationship between the volume group and the physical volume.
[0009] The access module is used to access the physical volume corresponding to the second identification information.
[0010] Thirdly, embodiments of the present invention also provide a computer device, the computer device including a processor, a memory, a computer program stored in the memory and executable by the processor, and a data bus for implementing connection communication between the processor and the memory, wherein when the computer program is executed by the processor, it implements the physical volume access method as described in the first aspect.
[0011] Fourthly, embodiments of the present invention also provide a storage medium for computer-readable storage, the storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the physical volume access method as described in the first aspect.
[0012] This invention provides a physical volume access method, apparatus, computer device, and storage medium. In this embodiment, the mapping relationship file between volume groups and physical volumes is stored in a memory file system. When executing an LVM command, the mapping relationship file in the memory file system can be quickly accessed based on the first identifier information of the volume group in the LVM command. This allows for the rapid acquisition of the second identifier information of the physical volume involved in executing the LVM command from the mapping relationship file. Furthermore, only the physical volume corresponding to the obtained second identifier information is accessed; that is, access is only performed on the physical volume involved in executing the LVM command. This effectively reduces the number of times the LVM command accesses block devices in the system, reduces the time required to access physical volumes, and greatly improves the access efficiency of physical volumes and the execution efficiency of LVM commands. Attached Figure Description
[0013] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 This is a flowchart illustrating a physical volume access method provided in an embodiment of the present invention;
[0015] Figure 2 This is a schematic diagram of the directory hierarchy of the mapping relationship files in an embodiment of the present invention;
[0016] Figure 3 This is a flowchart illustrating another physical volume access method provided in an embodiment of the present invention;
[0017] Figure 4This is a flowchart illustrating another physical volume access method provided in an embodiment of the present invention;
[0018] Figure 5 This is another schematic diagram of the directory hierarchy of the mapping relationship files in this embodiment of the invention;
[0019] Figure 6 This is yet another schematic diagram of the directory hierarchy structure of the mapping relationship files in an embodiment of the present invention;
[0020] Figure 7 This is a schematic block diagram of a physical volume access device provided in an embodiment of the present invention;
[0021] Figure 8 This is a schematic block diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.
[0024] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0025] Logical Volume Manager (LVM) is a mechanism for managing disk partitions in Linux environments. Using LVM, users can adjust the usage of each disk partition without system downtime, and it also solves many problems related to the inflexibility of disk partition size adjustment, enabling more rational allocation and use of disk space. LVM commands parse LVM metadata to understand how logical volumes (LVs) are built on top of physical volumes (PVs), and then instruct the Linux kernel to create the corresponding mapping device object for the logical volume. However, executing LVM commands requires scanning and querying all block devices in the system. Therefore, the more block devices the system has, the longer the time consumed by directly accessing block devices for read and write operations, and the greater the access pressure on the physical volume, resulting in slow LVM command execution and slow return of results.
[0026] To address the aforementioned problems, embodiments of the present invention provide a physical volume access method, apparatus, computer device, and storage medium. In these embodiments, the mapping relationship file between volume groups and physical volumes is stored in a memory file system. Thus, when executing an LVM command, the mapping relationship file in the memory file system can be quickly accessed based on the first identifier information of the volume group in the LVM command. This allows for the rapid acquisition of the second identifier information of the physical volume involved in executing the LVM command from the mapping relationship file. Furthermore, only the physical volume corresponding to the obtained second identifier information is accessed; that is, access is only performed on the physical volume involved in executing the LVM command. This effectively reduces the number of times the LVM command accesses block devices in the system, reduces the time required to access physical volumes, and significantly improves the access efficiency of physical volumes and the execution efficiency of LVM commands.
[0027] This physical volume access method can be applied to computer devices to improve the efficiency of computer devices accessing physical volumes through LVM. The computer device can include any of the following: mobile phone, camera, tablet, wearable device, in-vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop, personal computer (PC), netbook, personal digital assistant (PDA), and server. The server can be a standalone server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms.
[0028] The following detailed description of some embodiments of the present invention is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0029] Please see Figure 1 , Figure 1 This is a flowchart illustrating a physical volume access method provided in 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: Based on 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 lowest level in the Logical Volume Manager (LVM). It can be a partition on an actual physical hard drive or an entire physical hard drive. A Volume Group (VG) is built on top of a Physical Volume. A Volume Group includes at least one Physical Volume, and Physical Volumes can be dynamically added to the Volume Group after it is created. The Logical Volume Management System can include one Volume Group or multiple Volume Groups.
[0033] LVM commands are commands that control the Logical Volume Manager (LVM) to perform related operations. These LVM commands are triggered by upper-layer applications. For example, LVM commands can be commands related to physical volumes, volume groups, or logical volumes. Commands related to physical volumes can include lvmdiskscan, pvcreate, pvs, pvscan, pvdisplay, pvchange, or pvmove, etc. Commands related to volume groups can include vgcreate, vgs, vgscan, vgdisplay, vgrename, vgchange, vgmove, vgextend, or vgreduce, etc. Commands related to logical volumes can include lvcreate, lvs, lvscan, lvdisplay, lvchange, lvextend, or lvreduce, etc.
[0034] Among them, the memory file system is a memory-based file system where the directory resides in memory, not on disk. This allows for quick lookup of the mapping relationship between volume groups and physical volumes. Memory file systems include at least one of the following: tmpfs (temporary file system), ramfs (random access memory-based file system), shmfs (shared memory file system), and hugetlbfs (huge page-based memory file system). Before using a memory file system, it can be mounted to a preset directory in memory. After mounting, the memory file system can provide higher file read / write and access efficiency, improving performance. For example, mounting tmpfs to the / dev / shm directory in memory.
[0035] In this embodiment, the mapping relationship file is a mapping relationship file between volume groups and physical volumes. This mapping relationship file describes the mapping relationship between volume groups and physical volumes. The mapping relationship file includes first identification information of the volume group, second identification information of the physical volume, and the mapping relationship between the first and second identification information (i.e., the mapping relationship between the volume group and the physical volume). The first identification information of the volume group is used to uniquely identify the volume group; the first identification information can be the name of the volume group or the volume group number. The second identification information of the physical volume is used to uniquely identify the physical volume; the second identification information can include the name of the physical volume or it can include the name and access path of the physical volume. If a mapping relationship file exists in the memory file system, the second identification information of the physical volume involved in executing LVM commands can be queried from this mapping relationship file using the first identification information.
[0036] In some embodiments, the mapping file between volume groups and physical volumes is stored as a linked list. Storing the mapping file in memory as a linked list allows for quick retrieval of the second identification information of the physical volumes involved in executing LVM commands. For example, as... Figure 2 As shown, tmpfs is mounted in the top-level directory / dev / shm. The / dev / shm directory stores the mapping relationship file between volume groups and physical volumes. This 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 volume A and physical volume B) and the mapping relationship between VG_B and PV_C and PV_D (the mapping relationship between volume group B and physical volume C and physical volume D). The / dev / shm / VG_A directory stores the physical volume linked list corresponding to VG_A (volume group A). This 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 directory / dev / shm / VG_B stores a physical volume list corresponding to VG_B (volume group B). This physical volume 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 accessed quickly 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, and greatly improve the access efficiency of the physical volume and the execution efficiency of the LVM command.
[0040] For example, assuming the first identifier is VG_B, the mapping file between volume groups and physical volumes is as follows: Figure 2As shown, when executing an LVM command containing VG_B, the physical volume list corresponding to VG_B can be found in the / dev / shm / VG_B directory of the memory file system. The physical volume list corresponding to VG_B includes the name and access path (PV_Name_C_Path_C) of physical volume C and the name and access path (PV_Name_C_Path_C) of physical volume D. 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 executing an LVM command containing VG_B, physical volume C can be quickly accessed through its name and access path, and physical volume D can be quickly accessed through its name and access path.
[0041] In some embodiments, such as Figure 3 As shown, the procedure before step S101 also includes:
[0042] Step S103: If 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 a mapping relationship file between a volume group and a physical volume exists in the memory file system can be as follows: if the currently executed LVM command includes the first identifier information of the volume group, determine whether a mapping relationship file between a volume group and a physical volume exists in a preset directory, and the memory file system is mounted in the preset directory; if a mapping relationship file between a volume group and a physical volume exists in the preset directory, determine that a mapping relationship file between a volume group and a physical volume exists in the memory file system; if a mapping relationship file between a volume group and a physical volume exists in the preset directory, determine that a mapping relationship file between a volume group and a physical volume does not exist in the memory file system.
[0044] Step S104: If there is no mapping relationship file 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] In the absence of a mapping relationship file between volume groups and physical volumes in the memory file system, a mapping relationship file is generated and stored in the memory file system. In the presence of a mapping relationship file in the memory file system, step S101 is executed, which obtains 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 based on the first identification information of the volume group in the currently executed LVM command, and then accesses the physical volume corresponding to the second identification information. This greatly improves the execution efficiency of LVM commands and the access efficiency of physical volumes.
[0046] In some embodiments, the method for generating the mapping relationship file between volume groups and physical volumes can be as follows: Scan all block devices to obtain the status identifiers of each block device; for each block device, if the status identifier is a first preset identifier, determine that the block device is a physical volume in a Logical Volume Manager (LVM); if the status identifier is a second preset identifier, determine that the block device is not a physical volume in a Logical Volume Manager (LVM); obtain the second identifier information of each determined physical volume, and determine the first identifier information of the volume group to which the physical volume belongs; generate the mapping relationship file between volume groups and physical volumes based on the determined second identifier information of each physical volume and the first identifier information of the volume group to which each physical volume belongs. The first and second preset identifiers can be set based on actual conditions, and this embodiment of the invention does not specifically limit their settings.
[0047] In some embodiments, such as Figure 4 As shown, the procedure before step S101 also includes:
[0048] Step S105: If 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 the first identifier is VG_B, the mapping file between volume groups and physical volumes is as follows: Figure 2 As shown, when executing an LVM command containing VG_B, in the case of... Figure 2 The mapping file shown is used to check if a physical volume list corresponding to VG_B exists, while... Figure 2 The mapping file shown can be used to find the physical volume linked list corresponding to VG_B. This physical volume linked list includes the name and access path (PV_Name_C_Path_C) of physical volume C and the name and access path (PV_Name_C_Path_C) of physical volume D.
[0050] For example, assuming the first identifier is VG_B, the mapping file between volume groups and physical volumes is as follows: Figure 5 As shown, when executing an LVM command containing VG_B, in the case of... Figure 5 The mapping file shown is used to check if a physical volume list corresponding to VG_B exists, while... Figure 5 The mapping file shown does not contain a physical volume list corresponding to VG_B, meaning the second identifier information of the physical volume corresponding to VG_B cannot be found.
[0051] Step S106: If the second identifier information of the physical volume involved in executing the LVM command is not found according to the first identifier 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.
[0052] In this embodiment, if the second identification information of the physical volume involved in executing the LVM command is not found, it can be known that the current mapping file is incorrect. By regenerating the mapping file between the volume group and the physical volume and replacing the current mapping file in the memory file system with the regenerated mapping file, the incorrect mapping file can be corrected. This makes it easier to quickly query the physical volume involved in executing the LVM command through the correct mapping file when executing the LVM command in the future, thereby improving the access efficiency of the physical volume and the execution efficiency of the LVM command.
[0053] In some embodiments, if the second identification information of the physical volume involved in executing the LVM command is found 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 the first identifier is VG_B, the mapping file between volume groups and physical volumes is as follows: Figure 5 As shown, when executing an LVM command containing VG_B, VG_B cannot be used in the following way: Figure 5 The mapping file shown retrieves the physical volume list corresponding to VG_B. In this case, the mapping file between the volume group and the physical volume is regenerated. The regenerated mapping file between the volume group and the physical volume is as follows: Figure 6 As shown, when executing an LVM command containing VG_B, the result can be obtained based on VG_B, such as... Figure 6 The mapping file shown yields the physical volume list corresponding to VG_B. The physical volume 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 volume groups and physical volumes can be regenerated as follows: if the second identifier information of the physical volume involved in executing the LVM command is not found based on the first identifier information, the status information of each physical volume is obtained; if the status information of each physical volume determines that each physical volume is in an active state, the mapping relationship file between volume groups and physical volumes is regenerated. Specifically, if the status information of a physical volume is the first status information, it can be determined that the physical volume is in an active state; if the status information of a 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 volume groups and physical volumes when it is determined that each physical volume is in an active state, i.e., there are no inaccessible or lost physical volumes, it can be ensured that the generated mapping relationship file contains all the mapping relationships between volume groups and physical volumes in the system. This facilitates the quick querying of the physical volume involved in executing the LVM command using the correct mapping relationship file, improving the access efficiency of physical volumes and the execution efficiency of LVM commands.
[0056] In some embodiments, the method for regenerating the mapping relationship file between volume groups and physical volumes can be as follows: if the second identifier information of the physical volume involved in executing the LVM command is not found based on the first identifier information, obtain the status information of each physical volume; if at least one physical volume is determined to be in a lost state based on the status information of each physical volume, obtain the status information of at least one physical volume at a preset interval; if the status of at least one physical volume changes from a lost state to an active state based on the status information of at least one physical volume, regenerate the mapping relationship file between volume groups and physical volumes. The preset interval can be set based on actual conditions, and this embodiment of the invention does not specifically limit it; for example, the preset interval is 5 seconds. By periodically obtaining the status information of a lost physical volume when it is determined that the physical volume is in a lost state, and regenerating the mapping relationship file between volume groups and physical volumes when it is determined that the physical volume's status changes from a lost state to an active state, it can be ensured that the generated mapping relationship file can contain the mapping relationships between all volume groups and physical volumes in the system. This facilitates the quick query of the physical volume involved in executing the LVM command using the correct mapping relationship file when executing the LVM command, improving the access efficiency of physical volumes and the execution efficiency of LVM commands.
[0057] For example, if only physical volume A is missing out of all physical volumes, the status information of physical volume A can be obtained after 5 seconds. If the status information of physical volume A indicates that physical volume A is still missing, the status information of physical volume A can be obtained again after 5 seconds. If the status information of physical volume A indicates that the missing state of physical volume A has changed to an active state, the mapping relationship file between volume group and physical volume can be regenerated.
[0058] The physical volume access method provided in the above embodiments, since the mapping relationship file between volume groups and physical volumes is stored in the memory file system, can quickly access the mapping relationship file in the memory file system based on the first identification information of the volume group in the LVM command when executing the LVM command. This allows for the rapid acquisition of the second identification information of the physical volume involved in executing the LVM command from the mapping relationship file, and access is only performed on the physical volume corresponding to the acquired second identification information. In other words, access is only performed on the physical volume involved in executing the LVM command. This effectively reduces the number of times the LVM command accesses block devices in the system, reduces the time required to access the physical volume, and greatly improves the access efficiency of the physical volume and the execution efficiency of the LVM command.
[0059] Please see Figure 7 , Figure 7 This is a schematic block diagram of a physical volume access device provided in 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 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, based on the first identification information of the volume group in the currently executed LVM command. The mapping relationship file is used to describe the mapping relationship between the volume group and the physical volume.
[0062] 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] The determination module is used to determine whether a mapping relationship file between a volume group and a physical volume exists in the memory file system, provided that 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 volume groups and physical volumes when the mapping relationship file does not exist in the memory file system, and to store the generated mapping relationship file between volume groups and physical volumes in the memory file system.
[0067] In one embodiment, the physical volume access device 200 further includes:
[0068] The query module is used to query, based on the first identification information, 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, when the currently executed LVM command includes the first identification information of the volume group.
[0069] The file generation module is further configured to regenerate the mapping relationship file between the volume group and the physical volume if the second identification information of the physical volume involved in executing the LVM command is not found 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 newly generated mapping relationship file.
[0071] In one embodiment, the file generation module is further configured to:
[0072] If the second identifier information of the physical volume involved in executing the LVM command is not found based on the first identifier information, the status information of each physical volume is obtained;
[0073] If each physical volume is confirmed to be active based on its status information, the mapping file between the volume group and the physical volume is regenerated.
[0074] In one embodiment, the file generation module is further configured to:
[0075] If at least one physical volume is determined to be lost based on the status information of each physical volume, the status information of the at least one physical volume is acquired at preset intervals.
[0076] If the status of the at least one physical volume changes from a lost state to an active state based on the status information of the at least one physical volume, the 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 hugeetlbfs.
[0078] It should be noted that those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the device and each module and unit described above can be referred to the corresponding processes in the aforementioned fraud identification method embodiments, and will not be repeated here.
[0079] The apparatus provided in the above embodiments can be implemented as a computer program, which can be used in, for example... Figure 8 It runs on the computer device shown.
[0080] Please see Figure 8 , Figure 8 This is a schematic block diagram of the structure of a computer device provided in an embodiment of the present invention.
[0081] like Figure 8 As shown, the computer device 300 includes a processor 301 and a memory 302, which are connected via a bus 303, such as an I2C (Inter-integrated Circuit) bus.
[0082] Specifically, processor 301 provides computing and control capabilities to support the operation of the entire computer device. Processor 301 can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0083] Specifically, the memory 302 can be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a portable hard drive, etc.
[0084] Those skilled in the art will understand that Figure 8 The structures shown are merely block diagrams of some structures related to the embodiments of the present invention, and do not constitute a limitation on the computer devices on which the embodiments of the present invention are applied. Specific computer devices may include more or fewer components than those shown in the figures, or combine certain components, or have different component arrangements.
[0085] The processor 301 is used to run a computer program stored in the memory 302, and implements any of the physical volume access methods provided in the embodiments of the present invention when executing the computer program.
[0086] In one embodiment, the processor 301 is configured to run a computer program stored in a memory, and to perform the following steps when executing the computer program:
[0087] Based on the first identifier information of the volume group in the currently executed LVM command, the second identifier information of the physical volume involved in executing the LVM command is obtained from the mapping relationship file stored in the memory file system. 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 the processor 301 obtains the second identification information of the physical volume involved in executing the LVM command from a mapping file stored in the memory file system based on the first identification information of the volume group in the currently executed LVM command, it is further configured to:
[0091] If the currently executed LVM command includes the first identification information of the volume group, determine whether there is a mapping file between the volume group and the physical volume in the memory file system;
[0092] If 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 stored in the memory file system.
[0093] In one embodiment, before the processor 301 obtains the second identification information of the physical volume involved in executing the LVM command from a mapping file stored in the memory file system based on the first identification information of the volume group in the currently executed LVM command, it is further configured to:
[0094] If the currently executed LVM command includes the first identification information of the volume group, the second identification information of the physical volume involved in executing the LVM command is queried from the mapping relationship file stored in the memory file system based on the first identification information.
[0095] If the second identifier information of the physical volume involved in executing the LVM command is not found based on the first identifier 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 the processor 301 regenerates the mapping relationship file between the volume group and the physical volume, it is configured to:
[0097] If the second identifier information of the physical volume involved in executing the LVM command is not found based on the first identifier information, the status information of each physical volume is obtained;
[0098] If each physical volume is confirmed to be active based on its status information, the mapping file between the volume group and the physical volume is regenerated.
[0099] In one embodiment, after acquiring the status information of each physical volume, the processor 301 is further configured to:
[0100] If at least one physical volume is determined to be lost based on the status information of each physical volume, the status information of the at least one physical volume is acquired at preset intervals.
[0101] If the status of the at least one physical volume changes from a lost state to an active state based on the status information of the at least one physical volume, the 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 hugeetlbfs.
[0103] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the computer device described above can be referred to the corresponding process in the aforementioned physical volume access method embodiments, and will not be repeated here.
[0104] This invention also provides a storage medium for computer-readable storage, wherein the storage medium stores one or more programs that can be executed by one or more processors to implement any of the physical volume access methods provided in the specification of this invention.
[0105] The storage medium can be an internal storage unit of the computer device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device.
[0106] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware embodiments, the division between 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 collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media 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 technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0107] It should be understood that the term "and / or" as used in this specification and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations. It should be noted that, herein, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0108] The sequence numbers of the above embodiments of the present invention are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. The above descriptions are only specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for accessing a physical volume, characterized in that, include: If the currently executed LVM command includes the first identification information of the volume group, the second identification information of the physical volume involved in executing the LVM command is queried from the mapping relationship file stored in the memory file system based on the first identification information. If the second identifier information of the physical volume involved in executing the LVM command is not found according to the first identifier 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. Based on the first identifier information of the volume group in the currently executed LVM command, the second identifier information of the physical volume involved in executing the LVM command is obtained from the mapping relationship file stored in the memory file system. 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 based on the first identification information of the volume group in the currently executed LVM command, the method further includes: If the currently executed LVM command includes the first identification information of the volume group, determine whether there is a mapping file between the volume group and the physical volume in the memory file system; If 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 stored in the memory file system.
4. The physical volume access method according to claim 1, characterized in that, The process of regenerating the mapping file between volume groups and physical volumes includes: If the second identifier information of the physical volume involved in executing the LVM command is not found based on the first identifier information, the status information of each physical volume is obtained; If each physical volume is confirmed to be active based on its status information, the mapping file between the volume group and the physical volume is regenerated.
5. The physical volume access method according to claim 4, characterized in that, After obtaining the status information of each physical volume, the process also includes: If at least one physical volume is determined to be lost based on the status information of each physical volume, the status information of the at least one physical volume is acquired at preset intervals. If the status of the at least one physical volume changes from a lost state to an active state based on the status information of the at least one physical volume, the mapping relationship file between the volume group and the physical volume is regenerated.
6. The physical volume access method according to any one of claims 1-3, characterized in that, The memory file system includes at least one of tmpfs, ramfs, shmfs, and hugeetlbfs.
7. A physical volume access device, characterized in that, include: The determination module is configured to, when the currently executed LVM command includes first identification information of a volume group, query second identification information of the physical volume involved in executing the LVM command from a mapping relationship file stored in the memory file system, based on the first identification information; The file generation module is used to regenerate the 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 found according to the first identification information, and replace the current mapping relationship file in the memory file system with the regenerated mapping relationship file. The acquisition module is used to obtain 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, based on the first identification information of the volume group in the currently executed LVM command. The mapping relationship file is used to describe the mapping relationship between the volume group and the physical volume. The access module is used to access the physical volume corresponding to the second identification information.
8. 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 implementing communication between the processor and the memory, wherein when the computer program is executed by the processor, it implements the steps of the physical volume access method as described in any one of claims 1 to 6.
9. A storage medium for computer-readable storage, characterized in that, The storage medium stores one or more programs, which 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 6.