Log data storage method, device, electronic device and storage medium

By using MRAM storage medium to save or cache log data when the SSD is powered off abnormally, the problem of log data not being persisted in DRAM is solved, and the rapid writing and persistence of log data is realized, avoiding data loss.

CN116185773BActive Publication Date: 2025-08-29INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310126106.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-16
Publication Date
2025-08-29
Estimated Expiration
2043-02-16

AI Technical Summary

Technical Problem

When the solid state hard disk (SSD) is powered off abnormally, the log data cached in DRAM fails to meet the writing unit requirements of NAND FLASH, resulting in the log data not being persisted and saved, resulting in loss.

Method used

MRAM is used as the storage medium for log data. When power is off abnormally, log data is written to the MRAM storage space for storage or cache. It uses the high performance and non-volatile characteristics of MRAM to realize the rapid writing and persistence of log data.

Benefits of technology

It avoids the loss of log data in electric scenarios under abnormal conditions, realizes rapid writing and persistent storage of log data, and utilizes the high performance and non-volatile characteristics of MRAM.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116185773B_ABST
    Figure CN116185773B_ABST
Patent Text Reader

Abstract

Embodiments of the present invention provide a log data storage method, apparatus, electronic device, and storage medium. The method is applied to a solid-state drive (SSD) including a non-volatile memory (MRAM). The method includes: when the SSD experiences an abnormal power outage, receiving log data to be saved, and writing the log data to the MRAM storage space for log storage; or, alternatively, writing the log data to the MRAM storage space for log caching. By utilizing the high performance and non-volatility of MRAM to save or cache log data, the embodiments of the present invention can achieve rapid writing and persistent storage of log data, avoiding the problem of log data being easily lost in power outage scenarios, especially abnormal power outage scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a log data storage method, a log data storage device, an electronic device, and a computer-readable storage medium. Background Art

[0002] In SSD (Solid State Disk) system applications, the logging module is a key functional module. Upon receiving a request to save log data, the logging module writes the required information to DRAM (Dynamic Random Access Memory) for cache and synchronizes the log information cached in DRAM to non-volatile storage media such as NAND Flash (Not AND) for permanent storage.

[0003] NAND FLASH requires data to be written in pages, so log data cached in DRAM must be written to a full page before being written to NAND. However, in the event of an abnormal power outage, the amount of log data generated during the power-off process may not be an integer multiple of the page size. Furthermore, due to capacitor capacity limitations and a very short system operating time, the log data cached in DRAM may not be persisted due to not fully writing to the page size, resulting in log data loss. Summary of the Invention

[0004] In view of the above problems, embodiments of the present invention are proposed to provide a log data storage method, a log data storage device, an electronic device, and a computer-readable storage medium that overcome the above problems or at least partially solve the above problems.

[0005] To solve the above problems, an embodiment of the present invention discloses a log data storage method, which is applied to a solid-state drive (SSD), wherein the solid-state drive includes a non-volatile memory (Magnetoresistive Random Access Memory) (MRAM), and comprises:

[0006] When the SSD is abnormally powered off, receiving log data to be saved;

[0007] When the save instruction information is received, the log data is written into the MRAM storage space for log storage;

[0008] When the cache indication information is received, the log data is written into the MRAM storage space for log cache.

[0009] Optionally, writing the log data into an MRAM storage space for log storage includes:

[0010] Obtain the number of logs that can be stored in the MRAM storage space and the serial number information of the log data;

[0011] Determining a storage location for the log data based on the number of logs, the sequence number information of the log data, and the log length;

[0012] According to the storage location, the log data is written into the MRAM storage space for storage.

[0013] Optionally, obtaining the number of logs that can be stored in the MRAM storage space includes:

[0014] The ratio of the total storage capacity of the MRAM to the log length is calculated to obtain the number of logs that can be stored in the MRAM storage space.

[0015] Optionally, determining the storage location of the log data according to the number of logs, sequence number information of the log data, and log length includes:

[0016] Performing a modulo operation on the serial number information of the log data and the number of logs to obtain a modulo operation result;

[0017] The product value of the remainder operation result and the log length is calculated, and the storage location of the log data is determined to be the location where the log start storage location is offset by the product value.

[0018] Optionally, the solid-state drive further includes a NAND flash memory, and the MRAM includes at least two log cache areas for caching log data; and writing the log data into the MRAM storage space for log caching includes:

[0019] Acquire the usage status of the at least two log buffer areas, and determine the log buffer area with a usage status of a data receiving state as the target buffer area;

[0020] Writing the log data into the target buffer area;

[0021] When the target cache area is full, the log data in the target cache area is flushed to the NAND for persistent storage.

[0022] Optionally, while flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0023] Switching the use state of the target buffer area from the data receiving state to the data flushing state, switching to the next log buffer area to receive log data, and switching the use state of the next log buffer area to the data receiving state;

[0024] After flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0025] The use state of the target cache area is switched from a data flushing state to an idle state.

[0026] Optionally, the MRAM is further used to store metadata, and after flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0027] Obtaining location information of the log data written on the NAND, current usage information of the NAND storage space, and current usage status of each log buffer area;

[0028] The location information of the log data written in the NAND, the current usage information of the NAND storage space, and the current usage status of each log buffer area are saved in metadata, so that the MRAM manages the log data.

[0029] An embodiment of the present invention further discloses a log data storage device, which is applied to a solid-state drive (SSD), wherein the solid-state drive includes a non-volatile memory (MRAM), and the device includes:

[0030] A data receiving module, configured to receive log data to be saved when the SSD is abnormally powered off;

[0031] A log saving module is configured to write the log data into the MRAM storage space for log saving upon receiving the saving instruction information;

[0032] The log cache module is used to write the log data into the MRAM storage space for log cache when receiving cache indication information.

[0033] Optionally, the log storage module includes:

[0034] An information acquisition submodule, used to obtain the number of logs that can be stored in the MRAM storage space and the serial number information of the log data;

[0035] A location determination submodule, configured to determine a storage location of the log data based on the number of logs, the sequence number information of the log data, and the log length;

[0036] According to the storage location, the log data is written into the MRAM storage space for storage.

[0037] Optionally, the information acquisition submodule includes:

[0038] The log quantity calculation unit is used to calculate the ratio of the total storage capacity of the MRAM to the log length, and obtain the number of logs that can be stored in the MRAM storage space.

[0039] Optionally, the position determination submodule includes:

[0040] a modulo operation unit, configured to perform a modulo operation on the sequence number information of the log data and the number of logs to obtain a modulo operation result;

[0041] The product calculation unit is used to calculate the product value of the remainder operation result and the log length, and determine the storage location of the log data to be the log starting storage location offset by the product value.

[0042] Optionally, the solid-state drive further includes a NAND flash memory, and the MRAM includes at least two log cache areas for caching log data; the log cache module includes:

[0043] A usage status acquisition submodule is configured to acquire the usage status of the at least two log buffer areas, and determine the log buffer area whose usage status is a data receiving state as a target buffer area;

[0044] A cache writing submodule, configured to write the log data into the target cache area;

[0045] The flush module is used to flush the log data in the target cache area to the NAND for persistent storage when the target cache area is full.

[0046] Optionally, while flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0047] The flushing state switching submodule is used to switch the use state of the target buffer area from the data receiving state to the data flushing state, and switch to the next log buffer area to receive log data, and switch the use state of the next log buffer area to the data receiving state;

[0048] After flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0049] The idle state switching submodule is used to switch the use state of the target cache area from the data flushing state to the idle state.

[0050] Optionally, the MRAM is further used to store metadata, and after flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0051] A usage information acquisition submodule is used to obtain the location information of the log data written in the NAND, the current usage information of the NAND storage space, and the current usage status of each log buffer area;

[0052] The log management submodule is used to save the location information of the log data written in the NAND, the current usage information of the NAND storage space, and the current usage status of each log buffer area into metadata, so that the MRAM can manage the log data.

[0053] An embodiment of the present invention further discloses an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the log data storage method described above when executed by the processor.

[0054] An embodiment of the present invention further discloses 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 data storage method described above are implemented.

[0055] The embodiments of the present invention include the following advantages:

[0056] In an embodiment of the present invention, when an abnormal power failure occurs in an SSD, log data to be saved can be received, and MRAM can be used as a storage medium for saving the log data, and the log data can be written to the MRAM storage space for log storage; or, MRAM can be used to cache log data, and the log data can be written to the MRAM storage space for log caching, thereby achieving the functions of fast writing and persistent storage of log data, thereby utilizing the high performance and non-volatility of MRAM to avoid the problem of easy loss of log data in power failure scenarios, especially abnormal power failure scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 This is a flow chart of the steps of a log data storage method provided by an embodiment of the present invention;

[0058] Figure 2 This is a flowchart of another log data storage method provided by an embodiment of the present invention;

[0059] Figure 3 This is a flowchart of another log data storage method provided by an embodiment of the present invention;

[0060] Figure 4This is a structural block diagram of a log data storage device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0061] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0062] In SSD system applications, the log module is an important functional module. A well-designed log module helps users and developers to better and more efficiently maintain and develop SSD products. Currently, the storage devices used in the log module can include DRAM, NAND FLASH (NAND flash memory, Not AND, is AND NOT) and NOR FLASH (NOR flash memory, NOR, is OR NOT). Among them, DRAM can be used for caching log data due to its fast read and write speed and the volatility of data during power failure; NAND FLASH has high data density integration and non-volatility, and can be used for persistent storage of large blocks of log data; NOR FLASH is also non-volatile, but has a smaller capacity, so it is usually used to store critical logs such as log data during power on and off processes.

[0063] The functional implementation process of the log module may include: sending log recording request information to the log module according to actual needs during software operation; after receiving the recording request, the log module can write the information to be recorded into DRAM for caching; the log module can synchronize the log information cached in DRAM to non-volatile storage media such as Flash for permanent storage; when the log needs to be read, the log information recorded in the non-volatile storage medium can be read out and presented to the user in a readable form.

[0064] Abnormal power failure is a critical issue in SSD applications. For enterprise-class SSDs, supporting abnormal power failures is a key feature that must be considered during product design. However, when recording log data, if an abnormal power failure occurs, the system may encounter the following issues:

[0065] 1. During a power-off process, each module in the system generates log data related to the power-off. This log data is sent to the log module together, causing the log module to face greater traffic processing pressure during a power-off than in normal business scenarios.

[0066] 2. In the event of an abnormal power outage, the system will switch to its internal capacitor power supply upon losing external power. However, due to the limited capacity of the system's internal capacitors, the capacitor power supply time is generally in the millisecond level. Therefore, the logging module must ensure that all log data is persisted in such a short period of time, requiring higher data processing performance than a typical power-off process.

[0067] 3. NAND FLASH requires data to be written in pages (a page is typically 4KB / 16KB in size). Therefore, log data cached in DRAM must be written to a full page before being written to NAND. However, in power-off scenarios, especially abnormal power-off scenarios, the amount of log data generated during the power-off process may not be an integer multiple of the page size. Furthermore, due to capacitor limitations and a very short system operating time, the log data cached in DRAM may not be persisted due to not filling the full page size, resulting in log data loss.

[0068] One of the core concepts of the embodiments of the present invention is that when an SSD experiences an abnormal power outage, log data to be saved can be received, and MRAM can be used as a storage medium for saving the log data, and the log data can be written to the MRAM storage space for log storage; or MRAM can be used to cache log data, and the log data can be written to the MRAM storage space for log caching, thereby achieving the functions of fast writing and persistent storage of log data, thereby utilizing the high performance and non-volatility of MRAM to avoid the problem of easy loss of log data in power outage scenarios, especially abnormal power outage scenarios.

[0069] Reference Figure 1 , shows a flowchart of a log data storage method provided by an embodiment of the present invention. The method is applied to a solid-state drive (SSD), which includes a non-volatile memory (MRAM). The method may specifically include the following steps:

[0070] Step 101: receiving log data to be saved when the SSD is abnormally powered off.

[0071] The log data storage method of the embodiment of the present invention can be applied to a solid-state drive (SSD), specifically, it can be applied to a log module in a solid-state drive (SSD) system. The log module may include a log generating unit, a log processing unit, and a log saving unit. The log generating unit, i.e., the business module that generates log data, may send the log data to the log processing unit by calling an external interface provided by the log processing unit; the log processing unit may format, assemble, and limit the received log data, generate predefined log data, and send the predefined log data to the log saving unit; the log saving unit may save the received predefined log data to an MRAM medium, which may be used to manage the storage space for storing log data, specifically including the maintenance of the first address of the log storage and the recovery of the space after it is full, so as to realize the function of circular recording of log data.

[0072] MRAM is a new storage medium that can be read and written on a byte-by-byte basis. Due to its inherent non-volatile nature, it can also support data preservation after a power outage. In an embodiment of the present invention, a solid-state drive (SSD) may include non-volatile MRAM memory. When the SSD experiences an abnormal power outage, the log module in the SSD can receive log data related to the power outage that needs to be saved and sent by other modules, and write the log data to the MRAM storage space, thereby preventing the loss of log data after the SSD experiences an abnormal power outage.

[0073] Step 102: When the save instruction information is received, the log data is written into the MRAM storage space for log storage.

[0074] In practical applications, MRAM is relatively expensive. Users can use MRAM to store log data in scenarios where cost is not a concern. The save instruction information can be information indicating that the log data should be stored in MRAM. In an embodiment of the present invention, if the user instructs to store log data in MRAM, when the SSD experiences an abnormal power outage, the received log data to be stored can be written to the MRAM storage space for log storage, using MRAM as the primary medium for storing log data, thereby achieving rapid writing and persistent storage of log information.

[0075] Step 103: When the cache indication information is received, the log data is written into the MRAM storage space for log cache.

[0076] In actual applications, the cost of MRAM is relatively high. In order to reduce costs, the total capacity of MRAM in the SSD system is smaller than that of DRAM and NAND. In order to improve the reliability of the SSD system, the storage space must also be used to save other data such as firmware data, so the MRAM storage space used to store log data is limited. Therefore, users can use MRAM to cache log data in scenarios where costs need to be reduced, and not store the log data directly in MRAM. The cache indication information can be information that the user instructs to cache the log data in MRAM. In an embodiment of the present invention, if the user instructs to cache the log data in MRAM, when the SSD is abnormally powered off, the received log data to be saved can be written to the MRAM storage space for log caching, and the MRAM can be used as a cache for the log data, thereby achieving rapid writing and persistent storage of log information.

[0077] In an embodiment of the present invention, when an abnormal power failure occurs in an SSD, log data to be saved can be received, and MRAM can be used as a storage medium for saving the log data, and the log data can be written to the MRAM storage space for log storage; alternatively, MRAM can be used to cache log data, and the log data can be written to the MRAM storage space for log caching, which can achieve the functions of fast writing and persistent storage of log data, thereby utilizing the high performance and non-volatility of MRAM to avoid the problem of easy loss of log data in power failure scenarios, especially abnormal power failure scenarios.

[0078] Reference Figure 2 , shows a flowchart of another method for storing log data according to an embodiment of the present invention. The method is applied to a solid-state drive (SSD), which includes a non-volatile memory (MRAM). The method may specifically include the following steps:

[0079] Step 201: receiving log data to be saved when the SSD is abnormally powered off.

[0080] In an embodiment of the present invention, MRAM can be used for log recording. When an abnormal power failure occurs in the SSD, log data packaged in a predefined format can be received, and the log data packaged in the predefined format can be written into the MRAM storage space for storage.

[0081] Step 202: Obtain the number of logs that can be stored in the MRAM storage space and the serial number information of the log data.

[0082] In an optional embodiment, obtaining the number of logs that can be stored in the MRAM storage space may include: calculating a ratio of the total storage capacity of the MRAM to the log length to obtain the number of logs that can be stored in the MRAM storage space.

[0083] In a specific implementation, the log module on the solid-state drive (SSD) can maintain the current MRAM storage space usage. Specifically, the ratio S / L of the total storage capacity S (in bytes) used to store log data in the MRAM to the fixed length L (in bytes) of each log can be calculated to obtain the number N of logs that can be stored in the MRAM storage space.

[0084] The first 8 bytes of each log entry can be used to store the log's sequence number information. For example, the first log entry has a sequence number of 0, the second log entry has a sequence number of 1, the third log entry has a sequence number of 2, and so on. The sequence number of the nth log entry is n-1, ensuring that the sequence number information does not roll over during the entire life cycle.

[0085] Step 203: Determine the storage location of the log data according to the number of logs, the sequence number information of the log data, and the log length.

[0086] In an optional embodiment, step 203 may include the following sub-steps S11-S12:

[0087] Sub-step S11 , performing a modulo operation on the sequence number information of the log data and the number of logs to obtain a modulo operation result.

[0088] Sub-step S12, calculating the product value of the remainder operation result and the log length, and determining the storage location of the log data to be the log starting storage location offset by the product value.

[0089] Specifically, the storage address of each log entry can be determined according to P = X%N×L (in bytes), where X is the log entry's sequence number, N is the number of logs that can be stored, and L is the log length. X%N represents the modulo operation of the log entry's sequence number and the number of logs that can be stored. For example, the first log entry is stored at a 0-byte offset from the starting position, and the second log entry is stored at a 1-byte offset from the starting position.

[0090] Step 204: write the log data into the MRAM storage space for storage according to the storage location.

[0091] In an embodiment of the present invention, log data can be written to the MRAM storage space for storage according to the storage location of the log data. When the nth log is stored, the MRAM space is full. According to the storage location P = X% N × L, new log data can be re-recorded from the starting position, overwriting the oldest log. Each time a round is filled, it will switch back to the starting position and restart recording. For example, if the number of logs that can be stored in the MRAM space is 100, when the 101st log is stored, the sequence number of the log is 100. According to P = X% N × L, the remainder operation results in a calculation result of 0. It can be determined that the storage location of the 101st log data is 0 bytes offset from the starting position. Then, the 102nd log is stored. The sequence number of the log is 101. According to P = X% N × L, the remainder operation results in a calculation result of 1. It can be determined that the storage location of the 102nd log data is L bytes offset from the starting position. Therefore, the first log data is overwritten by the 101st log data, and the second log data is overwritten by the 102nd log data.

[0092] When log export is required, the locations P1 and P0 of the log entries with the largest and smallest serial numbers can be found by scanning, i.e., the addresses of the latest and oldest log entries, respectively. When P1 is greater than P0, it indicates that the log data stored in the MRAM space has not been overwritten by new log data, and the data in the range [P0, P1] can be exported as log data. When P1 is less than P0, it indicates that the log data stored in the MRAM space has been partially or completely overwritten by new log data, and the data in the ranges [P0, S] and [0, P1] can be exported as log data in sequence.

[0093] In an embodiment of the present invention, when an abnormal power failure occurs in the SSD, by receiving the log data to be saved, using MRAM as the storage medium for saving the log data, and writing the log data into the MRAM storage space for log storage, the log data can be quickly written and persistently saved. This can utilize the high performance and non-volatility of MRAM to avoid the problem of easy loss of log data in power failure scenarios, especially abnormal power failure scenarios.

[0094] Reference Figure 3 , shows a flowchart of another method for storing log data according to an embodiment of the present invention. The method is applied to a solid-state drive (SSD). The solid-state drive includes a non-volatile memory (MRAM), which also includes a flash memory (NAND). The MRAM includes at least two log buffer areas for caching log data. The method may specifically include the following steps:

[0095] Step 301: receiving log data to be saved when the SSD is abnormally powered off.

[0096] In an embodiment of the present invention, MRAM+NAND can be used for logging. Specifically, MRAM storage space can be used for write caching of log data and storage of management data, and NAND can be used for persistent storage of large-capacity log data. When an SSD experiences an abnormal power outage, log data packaged in a predefined format can be received, and then the predefined log data packaged in the predefined format can be written to the MRAM storage space for caching, and then further written to the NAND for persistent storage.

[0097] At least two log buffer areas can be divided in the MRAM storage space for caching log data. For example, two log buffer areas can be divided, each of which can cache log data of a page size, and ping-pong receives log data sent by the upstream module.

[0098] Step 302: Acquire the usage status of the at least two log buffer areas, and determine the log buffer area with a usage status of a data receiving state as the target buffer area.

[0099] The usage status of the log buffer area may include the data receiving state active state, data flushing state and idle state idel state. In the embodiment of the present invention, the usage status of each log buffer area can be obtained, and the log buffer area with the data receiving state active state is determined as the target buffer area.

[0100] Step 303: Write the log data into the target buffer area.

[0101] In an embodiment of the present invention, log data can be written to the target cache area. For example, log cache area A can receive log data at the starting moment and be defined as active. The active log cache area can continue to receive log data until a page is filled.

[0102] Step 304: When the target cache area is full, the log data in the target cache area is flushed to the NAND for persistent storage.

[0103] In an optional embodiment, while flushing the log data in the target cache area to the NAND for persistent storage, it may also include: switching the use state of the target cache area from a data receiving state to a data flushing state, and switching to the next log cache area to receive log data, and switching the use state of the next log cache area to a data receiving state; after flushing the log data in the target cache area to the NAND for persistent storage, it may also include: switching the use state of the target cache area from a data flushing state to an idle state.

[0104] In the specific implementation, when cache area A is full, the data in cache area A can be flushed to NAND for persistent storage. At the same time, the state of cache A is switched to flush, and cache B is switched to receive log data sent by the upstream module, and cache B is switched to active. When the flush command is completed and returned, the state of cache area A can be switched from flush to idel.

[0105] In an optional embodiment, the MRAM is also used to store metadata. After the log data in the target cache area is flushed to the NAND for persistent storage, the method may further include: obtaining the location information of the log data written on the NAND, the current usage information of the NAND storage space, and the current usage status of each log cache area; saving the location information of the log data written on the NAND, the current usage information of the NAND storage space, and the current usage status of each log cache area to the metadata, so that the MRAM manages the log data.

[0106] In the MRAM storage space, not only can at least two log buffer areas be allocated for caching log data, but part of the storage space can also be allocated for storing metadata. The metadata can include management data such as the usage of each log buffer area, the location where log data is written to the NAND, and NAND space usage information. NAND flash memory can be managed in units of blocks, and the header and tail information of log data can also be recorded in the metadata. When all blocks are full, the oldest block can be erased to free up new space for storing log data and update the MRAM metadata information at the same time.

[0107] In an embodiment of the present invention, when an SSD experiences an abnormal power outage, by receiving log data to be saved and using MRAM as a cache for the log data, the log data is first written to the MRAM storage space for caching and then written to the NAND for persistent storage. This allows for rapid writing and persistent storage of log data, thereby utilizing the high performance and non-volatility of MRAM to avoid the problem of log data being easily lost in power outage scenarios, especially abnormal power outage scenarios. In an embodiment of the present invention, MRAM can store cached data and metadata, and these data are relatively small, at the level of 10KB. Therefore, only a very small capacity of MRAM is required to implement the logging function, greatly reducing the required MRAM capacity.

[0108] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0109] Reference Figure 4 , shows a structural block diagram of a log data storage device provided by an embodiment of the present invention. The device is applied to a solid-state drive (SSD). The solid-state drive includes a non-volatile memory (MRAM), and specifically may include the following modules:

[0110] The data receiving module 401 is configured to receive log data to be saved when the SSD is abnormally powered off;

[0111] The log saving module 402 is configured to write the log data into the MRAM storage space for log saving upon receiving the saving instruction information;

[0112] The log cache module 403 is configured to write the log data into the MRAM storage space for log cache upon receiving the cache indication information.

[0113] In an optional embodiment, the log storage module includes:

[0114] An information acquisition submodule, used to obtain the number of logs that can be stored in the MRAM storage space and the serial number information of the log data;

[0115] A location determination submodule, configured to determine a storage location of the log data based on the number of logs, the sequence number information of the log data, and the log length;

[0116] According to the storage location, the log data is written into the MRAM storage space for storage.

[0117] In an optional embodiment, the information acquisition submodule includes:

[0118] The log quantity calculation unit is used to calculate the ratio of the total storage capacity of the MRAM to the log length, and obtain the number of logs that can be stored in the MRAM storage space.

[0119] In an optional embodiment, the position determination submodule includes:

[0120] a modulo operation unit, configured to perform a modulo operation on the sequence number information of the log data and the number of logs to obtain a modulo operation result;

[0121] The product calculation unit is used to calculate the product value of the remainder operation result and the log length, and determine the storage location of the log data to be the log starting storage location offset by the product value.

[0122] In an optional embodiment, the solid-state drive further includes a NAND flash memory, the MRAM includes at least two log cache areas for caching log data, and the log cache module includes:

[0123] A usage status acquisition submodule is configured to acquire the usage status of the at least two log buffer areas, and determine the log buffer area whose usage status is a data receiving state as a target buffer area;

[0124] A cache writing submodule, configured to write the log data into the target cache area;

[0125] The flush module is used to flush the log data in the target cache area to the NAND for persistent storage when the target cache area is full.

[0126] In an optional embodiment, while flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0127] The flushing state switching submodule is used to switch the use state of the target buffer area from the data receiving state to the data flushing state, and switch to the next log buffer area to receive log data, and switch the use state of the next log buffer area to the data receiving state;

[0128] After flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0129] The idle state switching submodule is used to switch the use state of the target cache area from the data flushing state to the idle state.

[0130] In an optional embodiment, the MRAM is further used to store metadata, and after flushing the log data in the target cache area to the NAND for persistent storage, the method further includes:

[0131] A usage information acquisition submodule is used to obtain the location information of the log data written in the NAND, the current usage information of the NAND storage space, and the current usage status of each log buffer area;

[0132] The log management submodule is used to save the location information of the log data written in the NAND, the current usage information of the NAND storage space, and the current usage status of each log buffer area into metadata, so that the MRAM can manage the log data.

[0133] In an embodiment of the present invention, when an abnormal power failure occurs in an SSD, log data to be saved can be received, and MRAM can be used as a storage medium for saving the log data, and the log data can be written to the MRAM storage space for log storage; or, MRAM can be used to cache log data, and the log data can be written to the MRAM storage space for log caching, thereby achieving the functions of fast writing and persistent storage of log data, thereby utilizing the high performance and non-volatility of MRAM to avoid the problem of easy loss of log data in power failure scenarios, especially abnormal power failure scenarios.

[0134] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0135] An embodiment of the present invention further provides an electronic device, including:

[0136] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned log data storage method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0137] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned log data storage method embodiment are implemented, and the same technical effects can be achieved. To avoid repetition, they are not described here.

[0138] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0139] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0140] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0141] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0142] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0143] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0144] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0145] The above describes in detail a log data storage method, device, electronic device, and storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only intended to help understand the method and core ideas of the present invention. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.

Claims

1. A log data storage method, characterized in that: The method is applied to a solid-state drive (SSD), wherein the solid-state drive includes a non-volatile memory (MRAM), and the method includes: When the SSD is abnormally powered off, receiving log data to be saved; When the save instruction information is received, the log data is written into the MRAM storage space for log storage; When receiving the cache indication information, writing the log data into the MRAM storage space for log caching; The solid-state drive further includes a NAND flash memory, and the MRAM includes at least two log buffer areas for caching log data; and writing the log data into the MRAM storage space for log buffering includes: Acquire the usage status of the at least two log buffer areas, and determine the log buffer area with a usage status of a data receiving state as the target buffer area; Writing the log data into the target buffer area; When the target cache area is full, the log data in the target cache area is flushed to the NAND for persistent storage; While flushing the log data in the target cache area to the NAND for persistent storage, the method further includes: Switching the use state of the target buffer area from the data receiving state to the data flushing state, switching to the next log buffer area to receive log data, and switching the use state of the next log buffer area to the data receiving state; After flushing the log data in the target cache area to the NAND for persistent storage, the method further includes: The use state of the target cache area is switched from a data flushing state to an idle state.

2. The method according to claim 1, characterized in that Writing the log data into the MRAM storage space for log storage includes: Obtain the number of logs that can be stored in the MRAM storage space and the serial number information of the log data; Determining a storage location for the log data based on the number of logs, the sequence number information of the log data, and the log length; According to the storage location, the log data is written into the MRAM storage space for storage.

3. The method according to claim 2, characterized in that Obtaining the number of logs that can be stored in the MRAM storage space includes: The ratio of the total storage capacity of the MRAM to the log length is calculated to obtain the number of logs that can be stored in the MRAM storage space.

4. The method according to claim 2, characterized in that The determining the storage location of the log data according to the number of logs, the sequence number information of the log data, and the log length includes: Performing a modulo operation on the serial number information of the log data and the number of logs to obtain a modulo operation result; The product value of the remainder operation result and the log length is calculated, and the storage location of the log data is determined to be the location where the log start storage location is offset by the product value.

5. The method according to claim 1, characterized in that The MRAM is also used to store metadata. After the log data in the target cache area is flushed to the NAND for persistent storage, the method further includes: Obtaining location information of the log data written on the NAND, current usage information of the NAND storage space, and current usage status of each log buffer area; The location information of the log data written in the NAND, the current usage information of the NAND storage space, and the current usage status of each log buffer area are saved in metadata, so that the MRAM manages the log data.

6. A log data storage device, characterized in that: The device is applied to a solid-state drive (SSD), wherein the solid-state drive includes a non-volatile memory (MRAM), and the device includes: A data receiving module, configured to receive log data to be saved when the SSD is abnormally powered off; A log saving module is configured to write the log data into the MRAM storage space for log saving upon receiving the saving instruction information; A log cache module is configured to write the log data into the MRAM storage space for log cache upon receiving cache indication information; The solid-state drive further includes a NAND flash memory, and the MRAM includes at least two log buffer areas for caching log data; the log buffer module includes: A usage status acquisition submodule is configured to acquire the usage status of the at least two log buffer areas, and determine the log buffer area whose usage status is a data receiving state as a target buffer area; A cache writing submodule, configured to write the log data into the target cache area; A flush module is used to flush the log data in the target cache area to the NAND for persistent storage when the target cache area is full; While flushing the log data in the target cache area to the NAND for persistent storage, the method further includes: The flushing state switching submodule is used to switch the use state of the target buffer area from the data receiving state to the data flushing state, and switch to the next log buffer area to receive log data, and switch the use state of the next log buffer area to the data receiving state; After flushing the log data in the target cache area to the NAND for persistent storage, the method further includes: The idle state switching submodule is used to switch the use state of the target cache area from the data flushing state to the idle state.

7. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the log data storage method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the log data storage method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • A method for accelerating log file saving and recovery of solid-state storage device base on STT-MRAM

    CN108959589A

  • A STT-MRAM-based solid-state memory device power-off recovery method

    CN109284070A