CN114253820A - Log recording method and related device - Google Patents

Log recording method and related device Download PDF

Info

Publication number
CN114253820A
CN114253820A CN202210174258.8A CN202210174258A CN114253820A CN 114253820 A CN114253820 A CN 114253820A CN 202210174258 A CN202210174258 A CN 202210174258A CN 114253820 A CN114253820 A CN 114253820A
Authority
CN
China
Prior art keywords
space
preset
log data
target space
size
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210174258.8A
Other languages
Chinese (zh)
Inventor
费卫宏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202210174258.8A priority Critical patent/CN114253820A/en
Publication of CN114253820A publication Critical patent/CN114253820A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Abstract

The application discloses a log recording method, which comprises the following steps: caching log data generated by solid state disk firmware into a memory; the method comprises the steps that log data cached in a memory are printed in a nonvolatile random access storage medium through a flash memory control module; judging whether the available space of a preset externally stored target space reaches the size of a preset space or not; if so, calling a preset application program interface, and writing the log data generated by the solid state disk firmware into a preset target space of external storage; and if the log data is not reached, erasing the written log data in the target space to enable the available space to reach the size of the preset space, and then calling a preset application program interface to write the log data generated by the solid state disk firmware into the target space of the preset external storage. The log recording method can guarantee successful log recording and is beneficial to problem troubleshooting. The application also discloses a log recording device, equipment and a computer readable storage medium, which have the technical effects.

Description

Log recording method and related device
Technical Field
The application relates to the technical field of solid state disks, in particular to a log recording method; it also relates to a logging apparatus, a device and a computer readable storage medium.
Background
After the SSD (Solid State Disk) firmware runs, a general logging manner is as follows: log data generated by SSD firmware is stored to a specific block (unit in flash memory, minimum unit of erasure) location in NAND-flash (a non-volatile random access storage medium). In the log Data storage process, firstly, the log Data is cached in a DDR (Double Data Rate SDRAM), and when the Data in the DDR is accumulated to a certain amount, the Data in the DDR is printed to the NAND-Flash by an FCC (Flash Channel Control) in firmware. However, by adopting the log recording mode, when the situation that the data stream of the NAND-flash operation is obstructed due to the fact that the FCC is hung up and the CPU core is abnormal occurs, the log data cannot be normally printed on the NAND-flash, so that the log cannot be successfully recorded, and further problems are not solved.
In view of this, how to guarantee successful log recording becomes a technical problem to be solved urgently by those skilled in the art.
Disclosure of Invention
The application aims to provide a log recording method, which can guarantee successful log recording and is beneficial to problem troubleshooting. Another object of the present application is to provide a logging apparatus, a device and a computer readable storage medium, all having the above technical effects.
In order to solve the above technical problem, the present application provides a log recording method, including:
caching log data generated by solid state disk firmware into a memory;
the method comprises the steps that log data cached in a memory are printed in a nonvolatile random access storage medium through a flash memory control module;
judging whether the available space of a preset externally stored target space reaches the size of a preset space or not;
if so, calling a preset application program interface, and writing the log data generated by the solid state disk firmware into a preset target space of external storage;
and if not, erasing the written log data in the target space to enable the available space to reach the size of the preset space, calling the preset application program interface after the available space reaches the size of the preset space, and writing the log data generated by the solid state disk firmware into the target space of the preset external storage.
Optionally, the determining whether the available space of the target space of the preset external storage reaches the size of the preset space includes:
searching a head address and a tail address of the target space;
obtaining the size of the available space according to the head address and the tail address of the target space;
and judging whether the available space reaches the size of the preset space or not by comparing the size of the available space with the size of the preset space.
Optionally, the searching for the head address of the target space includes:
and traversing the target space by adopting a dichotomy by taking bytes with a first preset length as a unit to search the head address.
Optionally, the searching for the tail address of the target space includes:
and traversing the target space by adopting a dichotomy by taking bytes with a second preset length as a unit, and searching a tail address of the target space.
Optionally, the erasing the written log data in the target space to make the available space of the target space reach the preset space size includes:
and erasing the written log data in the target space from the head address to enable the available space to reach the size of the preset space.
Optionally, the preset external storage is a nor-flash or an EEPROM.
Optionally, the method further includes:
judging whether a thread executes the operation of writing log data into the target space currently or not;
and if the current thread executes the operation of writing the log data into the target space, prohibiting other threads from executing the operation of writing the log data into the target space.
In order to solve the above technical problem, the present application further provides a log recording apparatus, including:
the cache module is used for caching the log data generated by the solid state disk firmware into a memory;
the lower brushing module is used for brushing the log data cached in the memory into the nonvolatile random access storage medium through the flash memory control module;
the judging module is used for judging whether the available space of the target space of the preset external storage reaches the size of the preset space;
the writing module is used for calling a preset application program interface if the log data is reached, and writing the log data generated by the solid state disk firmware into a preset target space of external storage;
and the erasing module is used for erasing the written log data in the target space if the written log data does not reach the preset space size, so that the available space reaches the preset space size, and calling the preset application program interface to write the log data generated by the solid state disk firmware into the target space of the preset external storage after the available space reaches the preset space size.
In order to solve the above technical problem, the present application further provides a log recording apparatus, including:
a memory for storing a computer program;
a processor for implementing the steps of the logging method as defined in any of the above when executing the computer program.
To solve the above technical problem, the present application further provides a computer-readable storage medium, having a computer program stored thereon, where the computer program is executed by a processor to implement the steps of the logging method as described in any one of the above.
The log recording method provided by the application comprises the following steps: caching log data generated by solid state disk firmware into a memory; the method comprises the steps that log data cached in a memory are printed in a nonvolatile random access storage medium through a flash memory control module; judging whether the available space of a preset externally stored target space reaches the size of a preset space or not; if so, calling a preset application program interface, and writing the log data generated by the solid state disk firmware into a preset target space of external storage; and if not, erasing the written log data in the target space to enable the available space to reach the size of the preset space, calling the preset application program interface after the available space reaches the size of the preset space, and writing the log data generated by the solid state disk firmware into the target space of the preset external storage.
Therefore, the log recording method provided by the application comprises two independent and parallel log recording processes, and log data generated by the solid state disk firmware can be stored by taking a nonvolatile random access storage medium as a storage medium and by taking external storage as the storage medium. When the log data cannot be brushed to the nonvolatile random access storage medium due to the hanging of FCC and the like, the key log data can be recorded by the nonvolatile random access storage medium for problem troubleshooting. Therefore, the successful recording of the log can be guaranteed, and problem troubleshooting is facilitated.
The log recording device, the log recording equipment and the computer-readable storage medium have the technical effects.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the prior art and the embodiments are briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a schematic flowchart of a log recording method according to an embodiment of the present application;
fig. 2 is a schematic diagram of a logging apparatus according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram of a logging device according to an embodiment of the present application.
Detailed Description
The core of the application is to provide a log recording method, which can ensure the successful recording of the log and is beneficial to problem troubleshooting. Another core of the present application is to provide a logging apparatus, a device and a computer readable storage medium, all having the above technical effects.
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a schematic flow chart of a log recording method according to an embodiment of the present application, and referring to fig. 1, the method mainly includes:
s101: caching log data generated by solid state disk firmware into a memory;
s102: the method comprises the steps that log data cached in a memory are printed in a nonvolatile random access storage medium through a flash memory control module;
s103: judging whether the available space of a preset externally stored target space reaches the size of a preset space or not;
s104: if so, calling a preset application program interface, and writing the log data generated by the solid state disk firmware into a preset target space of external storage;
s105: and if not, erasing the written log data in the target space to enable the available space to reach the size of the preset space, calling the preset application program interface after the available space reaches the size of the preset space, and writing the log data generated by the solid state disk firmware into the target space of the preset external storage.
The logging method provided by the embodiment comprises two independent and parallel logging processes. In the log recording process, a nonvolatile random access storage medium, namely NAND-flash, is used as the storage medium, log data generated by solid state disk firmware is firstly cached in a memory (such as DDR), and when the data in the memory reaches a certain amount, the log data cached in the memory is then downloaded to the nonvolatile random access storage medium through FCC.
In the other log recording process, an external storage is used as a storage medium, and logs generated by the solid state disk firmware are directly recorded into a preset external storage through an application program interface. The predetermined external memory may be a nor-flash (a non-volatile flash memory) or an EEPROM (Electrically Erasable Programmable read only memory).
For a logging process with an external storage as a storage medium, a space for storing log data is reserved in advance in a preset external storage. The target space is a space for storing the log. For example, a space of 1Mbyte is reserved in the preset external storage for storing log data.
When log data are generated in the solid state disk firmware, firstly, judging whether the available space of a preset externally stored target space reaches the size of a preset space; if the log data is obtained, the available space can meet the requirement of writing the log data, and at the moment, a preset application program interface is called to write the log data into a preset target space of external storage; if the available space does not meet the requirement for writing the log data, the written log data in the target space is firstly erased, so that the available space of the target space reaches the preset space size, and then the preset application program interface is called after the available space of the target space reaches the preset space size, and the log data is written into the target space of the preset external storage.
In some embodiments, the manner of determining whether the available space of the target space of the preset external storage reaches the preset space size is as follows: searching a head address and a tail address of the target space; obtaining the size of the available space according to the head address and the tail address of the target space; and judging whether the available space reaches the size of the preset space or not by comparing the size of the available space with the size of the preset space.
The embodiment reserves a certain size of space in the preset external storage to be used as a ring buffer. The head address indicates the end address of the log record, and the tail address indicates the address at which the next log record starts. The space between the tail address and the head address where no log data has been written is available. Therefore, when judging whether the available space of the target space reaches the preset space size, firstly searching a head address and a tail address of the target space, obtaining the size of the available space according to the head address and the tail address, and then comparing the size of the available space with the preset space size to judge whether the available space reaches the preset space size.
For the value of the preset space size, the method and the device are not limited uniquely, and difference setting can be carried out.
For example, the preset space size is 64KB, and if the available space is greater than or equal to 64KB, the available space reaches the preset space size. Conversely, if the available space is less than 64KB, the available space does not reach the preset space size.
On the basis of the foregoing embodiment, as a specific implementation manner, a manner of searching for a header address of the target space may be:
and traversing the target space by adopting a dichotomy by taking bytes with a first preset length as a unit to search the head address.
For example, the first preset length is 4kbyte, and with 4kbyte as a unit, the whole target space is traversed by adopting a binary method to search the head address of the target space.
On the basis of the foregoing embodiment, as a specific implementation manner, a manner of searching for the tail address of the target space may be:
and traversing the target space by adopting a dichotomy by taking bytes with a second preset length as a unit, and searching a tail address of the target space.
For example, the second preset length is 128 bytes, and the whole target space is traversed by adopting a binary method with 128 bytes as a unit to find the tail address of the target space.
Further, on the basis of the foregoing embodiment, as a specific implementation manner, erasing the log data written in the target space, so that the available space of the target space reaches the preset space size, includes:
and erasing the written log data in the target space from the head address to enable the available space to reach the size of the preset space.
The written partial log data is erased from the head address, so that the log data with earlier writing time can be preferentially erased, and the log data written recently can be kept as much as possible.
Further, on the basis of the above embodiment, as a specific implementation manner, the method further includes:
judging whether a thread executes the operation of writing log data into the target space currently or not;
and if the current thread executes the operation of writing the log data into the target space, prohibiting other threads from executing the operation of writing the log data into the target space.
A plurality of threads of a CPU (Central Processing Unit) may each perform an operation of writing log data into a target space of a preset external storage. In order to avoid the situations of log data duplication, errors and the like which may be caused by the simultaneous writing of the log data into the target space of the preset external storage by the multiple threads, the present embodiment performs locking protection, and prohibits the simultaneous execution of the operation of writing the log data into the preset external storage by the multiple threads. If a thread writes log data into the target space within a certain time, other threads are prohibited from executing the operation of writing the log data into the target space within the certain time.
In addition, for the head address global shared variable and the tail address global shared variable, the application program interface also updates the state, and updates the values of the head address shared variable and the tail address shared variable to the current actual positions of the head address and the tail address.
In summary, the log recording method provided by the present application includes two independent and parallel log recording processes, and the log data generated by the solid state disk firmware may be stored not only by using the nonvolatile random access storage medium as the storage medium, but also by using the external storage as the storage medium. When the log data cannot be brushed to the nonvolatile random access storage medium due to the hanging of FCC and the like, the key log data can be recorded by the nonvolatile random access storage medium for problem troubleshooting. Therefore, the successful recording of the log can be guaranteed, and problem troubleshooting is facilitated.
The application also provides a logging device, which can be correspondingly referred to with the method described above. Referring to fig. 2, fig. 2 is a schematic diagram of a logging apparatus according to an embodiment of the present disclosure, and referring to fig. 2, the logging apparatus includes:
the cache module 10 is configured to cache log data generated by the solid state disk firmware in a memory;
the lower brushing module 20 is used for brushing the log data cached in the memory into the nonvolatile random access storage medium through the flash memory control module;
the judging module 30 is configured to judge whether an available space of a preset target space of the external storage reaches a preset space size;
the writing module 40 is configured to call a preset application program interface if the target space is reached, and write log data generated by the solid state disk firmware into a preset target space of an external storage;
and the erasing module 50 is configured to erase the written log data in the target space if the written log data does not reach the preset space size, so that the available space reaches the preset space size, and call the preset application program interface to write the log data generated by the solid state disk firmware into the target space of the preset external storage after the available space reaches the preset space size.
Specifically, the logging apparatus provided in this embodiment implements two independent and parallel logging processes through each module. In the log recording process, a nonvolatile random access storage medium is used as a storage medium, log data generated by solid state disk firmware is firstly cached in a memory (such as DDR), and when the data in the memory reaches a certain amount, the log data cached in the memory is downloaded to the nonvolatile random access storage medium through FCC. The logging process is implemented by the cache module 10 and the flush module 20.
In the other log recording process, an external storage is used as a storage medium, and logs generated by the solid state disk firmware are directly recorded into a preset external storage through an application program interface. The logging process is implemented by the determining module 30, the writing module 40, and the erasing module 50.
For a logging process with an external storage as a storage medium, a space for storing log data is reserved in advance in a preset external storage. The target space is a space for storing the log. For example, a space of 1Mbyte is reserved in the preset external storage for storing log data.
When log data is generated in the solid state disk firmware, the determining module 30 first determines whether an available space of a target space of a preset external storage reaches a preset space size; if the available space can meet the requirement of writing the log data, the writing module 40 calls a preset application program interface to write the log data into a preset target space of external storage; if the available space does not meet the requirement for writing the log data, the erasing module 50 erases part of the written log data in the target space to make the available space of the target space reach the preset space size, and then calls the preset application program interface to write the log data into the preset externally stored target space after the available space of the target space reaches the preset space size.
On the basis of the foregoing embodiment, as a specific implementation manner, the determining module 30 includes:
the searching unit is used for searching a head address and a tail address of the target space;
the calculation unit is used for obtaining the size of the available space according to the head address and the tail address of the target space;
and the comparison unit is used for comparing the size of the available space with the size of the preset space and judging whether the available space reaches the size of the preset space.
Specifically, the present embodiment reserves a space of a certain size in the preset external storage to be used as a ring buffer. The head address indicates the end address of the log record, and the tail address indicates the address at which the next log record starts. The space between the tail address and the head address where no log data has been written is available. Therefore, when the determining module 30 determines whether the available space of the target space reaches the preset space size, the searching unit searches the head address and the tail address of the target space, the calculating unit obtains the size of the available space according to the head address and the tail address, and the comparing unit determines whether the available space reaches the preset space size by comparing the size of the available space with the preset space size.
On the basis of the foregoing embodiment, as a specific implementation manner, the searching unit is configured to traverse the target space by using a dichotomy with a byte of a first preset length as a unit, and search the head address.
For example, the first preset length is 4kbyte, and with 4kbyte as a unit, the whole target space is traversed by adopting a binary method to search the head address of the target space.
On the basis of the foregoing embodiment, as a specific implementation manner, the searching unit is configured to traverse the target space by using a binary method with a byte of a second preset length as a unit, and search for a tail address of the target space.
For example, the second preset length is 128 bytes, and the whole target space is traversed by adopting a binary method with 128 bytes as a unit to find the tail address of the target space.
On the basis of the foregoing embodiment, as a specific implementation manner, the erasing unit is configured to erase, starting from the head address, the log data written in the target space, so that the available space reaches the preset space size.
The written partial log data is erased from the head address, so that the log data with earlier writing time can be preferentially erased, and the log data written recently can be kept as much as possible.
On the basis of the above embodiment, as a specific implementation manner, the preset external storage is a nor-flash or an EEPROM.
On the basis of the above embodiment, as a specific implementation manner, the method further includes:
the write operation judging module is used for judging whether a thread executes the operation of writing the log data into the target space at present;
and the write operation forbidding module is used for forbidding other threads to execute the operation of writing the log data into the target space if the current thread executes the operation of writing the log data into the target space.
Specifically, each of the plurality of threads of the CPU may perform an operation of writing log data to a target space of a preset external storage. In order to avoid the situations of log data duplication, errors and the like which may be caused by the simultaneous writing of the log data into the target space of the preset external storage by the multiple threads, the present embodiment performs locking protection, and prohibits the simultaneous execution of the operation of writing the log data into the preset external storage by the multiple threads.
The log recording device comprises two independent and parallel log recording processes, and log data generated by solid state disk firmware can be stored by taking a nonvolatile random access storage medium as a storage medium and by taking external storage as the storage medium. When the log data cannot be brushed to the nonvolatile random access storage medium due to the hanging of FCC and the like, the key log data can be recorded by the nonvolatile random access storage medium for problem troubleshooting. Therefore, the successful recording of the log can be guaranteed, and problem troubleshooting is facilitated.
The present application also provides a logging device, shown with reference to fig. 3, comprising a memory 1 and a processor 2.
A memory 1 for storing a computer program;
a processor 2 for executing a computer program to implement the steps of:
caching log data generated by solid state disk firmware into a memory; the method comprises the steps that log data cached in a memory are printed in a nonvolatile random access storage medium through a flash memory control module; judging whether the available space of a preset externally stored target space reaches the size of a preset space or not; if so, calling a preset application program interface, and writing the log data generated by the solid state disk firmware into a preset target space of external storage; and if not, erasing the written log data in the target space to enable the available space to reach the size of the preset space, calling the preset application program interface after the available space reaches the size of the preset space, and writing the log data generated by the solid state disk firmware into the target space of the preset external storage.
For the introduction of the device provided in the present application, please refer to the above method embodiment, which is not described herein again.
The present application further provides a computer readable storage medium having a computer program stored thereon, which when executed by a processor, performs the steps of:
caching log data generated by solid state disk firmware into a memory; the method comprises the steps that log data cached in a memory are printed in a nonvolatile random access storage medium through a flash memory control module; judging whether the available space of a preset externally stored target space reaches the size of a preset space or not; if so, calling a preset application program interface, and writing the log data generated by the solid state disk firmware into a preset target space of external storage; and if not, erasing the written log data in the target space to enable the available space to reach the size of the preset space, calling the preset application program interface after the available space reaches the size of the preset space, and writing the log data generated by the solid state disk firmware into the target space of the preset external storage.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
For the introduction of the computer-readable storage medium provided in the present application, please refer to the above method embodiments, which are not described herein again.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device, the apparatus and the computer-readable storage medium disclosed by the embodiments correspond to the method disclosed by the embodiments, so that the description is simple, and the relevant points can be referred to the description of the method.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The log recording method, apparatus, device and computer readable storage medium provided by the present application are described in detail above. The principles and embodiments of the present application are explained herein using specific examples, which are provided only to help understand the method and the core idea of the present application. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.

Claims (10)

1. A method of logging, comprising:
caching log data generated by solid state disk firmware into a memory;
the method comprises the steps that log data cached in a memory are printed in a nonvolatile random access storage medium through a flash memory control module;
judging whether the available space of a preset externally stored target space reaches the size of a preset space or not;
if so, calling a preset application program interface, and writing the log data generated by the solid state disk firmware into a preset target space of external storage;
and if not, erasing the written log data in the target space to enable the available space to reach the size of the preset space, calling the preset application program interface after the available space reaches the size of the preset space, and writing the log data generated by the solid state disk firmware into the target space of the preset external storage.
2. The logging method of claim 1, wherein said determining whether the available space of the target space of the preset external storage reaches a preset space size comprises:
searching a head address and a tail address of the target space;
obtaining the size of the available space according to the head address and the tail address of the target space;
and judging whether the available space reaches the size of the preset space or not by comparing the size of the available space with the size of the preset space.
3. The logging method of claim 2, wherein finding the head address of the target space comprises:
and traversing the target space by adopting a dichotomy by taking bytes with a first preset length as a unit to search the head address.
4. The logging method of claim 2, wherein finding the tail address of the target space comprises:
and traversing the target space by adopting a dichotomy by taking bytes with a second preset length as a unit, and searching a tail address of the target space.
5. The logging method of claim 1, wherein erasing the written log data in the target space to make the available space of the target space reach the preset space size comprises:
and erasing the written log data in the target space from the head address to enable the available space to reach the size of the preset space.
6. The logging method of claim 1, wherein said predetermined external storage is nor-flash or EEPROM.
7. The logging method of claim 1, further comprising:
judging whether a thread executes the operation of writing log data into the target space currently or not;
and if the current thread executes the operation of writing the log data into the target space, prohibiting other threads from executing the operation of writing the log data into the target space.
8. A logging apparatus, comprising:
the cache module is used for caching the log data generated by the solid state disk firmware into a memory;
the lower brushing module is used for brushing the log data cached in the memory into the nonvolatile random access storage medium through the flash memory control module;
the judging module is used for judging whether the available space of the target space of the preset external storage reaches the size of the preset space;
the writing module is used for calling a preset application program interface if the log data is reached, and writing the log data generated by the solid state disk firmware into a preset target space of external storage;
and the erasing module is used for erasing the written log data in the target space if the written log data does not reach the preset space size, so that the available space reaches the preset space size, and calling the preset application program interface to write the log data generated by the solid state disk firmware into the target space of the preset external storage after the available space reaches the preset space size.
9. A logging device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the logging method as claimed in any one of claims 1 to 7 when executing said computer program.
10. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, carries out the steps of the logging method as claimed in any one of the claims 1 to 7.
CN202210174258.8A 2022-02-25 2022-02-25 Log recording method and related device Pending CN114253820A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210174258.8A CN114253820A (en) 2022-02-25 2022-02-25 Log recording method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210174258.8A CN114253820A (en) 2022-02-25 2022-02-25 Log recording method and related device

Publications (1)

Publication Number Publication Date
CN114253820A true CN114253820A (en) 2022-03-29

Family

ID=80797083

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210174258.8A Pending CN114253820A (en) 2022-02-25 2022-02-25 Log recording method and related device

Country Status (1)

Country Link
CN (1) CN114253820A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115758206A (en) * 2022-11-07 2023-03-07 武汉麓谷科技有限公司 Method for quickly searching NorFlash last-time writing end position in ZNS solid state disk

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591743B (en) * 2010-11-22 2016-08-03 佳能株式会社 Data processing equipment and access control method
CN107515827A (en) * 2017-08-21 2017-12-26 湖南国科微电子股份有限公司 Storage method, device and the SSD of the self-defined daily records of PCIE SSD
CN107918568A (en) * 2017-11-13 2018-04-17 北京全路通信信号研究设计院集团有限公司 A kind of method for preventing linux system from restarting failure

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591743B (en) * 2010-11-22 2016-08-03 佳能株式会社 Data processing equipment and access control method
CN107515827A (en) * 2017-08-21 2017-12-26 湖南国科微电子股份有限公司 Storage method, device and the SSD of the self-defined daily records of PCIE SSD
CN107918568A (en) * 2017-11-13 2018-04-17 北京全路通信信号研究设计院集团有限公司 A kind of method for preventing linux system from restarting failure

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115758206A (en) * 2022-11-07 2023-03-07 武汉麓谷科技有限公司 Method for quickly searching NorFlash last-time writing end position in ZNS solid state disk
CN115758206B (en) * 2022-11-07 2023-05-16 武汉麓谷科技有限公司 Method for quickly searching last write end position of Norflash in ZNS solid state disk

Similar Documents

Publication Publication Date Title
TWI420303B (en) Method, non-transistory computer readable medium and apparatus for writing data to different portions of memory based on write frequency
EP3588259B1 (en) Garbage collection method for storage media, storage medium, and program product
US6601132B2 (en) Nonvolatile memory and method of writing data thereto
US8910002B2 (en) NAND flash-based storage device with built-in test-ahead for failure anticipation
US8732519B2 (en) Method for using bad blocks of flash memory
CN106909318B (en) Solid state disk using method and device
JP2019168937A (en) Memory system, control method and controller
US10592134B1 (en) Open block stability scanning
US9348708B2 (en) Memory system performing address mapping according to bad page map
US8332696B2 (en) Defect management method for storage medium and system thereof
JP2011503768A5 (en)
JP2011503741A5 (en)
US10162521B2 (en) Media region management based on storage hints for a data storage device
KR20140133427A (en) Method for managing data stored in flash memory and associated memory device and controller
CN110347335B (en) Solid state disk data storage method and device
US20180188981A1 (en) Methods and apparatus for read disturb detection based on logical domain
US10089170B1 (en) Open block management
CN114253820A (en) Log recording method and related device
US20090249140A1 (en) Method for managing defect blocks in non-volatile memory
CN108549588A (en) A method of eliminating TLC flash memory multi-disc program fails
US8527690B2 (en) Optimization of non-volatile solid-state memory by moving data based on data generation and memory wear
JP6306548B2 (en) Memory management circuit, storage device, memory management method, and memory management program
CN110806840A (en) Flash memory card data storage method based on multiple data streams, flash memory card and equipment
KR20120070408A (en) Methods of non-volitile memory device for controlling block
CN111949198A (en) Bad block management method and device and storage equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20220329