Log operation method, device, storage medium and program product
By using the substrate management control system to convert storage addresses in the server, unified management of each system log is achieved, complex log collection and unbalanced erase writing are solved, and the normal operation and functional integrity of the system are ensured.
Patent Information
- Application Number
- CN202510705559.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-05-29
AI Technical Summary
The prior art cannot manage the logs generated by various systems in the server, resulting in complex and uneven number of erases in log collection, affecting the normal operation and function of the system.
By receiving log operation instructions from the target system, the substrate management control system is used to convert the storage address, convert the first storage address of the target log into the second storage address, and uniformly manage it according to the planning of the substrate management control system, and at the same time, the target system is allowed to generate operation instructions based on the first storage address.
It realizes unified management of each target system log, reduces the complexity of log collection, balances the number of erases, and ensures the integrity of system functions.
Smart Images

Figure CN120256247B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of server technology, and in particular to a log operation method, device, storage medium, and program product. Background Art
[0002] A server typically includes multiple systems with different functions, such as the Basic Input / Output System (BIOS), Baseboard Management Controller (BMC), backup and recovery system, and network security system. During system operation, logs are generated to record system status, error messages, and debugging information.
[0003] Currently, some technologies cannot uniformly manage the logs generated by various systems and need to be improved. Summary of the Invention
[0004] The present application provides a log operation method, a recovery method, a log operation device, a recovery device, an electronic device, a computer-readable storage medium, and a computer program product to at least solve the problem in the related art that logs generated by various systems cannot be uniformly managed.
[0005] This application provides a log operation method, which includes:
[0006] Receiving a log operation instruction sent by a target system, the log operation instruction is used to indicate a target log to be operated by the target system and a first storage address of the target log, the target log is a log generated by the target system, and the first storage address is a storage address planned by the target system for the target log;
[0007] converting the first storage address into a second storage address according to a first conversion logic, where the second storage address is a storage address planned by a baseboard management and control system for the target log, the baseboard management and control system being used to perform operation management on the log of at least one target system;
[0008] The target log is operated according to the second storage address.
[0009] The present application also provides a log operation device, the device comprising:
[0010] An instruction receiving module is configured to receive a log operation instruction sent by a target system, wherein the log operation instruction is used to indicate a target log to be operated by the target system and a first storage address of the target log, wherein the target log is a log generated by the target system, and the first storage address is a storage address planned by the target system for the target log;
[0011] an address conversion module, configured to convert the first storage address into a second storage address according to a first conversion logic, where the second storage address is a storage address planned by a baseboard management and control system for the target log, the baseboard management and control system being configured to perform operations and management on the log of at least one target system;
[0012] A log operation module is used to operate the target log according to the second storage address.
[0013] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned log operation methods when executing the computer program.
[0014] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned marking methods are implemented.
[0015] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned marking methods when executed by a processor.
[0016] In the technical solutions of some embodiments of the present application, on the one hand, when receiving the log operation instruction sent by the target system, the first storage address indicated by the log operation instruction is converted to the second storage address, so that the target log indicated by the log operation instruction can be uniformly managed according to the storage address planning of the baseboard management control system. On the other hand, based on the conversion function of the storage address, while the target log is uniformly managed according to the second storage address, the target system can still generate an operation instruction for the target log based on the first storage address, that is, it does not affect the log processing logic on the target system side. Based on the above two aspects, the technical solution of the present application can solve the problem in some technologies that the logs generated by each target system cannot be uniformly managed. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 Schematic diagram of log management for servers in some technologies;
[0019] Figure 2 Schematic diagram of log management for servers in other technologies;
[0020] Figure 3 A flowchart of a log operation method provided in some embodiments of the present application;
[0021] Figure 4 A schematic diagram of log storage partitions provided for some embodiments of the present application;
[0022] Figure 5 A schematic diagram of a module of a log operation device provided in some embodiments of the present application;
[0023] Figure 6 A schematic diagram of a module of an electronic device provided for some embodiments of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0025] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0026] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0027] See also Figure 1 , which is a schematic diagram of log management for servers in some technologies. Figure 1 In this example, systems 1-n refer to the various systems running on the server. For example, system 1 is the basic input / output system (BIOS), system 2 is the baseboard management and control system (BMS), and system n is the network security system. Systems 1-n are connected to memories 1-n in a one-to-one correspondence based on the SPI (Serial Peripheral Interface) protocol. Memories 1-n can be non-volatile memories, such as Flash. Each memory can be used to store the firmware and logs of the corresponding system. For example, memory 1 stores the firmware and logs of system 1, while memory 2 stores the firmware and logs of system 2.
[0028] In the program code of each system, log storage addresses can be pre-planned based on actual needs, meaning that each system can manage logs independently. For example, in the program code of system 1, log a generated by system 1 can be planned to be stored at storage address a1 of memory 1, and log b generated by system 1 can be stored at storage address b1 of memory 1. For another example, in the program code of system 2, log c generated by system 2 can be planned to be stored at storage address c1 of memory 2, and log d generated by system 2 can be stored at storage address d1 of memory 2.
[0029] exist Figure 1 In the log management method shown, on the one hand, each system manages logs independently, which is not convenient for unified management and collection of logs. For example, in order to monitor and manage each system, the baseboard management control system may need to collect logs of basic input and output systems, network security systems, etc. Figure 1 In the log management method shown, the baseboard management and control system needs to obtain the storage address planning logic of each system and, based on the storage address planning logic, collect logs from the storage devices connected to each system. It can be seen that the entire log collection process is relatively complex and time-consuming. On the other hand, the firmware and logs of each system are stored in the same memory, which will lead to the problem of uneven erase and write times in different storage areas of the same memory. For example, since logs are read and written more frequently and firmware is read and written less frequently, the log storage area will have more erase and write times and the firmware storage area will have fewer erase and write times in the log storage area and firmware storage area of the same memory. In this way, when the firmware storage area is not damaged, the log storage area may be damaged and the memory needs to be replaced.
[0030] See also Figure 2 , which is a schematic diagram of log management for servers in other technologies. Figure 2 In the example, the baseboard management and control system is connected to a log memory, and the baseboard management and control system and each system outside the baseboard management and control system are respectively connected to a firmware memory. The firmware memory is used to store the firmware of the connected system, and the log memory is used to store the logs of all systems.
[0031] Specifically, the baseboard management and control system can divide the log memory into multiple partitions, and each partition is used to save the log of one of the systems. For example, the log memory can be divided into partition 1, partition 2, ..., partition n. Among them, partition 1 is used to save the log of the baseboard management and control system, partition 2 is used to save the log of the basic input and output system, and so on. Other systems outside the baseboard management and control system (such as the basic input and output system, network security system) can send logs to the baseboard management and control system based on the ESPI (Enhanced Serial Peripheral Interface) protocol. The baseboard management and control system can plan the log storage address of each system, and save the logs generated by itself and the logs sent by other systems into the log memory according to the planned log storage address. In this way, the baseboard management and control system can uniformly manage the logs generated by each system, without having to collect logs from the storage connected to each system, thereby greatly reducing the complexity of log collection. In addition, Figure 2 In the scheme shown, since the logs of multiple systems are stored in different partitions of the log memory, and the system logs and firmware are stored in different memories, the number of erase and write times of each partition of the log memory can be relatively balanced, thereby avoiding Figure 1 The problem of uneven erase and write times in different partitions of the same memory is solved.
[0032] but, Figure 2 The solution shown still has some issues. For example, because the log storage address of each system is planned by the baseboard management and control system, systems other than the baseboard management and control system cannot obtain the accurate log storage address after sending logs to the baseboard management and control system. As a result, these systems cannot directly generate log operation instructions such as log read and write instructions and log delete instructions (because log operation instructions usually require the log storage address). In other words, these systems cannot perform log operations (such as log read, write, and delete) based on the log storage address, which limits the functionality of these systems.
[0033] In view of this, the present application provides a log operation method that can uniformly manage the logs generated by multiple systems and support each system to directly generate log operation instructions according to actual needs. The log operation method can be applied to a baseboard management control system, or can be applied to an electronic device that runs a baseboard management control system. The electronic device may include but is not limited to a baseboard management controller. In the method of the present application, the architectural relationship between the baseboard management control system and other systems can be the same as Figure 2 Similar, no further details will be given later.
[0034] See also Figure 3, which is a flowchart of the log operation method provided in some embodiments of the present application. Figure 3 In the log operation method, the following steps are included:
[0035] Step S301: Receive a log operation instruction sent by a target system. The log operation instruction is used to indicate the target log to be operated by the target system and the first storage address of the target log. The target log is a log generated by the target system, and the first storage address is the storage address planned by the target system for the target log.
[0036] For details, please refer to Figure 2 ,The target system refers to other systems besides the baseboard management and control system, ,such as basic input and output systems, network security systems, ,etc.
[0037] Log operation instructions may include but are not limited to log write instructions, log read instructions, log modification instructions, log deletion instructions, etc. A complete log operation instruction may include an operation keyword, log information of the target log, and a first storage address. The operation keyword is used to indicate the type of operation to be performed on the target log, such as write, read, modify, delete, etc. The log information is used to indicate the target log to be operated. In different types of log operation instructions, the log information may be different. For example, in a log write instruction, the log information may include the entity content of the target log, indicating that the log in the log operation instruction is saved in the log storage. In a log read instruction, the log information may include the size of the target log or the generation time of the target log, indicating that a log of a specified size or a specified generation time is read from the log storage. The first storage address refers to the log storage address planned for the target log according to the first address planning logic of the target system.
[0038] In this embodiment, the first storage address specifically refers to the starting storage address of the target log planned by the target system, that is, the target log is operated from the first storage address. For example, starting from the first storage address, the target log is sequentially saved to the log storage. For another example, starting from the first storage address, the content of a specified size is read as the target log.
[0039] For ease of understanding, the following examples illustrate log operation instructions. For example, a log write instruction can be expressed as write_log logM address1. Among them, write_log is the operation keyword, indicating a write operation, logM is the physical content of the target log to be saved, and address1 is the storage address planned by the target system for the target log logM. For another example, a log read instruction can be expressed as read_log 20250517 address2. Among them, read_log is the operation keyword, indicating a read operation, 20250517 is the log information, indicating reading the target log with a generation time of 20250517, and address2 is the storage address planned by the target system for the target log with a generation time of 20250517. It should be noted that the above logM, address1, 20250517, and address2 are only examples. When generating log operation instructions, replace logM, address1, 20250517, and address2 according to actual needs.
[0040] Furthermore, the log operation instruction may also include but is not limited to information such as the log level and the system identifier of the target system. Take the system identifier as an example. The baseboard management and control system can identify the log operation instructions sent by different target systems based on the system identifier. For example, the above-mentioned log write instruction write_log logM address1 can be further written as write_log S1 logM address1, where S1 is the system identifier of the target system 1. In this way, based on the system identifier S1, the baseboard management and control system can determine that the target operation instruction is an instruction sent by the target system 1.
[0041] Step S302 : According to a first conversion logic, convert the first storage address into a second storage address, where the second storage address is a storage address planned by a baseboard management control system for a target log. The baseboard management control system is used to operate and manage logs of at least one target system.
[0042] Specifically, the second storage address refers to the log storage address planned for the target log according to the second address planning logic of the baseboard management control system. Similar to the first storage address, the second storage address can specifically refer to the starting storage address of the target log planned by the baseboard management control system. The first storage address and the second storage address can be the same or different.
[0043] In the baseboard management and control system, a first conversion logic can be pre-set. Based on the first conversion logic, the first storage address planned by the target system can be converted to the second storage address planned by the baseboard management and control system. Specifically, the first conversion logic may include a storage address mapping relationship between the target system and the baseboard management and control system. After receiving a log operation instruction sent by the target system, the baseboard management and control system can convert the first storage address indicated by the log operation instruction into a second storage address based on the storage address mapping relationship. For example, the storage address mapping relationship can be shown in Table 1.
[0044] Table 1 Storage address mapping relationship
[0045]
[0046] Taking the second row in Table 1 as an example, it indicates that in the log operation instruction sent by the target system, if the first storage address is Address11, the converted second storage address may be Address12.
[0047] For another example, the storage address mapping relationship can be shown as expression (1).
[0048] AddressY = AddressX + 2 (1)
[0049] In expression (1), AddressX represents the first storage address planned by the target system for the target log, and AddressY represents the second storage address planned by the baseboard management control system for the target log.
[0050] It should be noted that the storage address mapping relationship may include but is not limited to the forms of Table 1 and Expression (1), and this application does not impose any restrictions on this.
[0051] In this embodiment, each target system and the baseboard management control system may have a corresponding storage address mapping relationship. For example, the storage address mapping relationship between target system 1 and the baseboard management control system may be as shown in Expression (2).
[0052] AddressY1= AddressX1+5(2)
[0053] In expression (2), AddressX1 represents the first storage address planned by target system 1 for its target log, and AddressY1 represents the second storage address planned by the baseboard management control system for the target log of target system 1.
[0054] For another example, the storage address mapping relationship between the target system 2 and the baseboard management control system can be shown as expression (3).
[0055] AddressY2= AddressX2+8(3)
[0056] In expression (3), AddressX2 represents the first storage address planned by target system 2 for its target log, and AddressY2 represents the second storage address planned by the baseboard management control system for the target log of target system 2.
[0057] Step S303: operate the target log according to the second storage address.
[0058] In this embodiment, the storage address of the target log can be uniformly managed based on the second address planning logic in the baseboard management and control system. For example, the target log can be saved to the second storage address determined according to the second address planning logic, or the target log can be collected from the second storage address. Since the baseboard management and control system has the storage address conversion function, the target system can still plan the first storage address of the target log according to the first address planning logic, and generate log operation instructions for the target log based on the first storage address, that is, the target system does not need to perceive the second storage address.
[0059] For example, assuming that the target system determines, based on the first address planning logic, that the target log L1 should be stored at the first storage address addrees1 of the log memory, the target system can generate a log write instruction for the target log L1 based on the first storage address addrees1. After receiving the log write instruction, the baseboard management and control system can convert the first storage address address1 to the second storage address address2 based on the first conversion logic, and after saving the target log L1 at the second storage address address2, return a successful save response to the target system. When the target system needs to query the target log L1, the target system determines, based on the first address planning logic, that the target log L1 is stored at the first storage address addrees1 of the log memory, so it can generate a log read instruction for the target log L1 based on the first storage address addrees1. After receiving the log read instruction, the baseboard management and control system can convert the first storage address address1 to the second storage address address2 based on the first conversion logic, and return the target log L1 read from the second storage address address2 to the target system.
[0060] In summary, in the technical solutions of some embodiments of the present application, on the one hand, when receiving the log operation instruction sent by the target system, the first storage address indicated by the log operation instruction is converted to the second storage address, so that the target log indicated by the log operation instruction can be uniformly managed according to the storage address planning of the baseboard management control system. On the other hand, based on the conversion function of the storage address, while the target log is uniformly managed according to the second storage address, the target system can still generate an operation instruction for the target log based on the first storage address, that is, it does not affect the log processing logic on the target system side. Based on the above two aspects, the technical solution of the present application can solve the problem that some technologies cannot uniformly manage the logs generated by each target system.
[0061] Specifically, according to the storage address planning of the baseboard management control system, the target logs indicated by the log operation instruction are uniformly managed, which mainly includes the following two aspects: 1) In the log memory, log storage partitions are divided for each target system; 2) After receiving the log operation instruction of the target system, the first storage address in the log operation instruction is converted to the second storage address in the log storage partition corresponding to the target system through storage address conversion. Based on the above description, in some embodiments, before receiving the log operation instruction, the method of the present application may also include:
[0062] In the log storage, a log storage partition is divided for each target system. The log storage partition includes a partition header. The partition header represents the partition range of each log storage partition and the target system corresponding to each log storage partition. Each log storage partition is used to store the log of the corresponding target system. The second storage address is the storage address of the target log in the log storage.
[0063] The partition range refers to the address range of the log storage partition. Figure 4 , which is a schematic diagram of log storage partitions provided in some embodiments of the present application. Figure 4In the example, the log storage is divided into four log storage partitions D1, D2, D3, and D4. Among them, log storage partition D1 can represent the log storage partition of target system 1, and log storage partition D2 can represent the log storage partition of target system 2. And so on. Each log storage partition can include a partition header. The partition header can record the partition information of the log storage partition. The partition information can include but is not limited to the starting address, ending address, partition size, partition name, etc. of the log storage partition. Based on the starting address and ending address of the log storage partition, the address range of the log storage partition can be determined. Alternatively, based on the starting address and partition size of the log storage partition, the address range of the log storage partition can be determined. The partition name is used to identify the target system corresponding to the log storage partition. For example, the partition name of the log storage partition D1 can be sy1, and the partition name of the log storage partition D2 can be sy2. Among them, sy1 can be the system identifier of target system 1, indicating that log storage partition D1 corresponds to target system 1, that is, log storage partition D1 is used to store the logs of target system 1; sy2 can be the system identifier of target system 2, indicating that log storage partition D2 corresponds to target system 2, that is, log storage partition D2 is used to store the logs of target system 2. In this way, based on the system identifier in the log operation instruction, the baseboard management and control system can identify the target system that sent the log operation instruction. Based on the partition header of each log storage partition, the target log storage partition corresponding to the target system can be found. Then, through storage address conversion, the first storage address in the log operation instruction can be converted to a second storage address located in the target log storage partition.
[0064] In some embodiments, the first storage address may include a first offset address of the target log. The conversion of the first storage address to the second storage address according to the first conversion logic may include:
[0065] Converting the first offset address into a second offset address according to the first conversion logic;
[0066] Based on the partition header, find the target log storage partition corresponding to the target system;
[0067] A second storage address is obtained based on the base address and the second offset address of the target log storage partition.
[0068] Specifically, the principle of converting the first offset address into the second offset address can be found in the relevant description of Table 1 and Expression (1) above, which will not be repeated here. The following example illustrates how to obtain the second storage address based on the second offset address. For example Figure 3In the example, assume that each partition header is 64KB in size and that the size of log storage partition D1 is 10MB (including the size of the partition header of log storage partition D1). If the target log storage partition is log storage partition D2, the base address of the target log storage partition is 10MB + 64KB, and the second storage address is 10MB + 64KB + the first offset address.
[0069] In the above embodiment, the partition range of each log storage partition and the target system corresponding to each log storage partition are recorded in the partition header, so that when a log operation instruction is received, the target log storage partition corresponding to the target system can be quickly found, and the search efficiency is high.
[0070] Specifically, in some embodiments, for any log storage partition, the partition header of the log storage partition includes the partition size, starting address, and partition name of the log storage partition. The above-mentioned search for the target log storage partition corresponding to the target system based on the partition header includes:
[0071] Determine the partition range of each log storage partition based on the partition size and starting address in the partition header;
[0072] Determine the target log storage partition based on the partition range of each log storage partition and the partition name in the partition header.
[0073] Specifically, the target partition header of the target log storage partition corresponding to the target system can be found based on the partition name in each partition header, and then the partition range of the target log storage partition can be determined based on the partition size and starting address in the target partition header. For example, assuming that the system identifier in the log operation instruction sent by the target system is sy2, the log storage partition D2 corresponding to the target system can be found based on the system identifier sy2 and the partition name in each partition header. Assuming that the starting address of the log storage partition D2 is address1 and the partition size of the log storage partition D2 is 10M, the end address of the log storage partition D2 is at the position of address1+10M, that is, the partition range of the log storage partition D2 is between address1 and address1+10M.
[0074] In the above embodiment, the partition size and starting address of the log storage partition are recorded in the partition header, and the ending address of the log storage partition is calculated based on the starting address and the partition size. In this way, the ending address of the log storage partition does not need to be recorded in the partition header, thereby reducing the data volume of the partition header.
[0075] In some embodiments, the log storage includes a partition table. The partition table may include the partition size and starting address of each log storage partition. The partition header of each log storage partition may include a partition table identifier and a partition name. The above-mentioned search for the target log storage partition corresponding to the target system based on the partition header may include:
[0076] Find the partition table based on the partition table identifier in the partition header;
[0077] Based on the partition table, determine the partition range of each log storage partition;
[0078] Determine the target log storage partition based on the partition range of each log storage partition and the partition name in the partition header.
[0079] Specifically, based on the partition name in each partition header, the target partition header of the target log storage partition corresponding to the target system can be searched. Furthermore, based on the partition table identifier in the target partition header, the starting address and partition size of the target log storage partition can be searched in the partition table. Based on the starting address and partition size of the target log storage partition, the partition range of the target log storage partition can be determined.
[0080] Since the partition table of this embodiment may include the partition size and starting address of each log storage partition, the partition table identifier in each partition header is the same.
[0081] In the above embodiment, by recording the partition table identifier in each partition header, the data volume of the partition header can be further reduced.
[0082] In some embodiments, the log operation instruction is also used to indicate the type of operation to be performed on the target log. Specifically, as described in step S301 above, the operation type can be determined based on the operation keyword in each log operation instruction. After receiving the log operation instruction sent by the target system, the method of the present application may further include:
[0083] Cache the log operation instruction in the first buffer area;
[0084] When the number of log operation instructions cached in the first buffer area reaches a threshold, target logs indicated by the log operation instructions are batch-operated in the log memory according to the operation types indicated by the log operation instructions.
[0085] Specifically, in some embodiments, batch-operating the target log indicated by the log operation instruction in the log storage may include:
[0086] Among the log operation instructions cached in the first cache area, a plurality of log operation instructions are executed in parallel.
[0087] The so-called parallel execution of multiple log operation instructions refers to operating the target logs indicated by multiple log operation instructions in the log memory at the same time, which can improve the efficiency of log operation.
[0088] In some embodiments, before simultaneously operating the target logs indicated by multiple log operation instructions, it can be determined whether the second storage addresses corresponding to the multiple log operation instructions have the same second storage address. If not, the target logs indicated by the multiple log operation instructions can be operated in parallel. If so, the target logs indicated by the multiple log operation instructions are not operated in parallel. This can avoid hardware conflicts, data conflicts, and other problems caused by executing different log operations at the same storage address.
[0089] In some embodiments, performing a batch operation on a target log indicated by a log operation instruction in a log storage may include:
[0090] In the first buffer area, if there are multiple log operation instructions indicating the same operation type and the second storage addresses of the target logs indicated by the multiple log operation instructions are continuous storage addresses, the target logs indicated by the multiple log operation instructions are batch operated in the log memory.
[0091] Specifically, if the operation types indicated by multiple log operation instructions are the same, and the second storage addresses of the target logs indicated by the multiple log operation instructions are continuous storage addresses, the multiple log operation instructions can be merged into one log operation instruction, and the target logs indicated by the multiple log operation instructions can be operated at once. In this way, the number of erase and write operations of the log memory can be greatly reduced, thereby extending the service life of the log memory. For example, assuming that the operation types of log operation instructions A and log operation instruction B are both write operations, and log operation instruction A instructs to write target log a at the first storage address address1, and log operation instruction B instructs to write target log b at the first storage address address2, after converting the first storage address address1, the second storage address address3 is obtained, and after converting the first storage address address2, the second storage address address4 is obtained. If the second storage address address3 and the second storage address address4 are continuous storage addresses, the target log a and the target log b can be written to the log memory at one time. Compared with writing the target log a and the target log b to the log storage in batches, this merged writing method can greatly reduce the number of erase and write operations of the log memory, thereby extending the service life of the log memory.
[0092] In some embodiments, considering that the log memory is a non-volatile memory and reading and writing data in the log memory is relatively slow, log operation instructions can also be cached in a first cache area, and logs in the log memory can be cached in a second cache area. The first cache area and the second cache area can be different memory areas. The above operation target log based on the second storage address can include:
[0093] According to the second conversion logic, the second storage address is converted into a third storage address, where the third storage address is a storage address of the target log in the second buffer area;
[0094] The target log is operated in the second buffer area according to the third storage address.
[0095] Since the second buffer area can be a memory, the speed of reading and writing logs from the second buffer area can be much higher than the speed of reading and writing logs from the log storage, thereby improving the log reading and writing efficiency.
[0096] Specifically, when the operation type represented by the log operation instruction is a read operation, after the target log is read from the second buffer area, the corresponding log operation instruction in the first buffer area can be deleted, so as to avoid repeated execution of the log operation instruction.
[0097] If the log operation instruction represents a write operation, the target log can be written to the second buffer area while the target log is being written to the log memory. This ensures that the data in the log memory and the second buffer area are consistent. After the second buffer area and the log memory complete the write operation on the target log, the corresponding log operation instruction in the first buffer area can be deleted. This prevents repeated execution of the log operation instruction.
[0098] In some embodiments, when the target log is written into the second buffer area, the step of writing the target log into the log storage may include:
[0099] When the number of log operation instructions cached in the first cache area reaches a threshold, if there are multiple log operation instructions indicating operation types that are all write operations, and the second storage addresses of the target logs indicated by the multiple log operation instructions are continuous storage addresses, then the target logs indicated by the multiple log operation instructions are batch written into the log memory.
[0100] The principles of batch operations are similar to those described above and will not be repeated here.
[0101] In some embodiments, when caching logs from the log storage into the second buffer area, if a log operation instruction is received from the target system, the target log indicated by the log operation instruction will not be operated in the second buffer area until the caching operation is completed. This avoids hardware conflicts and data conflicts caused by performing log operations on the same storage address.
[0102] In some embodiments, before operating the target log indicated by the log operation instruction in the log storage, the method of the present application further includes:
[0103] Determine whether there is a log operation in progress in the log memory. If so, do not operate the target log indicated by the log operation instruction in the log memory until the log operation is completed. This avoids hardware conflicts and data conflicts caused by log operations at the same storage address.
[0104] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0105] The embodiment of the present application also provides a log operation device, Figure 5 , which is a module diagram of a log operation device provided in some embodiments of the present application. Figure 5 In the example, the log operation device includes:
[0106] The instruction receiving module 501 is used to receive a log operation instruction sent by a target system. The log operation instruction is used to indicate the target log to be operated by the target system and the first storage address of the target log. The target log is a log generated by the target system. The first storage address is the storage address planned by the target system for the target log.
[0107] An address conversion module 502 is configured to convert a first storage address into a second storage address according to a first conversion logic, where the second storage address is a storage address planned by a baseboard management control system for a target log, and the baseboard management control system is configured to perform operations and management on the logs of at least one target system;
[0108] The log operation module 503 is used to operate the target log according to the second storage address.
[0109] In some embodiments, logs of at least one target system are stored in a log storage;
[0110] Before receiving the log operation instruction, the instruction receiving module 501 is further configured to:
[0111] In the log storage, a log storage partition is divided for each target system. The log storage partition includes a partition header. The partition header represents the partition range of each log storage partition and the target system corresponding to each log storage partition. Each log storage partition is used to store the log of the corresponding target system. The second storage address is the storage address of the target log in the log storage.
[0112] In some embodiments, the first storage address includes a first offset address of the target log; the address conversion module 502 is specifically configured to:
[0113] Converting the first offset address into a second offset address according to the first conversion logic;
[0114] Based on the partition header, find the target log storage partition corresponding to the target system;
[0115] A second storage address is obtained based on the base address and the second offset address of the target log storage partition.
[0116] In some embodiments, the partition header includes a partition table identifier and a partition name; the address conversion module 502 is specifically configured to:
[0117] Based on the partition table identifier in the partition header, search the partition table, which includes the partition size and starting address of each log storage partition;
[0118] Based on the partition table, determine the partition range of each log storage partition;
[0119] Determine the target log storage partition based on the partition range of each log storage partition and the partition name in the partition header.
[0120] In some embodiments, the partition header includes the partition size, starting address, and partition name of the log storage partition; the address conversion module 502 is specifically configured to:
[0121] Determine the partition range of each log storage partition based on the partition size and starting address in the partition header;
[0122] Determine the target log storage partition based on the partition range of each log storage partition and the partition name in the partition header.
[0123] In some embodiments, the log operation instruction is further used to indicate the type of operation to be performed on the target log;
[0124] After receiving the log operation instruction sent by the target system, the log operation module 503 is specifically used to:
[0125] Cache the log operation instruction in the first buffer area;
[0126] When the number of log operation instructions cached in the first buffer area reaches a threshold, target logs indicated by the log operation instructions are batch-operated in the log memory according to the operation types indicated by the log operation instructions.
[0127] In some embodiments, the log operation module 503 is specifically used to
[0128] In the first buffer area, if there are multiple log operation instructions indicating the same operation type and the second storage addresses of the target logs indicated by the multiple log operation instructions are continuous storage addresses, the target logs indicated by the multiple log operation instructions are batch operated in the log memory.
[0129] In some embodiments, the instruction receiving module 501 is further configured to:
[0130] caching the log operation instruction in the first buffer area, and caching the log in the log memory in the second buffer area;
[0131] The log operation module 503 is specifically used for:
[0132] According to the second conversion logic, the second storage address is converted into a third storage address, where the third storage address is a storage address of the target log in the second buffer area;
[0133] The target log is operated in the second buffer area according to the third storage address.
[0134] In some embodiments, the log operation instruction further indicates the type of operation to be performed on the target log, including a read operation and a write operation. The log operation module 503 is further configured to:
[0135] If the operation type is a write operation, in the case where the target log is written in the second buffer area, the target log is written in the log storage.
[0136] In some embodiments, the log operation module 503 is specifically used to:
[0137] When the number of log operation instructions cached in the first cache area reaches a threshold, if there are multiple log operation instructions indicating operation types that are all write operations, and the second storage addresses of the target logs indicated by the multiple log operation instructions are continuous storage addresses, then the target logs indicated by the multiple log operation instructions are batch written into the log memory.
[0138] In some embodiments, the log operation module 503 is further configured to:
[0139] During the process of caching the logs in the log storage into the second buffer area, if a log operation instruction is received from the target system, the target log indicated by the log operation instruction is not operated in the second buffer area before the cache operation is completed.
[0140] In some embodiments, before operating the target log indicated by the log operation instruction in the log storage, the log operation module 503 is further configured to:
[0141] It is determined whether there is a log operation being executed in the log memory. If so, the target log indicated by the log operation instruction is not operated in the log memory before the log operation being executed is completed.
[0142] For the description of the features in the embodiment corresponding to the log operation device, please refer to the relevant description of the embodiment corresponding to the log operation method, and no further details will be given here.
[0143] See also Figure 6 An embodiment of the present application further provides an electronic device, comprising a memory 10 and a processor 20, wherein the memory 10 stores a computer program, and the processor 20 is configured to run the computer program to execute the steps in any one of the above-mentioned log operation method embodiments.
[0144] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above-mentioned log operation method embodiments when running.
[0145] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0146] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned log operation method embodiments are implemented.
[0147] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned log operation method embodiments are implemented.
[0148] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0149] The above is a detailed introduction to a log operation method, device, storage medium and program product provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A log operation method, characterized in that: The method comprises: Receiving a log operation instruction sent by a target system, the log operation instruction is used to indicate a target log to be operated by the target system and a first storage address of the target log, the target log is a log generated by the target system, and the first storage address is a storage address planned by the target system for the target log; converting the first storage address into a second storage address according to a first conversion logic, where the second storage address is a storage address planned by a baseboard management and control system for the target log, the baseboard management and control system being used to perform operation management on the log of at least one target system; operating the target log according to the second storage address; The log of the at least one target system is stored in a log memory. Before receiving the log operation instruction, a log storage partition is divided in the log memory for each target system. The log storage partition includes a partition header. The partition header represents a partition range of each log storage partition and a target system corresponding to each log storage partition. Each log storage partition is used to store the log of the corresponding target system. The second storage address is a storage address of the target log in the log memory. The first storage address includes a first offset address of the target log. Converting the first storage address to the second storage address according to the first conversion logic includes: converting the first offset address into a second offset address according to the first conversion logic; Based on the partition header, searching for the target log storage partition corresponding to the target system; The second storage address is obtained based on the base address of the target log storage partition and the second offset address.
2. The method according to claim 1, characterized in that The partition header includes a partition table identifier and a partition name; The searching, based on the partition header, for a target log storage partition corresponding to the target system includes: Based on the partition table identifier in the partition header, searching for a partition table, wherein the partition table includes a partition size and a starting address of each log storage partition; Determining a partition range of each log storage partition based on the partition table; The target log storage partition is determined based on the partition range of each log storage partition and the partition name in the partition header.
3. The method according to claim 1, characterized in that The partition header includes the partition size, starting address and partition name of the log storage partition; The searching, based on the partition header, for a target log storage partition corresponding to the target system includes: Determining a partition range of each log storage partition based on the partition size and the starting address in the partition header; The target log storage partition is determined based on the partition range of each log storage partition and the partition name in the partition header.
4. The method according to claim 1, wherein The log operation instruction is also used to indicate the type of operation to be performed on the target log; After receiving the log operation instruction sent by the target system, the method further includes: Cache the log operation instruction in a first buffer area; When the number of log operation instructions cached in the first cache area reaches a threshold, target logs indicated by the log operation instructions are batch-operated in the log memory according to the operation type indicated by each log operation instruction.
5. The method according to claim 4, characterized in that The batch operation of the target logs indicated by the log operation instruction in the log storage includes: In the first cache area, if there are multiple log operation instructions indicating the same operation type, and the second storage addresses of the target logs indicated by the multiple log operation instructions are continuous storage addresses, the target logs indicated by the multiple log operation instructions are batch operated in the log memory.
6. The method according to claim 1, characterized in that The method further comprises: caching the log operation instruction in a first buffer area, and caching the log in the log memory in a second buffer area; The operating the target log according to the second storage address includes: According to a second conversion logic, convert the second storage address into a third storage address, where the third storage address is a storage address of the target log in the second buffer area; The target log is operated in the second buffer area according to the third storage address.
7. The method according to claim 6, characterized in that The log operation instruction further represents the type of operation to be performed on the target log, and the operation type includes a read operation and a write operation; The method further comprises: If the operation type is a write operation, then when the target log is written into the second buffer area, the target log is written into the log memory.
8. The method according to claim 7, characterized in that Writing the target log into the log storage includes: When the number of log operation instructions cached in the first cache area reaches a threshold, if there are multiple log operation instructions indicating operation types that are all write operations, and the second storage addresses of the target logs indicated by the multiple log operation instructions are continuous storage addresses, then the target logs indicated by the multiple log operation instructions are batch written into the log memory.
9. The method according to claim 6, characterized in that The method further comprises: During the process of caching the logs in the log storage into the second cache area, if the log operation instruction sent by the target system is received, the target log indicated by the log operation instruction is not operated in the second cache area before the cache operation is completed.
10. The method according to any one of claims 4, 5, 7 and 8, characterized in that: Before operating the target log indicated by the log operation instruction in the log storage, the method further includes: It is determined whether there is a log operation being executed in the log memory. If so, the target log indicated by the log operation instruction is not operated in the log memory before the log operation being executed is completed.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
12. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 10 is implemented.
13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Storage device log generation method and storage device thereof
CN112765006A
Log data processing method and device
CN115470066A