Log storage method and device, program product, electronic equipment and computer readable storage medium

By obtaining the physical information of log information from the log buffer of the inexpensive redundant disk array and writing it to the solid-state drive, the problem of outputting log information to the serial port affecting program performance is solved, and faster logging and more efficient program execution is achieved.

CN120029552APending Publication Date: 2025-05-23SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510227761.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-27
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

In the chip simulation platform, outputting log information to the serial port will have a huge impact on program performance, resulting in a long execution time of test cases.

Method used

Provides a log disk drop method, which generates a write disk request for a solid state hard disk from a log buffer in an inexpensive redundant disk array, and transports the log information from the log buffer to the log storage area of ​​the solid state hard disk.

Benefits of technology

It reduces the impact of log information on program performance, shortens the execution time of test cases, and improves the efficiency of log information reading.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029552A_ABST
    Figure CN120029552A_ABST
Patent Text Reader

Abstract

The invention relates to the field of computers, and discloses a log storage method and device, a program product, electronic equipment and a computer readable storage medium, and the method comprises the steps: obtaining physical information of log information from a log buffer area in a redundant array of inexpensive disks; the physical information comprises the address and the size of the log information; when the size of the log information is not smaller than a preset threshold value, generating a disk writing request of the solid state disk; the disk writing request comprises physical information; and sending a disk writing request to the solid state disk to enable the solid state disk to carry the log information from the log buffer area to a log storage area of the solid state disk. The physical information of the log information is obtained from the log buffer area, then the disk writing request is generated and sent to the solid state disk, and the solid state disk carries the log information to the log storage area, so that the mode of transmitting the log information to a serial port is replaced, and the inherent limitation of a simulation platform and the serial port in the related technology is eliminated; influence of log information on program performance is reduced, and time consumption is shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a method and device for storing logs on a disk, a computer program product, an electronic device, and a computer-readable storage medium. Background Art

[0002] During the development and debugging of the multi-core RAID card (redundant arrays of independent disks) on the chip simulation platform, log information is output to the serial port to monitor the running path and status of the current program. However, due to the inherent limitations of the simulation platform and the serial port, such as the CPU (Central Processing Unit) frequency is too slow, the serial port rate is too low relative to the CPU speed, etc., the output of log information to the serial port will have a huge impact on the program performance, resulting in a long test case execution time. For example, during debugging, it was found that the time required to execute the same test case differed by more than 6 times when the serial port printing was turned on and off.

[0003] Therefore, how to solve the above technical problems should be the focus of technical personnel in this field. Summary of the invention

[0004] The purpose of the present invention is to provide a log storage method, device, program product, electronic device and computer-readable storage medium to reduce the impact of log information on program performance and shorten the time consumption.

[0005] In order to solve the above technical problems, the present invention provides a log storage method, comprising:

[0006] Obtaining physical information of the log information from a log buffer in a cheap redundant disk array; the physical information includes an address and a size of the log information; the cheap redundant disk array includes a plurality of cores, and the log information is transmitted to the log buffer by the cores;

[0007] When the size of the log information is not less than a preset threshold, generating a write request for the solid state drive; the write request includes the physical information;

[0008] The write request is sent to the solid state drive, so that the solid state drive moves the log information from the log buffer to the log storage area of ​​the solid state drive.

[0009] As an implementable method, before obtaining the physical information of the log information from the log buffer in the inexpensive redundant disk array, the method further includes:

[0010] The log information on each core in the inexpensive redundant disk array is output to the log buffer.

[0011] As an implementable method, outputting the log information on each core in the inexpensive redundant disk array to the log buffer includes:

[0012] Step S11, when the core is in the interrupt-off state, and the cores other than the core are in the spin-locked state, recording the current write allocation position of the log buffer;

[0013] Step S12, determining whether the size of the log information on the core exceeds the current capacity of the log buffer;

[0014] Step S13: If the size of the log information on the core exceeds the current capacity of the log buffer, the log information is discarded;

[0015] Step S14: If the size of the log information on the core does not exceed the current capacity of the log buffer, adjust the current write allocation position of the log buffer to reserve storage space for the log information;

[0016] Step S15, controlling a core other than the core to unlock the spin lock, taking the core with the unlocked spin lock as a new core, and entering step S11 until all other cores have unlocked their spin locks;

[0017] Step S16: cyclically write the log information into the current write allocation position of the log buffer.

[0018] As an implementation method, before determining whether the size of the log information on the core exceeds the current capacity of the log buffer, the method further includes:

[0019] Determine a first difference between a current write allocation position of the log buffer and a position where the log buffer is written to the solid state drive; the first difference is greater than or equal to zero;

[0020] A second difference between the total capacity of the log buffer and the first difference is determined, and the second difference is used as the size of the log information on the core.

[0021] As an implementation method, after the log information is cyclically written into the current write allocation position of the log buffer, the method further includes:

[0022] Determine whether the current write completion position of the log buffer is the same as the current write allocation position of the log buffer;

[0023] If the current write completion position of the log buffer is the same as the current write allocation position of the log buffer, the current write completion position of the log buffer is adjusted.

[0024] As an implementable method, after adjusting the current write completion position of the log buffer, the method further includes:

[0025] Enable interrupts for the core;

[0026] Based on the current write completion position of the log buffer and the data reading position of the log buffer, determining whether the size of the unwritten log information is less than a preset threshold;

[0027] If the size of the unwritten log information is smaller than the preset threshold, exit;

[0028] If the size of the unwritten log information is not less than the preset threshold, the semaphore is released and the disk writing thread is awakened.

[0029] As an implementable method, when the size of the log information is not less than a preset threshold, before generating a write request for the solid state drive, the method further includes:

[0030] Step S21, blocking the log information waiting to be written into the solid state drive;

[0031] Step S22, controlling the interruption of the core in the inexpensive redundant disk array to be turned off, and controlling the other cores except the core to be in a spin lock state;

[0032] Step S23, determining whether the size of the log information to be written into the solid state drive is less than a preset threshold;

[0033] Step S24: If the size of the log information is smaller than the preset threshold, proceed to step S21 until the size of the log information is not smaller than the preset threshold;

[0034] Step S25: if the size of the log information is not less than the preset threshold, setting the address of the log information as the log buffer data reading position;

[0035] Step S26, taking out first target log information whose size is the preset threshold from the log information, and filling the fill flag of the first target log information with the first flag bit;

[0036] Step S27, adjusting the data reading position of the log buffer;

[0037] Step S28: unlock the interrupt of the core and the spin locks of other cores.

[0038] As an implementable method, adjusting the data reading position of the log buffer includes:

[0039] Determine the sum of the set log buffer data reading position and the preset threshold;

[0040] Determine the remainder of dividing the sum by the capacity of the log buffer;

[0041] The remainder is set as the adjusted position of the log buffer data reading position.

[0042] As an implementable embodiment, the log buffer is a ring buffer, and / or the log storage area is a ring storage area.

[0043] As an implementable embodiment, it also includes:

[0044] The second target log information whose size is smaller than a preset threshold is written back to the solid state drive.

[0045] As an implementable method, writing the second target log information whose size is smaller than a preset threshold back to the solid state drive includes:

[0046] Step S41, controlling the interruption of the core in the inexpensive redundant disk array to be turned off, and controlling the other cores except the core to be in a spin lock state;

[0047] Step S42, determining whether the current write completion position of the log buffer is equal to the current write allocation position of the log buffer;

[0048] Step S43: If the current write completion position of the log buffer is not equal to the current write allocation position of the log buffer, return to step S42;

[0049] Step S44: if the current write completion position of the log buffer is equal to the current write allocation position of the log buffer, then determine whether there is log information that can be written to the solid state drive;

[0050] Step S45: If there is currently log information that can be written to the solid state drive, unlock the interrupt and spin lock;

[0051] Step S46: if there is no log information that can be written to the solid state drive, then the address of the second target log information is set as the log buffer data reading position;

[0052] Step S47: starting from the current write completion position of the log buffer, fill the second target log information with target data so that the size of the second target log information is a preset threshold, and set a fill flag of the second target log information after filling;

[0053] Step S48, unlocking interrupt and spin lock;

[0054] Step S49, generating a write request for the solid state drive;

[0055] Step S410: Send the write request to the solid state drive, so that the solid state drive moves the filled second target log information from the log buffer to the log storage area of ​​the solid state drive.

[0056] The present invention also provides a log storage method, which includes: when the log buffer in the inexpensive redundant disk array stores log information and the size of the log information is not less than a preset threshold value, the method comprises:

[0057] receiving a disk write request; the disk write request includes physical information of the log information, and the physical information includes an address and a size of the log information;

[0058] The log information is transferred from the log buffer to the log storage area of ​​the solid state drive according to the disk write request.

[0059] As an implementable method, after the log information is transferred from the log buffer to the log storage area of ​​the solid state drive according to the write request, the method further includes:

[0060] The interrupt processing function is sent to the firmware so that the firmware completes the interrupt processing function.

[0061] As an implementable method, the firmware completes the interrupt processing function including:

[0062] Step S31, when the fill flag of the log information is not the second flag bit, and the address of the log information is equal to the completion position of the log buffer writing to the solid state hard disk, adjusting the completion position of the log buffer writing to the solid state hard disk;

[0063] Step S32, determining the index position of the adjusted log buffer writing completion position in the solid state drive in the log buffer;

[0064] Step S33, determining whether the release flag corresponding to the index position is 1;

[0065] Step S34: if the release flag is not 1, release the write request space of the solid state drive and exit;

[0066] Step S35: If the release flag is 1, adjusting the log buffer to write to the solid state hard disk completion position;

[0067] Step S36, clearing the release flag corresponding to the index position;

[0068] Step S37, add 1 to the index position to obtain a new index position, and go to step S33.

[0069] As an implementable method, when the fill flag of the log information is not the second flag bit, and the address of the log information is equal to the completion position of the log buffer writing to the solid state hard disk, before adjusting the completion position of the log buffer writing to the solid state hard disk, it also includes:

[0070] According to the disk write request, obtain the address and fill mark of the log information;

[0071] Determine whether the fill flag is the second flag bit;

[0072] If the fill flag is the second flag bit, proceed to step S34;

[0073] If the fill flag is not the second flag bit, determining whether the address of the log information is equal to the position where the log buffer is written into the solid state hard disk;

[0074] If the address of the log information is equal to the position where the log buffer is written into the solid state hard disk, then the process proceeds to step S31;

[0075] If the address of the log information is not equal to the position where the log buffer is written into the solid state hard disk, determining the index position of the log information according to the address of the log information, the pre-fixed address of the log information in the log buffer and the size of the log information;

[0076] The release flag corresponding to the index position is set to 1, and the process proceeds to step S34.

[0077] As an implementable method, determining the index position of the log information according to the address of the log information, the pre-fixed address of the log information in the log buffer, and the size of the log information includes:

[0078] Determine a third difference between the address of the log information and the pre-fixed address;

[0079] A ratio of the third difference to the size of the log information is determined, and the ratio is used as an index position of the log information.

[0080] The present invention also provides a log transfer device, comprising:

[0081] A first acquisition module is used to acquire physical information of the log information from a log buffer in an inexpensive redundant disk array; the physical information includes an address and a size of the log information; the inexpensive redundant disk array includes a plurality of cores, and the log information is transmitted from the cores to the log buffer;

[0082] A generating module, configured to generate a write request for the solid state drive when the size of the log information is not less than a preset threshold; the write request includes the physical information;

[0083] The first sending module is used to send the disk write request to the solid state drive, so that the solid state drive transfers the log information from the log buffer to the log storage area of ​​the solid state drive.

[0084] The present invention also provides a computer program product, including a computer program / instruction, which implements the steps of any of the above-mentioned log storage methods when executed by a processor.

[0085] The present invention also provides an electronic device, comprising:

[0086] Memory for storing computer programs;

[0087] A processor is used to implement the steps of any of the above-mentioned log storage methods when executing the computer program.

[0088] The present invention provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the steps of any one of the above-mentioned log storage methods are implemented.

[0089] A log writing method provided by the present invention includes: obtaining physical information of log information from a log buffer in a cheap redundant disk array; the physical information includes the address and size of the log information; when the size of the log information is not less than a preset threshold, generating a write request for a solid state drive; the write request includes the physical information; sending the write request to the solid state drive so that the solid state drive moves the log information from the log buffer to the log storage area of ​​the solid state drive.

[0090] It can be seen that in the log-to-disk method of the present invention, the log information is stored in the log buffer in the cheap redundant disk array, the physical information of the log information is obtained from the log buffer, and then a write request for the solid-state hard disk is generated, and then the write request is sent to the solid-state hard disk. Since the write request includes the physical information of the log information, the solid-state hard disk moves the log information in the log buffer to the log storage area of ​​the solid-state hard disk. That is, the present invention drops the log information into the solid-state hard disk, replacing the method of transmitting the log information to the serial port, getting rid of the inherent limitations of the simulation platform and the serial port in the related technology, reducing the impact of the log information on the program performance, and shortening the time consumption. In addition, what is obtained from the log buffer in the present invention is the physical information of the log information, not the log information, which can improve the reading efficiency.

[0091] In addition, the present invention also provides a device, a program product, an electronic device and a computer-readable storage medium having the above advantages. BRIEF DESCRIPTION OF THE DRAWINGS

[0092] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0093] Figure 1 A schematic diagram of the hardware structure of a RAID card in a simulation platform provided by the present invention;

[0094] Figure 2 A logic diagram of asynchronously writing log information into a solid state hard disk provided by an embodiment of the present invention;

[0095] Figure 3 A log storage method provided by the present invention Figure 1 ;

[0096] Figure 4 A process for outputting log information on a core of a cheap redundant disk array to a log buffer provided by an embodiment of the present invention Figure 1 ;

[0097] Figure 5 A process for outputting log information on a core of a cheap redundant disk array to a log buffer provided by an embodiment of the present invention Figure 2 ;

[0098] Figure 6 A log storage method provided by the present invention Figure 2 ;

[0099] Figure 7 A log storage method provided by the present invention Figure 3 ;

[0100] Figure 8 A process of completing an interrupt processing function of a firmware provided by an embodiment of the present invention Figure 1 ;

[0101] Fig. 9 A process of completing an interrupt processing function of a firmware provided by an embodiment of the present invention Figure 2 ;

[0102] Fig.10 A schematic diagram of a state where a log buffer is empty provided by an embodiment of the present invention;

[0103] Fig.11 A schematic diagram of a log buffer being full provided by an embodiment of the present invention;

[0104] Fig.12 A flowchart of a write-back provided by an embodiment of the present invention;

[0105] Fig.13 A structural block diagram of a log storage device provided in an embodiment of the present invention;

[0106] Fig.14 This is a structural block diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0107] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0108] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0109] As mentioned in the background technology section, due to the inherent limitations of the simulation platform and serial port, such as the CPU frequency is too slow, the serial port rate is too low relative to the CPU speed, etc., outputting log information to the serial port will have a huge impact on program performance, resulting in a long test case execution time.

[0110] The hardware structure of the RAID card in the simulation platform is as follows: Figure 1 As shown in the figure, the RAID card is connected to the host through the PCIE (peripheral component interconnect express, a high-speed serial computer expansion bus standard) interface, and is connected to the solid-state drive through the PCIE interface. When the host needs to read or write the solid-state drive, it must first be processed by the RAID card. In addition, the RAID card can also actively initiate read and write requests for the solid-state drive, which provides feasibility for writing log information data to the solid-state drive. After testing the write rate of the solid-state drive, it was found that the write rate of the solid-state drive is more than 40 times the write rate of the serial port, so in the RAID card chip simulation platform, writing log information to the solid-state drive for storage becomes a better choice.

[0111] The present invention provides a method for storing logs on disk. Figure 2 and Figure 3 , the method comprising:

[0112] Step S101: obtaining physical information of log information from a log buffer in a redundant inexpensive disk array; the physical information includes the address and size of the log information; the redundant inexpensive disk array includes multiple cores, and the log information is transmitted from the core to the log buffer.

[0113] The log storage method of the present invention is applicable to a cheap redundant disk array. The cheap redundant disk array includes a log buffer and at least two cores. The specific number of cores is not limited in the present invention and depends on the situation.

[0114] In this step, log information has been stored in the log buffer.

[0115] It should be noted that the capacity of the log buffer is not limited in the present invention and depends on the situation. For example, the capacity of the log buffer may be 64KB.

[0116] This step only obtains the log information start address and data size, that is, physical information, from the log buffer without copying the data, which can improve the reading efficiency.

[0117] Step S102: When the size of the log information is not less than a preset threshold, a write request for the solid state drive is generated; the write request includes physical information.

[0118] The preset threshold is the size of data required to be written by the SSD write request. The preset threshold is not limited in the present invention and depends on the situation. For example, the SSD write request requires that the data size to be written must be aligned to 4KB, and the SSD must be an integer multiple of 4KB when writing at a time, which satisfies the size of a sector page, and the preset threshold is 4KB.

[0119] When generating a disk write request, the process may include applying for a disk write request for the solid state drive; and filling the disk write request for the solid state drive according to the physical information of the log information.

[0120] Step S103: Send a write request to the solid state drive, so that the solid state drive transfers the log information from the log buffer to the log storage area of ​​the solid state drive.

[0121] Since the write request includes the physical information of the log information, the solid-state drive can move the log information from the log buffer to the log storage area after receiving the write request.

[0122] When a solid-state drive write request is executed, direct memory access (DMA) is used to transfer data. During the transfer process, the address space cannot be released and the address content cannot be modified, otherwise wrong data will be written.

[0123] The capacity of the log storage area is not limited in this embodiment and can be set by oneself. For example, the capacity of the log storage area can be 64MB.

[0124] The solid state drive includes a data area and a log storage area. The log storage area is located at the end of the solid state drive. Figure 2 As shown, the log storage area is invisible to the upper layer when forming a RAID and is specifically used for log storage.

[0125] In the log-to-disk method of this embodiment, the log information is stored in the log buffer in the cheap redundant disk array, the physical information of the log information is obtained from the log buffer, and then a write request for the solid-state hard disk is generated, and then the write request is sent to the solid-state hard disk. Since the write request includes the physical information of the log information, the solid-state hard disk moves the log information in the log buffer to the log storage area of ​​the solid-state hard disk. That is, the present invention drops the log information into the solid-state hard disk, replacing the method of transmitting the log information to the serial port, getting rid of the inherent limitations of the simulation platform and the serial port in the related technology, reducing the impact of the log information on the program performance, and shortening the time consumption. In addition, in this embodiment, what is obtained from the log buffer is the physical information of the log information, not the log information, which can improve the reading efficiency.

[0126] Based on the above embodiment, in one embodiment of the present invention, before obtaining the physical information of the log information from the log buffer in the inexpensive redundant disk array, the following method may be further included:

[0127] Output the log information on each core in the inexpensive redundant array of disks to the log buffer.

[0128] The core writes the formatted log information into the log buffer by calling the log output interface.

[0129] It should be pointed out that in this embodiment, the method of transmitting the log information on the core to the log buffer is not specifically limited, as long as the log information on the core can be transmitted to the log buffer.

[0130] It is understandable that before the log information is stored in the log buffer, the limited memory space is taken into consideration.

[0131] As an implementation option, please refer to Figure 4 , outputting log information on each core in the redundant array of inexpensive disks to the log buffer may include:

[0132] Step S11: When the core is in the interrupt-off state and the cores other than the core are in the spin-locked state, the current write allocation position of the log buffer is recorded.

[0133] The current write allocation position of the recorded log buffer is the current position, which is used for subsequent position comparison.

[0134] When multiple cores write log information to the log buffer, the present invention turns off the interrupt of the core that is to transmit the log information, and spin-locks the other cores. Turning off interrupts can prohibit scheduling within the core, ensuring mutual exclusion between interrupts and threads, and between threads within the core; spin locks can ensure mutual exclusion of access between multiple cores.

[0135] In the RAID card, there are scenarios where multiple cores output log information in parallel or interrupt log information output. Using interrupts and spin locks to protect access to the log buffer can avoid problems caused by concurrent access between threads and interrupts, threads and threads, and multiple cores.

[0136] The log buffer contains four marking positions, namely: the current write allocation position of the log buffer (write_head), the current write completion position of the log buffer (write_tail), the data reading position of the log buffer (read_head), and the log buffer write completion position of the solid-state drive (read_tail).

[0137] Step S12: Determine whether the size of the log information on the core exceeds the current capacity of the log buffer.

[0138] Step S13: If the size of the log information on the core exceeds the current capacity of the log buffer, the log information is discarded.

[0139] When the size of the log information exceeds the current capacity of the log buffer, it indicates that this is an abnormal situation, and the current log information is directly discarded and exited.

[0140] Step S14: If the size of the log information on the core does not exceed the current capacity of the log buffer, the current write allocation position of the log buffer is adjusted to reserve storage space for the log information.

[0141] When the size of the log information does not exceed the current capacity of the log buffer, it indicates that the log information can be stored. According to the size of the log information, the current write allocation position of the log buffer is adjusted to reserve the space where the log information will be written.

[0142] Step S15, controlling a core other than the core to unlock the spin lock, taking the core with the unlocked spin lock as a new core, and entering step S11 until all other cores have unlocked their spin locks.

[0143] After unlocking, other cores can output log information. Unlocking at this time is to maximize the use of multi-core parallelism and reduce the impact of log information output on performance.

[0144] When multiple cores write log information to the log buffer, modifying the current write allocation position (write_head) requires the use of interrupts and spin locks for mutual exclusion protection of multithreading and interrupts between cores and within a core. After the modification is completed, only the interrupt needs to be used to protect the mutual exclusion scenario within the core. This can minimize the protection scenarios between cores and improve parallel efficiency.

[0145] Step S16: cyclically write the log information to the current write allocation position of the log buffer.

[0146] Each time a core is unlocked, the log information on the core is written into the current write allocation position of the log buffer recorded in step S11.

[0147] Based on the above embodiments, in one embodiment of the present invention, please refer to Figure 5 , outputting log information on each core in the redundant array of inexpensive disks to the log buffer may include:

[0148] Step S51: When the core is in the interrupt-off state and the cores other than the core are in the spin-locked state, the current write allocation position of the log buffer is recorded.

[0149] Step S52, determining a first difference between the current write allocation position of the log buffer and the position where the log buffer is written to the solid state drive; the first difference is greater than or equal to zero.

[0150] Assume that the length of the current write allocation position (write_head) of the log buffer is a, and the completion position (write_tail) of the log buffer writing to the solid-state hard disk is b. When the current write allocation position of the log buffer is greater than the completion position of the log buffer writing to the solid-state hard disk, the first difference m is the difference between the current write allocation position a of the log buffer and the completion position b of the log buffer writing to the solid-state hard disk; when the current write allocation position of the log buffer is less than the completion position of the log buffer writing to the solid-state hard disk, the first difference m is the difference between the completion position b of the log buffer writing to the solid-state hard disk and the current write allocation position a of the log buffer.

[0151] Step S53: determine a second difference between the total capacity of the log buffer and the first difference, and use the second difference as the size of the log information on the core.

[0152] Assuming that the total capacity of the log buffer is M, the size of the log information is the total capacity M minus the first difference m.

[0153] Step S54: determine whether the size of the log information on the core exceeds the current capacity of the log buffer.

[0154] Step S55: If the size of the log information on the core exceeds the current capacity of the log buffer, the log information is discarded.

[0155] Step S56: If the size of the log information on the core does not exceed the current capacity of the log buffer, adjust the current write allocation position of the log buffer to reserve storage space for the log information.

[0156] Step S57, control one core other than the core to unlock the spin lock, use the other core with the unlocked spin lock as a new core, and enter step S51 until all other cores have unlocked their spin locks.

[0157] Step S58: cyclically write the log information into the current write allocation position of the log buffer.

[0158] When an abnormal situation occurs in the log buffer, the log buffer data overflows. At this time, the current log information can only be discarded because the old log information has not been completely written to the hard disk. If it is overwritten, the log sequence will be disordered, affecting the location of the problem.

[0159] Based on any of the above embodiments, in one embodiment of the present invention, after the log information is cyclically written into the current write allocation position of the log buffer, the following method may be further included:

[0160] Determine whether the current write completion position of the log buffer is the same as the current write allocation position of the log buffer;

[0161] If the current write completion position of the log buffer is the same as the current write allocation position of the log buffer, the current write completion position of the log buffer is adjusted.

[0162] The current write completion position of the log buffer may be adjusted by adding a preset threshold (the length of the log information to be written) to the current write completion position of the log buffer to obtain a sum value, and then dividing the sum value by the size of the log buffer and taking the remainder. The remainder obtained is the adjusted position.

[0163] It should be pointed out that when the current write completion position of the log buffer and the current write allocation position of the log buffer are not the same, then keep waiting and return to the step of determining whether the current write completion position of the log buffer and the current write allocation position of the log buffer are the same until it is determined that the current write completion position of the log buffer and the current write allocation position of the log buffer are the same.

[0164] In this implementation, after the log information is written into the log buffer, a further position comparison is performed until the current write completion position of the log buffer is equal to the current write allocation position of the log buffer, thereby adjusting the current write completion position of the log buffer.

[0165] Based on any of the above embodiments, in one embodiment of the present invention, after adjusting the current write completion position of the log buffer, the following method may be further included:

[0166] Enable kernel interrupts;

[0167] Based on the current write completion position of the log buffer and the data reading position of the log buffer, determining whether the size of the unwritten log information is less than a preset threshold;

[0168] If the size of the unwritten log information is less than the preset threshold, exit;

[0169] If the size of the unwritten log information is not less than the preset threshold, the semaphore is released and the disk writing thread is awakened.

[0170] When the size of the log information is smaller than the preset threshold, the disk writing task will not be woken up.

[0171] After the core interrupt is turned on, the interrupts and tasks within the core can run normally.

[0172] The method for determining whether the size of the unwritten log information is less than the preset threshold value can be: assuming that the current write completion position (write_tail) of the log buffer is b, and the data reading position (read_head) of the log buffer is c, if the current write completion position b of the log buffer is greater than the data reading position c of the log buffer, then the size of the unwritten log information is the value of the current write completion position b of the log buffer minus the data reading position c of the log buffer; if the current write completion position b of the log buffer is less than the data reading position c of the log buffer, then the size of the unwritten log information is the value of the data reading position c of the log buffer minus the current write completion position b of the log buffer.

[0173] Since the solid-state drive can only be written according to the size of the preset threshold, when the size of the unwritten log information is less than the preset threshold, it cannot be written and exits; when the size of the unwritten log information is not less than the preset threshold, it can be written, at which time the semaphore is released and the disk writing thread is awakened.

[0174] Please refer to Figure 6 Based on any of the above embodiments, in one embodiment of the present invention, the log storage method may include:

[0175] Step S201: obtaining physical information of log information from a log buffer in a redundant inexpensive disk array; the physical information includes the address and size of the log information; the redundant inexpensive disk array includes multiple cores, and the log information is transmitted from the core to the log buffer.

[0176] Step S202: Block and wait for log information to be written into the solid state drive.

[0177] It should be noted that before blocking the log information waiting to be written to the SSD, you must ensure that the SSD is ready.

[0178] The purpose of blocking and waiting for log information is to ensure that the size of the log information is not less than a preset threshold value to meet the requirements of the solid-state drive write request.

[0179] Step S203: Control the interruption of the core in the inexpensive redundant disk array to be turned off, and control the cores other than the core to be in a spin lock state.

[0180] Disable interrupts and lock the spin lock to gain exclusive access to the log buffer.

[0181] Step S204: determine whether the size of the log information to be written into the solid state drive is less than a preset threshold.

[0182] This step is judged based on the relative position of the current write completion position (write_tail) of the log buffer and the data read position (read_head) of the log buffer. The current write completion position (write_tail) of the log buffer is b, and the data read position (read_head) of the log buffer is c. If the current write completion position b of the log buffer is greater than the data read position c of the log buffer, the size of the log information to be written is the value of the current write completion position b of the log buffer minus the data read position c of the log buffer; if the current write completion position b of the log buffer is less than the data read position c of the log buffer, the size of the log information to be written is the value of the data read position c of the log buffer minus the current write completion position b of the log buffer.

[0183] Step S205: If the size of the log information is smaller than the preset threshold, proceed to step S202 until the size of the log information is no smaller than the preset threshold.

[0184] The size of the log information is smaller than the preset threshold, indicating that the SSD write requirement is not met.

[0185] Step S206: If the size of the log information is not less than the preset threshold, the address of the log information is set as the data reading position of the log buffer.

[0186] Step S207: extract first target log information whose size is a preset threshold from the log information, and fill the fill flag of the first target log information with the first flag bit.

[0187] For example, when the size of the log information to be written is 5 KB and the preset threshold size is 4 KB, 4 KB of log information is taken from the log information to be written as the first target log information.

[0188] When there is remaining log information, return to step S202.

[0189] The fill flag indicates whether the log information is filled with other data to make the size of the log information equal to the preset threshold.

[0190] The first flag indicates that the first target log information has no other data to fill in, and the size of the first target log information is a preset threshold. In this embodiment, the symbol of the first flag is not limited, including but not limited to any one of numbers, letters, and characters. For example, the first flag can be 0.

[0191] Step S208: Adjust the data reading position in the log buffer.

[0192] It should be noted that the present embodiment does not limit the manner of adjusting the data reading position in the log buffer.

[0193] As an implementable method, adjusting the log buffer data reading position includes:

[0194] Step S2081: Determine the sum of the set log buffer data reading position and the preset threshold.

[0195] Step S2082: determine the remainder of dividing the sum value by the capacity of the log buffer.

[0196] Step S2083: Set the remainder as the adjusted position of the log buffer data reading position.

[0197] Step S209: unlock the interrupt of the core and the spin locks of other cores.

[0198] After unlocking, other cores can output log information.

[0199] Step S210: Generate a write request for the solid state drive; the write request includes physical information.

[0200] Step S211: Send a write request to the solid state drive, so that the solid state drive moves the log information from the log buffer to the log storage area of ​​the solid state drive.

[0201] The present invention also provides a log storage method, which includes: when the log buffer in the inexpensive redundant disk array stores log information and the size of the log information is not less than a preset threshold value, the method comprises:

[0202] Receive a disk write request; the disk write request includes physical information of the log information, and the physical information includes the address and size of the log information;

[0203] The log information is moved from the log buffer to the log storage area of ​​the solid-state drive according to the write request.

[0204] The log information is moved by Direct Memory Access (DMA) in the solid-state drive.

[0205] The method in this embodiment is implemented from the perspective of a solid state drive. The received write request is sent by a cheap redundant disk array.

[0206] Please refer to Figure 7 Based on any of the above embodiments, in one embodiment of the present invention, the log storage method may include:

[0207] Step S301: receiving a disk write request; the disk write request includes physical information of the log information, and the physical information includes the address and size of the log information.

[0208] Step S302: The log information is transferred from the log buffer to the log storage area of ​​the solid state drive according to the disk write request.

[0209] Step S303: Send the interrupt processing function to the firmware so that the firmware completes the interrupt processing function.

[0210] After the solid-state drive has finished moving the log information, the Direct Memory Access (DMA) will send a completion interrupt to the firmware to complete the interrupt processing process.

[0211] The SSD write operation is to transfer the log information from the log buffer to the SSD through DMA. It is an asynchronous process. When the DMA transfer is completed, an interrupt will be issued to notify the firmware that the data transfer is completed. Only when the write request to the same address is completed, the next transfer to the same address can be performed, otherwise it will cause data confusion.

[0212] In this embodiment, there is no limitation on the method of completing the interrupt processing flow, which can be set by oneself.

[0213] As an implementation method, Figure 8 As shown, the firmware completion interrupt processing function may include:

[0214] Step S31: when the fill flag of the log information is not the second flag bit, and the address of the log information is equal to the completion position of the log buffer writing to the solid state hard disk, adjust the completion position of the log buffer writing to the solid state hard disk.

[0215] The second flag bit indicates that the size of the current log information is less than the preset threshold, and the fill flag of the log information is not the second flag bit, which means that the fill flag of the log information is the first flag bit.

[0216] It should be noted that the second flag bit is not limited in this embodiment and can be set at will. For example, the second flag bit can be any one of a number, a letter, and a character. For example, the second flag bit can be 1.

[0217] When the address of the log information is equal to the completion position (read_tail) of the log buffer writing to the solid-state drive, it means that the currently released address is the first executed solid-state drive write request, and the position of the completion position (read_tail) of the log buffer writing to the solid-state drive is adjusted.

[0218] The adjustment method can be to add a preset threshold to the completion position of writing the log buffer to the solid state drive to obtain a sum value, and then divide the sum value by the size of the log buffer and take the remainder, and the remainder obtained is the adjusted position.

[0219] Step S32: Determine the index position in the log buffer of the position where the adjusted log buffer is written to the solid state drive.

[0220] The adjusted log buffer is written to the solid state drive. The pre-fixed address of the log information in the log buffer is subtracted to obtain a difference, and then the difference is divided by the size of the log information to obtain a ratio, which is the index position. The size of the log information is equal to the preset threshold.

[0221] Step S33: Determine whether the release flag corresponding to the index position is 1.

[0222] The purpose of judging whether the release flag is 1 is to check whether the subsequent index has a released address space.

[0223] Step S34: If the release flag is not 1, release the write request space of the solid state drive and exit.

[0224] If the release flag is not 1, it indicates that the continuously released address space has been retrieved, and the write request space of the solid-state drive can be released and exited.

[0225] Step S35: If the release flag is 1, adjust the log buffer to write to the solid state hard disk completion position.

[0226] Adjusting the position where the log buffer is written to the SSD is done by adding the preset threshold to the position where the log buffer is written to the SSD to get the sum value, and then dividing the sum value by the size of the log buffer and taking the remainder, which is the adjusted position. For example, when the size of the preset threshold is 4KB, it is increased by 4KB.

[0227] Step S36: Clear the release flag corresponding to the index position.

[0228] Step S37, add 1 to the index position to obtain a new index position, and go to step S33.

[0229] After the index position is increased by 1, a new index position is obtained, and then the judgment is repeated.

[0230] As an implementation method, Fig. 9As shown, the firmware completion interrupt processing function may include:

[0231] Step S61: Obtain the address and fill mark of the log information according to the disk write request.

[0232] The fill flag may indicate whether the log information is filled with other data so that the size of the log information is equal to a preset threshold.

[0233] Step S62: Determine whether the fill flag is the second flag.

[0234] Step S63: If the fill flag is the second flag, proceed to step S611.

[0235] The fill flag of the log information is the second flag bit, indicating that the current log information size is smaller than the preset threshold. The write request corresponds to a write-back operation. Data is filled in the log information. It is not a complete write request corresponding to the preset threshold size. It is necessary to release the write request space of the solid-state drive and exit.

[0236] Step S64: If the fill flag is not the second flag bit, determine whether the address of the log information is equal to the position where the log buffer is written to the solid state hard disk.

[0237] The fill flag of the log information is not the second flag bit, that is, the fill flag is the first flag bit, indicating that the current log information size is the preset threshold size, and the corresponding disk write request is a normal request, then the next step can be performed.

[0238] Step S65: If the address of the log information is equal to the position where the log buffer is written into the solid state hard disk, proceed to step S68.

[0239] Step S66: If the address of the log information is not equal to the position where the log buffer is written into the solid state hard disk, the index position of the log information is determined according to the address of the log information, the pre-fixed address of the log information in the log buffer, and the size of the log information.

[0240] When the address of the log information is not equal to the position where the log buffer is written to the solid state drive, it indicates that the write request is executed first, and the index position of the log information with a size equal to the preset threshold in the log buffer is calculated.

[0241] It should be noted that the method for determining the index position is not limited in this embodiment.

[0242] In one embodiment of the present invention, determining the index position of the log information according to the address of the log information, the pre-fixed address of the log information in the log buffer, and the size of the log information includes:

[0243] Determine a third difference between the address of the log information and the pre-fixed address;

[0244] A ratio of the third difference value to the size of the log information is determined, and the ratio is used as an index position of the log information.

[0245] Assuming that the starting address of the log information is x and the pre-fixed address of the log information in the log buffer is y, the third difference is equal to the starting address x of the log information minus the pre-fixed address y of the log information in the log buffer.

[0246] The pre-fixed address of the log information in the log buffer is also the starting address of the log information.

[0247] The size of the log information is equal to the preset threshold, and the third difference divided by the preset threshold is the ratio. The third difference divided by the preset threshold is divisible, that is, an integer is obtained.

[0248] Step S67, set the release flag corresponding to the index position to 1, and go to step S611.

[0249] Step S68: When the fill flag of the log information is not the second flag bit, and the address of the log information is equal to the completion position of the log buffer writing to the solid state hard disk, adjust the completion position of the log buffer writing to the solid state hard disk.

[0250] The adjustment method is to add the preset threshold to the position where the log buffer is written to the solid state drive to obtain a sum value, and then divide the sum value by the size of the log buffer and take the remainder, and the remainder obtained is the adjusted position.

[0251] Step S69: Determine the index position in the log buffer of the position where the adjusted log buffer is written to the solid state drive.

[0252] The adjusted log buffer is written to the solid state drive. The pre-fixed address of the log information in the log buffer is subtracted to obtain a difference, and then the difference is divided by the size of the log information to obtain a ratio, which is the index position. The size of the log information is equal to the preset threshold.

[0253] Step S610: Determine whether the release flag corresponding to the index position is 1.

[0254] Step S611: If the release flag is not 1, release the write request space of the solid state drive and exit.

[0255] Step S612: If the release flag is 1, adjust the log buffer to write to the solid state hard disk completion position.

[0256] Step S613: Clear the release flag corresponding to the index position.

[0257] Step S614, add 1 to the index position to obtain a new index position, and go to step S33.

[0258] Based on the above embodiments, in one embodiment of the present invention, Fig.10 and Fig.11 As shown, the log buffer is a ring buffer, and / or the log storage area is a ring storage area.

[0259] The log buffer is a ring buffer. Using a ring buffer can prevent the log information data from exceeding the log buffer and save space.

[0260] The log storage area is a circular storage area, which can ensure that the log information data does not exceed the log storage area and save space.

[0261] The log storage area is used cyclically, and the most recent log information is always retained. The mapping relationship between the location of log information on disk and the location of log information in the log buffer is:

[0262] Disk location = ssd_log_offset + ssd_total_size % ssd_log_size + log_buf_loc;

[0263] Among them, % means modulo, ssd_log_offset is the base address of the log storage area, ssd_total_size is the size of the log information data that has been written to the disk, ssd_log_size is the size of the log storage area, and log_buf_loc is the offset of the data to be written to the disk in the log buffer.

[0264] In the present invention, when the current write completion position (write_tail) of the log buffer is the same as the data read position (read_head) of the log buffer, it indicates that the log buffer is empty. Fig.10 As shown in the figure, the log buffer is full when the current write allocation position (write_head) of the log buffer is one position before the log buffer write completion position (read_tail). Fig.11 shown.

[0265] The mapping relationship between the location where the log information is stored on the disk and the location of the log information in the log buffer enables the solid state drive log storage area to be recycled and always keep the latest log information.

[0266] In one embodiment of the present invention, when the log information on the core of the inexpensive redundant disk array is output to the log buffer, no invalid characters are stored and no holes exist between two adjacent log information.

[0267] There are no invalid characters and no holes between two adjacent log messages, that is, the log messages are compactly arranged when stored in the log buffer, maximizing the buffer utilization.

[0268] Log information can be a string information. When output, the trailing '\0' identifier is an invalid identifier, such as the log buffer full icon ( Fig.11 ), "abc" and "efg" are stored as shown, arranged closely, without '\0'.

[0269] Based on any of the above embodiments, in one embodiment of the present invention, the log storage method may further include:

[0270] The second target log information whose size is smaller than the preset threshold is written back to the solid state drive.

[0271] The write-back operation can be performed when the log is written to disk abnormally or exits.

[0272] When the content of the log buffer that has not been written back to the SSD is less than the preset threshold, the disk writing task cannot be awakened, and the log information needs to be written back to the SSD at this time. For example, when an exception occurs or before exiting the program, the hard disk log write back interface can be used to write the log information that is less than the preset threshold back to the SSD.

[0273] By performing a write-back operation, all data is written back to the solid-state drive. For log information that is smaller than a preset threshold, the log information can be supplemented to the preset threshold and written back according to the size of the preset threshold.

[0274] The present invention does not limit the manner of the write-back operation, as long as the write-back can be implemented.

[0275] As an implementation method, Fig.12 As shown, writing the second target log information whose size is smaller than the preset threshold back to the solid state drive includes:

[0276] Step S41, controlling the interruption of the core in the inexpensive redundant disk array to be turned off, and controlling the cores other than the core to be in a spin lock state.

[0277] It should be noted that before this step, it has been determined that the solid state drive is in a ready state. If the solid state drive is not ready, it returns directly.

[0278] Disable interrupts for the core and spin-lock other cores for exclusive access to the log buffer.

[0279] Step S42: Determine whether the current write completion position of the log buffer is equal to the current write allocation position of the log buffer.

[0280] Step S43: If the current write completion position of the log buffer is not equal to the current write allocation position of the log buffer, return to step S42.

[0281] If the current write completion position (write_tail) of the log buffer is not equal to the current write allocation position (write_head) of the log buffer, it indicates that there is currently log information being copied and waiting is required. Return to step S42.

[0282] Step S44: If the current write completion position of the log buffer is equal to the current write allocation position of the log buffer, then determine whether there is log information that can be written to the solid-state drive currently.

[0283] When the current write completion position (write_tail) of the log buffer is equal to the current write allocation position (write_head) of the log buffer, it indicates that all current log information has been written, and there will be no data conflict during data filling.

[0284] In this step, it can be determined whether there is log information that can be written to the solid-state drive currently according to the data read position (read_head) of the log buffer and the current write completion position (write_tail) of the log buffer.

[0285] When the data read position (read_head) of the log buffer is equal to the current write completion position (write_tail) of the log buffer, it indicates that there is log information that can be written to the solid-state drive currently; when the data read position (read_head) of the log buffer is not equal to the current write completion position (write_tail) of the log buffer, it indicates that there is no log information that can be written to the solid-state drive currently.

[0286] Step S45: If there is log information that can be written to the solid-state drive currently, then unlock the interrupt and the spin lock.

[0287] After unlocking the interrupt and the spin lock, the process exits.

[0288] Step S46: If there is no log information that can be written to the solid-state drive currently, then set the address of the second target log information to the data read position of the log buffer.

[0289] Step S47: Starting from the current write completion position of the log buffer, use the target data to fill the second target log information so that the size of the second target log information is the preset threshold, and set the filling flag of the filled second target log information.

[0290] The target data can generally be 0. Since the second target log information only reaches the preset threshold after being filled with the target data, the filling flag of the filled second target log information is the second flag bit.

[0291] Step S48: Unlock the interrupt and the spin lock.

[0292] Step S49: Generate a write request for the solid state drive.

[0293] Step S410: Send a disk write request to the solid state drive, so that the solid state drive moves the filled second target log information from the log buffer to the log storage area of ​​the solid state drive.

[0294] Log information data that meets the preset threshold size (for example, 4KB) is written back in a manner aligned with the preset threshold size (for example, 4KB). For log information data that does not meet the preset threshold alignment, the log information data is supplemented with the preset threshold. The supplemented data can be 0 and is written back according to the preset threshold size.

[0295] In summary, the log storage method of the present invention has the following advantages: (1) using a circular buffer to store log information, compactly storing the log information output by multiple cores, removing invalid characters, giving full play to the multi-core parallelism, and maximizing the use of limited buffer space; the specific mapping relationship between the solid-state hard disk log storage area and the log buffer enables the solid-state hard disk log storage area to be used cyclically and always keep the latest data; in response to the requirements of out-of-order execution, preset threshold alignment and asynchronous execution of solid-state hard disk write requests, a write request is generated when the conditions are met, and the address identifier and address index method are used to prevent data confusion caused by asynchronous writing and ensure that the data will not be modified by mistake. (2) When the multi-core RAID card chip writes log information to the log buffer, two write pointers are used, one to identify the write allocation position and the other to identify the write completion position. Different positions use different critical area protection methods at different stages when the log information is output, which not only protects the mutual exclusive access of critical resources, but also maximizes the use of multi-core parallelism. (3) When the log buffer is in use, two read pointers are used, one to mark the starting position and the other to mark the position where the SSD write request is completed. The corresponding pointer is modified according to the status of the SSD write request when it is completed. This ensures that the SSD write request is allocated and written in a timely manner, and also ensures that data confusion will not occur due to asynchronous execution and out-of-order execution of the SSD write request.

[0296] The following is an introduction to a log-placing device provided in an embodiment of the present invention. The log-placing device described below and the log-placing method described above can be referred to each other.

[0297] Fig.13 The structural block diagram of the log storage device provided in the embodiment of the present invention, the log storage device may include:

[0298] The first acquisition module 100 is used to acquire physical information of the log information from the log buffer in the inexpensive redundant disk array; the physical information includes the address and size of the log information; the inexpensive redundant disk array includes multiple cores, and the log information is transmitted from the core to the log buffer;

[0299] The generating module 200 is used to generate a write request for the solid state drive when the size of the log information is not less than a preset threshold; the write request includes physical information;

[0300] The first sending module 300 is used to send a disk write request to the solid state drive, so that the solid state drive transfers the log information from the log buffer to the log storage area of ​​the solid state drive.

[0301] The log-pick-up device of the present embodiment is used to implement the aforementioned log-pick-up method. Therefore, the specific implementation of the log-pick-up device can be seen in the implementation example of the log-pick-up method in the foregoing text. For example, the first acquisition module 100, the generation module 200, and the first sending module 300 are respectively used to implement steps S101, S102, and S103 in the aforementioned log-pick-up method. Therefore, its specific implementation example can refer to the description of the corresponding embodiments of each part, which will not be repeated here.

[0302] In the log disk device of the present embodiment, the log information is stored in the log buffer in the cheap redundant disk array, the physical information of the log information is obtained from the log buffer, and then a write request of the solid state drive is generated, and then the write request is sent to the solid state drive. Since the write request includes the physical information of the log information, the solid state drive moves the log information in the log buffer to the log storage area of ​​the solid state drive. That is, the present invention drops the log information into the solid state drive, replacing the method of transmitting the log information to the serial port, getting rid of the inherent limitations of the simulation platform and the serial port in the related technology, reducing the impact of the log information on the program performance, and shortening the time consumption. In addition, in the present embodiment, what is obtained from the log buffer is the physical information of the log information, not the log information, which can improve the reading efficiency.

[0303] As an implementable embodiment, the log transfer device may further include:

[0304] The output module is used to output the log information on each core in the inexpensive redundant disk array to the log buffer.

[0305] As an implementable embodiment, the output module includes:

[0306] A recording unit, configured to execute step S11, when the core is in the interrupt-off state and the cores other than the core are in the spin-locked state, record the current write allocation position of the log buffer;

[0307] The first judgment unit is used to execute step S12 to judge whether the size of the log information on the core exceeds the current capacity of the log buffer;

[0308] A discarding unit, configured to execute step S13, if the size of the log information on the core exceeds the current capacity of the log buffer, discard the log information;

[0309] The first adjustment unit is used to execute step S14, if the size of the log information on the core does not exceed the current capacity of the log buffer, adjust the current write allocation position of the log buffer to reserve storage space for the log information;

[0310] A first control unit is used to execute step S15, control one core other than the core to unlock the spin lock, use the other core with the unlocked spin lock as a new core, and enter step S11 until all other cores unlock the spin lock;

[0311] The cyclic writing unit is used to execute step S16, cyclically writing the log information into the current write allocation position of the log buffer.

[0312] As an implementable embodiment, the output module may further include:

[0313] A first determining unit is used to determine a first difference between a current write allocation position of the log buffer and a position where the log buffer is written to the solid state hard disk; the first difference is greater than or equal to zero;

[0314] The second determining unit is used to determine a second difference between the total capacity of the log buffer and the first difference, and use the second difference as the size of the log information on the core.

[0315] As an implementable embodiment, the output module may further include:

[0316] A second judgment unit is used to judge whether the current write completion position of the log buffer is the same as the current write allocation position of the log buffer;

[0317] The second adjustment unit is used to adjust the current write completion position of the log buffer if the current write completion position of the log buffer is the same as the current write allocation position of the log buffer.

[0318] As an implementable embodiment, the output module may further include:

[0319] Open unit, used to open the interrupt of the core;

[0320] A third judgment unit, used to judge whether the size of the unwritten log information is less than a preset threshold based on the current write completion position of the log buffer and the data reading position of the log buffer;

[0321] An exit unit, used for exiting if the size of the unwritten log information is smaller than a preset threshold;

[0322] The release and wake-up unit is used to release the semaphore and wake up the disk writing thread if the size of the unwritten log information is not less than a preset threshold.

[0323] As an implementable embodiment, the log transfer device may further include:

[0324] A blocking module, used to execute step S21, blocking the log information waiting to be written into the solid state drive;

[0325] A control module, used to execute step S22, control the interrupt shutdown of the core in the inexpensive redundant disk array, and control the other cores except the core to be in a spin lock state;

[0326] A first judgment module, used to execute step S23, to judge whether the size of the log information to be written into the solid state drive is less than a preset threshold;

[0327] A repeating module is used to execute step S24, and if the size of the log information is less than the preset threshold, then enter step S21, until the size of the log information is not less than the preset threshold;

[0328] A setting module, used in step S25, if the size of the log information is not less than a preset threshold, setting the address of the log information as a data reading position of the log buffer;

[0329] The fetching and filling module is used to execute step S26, fetch the first target log information whose size is a preset threshold from the log information, and fill the filling flag of the first target log information with the first flag bit;

[0330] A first adjustment module, used to execute step S27, adjusting the data reading position of the log buffer;

[0331] The unlocking module is used to execute step S28, unlock the interrupt of the core and the spin locks of other cores.

[0332] As an implementable embodiment, the adjustment module includes:

[0333] A third determining unit, used to determine a sum of a set log buffer data reading position and a preset threshold;

[0334] A fourth determining unit, used to determine a remainder of dividing the sum value by the capacity of the log buffer;

[0335] The first setting unit is used to set the remainder as the adjusted position of the data reading position in the log buffer.

[0336] As an implementable method, when the output module outputs the log information on the core of the inexpensive redundant disk array to the log buffer, no invalid characters are stored between two adjacent log information and no holes exist.

[0337] As an implementable embodiment, the log transfer device may further include:

[0338] The write-back module is used to write the second target log information whose size is smaller than a preset threshold back to the solid state drive.

[0339] As an implementable embodiment, the write-back module includes:

[0340] A second control unit is used to execute step S41, control the interruption shutdown of the core in the inexpensive redundant disk array, and control the other cores except the core to be in a spin lock state;

[0341] A fourth judgment unit is used to execute step S42, and judge whether the current write completion position of the log buffer is equal to the current write allocation position of the log buffer;

[0342] A returning unit is used to execute step S43, and if the current write completion position of the log buffer is not equal to the current write allocation position of the log buffer, then return to step S42;

[0343] A fifth judgment unit is used to execute step S44, if the current write completion position of the log buffer is equal to the current write allocation position of the log buffer, then judge whether there is log information that can be written to the solid state hard disk;

[0344] A first unlocking unit, configured to execute step S45, unlocking the interrupt and the spin lock if there is currently log information that can be written to the solid state drive;

[0345] A second setting unit is used to execute step S46, if there is no log information that can be written to the solid state hard disk, then set the address of the second target log information as the log buffer data reading position;

[0346] A filling unit, configured to execute step S47, starting from the current write completion position of the log buffer, fill the second target log information with the target data so that the size of the second target log information is a preset threshold, and set a filling flag of the filled second target log information;

[0347] A second unlocking unit, used to execute step S48, unlock the interrupt and the spin lock;

[0348] A generating unit, used to execute step S49 and generate a write request for the solid state drive;

[0349] The sending unit is used to execute step S410 and send a disk write request to the solid state drive, so that the solid state drive transfers the filled second target log information from the log buffer to the log storage area of ​​the solid state drive.

[0350] The present application also provides a log storage device, which, when the log buffer in the inexpensive redundant disk array stores log information and the size of the log information is not less than a preset threshold, comprises:

[0351] The receiving module is used to receive a disk write request; the disk write request includes physical information of the log information, and the physical information includes the address and size of the log information;

[0352] The transport module is used to transport log information from the log buffer to the log storage area of ​​the solid state drive according to the disk write request.

[0353] As an implementable embodiment, the log transfer device may further include:

[0354] The second sending module is used to send the interrupt processing function to the firmware so that the firmware completes the interrupt processing function.

[0355] As an implementable embodiment, the log transfer device may further include:

[0356] A second adjustment module is used to execute step S31, when the fill flag of the log information is not the second flag bit, and the address of the log information is equal to the completion position of the log buffer writing to the solid state hard disk, adjust the completion position of the log buffer writing to the solid state hard disk;

[0357] A first determination module is used to execute step S32, determine the index position of the adjusted log buffer writing completion position in the log buffer;

[0358] A second judgment module is used to execute step S33 to judge whether the release flag corresponding to the index position is 1;

[0359] A release module, configured to execute step S34, release the write request space of the solid state drive if the release flag is not 1, and exit;

[0360] A third adjustment module is used to execute step S35, and if the release flag is 1, adjust the completion position of writing the log buffer into the solid state hard disk;

[0361] A clearing module, used to execute step S36, clearing a release flag corresponding to the index position;

[0362] An additional module is provided to execute step S37, add 1 to the index position to obtain a new index position, and enter step S33.

[0363] As an implementable embodiment, the log transfer device may further include:

[0364] The second acquisition module is used to obtain the address and fill mark of the log information according to the disk write request;

[0365] The third judgment module is used to judge whether the filling flag is the second flag position; if the filling flag is the second flag position, the process proceeds to step S34;

[0366] The fourth judgment module is used to judge whether the address of the log information is equal to the position where the log buffer is written to the solid state hard disk if the fill flag is not the second flag bit; if the address of the log information is equal to the position where the log buffer is written to the solid state hard disk, then enter step S31;

[0367] A second determination module is used to determine the index position of the log information according to the address of the log information, the pre-fixed address of the log information in the log buffer and the size of the log information if the address of the log information is not equal to the position where the log buffer is written into the solid state hard disk;

[0368] The release flag setting module is used to set the release flag corresponding to the index position to 1 and enter step S34.

[0369] As an implementable embodiment, the second determination module includes:

[0370] a fifth determining unit, configured to determine a third difference between an address of the log information and a pre-fixed address;

[0371] The sixth determining unit is used to determine a ratio of the third difference to the size of the log information, and use the ratio as an index position of the log information.

[0372] The following is an introduction to a computer program product provided by an embodiment of the present invention. The computer program product described below and the log storage method described above can be referenced to each other.

[0373] The present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the log storage method in any of the above embodiments.

[0374] The electronic device provided by the embodiment of the present invention is introduced below. The electronic device described below and the log storage method described above can be referred to each other.

[0375] The present invention also provides an electronic device, such as Fig.14 As shown, including:

[0376] A memory 11, used for storing computer programs;

[0377] The processor 12 is used to implement the steps of the log storage method of any of the above embodiments when executing a computer program.

[0378] The electronic device provided by the embodiment of the present invention is introduced below. The electronic device described below and the log storage method described above can be referred to each other.

[0379] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the log storage method in any of the above embodiments are implemented.

[0380] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0381] 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 composition and steps of each example have been generally described in the above description according to function. 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 to be beyond the scope of the present invention.

[0382] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0383] The log storage method, device, program product, electronic device and computer-readable storage medium provided by the present invention are introduced in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the scheme of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.

Claims

1. A method for storing logs on a disk, characterized in that: include: Obtain physical information of log information from the log buffer in the inexpensive redundant disk array; The physical information includes the address and size of the log information; the inexpensive redundant disk array includes a plurality of cores, and the log information is transmitted from the cores to the log buffer; When the size of the log information is not less than a preset threshold, generating a write request for the solid state drive; the write request includes the physical information; The write request is sent to the solid state drive, so that the solid state drive moves the log information from the log buffer to the log storage area of ​​the solid state drive.

2. The log storage method according to claim 1, characterized in that: Before obtaining the physical information of the log information from the log buffer in the inexpensive redundant disk array, it also includes: The log information on each core in the inexpensive redundant disk array is output to the log buffer.

3. The log storage method according to claim 2, characterized in that: Outputting the log information on each core in the inexpensive redundant disk array to the log buffer includes: Step S11, when the core is in the interrupt-off state, and the cores other than the core are in the spin-locked state, recording the current write allocation position of the log buffer; Step S12, determining whether the size of the log information on the core exceeds the current capacity of the log buffer; Step S13: If the size of the log information on the core exceeds the current capacity of the log buffer, the log information is discarded; Step S14: If the size of the log information on the core does not exceed the current capacity of the log buffer, adjust the current write allocation position of the log buffer to reserve storage space for the log information; Step S15, controlling a core other than the core to unlock the spin lock, taking the core with the unlocked spin lock as a new core, and entering step S11 until all other cores have unlocked their spin locks; Step S16: cyclically write the log information into the current write allocation position of the log buffer.

4. The log storage method according to claim 3, characterized in that: Before determining whether the size of the log information on the core exceeds the current capacity of the log buffer, the method further includes: Determine a first difference between a current write allocation position of the log buffer and a position where the log buffer is written to the solid state drive; the first difference is greater than or equal to zero; A second difference between the total capacity of the log buffer and the first difference is determined, and the second difference is used as the size of the log information on the core.

5. The log storage method according to claim 3, characterized in that: After the log information is cyclically written into the current write allocation position of the log buffer, the method further includes: Determine whether the current write completion position of the log buffer is the same as the current write allocation position of the log buffer; If the current write completion position of the log buffer is the same as the current write allocation position of the log buffer, the current write completion position of the log buffer is adjusted.

6. The log storage method according to claim 5, characterized in that: After adjusting the current write completion position of the log buffer, the method further includes: Enable interrupts for the core; Based on the current write completion position of the log buffer and the data reading position of the log buffer, determining whether the size of the unwritten log information is less than a preset threshold; If the size of the unwritten log information is smaller than the preset threshold, exit; If the size of the unwritten log information is not less than the preset threshold, the semaphore is released and the disk writing thread is awakened.

7. The log storage method according to claim 1, characterized in that: When the size of the log information is not less than the preset threshold, before generating a write request to the solid state drive, the following steps are also included: Step S21, blocking the log information waiting to be written into the solid state drive; Step S22, controlling the interruption of the core in the inexpensive redundant disk array to be turned off, and controlling the other cores except the core to be in a spin lock state; Step S23, determining whether the size of the log information to be written into the solid state drive is less than a preset threshold; Step S24: If the size of the log information is smaller than the preset threshold, proceed to step S21 until the size of the log information is not smaller than the preset threshold; Step S25: if the size of the log information is not less than the preset threshold, setting the address of the log information as the log buffer data reading position; Step S26, taking out first target log information whose size is the preset threshold from the log information, and filling the fill flag of the first target log information with the first flag bit; Step S27, adjusting the data reading position of the log buffer; Step S28: unlock the interrupt of the core and the spin locks of other cores.

8. The log storage method according to claim 7, characterized in that: Adjusting the data reading position of the log buffer includes: Determine the sum of the set log buffer data reading position and the preset threshold; Determine the remainder of dividing the sum by the capacity of the log buffer; The remainder is set as the adjusted position of the log buffer data reading position.

9. The log storage method according to claim 1, characterized in that: The log buffer is a ring buffer, and / or the log storage area is a ring storage area.

10. The log transfer method according to any one of claims 1 to 9, characterized in that: Also includes: The second target log information whose size is smaller than a preset threshold is written back to the solid state drive.

11. The log storage method according to claim 10, characterized in that: Writing the second target log information whose size is smaller than a preset threshold back to the solid state drive includes: Step S41, controlling the interruption of the core in the inexpensive redundant disk array to be turned off, and controlling the other cores except the core to be in a spin lock state; Step S42, determining whether the current write completion position of the log buffer is equal to the current write allocation position of the log buffer; Step S43: If the current write completion position of the log buffer is not equal to the current write allocation position of the log buffer, return to step S42; Step S44: if the current write completion position of the log buffer is equal to the current write allocation position of the log buffer, then determine whether there is log information that can be written to the solid state drive; Step S45: If there is currently log information that can be written to the solid state drive, unlock the interrupt and spin lock; Step S46: if there is no log information that can be written to the solid state drive, then the address of the second target log information is set as the log buffer data reading position; Step S47: starting from the current write completion position of the log buffer, fill the second target log information with target data so that the size of the second target log information is a preset threshold, and set a fill flag of the second target log information after filling; Step S48, unlocking the interrupt and the spin lock; Step S49, generating a write request for the solid state drive; Step S410: Send the write request to the solid state drive, so that the solid state drive moves the filled second target log information from the log buffer to the log storage area of ​​the solid state drive.

12. A method for storing logs on a disk, characterized in that: When the log buffer in the redundant array of inexpensive disks stores log information and the size of the log information is not less than a preset threshold, including: receiving a disk write request; the disk write request includes physical information of the log information, and the physical information includes an address and a size of the log information; The log information is transferred from the log buffer to the log storage area of ​​the solid state drive according to the disk write request.

13. The log storage method according to claim 12, characterized in that: After the log information is transferred from the log buffer to the log storage area of ​​the solid state drive according to the write request, the method further includes: The interrupt processing function is sent to the firmware so that the firmware completes the interrupt processing function.

14. The log storage method according to claim 13, characterized in that: The firmware completes the interrupt processing function including: Step S31, when the fill flag of the log information is not the second flag bit, and the address of the log information is equal to the completion position of the log buffer writing to the solid state hard disk, adjusting the completion position of the log buffer writing to the solid state hard disk; Step S32, determining the index position of the adjusted log buffer writing completion position in the solid state drive in the log buffer; Step S33, determining whether the release flag corresponding to the index position is 1; Step S34: if the release flag is not 1, release the write request space of the solid state drive and exit; Step S35: If the release flag is 1, adjusting the log buffer to write to the solid state hard disk completion position; Step S36, clearing the release flag corresponding to the index position; Step S37, add 1 to the index position to obtain a new index position, and go to step S33.

15. The log storage method according to claim 14, characterized in that: When the fill flag of the log information is not the second flag bit, and the address of the log information is equal to the completion position of the log buffer writing to the solid state hard disk, before adjusting the completion position of the log buffer writing to the solid state hard disk, the method further includes: According to the disk write request, obtain the address and fill mark of the log information; Determine whether the fill flag is the second flag bit; If the fill flag is the second flag bit, proceed to step S34; If the fill flag is not the second flag bit, determining whether the address of the log information is equal to the position where the log buffer is written into the solid state hard disk; If the address of the log information is equal to the position where the log buffer is written into the solid state hard disk, then the process proceeds to step S31; If the address of the log information is not equal to the position where the log buffer is written into the solid state hard disk, determining the index position of the log information according to the address of the log information, the pre-fixed address of the log information in the log buffer and the size of the log information; The release flag corresponding to the index position is set to 1, and the process proceeds to step S34.

16. The log storage method according to claim 15, characterized in that: Determining the index position of the log information according to the address of the log information, the pre-fixed address of the log information in the log buffer, and the size of the log information includes: Determine a third difference between the address of the log information and the pre-fixed address; A ratio of the third difference to the size of the log information is determined, and the ratio is used as an index position of the log information.

17. A log plate-loading device, characterized in that: include: A first acquisition module is used to acquire physical information of log information from a log buffer in a cheap redundant disk array; The physical information includes the address and size of the log information; A generating module, configured to generate a write request for the solid state drive when the size of the log information is not less than a preset threshold; the write request includes the physical information; The first sending module is used to send the disk write request to the solid state drive, so that the solid state drive transfers the log information from the log buffer to the log storage area of ​​the solid state drive.

18. A computer program product, characterized in that The method comprises a computer program / instruction, which, when executed by a processor, implements the steps of the log storage method as claimed in any one of claims 1 to 16.

19. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is used to implement the steps of the log storage method as claimed in any one of claims 1 to 16 when executing the computer program.

20. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the log storage method according to any one of claims 1 to 16 are implemented.